From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.12830.1592935027754739135 for ; Tue, 23 Jun 2020 10:57:08 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ard.biesheuvel@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0A83631B; Tue, 23 Jun 2020 10:57:06 -0700 (PDT) Received: from localhost.localdomain (unknown [10.37.8.29]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E568B3F71E; Tue, 23 Jun 2020 10:57:04 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: lersek@redhat.com, philmd@redhat.com, Ard Biesheuvel Subject: [PATCH] ArmVirtPkg/NorFlashQemuLib: disable NOR flash DT nodes upon discovery Date: Tue, 23 Jun 2020 19:57:00 +0200 Message-Id: <20200623175700.1564281-1-ard.biesheuvel@arm.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Our UEFI guest firmware takes ownership of the emulated NOR flash in order to support the variable runtime services, and it does not expect the OS to interfere with the underlying storage directly. So disable the NOR flash DT nodes as we discover them, in a way similar to how we disable the PL031 RTC in the device tree when we attach our RTC runtime driver to it. Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c b/ArmVirt= Pkg/Library/NorFlashQemuLib/NorFlashQemuLib.c index 9b1d1184bdd3..c676039785be 100644 --- a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c +++ b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c @@ -86,6 +86,18 @@ NorFlashPlatformGetDevices ( mNorFlashDevices[Num].BlockSize =3D QEMU_NOR_BLOCK_SIZE;=0D Num++;=0D }=0D +=0D + //=0D + // UEFI takes ownership of the NOR flash, and exposes its functionalit= y=0D + // through the UEFI Runtime Services GetVariable, SetVariable, etc. Th= is=0D + // means we need to disable it in the device tree to prevent the OS fr= om=0D + // attaching its device driver as well.=0D + //=0D + Status =3D FdtClient->SetNodeProperty (FdtClient, Node, "status",=0D + "disabled", sizeof ("disabled"));=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((EFI_D_WARN, "Failed to set NOR flash status to 'disabled'\= n"));=0D + }=0D }=0D =0D *NorFlashDescriptions =3D mNorFlashDevices;=0D --=20 2.27.0