Skip to contentSkip to conversation

arm64: zynqmp: Print the secure boot status information in EL3

PATCH In review Jorge Ramirez-Ortiz 3 participants 5 messages Jul 22, 2021 – Aug 27, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: zynqmp: Print the secure boot status information in EL3

Confirm the secure boot configuration on the console.

---
 arch/arm/mach-zynqmp/include/mach/hardware.h |  3 ++-
 board/xilinx/zynqmp/zynqmp.c                 | 16 +++++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)
arch/arm/mach-zynqmp/include/mach/hardware.h +2 -1
index 3776499070..3d3ffa086e 100644
@@ -139,7 +139,8 @@ struct apu_regs {
 #define ZYNQMP_SILICON_VER_SHIFT	0
 
 struct csu_regs {
-	u32 reserved0[4];
+	u32 status;
+	u32 reserved0[3];
 	u32 multi_boot;
 	u32 reserved1[11];
 	u32 idcode;
board/xilinx/zynqmp/zynqmp.c +15 -1
index 1748fec2e4..b7d11630d1 100644
@@ -355,6 +355,18 @@ static int multi_boot(void)
 	return 0;
 }
 
+static void secure_boot(void)
+{
+	u32 status;
+
+	status = readl(&csu_base->status);
+	if (status & (BIT(0) | BIT(1))) {
+		printf("Secure Boot:\t%s%s\n",
+		       status & BIT(0) ? "authenticated" : "not authenticated",
+		       status & BIT(1) ? ", encrypted" : ", not encrypted");
+	}
+}
+
 #define PS_SYSMON_ANALOG_BUS_VAL	0x3210
 #define PS_SYSMON_ANALOG_BUS_REG	0xFFA50914
 
@@ -391,8 +403,10 @@ int board_init(void)
 	fpga_add(fpga_xilinx, &zynqmppl);
 #endif
 
-	if (current_el() == 3)
+	if (current_el() == 3) {
 		multi_boot();
+		secure_boot();
+	}
 
 	return 0;
 }
Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Jorge,

Quoted 59 lines · Jorge Ramirez-Ortiz

Confirm the secure boot configuration on the console.

---
 arch/arm/mach-zynqmp/include/mach/hardware.h |  3 ++-
 board/xilinx/zynqmp/zynqmp.c                 | 16 +++++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)
arch/arm/mach-zynqmp/include/mach/hardware.h +2 -1
index 3776499070..3d3ffa086e 100644
@@ -139,7 +139,8 @@ struct apu_regs {
 #define ZYNQMP_SILICON_VER_SHIFT       0
 
 struct csu_regs {
-       u32 reserved0[4];
+       u32 status;
+       u32 reserved0[3];
        u32 multi_boot;
        u32 reserved1[11];
        u32 idcode;
board/xilinx/zynqmp/zynqmp.c +15 -2
index 1748fec2e4..b7d11630d1 100644
@@ -355,6 +355,18 @@ static int multi_boot(void)
        return 0;
 }
 
+static void secure_boot(void)
+{
+       u32 status;
+
+       status = readl(&csu_base->status);
+       if (status & (BIT(0) | BIT(1))) {
+               printf("Secure Boot:\t%s%s\n",
+                      status & BIT(0) ? "authenticated" : "not authenticated",
+                      status & BIT(1) ? ", encrypted" : ", not encrypted");
+       }
+}
+
 #define PS_SYSMON_ANALOG_BUS_VAL       0x3210
 #define PS_SYSMON_ANALOG_BUS_REG       0xFFA50914
 
@@ -391,8 +403,10 @@ int board_init(void)
        fpga_add(fpga_xilinx, &zynqmppl);
 #endif
 
-       if (current_el() == 3)
+       if (current_el() == 3) {
                multi_boot();
+               secure_boot();
+       }
 
        return 0;
 }
--
Quoted 2 lines

2.31.1

Signature · 8 lines
Best regards - Freundliche Grüsse - Meilleures salutations

Igor Opaniuk

mailto: [email protected]
skype: igor.opanyuk
+380 (93) 836 40 67
http://ua.linkedin.com/in/iopaniuk
#2 lore raw
In reply to Jorge Ramirez-Ortiz

On 22/07/21, Jorge Ramirez-Ortiz wrote:

reminder

Quoted 60 lines

Confirm the secure boot configuration on the console.

