diff mbox series

broken_sc1: handle H_UNSUPPORTED as well

Message ID 20180402095312.16343-1-nikunj@linux.vnet.ibm.com
State Superseded
Headers show
Series broken_sc1: handle H_UNSUPPORTED as well | expand

Commit Message

Nikunj A Dadhania April 2, 2018, 9:53 a.m. UTC
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. Make sure we handle H_UNSUPPORTED as well.

CC: Michael Ellerman <michael@ellerman.id.au>
CC: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
---
 lib/libhvcall/brokensc1.c | 2 +-
 lib/libhvcall/libhvcall.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

Comments

Thomas Huth April 2, 2018, 7:38 p.m. UTC | #1
On 02.04.2018 11:53, Nikunj A Dadhania wrote:
> 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. Make sure we handle H_UNSUPPORTED as well.
> 
> CC: Michael Ellerman <michael@ellerman.id.au>
> CC: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
> ---
>  lib/libhvcall/brokensc1.c | 2 +-
>  lib/libhvcall/libhvcall.h | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/libhvcall/brokensc1.c b/lib/libhvcall/brokensc1.c
> index e6387e0..163ee30 100644
> --- a/lib/libhvcall/brokensc1.c
> +++ b/lib/libhvcall/brokensc1.c
> @@ -47,7 +47,7 @@ static int check_broken_sc1(void)
>  	 * supervisor mode.
>  	 */
>  	r = hcall(INS_SC1, H_SET_DABR, 0);
> -	if (r == H_SUCCESS || r == H_HARDWARE) {
> +	if (r == H_SUCCESS || r == H_HARDWARE || r == H_UNSUPPORTED) {
>  		/* All is fine */
>  		return 0;

Sounds like this is ok for now. But while you're at it, it's maybe
cleaner to revert the logic here:

	r = hcall(INS_SC1, H_SET_DABR, 0);
	if (r == H_PRIVILEGE)
		return 1;

	return 0;

We're using this check in kvm-unit-tests, too, and I think it makes more
sense to check for H_PRIVILEGE than the other way round.

 Thomas
diff mbox series

Patch

diff --git a/lib/libhvcall/brokensc1.c b/lib/libhvcall/brokensc1.c
index e6387e0..163ee30 100644
--- a/lib/libhvcall/brokensc1.c
+++ b/lib/libhvcall/brokensc1.c
@@ -47,7 +47,7 @@  static int check_broken_sc1(void)
 	 * supervisor mode.
 	 */
 	r = hcall(INS_SC1, H_SET_DABR, 0);
-	if (r == H_SUCCESS || r == H_HARDWARE) {
+	if (r == H_SUCCESS || r == H_HARDWARE || r == H_UNSUPPORTED) {
 		/* All is fine */
 		return 0;
 	}
diff --git a/lib/libhvcall/libhvcall.h b/lib/libhvcall/libhvcall.h
index 3fa4398..1ef320e 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_UNSUPPORTED           -67
 
 #define H_GET_TCE		0x1C
 #define H_PUT_TCE		0x20