]> xenbits.xensource.com Git - people/dariof/xen.git/commitdiff
x86/HVM: don't give the wrong impression of WRMSR succeeding
authorJan Beulich <jbeulich@suse.com>
Tue, 27 Feb 2018 14:12:23 +0000 (15:12 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 27 Feb 2018 14:12:23 +0000 (15:12 +0100)
... for non-existent MSRs: wrmsr_hypervisor_regs()'s comment clearly
says that the function returns 0 for unrecognized MSRs, so
{svm,vmx}_msr_write_intercept() should not convert this into success. We
don't want to unconditionally fail the access though, as we can't be
certain the list of handled MSRs is complete enough for the guest types
we care about, so instead mirror what we do on the read paths and probe
the MSR to decide whether to raise #GP.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
xen/arch/x86/hvm/svm/svm.c
xen/arch/x86/hvm/vmx/vmx.c

index 1dd74b44c4ac35c5e380109669eaaa97675c68de..f2fbe07b20db000d61d9a376dc868bca8838e585 100644 (file)
@@ -2128,6 +2128,13 @@ static int svm_msr_write_intercept(unsigned int msr, uint64_t msr_content)
             result = X86EMUL_RETRY;
             break;
         case 0:
+            /*
+             * Match up with the RDMSR side for now; ultimately this entire
+             * case block should go away.
+             */
+            if ( rdmsr_safe(msr, msr_content) == 0 )
+                break;
+            goto gpf;
         case 1:
             break;
         default:
index 9a5887ce528a27563c9aafa9367ac45dc52ca291..aa0505036b7f3e0f6825cda6e1b32bcd674d2be6 100644 (file)
@@ -3191,6 +3191,13 @@ static int vmx_msr_write_intercept(unsigned int msr, uint64_t msr_content)
                 case -ERESTART:
                     return X86EMUL_RETRY;
                 case 0:
+                    /*
+                     * Match up with the RDMSR side for now; ultimately this
+                     * entire case block should go away.
+                     */
+                    if ( rdmsr_safe(msr, msr_content) == 0 )
+                        break;
+                    goto gp_fault;
                 case 1:
                     break;
                 default: