WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH] Limit MCG Cap

To: Keir Fraser <keir@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] Limit MCG Cap
From: David Lively <dlively@xxxxxxxxxxxxxxx>
Date: Tue, 28 Aug 2007 09:56:33 -0400
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx, Ben Guthro <bguthro@xxxxxxxxxxxxxxx>
Delivery-date: Tue, 28 Aug 2007 06:57:23 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <C2F9B040.14F1A%keir@xxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <C2F9B040.14F1A%keir@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.5 (X11/20070719)
I don't see why not, now that you mention it.

I'll give it a try ...

Dave


Keir Fraser wrote:
Given that we don't properly virtualise/emulate machine check (we only set
the feature bit because some versions of Windows demand it) can we get away
with returning zero for reads of MCG_CAP?

 -- Keir

On 27/8/07 20:11, "Ben Guthro" <bguthro@xxxxxxxxxxxxxxx> wrote:

Intercept guest reads of MSR_IA32_MCG_CAP and limit the number of memory banks
reported to one.
This prevents us from trying to read status of non-existent banks when
migrated to a machine
with fewer banks.

Signed-off-by: Ben Guthro
Signed-off-by: David Lively <dlively@xxxxxxxxxxxxxxx>

diff -r 4eea7c9b3bf2 xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c Thu Aug 02 08:59:43 2007 -0400
+++ b/xen/arch/x86/hvm/svm/svm.c Thu Aug 02 08:59:43 2007 -0400
@@ -2162,7 +2162,19 @@ static void svm_do_msr_access(
             /* No point in letting the guest see real MCEs */
             msr_content = 0;
             break;
-
+        case MSR_IA32_MCG_CAP:
+            if ( rdmsr_safe(ecx, regs->eax, regs->edx) == 0 ) {
+                /*
+                 * Report at most one memory bank so migration to a machine
with
+                 * fewer banks doesn't cause guest GPFs when the guest tries
to read the
+                 * (now, after migration) non-existent banks' MSRs.
+                 */
+                regs->eax = (regs->eax & ~0xFF) | !!(regs->eax & 0xFF);
+                goto done;
+            }
+            gdprintk(XENLOG_ERR, "%s: rdmsr_safe(MCG_CAP) failed!\n",
__FUNCTION__);
+            svm_inject_exception(v, TRAP_gp_fault, 1, 0);
+            return;
         default:
             if ( rdmsr_hypervisor_regs(ecx, &eax, &edx) ||
                  rdmsr_safe(ecx, eax, edx) == 0 )
diff -r 4eea7c9b3bf2 xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c Thu Aug 02 08:59:43 2007 -0400
+++ b/xen/arch/x86/hvm/vmx/vmx.c Thu Aug 02 09:14:06 2007 -0400
@@ -2754,6 +2754,19 @@ static int vmx_do_msr_read(struct cpu_us
         /* No point in letting the guest see real MCEs */
         msr_content = 0;
         break;
+    case MSR_IA32_MCG_CAP:
+        if ( rdmsr_safe(ecx, regs->eax, regs->edx) == 0 ) {
+            /*
+             * Report only a single memory bank so migration to a machine
with
+             * fewer banks doesn't cause guest GPFs when the guest tries to
read the
+             * (now, after migration) non-existent banks' MSRs.
+             */
+            regs->eax = (regs->eax & ~0xFF) | !!(regs->eax & 0xFF);
+            goto done;
+        }
+        gdprintk(XENLOG_ERR, "%s: rdmsr_safe(MCG_CAP) failed!\n",
__FUNCTION__);
+        vmx_inject_hw_exception(v, TRAP_gp_fault, 0);
+        return 0;
     default:
         switch ( long_mode_do_msr_read(regs) )
         {
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>