x86/Intel: hide CPUID faulting capability from guests
PATCH 1/1 x86/Intel: hide CPUID faulting capability from guests
We don't currently emulate it, so guests should not be misguided to believe they can (try to) use it.
For now, simply return zero to guests for platform MSR reads, and only accept (by discarding) writes of zero. If ever there will be bits we can safely expose to guests, let's handle them by white listing.
(As a side note - according to SDM version 059 bit 31 is reserved on all known families.)
xen/arch/x86/hvm/vmx/vmx.c +14 -0
@@ -2699,6 +2699,13 @@ static int vmx_msr_read_intercept(unsignif (vpmu_do_rdmsr (msr, msr_content) ) goto gp_fault;break ; + +case MSR_INTEL_PLATFORM_INFO : +if (rdmsr_safe (MSR_INTEL_PLATFORM_INFO , *msr_content) ) + goto gp_fault; + *msr_content =0 ; +break ; +default :if (passive_domain_do_rdmsr (msr, msr_content) ) goto done;
@@ -2918,6 +2925,13 @@ static int vmx_msr_write_intercept(unsigif (vpmu_do_wrmsr (msr, msr_content,0 ) ) goto gp_fault;break ; + +case MSR_INTEL_PLATFORM_INFO : +if ( msr_content || +rdmsr_safe (MSR_INTEL_PLATFORM_INFO , msr_content) ) + goto gp_fault; +break ; +default :if (passive_domain_do_wrmsr (msr, msr_content) )return X86EMUL_OKAY ;
xen/arch/x86/traps.c +16 -0
@@ -2938,6 +2938,14 @@ static int emulate_privileged_op(structif ( v->arch.debugreg[7 ] &DR7_ACTIVE_MASK )wrmsrl (regs->_ecx, msr_content);break ; + +case MSR_INTEL_PLATFORM_INFO : +if ( boot_cpu_data.x86_vendor !=X86_VENDOR_INTEL || + msr_content || +rdmsr_safe (MSR_INTEL_PLATFORM_INFO , msr_content) ) + goto fail; +break ; + case MSR_P6_PERFCTR(0)...MSR_P6_PERFCTR(7): case MSR_P6_EVNTSEL(0)...MSR_P6_EVNTSEL(3): case MSR_CORE_PERF_FIXED_CTR0...MSR_CORE_PERF_FIXED_CTR2:
@@ -3066,6 +3074,14 @@ static int emulate_privileged_op(struct/* No extra capabilities are supported */ regs->eax = regs->edx =0 ;break ; + +case MSR_INTEL_PLATFORM_INFO : +if ( boot_cpu_data.x86_vendor !=X86_VENDOR_INTEL || +rdmsr_safe (MSR_INTEL_PLATFORM_INFO , val) ) + goto fail; + regs->eax = regs->edx =0 ; +break ; + case MSR_P6_PERFCTR(0)...MSR_P6_PERFCTR(7): case MSR_P6_EVNTSEL(0)...MSR_P6_EVNTSEL(3): case MSR_CORE_PERF_FIXED_CTR0...MSR_CORE_PERF_FIXED_CTR2:
x86/Intel: hide CPUID faulting capability from guests
We don't currently emulate it, so guests should not be misguided to believe they can (try to) use it.
For now, simply return zero to guests for platform MSR reads, and only accept (by discarding) writes of zero. If ever there will be bits we can safely expose to guests, let's handle them by white listing.
(As a side note - according to SDM version 059 bit 31 is reserved on all known families.)
xen/arch/x86/hvm/vmx/vmx.c +14 -0
@@ -2699,6 +2699,13 @@ static int vmx_msr_read_intercept(unsignif (vpmu_do_rdmsr (msr, msr_content) ) goto gp_fault;break ; + +case MSR_INTEL_PLATFORM_INFO : +if (rdmsr_safe (MSR_INTEL_PLATFORM_INFO , *msr_content) ) + goto gp_fault; + *msr_content =0 ; +break ; +default :if (passive_domain_do_rdmsr (msr, msr_content) ) goto done;
@@ -2918,6 +2925,13 @@ static int vmx_msr_write_intercept(unsigif (vpmu_do_wrmsr (msr, msr_content,0 ) ) goto gp_fault;break ; + +case MSR_INTEL_PLATFORM_INFO : +if ( msr_content || +rdmsr_safe (MSR_INTEL_PLATFORM_INFO , msr_content) ) + goto gp_fault; +break ; +default :if (passive_domain_do_wrmsr (msr, msr_content) )return X86EMUL_OKAY ;
xen/arch/x86/traps.c +16 -0
@@ -2938,6 +2938,14 @@ static int emulate_privileged_op(structif ( v->arch.debugreg[7 ] &DR7_ACTIVE_MASK )wrmsrl (regs->_ecx, msr_content);break ; + +case MSR_INTEL_PLATFORM_INFO : +if ( boot_cpu_data.x86_vendor !=X86_VENDOR_INTEL || + msr_content || +rdmsr_safe (MSR_INTEL_PLATFORM_INFO , msr_content) ) + goto fail; +break ; + case MSR_P6_PERFCTR(0)...MSR_P6_PERFCTR(7): case MSR_P6_EVNTSEL(0)...MSR_P6_EVNTSEL(3): case MSR_CORE_PERF_FIXED_CTR0...MSR_CORE_PERF_FIXED_CTR2:
@@ -3066,6 +3074,14 @@ static int emulate_privileged_op(struct/* No extra capabilities are supported */ regs->eax = regs->edx =0 ;break ; + +case MSR_INTEL_PLATFORM_INFO : +if ( boot_cpu_data.x86_vendor !=X86_VENDOR_INTEL || +rdmsr_safe (MSR_INTEL_PLATFORM_INFO , val) ) + goto fail; + regs->eax = regs->edx =0 ; +break ; + case MSR_P6_PERFCTR(0)...MSR_P6_PERFCTR(7): case MSR_P6_EVNTSEL(0)...MSR_P6_EVNTSEL(3): case MSR_CORE_PERF_FIXED_CTR0...MSR_CORE_PERF_FIXED_CTR2:
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 7 lines · Jan Beulich
We don't currently emulate it, so guests should not be misguided to believe they can (try to) use it.
For now, simply return zero to guests for platform MSR reads, and only accept (by discarding) writes of zero. If ever there will be bits we can safely expose to guests, let's handle them by white listing.
Quoted 5 lines
(As a side note - according to SDM version 059 bit 31 is reserved on all known families.)
Reported-by Kyle Huey <[email protected]>Signed-off-by Jan Beulich <[email protected]>
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 16.09.16 at 11:46, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
We don't currently emulate it, so guests should not be misguided to believe they can (try to) use it.
For now, simply return zero to guests for platform MSR reads, and only accept (by discarding) writes of zero. If ever there will be bits we can safely expose to guests, let's handle them by white listing.
Quoted 8 lines
Quoted 5 lines
(As a side note - according to SDM version 059 bit 31 is reserved on all known families.)
Reported-by Kyle Huey <[email protected]>Signed-off-by Jan Beulich <[email protected]>suggest putting in a
d->arch.x86_vendorcheck against Intel as well.
In general I agree, but then let's please do this for all instances which currently use the host CPU vendor field at once: There's no single example of this, and I have to admit that it's also not immediately clear to me what the best behavior would be in some of the cases if host and guest vendor disagree.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 68 lines · Jan Beulich
We don't currently emulate it, so guests should not be misguided to believe they can (try to) use it.
For now, simply return zero to guests for platform MSR reads, and only accept (by discarding) writes of zero. If ever there will be bits we can safely expose to guests, let's handle them by white listing.
(As a side note - according to SDM version 059 bit 31 is reserved on all known families.)
Reported-by Kyle Huey <[email protected]>Signed-off-by Jan Beulich <[email protected]>xen/arch/x86/hvm/vmx/vmx.c +14
-0@@ -2699,6 +2699,13 @@ static int vmx_msr_read_intercept(unsignif (vpmu_do_rdmsr (msr, msr_content) ) goto gp_fault;break ; + +case MSR_INTEL_PLATFORM_INFO : +if (rdmsr_safe (MSR_INTEL_PLATFORM_INFO , *msr_content) ) + goto gp_fault; + *msr_content =0 ; +break ; +default :if (passive_domain_do_rdmsr (msr, msr_content) ) goto done;@@ -2918,6 +2925,13 @@ static int vmx_msr_write_intercept(unsigif (vpmu_do_wrmsr (msr, msr_content,0 ) ) goto gp_fault;break ; + +case MSR_INTEL_PLATFORM_INFO : +if ( msr_content || +rdmsr_safe (MSR_INTEL_PLATFORM_INFO , msr_content) ) + goto gp_fault; +break ; +default :if (passive_domain_do_wrmsr (msr, msr_content) )return X86EMUL_OKAY ;xen/arch/x86/traps.c +9
-0@@ -2938,6 +2938,14 @@ static int emulate_privileged_op(structif ( v->arch.debugreg[7 ] &DR7_ACTIVE_MASK )wrmsrl (regs->_ecx, msr_content);break ; + +case MSR_INTEL_PLATFORM_INFO : +if ( boot_cpu_data.x86_vendor !=X86_VENDOR_INTEL || + msr_content || +rdmsr_safe (MSR_INTEL_PLATFORM_INFO , msr_content) ) + goto fail; +break ; + case MSR_P6_PERFCTR(0)...MSR_P6_PERFCTR(7): case MSR_P6_EVNTSEL(0)...MSR_P6_EVNTSEL(3): case MSR_CORE_PERF_FIXED_CTR0...MSR_CORE_PERF_FIXED_CTR2:@@ -3066,6 +3074,14 @@ static int emulate_privileged_op(struct/* No extra capabilities are supported */ regs->eax = regs->edx =0 ;break ; +
xen/arch/x86/traps.c static int emulate_privileged_op(struct · line 3087
Quoted 10 lines
xen/arch/x86/traps.c +7
-0+case MSR_INTEL_PLATFORM_INFO : +if ( boot_cpu_data.x86_vendor !=X86_VENDOR_INTEL || +rdmsr_safe (MSR_INTEL_PLATFORM_INFO , val) ) + goto fail; + regs->eax = regs->edx =0 ; +break ; + case MSR_P6_PERFCTR(0)...MSR_P6_PERFCTR(7): case MSR_P6_EVNTSEL(0)...MSR_P6_EVNTSEL(3): case MSR_CORE_PERF_FIXED_CTR0...MSR_CORE_PERF_FIXED_CTR2:
Excellent. Thank you for writing this.
- Kyle
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 10 lines
From: Jan Beulich [mailto:[email protected]]
Sent: Friday, September 16, 2016 2:32 PMWe don't currently emulate it, so guests should not be misguided to believe they can (try to) use it.
For now, simply return zero to guests for platform MSR reads, and only accept (by discarding) writes of zero. If ever there will be bits we can safely expose to guests, let's handle them by white listing.
Quoted 6 lines
(As a side note - according to SDM version 059 bit 31 is reserved on all known families.)
Reported-by Kyle Huey <[email protected]>Signed-off-by Jan Beulich <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel