From c2a331f275b8e8e6c049eb7d61c03c7dbb39f2a4 Mon Sep 17 00:00:00 2001 From: Nikunj A Dadhania Date: Tue, 3 Apr 2018 09:51:42 +0530 Subject: broken_sc1: check for H_PRIVILEGE Recently, found that when DAWR was disabled by linux kernel, the hcall started returning H_UNSUPPORTED, and VM did not boot up as broken_sc1 patched up SC calls falsely. Instead of checking for various returns, check if its not in privilege mode and patch sc1 in that case. CC: Michael Ellerman CC: Aneesh Kumar K.V Signed-off-by: Nikunj A Dadhania Reviewed-by: Thomas Huth Signed-off-by: Alexey Kardashevskiy --- lib/libhvcall/brokensc1.c | 10 +++++----- lib/libhvcall/libhvcall.h | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/libhvcall/brokensc1.c b/lib/libhvcall/brokensc1.c index e6387e0..d97ae77 100644 --- a/lib/libhvcall/brokensc1.c +++ b/lib/libhvcall/brokensc1.c @@ -47,13 +47,13 @@ static int check_broken_sc1(void) * supervisor mode. */ r = hcall(INS_SC1, H_SET_DABR, 0); - if (r == H_SUCCESS || r == H_HARDWARE) { - /* All is fine */ - return 0; + if (r == H_PRIVILEGE) { + /* We found a broken sc1 host! */ + return 1; } - /* We found a broken sc1 host! */ - return 1; + /* All is fine */ + return 0; } int patch_broken_sc1(void *start, void *end, uint32_t *test_ins) diff --git a/lib/libhvcall/libhvcall.h b/lib/libhvcall/libhvcall.h index 3fa4398..caa4d6d 100644 --- a/lib/libhvcall/libhvcall.h +++ b/lib/libhvcall/libhvcall.h @@ -3,6 +3,7 @@ #define H_SUCCESS 0 #define H_HARDWARE -1 +#define H_PRIVILEGE -3 /* Caller not privileged */ #define H_GET_TCE 0x1C #define H_PUT_TCE 0x20 -- cgit v1.1