From: "Jan Beulich" Subject: [PATCH] x86: emulate MSR_IA32_UCODE_REV Intel access protocol Date: Thu, 07 Oct 2010 11:31:18 +0100 Message-ID: <4CADBD96020000780001B36B@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part4E63A266.0__=" 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" List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part4E63A266.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Intel requires a write of zeros (hence such writes now get silently ignored) followed by a cpuid(1) followed by the actual read. Includes some code redundancy elimination possible after the actual change. Signed-off-by: Jan Beulich --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -2277,6 +2277,14 @@ static int emulate_privileged_op(struct=20 if ( wrmsr_safe(MSR_FAM10H_MMIO_CONF_BASE, msr_content) !=3D = 0 ) goto fail; break; + case MSR_IA32_UCODE_REV: + if ( boot_cpu_data.x86_vendor !=3D X86_VENDOR_INTEL ) + goto fail; + if ( rdmsr_safe(regs->ecx, val) ) + goto fail; + if ( msr_content ) + goto invalid; + break; case MSR_IA32_MISC_ENABLE: if ( rdmsr_safe(regs->ecx, val) ) goto invalid; @@ -2383,11 +2391,16 @@ static int emulate_privileged_op(struct=20 regs->eax =3D regs->edx =3D 0; break; } - if ( rdmsr_safe(regs->ecx, msr_content) !=3D 0 ) - goto fail; - regs->eax =3D (uint32_t)msr_content; - regs->edx =3D (uint32_t)(msr_content >> 32); - break; + goto rdmsr_normal; + case MSR_IA32_UCODE_REV: + BUILD_BUG_ON(MSR_IA32_UCODE_REV !=3D MSR_AMD_PATCHLEVEL); + if ( boot_cpu_data.x86_vendor =3D=3D X86_VENDOR_INTEL ) + { + if ( wrmsr_safe(MSR_IA32_UCODE_REV, 0) ) + goto fail; + sync_core(); + } + goto rdmsr_normal; case MSR_IA32_MISC_ENABLE: if ( rdmsr_safe(regs->ecx, msr_content) ) goto fail; @@ -2395,8 +2408,6 @@ static int emulate_privileged_op(struct=20 regs->eax =3D (uint32_t)msr_content; regs->edx =3D (uint32_t)(msr_content >> 32); break; - case MSR_EFER: - case MSR_AMD_PATCHLEVEL: default: if ( rdmsr_hypervisor_regs(regs->ecx, &val) ) { @@ -2412,6 +2423,8 @@ static int emulate_privileged_op(struct=20 if ( rc ) goto rdmsr_writeback; =20 + case MSR_EFER: + rdmsr_normal: /* Everyone can read the MSR space. */ /* gdprintk(XENLOG_WARNING,"Domain attempted RDMSR %p.\n", _p(regs->ecx));*/ --=__Part4E63A266.0__= Content-Type: text/plain; name="x86-msr-ucode-rev.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-msr-ucode-rev.patch" Intel requires a write of zeros (hence such writes now get silently=0Aignor= ed) followed by a cpuid(1) followed by the actual read.=0A=0AIncludes some = code redundancy elimination possible after the actual=0Achange.=0A=0ASigned= -off-by: Jan Beulich =0A=0A--- a/xen/arch/x86/traps.c= =0A+++ b/xen/arch/x86/traps.c=0A@@ -2277,6 +2277,14 @@ static int = emulate_privileged_op(struct =0A if ( wrmsr_safe(MSR_FAM10H_MMI= O_CONF_BASE, msr_content) !=3D 0 )=0A goto fail;=0A = break;=0A+ case MSR_IA32_UCODE_REV:=0A+ if ( = boot_cpu_data.x86_vendor !=3D X86_VENDOR_INTEL )=0A+ goto = fail;=0A+ if ( rdmsr_safe(regs->ecx, val) )=0A+ = goto fail;=0A+ if ( msr_content )=0A+ goto = invalid;=0A+ break;=0A case MSR_IA32_MISC_ENABLE:=0A = if ( rdmsr_safe(regs->ecx, val) )=0A goto = invalid;=0A@@ -2383,11 +2391,16 @@ static int emulate_privileged_op(struct = =0A regs->eax =3D regs->edx =3D 0;=0A = break;=0A }=0A- if ( rdmsr_safe(regs->ecx, = msr_content) !=3D 0 )=0A- goto fail;=0A- = regs->eax =3D (uint32_t)msr_content;=0A- regs->edx =3D = (uint32_t)(msr_content >> 32);=0A- break;=0A+ goto = rdmsr_normal;=0A+ case MSR_IA32_UCODE_REV:=0A+ BUILD_BUG_= ON(MSR_IA32_UCODE_REV !=3D MSR_AMD_PATCHLEVEL);=0A+ if ( = boot_cpu_data.x86_vendor =3D=3D X86_VENDOR_INTEL )=0A+ {=0A+ = if ( wrmsr_safe(MSR_IA32_UCODE_REV, 0) )=0A+ = goto fail;=0A+ sync_core();=0A+ }=0A+ = goto rdmsr_normal;=0A case MSR_IA32_MISC_ENABLE:=0A = if ( rdmsr_safe(regs->ecx, msr_content) )=0A goto = fail;=0A@@ -2395,8 +2408,6 @@ static int emulate_privileged_op(struct =0A = regs->eax =3D (uint32_t)msr_content;=0A regs->edx = =3D (uint32_t)(msr_content >> 32);=0A break;=0A- case = MSR_EFER:=0A- case MSR_AMD_PATCHLEVEL:=0A default:=0A = if ( rdmsr_hypervisor_regs(regs->ecx, &val) )=0A {=0A@@ = -2412,6 +2423,8 @@ static int emulate_privileged_op(struct =0A = if ( rc )=0A goto rdmsr_writeback;=0A =0A+ case = MSR_EFER:=0A+ rdmsr_normal:=0A /* Everyone can read the MSR = space. */=0A /* gdprintk(XENLOG_WARNING,"Domain attempted = RDMSR %p.\n",=0A _p(regs->ecx));*/=0A --=__Part4E63A266.0__= 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 --=__Part4E63A266.0__=--