Re: [kvm-unit-tests PATCH] VMCS shadow high access consistency

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 06/07/2017 21:28, Jim Mattson wrote:
> Test for consistency of mixed accesses to full and high parts of
> 64-bit VMCS fields. (Currently just tests TSC_OFFSET, which is one of
> the fields shadowed by kvm.)
> 
> Signed-off-by: Jim Mattson <jmattson@xxxxxxxxxx>
> ---
>  x86/unittests.cfg |  6 ++++++
>  x86/vmx.c         | 26 ++++++++++++++++++++++++++
>  2 files changed, 32 insertions(+)
> 
> diff --git a/x86/unittests.cfg b/x86/unittests.cfg
> index c9858159c657..93fc9a3f98a3 100644
> --- a/x86/unittests.cfg
> +++ b/x86/unittests.cfg
> @@ -242,6 +242,12 @@ extra_params = -cpu host,+vmx -append test_vmwrite_vmread
>  arch = x86_64
>  groups = vmx
>  
> +[vmx_test_vmcs_high]
> +file = vmx.flat
> +extra_params = -cpu host,+vmx -append test_vmcs_high
> +arch = x86_64
> +groups = vmx
> +
>  [vmx_test_vmcs_lifecycle]
>  file = vmx.flat
>  extra_params = -cpu host,+vmx -append test_vmcs_lifecycle
> diff --git a/x86/vmx.c b/x86/vmx.c
> index f71d71f64f46..8b79293d2bc4 100644
> --- a/x86/vmx.c
> +++ b/x86/vmx.c
> @@ -318,6 +318,30 @@ void test_vmwrite_vmread(void)
>  	free_page(vmcs);
>  }
>  
> +void test_vmcs_high(void)
> +{
> +	struct vmcs *vmcs = alloc_page();
> +
> +	memset(vmcs, 0, PAGE_SIZE);
> +	vmcs->revision_id = basic.revision;
> +	assert(!vmcs_clear(vmcs));
> +	assert(!make_vmcs_current(vmcs));
> +
> +	vmcs_write(TSC_OFFSET, 0x0123456789ABCDEFull);
> +	report("VMREAD TSC_OFFSET after VMWRITE TSC_OFFSET",
> +	       vmcs_read(TSC_OFFSET) == 0x0123456789ABCDEFull);
> +	report("VMREAD TSC_OFFSET_HI after VMWRITE TSC_OFFSET",
> +	       vmcs_read(TSC_OFFSET_HI) == 0x01234567ull);
> +	vmcs_write(TSC_OFFSET_HI, 0x76543210ul);
> +	report("VMREAD TSC_OFFSET_HI after VMWRITE TSC_OFFSET_HI",
> +	       vmcs_read(TSC_OFFSET_HI) == 0x76543210ul);
> +	report("VMREAD TSC_OFFSET after VMWRITE TSC_OFFSET_HI",
> +	       vmcs_read(TSC_OFFSET) == 0x7654321089ABCDEFull);
> +
> +	assert(!vmcs_clear(vmcs));
> +	free_page(vmcs);
> +}
> +
>  void test_vmcs_lifecycle(void)
>  {
>  	struct vmcs *vmcs[2] = {};
> @@ -1824,6 +1848,8 @@ int main(int argc, const char *argv[])
>  		test_vmptrst();
>  	if (test_wanted("test_vmwrite_vmread", argv, argc))
>  		test_vmwrite_vmread();
> +	if (test_wanted("test_vmcs_high", argv, argc))
> +		test_vmcs_high();
>  	if (test_wanted("test_vmcs_lifecycle", argv, argc))
>  		test_vmcs_lifecycle();
>  	if (test_wanted("test_vmx_caps", argv, argc))
> 

Reviewed-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux