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.web08.5995.1627031756537038535 for ; Fri, 23 Jul 2021 02:15:56 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: sunny.wang@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 12D8A113E; Fri, 23 Jul 2021 02:15:56 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1497A3F73D; Fri, 23 Jul 2021 02:15:53 -0700 (PDT) From: "Sunny Wang" To: devel@edk2.groups.io Cc: Sunny Wang , Samer El-Haj-Mahmoud , Sami Mujawar , Jeremy Linton , Ard Biesheuvel , Pete Batard , Leif Lindholm , Sunny Wang Subject: [edk2-platform PATCH v1 1/1] Platform/RaspberryPi: Make SetVariable return EFI_UNSUPPORTED at runtime Date: Fri, 23 Jul 2021 17:15:21 +0800 Message-Id: <20210723091521.1663-1-Sunny.Wang@arm.com> X-Mailer: git-send-email 2.31.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable The RPi does not support storing UEFI NV variables at runtime. For now, gRT->SetVariable at runtime returns EFI_OUT_OF_RESOURCES which is not a proper error and would cause FWTS failures. Therefore, this patch is to make gRT->SetVariable at runtime return EFI_UNSUPPORTED. For more information, please check the issues below: -https://github.com/pftf/RPi4/issues/6 -https://github.com/pftf/RPi4/issues/93 -https://github.com/pftf/RPi4/issues/163 I also tested this with the ACS 3.0 FWTS. All the failures reported in issue 93 and 163 can be fixed by this patch. Cc: Samer El-Haj-Mahmoud Cc: Sami Mujawar Cc: Jeremy Linton Cc: Ard Biesheuvel Cc: Pete Batard Cc: Leif Lindholm Signed-off-by: Sunny Wang --- .../Drivers/VarBlockServiceDxe/VarBlockService.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServ= ice.c b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockService.c index 572309439a..16d4d4f178 100644 --- a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockService.c +++ b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockService.c @@ -2,6 +2,7 @@ * * Copyright (c) 2018, Andrei Warkentin * Copyright (c) 2006-2014, Intel Corporation. All rights reserved. + * Copyright (c) 2021, ARM Limited. All rights reserved. * * SPDX-License-Identifier: BSD-2-Clause-Patent * @@ -596,6 +597,7 @@ FvbProtocolWrite ( EFI_DEVICE_ERROR - The block device is not functioning correctl= y and could not be written EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL + EFI_UNSUPPORTED This function is not supported at runtime =20 --*/ { @@ -605,6 +607,16 @@ FvbProtocolWrite ( EFI_STATUS Status; EFI_STATUS ReturnStatus; =20 + // + // The current variables support relies on modifying RPI_EFI.FD on SD + // card, which works fine at boot time. However, at runtime, the SD=20 + // controller is exposed via ACPI and subsequently owned by the OS. + // Therefore, we need to direclty return EFI_UNSUPPORTED. + // + if (EfiAtRuntime ()) { + return EFI_UNSUPPORTED; + } + // // Check for invalid conditions. // --=20 2.31.0.windows.1