From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web11.18399.1687206891402860953 for ; Mon, 19 Jun 2023 13:34:51 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=J1D/CvxK; spf=pass (domain: redhat.com, ip: 170.10.129.124, mailfrom: osteffen@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687206890; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9XA1YmLqUVVrVwPJx3cYDg85E4OPLYbW5WW9sIAsLoc=; b=J1D/CvxKnlG2pSqIxnbpH4fg76BHZU6yfRBuBcDMUDvT4q/00Jt7yq67YtDLCcsios24CQ ETrM0tegqxU3BCXr+mWMd26rO2NAk5y/oOwG1fSGh4ZL/hX77DUzXT64AlNdP7SO0VWlve X35lU9qmI3GlbglYp9zz6hXYr/xDas0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-663-mzBaA4JSPmCBNEfcFagDqA-1; Mon, 19 Jun 2023 16:34:45 -0400 X-MC-Unique: mzBaA4JSPmCBNEfcFagDqA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B3F60185A78B; Mon, 19 Jun 2023 20:34:44 +0000 (UTC) Received: from osteffen-laptop.redhat.com (unknown [10.39.192.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 68DF6112132C; Mon, 19 Jun 2023 20:34:28 +0000 (UTC) From: "Oliver Steffen" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Daniel Schaefer , Eric Dong , Gerd Hoffmann , Leif Lindholm , Liming Gao , Michael D Kinney , Rahul Kumar , Ray Ni , Sami Mujawar , Sunil V L , Zhiguang Liu , Oliver Steffen Subject: [PATCH 1/1] ArmPkg: Add Pcd to disable EFI_MEMORY_ATTRIBUTE_PROTOCOL Date: Mon, 19 Jun 2023 22:32:25 +0200 Message-ID: <20230619203244.228933-1-osteffen@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Recent versions of shim (15.6 and 15.7) crash when the newly added EFI_MEMORY_ATTRIBUTE_PROTOCOL is provided by the firmware. To allow existing installations to boot, provide a workaround in form of a Pcd that allows tuning it off at build time (defaults to 'enabled'). Additionally, check the return code of the protocol installation calls. Signed-off-by: Oliver Steffen --- PR: https://github.com/tianocore/edk2/pull/4560 --- ArmPkg/ArmPkg.dec | 3 +++ ArmPkg/Drivers/CpuDxe/CpuDxe.inf | 1 + ArmPkg/Drivers/CpuDxe/CpuDxe.c | 13 +++++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec index 1a16d044c94b..bd612c8c4b93 100644 --- a/ArmPkg/ArmPkg.dec +++ b/ArmPkg/ArmPkg.dec @@ -172,6 +172,9 @@ [PcdsFixedAtBuild.common] gArmTokenSpaceGuid.PcdCpuVectorBaseAddress|0xffff0000|UINT64|0x00000004 gArmTokenSpaceGuid.PcdCpuResetAddress|0x00000000|UINT32|0x00000005 + # Enable/Disable EFI_MEMORY_ATTRIBUTE_PROTOCOL + gArmTokenSpaceGuid.PcdEnableEfiMemoryAttributeProtocol|TRUE|BOOLEAN|0x000000EE + # # ARM Secure Firmware PCDs # diff --git a/ArmPkg/Drivers/CpuDxe/CpuDxe.inf b/ArmPkg/Drivers/CpuDxe/CpuDxe.inf index 7d8132200e64..feb4f28b65f1 100644 --- a/ArmPkg/Drivers/CpuDxe/CpuDxe.inf +++ b/ArmPkg/Drivers/CpuDxe/CpuDxe.inf @@ -66,6 +66,7 @@ [Guids] [Pcd.common] gArmTokenSpaceGuid.PcdVFPEnabled gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy + gArmTokenSpaceGuid.PcdEnableEfiMemoryAttributeProtocol [FeaturePcd.common] gArmTokenSpaceGuid.PcdDebuggerExceptionSupport diff --git a/ArmPkg/Drivers/CpuDxe/CpuDxe.c b/ArmPkg/Drivers/CpuDxe/CpuDxe.c index f820f3f62189..927b91bde36e 100644 --- a/ArmPkg/Drivers/CpuDxe/CpuDxe.c +++ b/ArmPkg/Drivers/CpuDxe/CpuDxe.c @@ -329,10 +329,19 @@ CpuDxeInitialize ( &mCpuHandle, &gEfiCpuArchProtocolGuid, &mCpu, - &gEfiMemoryAttributeProtocolGuid, - &mMemoryAttribute, NULL ); + ASSERT_EFI_ERROR (Status); + + if (PcdGetBool (PcdEnableEfiMemoryAttributeProtocol)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &mCpuHandle, + &gEfiMemoryAttributeProtocolGuid, + &mMemoryAttribute, + NULL + ); + ASSERT_EFI_ERROR (Status); + } // // Make sure GCD and MMU settings match. This API calls gDS->SetMemorySpaceAttributes () -- 2.41.0