From: Jim Mattson Subject: [kvm-unit-tests PATCH 4/4] Test of virtual-APIC address Date: Thu, 24 Aug 2017 13:23:56 -0700 Message-ID: <20170824202356.61397-4-jmattson@google.com> References: <20170824202356.61397-1-jmattson@google.com> Cc: Jim Mattson To: kvm@vger.kernel.org Return-path: Received: from mail-pg0-f42.google.com ([74.125.83.42]:36340 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753217AbdHXUYV (ORCPT ); Thu, 24 Aug 2017 16:24:21 -0400 Received: by mail-pg0-f42.google.com with SMTP id r133so2956993pgr.3 for ; Thu, 24 Aug 2017 13:24:21 -0700 (PDT) In-Reply-To: <20170824202356.61397-1-jmattson@google.com> Sender: kvm-owner@vger.kernel.org List-ID: This test checks that a nested VM-entry fails if the "use TPR shadow" VM-execution control is set and the virtual-APIC address is illegal. A legal virtual-apic address is 4k-aligned and within the physical address space supported by the processor. Signed-off-by: Jim Mattson --- x86/vmx_tests.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index 22295e8..32aa35a 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -3438,6 +3438,20 @@ static void test_msr_bitmap(void) "MSR bitmap", "Use MSR bitmaps"); } +/* + * If the "use TPR shadow" VM-execution control is 1, the virtual-APIC + * address must satisfy the following checks: + * - Bits 11:0 of the address must be 0. + * - The address should not set any bits beyond the processor's + * physical-address width. + * [Intel SDM] + */ +static void test_apic_virt_addr(void) +{ + test_vmcs_page_reference(CPU_TPR_SHADOW, APIC_VIRT_ADDR, + "virtual-APIC address", "Use TPR shadow"); +} + static void vmx_controls_test(void) { /* @@ -3453,6 +3467,7 @@ static void vmx_controls_test(void) test_cr3_targets(); test_io_bitmaps(); test_msr_bitmap(); + test_apic_virt_addr(); } static bool valid_vmcs_for_vmentry(void) -- 2.14.1.342.g6490525c54-goog