---
 arch/arm/mach-zynqmp/include/mach/hardware.h |  3 ++-
 board/xilinx/zynqmp/zynqmp.c                 | 16 +++++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)
arch/arm/mach-zynqmp/include/mach/hardware.h +2 -1
index 3776499070..3d3ffa086e 100644
@@ -139,7 +139,8 @@ struct apu_regs {
 #define ZYNQMP_SILICON_VER_SHIFT	0
 
 struct csu_regs {
-	u32 reserved0[4];
+	u32 status;
+	u32 reserved0[3];
 	u32 multi_boot;
 	u32 reserved1[11];
 	u32 idcode;
board/xilinx/zynqmp/zynqmp.c +15 -1
index 1748fec2e4..b7d11630d1 100644
@@ -355,6 +355,18 @@ static int multi_boot(void)
 	return 0;
 }
 
+static void secure_boot(void)
+{
+	u32 status;
+
+	status = readl(&csu_base->status);
+	if (status & (BIT(0) | BIT(1))) {
+		printf("Secure Boot:\t%s%s\n",
+		       status & BIT(0) ? "authenticated" : "not authenticated",
+		       status & BIT(1) ? ", encrypted" : ", not encrypted");
+	}
+}
+
 #define PS_SYSMON_ANALOG_BUS_VAL	0x3210
 #define PS_SYSMON_ANALOG_BUS_REG	0xFFA50914
 
@@ -391,8 +403,10 @@ int board_init(void)
 	fpga_add(fpga_xilinx, &zynqmppl);
 #endif
 
-	if (current_el() == 3)
+	if (current_el() == 3) {
 		multi_boot();
+		secure_boot();
+	}
 
 	return 0;
 }
Signature · 1 line
2.31.1
#3 lore raw
In reply to Jorge Ramirez-Ortiz
Quoted 27 lines · Jorge Ramirez-Ortiz

Confirm the secure boot configuration on the console.

---
 arch/arm/mach-zynqmp/include/mach/hardware.h |  3 ++-
 board/xilinx/zynqmp/zynqmp.c                 | 16 +++++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)
arch/arm/mach-zynqmp/include/mach/hardware.h +2 -1
index 3776499070..3d3ffa086e 100644
@@ -139,7 +139,8 @@ struct apu_regs {
 #define ZYNQMP_SILICON_VER_SHIFT	0
 
 struct csu_regs {
-	u32 reserved0[4];
+	u32 status;
+	u32 reserved0[3];
 	u32 multi_boot;
 	u32 reserved1[11];
 	u32 idcode;
board/xilinx/zynqmp/zynqmp.c +0 -0
index 1748fec2e4..b7d11630d1 100644

board/xilinx/zynqmp/zynqmp.c static int multi_boot(void) · line 363

Quoted 9 lines
board/xilinx/zynqmp/zynqmp.c +6 -0
@@ -355,6 +355,18 @@ static int multi_boot(void)
 	return 0;
 }
 
+static void secure_boot(void)
+{
+	u32 status;
+
+	status = readl(&csu_base->status);
+	if (status & (BIT(0) | BIT(1))) {

please create macros for these bits.

{} around are not needed.

board/xilinx/zynqmp/zynqmp.c static int multi_boot(void) · line 366

Quoted 3 lines
board/xilinx/zynqmp/zynqmp.c +3 -0
+		printf("Secure Boot:\t%s%s\n",
+		       status & BIT(0) ? "authenticated" : "not authenticated",
+		       status & BIT(1) ? ", encrypted" : ", not encrypted");

Isn't this more space efficient? printf("Secure Boot:\t%sauthenticated, %sencrypted\n",

	       status & BIT(0) ? "" : "not ",
	       status & BIT(1) ? "" : "not ");

And as I see it is.
aarch64: (for 1/1 boards) all -33.0 rodata -17.0 spl/u-boot-spl:all -33.0 spl/u-boot-spl:rodata -17.0 spl/u-boot-spl:text -16.0 text -16.0
xilinx_zynqmp_virt: all -33 rodata -17 spl/u-boot-spl:all
-33 spl/u-boot-spl:rodata -17 spl/u-boot-spl:text -16 text -16

               spl-u-boot-spl: add: 0/0, grow: 0/-1 bytes: 0/-16 (-16)
Quoted 7 lines
board/xilinx/zynqmp/zynqmp.c +3 -0
+	}
+}
+
 #define PS_SYSMON_ANALOG_BUS_VAL	0x3210
 #define PS_SYSMON_ANALOG_BUS_REG	0xFFA50914
 

