diff mbox series

[kvm-unit-tests] x86: nVMX: fix EPT A/D disabled MMIO access test

Message ID 20181008150403.8489-1-vkuznets@redhat.com (mailing list archive)
State New, archived
Headers show
Series [kvm-unit-tests] x86: nVMX: fix EPT A/D disabled MMIO access test | expand

Commit Message

Vitaly Kuznetsov Oct. 8, 2018, 3:04 p.m. UTC
When testing MMIO interface to APIC we need to make sure that APIC is in
xAPIC mode (and not x2APIC). KVM started enforcing this since commit
d1766202779e ("x86/kvm/lapic: always disable MMIO interface in x2APIC
mode").

While the 'clean' fix would be to separate L2's APIC from L1's and put
it to xAPIC mode or create a different MMIO mapping just for the test
we lack the required infrastructure in vmx library. As a quick band-aid
put L1's APIC to xAPIC mode for both EPT A/D enabled and disabled tests,
it seems we don't require x2APIC for anything.

Reported-by: kernel test robot <rong.a.chen@intel.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 x86/vmx_tests.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Paolo Bonzini Oct. 10, 2018, 4:53 p.m. UTC | #1
On 08/10/2018 17:04, Vitaly Kuznetsov wrote:
> When testing MMIO interface to APIC we need to make sure that APIC is in
> xAPIC mode (and not x2APIC). KVM started enforcing this since commit
> d1766202779e ("x86/kvm/lapic: always disable MMIO interface in x2APIC
> mode").
> 
> While the 'clean' fix would be to separate L2's APIC from L1's and put
> it to xAPIC mode or create a different MMIO mapping just for the test
> we lack the required infrastructure in vmx library. As a quick band-aid
> put L1's APIC to xAPIC mode for both EPT A/D enabled and disabled tests,
> it seems we don't require x2APIC for anything.
> 
> Reported-by: kernel test robot <rong.a.chen@intel.com>
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> ---
>  x86/vmx_tests.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
> index b105b23..cc5192f 100644
> --- a/x86/vmx_tests.c
> +++ b/x86/vmx_tests.c
> @@ -1094,6 +1094,8 @@ static int ept_init_common(bool have_ad)
>  	install_ept(pml4, (unsigned long)data_page1, (unsigned long)data_page2,
>  			EPT_RA | EPT_WA | EPT_EA);
>  
> +	reset_apic();
> +
>  	apic_version = apic_read(APIC_LVR);
>  
>  	ret = pci_find_dev(PCI_VENDOR_ID_REDHAT, PCI_DEVICE_ID_REDHAT_TEST);
> 

Queued, thanks.

Paolo
Vitaly Kuznetsov Nov. 9, 2018, 10:59 a.m. UTC | #2
Paolo Bonzini <pbonzini@redhat.com> writes:

> On 08/10/2018 17:04, Vitaly Kuznetsov wrote:
>> When testing MMIO interface to APIC we need to make sure that APIC is in
>> xAPIC mode (and not x2APIC). KVM started enforcing this since commit
>> d1766202779e ("x86/kvm/lapic: always disable MMIO interface in x2APIC
>> mode").
>> 
>> While the 'clean' fix would be to separate L2's APIC from L1's and put
>> it to xAPIC mode or create a different MMIO mapping just for the test
>> we lack the required infrastructure in vmx library. As a quick band-aid
>> put L1's APIC to xAPIC mode for both EPT A/D enabled and disabled tests,
>> it seems we don't require x2APIC for anything.
>> 
>> Reported-by: kernel test robot <rong.a.chen@intel.com>
>> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>> ---
>>  x86/vmx_tests.c | 2 ++
>>  1 file changed, 2 insertions(+)
>> 
>> diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
>> index b105b23..cc5192f 100644
>> --- a/x86/vmx_tests.c
>> +++ b/x86/vmx_tests.c
>> @@ -1094,6 +1094,8 @@ static int ept_init_common(bool have_ad)
>>  	install_ept(pml4, (unsigned long)data_page1, (unsigned long)data_page2,
>>  			EPT_RA | EPT_WA | EPT_EA);
>>  
>> +	reset_apic();
>> +
>>  	apic_version = apic_read(APIC_LVR);
>>  
>>  	ret = pci_find_dev(PCI_VENDOR_ID_REDHAT, PCI_DEVICE_ID_REDHAT_TEST);
>> 
>
> Queued, thanks.

Out of pure curiosity, what happened to it after it was queued? :-)
diff mbox series

Patch

diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index b105b23..cc5192f 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -1094,6 +1094,8 @@  static int ept_init_common(bool have_ad)
 	install_ept(pml4, (unsigned long)data_page1, (unsigned long)data_page2,
 			EPT_RA | EPT_WA | EPT_EA);
 
+	reset_apic();
+
 	apic_version = apic_read(APIC_LVR);
 
 	ret = pci_find_dev(PCI_VENDOR_ID_REDHAT, PCI_DEVICE_ID_REDHAT_TEST);