From: Keir Fraser Date: Fri, 16 Jan 2009 15:43:59 +0000 (+0000) Subject: x86: Tighten MSR access checks so only dom0 can access cpufreq MSRs, X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14014^2~48 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ee76467a91bebb6426dc9d89558b6905a32fd6cd;p=xen.git x86: Tighten MSR access checks so only dom0 can access cpufreq MSRs, and then only when it is the cpufreq controller. Signed-off-by: Keir Fraser --- diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 226cc899da..f6e0eaf59d 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -1632,6 +1632,12 @@ void (*pv_post_outb_hook)(unsigned int port, u8 value); # define read_sreg(regs, sr) read_segment_register(sr) #endif +static int is_cpufreq_controller(struct domain *d) +{ + return ((cpufreq_controller == FREQCTL_dom0_kernel) && + (d->domain_id == 0)); +} + static int emulate_privileged_op(struct cpu_user_regs *regs) { struct vcpu *v = current; @@ -2143,7 +2149,7 @@ static int emulate_privileged_op(struct cpu_user_regs *regs) case MSR_K8_PSTATE7: if ( boot_cpu_data.x86_vendor != X86_VENDOR_AMD ) goto fail; - if ( cpufreq_controller != FREQCTL_dom0_kernel ) + if ( !is_cpufreq_controller(v->domain) ) break; if ( wrmsr_safe(regs->ecx, eax, edx) != 0 ) goto fail; @@ -2181,16 +2187,11 @@ static int emulate_privileged_op(struct cpu_user_regs *regs) case MSR_IA32_MPERF: case MSR_IA32_APERF: case MSR_IA32_PERF_CTL: - if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL ) - goto fail; - if ( cpufreq_controller != FREQCTL_dom0_kernel ) - break; - if ( wrmsr_safe(regs->ecx, eax, edx) != 0 ) - goto fail; - break; case MSR_IA32_THERM_CONTROL: if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL ) goto fail; + if ( !is_cpufreq_controller(v->domain) ) + break; if ( wrmsr_safe(regs->ecx, eax, edx) != 0 ) goto fail; break; @@ -2249,7 +2250,7 @@ static int emulate_privileged_op(struct cpu_user_regs *regs) case MSR_K8_PSTATE7: if ( boot_cpu_data.x86_vendor != X86_VENDOR_AMD ) goto fail; - if ( cpufreq_controller != FREQCTL_dom0_kernel ) + if ( !is_cpufreq_controller(v->domain) ) { regs->eax = regs->edx = 0; break; @@ -2267,7 +2268,6 @@ static int emulate_privileged_op(struct cpu_user_regs *regs) MSR_IA32_MISC_ENABLE_XTPR_DISABLE; break; case MSR_EFER: - case MSR_IA32_THERM_CONTROL: case MSR_AMD_PATCHLEVEL: default: if ( rdmsr_hypervisor_regs(regs->ecx, &l, &h) )