* [PATCH 1/1] Platform/SbsaQemu: read platform version
@ 2023-05-10 15:08 Marcin Juszkiewicz
2023-05-10 15:21 ` [edk2-devel] " Ard Biesheuvel
2023-05-10 15:26 ` Rebecca Cran
0 siblings, 2 replies; 10+ messages in thread
From: Marcin Juszkiewicz @ 2023-05-10 15:08 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Leif Lindholm, Rebecca Cran, Sami Mujawar,
Marcin Juszkiewicz
Qemu has versioning for sbsa-ref platform. TF-A reads it from provided
DeviceTree and provides as SMC.
This change adds reading platform version into EDK2.
Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
---
Platform/Qemu/SbsaQemu/SbsaQemu.dsc | 3 +++
.../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c | 14 ++++++++++++++
.../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf | 5 +++++
Silicon/Qemu/SbsaQemu/SbsaQemu.dec | 3 +++
4 files changed, 25 insertions(+)
diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
index c9b912cc1e9e..facca3b3e272 100644
--- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
+++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
@@ -561,6 +561,9 @@ DEFINE NETWORK_HTTP_BOOT_ENABLE = FALSE
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisAssetTag|L"AT0000"
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisSKU|L"SK0000"
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor|0x0
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor|0x0
+
################################################################################
#
# Components Section - list of all EDK II Modules needed by this Platform
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
index b7270a07abbd..7a22f067b600 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
@@ -7,12 +7,14 @@
*
**/
+#include <Library/ArmSmcLib.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/NonDiscoverableDeviceRegistrationLib.h>
#include <Library/PcdLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiDriverEntryPoint.h>
+#include <IndustryStandard/ArmStdSmc.h>
#include <Protocol/FdtClient.h>
@@ -26,6 +28,9 @@ InitializeSbsaQemuPlatformDxe (
EFI_STATUS Status;
UINTN Size;
VOID* Base;
+ UINTN Major;
+ UINTN Minor;
+ UINTN Result;
DEBUG ((DEBUG_INFO, "%a: InitializeSbsaQemuPlatformDxe called\n", __FUNCTION__));
@@ -51,5 +56,14 @@ InitializeSbsaQemuPlatformDxe (
return Status;
}
+ Result = ArmCallSmc0(SIP_FUNCTION_ID(1), &Major, &Minor, NULL);
+ if (Result != 0xFFFFFF)
+ {
+ PcdSet32S (PcdPlatformVersionMajor, Major);
+ PcdSet32S (PcdPlatformVersionMinor, Minor);
+ }
+
+ DEBUG((DEBUG_ERROR, "Platform version: %d.%d\n", Major, Minor));
+
return EFI_SUCCESS;
}
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
index 21d2135f6d17..1f2c8a9dd6af 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
@@ -20,6 +20,7 @@
SbsaQemuPlatformDxe.c
[Packages]
+ ArmPkg/ArmPkg.dec
ArmVirtPkg/ArmVirtPkg.dec
EmbeddedPkg/EmbeddedPkg.dec
MdeModulePkg/MdeModulePkg.dec
@@ -27,6 +28,7 @@
Silicon/Qemu/SbsaQemu/SbsaQemu.dec
[LibraryClasses]
+ ArmSmcLib
PcdLib
DebugLib
NonDiscoverableDeviceRegistrationLib
@@ -36,6 +38,9 @@
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciBase
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciSize
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor
+
[Depex]
TRUE
diff --git a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
index 8654cc7c858c..fb5903bfda0f 100644
--- a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
+++ b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
@@ -70,3 +70,6 @@
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisManufacturer|L""|VOID*|0x0000011B
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisAssetTag|L""|VOID*|0x0000011C
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisSKU|L""|VOID*|0x0000011D
+
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor|0x0|UINT32|0x0000011E
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor|0x0|UINT32|0x0000011F
--
2.40.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [edk2-devel] [PATCH 1/1] Platform/SbsaQemu: read platform version
2023-05-10 15:08 [PATCH 1/1] Platform/SbsaQemu: read platform version Marcin Juszkiewicz
@ 2023-05-10 15:21 ` Ard Biesheuvel
2023-05-10 15:26 ` Rebecca Cran
1 sibling, 0 replies; 10+ messages in thread
From: Ard Biesheuvel @ 2023-05-10 15:21 UTC (permalink / raw)
To: devel, marcin.juszkiewicz
Cc: Ard Biesheuvel, Leif Lindholm, Rebecca Cran, Sami Mujawar
HI Marcin,
On Wed, 10 May 2023 at 17:08, Marcin Juszkiewicz
<marcin.juszkiewicz@linaro.org> wrote:
>
> Qemu has versioning for sbsa-ref platform. TF-A reads it from provided
> DeviceTree and provides as SMC.
>
> This change adds reading platform version into EDK2.
>
> Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
> ---
> Platform/Qemu/SbsaQemu/SbsaQemu.dsc | 3 +++
> .../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c | 14 ++++++++++++++
> .../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf | 5 +++++
> Silicon/Qemu/SbsaQemu/SbsaQemu.dec | 3 +++
> 4 files changed, 25 insertions(+)
>
> diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
> index c9b912cc1e9e..facca3b3e272 100644
> --- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
> +++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
> @@ -561,6 +561,9 @@ DEFINE NETWORK_HTTP_BOOT_ENABLE = FALSE
> gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisAssetTag|L"AT0000"
> gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisSKU|L"SK0000"
>
> + gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor|0x0
> + gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor|0x0
> +
> ################################################################################
> #
> # Components Section - list of all EDK II Modules needed by this Platform
> diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
> index b7270a07abbd..7a22f067b600 100644
> --- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
> +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
> @@ -7,12 +7,14 @@
> *
> **/
>
> +#include <Library/ArmSmcLib.h>
> #include <Library/BaseLib.h>
> #include <Library/DebugLib.h>
> #include <Library/NonDiscoverableDeviceRegistrationLib.h>
> #include <Library/PcdLib.h>
> #include <Library/UefiBootServicesTableLib.h>
> #include <Library/UefiDriverEntryPoint.h>
> +#include <IndustryStandard/ArmStdSmc.h>
>
> #include <Protocol/FdtClient.h>
>
> @@ -26,6 +28,9 @@ InitializeSbsaQemuPlatformDxe (
> EFI_STATUS Status;
> UINTN Size;
> VOID* Base;
> + UINTN Major;
> + UINTN Minor;
> + UINTN Result;
>
> DEBUG ((DEBUG_INFO, "%a: InitializeSbsaQemuPlatformDxe called\n", __FUNCTION__));
>
> @@ -51,5 +56,14 @@ InitializeSbsaQemuPlatformDxe (
> return Status;
> }
>
> + Result = ArmCallSmc0(SIP_FUNCTION_ID(1), &Major, &Minor, NULL);
> + if (Result != 0xFFFFFF)
> + {
> + PcdSet32S (PcdPlatformVersionMajor, Major);
> + PcdSet32S (PcdPlatformVersionMinor, Minor);
Please don't ignore the return values of PcdSet32S like that - at
least capture the return value and use ASSERT_EFI_ERROR() or log them
using DEBUG() so we'll notice if this breaks.
> + }
> +
> + DEBUG((DEBUG_ERROR, "Platform version: %d.%d\n", Major, Minor));
> +
> return EFI_SUCCESS;
> }
> diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
> index 21d2135f6d17..1f2c8a9dd6af 100644
> --- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
> +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
> @@ -20,6 +20,7 @@
> SbsaQemuPlatformDxe.c
>
> [Packages]
> + ArmPkg/ArmPkg.dec
> ArmVirtPkg/ArmVirtPkg.dec
> EmbeddedPkg/EmbeddedPkg.dec
> MdeModulePkg/MdeModulePkg.dec
> @@ -27,6 +28,7 @@
> Silicon/Qemu/SbsaQemu/SbsaQemu.dec
>
> [LibraryClasses]
> + ArmSmcLib
> PcdLib
> DebugLib
> NonDiscoverableDeviceRegistrationLib
> @@ -36,6 +38,9 @@
> gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciBase
> gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciSize
>
> + gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor
> + gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor
> +
> [Depex]
> TRUE
>
> diff --git a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
> index 8654cc7c858c..fb5903bfda0f 100644
> --- a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
> +++ b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
> @@ -70,3 +70,6 @@
> gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisManufacturer|L""|VOID*|0x0000011B
> gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisAssetTag|L""|VOID*|0x0000011C
> gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisSKU|L""|VOID*|0x0000011D
> +
> + gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor|0x0|UINT32|0x0000011E
> + gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor|0x0|UINT32|0x0000011F
> --
> 2.40.1
>
>
>
> ------------
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#104572): https://edk2.groups.io/g/devel/message/104572
> Mute This Topic: https://groups.io/mt/98807889/1131722
> Group Owner: devel+owner@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [ardb@kernel.org]
> ------------
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/1] Platform/SbsaQemu: read platform version
2023-05-10 15:08 [PATCH 1/1] Platform/SbsaQemu: read platform version Marcin Juszkiewicz
2023-05-10 15:21 ` [edk2-devel] " Ard Biesheuvel
@ 2023-05-10 15:26 ` Rebecca Cran
2023-05-10 15:40 ` [PATCH v2 " Marcin Juszkiewicz
[not found] ` <175DD274B9968CD4.32438@groups.io>
1 sibling, 2 replies; 10+ messages in thread
From: Rebecca Cran @ 2023-05-10 15:26 UTC (permalink / raw)
To: Marcin Juszkiewicz, devel; +Cc: Ard Biesheuvel, Leif Lindholm, Sami Mujawar
On 5/10/23 09:08, Marcin Juszkiewicz wrote:
> + Result = ArmCallSmc0(SIP_FUNCTION_ID(1), &Major, &Minor, NULL);
There should be space before the opening parenthesis.
Also, it would be nice to avoid a magic number - i.e. define what
SIP_FUNCTION_ID(1) is.
--
Rebecca Cran
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 1/1] Platform/SbsaQemu: read platform version
2023-05-10 15:26 ` Rebecca Cran
@ 2023-05-10 15:40 ` Marcin Juszkiewicz
2023-05-10 15:49 ` Rebecca Cran
[not found] ` <175DD274B9968CD4.32438@groups.io>
1 sibling, 1 reply; 10+ messages in thread
From: Marcin Juszkiewicz @ 2023-05-10 15:40 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Leif Lindholm, Rebecca Cran, Sami Mujawar,
Marcin Juszkiewicz
Qemu has versioning for sbsa-ref platform. TF-A reads it from provided
DeviceTree and provides as SMC.
This change adds reading platform version into EDK2.
Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
---
Platform/Qemu/SbsaQemu/SbsaQemu.dsc | 3 +++
.../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c | 24 +++++++++++++++++++
.../SbsaQemuPlatformDxe.inf | 5 ++++
Silicon/Qemu/SbsaQemu/SbsaQemu.dec | 3 +++
4 files changed, 35 insertions(+)
diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
index c9b912cc1e9e..facca3b3e272 100644
--- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
+++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
@@ -561,6 +561,9 @@ DEFINE NETWORK_HTTP_BOOT_ENABLE = FALSE
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisAssetTag|L"AT0000"
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisSKU|L"SK0000"
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor|0x0
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor|0x0
+
################################################################################
#
# Components Section - list of all EDK II Modules needed by this Platform
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
index b7270a07abbd..c9dd79f69958 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
@@ -7,15 +7,25 @@
*
**/
+#include <Library/ArmSmcLib.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/NonDiscoverableDeviceRegistrationLib.h>
#include <Library/PcdLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiDriverEntryPoint.h>
+#include <IndustryStandard/ArmStdSmc.h>
#include <Protocol/FdtClient.h>
+/* those probably should go into IndustryStandard/ArmStdSmc.h */
+#define SMC_FASTCALL 0x80000000
+#define SMC64_FUNCTION (SMC_FASTCALL | 0x40000000)
+#define SIP_FUNCTION (SMC64_FUNCTION | 0x02000000)
+#define SIP_FUNCTION_ID(n) (SIP_FUNCTION | (n))
+
+#define SIP_SVC_VERSION SIP_FUNCTION_ID(1)
+
EFI_STATUS
EFIAPI
InitializeSbsaQemuPlatformDxe (
@@ -26,6 +36,9 @@ InitializeSbsaQemuPlatformDxe (
EFI_STATUS Status;
UINTN Size;
VOID* Base;
+ UINTN Major;
+ UINTN Minor;
+ UINTN Result;
DEBUG ((DEBUG_INFO, "%a: InitializeSbsaQemuPlatformDxe called\n", __FUNCTION__));
@@ -51,5 +64,16 @@ InitializeSbsaQemuPlatformDxe (
return Status;
}
+ Result = ArmCallSmc0 (SIP_SVC_VERSION, &Major, &Minor, NULL);
+ if (Result == SMC_ARCH_CALL_SUCCESS)
+ {
+ Result = PcdSet32S (PcdPlatformVersionMajor, Major);
+ ASSERT_EFI_ERROR (Result);
+ Result = PcdSet32S (PcdPlatformVersionMinor, Minor);
+ ASSERT_EFI_ERROR (Result);
+ }
+
+ DEBUG((DEBUG_ERROR, "Platform version: %d.%d\n", Major, Minor));
+
return EFI_SUCCESS;
}
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
index 21d2135f6d17..1f2c8a9dd6af 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
@@ -20,6 +20,7 @@
SbsaQemuPlatformDxe.c
[Packages]
+ ArmPkg/ArmPkg.dec
ArmVirtPkg/ArmVirtPkg.dec
EmbeddedPkg/EmbeddedPkg.dec
MdeModulePkg/MdeModulePkg.dec
@@ -27,6 +28,7 @@
Silicon/Qemu/SbsaQemu/SbsaQemu.dec
[LibraryClasses]
+ ArmSmcLib
PcdLib
DebugLib
NonDiscoverableDeviceRegistrationLib
@@ -36,6 +38,9 @@
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciBase
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciSize
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor
+
[Depex]
TRUE
diff --git a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
index 8654cc7c858c..fb5903bfda0f 100644
--- a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
+++ b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
@@ -70,3 +70,6 @@
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisManufacturer|L""|VOID*|0x0000011B
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisAssetTag|L""|VOID*|0x0000011C
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisSKU|L""|VOID*|0x0000011D
+
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor|0x0|UINT32|0x0000011E
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor|0x0|UINT32|0x0000011F
--
2.40.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [edk2-devel] [PATCH v2 1/1] Platform/SbsaQemu: read platform version
[not found] ` <175DD274B9968CD4.32438@groups.io>
@ 2023-05-10 15:42 ` Marcin Juszkiewicz
0 siblings, 0 replies; 10+ messages in thread
From: Marcin Juszkiewicz @ 2023-05-10 15:42 UTC (permalink / raw)
To: devel; +Cc: Ard Biesheuvel, Leif Lindholm, Rebecca Cran, Sami Mujawar
W dniu 10.05.2023 o 17:40, Marcin Juszkiewicz via groups.io pisze:
> Qemu has versioning for sbsa-ref platform. TF-A reads it from provided
> DeviceTree and provides as SMC.
>
> This change adds reading platform version into EDK2.
TF-A side of change:
https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/20871
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/1] Platform/SbsaQemu: read platform version
2023-05-10 15:40 ` [PATCH v2 " Marcin Juszkiewicz
@ 2023-05-10 15:49 ` Rebecca Cran
2023-05-10 16:06 ` [PATCH v3 " Marcin Juszkiewicz
0 siblings, 1 reply; 10+ messages in thread
From: Rebecca Cran @ 2023-05-10 15:49 UTC (permalink / raw)
To: Marcin Juszkiewicz, devel; +Cc: Ard Biesheuvel, Leif Lindholm, Sami Mujawar
On 5/10/23 09:40, Marcin Juszkiewicz wrote:
> @@ -26,6 +36,9 @@ InitializeSbsaQemuPlatformDxe (
> EFI_STATUS Status;
> UINTN Size;
> VOID* Base;
> + UINTN Major;
> + UINTN Minor;
> + UINTN Result;
>
> DEBUG ((DEBUG_INFO, "%a: InitializeSbsaQemuPlatformDxe called\n", __FUNCTION__));
>
> @@ -51,5 +64,16 @@ InitializeSbsaQemuPlatformDxe (
> return Status;
> }
>
> + Result = ArmCallSmc0 (SIP_SVC_VERSION, &Major, &Minor, NULL);
> + if (Result == SMC_ARCH_CALL_SUCCESS)
> + {
> + Result = PcdSet32S (PcdPlatformVersionMajor, Major);
> + ASSERT_EFI_ERROR (Result);
> + Result = PcdSet32S (PcdPlatformVersionMinor, Minor);
> + ASSERT_EFI_ERROR (Result);
> + }
> +
> + DEBUG((DEBUG_ERROR, "Platform version: %d.%d\n", Major, Minor));
> +
> return EFI_SUCCESS;
> }
That should probably be logged at DEBUG_INFO instead of DEBUG_ERROR.
Also, if the SMC call fails Major and Minor are uninitialized. With a
slightly older TF-A I get:
Platform version: -71457408.-8905312
--
Rebecca Cran
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 1/1] Platform/SbsaQemu: read platform version
2023-05-10 15:49 ` Rebecca Cran
@ 2023-05-10 16:06 ` Marcin Juszkiewicz
2023-05-10 16:14 ` Rebecca Cran
0 siblings, 1 reply; 10+ messages in thread
From: Marcin Juszkiewicz @ 2023-05-10 16:06 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Leif Lindholm, Rebecca Cran, Sami Mujawar,
Marcin Juszkiewicz
Qemu has versioning for sbsa-ref platform. TF-A reads it from provided
DeviceTree and provides as SMC.
This change adds reading platform version into EDK2.
Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
---
Platform/Qemu/SbsaQemu/SbsaQemu.dsc | 3 ++
.../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c | 29 +++++++++++++++++++
.../SbsaQemuPlatformDxe.inf | 5 ++++
Silicon/Qemu/SbsaQemu/SbsaQemu.dec | 3 ++
4 files changed, 40 insertions(+)
diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
index c9b912cc1e9e..facca3b3e272 100644
--- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
+++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
@@ -561,6 +561,9 @@ DEFINE NETWORK_HTTP_BOOT_ENABLE = FALSE
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisAssetTag|L"AT0000"
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisSKU|L"SK0000"
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor|0x0
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor|0x0
+
################################################################################
#
# Components Section - list of all EDK II Modules needed by this Platform
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
index b7270a07abbd..f03369c7c81f 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
@@ -7,15 +7,25 @@
*
**/
+#include <Library/ArmSmcLib.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/NonDiscoverableDeviceRegistrationLib.h>
#include <Library/PcdLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiDriverEntryPoint.h>
+#include <IndustryStandard/ArmStdSmc.h>
#include <Protocol/FdtClient.h>
+/* those probably should go into IndustryStandard/ArmStdSmc.h */
+#define SMC_FASTCALL 0x80000000
+#define SMC64_FUNCTION (SMC_FASTCALL | 0x40000000)
+#define SIP_FUNCTION (SMC64_FUNCTION | 0x02000000)
+#define SIP_FUNCTION_ID(n) (SIP_FUNCTION | (n))
+
+#define SIP_SVC_VERSION SIP_FUNCTION_ID(1)
+
EFI_STATUS
EFIAPI
InitializeSbsaQemuPlatformDxe (
@@ -26,6 +36,9 @@ InitializeSbsaQemuPlatformDxe (
EFI_STATUS Status;
UINTN Size;
VOID* Base;
+ UINTN Major;
+ UINTN Minor;
+ UINTN Result;
DEBUG ((DEBUG_INFO, "%a: InitializeSbsaQemuPlatformDxe called\n", __FUNCTION__));
@@ -51,5 +64,21 @@ InitializeSbsaQemuPlatformDxe (
return Status;
}
+ Result = ArmCallSmc0 (SIP_SVC_VERSION, &Major, &Minor, NULL);
+ if (Result == SMC_ARCH_CALL_SUCCESS)
+ {
+ Result = PcdSet32S (PcdPlatformVersionMajor, Major);
+ ASSERT_EFI_ERROR (Result);
+ Result = PcdSet32S (PcdPlatformVersionMinor, Minor);
+ ASSERT_EFI_ERROR (Result);
+ }
+
+ Major = PcdGet32 (PcdPlatformVersionMajor);
+ ASSERT_EFI_ERROR (Major);
+ Minor = PcdGet32 (PcdPlatformVersionMinor);
+ ASSERT_EFI_ERROR (Minor);
+
+ DEBUG((DEBUG_INFO, "Platform version: %d.%d\n", Major, Minor));
+
return EFI_SUCCESS;
}
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
index 21d2135f6d17..1f2c8a9dd6af 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
@@ -20,6 +20,7 @@
SbsaQemuPlatformDxe.c
[Packages]
+ ArmPkg/ArmPkg.dec
ArmVirtPkg/ArmVirtPkg.dec
EmbeddedPkg/EmbeddedPkg.dec
MdeModulePkg/MdeModulePkg.dec
@@ -27,6 +28,7 @@
Silicon/Qemu/SbsaQemu/SbsaQemu.dec
[LibraryClasses]
+ ArmSmcLib
PcdLib
DebugLib
NonDiscoverableDeviceRegistrationLib
@@ -36,6 +38,9 @@
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciBase
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciSize
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor
+
[Depex]
TRUE
diff --git a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
index 8654cc7c858c..fb5903bfda0f 100644
--- a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
+++ b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
@@ -70,3 +70,6 @@
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisManufacturer|L""|VOID*|0x0000011B
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisAssetTag|L""|VOID*|0x0000011C
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisSKU|L""|VOID*|0x0000011D
+
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor|0x0|UINT32|0x0000011E
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor|0x0|UINT32|0x0000011F
--
2.40.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v3 1/1] Platform/SbsaQemu: read platform version
2023-05-10 16:06 ` [PATCH v3 " Marcin Juszkiewicz
@ 2023-05-10 16:14 ` Rebecca Cran
2023-05-10 17:30 ` [PATCH v4 " Marcin Juszkiewicz
2023-05-10 17:32 ` [PATCH v3 " Marcin Juszkiewicz
0 siblings, 2 replies; 10+ messages in thread
From: Rebecca Cran @ 2023-05-10 16:14 UTC (permalink / raw)
To: Marcin Juszkiewicz, devel; +Cc: Ard Biesheuvel, Leif Lindholm, Sami Mujawar
On 5/10/23 10:06, Marcin Juszkiewicz wrote:
> + Result = ArmCallSmc0 (SIP_SVC_VERSION, &Major, &Minor, NULL);
> + if (Result == SMC_ARCH_CALL_SUCCESS)
> + {
> + Result = PcdSet32S (PcdPlatformVersionMajor, Major);
> + ASSERT_EFI_ERROR (Result);
> + Result = PcdSet32S (PcdPlatformVersionMinor, Minor);
> + ASSERT_EFI_ERROR (Result);
> + }
> +
> + Major = PcdGet32 (PcdPlatformVersionMajor);
> + ASSERT_EFI_ERROR (Major);
> + Minor = PcdGet32 (PcdPlatformVersionMinor);
> + ASSERT_EFI_ERROR (Minor);
> +
> + DEBUG((DEBUG_INFO, "Platform version: %d.%d\n", Major, Minor));
> +
> return EFI_SUCCESS;
> }
Sorry, but there are new problems.
There should be a space before the parenthesis in the 'DEBUG' line.
PcdGet32 doesn't return a RETURN_STATUS or EFI_STATUS, so
ASSERT_EFI_ERROR is incorrect.
--
Rebecca Cran
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v4 1/1] Platform/SbsaQemu: read platform version
2023-05-10 16:14 ` Rebecca Cran
@ 2023-05-10 17:30 ` Marcin Juszkiewicz
2023-05-10 17:32 ` [PATCH v3 " Marcin Juszkiewicz
1 sibling, 0 replies; 10+ messages in thread
From: Marcin Juszkiewicz @ 2023-05-10 17:30 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Leif Lindholm, Rebecca Cran, Sami Mujawar,
Marcin Juszkiewicz
Qemu has versioning for sbsa-ref platform. TF-A reads it from provided
DeviceTree and provides as SMC.
This change adds reading platform version into EDK2.
Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
---
Platform/Qemu/SbsaQemu/SbsaQemu.dsc | 3 +++
.../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c | 27 +++++++++++++++++++
.../SbsaQemuPlatformDxe.inf | 5 ++++
Silicon/Qemu/SbsaQemu/SbsaQemu.dec | 3 +++
4 files changed, 38 insertions(+)
diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
index c9b912cc1e9e..facca3b3e272 100644
--- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
+++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
@@ -561,6 +561,9 @@ DEFINE NETWORK_HTTP_BOOT_ENABLE = FALSE
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisAssetTag|L"AT0000"
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisSKU|L"SK0000"
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor|0x0
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor|0x0
+
################################################################################
#
# Components Section - list of all EDK II Modules needed by this Platform
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
index b7270a07abbd..91ae85e0d950 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
@@ -7,15 +7,25 @@
*
**/
+#include <Library/ArmSmcLib.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/NonDiscoverableDeviceRegistrationLib.h>
#include <Library/PcdLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiDriverEntryPoint.h>
+#include <IndustryStandard/ArmStdSmc.h>
#include <Protocol/FdtClient.h>
+/* those probably should go into IndustryStandard/ArmStdSmc.h */
+#define SMC_FASTCALL 0x80000000
+#define SMC64_FUNCTION (SMC_FASTCALL | 0x40000000)
+#define SIP_FUNCTION (SMC64_FUNCTION | 0x02000000)
+#define SIP_FUNCTION_ID(n) (SIP_FUNCTION | (n))
+
+#define SIP_SVC_VERSION SIP_FUNCTION_ID(1)
+
EFI_STATUS
EFIAPI
InitializeSbsaQemuPlatformDxe (
@@ -26,6 +36,9 @@ InitializeSbsaQemuPlatformDxe (
EFI_STATUS Status;
UINTN Size;
VOID* Base;
+ UINTN Major;
+ UINTN Minor;
+ UINTN Result;
DEBUG ((DEBUG_INFO, "%a: InitializeSbsaQemuPlatformDxe called\n", __FUNCTION__));
@@ -51,5 +64,19 @@ InitializeSbsaQemuPlatformDxe (
return Status;
}
+ Result = ArmCallSmc0 (SIP_SVC_VERSION, &Major, &Minor, NULL);
+ if (Result == SMC_ARCH_CALL_SUCCESS)
+ {
+ Result = PcdSet32S (PcdPlatformVersionMajor, Major);
+ ASSERT_EFI_ERROR (Result);
+ Result = PcdSet32S (PcdPlatformVersionMinor, Minor);
+ ASSERT_EFI_ERROR (Result);
+ }
+
+ Major = PcdGet32 (PcdPlatformVersionMajor);
+ Minor = PcdGet32 (PcdPlatformVersionMinor);
+
+ DEBUG ((DEBUG_INFO, "Platform version: %d.%d\n", Major, Minor));
+
return EFI_SUCCESS;
}
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
index 21d2135f6d17..1f2c8a9dd6af 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
@@ -20,6 +20,7 @@
SbsaQemuPlatformDxe.c
[Packages]
+ ArmPkg/ArmPkg.dec
ArmVirtPkg/ArmVirtPkg.dec
EmbeddedPkg/EmbeddedPkg.dec
MdeModulePkg/MdeModulePkg.dec
@@ -27,6 +28,7 @@
Silicon/Qemu/SbsaQemu/SbsaQemu.dec
[LibraryClasses]
+ ArmSmcLib
PcdLib
DebugLib
NonDiscoverableDeviceRegistrationLib
@@ -36,6 +38,9 @@
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciBase
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciSize
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor
+
[Depex]
TRUE
diff --git a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
index 8654cc7c858c..fb5903bfda0f 100644
--- a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
+++ b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
@@ -70,3 +70,6 @@
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisManufacturer|L""|VOID*|0x0000011B
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisAssetTag|L""|VOID*|0x0000011C
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisSKU|L""|VOID*|0x0000011D
+
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor|0x0|UINT32|0x0000011E
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor|0x0|UINT32|0x0000011F
--
2.40.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v3 1/1] Platform/SbsaQemu: read platform version
2023-05-10 16:14 ` Rebecca Cran
2023-05-10 17:30 ` [PATCH v4 " Marcin Juszkiewicz
@ 2023-05-10 17:32 ` Marcin Juszkiewicz
1 sibling, 0 replies; 10+ messages in thread
From: Marcin Juszkiewicz @ 2023-05-10 17:32 UTC (permalink / raw)
To: Rebecca Cran, devel; +Cc: Ard Biesheuvel, Leif Lindholm, Sami Mujawar
W dniu 10.05.2023 o 18:14, Rebecca Cran pisze:
> Sorry, but there are new problems.
No problem. Thanks for reviewing.
> There should be a space before the parenthesis in the 'DEBUG' line.
No problem. I hope that one day someone will run source formatter on
whole edk2-platforms so it would be possible to autoformat changes
before posting.
> PcdGet32 doesn't return a RETURN_STATUS or EFI_STATUS, so
> ASSERT_EFI_ERROR is incorrect.
fixed
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-05-10 17:32 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-10 15:08 [PATCH 1/1] Platform/SbsaQemu: read platform version Marcin Juszkiewicz
2023-05-10 15:21 ` [edk2-devel] " Ard Biesheuvel
2023-05-10 15:26 ` Rebecca Cran
2023-05-10 15:40 ` [PATCH v2 " Marcin Juszkiewicz
2023-05-10 15:49 ` Rebecca Cran
2023-05-10 16:06 ` [PATCH v3 " Marcin Juszkiewicz
2023-05-10 16:14 ` Rebecca Cran
2023-05-10 17:30 ` [PATCH v4 " Marcin Juszkiewicz
2023-05-10 17:32 ` [PATCH v3 " Marcin Juszkiewicz
[not found] ` <175DD274B9968CD4.32438@groups.io>
2023-05-10 15:42 ` [edk2-devel] [PATCH v2 " Marcin Juszkiewicz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox