Skip to contentSkip to conversation

x86: Consistently use safe_halt() in place of inline assembly

PATCH Applied Oliver Upton 2 participants 3 messages Oct 19, 2021 – Oct 20, 2021 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 x86: Consistently use safe_halt() in place of inline assembly

The safe_halt() library function simply performs an 'sti; hlt' instruction sequence. There are several places where bare inline assembly was used instead of this helper. Replace all open-coded implementations with the helper.

No functional change intended.

---
 x86/svm_tests.c | 2 +-
 x86/vmexit.c    | 8 ++++----
 x86/vmx_tests.c | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)
x86/svm_tests.c +1 -1
index 3344e28..afdd359 100644
@@ -1302,7 +1302,7 @@ static void interrupt_test(struct svm_test *test)
     timer_fired = false;
     start = rdtsc();
     apic_write(APIC_TMICT, 1000000);
-    asm volatile ("sti; hlt");
+    safe_halt();
 
     report(rdtsc() - start > 10000 && timer_fired,
           "direct interrupt + hlt");
x86/vmexit.c +4 -4
index 999babf..8cfb36b 100644
@@ -103,7 +103,7 @@ static void self_ipi_sti_hlt(void)
 	x = 0;
 	irq_disable();
 	apic_self_ipi(IPI_TEST_VECTOR);
-	asm volatile("sti; hlt");
+	safe_halt();
 	if (x != 1) printf("%d", x);
 }
 
@@ -135,7 +135,7 @@ static void self_ipi_tpr_sti_hlt(void)
 	apic_set_tpr(0x0f);
 	apic_self_ipi(IPI_TEST_VECTOR);
 	apic_set_tpr(0x00);
-	asm volatile("sti; hlt");
+	safe_halt();
 	if (x != 1) printf("%d", x);
 }
 
@@ -155,7 +155,7 @@ static void x2apic_self_ipi_sti_hlt(void)
 {
 	irq_disable();
 	x2apic_self_ipi(IPI_TEST_VECTOR);
-	asm volatile("sti; hlt");
+	safe_halt();
 }
 
 static void x2apic_self_ipi_tpr(void)
@@ -181,7 +181,7 @@ static void x2apic_self_ipi_tpr_sti_hlt(void)
 	apic_set_tpr(0x0f);
 	x2apic_self_ipi(IPI_TEST_VECTOR);
 	apic_set_tpr(0x00);
-	asm volatile("sti; hlt");
+	safe_halt();
 }
 
 static void ipi(void)
x86/vmx_tests.c +2 -2
index 3b97cfa..ac2b0b4 100644
@@ -1674,7 +1674,7 @@ static void interrupt_main(void)
 	start = rdtsc();
 	apic_write(APIC_TMICT, 1000000);
 
-	asm volatile ("sti; hlt");
+	safe_halt();
 
 	report(rdtsc() - start > 1000000 && timer_fired,
 	       "direct interrupt + hlt");
@@ -1686,7 +1686,7 @@ static void interrupt_main(void)
 	start = rdtsc();
 	apic_write(APIC_TMICT, 1000000);
 
-	asm volatile ("sti; hlt");
+	safe_halt();
 
 	report(rdtsc() - start > 10000 && timer_fired,
 	       "intercepted interrupt + hlt");
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
#1 lore raw

PATCH 2/2 git: Ignore patch files in the git tree

---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)
.gitignore +1 -0
index b3cf2cb..3d5be62 100644
@@ -5,6 +5,7 @@ tags
 *.o
 *.flat
 *.elf
+*.patch
 .pc
 patches
 .stgit-*
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
maintainer Applied
#2 lore raw

Re: [kvm-unit-tests PATCH 2/2] git: Ignore patch files in the git tree

Quoted 11 lines · Oliver Upton
---
  .gitignore | 1 +
  1 file changed, 1 insertion(+)
.gitignore +0 -0
index b3cf2cb..3d5be62 100644

.gitignore tags · line 11

Quoted 7 lines
.gitignore +1 -0
@@ -5,6 +5,7 @@ tags
  *.o
  *.flat
  *.elf
+*.patch
  .pc
  patches
  .stgit-*

Queued both, thanks. (Next time, for unrelated patches you can use --no-numbered --no-thread in git-send-email).

Paolo