Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp4249770rwb; Fri, 30 Sep 2022 15:34:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7z3J0ck2JRUWXxwHKPsQlAxEmO3RogyllGFq5xZB7h6TR6z4J9dy4L0Oawyqwfl91/t0xC X-Received: by 2002:a17:907:2c74:b0:77d:5a0e:bb8f with SMTP id ib20-20020a1709072c7400b0077d5a0ebb8fmr7678572ejc.579.1664577256696; Fri, 30 Sep 2022 15:34:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664577256; cv=none; d=google.com; s=arc-20160816; b=eZbZunFD1VYe+gaBpjB98Ma3UA7qtLGVJohFsQCeUYPDJ4s8OEGEKFl4MRc8RH86gk Rvf78fpqe4RGHB2/ixnGp3zl5BBI6yu1Rc2CGzLe8mO2fwcJ2m8R3ubkvsQLLz2ZLuGW LGpTogAlsIy3nbVou9MiT16VjjF4SW6CTISBuRfOnTTKm9htot6vXoOiDvTwaUOXKspY IfFxMr79MVZT6gDYGNNsJUkl5ULGOarzlW7Fl7TqAvjZC2qZWaZ0e+3c+DeNggRbop0t h7tJOtgybzcBfuHtNcTw3vWtqvVzTSQWnQ91F6/GDZCv+LXnhQAUxGX7D8d75KWyh1+y oJWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=RX384jPlUWMAwZzt1xsK9je9R67ehV0OxhWWNtDc/gk=; b=deyvtKaIOqbBHOLITMkkD6ARPfjDNmbpTte5Ww8TaiTKWKKAMR2zEsgBA03fFkj/R8 3LdchEvl09b7dstnl1IxaR2ImqW7T8NznH55O170cnRG9An2ZJA4vEcDTrIfufM1P/Ni CBzGRJbtuGJRT/2HUk/ltjTGMwRg3kZjJdpGbrpSbi2azIeprd7VOFanTWEiO4rRvnyc 3GMBhuMV/XsQQAVe63RHfTkjXa8sRCxc/LKYy5nHfLpj6NkWPEqQTJr2pvAfLP4M6q4v xAPHMeBFLfGbcVGZmD2+jbudSRyFnugMcFill5uQcxO/b0FljSAizWuWJPVa9AbOFooR AA3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@invisiblethingslab.com header.s=fm2 header.b=kpD7cEtj; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=pXvbizsE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dd13-20020a1709069b8d00b0073dced7204bsi2796450ejc.767.2022.09.30.15.33.51; Fri, 30 Sep 2022 15:34:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@invisiblethingslab.com header.s=fm2 header.b=kpD7cEtj; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=pXvbizsE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232693AbiI3WX6 (ORCPT + 99 others); Fri, 30 Sep 2022 18:23:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231237AbiI3WX4 (ORCPT ); Fri, 30 Sep 2022 18:23:56 -0400 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D33341A2A0C; Fri, 30 Sep 2022 15:23:54 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id D443932009A8; Fri, 30 Sep 2022 18:23:50 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Fri, 30 Sep 2022 18:23:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= invisiblethingslab.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1664576630; x= 1664663030; bh=RX384jPlUWMAwZzt1xsK9je9R67ehV0OxhWWNtDc/gk=; b=k pD7cEtjbCxE5nVCLEl/0YbAgI6yENgCfHjBA57XcStaWJyv6QXYfjknx0W7MDM9t vyh08oGvHiRvNSTvd0utQKRno1Nshjbr9spNXjkMC/phqsttU8kI6ymP8rhVnlFb wvBLEuLRZoa97gJIrQS7IJf2D0Lt02IhT9cFXe2mGjdKvWLLsquf0zddjFCg9wqs ljJ3KS8S+smFRnSJtQPKEh3qYqmnhh3yXxJbDwLEIDNIBeZbBaATmvUXq2c3G/Gh 7KSpgd8PwlvaxA9yj4HHNKXqPfo6Xvrh3Sv5jUuiaVhmSdsjlqmrcxcypHrhOavj w7vFQmrsUbbRMsrHhKItQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1664576630; x=1664663030; bh=RX384jPlUWMAwZzt1xsK9je9R67e hV0OxhWWNtDc/gk=; b=pXvbizsEhFw8zh6954MAZ+w4xmpNnTLvhevaVkLwpVtD Dol0MkD1QAowrlujkHWwpoM68NT8bh31071mehu6aDzo6cvCA7nNgskyILXqo/+I K+euqrbCNOUx3TjUKCEHqhZVprZzEkaXb9YhXVNWm9YfYJE/ljzxS0umjrydjsbA VeB4+N5YrZi+4OfpJLWuuJAjEtcIYJ8ff0+SJyo99UtjDX0HAeXxNJFQUTiAQ5O5 k0sSg3Zi/zkwd+DxNXLIgOmSy6Z4g3ndGSQxuzonARGC/287p8+iZVkhXxtZdviM kZz46uFz29qyznAh/GS+qNH6v8KxWHxsBQtKX+OtDA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeehfedgudduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtjeenucfhrhhomhepffgvmhhi ucforghrihgvucfqsggvnhhouhhruceouggvmhhisehinhhvihhsihgslhgvthhhihhngh hslhgrsgdrtghomheqnecuggftrfgrthhtvghrnhepvdejteegkefhteduhffgteffgeff gfduvdfghfffieefieekkedtheegteehffelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepuggvmhhisehinhhvihhsihgslhgvthhhihhnghhs lhgrsgdrtghomh X-ME-Proxy: Feedback-ID: iac594737:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 30 Sep 2022 18:23:49 -0400 (EDT) Date: Fri, 30 Sep 2022 18:22:48 -0400 From: Demi Marie Obenour To: Ard Biesheuvel Cc: Peter Jones , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Kees Cook , Anton Vorontsov , Colin Cross , Tony Luck , Marek =?utf-8?Q?Marczykowski-G=C3=B3recki?= , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org Subject: Re: [PATCH v4 2/2] Support ESRT in Xen dom0 Message-ID: References: <5649176eacda434267f68676f1733d06c572d19e.1664298147.git.demi@invisiblethingslab.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="O0m4X08RcO4y0b4+" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --O0m4X08RcO4y0b4+ Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Date: Fri, 30 Sep 2022 18:22:48 -0400 From: Demi Marie Obenour To: Ard Biesheuvel Cc: Peter Jones , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Kees Cook , Anton Vorontsov , Colin Cross , Tony Luck , Marek =?utf-8?Q?Marczykowski-G=C3=B3recki?= , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org Subject: Re: [PATCH v4 2/2] Support ESRT in Xen dom0 On Fri, Sep 30, 2022 at 11:24:37PM +0200, Ard Biesheuvel wrote: > On Fri, 30 Sept 2022 at 22:59, Ard Biesheuvel wrote: > > > > On Fri, 30 Sept 2022 at 22:21, Demi Marie Obenour > > wrote: > > > > > > On Fri, Sep 30, 2022 at 09:11:19PM +0200, Ard Biesheuvel wrote: > > > > On Fri, 30 Sept 2022 at 20:21, Demi Marie Obenour > > > > wrote: > > > > > > > > > > On Fri, Sep 30, 2022 at 06:36:11PM +0200, Ard Biesheuvel wrote: > > > > > > On Fri, 30 Sept 2022 at 01:02, Demi Marie Obenour > > > > > > wrote: > > > > > > > > > > > > > > fwupd requires access to the EFI System Resource Table (ESRT)= to > > > > > > > discover which firmware can be updated by the OS. Currently,= Linux does > > > > > > > not expose the ESRT when running as a Xen dom0. Therefore, i= t is not > > > > > > > possible to use fwupd in a Xen dom0, which is a serious probl= em for e.g. > > > > > > > Qubes OS. > > > > > > > > > > > > > > Before Xen 4.17, this was not fixable due to hypervisor limit= ations. > > > > > > > The UEFI specification requires the ESRT to be in EfiBootServ= icesData > > > > > > > memory, which Xen will use for whatever purposes it likes. T= herefore, > > > > > > > Linux cannot safely access the ESRT, as Xen may have overwrit= ten it. > > > > > > > > > > > > > > Starting with Xen 4.17, Xen checks if the ESRT is in EfiBootS= ervicesData > > > > > > > or EfiRuntimeServicesData memory. If the ESRT is in EfiBootS= ervicesData > > > > > > > memory, Xen replaces the ESRT with a copy in memory that it h= as > > > > > > > reserved. Such memory is currently of type EFI_RUNTIME_SERVI= CES_DATA, > > > > > > > but in the future it will be of type EFI_ACPI_RECLAIM_MEMORY.= This > > > > > > > ensures that the ESRT can safely be accessed by the OS. > > > > > > > > > > > > > > When running as a Xen dom0, use the new > > > > > > > xen_config_table_memory_region_max() function to determine if= Xen has > > > > > > > reserved the ESRT and, if so, find the end of the memory regi= on > > > > > > > containing it. This allows programs such as fwupd which requ= ire the > > > > > > > ESRT to run under Xen, and so makes fwupd support in Qubes OS= possible. > > > > > > > > > > > > > > Signed-off-by: Demi Marie Obenour > > > > > > > > > > > > Why do we need this patch? I'd expect esrt_table_exists() to re= turn > > > > > > false when patch 1/2 is applied. > > > > > > > > > > efi_enabled(EFI_MEMMAP) is false under Xen, so there needs to be = an > > > > > alternative way to get the end of the memory region containing th= e ESRT. > > > > > That is what this patch provides. > > > > > > > > OK. I don't think we need that to be honest. When running under Xen, > > > > we should be able to assume that the ESRT does not span multiple > > > > memory regions arbitrarily, so we can just omit this check if > > > > !efi_enabled(EFI_MEMMAP) > > > > > > > > IIRC (and Peter would know), we are trying to filter out descriptors > > > > that are completely bogus here: zero lenght, zero address, etc etc.= I > > > > don't think we need that for Xen. > > > > > > Xen doesn=E2=80=99t uninstall bogus ESRTs, so there is no less reason= to worry > > > under Xen than on bare hardware. > > > > That may be true. But if Xen needs dom0 to be able to cross reference > > the EFI memory map, it should provide one (and set EFI_MEMMAP to > > enabled). >=20 > Btw the efi_mem_reserve() for the ESRT is also redundant if it is > guaranteed to be in RT services data or ACPI reclaim memory. It=E2=80=99s needed on bare hardware. On Xen it=E2=80=99s unreachable code. --=20 Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab --O0m4X08RcO4y0b4+ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEdodNnxM2uiJZBxxxsoi1X/+cIsEFAmM3bHMACgkQsoi1X/+c IsELVxAArRvWRhFqD/HZjNwD8miJSVhkUC762UgZ3NMbiQ0XEB+cjEpOxs6cEGWg zyclHhXXkl2SUxuOC/PyIDj5WngwTIHGmGxvWEnq4zr4PAJWYptR1MeAo4zYWU1k dBcBH/GZ8+ofW3hjfQdS9B8mnJQanp4BubEN0wY9mQOPetx8Fh0my7Pz36xVuUhf Nl1QgdrB8+Akmya4m7KN0ZxdMTm+e/QNSWogtsCpNls+nNDo6Rz7rjsKZJVpULQW 3GyptvapCv/tneLk7XgevsTP2FqWIIkV9DHag8HOrMCdv26xkyH2BrRXAYOvMzae N5H6dJYuZsdAnRptOzD74OeRRHo7Jgeb6oiqRSmmVG4VdfSVMrnJ5k4ZoN3tb0bx lBgWDLVQRwoqdYDP6i0d5sf5ZPe+iopD2L1U2+doE8MfNETOxF9BRXolzYS1qwzS w9ypAkP0NymMO2yCpDxm5mpNwyK/fr40SPBx+E0HgqezKAB5JimPuNI2B54Gb7P7 pbn24u3NyLDnEKSMOaDUmaExTVQqfv4vHmhLYnxya0+bWSqzQ1ia/VAI7SfHZqR7 xwOkstQ1VDwSnZsVoZJebsGDEg5G3B3G21MPFuQd2I6G2KPJRQlQG+kqlLn0vV4J rJWlWzvlSQZNtoh0h3HL8+KfiT8ztRBJmDfKnCfxB14LWGOVBHw= =FSrg -----END PGP SIGNATURE----- --O0m4X08RcO4y0b4+--