[PATCH] powerpc/pseries: Avoid hcall in plpks_is_available() on non-pseries

Russell Currey ruscur at russell.cc
Wed Feb 22 13:17:08 AEDT 2023


plpks_is_available() can be called on any platform via kexec but calls
_plpks_get_config() which makes a hcall, which will only work on pseries.
Fix this by returning early in plpks_is_available() if hcalls aren't
possible.

Fixes: 119da30d037d ("powerpc/pseries: Expose PLPKS config values, support additional fields")
Reported-by: Murphy Zhou <jencce.kernel at gmail.com>
Signed-off-by: Russell Currey <ruscur at russell.cc>
---
 arch/powerpc/platforms/pseries/plpks.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/platforms/pseries/plpks.c b/arch/powerpc/platforms/pseries/plpks.c
index cdf09e5bd741..6f7bf3fc3aea 100644
--- a/arch/powerpc/platforms/pseries/plpks.c
+++ b/arch/powerpc/platforms/pseries/plpks.c
@@ -22,6 +22,7 @@
 #include <asm/hvcall.h>
 #include <asm/machdep.h>
 #include <asm/plpks.h>
+#include <asm/firmware.h>
 
 static u8 *ospassword;
 static u16 ospasswordlength;
@@ -377,6 +378,9 @@ bool plpks_is_available(void)
 {
 	int rc;
 
+	if (!firmware_has_feature(FW_FEATURE_LPAR))
+		return false;
+
 	rc = _plpks_get_config();
 	if (rc)
 		return false;
-- 
2.39.2



More information about the Linuxppc-dev mailing list