board/xilinx/zynqmp/zynqmp.c int board_init(void) · line 409

Quoted 8 lines
board/xilinx/zynqmp/zynqmp.c +3 -1
@@ -391,8 +403,10 @@ int board_init(void)
 	fpga_add(fpga_xilinx, &zynqmppl);
 #endif
 
-	if (current_el() == 3)
+	if (current_el() == 3) {
 		multi_boot();
+		secure_boot();
+	}

Please take a look at
https://lists.denx.de/pipermail/u-boot/2021-July/456382.html
I have changed multi_boot function a little bit.

Thanks,
Michal

Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs
#4 lore raw
Quoted 33 lines · Michal Simek
Quoted 30 lines · Jorge Ramirez-Ortiz

Confirm the secure boot configuration on the console.

---
 arch/arm/mach-zynqmp/include/mach/hardware.h |  3 ++-
 board/xilinx/zynqmp/zynqmp.c                 | 16 +++++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)
arch/arm/mach-zynqmp/include/mach/hardware.h +2 -1
index 3776499070..3d3ffa086e 100644
@@ -139,7 +139,8 @@ struct apu_regs {
 #define ZYNQMP_SILICON_VER_SHIFT	0
 
 struct csu_regs {
-	u32 reserved0[4];
+	u32 status;
+	u32 reserved0[3];
 	u32 multi_boot;
 	u32 reserved1[11];
 	u32 idcode;
board/xilinx/zynqmp/zynqmp.c +0 -0
index 1748fec2e4..b7d11630d1 100644
@@ -355,6 +355,18 @@ static int multi_boot(void)
 	return 0;
 }
 
Quoted 8 lines

board/xilinx/zynqmp/zynqmp.c static int multi_boot(void) · line 363

Quoted 6 lines
board/xilinx/zynqmp/zynqmp.c +6 -0
+static void secure_boot(void)
+{
+	u32 status;
+
+	status = readl(&csu_base->status);
+	if (status & (BIT(0) | BIT(1))) {

please create macros for these bits.

ok

Quoted 2 lines

{} around are not needed.

yep

Quoted 11 lines

board/xilinx/zynqmp/zynqmp.c static int multi_boot(void) · line 366

Quoted 5 lines
board/xilinx/zynqmp/zynqmp.c +3 -0
+		printf("Secure Boot:\t%s%s\n",
+		       status & BIT(0) ? "authenticated" : "not authenticated",
+		       status & BIT(1) ? ", encrypted" : ", not encrypted");

Isn't this more space efficient? printf("Secure Boot:\t%sauthenticated, %sencrypted\n",

	       status & BIT(0) ? "" : "not ",
	       status & BIT(1) ? "" : "not ");
Quoted 8 lines

And as I see it is.
aarch64: (for 1/1 boards) all -33.0 rodata -17.0 spl/u-boot-spl:all -33.0 spl/u-boot-spl:rodata -17.0 spl/u-boot-spl:text -16.0 text -16.0
xilinx_zynqmp_virt: all -33 rodata -17 spl/u-boot-spl:all
-33 spl/u-boot-spl:rodata -17 spl/u-boot-spl:text -16 text -16

               spl-u-boot-spl: add: 0/0, grow: 0/-1 bytes: 0/-16 (-16)

ok with me

Quoted 10 lines
Quoted 10 lines
board/xilinx/zynqmp/zynqmp.c +3 -0
+	}
+}
+
 #define PS_SYSMON_ANALOG_BUS_VAL	0x3210
 #define PS_SYSMON_ANALOG_BUS_REG	0xFFA50914
 
@@ -391,8 +403,10 @@ int board_init(void)
 	fpga_add(fpga_xilinx, &zynqmppl);
 #endif
 
Quoted 9 lines

board/xilinx/zynqmp/zynqmp.c int board_init(void) · line 409

Quoted 5 lines
board/xilinx/zynqmp/zynqmp.c +3 -1
-	if (current_el() == 3)
+	if (current_el() == 3) {
 		multi_boot();
+		secure_boot();
+	}

Please take a look at
https://lists.denx.de/pipermail/u-boot/2021-July/456382.html
I have changed multi_boot function a little bit.

ok

Quoted 11 lines

Thanks,
Michal

Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs