From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Guthro Subject: [PATCH] Limit MCG Cap Date: Mon, 27 Aug 2007 15:11:24 -0400 Message-ID: <46D321DC.30504@virtualiron.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040506070703040907090106" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: Dave Lively List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------040506070703040907090106 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 --------------040506070703040907090106 Content-Type: text/x-patch; name="xen-limit-mcg-cap.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="xen-limit-mcg-cap.patch" 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) ) { --------------040506070703040907090106 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------040506070703040907090106--