summaryrefslogtreecommitdiff
path: root/xen/arch/x86/msr.c
diff options
context:
space:
mode:
authorAndrew Cooper <andrew.cooper3@citrix.com>2018-04-13 15:34:01 +0000
committerAndrew Cooper <andrew.cooper3@citrix.com>2018-08-14 16:56:47 +0100
commitfd9823faf9df057a69a9a53c2e100691d3f4267c (patch)
treed13c9af2ed58a00b75280143117de928b46a4c4c /xen/arch/x86/msr.c
parent3563fc2b2731a63fd7e8372ab0f5cef205bf8477 (diff)
x86/msr: Virtualise MSR_FLUSH_CMD for guests
Guests (outside of the nested virt case, which isn't supported yet) don't need L1D_FLUSH for their L1TF mitigations, but offering/emulating MSR_FLUSH_CMD is easy and doesn't pose an issue for Xen. The MSR is offered to HVM guests only. PV guests attempting to use it would trap for emulation, and the L1D cache would fill long before the return to guest context. As such, PV guests can't make any use of the L1D_FLUSH functionality. This is part of XSA-273 / CVE-2018-3646. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com>
Diffstat (limited to 'xen/arch/x86/msr.c')
-rw-r--r--xen/arch/x86/msr.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c
index c2bcaa382a..b675f3ac02 100644
--- a/xen/arch/x86/msr.c
+++ b/xen/arch/x86/msr.c
@@ -123,6 +123,7 @@ int guest_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val)
case MSR_AMD_PATCHLOADER:
case MSR_IA32_UCODE_WRITE:
case MSR_PRED_CMD:
+ case MSR_FLUSH_CMD:
/* Write-only */
goto gp_fault;
@@ -221,6 +222,17 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)
wrmsrl(MSR_PRED_CMD, val);
break;
+ case MSR_FLUSH_CMD:
+ if ( !cp->feat.l1d_flush )
+ goto gp_fault; /* MSR available? */
+
+ if ( val & ~FLUSH_CMD_L1D )
+ goto gp_fault; /* Rsvd bit set? */
+
+ if ( v == curr )
+ wrmsrl(MSR_FLUSH_CMD, val);
+ break;
+
case MSR_INTEL_MISC_FEATURES_ENABLES:
{
bool old_cpuid_faulting = msrs->misc_features_enables.cpuid_faulting;