From: "Jan Beulich" Subject: [PATCH] x86: tighten conditions under which writing certain MSRs is permitted Date: Thu, 10 Feb 2011 13:57:30 +0000 Message-ID: <4D53FCDA02000078000313F0@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part426E51DA.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. --=__Part426E51DA.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline MSRs that control physical CPU aspects generally are pointless (and possibly dangerous) to be written when the writer isn't sufficiently aware that it's running virtualized. Signed-off-by: Jan Beulich --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -2282,7 +2282,7 @@ static int emulate_privileged_op(struct=20 if ( boot_cpu_data.x86_vendor !=3D X86_VENDOR_AMD || boot_cpu_data.x86 < 0x10 || boot_cpu_data.x86 > 0x17 ) goto fail; - if ( !IS_PRIV(v->domain) ) + if ( !IS_PRIV(v->domain) || !is_pinned_vcpu(v) ) break; if ( (rdmsr_safe(MSR_AMD64_NB_CFG, val) !=3D 0) || (eax !=3D (uint32_t)val) || @@ -2295,7 +2295,7 @@ static int emulate_privileged_op(struct=20 if ( boot_cpu_data.x86_vendor !=3D X86_VENDOR_AMD || boot_cpu_data.x86 < 0x10 || boot_cpu_data.x86 > 0x17 ) goto fail; - if ( !IS_PRIV(v->domain) ) + if ( !IS_PRIV(v->domain) || !is_pinned_vcpu(v) ) break; if ( (rdmsr_safe(MSR_FAM10H_MMIO_CONF_BASE, val) !=3D 0) ) goto fail; @@ -2317,6 +2317,8 @@ static int emulate_privileged_op(struct=20 case MSR_IA32_UCODE_REV: if ( boot_cpu_data.x86_vendor !=3D X86_VENDOR_INTEL ) goto fail; + if ( !IS_PRIV(v->domain) || !is_pinned_vcpu(v) ) + break; if ( rdmsr_safe(regs->ecx, val) ) goto fail; if ( msr_content ) @@ -2324,7 +2326,7 @@ static int emulate_privileged_op(struct=20 break; case MSR_IA32_MISC_ENABLE: if ( rdmsr_safe(regs->ecx, val) ) - goto invalid; + goto fail; val =3D guest_misc_enable(val); if ( msr_content !=3D val ) goto invalid; @@ -2351,7 +2353,7 @@ static int emulate_privileged_op(struct=20 case MSR_IA32_ENERGY_PERF_BIAS: if ( boot_cpu_data.x86_vendor !=3D X86_VENDOR_INTEL ) goto fail; - if ( (v->domain->domain_id !=3D 0) || !is_pinned_vcpu(v) ) + if ( !IS_PRIV(v->domain) || !is_pinned_vcpu(v) ) break; if ( wrmsr_safe(regs->ecx, msr_content) !=3D 0 ) goto fail; --=__Part426E51DA.0__= Content-Type: text/plain; name="x86-adjust-guest-wrmsr.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-adjust-guest-wrmsr.patch" MSRs that control physical CPU aspects generally are pointless (and=0Apossi= bly dangerous) to be written when the writer isn't sufficiently=0Aaware = that it's running virtualized.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- a/xen/arch/x86/traps.c=0A+++ b/xen/arch/x86/traps.c=0A@@= -2282,7 +2282,7 @@ static int emulate_privileged_op(struct =0A = if ( boot_cpu_data.x86_vendor !=3D X86_VENDOR_AMD ||=0A = boot_cpu_data.x86 < 0x10 || boot_cpu_data.x86 > 0x17 )=0A = goto fail;=0A- if ( !IS_PRIV(v->domain) )=0A+ if ( = !IS_PRIV(v->domain) || !is_pinned_vcpu(v) )=0A break;=0A = if ( (rdmsr_safe(MSR_AMD64_NB_CFG, val) !=3D 0) ||=0A = (eax !=3D (uint32_t)val) ||=0A@@ -2295,7 +2295,7 @@ static int = emulate_privileged_op(struct =0A if ( boot_cpu_data.x86_vendor = !=3D X86_VENDOR_AMD ||=0A boot_cpu_data.x86 < 0x10 || = boot_cpu_data.x86 > 0x17 )=0A goto fail;=0A- if = ( !IS_PRIV(v->domain) )=0A+ if ( !IS_PRIV(v->domain) || = !is_pinned_vcpu(v) )=0A break;=0A if ( = (rdmsr_safe(MSR_FAM10H_MMIO_CONF_BASE, val) !=3D 0) )=0A = goto fail;=0A@@ -2317,6 +2317,8 @@ static int emulate_privileged_op(struct = =0A case MSR_IA32_UCODE_REV:=0A if ( boot_cpu_data.x86_= vendor !=3D X86_VENDOR_INTEL )=0A goto fail;=0A+ = if ( !IS_PRIV(v->domain) || !is_pinned_vcpu(v) )=0A+ = break;=0A if ( rdmsr_safe(regs->ecx, val) )=0A = goto fail;=0A if ( msr_content )=0A@@ -2324,7 +2326,7 @@ = static int emulate_privileged_op(struct =0A break;=0A = case MSR_IA32_MISC_ENABLE:=0A if ( rdmsr_safe(regs->ecx, val) = )=0A- goto invalid;=0A+ goto fail;=0A = val =3D guest_misc_enable(val);=0A if ( msr_content !=3D = val )=0A goto invalid;=0A@@ -2351,7 +2353,7 @@ static int = emulate_privileged_op(struct =0A case MSR_IA32_ENERGY_PERF_BIAS:=0A= if ( boot_cpu_data.x86_vendor !=3D X86_VENDOR_INTEL )=0A = goto fail;=0A- if ( (v->domain->domain_id !=3D 0) || = !is_pinned_vcpu(v) )=0A+ if ( !IS_PRIV(v->domain) || !is_pinned_= vcpu(v) )=0A break;=0A if ( wrmsr_safe(regs->ec= x, msr_content) !=3D 0 )=0A goto fail;=0A --=__Part426E51DA.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 --=__Part426E51DA.0__=--