Skip to contentSkip to conversation

x86: Halt on exit

PATCH Superseded Nadav Amit 3 participants 5 messages May 10, 2019 – May 13, 2019 KVM

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Nadav Amit

author
#0 lore raw

PATCH 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.

---
 lib/x86/io.c | 4 ++++
 1 file changed, 4 insertions(+)
lib/x86/io.c +4 -0
index f3e01f7..e6372c6 100644
@@ -99,6 +99,10 @@ void exit(int code)
 #else
         asm volatile("out %0, %1" : : "a"(code), "d"((short)0xf4));
 #endif
+	/* Fallback */
+	while (1) {
+		asm volatile ("hlt" ::: "memory");
+	}
 	__builtin_unreachable();
 }
 
Signature · 1 line
2.17.1
author
#1 lore raw

Err… kvm-unit-tests patch if there is any doubt.

Quoted 27 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.

---
lib/x86/io.c | 4 ++++

1 file changed, 4 insertions(+)
lib/x86/io.c +4 -0
index f3e01f7..e6372c6 100644
@@ -99,6 +99,10 @@ void exit(int code)
 #else
        asm volatile("out %0, %1" : : "a"(code), "d"((short)0xf4));
 #endif
+	/* Fallback */
+	while (1) {
+		asm volatile ("hlt" ::: "memory");
+	}
 	__builtin_unreachable();
 }
 
Signature · 1 line
2.17.1
#2 lore raw
Quoted 2 lines · Nadav Amit

Err… kvm-unit-tests patch if there is any doubt.

you should contain kvm-unit-tests in the subject as [kvm-unit-tests PATCH]

otherwise, we don't know it's a kvm-unit-tests patch.

Quoted 29 lines
Quoted 27 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.

---
lib/x86/io.c | 4 ++++

1 file changed, 4 insertions(+)
lib/x86/io.c +4 -0
index f3e01f7..e6372c6 100644
@@ -99,6 +99,10 @@ void exit(int code)
 #else
         asm volatile("out %0, %1" : : "a"(code), "d"((short)0xf4));
 #endif
+	/* Fallback */
+	while (1) {
+		asm volatile ("hlt" ::: "memory");
+	}
 	__builtin_unreachable();
 }
 
Signature · 1 line
2.17.1
author
#3 lore raw
Quoted 8 lines · Xiaoyao Li
Quoted 1 line · Nadav Amit

Err… kvm-unit-tests patch if there is any doubt.

you should contain kvm-unit-tests in the subject as [kvm-unit-tests PATCH]

otherwise, we don't know it's a kvm-unit-tests patch.

Thanks, I know. The “Err…” meant to say “Oops, I forgot the --subject-prefix, please excuse me."

Quoted 28 lines
Quoted 28 lines
Quoted 28 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.

---
lib/x86/io.c | 4 ++++

1 file changed, 4 insertions(+)
lib/x86/io.c +4 -0
index f3e01f7..e6372c6 100644
@@ -99,6 +99,10 @@ void exit(int code)
 #else
        asm volatile("out %0, %1" : : "a"(code), "d"((short)0xf4));
 #endif
+	/* Fallback */
+	while (1) {
+		asm volatile ("hlt" ::: "memory");
+	}
 	__builtin_unreachable();
 }
 
Signature · 1 line
2.17.1
#4 lore raw
In reply to Nadav Amit

2019-05-09 12:50-0700, Nadav Amit:

Quoted 10 lines

In some cases, shutdown through the test device and Bochs might fail. Just hang in a loop that executes halt in such cases.

---
 lib/x86/io.c | 4 ++++
 1 file changed, 4 insertions(+)

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

Quoted 8 lines
lib/x86/io.c +4 -0
@@ -99,6 +99,10 @@ void exit(int code)
 #else
         asm volatile("out %0, %1" : : "a"(code), "d"((short)0xf4));
 #endif
+	/* Fallback */
+	while (1) {
+		asm volatile ("hlt" ::: "memory");
+	}
 	__builtin_unreachable();

Looks good, we can also drop the __builtin_unreachable() now.