public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Oliver Upton <oupton@google.com>
To: kvm@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Jim Mattson <jmattson@google.com>,
	Sean Christopherson <seanjc@google.com>,
	David Matlack <dmatlack@google.com>,
	Oliver Upton <oupton@google.com>
Subject: [kvm-unit-tests PATCH 1/2] x86: Consistently use safe_halt() in place of inline assembly
Date: Tue, 19 Oct 2021 22:53:50 +0000	[thread overview]
Message-ID: <20211019225351.970397-1-oupton@google.com> (raw)

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.

Signed-off-by: Oliver Upton <oupton@google.com>
---
 x86/svm_tests.c | 2 +-
 x86/vmexit.c    | 8 ++++----
 x86/vmx_tests.c | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/x86/svm_tests.c b/x86/svm_tests.c
index 3344e28..afdd359 100644
--- a/x86/svm_tests.c
+++ b/x86/svm_tests.c
@@ -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");
diff --git a/x86/vmexit.c b/x86/vmexit.c
index 999babf..8cfb36b 100644
--- a/x86/vmexit.c
+++ b/x86/vmexit.c
@@ -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)
diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 3b97cfa..ac2b0b4 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -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");
-- 
2.33.0.1079.g6e70778dc9-goog


             reply	other threads:[~2021-10-19 22:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-19 22:53 Oliver Upton [this message]
2021-10-19 22:53 ` [kvm-unit-tests PATCH 2/2] git: Ignore patch files in the git tree Oliver Upton
2021-10-20  8:03   ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211019225351.970397-1-oupton@google.com \
    --to=oupton@google.com \
    --cc=dmatlack@google.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox