All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, Maxim Levitsky <mlevitsk@redhat.com>,
	Sean Christopherson <seanjc@google.com>
Subject: [kvm-unit-tests PATCH 4/9] x86/apic: Assert that vCPU0's APIC is enabled at the start of the test
Date: Sat,  1 Oct 2022 01:12:56 +0000	[thread overview]
Message-ID: <20221001011301.2077437-5-seanjc@google.com> (raw)
In-Reply-To: <20221001011301.2077437-1-seanjc@google.com>

Assert that vCPU's APIC is fully enabled at the start of the apic test.
The boot code is supposed to do that, but nothing ever actually verifies
the APIC got setup correctly.

Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 x86/apic.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/x86/apic.c b/x86/apic.c
index 650c1d0..6c555ce 100644
--- a/x86/apic.c
+++ b/x86/apic.c
@@ -15,6 +15,11 @@ static bool is_apic_hw_enabled(void)
 	return rdmsr(MSR_IA32_APICBASE) & APIC_EN;
 }
 
+static bool is_apic_sw_enabled(void)
+{
+	return apic_read(APIC_SPIV) & APIC_SPIV_APIC_ENABLED;
+}
+
 static bool is_x2apic_enabled(void)
 {
 	return (rdmsr(MSR_IA32_APICBASE) & (APIC_EN | APIC_EXTD)) == (APIC_EN | APIC_EXTD);
@@ -691,6 +696,9 @@ static void test_pv_ipi(void)
 
 int main(void)
 {
+	assert_msg(is_apic_hw_enabled() && is_apic_sw_enabled(),
+		   "APIC should be fully enabled by startup code.");
+
 	setup_vm();
 
 	test_lapic_existence();
-- 
2.38.0.rc1.362.ged0d419d3c-goog


  parent reply	other threads:[~2022-10-01  1:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-01  1:12 [kvm-unit-tests PATCH 0/9] x86/apic: Cleanups and new tests Sean Christopherson
2022-10-01  1:12 ` [kvm-unit-tests PATCH 1/9] x86/apic: Add test config to allow running apic tests against SVM's AVIC Sean Christopherson
2022-10-01  1:12 ` [kvm-unit-tests PATCH 2/9] x86/apic: Replaces spaces with tabs to fix indentation in apic.c Sean Christopherson
2022-10-01  1:12 ` [kvm-unit-tests PATCH 3/9] x86/apic: Add helpers to query current APIC state, e.g. xAPIC vs. x2APIC Sean Christopherson
2022-10-01  1:12 ` Sean Christopherson [this message]
2022-10-01  1:12 ` [kvm-unit-tests PATCH 5/9] x86/apic: Restore APIC to original state after every sub-test Sean Christopherson
2022-10-01  1:12 ` [kvm-unit-tests PATCH 6/9] x86/apic: Enable IRQs on vCPU0 for all tests Sean Christopherson
2022-10-01  1:12 ` [kvm-unit-tests PATCH 7/9] x86/apic: Run tests that modify APIC ID and/or APIC_BASE after other tests Sean Christopherson
2022-10-01  1:13 ` [kvm-unit-tests PATCH 8/9] x86/apic: Add test for logical mode IPI delivery (cluster and flat) Sean Christopherson
2022-10-01  1:13 ` [kvm-unit-tests PATCH 9/9] x86/apic: Add test to verify aliased xAPIC IDs both receive IPI Sean Christopherson

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=20221001011301.2077437-5-seanjc@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=mlevitsk@redhat.com \
    --cc=pbonzini@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.