diff mbox series

[kvm-unit-tests,v2] x86: Halt on exit

Message ID 20190513095828.41255-1-nadav.amit@gmail.com (mailing list archive)
State New, archived
Headers show
Series [kvm-unit-tests,v2] x86: Halt on exit | expand

Commit Message

Nadav Amit May 13, 2019, 9:58 a.m. UTC
In some cases, shutdown through the test device and Bochs might fail.
Just hang in a loop that executes halt in such cases. Remove the
__builtin_unreachable() as it is not needed anymore.

Signed-off-by: Nadav Amit <nadav.amit@gmail.com>
---
 lib/x86/io.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Paolo Bonzini May 20, 2019, 2:21 p.m. UTC | #1
On 13/05/19 11:58, Nadav Amit wrote:
> In some cases, shutdown through the test device and Bochs might fail.
> Just hang in a loop that executes halt in such cases. Remove the
> __builtin_unreachable() as it is not needed anymore.
> 
> Signed-off-by: Nadav Amit <nadav.amit@gmail.com>
> ---
>  lib/x86/io.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/x86/io.c b/lib/x86/io.c
> index f3e01f7..f4ffb44 100644
> --- a/lib/x86/io.c
> +++ b/lib/x86/io.c
> @@ -99,7 +99,11 @@ void exit(int code)
>  #else
>          asm volatile("out %0, %1" : : "a"(code), "d"((short)0xf4));
>  #endif
> -	__builtin_unreachable();
> +
> +	/* Fallback */
> +	while (1) {
> +		asm volatile("hlt" ::: "memory");
> +	}
>  }
>  
>  void __iomem *ioremap(phys_addr_t phys_addr, size_t size)
> 

Queued, thanks.

Paolo
diff mbox series

Patch

diff --git a/lib/x86/io.c b/lib/x86/io.c
index f3e01f7..f4ffb44 100644
--- a/lib/x86/io.c
+++ b/lib/x86/io.c
@@ -99,7 +99,11 @@  void exit(int code)
 #else
         asm volatile("out %0, %1" : : "a"(code), "d"((short)0xf4));
 #endif
-	__builtin_unreachable();
+
+	/* Fallback */
+	while (1) {
+		asm volatile("hlt" ::: "memory");
+	}
 }
 
 void __iomem *ioremap(phys_addr_t phys_addr, size_t size)