Skip vm_is_gpa_protected() call for APIC MMIO address in __virt_pg_map().
Without this change, the virt_pg_map() fails with below error for
APIC MMIO address.

    No vm physical memory at 0xfee00000

Signed-off-by: Neeraj Upadhyay <neeraj.upadh...@amd.com>
---
 tools/testing/selftests/kvm/lib/x86/processor.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/testing/selftests/kvm/lib/x86/processor.c 
b/tools/testing/selftests/kvm/lib/x86/processor.c
index 7129dfb652c4..197110ff1380 100644
--- a/tools/testing/selftests/kvm/lib/x86/processor.c
+++ b/tools/testing/selftests/kvm/lib/x86/processor.c
@@ -8,6 +8,7 @@
 #include "kvm_util.h"
 #include "processor.h"
 #include "sev.h"
+#include "apic.h"
 
 #ifndef NUM_INTERRUPTS
 #define NUM_INTERRUPTS 256
@@ -227,6 +228,11 @@ void __virt_pg_map(struct kvm_vm *vm, uint64_t vaddr, 
uint64_t paddr, int level)
                    "PTE already present for 4k page at vaddr: 0x%lx", vaddr);
        *pte = PTE_PRESENT_MASK | PTE_WRITABLE_MASK | (paddr & 
PHYSICAL_PAGE_MASK);
 
+       if (paddr == APIC_DEFAULT_GPA) {
+               *pte |= vm->arch.s_bit;
+               return;
+       }
+
        /*
         * Neither SEV nor TDX supports shared page tables, so only the final
         * leaf PTE needs manually set the C/S-bit.
-- 
2.34.1


Reply via email to