From patchwork Wed Oct 21 22:04:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 318883 Delivered-To: patch@linaro.org Received: by 2002:a92:d1d1:0:0:0:0:0 with SMTP id u17csp2541878ilg; Wed, 21 Oct 2020 15:05:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1GEMPA5uywp+zj8MHZ4baTAIEONMoaq5+RZIIYQ4BZnKtMOVPn6llFLaASyOwjTJLhPpY X-Received: by 2002:a17:906:e42:: with SMTP id q2mr2267180eji.261.1603317902395; Wed, 21 Oct 2020 15:05:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603317902; cv=none; d=google.com; s=arc-20160816; b=DDznPPBYLwf36VITTPNTKLsBBuyM9Tlje+tDApFKGDww1qc+F7SXvypn/eyLXYIQa/ I81EIFRZHq/2JXTU4ycuMlr36ySvaP4z2xnsl9R6LiaFMWalyMUcsWaeLsKS+sc/tDhV eEbf0jBM4pfGELrW4bfV43bzNOEZGxM+Tqc1xK6tjPSK6WBgUFBkUhoIb4WLHXwUSect 1vge72C5Vx8L0VB6idTnChyy3iCLixswvKeUcscXGi1KadPdIJ46zJ+OWL8b6cP975eI fXC/GUeQz6sHhE7OPXcxzwAvec1IcLI0Ra6Y7iVgT2fhTRaheiR1Mil1m/U8WjHeZQ3b 6AsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uu7HxEIYTR4YnHXAF0haZ8++KKLp505mc93v5AHYjOk=; b=lwcynbj3dzY8DHfThikxaDh5DjerlnrVxpFhUWYumdASdshisC+ILBYrhheH95bCR8 OHm4hYVFsEOSLQlkV32pUpgaKLfAoppG/gMX5rWbfaxWSgnJ/atywJ2whD1m9wGuzwm8 l+KTtQE6eTNewCpIm35d6NNdYzTRqfohQjt5L1FWdT9sktyhtijD0ZXWWHPo/fNxwU0V qDhlcmWwaT9rYXPFsY9gRRYljBe8azl3yr4huJV7WPG8MGpb4KMOlc4gO/NtKKaRlsKX A8xt3n0HmCqdENaCK+O3TvGa58zJg5LB9Le4hH7dwQ2PfK/sGsW7updl49xKJwaVTg8c veiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="F/o8ZktM"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id t27si2144164edt.158.2020.10.21.15.05.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 15:05:02 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="F/o8ZktM"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 895A78243D; Thu, 22 Oct 2020 00:04:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="F/o8ZktM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 20A4A82435; Thu, 22 Oct 2020 00:04:41 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,T_SPF_HELO_TEMPERROR,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C1551823DD for ; Thu, 22 Oct 2020 00:04:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ed1-x542.google.com with SMTP id l16so4126763eds.3 for ; Wed, 21 Oct 2020 15:04:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uu7HxEIYTR4YnHXAF0haZ8++KKLp505mc93v5AHYjOk=; b=F/o8ZktMS6e7Q5RzhvQ873PBHY5B9A+oK6OMrS7Sxkgce04mQkA4C8CN4L1wiNyUXz giD1vKR0epn0q7MoS1Bxn7Ax04whqyjhGd3M9KBLgIm7QWEghqesy7KCpcLbsB0MOmtS 0nbzbIePR2VW+N6goTzHi5SK1C5KJJ61bYtVFESngZZGbpkTyk8Pshk4/WkwYy2cksOp 0m0MTRjKs7Te7RzKRMLXCRreHR1i7lZV+75+LqxyiO3sHHcrHsqHUfyEJTspqqcNS+Hv UIoC1JjOSc8nsaKkoT4Z2f9KaHzP5j5SnSOFK1aczGliTWlejMYMCqdCTtFijmpXWSWH 6Bow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uu7HxEIYTR4YnHXAF0haZ8++KKLp505mc93v5AHYjOk=; b=o7OnNSuCrdIs2KBb5/dfh4V87uPm7qYjlkTLt7hLbSGayA9uif6uqPpwAclDZOI76y VGqsKqe8mUcEVqE8xrTGJjr5/yURO4C9uTgeu29/gnvzTRiohYDRmRm+W1MSRDVfL25z h/vaZC6yQdUU5TbU12ezPRWqdRWY6OmhLiEoBvYdoQv+kdcYO2M21MRY04SKVKF/M9SH r2R7VnIPLHbdn9hX/7avrP2Tvwx+9hDauoR3fLc5gwqCZjZk+HXkQ76cJrTGewsNDq0C 9XmBK6teQ8qhCcwRDifCoXEhskZqHAQxviWVEFDd0Jy/1fgS+WE7l5fkvLoKuuFNlmyt w0ig== X-Gm-Message-State: AOAM5305pUKU2xnstJHYgPtlRC24/tvNqi+9o+xILgJ+IcxGyRasva9f sOU665OwrMA/NhW+1dLCZiEdyd6h/W2qsg== X-Received: by 2002:a50:ab86:: with SMTP id u6mr5149735edc.158.1603317868087; Wed, 21 Oct 2020 15:04:28 -0700 (PDT) Received: from apalos.home ([2a02:587:4615:c071:2e56:dcff:fe9a:8f06]) by smtp.gmail.com with ESMTPSA id g3sm2586663eds.56.2020.10.21.15.04.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 15:04:27 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de, xypron.glpk@gmx.de Cc: agraf@csgraf.de, Ilias Apalodimas Subject: [PATCH 2/2 v2] efi_loader: Disable devices before handing over control Date: Thu, 22 Oct 2020 01:04:21 +0300 Message-Id: <20201021220421.1926180-2-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021220421.1926180-1-ilias.apalodimas@linaro.org> References: <20201021220421.1926180-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean U-Boot Driver Model is supposed to remove devices with either DM_REMOVE_ACTIVE_DMA or DM_REMOVE_OS_PREPARE flags set, before exiting. Our bootm command does that by explicitly calling calling "dm_remove_devices_flags(DM_REMOVE_ACTIVE_ALL);" and we also disable any USB devices. The EFI equivalent is doing none of those at the moment. As a result probing an fTPM driver now renders it unusable in Linux. During our (*probe) callback we open a session with OP-TEE, which is supposed to close with our (*remove) callback. Since the (*remove) is never called, once we boot into Linux and try to probe the device again we are getting a busy error response. Moreover all uclass (*preremove) functions won't run. So let's fix this by mimicking what bootm does and disconnect devices when efi_exit_boot_services() is called. Signed-off-by: Ilias Apalodimas --- changes since v1: - Add a patch sorting the .h files inclusions - Fix compilation errors for sandbox_spl_defconfig - TravisCI: https://travis-ci.com/github/apalos/u-boot/builds/191447335 lib/efi_loader/efi_boottime.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.28.0 Reviewed-by: Heinrich Schuchardt diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 2896c3ea5aa8..b26ac9fbfc79 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include #include #include @@ -15,6 +17,7 @@ #include #include #include +#include #include #include @@ -1993,7 +1996,10 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle, list_del(&evt->link); } + if IS_ENABLED(CONFIG_USB_DEVICE) + udc_disconnect(); board_quiesce_devices(); + dm_remove_devices_flags(DM_REMOVE_ACTIVE_ALL); /* Patch out unsupported runtime function */ efi_runtime_detach();