From nobody Fri Apr 3 10:43:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1774355621; cv=none; d=zohomail.com; s=zohoarc; b=ZU6+Jp+XvyS3RGNR6pmUodYFgjTpxJLvsMz6WOIun9G3CLIHkHboTsLMp08/aXzPDWZ7TYewCCA01AVqihkFs/A/o/lvsp5x3s4uiQTCaAGafAGoQPbeNw9kJnCs7QeJi/nd8JpvPwDcT8XpdnYPMoxUcfpHh44cMp6HeU7g77Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774355621; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aApGw00bRTG9YsHWYvBcAcOhWcCCk5rQkMe0Q+McyP8=; b=Sa53Wyci6hwIY6AQcyUsHkWjArpgmro7/cGkW+sbvl2ZBrF3+lhgiv5QF1JCtBdcncDpU4c20kfYYvoreiuLHg4nyvYLU5TGLlUUVrUarVugiOfXtBbr7dQnp6TFzCLoXJwm2fer6H2/7Sim8Ndf1cm3dW9a9UUII6qrPtXbHjU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1774355621154301.7956278693738; Tue, 24 Mar 2026 05:33:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1260633.1553894 (Exim 4.92) (envelope-from ) id 1w50wr-00055k-Ay; Tue, 24 Mar 2026 12:33:29 +0000 Received: by outflank-mailman (output) from mailman id 1260633.1553894; Tue, 24 Mar 2026 12:33:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w50wr-00055d-87; Tue, 24 Mar 2026 12:33:29 +0000 Received: by outflank-mailman (input) for mailman id 1260633; Tue, 24 Mar 2026 12:33:27 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w50wp-00054y-R0 for xen-devel@lists.xenproject.org; Tue, 24 Mar 2026 12:33:27 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1w50wp-008yL3-6w for xen-devel@lists.xenproject.org; Tue, 24 Mar 2026 13:33:27 +0100 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69c28491-e002-0a2a0a5209dd-0a2a4502c964-30 for ; Tue, 24 Mar 2026 13:33:27 +0100 Received: from [209.85.216.67] (helo=mail-pj1-f67.google.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.55.2) (envelope-from ) id 69c28495-63bb-0a2a45020019-d155d843edb7-3 for ; Tue, 24 Mar 2026 13:33:26 +0100 Received: by mail-pj1-f67.google.com with SMTP id 98e67ed59e1d1-35bb7afdc38so650535a91.1 for ; Tue, 24 Mar 2026 05:33:26 -0700 (PDT) Received: from fedora ([103.2.232.250]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35c031ed04esm2215792a91.12.2026.03.24.05.33.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2026 05:33:24 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774355605; x=1774960405; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aApGw00bRTG9YsHWYvBcAcOhWcCCk5rQkMe0Q+McyP8=; b=JtY+fYDFRURyFGgS4bpLD9TptIZjH9FaN0FJsyacnDZABHBR/qxZ6ZJN6uFPTJaF3A /W1GeINxbO7HJifougO1ZJK6fwlEp19I+uYgjL5jcCe2+njDyPOTgnyOaLk5rmP1ZS5F 9GHPkZGJS0ppklThu0IdEFoIwfHkdZs3A5/wO6qwUjO2d5YZWpsgckf4FJ0Xga5YB65m NleYz5DA4nhSt0F0zxwMBTBAwXyc7jf4KybDFgYhCAjXgXOlH8n6/Lo1cCJxNSLAOcLY +817qJwMTvDM/Fj7QgCT5PssJoKibnD+sCFVMk/IBSMtsQ4apnk5KKw95csNMaSOIkdV oXxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774355605; x=1774960405; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=aApGw00bRTG9YsHWYvBcAcOhWcCCk5rQkMe0Q+McyP8=; b=p+RfmXK6eplp2MAfGQfphr3eKV4EQc9T6/dTcAMwIXXwXou/7BQsNXopYeHnTYA1hf hzYpczt1guk73S1VvwDC09WFaBIX+XVclSgHGJlUK6km4fRaYe8Df9+D0rnZsTkMuN0C 8Om/jL6sz+QUWw0RFvBpBtmlx6lNFrDXP3u5jd9BxKs3hVSPQODxm3KGsYG7fwdkH/zl uw4FkiGKmoQ2JOBu290fs3dv6nhhOv9hZI6jypg3O1wo1G+wR+d3ax5dEHbdHLNrVKDL dt5kYpPke+8wPMV3bTQ71kyKiRwIULcK7DV+8b6MJhFzQ+D9EWbfopo8xrWJ67AZMEZp sXYA== X-Forwarded-Encrypted: i=1; AJvYcCWcqgc02G9T01r3HJ0UXdzYFv7Qem8eozltbENvpnlV9d+mx84EVYDHBGm7C1L2YJbMZFnTs1mMohw=@lists.xenproject.org X-Gm-Message-State: AOJu0YwgYkqswEfTf6TjqmZKMDb/2Zf4TDiwbl7s8GUKNfH1YOfMtRWS UbkuuytBHraHW4QcqxdmHl87dJpt58xrqbf7LW4wVlAjlm2O6V10hgq5y2Aaq2Dz X-Gm-Gg: ATEYQzy5U6V81TFZsruDqeTTybBu7py8wAF7MOWfT+z4+vxjYE/K8sn7KfafgvzH6QB aR+RDhgrdTFzTAqBNT0v2uVbzqIwoTaHFAYe7ODNeBhTA4w/EXFKMNwcCOqYgsdSOzlGOZYgr8t j7otwL7o4w/pQfDFFGBA1ehq5R7gDhD+Yfk+RAX+xe/iTRkT+KW/u961d6WlSUCnWqBcoWgtEAO pxIpiner2Y8AE6xo76WlKQ9d96RiYCC6BXhq3UvdhwnWhX5xkeb+7PrSPNr8uO6inOw2ZNO7/KQ 25N+z/ovIxzLnnHij/CW8pKPEp0ybvMBvi7HSA1u9YZ3y8p1/fxZ1aEWsR9fAGRrnccxticebvk sjVmF+R2Hn83JlOT+GC5rhev1BnLpsIXiEFH0/5QF3QPYVcRrTRvqnwO9jIWx0iVtQL+Yu57yHN NQJpfsIHxsXEkw3tZbfrpROL7ttOeoqld6aNK63o3JnwndbCdkR60TF6wgaqLG2tFFP4TuGS5Cv V8jkg+deEp/zqkqhPeGgF8Y1rXa8aI1wBT+oiGqNk/Nhd/WUBl2m2m2jCaKUtL4et1Fz++bMQ== X-Received: by 2002:a17:90b:4fcd:b0:35b:e553:9cc2 with SMTP id 98e67ed59e1d1-35be5539ff7mr7766870a91.26.1774355604739; Tue, 24 Mar 2026 05:33:24 -0700 (PDT) From: Soumyajyotii Ssarkar To: sarkarsoumyajyoti23@gmail.com, xen-devel@lists.xenproject.org Cc: Andrew Cooper , Jan Beulich , "Daniel P . Smith" , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Soumyajyotii Ssarkar Subject: [PATCH v5 1/3] x86/efi: Add BGRT image preservation infrastructure Date: Tue, 24 Mar 2026 18:03:10 +0530 Message-ID: <20260324123312.11076-2-soumyajyotisarkar23@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260324123312.11076-1-soumyajyotisarkar23@gmail.com> References: <20260324123312.11076-1-soumyajyotisarkar23@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-720697/1774355607-42A84DB8-B697ED9A/0/0 X-purgate-type: clean X-purgate-size: 6310 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1774355622733158500 Content-Type: text/plain; charset="utf-8" Add core EFI boot services code to preserve BGRT (Boot Graphics Resource Table) images during Xen boot. The BGRT contains a pointer to a boot logo stored in BootServicesData memory. Without preservation, this memory is reclaimed causing ACPI checksum errors in dom0. Implementation: - Walk XSDT to locate BGRT table (reusing efi.acpi20 from efi_tables()) - Validate BMP image signature and size constraints (max 16MB) - Allocate EfiACPIReclaimMemory and copy image data - Update BGRT table with new address and recalculate checksum The preservation follows the ESRT pattern, running before ExitBootServices() to ensure image remains accessible. Signed-off-by: Soumyajyotii Ssarkar Reported-by: Jan Beulich=C2=A0 Reported-by: Marek Marczykowski-G=C3=B3recki --- xen/arch/x86/efi/efi-boot.h | 2 + xen/common/efi/boot.c | 133 +++++++++++++++++++++++++++++++++++ xen/common/efi/common-stub.c | 1 + 3 files changed, 136 insertions(+) diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index 42a2c46b5e..0547d845cd 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -910,6 +910,8 @@ void __init efi_multiboot2(EFI_HANDLE ImageHandle, efi_relocate_esrt(SystemTable); + efi_preserve_bgrt_img(); + efi_exit_boot(ImageHandle, SystemTable); } diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 967094994d..47d5b9b2a8 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -1,12 +1,16 @@ #include "efi.h" #include #include +#include +#include +#include #include #include #include #include #include #include +#include #include #include #include @@ -747,6 +751,133 @@ static void __init efi_relocate_esrt(EFI_SYSTEM_TABLE= *SystemTable) efi_bs->FreePool(memory_map); } +typedef struct { + UINT16 signature; + UINT32 file_size; + UINT16 reserved[2]; + UINT32 data_offset; +} __attribute__((packed)) BMP_HEADER; + +static __initdata struct { + bool preserved; + const void *old_addr; + const void *new_addr; + UINTN size; + const char *failure_reason; +} bgrt_info =3D { + /* We would prefer the failure_reason to print */ + .failure_reason =3D "", +}; + +static struct acpi_table_bgrt *__init efi_get_bgrt(void) +{ + const struct acpi_table_rsdp *rsdp; + const struct acpi_table_xsdt *xsdt; + UINTN entry_count; + unsigned int i; + + if ( efi.acpi20 =3D=3D EFI_INVALID_TABLE_ADDR ) + return NULL; + + rsdp =3D (const void *)(UINTN)efi.acpi20; + if ( !rsdp || !rsdp->xsdt_physical_address ) + return NULL; + + xsdt =3D (const void *)rsdp->xsdt_physical_address; + + if ( memcmp(xsdt->header.signature, ACPI_SIG_XSDT, 4) !=3D 0 ) + return NULL; + + if ( xsdt->header.length < sizeof(xsdt->header) ) + return NULL; + entry_count =3D (xsdt->header.length - sizeof(xsdt->header)) / + sizeof(xsdt->table_offset_entry[0]); + + for ( i =3D 0; i < entry_count; i++ ) + { + const struct acpi_table_header *hdr; + + hdr =3D (const void *)xsdt->table_offset_entry[i]; + if ( !hdr ) + continue; + + if ( memcmp(hdr->signature, ACPI_SIG_BGRT, 4) =3D=3D 0 && + hdr->length >=3D sizeof(struct acpi_table_bgrt) ) + return (struct acpi_table_bgrt *)hdr; + } + + return NULL; +} + +#define BMP_SIGNATURE 0x4D42 +#define MAX_BGRT_IMAGE_SIZE (16 * 1024 * 1024) + +static void __init efi_preserve_bgrt_img(void) +{ + struct acpi_table_bgrt *bgrt; + const BMP_HEADER *bmp; + const void *old_image; + void *new_image; + UINTN image_size; + EFI_STATUS status; + UINT8 checksum; + unsigned int i; + + bgrt_info.preserved =3D false; + + bgrt =3D efi_get_bgrt(); + if ( !bgrt ) + { + bgrt_info.failure_reason =3D "BGRT table not found"; + return; + } + + if ( !bgrt->image_address ) + return; + + old_image =3D (const void *)bgrt->image_address; + bmp =3D old_image; + + if ( bmp->signature !=3D BMP_SIGNATURE ) + { + bgrt_info.failure_reason =3D "Invalid BMP signature"; + return; + } + + image_size =3D bmp->file_size; + if ( !image_size || image_size > MAX_BGRT_IMAGE_SIZE ) + { + bgrt_info.failure_reason =3D "Image size exceeds limit"; + return; + } + + /* + * Allocate memory of type EfiACPIReclaimMemory so that the image + * will remain available for the OS after ExitBootServices(). + */ + status =3D efi_bs->AllocatePool(EfiACPIReclaimMemory, image_size, &new= _image); + if ( EFI_ERROR(status) ) + { + bgrt_info.failure_reason =3D "Memory allocation failed"; + return; + } + memcpy(new_image, old_image, image_size); + bgrt->image_address =3D (UINTN)new_image; + bgrt->header.checksum =3D 0; + checksum =3D 0; + + for ( i =3D 0; i < bgrt->header.length; i++ ) + checksum +=3D ((const UINT8 *)bgrt)[i]; + + bgrt->header.checksum =3D -checksum; + + /* Filling the debug struct for printing later */ + bgrt_info.preserved =3D true; + bgrt_info.old_addr =3D old_image; + bgrt_info.new_addr =3D new_image; + bgrt_info.size =3D image_size; +} + /* * Include architecture specific implementation here, which references the * static globals defined above. @@ -1671,6 +1802,8 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE Imag= eHandle, efi_relocate_esrt(SystemTable); + efi_preserve_bgrt_img(); + efi_exit_boot(ImageHandle, SystemTable); efi_arch_post_exit_boot(); /* Doesn't return. */ diff --git a/xen/common/efi/common-stub.c b/xen/common/efi/common-stub.c index 9dc8aa538c..155a973f21 100644 --- a/xen/common/efi/common-stub.c +++ b/xen/common/efi/common-stub.c @@ -19,6 +19,7 @@ unsigned long efi_get_time(void) } void efi_reset_system(bool warm) { } +void __init efi_bgrt_status_info(void) { } int efi_get_info(uint32_t idx, union xenpf_efi_info *info) { -- 2.53.0 From nobody Fri Apr 3 10:43:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1774355626; cv=none; d=zohomail.com; s=zohoarc; b=VQ2gFry2S1RZ7tovxS3vYKOImt+SK5Eu4qWswNeZDt7BvQ4R1tTkoaf0quedziG/PmDsKZLCA2A2kAGi20WOg5B5eRLU5d84mhqI6rakKV3IzlEc7j+tKj6MY87WB26MxmvtkpJmf+IOmsMgQvrDHyA25q+AXzpjBxU0FlPyQlY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774355626; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aQMNUr9KZ8pnRmWrzhYdmQttfHchPPrIJHh8762NZBU=; b=lrMeTT2kI9rq+rRAzs1uuvvOGQm6LrSij8+D7QZ/c4WxznGVEL6ERopeGwL9yQofj4FovxHuR37y6K+n0GfkTQBjuc8KfQz1smWKBo/8EGLut4258enyxaQF/GD7lXe0gaHAqhGjW/wmkEspE+6SH7gAe0Lfr1bS4hP6aCXl0h8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1774355626972810.7413866743457; Tue, 24 Mar 2026 05:33:46 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1260634.1553904 (Exim 4.92) (envelope-from ) id 1w50wv-0005Mo-It; Tue, 24 Mar 2026 12:33:33 +0000 Received: by outflank-mailman (output) from mailman id 1260634.1553904; Tue, 24 Mar 2026 12:33:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w50wv-0005Mf-Fj; Tue, 24 Mar 2026 12:33:33 +0000 Received: by outflank-mailman (input) for mailman id 1260634; Tue, 24 Mar 2026 12:33:32 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w50wu-0005LR-D0 for xen-devel@lists.xenproject.org; Tue, 24 Mar 2026 12:33:32 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1w50wt-00EHMH-P9 for xen-devel@lists.xenproject.org; Tue, 24 Mar 2026 13:33:31 +0100 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69c28497-2eae-0a2a0a5409dd-0a2a4504dad8-32 for ; Tue, 24 Mar 2026 13:33:31 +0100 Received: from [209.85.216.68] (helo=mail-pj1-f68.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.55.2) (envelope-from ) id 69c2849a-c823-0a2a45040019-d155d844b160-3 for ; Tue, 24 Mar 2026 13:33:31 +0100 Received: by mail-pj1-f68.google.com with SMTP id 98e67ed59e1d1-35a02f3b8feso2254278a91.3 for ; Tue, 24 Mar 2026 05:33:31 -0700 (PDT) Received: from fedora ([103.2.232.250]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35c031ed04esm2215792a91.12.2026.03.24.05.33.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2026 05:33:28 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774355609; x=1774960409; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aQMNUr9KZ8pnRmWrzhYdmQttfHchPPrIJHh8762NZBU=; b=pbREfSWdlYODv1i2urbd4pFd0vV+I7J4eFwYOBLj3OMpAEeQta4Xq6Ah/zNq5yOjiX hJf6FncRKqBcvDWDAhzANXDT9rYh4txOAu+DZVLAy5W3nsOyZclSLgJ1lLL6vn9qjo+E ED3U03pR1ZXsleie9GA2T+yfQi6vz5W/9guogHMDhun8ep5rSUGQP4wf5yvqVY7hl0Df Wwn+3paVqUKUFz5CY/U+U0/AKuykXwFYWa6dyByKDg3gKIBLN05xGgCfNbNTBxT54uz7 JWqcd2irUc3LqMRDQGsVQcWKkqTqR6RJBCJ7poG42Laeu+IsPueoDw9TSwOy2irQ7xTM K85A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774355609; x=1774960409; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=aQMNUr9KZ8pnRmWrzhYdmQttfHchPPrIJHh8762NZBU=; b=VRXiJVtRQYRcGfUBtbN9gJtu6vsaYUU89i2+3SoEXMM3JpXs71GPloHS7MMxeS/kKr H2fqlmCLgSBmsy1DlaS+ySu3m3pzrSlq/IgJGVsgicCc/QqvlWUCVF/8H2pL5OdTgFbJ lhSw29xzvaXxit7w22DpU/pgCcbRKB3PVAtZssHROsrSH+lfSmuRZgdO5/gHPquWm/yZ 0ot1Z5KVUDeo24Hnk2+nOHKDMJTyCksvaYYRxxvf3UeW118tg2y02aKgSEX/3yw1D2dR eLnFzmJRvM1B6Yh8y6tagwQq80i97TLKSEOjXzAzcqtIJb9lawe/m00U393Af9sI3LTA EZ1A== X-Forwarded-Encrypted: i=1; AJvYcCUGNv4fHdYMEbcaxllkTlmGlHl+fvKAGAIDg83/UfhI9I/oq+iUyGiUq3cOd99NWuNATziStO0qESw=@lists.xenproject.org X-Gm-Message-State: AOJu0YxJ3GWMYS/qMM2pRGPeKkNKRvgLycU/3U4L+SkDF15e/gm4Xt4b xJmjEjDomLn4/VwxDrxrDTdFpTi0zoJv4Jp6ub0eC8JUQsKiBftXO59B X-Gm-Gg: ATEYQzw2eWl73plMt4wczpMobwWF49QQlrSgf2DShVsLhnmu3SS1sljrhk1XT6tHwkX Ud9QCt8fuzshBik4904dAY+A3xoIbo7p4jrPL4pLX6gA5TqpB34XuMZrXxEoy0NgJg5PogtHdVK P8QNvv0eP1J9Rif3g9sdvxv6WpCg3dVy2Y52FEJ59qajLKu3PEB2T8qFSd8ZfcKlvtAcsBTzklk t1Jp9SiSOP2Wj9KQWJri3EKMXxmSwPB0MyCP5L8gST1sDHDfFcj6WGf9BP2GzQ/0Nd+G6HMvGx6 pAzaD4cG0WEf5nY/63XPhFBnhxVny7GHuWSOzh/RZr+LrYQUd+NVrE5xuHSPNAo5jGg6EsbEMv+ g1/PyEPuqNjpWIdDzlBuGLt4hWIsUo/E+8oYuO2YiukLonex2vsGsePccauaaovjbsXnMPLdGiC lKtT41Deq/Pi6JsG/vFoie1KiKyYSoXmGw0BnLldZyxpTXw6eJxMZkwwA7OWk51pfbcyn7cG8xb EpW3o5eObqPdhBJTH9iB5hgvGT/AxFci1GCjzAEqKtXS+6veQN769p4LfnJubhTuhtDBgomkw== X-Received: by 2002:a17:90b:3849:b0:35b:947d:9fca with SMTP id 98e67ed59e1d1-35bd2cb761emr12853966a91.19.1774355609215; Tue, 24 Mar 2026 05:33:29 -0700 (PDT) From: Soumyajyotii Ssarkar To: sarkarsoumyajyoti23@gmail.com, xen-devel@lists.xenproject.org Cc: Andrew Cooper , Jan Beulich , "Daniel P . Smith" , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Soumyajyotii Ssarkar Subject: [PATCH v5 2/3] x86/acpi: Integrate BGRT preservation with status reporting Date: Tue, 24 Mar 2026 18:03:11 +0530 Message-ID: <20260324123312.11076-3-soumyajyotisarkar23@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260324123312.11076-1-soumyajyotisarkar23@gmail.com> References: <20260324123312.11076-1-soumyajyotisarkar23@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ebf023/1774355611-B309B9D1-7F1FBAE9/0/0 X-purgate-type: clean X-purgate-size: 3168 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1774355634418154100 Content-Type: text/plain; charset="utf-8" Add status reporting for BGRT preservation and integrate with Xen's ACPI subsystem: - efi_bgrt_status_info() prints preservation status (success/failure) - Called from acpi_boot_init() after ACPI tables are processed - Clarifying comment explains why invalidation code remains The invalidation code in acpi_invalidate_bgrt() now acts as a safety net: if preservation fails, the image remains in conventional RAM and gets invalidated. If preservation succeeds, the image is in EfiACPIReclaimMemory which won't match the RAM_TYPE_CONVENTIONAL check, leaving the table valid. Signed-off-by: Soumyajyotii Ssarkar Reported-by: Jan Beulich=C2=A0 Reported-by: Marek Marczykowski-G=C3=B3recki --- xen/arch/x86/acpi/boot.c | 8 ++++++++ xen/common/efi/boot.c | 16 ++++++++++++++++ xen/include/xen/efi.h | 1 + 3 files changed, 25 insertions(+) diff --git a/xen/arch/x86/acpi/boot.c b/xen/arch/x86/acpi/boot.c index 1ca2360e00..20afe79db9 100644 --- a/xen/arch/x86/acpi/boot.c +++ b/xen/arch/x86/acpi/boot.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -327,6 +328,11 @@ static int __init cf_check acpi_parse_hpet(struct acpi= _table_header *table) return 0; } +/* + * Invalidate BGRT if image is in conventional RAM (preservation failed). + * If preservation succeeded, image is in EfiACPIReclaimMemory, which + * won't match RAM_TYPE_CONVENTIONAL check, so table remains valid. + */ static int __init cf_check acpi_invalidate_bgrt(struct acpi_table_header *= table) { struct acpi_table_bgrt *bgrt_tbl =3D @@ -754,5 +760,7 @@ int __init acpi_boot_init(void) acpi_table_parse(ACPI_SIG_BGRT, acpi_invalidate_bgrt); + efi_bgrt_status_info(); + return 0; } diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 47d5b9b2a8..e22a42c15b 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -1911,6 +1911,22 @@ static bool __init cf_check rt_range_valid(unsigned = long smfn, unsigned long emf return true; } +void __init efi_bgrt_status_info(void) +{ + if ( !efi_enabled(EFI_BOOT) ) + return; + + if ( bgrt_info.preserved ) + { + printk(XENLOG_INFO "EFI: BGRT image preserved: %lu KB\n", + bgrt_info.size / 1024); + printk(XENLOG_INFO "EFI: BGRT relocated from %p to %p\n", + bgrt_info.old_addr, bgrt_info.new_addr); + } + else if ( bgrt_info.failure_reason[0] ) + printk(XENLOG_WARNING "EFI: BGRT preservation failed: %s\n", + bgrt_info.failure_reason); +} void __init efi_init_memory(void) { diff --git a/xen/include/xen/efi.h b/xen/include/xen/efi.h index 2e36b01e20..cebda997a5 100644 --- a/xen/include/xen/efi.h +++ b/xen/include/xen/efi.h @@ -39,6 +39,7 @@ static inline bool efi_enabled(unsigned int feature) extern bool efi_secure_boot; void efi_init_memory(void); +void efi_bgrt_status_info(void); bool efi_boot_mem_unused(unsigned long *start, unsigned long *end); bool efi_rs_using_pgtables(void); unsigned long efi_get_time(void); -- 2.53.0 From nobody Fri Apr 3 10:43:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1774355628; cv=none; d=zohomail.com; s=zohoarc; b=JamtDUl3AEXYkYPXqRknhgKwp60BTcXt2XHyx3jVeS7wviY8bmBXHrm/GQJUHW25szItsTIpMFehkgzoNuoPPCZDcXFng7DElhxtyLwI7MOnyCczvidVTaX7IhbCd1/rbWcSrwqkzmi4D0kgQgpy9WrK9I6U9SLuoCAb++cNOhU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774355628; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6/EFfTLPPvtpKfYbDxMVwQU9jDgu7ScMy19tpR6gQjI=; b=SrzymXwHbUXEe2dOu5PysMxh5MkIpUIF3E7gng7syn4oaHb+mfkSa4JRGn+mBkA20ZeEmSwtqf5QFNMiT0lwcgwF7m2ue3rz7lXaEECtO3zq1D8HjXhI9OywjrrFRi0r55ItbioQrAegrfr0qgnRzpBF5JjJvN2iZRE5IdvKQXQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1774355628321228.0143469743715; Tue, 24 Mar 2026 05:33:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1260639.1553913 (Exim 4.92) (envelope-from ) id 1w50x0-0005gd-Rs; Tue, 24 Mar 2026 12:33:38 +0000 Received: by outflank-mailman (output) from mailman id 1260639.1553913; Tue, 24 Mar 2026 12:33:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w50x0-0005gS-OO; Tue, 24 Mar 2026 12:33:38 +0000 Received: by outflank-mailman (input) for mailman id 1260639; Tue, 24 Mar 2026 12:33:37 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w50wy-0005dz-UH for xen-devel@lists.xenproject.org; Tue, 24 Mar 2026 12:33:37 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1w50wy-006OfX-A7 for xen-devel@lists.xenproject.org; Tue, 24 Mar 2026 13:33:36 +0100 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69c2849b-bab6-0a2a0a5309dd-0a2a4505ea44-40 for ; Tue, 24 Mar 2026 13:33:36 +0100 Received: from [209.85.216.66] (helo=mail-pj1-f66.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.55.2) (envelope-from ) id 69c2849e-5aeb-0a2a45050019-d155d842a439-3 for ; Tue, 24 Mar 2026 13:33:36 +0100 Received: by mail-pj1-f66.google.com with SMTP id 98e67ed59e1d1-35a1d4a095bso3177885a91.0 for ; Tue, 24 Mar 2026 05:33:35 -0700 (PDT) Received: from fedora ([103.2.232.250]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35c031ed04esm2215792a91.12.2026.03.24.05.33.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2026 05:33:33 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774355614; x=1774960414; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6/EFfTLPPvtpKfYbDxMVwQU9jDgu7ScMy19tpR6gQjI=; b=gMIWUa7uwCC9TMeUOldNRKNCQ5mmAtOCr51KtRqFcKQPgOEaOwQWMir2feHE6bYBiX iOyppAN9vlFmomvhbjsG+qrsEOcWdaeuGqN+b1ItkHY/8zJvuJqKM1lnUN+8accZPnB1 21NRjtOOhCbA2KWwWSZKJX6pbRE5UvUhizfrQalnrFGIRU84LIV1STugqgIPqwqMo9cR DQANL1/iTIq5+2B+Ya9XosR03KdnJpAjvWLEpUiRF+NZJInRM5jHN+I1OfoSYIkWUpXS Fe+wc4ctNUeFu06V36xn1YYdbeUwFw0AMu8VuTgPikn8re+eYY9beJBHCuPinclJAcw8 BkEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774355614; x=1774960414; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=6/EFfTLPPvtpKfYbDxMVwQU9jDgu7ScMy19tpR6gQjI=; b=Ev9D62IsymfQteD1zN1QMsOEBUwlezEpC4J6dhcYCQAmUXJ7gpVFvmlA4Fo1b5Nk4U fOoKOx6ATcgsBw+3ffJV1Xw8b3pLlqiDPjoKgHRYZhNLy6QgDzeFif2oiFciSt1wWxuc l3fQORk7mCYYpL6ndEH0ldlozEpnWi3KllMsDLw51LGCew6SktKJ8Q48wYWOKTx6DYd1 MtDPmb5rkIY/083loCgAis+YQw+lnSc5Dqvnywjb1mc77nnjRic4vTd2WCEhOKkM3sn4 Hpg6YxquiCy5L43o58G8Qm+Thbzr1Ihp4sWDdRcuQOyRP+IktEiXdgrBhD9DWg+AWgp1 TvgA== X-Forwarded-Encrypted: i=1; AJvYcCU8peUw3/j6DS1vCOl90O8OIYlO6488I3b80Pr7wjaQ5/f5ED10a1UXwZXUXRWOXo1+DB4oqCjAesw=@lists.xenproject.org X-Gm-Message-State: AOJu0YxRDbXjmFkcFI0R0uh/XlU0vOVqAcbKZme5s9f0l212lVUqwnmM WmvbTE4ZHkeA45ZH6Y/IXbcrbKjrUa2aZf2tm/JVidOmN6fmEjZMZ/KIL5eWfnSn X-Gm-Gg: ATEYQzySL70rFRDa3K8RGeSoNr5iX/GwJeYG9IUUrKeK3vDhOGiKQ0bZFY+6Q++14kp Y5wgFit3IvyOk4yMH97mwB9N+IGybtQLUx6ctr/+xCUkgtF28QYSJvfunsEu3tsYuImrucEBNJ+ wEHcL8Yxcz2d222ePPY1P/hZHq5XblFZXGIWDoVFfbq3sMFNBXoMxwu22yqLmo0lgDuV9jii45m 2ms35TeHT1br1ROI5QmOQfOqxa94hSoYsBb+GU3o74Wf8mhNT/Usf/O3PmGxxKfZ73NQcJVO7Eg l1UaaukNNCmueoCTVR3yO3EP+06z8ATWq2ZT9hepv9dzh58mzYtY4NB9s2+JteVr8BEm+H5JR0v wxpAXRAWrE/VMtqqDH10jnsUpn1giSV8QzXzz2eMlFSVhTG7Vhwqd434ac1KDTbBZdIE3RR6CjH FY3PGRS8vbZJnDoL+1Dq0IbZd7CEEf6H82G/gUoS+8Y1UW2O50V9llIwQa63xIULFQFo/ZouVao Au6KbZl4hWFGXBTDr/JRBVdI7BYc5Q/Z7vOU364UkjPMrMcsqBDQ37WNMiQJxDXKjvkayRaKQ== X-Received: by 2002:a17:90b:1e44:b0:34a:be93:72ee with SMTP id 98e67ed59e1d1-35c0083302cmr2487364a91.8.1774355613938; Tue, 24 Mar 2026 05:33:33 -0700 (PDT) From: Soumyajyotii Ssarkar To: sarkarsoumyajyoti23@gmail.com, xen-devel@lists.xenproject.org Cc: Andrew Cooper , Jan Beulich , "Daniel P . Smith" , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Soumyajyotii Ssarkar Subject: [PATCH v5 3/3] x86/efi: Add opt-out mechanism for BGRT preservation Date: Tue, 24 Mar 2026 18:03:12 +0530 Message-ID: <20260324123312.11076-4-soumyajyotisarkar23@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260324123312.11076-1-soumyajyotisarkar23@gmail.com> References: <20260324123312.11076-1-soumyajyotisarkar23@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c201ff/1774355616-82759488-AE5003A6/0/0 X-purgate-type: clean X-purgate-size: 3800 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1774355628720158500 Content-Type: text/plain; charset="utf-8" BGRT preservation is now enabled by default to fix ACPI corruption for desktop/workstation systems (similar to ESRT). As described in the task: https://github.com/QubesOS/qubes-issues/issues/10764 Add an opt-out parameter to allow disabling BGRT preservation on systems where the ~1MB memory overhead is not desired. The opt-out is implemented through two boot paths with early parsing during the EFI boot phase before preservation runs: 1. xen.efi direct boot: '-nobgrt' command line option (parsed in efi_start()) 2. Multiboot2 (GRUB): 'efi=3Dno-bgrt' peeked from mb2 cmdline tag using get_option() in efi_multiboot2() The flag is checked at the start of efi_preserve_bgrt_img() to skip preservation entirely when disabled. Status logging indicates whether preservation was disabled, succeeded, or failed. Usage: Default: BGRT preserved automatically xen.efi: Add '-nobgrt' option GRUB/MB2: Add 'efi=3Dno-bgrt' to Xen command line Signed-off-by: Soumyajyotii Ssarkar Reported-by: Jan Beulich=C2=A0 Reported-by: Marek Marczykowski-G=C3=B3recki --- xen/arch/x86/efi/efi-boot.h | 3 +++ xen/common/efi/boot.c | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index 0547d845cd..6c986cf6c0 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -897,6 +897,9 @@ void __init efi_multiboot2(EFI_HANDLE ImageHandle, efi_arch_edid(gop_handle); } + if ( cmdline && get_option(cmdline, "efi=3Dno-bgrt") ) + opt_bgrt_disabled =3D true; + efi_arch_edd(); efi_arch_cpu(); diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index e22a42c15b..a4db7ee516 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -170,6 +170,7 @@ static SIMPLE_TEXT_OUTPUT_INTERFACE *__initdata StdErr; static UINT32 __initdata mdesc_ver; static bool __initdata map_bs; +static bool __initdata opt_bgrt_disabled =3D false; static struct file __initdata cfg; static struct file __initdata kernel; @@ -825,6 +826,9 @@ static void __init efi_preserve_bgrt_img(void) bgrt_info.preserved =3D false; + if ( opt_bgrt_disabled ) + return; + bgrt =3D efi_get_bgrt(); if ( !bgrt ) { @@ -1582,6 +1586,8 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE Imag= eHandle, base_video =3D true; else if ( wstrcmp(ptr + 1, L"mapbs") =3D=3D 0 ) map_bs =3D true; + else if ( wstrcmp(ptr + 1, L"nobgrt") =3D=3D 0 ) + opt_bgrt_disabled =3D true; else if ( wstrncmp(ptr + 1, L"cfg=3D", 4) =3D=3D 0 ) cfg_file_name =3D ptr + 5; else if ( i + 1 < argc && wstrcmp(ptr + 1, L"cfg") =3D=3D = 0 ) @@ -1592,6 +1598,7 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE Imag= eHandle, PrintStr(L"Xen EFI Loader options:\r\n"); PrintStr(L"-basevideo retain current video mode\r\n"= ); PrintStr(L"-mapbs map EfiBootServices{Code,Data}= \r\n"); + PrintStr(L"-nobgrt disable BGRT preservation\r\n"= ); PrintStr(L"-cfg=3D specify configuration file\r= \n"); PrintStr(L"-help, -? display this help\r\n"); blexit(NULL); @@ -1916,7 +1923,9 @@ void __init efi_bgrt_status_info(void) if ( !efi_enabled(EFI_BOOT) ) return; - if ( bgrt_info.preserved ) + if ( opt_bgrt_disabled ) + printk(XENLOG_INFO "EFI: BGRT preservation disabled\n"); + else if ( bgrt_info.preserved ) { printk(XENLOG_INFO "EFI: BGRT image preserved: %lu KB\n", bgrt_info.size / 1024); -- 2.53.0