x86/msr: introduce guest_wrmsr()
authorSergey Dyasli <sergey.dyasli@citrix.com>
Mon, 25 Sep 2017 08:56:52 +0000 (10:56 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 25 Sep 2017 08:56:52 +0000 (10:56 +0200)
commit664adc5ccab1388ea8ff4dd476473d04effaa2c8
tree89902d3884e0e36aa30e4323a0b60b3a1f1e59b5
parent37f074a33831633118735b61c6f4e7b413792629
x86/msr: introduce guest_wrmsr()

The new function is responsible for handling WRMSR from both HVM and PV
guests. Currently it handles only 2 MSRs:

    MSR_INTEL_PLATFORM_INFO
    MSR_INTEL_MISC_FEATURES_ENABLES

It has a different behaviour compared to the old MSR handlers: if MSR
is being handled by guest_wrmsr() then WRMSR will either succeed (if
a guest is allowed to access it and provided a correct value based on
its MSR policy) or produce a GP fault. A guest will never see
a successful WRMSR of some MSR unknown to this function.

guest_wrmsr() unifies and replaces the handling code from
vmx_msr_write_intercept() and priv_op_write_msr().

Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
This also fixes a bug on AMD hardware where a guest which tries to
enable CPUID faulting via a direct write to the MSR will observe it
appearing to succeed, but because Xen actually ignored the write.

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
xen/arch/x86/hvm/hvm.c
xen/arch/x86/hvm/vmx/vmx.c
xen/arch/x86/msr.c
xen/arch/x86/pv/emul-priv-op.c
xen/include/asm-x86/msr.h