On 30/10/2018 08:06, Tian, Kevin wrote: >> From: Sergey Dyasli [mailto:sergey.dya...@citrix.com] >> Sent: Friday, October 12, 2018 11:28 PM >> >> The size of Xen's virtual vmcs region is 4096 bytes. Correctly report >> it to the guest in case when VMCS shadowing is not available instead of >> providing H/W value (which is usually smaller). > > what is the problem of reporting smaller size even when actual > size is 4096? is L1 expected to access the portion beyond h/w > reported size? >
Here's the code snippet from kvm-unit-tests: vmcs[0]->hdr.revision_id = basic.revision; assert(!vmcs_clear(vmcs[0])); assert(!make_vmcs_current(vmcs[0])); set_all_vmcs_fields(0x86); assert(!vmcs_clear(vmcs[0])); memcpy(vmcs[1], vmcs[0], basic.size); assert(!make_vmcs_current(vmcs[1])); report("test vmclear flush (current VMCS)", check_all_vmcs_fields(0x86)); set_all_vmcs_fields() vmwrites almost 4k, but memcpy() copies only 1024 bytes and vmreads get incorrect values. >> >> Signed-off-by: Sergey Dyasli <sergey.dya...@citrix.com> >> --- >> xen/arch/x86/hvm/vmx/vvmx.c | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> diff --git a/xen/arch/x86/hvm/vmx/vvmx.c >> b/xen/arch/x86/hvm/vmx/vvmx.c >> index 8b691bfc04..2c2ba36d94 100644 >> --- a/xen/arch/x86/hvm/vmx/vvmx.c >> +++ b/xen/arch/x86/hvm/vmx/vvmx.c >> @@ -2064,6 +2064,14 @@ int nvmx_msr_read_intercept(unsigned int msr, >> u64 *msr_content) >> data = (host_data & (~0ul << 32)) | >> (vmcs->vmcs_revision_id & 0x7fffffff); >> unmap_domain_page(vmcs); >> + >> + if ( !cpu_has_vmx_vmcs_shadowing ) >> + { >> + /* Report vmcs_region_size as 4096 */ >> + data &= ~VMX_BASIC_VMCS_SIZE_MASK; >> + data |= 1ULL << 44; >> + } >> + >> break; >> } >> case MSR_IA32_VMX_PINBASED_CTLS: >> -- >> 2.17.1 > _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel