[kvm-unit-tests] x86: Attempt to parse ACPI tables only when needed
diff mbox series

Message ID 20190822234837.3500-1-sean.j.christopherson@intel.com
State New
Headers show
Series
  • [kvm-unit-tests] x86: Attempt to parse ACPI tables only when needed
Related show

Commit Message

Sean Christopherson Aug. 22, 2019, 11:48 p.m. UTC
Parsing the ACPI tables to find the PM timer port hits a #PF on 32-bit
unit tests.  Regardless of what is causing the #PF, move the parsing to
the pmtimer test to unblock the other VM-Exit tests.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 x86/vmexit.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Patch
diff mbox series

diff --git a/x86/vmexit.c b/x86/vmexit.c
index fa72be7..66d3458 100644
--- a/x86/vmexit.c
+++ b/x86/vmexit.c
@@ -196,6 +196,13 @@  static void ipi_halt(void)
 int pm_tmr_blk;
 static void inl_pmtimer(void)
 {
+    if (!pm_tmr_blk) {
+	struct fadt_descriptor_rev1 *fadt;
+
+	fadt = find_acpi_table_addr(FACP_SIGNATURE);
+	pm_tmr_blk = fadt->pm_tmr_blk;
+	printf("PM timer port is %x\n", pm_tmr_blk);
+    }
     inl(pm_tmr_blk);
 }
 
@@ -541,7 +548,6 @@  static bool test_wanted(struct test *test, char *wanted[], int nwanted)
 
 int main(int ac, char **av)
 {
-	struct fadt_descriptor_rev1 *fadt;
 	int i;
 	unsigned long membar = 0;
 	struct pci_dev pcidev;
@@ -555,10 +561,6 @@  int main(int ac, char **av)
 	irq_enable();
 	on_cpus(enable_nx, NULL);
 
-	fadt = find_acpi_table_addr(FACP_SIGNATURE);
-	pm_tmr_blk = fadt->pm_tmr_blk;
-	printf("PM timer port is %x\n", pm_tmr_blk);
-
 	ret = pci_find_dev(PCI_VENDOR_ID_REDHAT, PCI_DEVICE_ID_REDHAT_TEST);
 	if (ret != PCIDEVADDR_INVALID) {
 		pci_dev_init(&pcidev, ret);