Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp850195rwb; Tue, 4 Oct 2022 11:30:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6M8aojUJfrpDu1iYsZCJHAKudAVLI9jV1BWoP86KL2CTYWwrSErEdDvKCGTLcSFlYOUFuN X-Received: by 2002:a05:6402:847:b0:453:944a:ba8e with SMTP id b7-20020a056402084700b00453944aba8emr24472928edz.326.1664908234980; Tue, 04 Oct 2022 11:30:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664908234; cv=none; d=google.com; s=arc-20160816; b=IKYirOo4BuQ5FI2poxX5kS5SqfH5q0q8X/kY9eT9qpUiCklIF9HztdtTIEDCuonpbg pp1ussisdmO7R/0wwCEnQ1r4HbxEU4LoE0BrCDm8hu/sth6+aASKrqjMpyOxBuWsqUTZ wHwc58LRZZJpF64ltXNUxLNiBjLDf6HnFz+RIRdX7/JcmyOtaHvSHT3kgGWU19kUy/pA nQ6fnHaAhdM6S6vqtSsk7koS3xrKj4a11VzNYeVY3jcYNvpOk5njs6mmwWJFEydRso4j RqcNxmto8dRY1edmNjpDZBK9VDqcUkmr/IUkHl4L3x2tKDobdyEaQjNkqDhSou99gusr Zd+g== 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=j1co2OtJjD7/vRKiHmQIV5tJWRkOaG0PZ91t7wBXB08=; b=SHUk7GptFB6CxfHsxJV3rj0uemAvvExCxo1dS0jLwTo+xcP+WHVtWWUVhYFSeFYFH+ tiIM5+DweWsMnMm8uIzkOrI/pnkSr0obQK+RucHa9qh7IxDxVlI8uDV2fBdKgafnY7kR TE9asiuycETUbYJE/7u3HU+kRLxL1on6305g4y+KGqHHKT2LFwedn/2jJ95O4qFXW6y3 UljECZtfdbIBB7a20Cey7vCtjd47FNtUxqKTZuvOz9aT65aCVP+Vmfd+/LSsJS+WyrAo 0FReEJqhK1ag8WArQL84T39uu5gHZI7IpPNoWJ4FNcGcZexUPCI4zQsfnPC3Odj12Jqy bwEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@invisiblethingslab.com header.s=fm2 header.b=buVrn8e+; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=r4NdtuS3; 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 hc41-20020a17090716a900b007707aab3171si14113521ejc.848.2022.10.04.11.30.09; Tue, 04 Oct 2022 11:30:34 -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=buVrn8e+; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=r4NdtuS3; 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 S229804AbiJDRqV (ORCPT + 99 others); Tue, 4 Oct 2022 13:46:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229921AbiJDRqP (ORCPT ); Tue, 4 Oct 2022 13:46:15 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5839265661; Tue, 4 Oct 2022 10:46:13 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id E91E85C0061; Tue, 4 Oct 2022 13:46:09 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 04 Oct 2022 13:46:09 -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=1664905569; x= 1664991969; bh=j1co2OtJjD7/vRKiHmQIV5tJWRkOaG0PZ91t7wBXB08=; b=b uVrn8e+X1yqcOFjSdZ2m0JtalxHee6ojtu6uxKe2dDP+PxZK0d4EdjiwOzV1qD4P DRVAYGUMQ46TQC79a8IgLyHmrHkLVd2QC5Vh5U1sE6FSxORGTmm75y1OZPH4v3Vd YOLDu2vqHupepX7WrjQlIbP64gbNo74NPBaE9ptLsTN4N/H6wPSoX22bYYkocbQQ eBJdolRQRQ+gKVKXvoWTloGYDF96rStVcIi3tu6nLwCY7+e5cYf9AS6ic37tTWwB OPGG3OG53Cp8Uk+VotAEbArlv+FOPRBZJyJbmdwdz7CeQ3B8je1pPvah42Ro7xAq mdOcG7DJ4DYF4qSZTmcaA== 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=1664905569; x=1664991969; bh=j1co2OtJjD7/vRKiHmQIV5tJWRkO aG0PZ91t7wBXB08=; b=r4NdtuS3BOGr1usAHz1Iam2a95O9RnYq7uMZgqz6NPeC nmMgdbtqLBMJnydm3qRndZlnAI3JbV9SfcpY8aOYVwUJAkvZ9kc6sVQzglGI2yhO QmeBnPcU9NGkjl0yaJYbbzUTK490oMT9O3dRHta7GTJaJIAk4e6Kjse5jHVJUY/n fPlp2xHEHi2pVd/ti0qIJSASo78Tq4DoB2X6G9Wk9/t6e2S7Asj84T4bUfXXxHmS KhReL40qlqq/E5fWtontKTbYRpX42iVuQxjz3SikwRfvGUmaTgpduEcpwdsD2eoY KuSYRzIidx4UXsGyaNuTZeBYOGE3wIjELfzfOpmR5A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeeiuddguddujecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttdejnecuhfhrohhmpeffvghm ihcuofgrrhhivgcuqfgsvghnohhurhcuoeguvghmihesihhnvhhishhisghlvghthhhinh hgshhlrggsrdgtohhmqeenucggtffrrghtthgvrhhnpedvjeetgeekhfetudfhgfetffeg fffguddvgffhffeifeeikeektdehgeetheffleenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpeguvghmihesihhnvhhishhisghlvghthhhinhhg shhlrggsrdgtohhm X-ME-Proxy: Feedback-ID: iac594737:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 4 Oct 2022 13:46:08 -0400 (EDT) Date: Tue, 4 Oct 2022 11:46:59 -0400 From: Demi Marie Obenour To: Jan Beulich Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Kees Cook , Anton Vorontsov , Colin Cross , Tony Luck , Marek =?utf-8?Q?Marczykowski-G=C3=B3recki?= , Ard Biesheuvel Subject: Re: [PATCH v4 1/2] Avoid using EFI tables Xen may have clobbered Message-ID: References: <282a225d-8782-0321-6f0e-19dd4510dc42@suse.com> <01d22092-8292-8ed7-ece7-9ca32d15bbce@suse.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="lgxbz4vBgheHS+D8" Content-Disposition: inline In-Reply-To: <01d22092-8292-8ed7-ece7-9ca32d15bbce@suse.com> 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 --lgxbz4vBgheHS+D8 Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Date: Tue, 4 Oct 2022 11:46:59 -0400 From: Demi Marie Obenour To: Jan Beulich Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Kees Cook , Anton Vorontsov , Colin Cross , Tony Luck , Marek =?utf-8?Q?Marczykowski-G=C3=B3recki?= , Ard Biesheuvel Subject: Re: [PATCH v4 1/2] Avoid using EFI tables Xen may have clobbered On Tue, Oct 04, 2022 at 10:22:13AM +0200, Jan Beulich wrote: > On 01.10.2022 02:30, Demi Marie Obenour wrote: > > On Fri, Sep 30, 2022 at 08:27:09PM +0200, Ard Biesheuvel wrote: > >> On Fri, 30 Sept 2022 at 19:12, Demi Marie Obenour wrote: > >>> On Fri, Sep 30, 2022 at 06:30:57PM +0200, Ard Biesheuvel wrote: > >>>> I know very little about Xen, but based on the context you provided = in > >>>> this thread, I'd say that the best approach from the Xen side is to > >>>> convert all EfiBootServicesData regions that have configuration tabl= es > >>>> pointing into them into EfiAcpiReclaimMemory. > >>> > >>> Should Xen convert the entire region, or should it try to reserve only > >>> the memory it needs? The latter would require it to parse the > >>> configuration tables. Is there a list of configuration tables that c= an > >>> legitimately be in EfiBootServicesData regions? > >>> > >> > >> Not really, no. So you would have to convert the entire region > >> /unless/ Xen knows the GUID, and therefore knows how to derive the > >> size of the table, allowing it to reserve memory more conservatively. > >> However, I doubt whether this is worth it: splitting entries implies > >> rewriting the memory map, which is a thing I'd rather avoid if I were > >> in your shoes. > >=20 > > I actually wonder if Xen needs to reserve *all* of EfiBootServicesData. > > The reason is that some (probably buggy) firmware may store ACPI tables > > there, and Xen does not have an ACPI implementation. >=20 > We already have the -mapbs option as a workaround in such situations. The problem is that there is no way for the user to know when it is needed. One option would be for dom0 to print a warning in the kernel log if it needs to ignore a table due to it being in EfiBootServicesData. > > From my > > perspective, a much safer approach would be to pass all of > > EfiBootServicesData memory directly to dom0, and have dom0 give Xen back > > what it doesn=E2=80=99t wind up using. That allows dom0=E2=80=99s memo= ry reservation > > code to work properly, which it currently does not. >=20 > As said already on a different thread: Giving memory to domains (incl > Dom0) isn't related to their original memory type (neither EFI's nor > E820's); the needed memory is taken from the general page allocator > (with one exception for initrd, to avoid unnecessary copying around of > data). Hence what you propose would end up as an (imo) awful hack in > Xen. I also don't see how this relates to "dom0=E2=80=99s memory reservat= ion > code", but I'm sure you can clarify that for me. Linux has a function called efi_mem_reserve() that is used to reserve EfiBootServicesData memory that contains e.g. EFI configuration tables. This function does not work under Xen because Xen could have already clobbered the memory. efi_mem_reserve() not working is the whole reason for this thread, as it prevents EFI tables that are in EfiBootServicesData from being used under Xen. A much nicer approach would be for Xen to reserve boot services memory unconditionally, but provide a hypercall that dom0 could used to free the parts of EfiBootServicesData memory that are no longer needed. This would allow efi_mem_reserve() to work normally. --=20 Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab --lgxbz4vBgheHS+D8 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEdodNnxM2uiJZBxxxsoi1X/+cIsEFAmM8VY8ACgkQsoi1X/+c IsHLdA/+LM4HOMK+UqW8ug41g4/DBfgbjzO9EIOgBAXcDsotBsE2hgv+29Nd8k2/ x08K8YAFtt6tgef77/ZH2pFmtCbY3v9AbO+Y0AUn6TD8ownHkXRvQZcH4f+/q1qu I/eMEvBHn2+Tcl5NLk8JbIj+iufNcZsgvuPxO5Bn6L6cs3uLKey68T+iBN1djFNc LrhecxdhCSa1096qkvxAn6d7RRQcplv1//S4LXrCjt3q77T4Dg7y8sPcqDQw98W1 QW+6l9GDwVr0EDWse00UkigGhQK+GP3bEv3ucJoxiDFYCAQy24sOTBL/m4wfcZmv t/43wgXv9010fUACW0Fl0kgKPWMKCMfUM1d7VLEj4GkWLaN41C8eZc5EBj5p37Df AR1xqfFhR3X50gACUUyoUVfLw2LbohUdzmqncPIAhFOYnrZ4/EfaQjHEq1EMHsPi X0ocJZhndjM12OXOgLpYdijTZ/1fl6LtYmEULzGdDP1ANinE85ihHsBmLOfUMF+R MOsy9XDSKzYpi1naZ0Pt+hJzEsEmzoxV7JytqBSxCKihGlnsFf6PPF+eKa3UnFyp ji4rdgWVtUqhrPa8SWHaxiNhTnNJSZ7VDYbj7hkwejS6dk08ZXmcfHmKDRo3FflR Y4PVJCITmoxzY63hLDFPN5bDwiEYqRAVlHpsix40rjxGDMDq7EM= =u0CQ -----END PGP SIGNATURE----- --lgxbz4vBgheHS+D8--