Skip to contentSkip to conversation

Allow --enable-psci to choose between smc and hvc

PATCH In review Qi Feng 1 participant 2 messages Jun 18, 2021 – Jul 12, 2021 Kbuild

lore
Share & tools
lore

Qi Feng

author
#0 lore raw

PATCH 1/1 Allow --enable-psci to choose between smc and hvc

According to Armv8-R AArch64 manual [1], Armv8-R AArch64 does not support smc:

- Pseudocode for AArch64.CheckForSMCUndefOrTrap has this snippet:

      if !HaveEL(EL3) || PSTATE.EL == EL0 then
          UNDEFINED;

And Armv8-R AArch64 does not have EL3.

- In the document of HCR_EL2 TSC bit:
If EL3 is not implemented and HCR_EL2.NV is 0, it is IMPLEMENTATION DEFINED whether this bit is:
- RES0.
- Implemented with the functionality as described in HCR_EL2.TSC.

So hvc is needed in this situation. And due to the lack of libfdt, the psci method cannot be modified at runtime.

To use smc, use --enable-psci or --enable-psci=smc. To use hvc, use --enable-psci=hvc.

[1]: https://developer.arm.com/documentation/ddi0600/latest/

---
 Makefile.am  |  2 +-
 configure.ac | 14 +++++++++-----
 2 files changed, 10 insertions(+), 6 deletions(-)
Makefile.am +1 -1
index ef6b793..a9ddd16 100644
@@ -47,7 +47,7 @@ BOOTMETHOD	:= psci.o
 OFILES		+= psci.o
 PSCI_NODE	:= psci {				\
 			compatible = \"arm,psci\";	\
-			method = \"smc\";		\
+			method = \"$(PSCI_METHOD)\";	\
 			cpu_on = <$(PSCI_CPU_ON)>;	\
 			cpu_off = <$(PSCI_CPU_OFF)>;	\
 		   };
configure.ac +9 -5
index 6914eb4..9aab4a1 100644
@@ -83,13 +83,17 @@ AS_IF([test "x$X_IMAGE" != "x"],
 # Allow a user to pass --enable-psci
 AC_ARG_ENABLE([psci],
 	AS_HELP_STRING([--enable-psci], [enable the psci boot method]),
-	[USE_PSCI=$enableval])
-AM_CONDITIONAL([PSCI], [test "x$USE_PSCI" = "xyes"])
-AS_IF([test "x$USE_PSCI" = "xyes"], [], [USE_PSCI=no])
-
-AS_IF([test "x$USE_PSCI" != "xyes" -a "x$KERNEL_ES" = "x32"],
+	[case "${enableval}" in
+		yes|smc) USE_PSCI=smc ;;
+		hvc) USE_PSCI=hvc ;;
+		*) AC_MSG_ERROR([Bad value "${enableval}" for --enable-psci. Use "smc" or "hvc"]) ;;
+	esac])
+AM_CONDITIONAL([PSCI], [test "x$USE_PSCI" = "xyes" -o "x$USE_PSCI" = "xsmc" -o "x$USE_PSCI" = "xhvc"])
+
+AS_IF([test "x$USE_PSCI" = "xno" -a "x$KERNEL_ES" = "x32"],
 	[AC_MSG_ERROR([With an AArch32 kernel, boot method must be PSCI.])]
 )
+AC_SUBST([PSCI_METHOD], [$USE_PSCI])
 
 # Allow a user to pass --with-initrd
 AC_ARG_WITH([initrd],
Signature · 7 lines
2.25.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#1 lore raw

Any comments for this patch?

Quoted 61 lines · Qi Feng

According to Armv8-R AArch64 manual [1], Armv8-R AArch64 does not support smc:

- Pseudocode for AArch64.CheckForSMCUndefOrTrap has this snippet:

       if !HaveEL(EL3) || PSTATE.EL == EL0 then
           UNDEFINED;

And Armv8-R AArch64 does not have EL3.

- In the document of HCR_EL2 TSC bit:
If EL3 is not implemented and HCR_EL2.NV is 0, it is IMPLEMENTATION DEFINED whether this bit is:
- RES0.
- Implemented with the functionality as described in HCR_EL2.TSC.

So hvc is needed in this situation. And due to the lack of libfdt, the psci method cannot be modified at runtime.

To use smc, use --enable-psci or --enable-psci=smc. To use hvc, use --enable-psci=hvc.

[1]: https://developer.arm.com/documentation/ddi0600/latest/

---
  Makefile.am  |  2 +-
  configure.ac | 14 +++++++++-----
  2 files changed, 10 insertions(+), 6 deletions(-)
Makefile.am +1 -1
index ef6b793..a9ddd16 100644
@@ -47,7 +47,7 @@ BOOTMETHOD	:= psci.o
  OFILES		+= psci.o
  PSCI_NODE	:= psci {				\
  			compatible = \"arm,psci\";	\
-			method = \"smc\";		\
+			method = \"$(PSCI_METHOD)\";	\
  			cpu_on = <$(PSCI_CPU_ON)>;	\
  			cpu_off = <$(PSCI_CPU_OFF)>;	\
  		   };
configure.ac +4 -5
index 6914eb4..9aab4a1 100644
@@ -83,13 +83,17 @@ AS_IF([test "x$X_IMAGE" != "x"],
  # Allow a user to pass --enable-psci
  AC_ARG_ENABLE([psci],
  	AS_HELP_STRING([--enable-psci], [enable the psci boot method]),
-	[USE_PSCI=$enableval])
-AM_CONDITIONAL([PSCI], [test "x$USE_PSCI" = "xyes"])
-AS_IF([test "x$USE_PSCI" = "xyes"], [], [USE_PSCI=no])
-
-AS_IF([test "x$USE_PSCI" != "xyes" -a "x$KERNEL_ES" = "x32"],
+	[case "${enableval}" in
+		yes|smc) USE_PSCI=smc ;;
+		hvc) USE_PSCI=hvc ;;
+		*) AC_MSG_ERROR([Bad value "${enableval}" for --enable-psci. Use "smc" or "hvc"]) ;;

configure.ac AS_IF([test "x$X_IMAGE" != "x"], · line 99

Quoted 10 lines
configure.ac +5 -0
+	esac])
+AM_CONDITIONAL([PSCI], [test "x$USE_PSCI" = "xyes" -o "x$USE_PSCI" = "xsmc" -o "x$USE_PSCI" = "xhvc"])
+
+AS_IF([test "x$USE_PSCI" = "xno" -a "x$KERNEL_ES" = "x32"],
  	[AC_MSG_ERROR([With an AArch32 kernel, boot method must be PSCI.])]
  )
+AC_SUBST([PSCI_METHOD], [$USE_PSCI])
 
  # Allow a user to pass --with-initrd
  AC_ARG_WITH([initrd],

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel