Re: [PATCH 1/4] kvm-unit-tests: VMX: Add test cases for PAT and EFER

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

 



On 2013-08-15 10:05, Arthur Chunqi Li wrote:
> On Thu, Aug 15, 2013 at 3:48 PM, Jan Kiszka <jan.kiszka@xxxxxx> wrote:
>> On 2013-08-15 09:41, Arthur Chunqi Li wrote:
>>> On Thu, Aug 15, 2013 at 3:17 PM, Jan Kiszka <jan.kiszka@xxxxxx> wrote:
>>>> On 2013-08-13 17:56, Arthur Chunqi Li wrote:
>>>>> Add test cases for ENT_LOAD_PAT, ENT_LOAD_EFER, EXI_LOAD_PAT,
>>>>> EXI_SAVE_PAT, EXI_LOAD_EFER, EXI_SAVE_PAT flags in enter/exit
>>>>> control fields.
>>>>>
>>>>> Signed-off-by: Arthur Chunqi Li <yzt356@xxxxxxxxx>
>>>>> ---
>>>>>  x86/vmx.h       |    7 +++
>>>>>  x86/vmx_tests.c |  185 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>>>  2 files changed, 192 insertions(+)
>>>>>
>>>>> diff --git a/x86/vmx.h b/x86/vmx.h
>>>>> index 28595d8..18961f1 100644
>>>>> --- a/x86/vmx.h
>>>>> +++ b/x86/vmx.h
>>>>> @@ -152,10 +152,12 @@ enum Encoding {
>>>>>       GUEST_DEBUGCTL          = 0x2802ul,
>>>>>       GUEST_DEBUGCTL_HI       = 0x2803ul,
>>>>>       GUEST_EFER              = 0x2806ul,
>>>>> +     GUEST_PAT               = 0x2804ul,
>>>>>       GUEST_PERF_GLOBAL_CTRL  = 0x2808ul,
>>>>>       GUEST_PDPTE             = 0x280aul,
>>>>>
>>>>>       /* 64-Bit Host State */
>>>>> +     HOST_PAT                = 0x2c00ul,
>>>>>       HOST_EFER               = 0x2c02ul,
>>>>>       HOST_PERF_GLOBAL_CTRL   = 0x2c04ul,
>>>>>
>>>>> @@ -330,11 +332,15 @@ enum Ctrl_exi {
>>>>>       EXI_HOST_64             = 1UL << 9,
>>>>>       EXI_LOAD_PERF           = 1UL << 12,
>>>>>       EXI_INTA                = 1UL << 15,
>>>>> +     EXI_SAVE_PAT            = 1UL << 18,
>>>>> +     EXI_LOAD_PAT            = 1UL << 19,
>>>>> +     EXI_SAVE_EFER           = 1UL << 20,
>>>>>       EXI_LOAD_EFER           = 1UL << 21,
>>>>>  };
>>>>>
>>>>>  enum Ctrl_ent {
>>>>>       ENT_GUEST_64            = 1UL << 9,
>>>>> +     ENT_LOAD_PAT            = 1UL << 14,
>>>>>       ENT_LOAD_EFER           = 1UL << 15,
>>>>>  };
>>>>>
>>>>> @@ -354,6 +360,7 @@ enum Ctrl0 {
>>>>>       CPU_NMI_WINDOW          = 1ul << 22,
>>>>>       CPU_IO                  = 1ul << 24,
>>>>>       CPU_IO_BITMAP           = 1ul << 25,
>>>>> +     CPU_MSR_BITMAP          = 1ul << 28,
>>>>>       CPU_SECONDARY           = 1ul << 31,
>>>>>  };
>>>>>
>>>>> diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
>>>>> index c1b39f4..61b0cef 100644
>>>>> --- a/x86/vmx_tests.c
>>>>> +++ b/x86/vmx_tests.c
>>>>> @@ -1,4 +1,15 @@
>>>>>  #include "vmx.h"
>>>>> +#include "msr.h"
>>>>> +#include "processor.h"
>>>>> +#include "vm.h"
>>>>> +
>>>>> +u64 ia32_pat;
>>>>> +u64 ia32_efer;
>>>>> +
>>>>> +static inline void vmcall()
>>>>> +{
>>>>> +     asm volatile("vmcall");
>>>>> +}
>>>>>
>>>>>  void basic_init()
>>>>>  {
>>>>> @@ -76,6 +87,176 @@ int vmenter_exit_handler()
>>>>>       return VMX_TEST_VMEXIT;
>>>>>  }
>>>>>
>>>>> +void msr_bmp_init()
>>>>> +{
>>>>> +     void *msr_bitmap;
>>>>> +     u32 ctrl_cpu0;
>>>>> +
>>>>> +     msr_bitmap = alloc_page();
>>>>> +     memset(msr_bitmap, 0x0, PAGE_SIZE);
>>>>> +     ctrl_cpu0 = vmcs_read(CPU_EXEC_CTRL0);
>>>>> +     ctrl_cpu0 |= CPU_MSR_BITMAP;
>>>>> +     vmcs_write(CPU_EXEC_CTRL0, ctrl_cpu0);
>>>>> +     vmcs_write(MSR_BITMAP, (u64)msr_bitmap);
>>>>> +}
>>>>
>>>> Better safe this function for the test case where you actually stress
>>>> the bitmap.
>>> What do you mean by "safe"?
>>
>> I meant the other "save": This function serves no purpose here. Let's
>> only introduce it when that changes, i.e. when you actually test the MSR
>> bitmap.
> No, the function is meaningful here. We need directly access to MSRs
> in guest and if msr bitmap is not set, any access to MSRs will cause
> vmexit. Here we just let all rdmsr/wrmsr pass in guest.

Ah, sorry. Forgot that the default is "trap", not "pass".

Jan


Attachment: signature.asc
Description: OpenPGP digital signature


[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