Skip to contentSkip to conversation

x86: Halt on exit

PATCH Applied Nadav Amit 2 participants 2 messages May 13, 2019 – May 20, 2019 KVM

lore
Share & tools
lore

Nadav Amit

author
#0 lore raw

PATCH v2 1/1 x86: Halt on exit

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.

---
 lib/x86/io.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
lib/x86/io.c +5 -1
index f3e01f7..f4ffb44 100644
@@ -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)
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw
Quoted 17 lines · Nadav Amit

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.

---
 lib/x86/io.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
lib/x86/io.c +0 -0
index f3e01f7..f4ffb44 100644
@@ -99,7 +99,11 @@ void exit(int code)
 #else
         asm volatile("out %0, %1" : : "a"(code), "d"((short)0xf4));

lib/x86/io.c void exit(int code) · line 109

Quoted 10 lines
lib/x86/io.c +5 -1
 #endif
-	__builtin_unreachable();
+
+	/* Fallback */
+	while (1) {
+		asm volatile("hlt" ::: "memory");
+	}
 }
 
 void __iomem *ioremap(phys_addr_t phys_addr, size_t size)

Queued, thanks.

Paolo