xen: cleanup msr handling
PATCH 1/1 xen: cleanup msr handling
Hi!
Attached is a patch which simplifies msr handling throughout xen kernel code.
Signature · 6 lines
---to satisfy European Law for business letters: Advanced Micro Devices GmbH Einsteinring 24, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
xen/arch/x86/acpi/cpufreq/cpufreq.c +8 -8
@@ -137,13 +137,12 @@ struct drv_cmd {static void do_drv_read (void *drvcmd) {struct drv_cmd *cmd; -u32 h; cmd = (struct drv_cmd *)drvcmd;switch (cmd->type) {case SYSTEM_INTEL_MSR_CAPABLE : -rdmsr (cmd->addr.msr.reg, cmd->val, h); + cmd->val =rdmsr (cmd->addr.msr.reg);break ;case SYSTEM_IO_CAPABLE : acpi_os_read_port((acpi_io_address)cmd->addr.io.port,
@@ -157,15 +156,16 @@ static void do_drv_read(void *drvcmd)static void do_drv_write (void *drvcmd) {struct drv_cmd *cmd; -u32 lo, hi; +uint64_t msr_content; cmd = (struct drv_cmd *)drvcmd;switch (cmd->type) {case SYSTEM_INTEL_MSR_CAPABLE : -rdmsr (cmd->addr.msr.reg, lo, hi); - lo = (lo & ~INTEL_MSR_RANGE ) | (cmd->val &INTEL_MSR_RANGE ); -wrmsr (cmd->addr.msr.reg, lo, hi); + msr_content =rdmsr (cmd->addr.msr.reg); + msr_content = (msr_content & ~INTEL_MSR_RANGE ) + | (cmd->val &INTEL_MSR_RANGE ); +wrmsr (cmd->addr.msr.reg, msr_content);break ;case SYSTEM_IO_CAPABLE : acpi_os_write_port((acpi_io_address)cmd->addr.io.port,
@@ -252,8 +252,8 @@ static void read_measured_perf_ctrs(void {struct perf_pair *readin = _readin; -rdmsr (MSR_IA32_APERF , readin->aperf.split.lo, readin->aperf.split.hi); -rdmsr (MSR_IA32_MPERF , readin->mperf.split.lo, readin->mperf.split.hi); + readin->aperf.whole =rdmsr (MSR_IA32_APERF ); + readin->mperf.whole =rdmsr (MSR_IA32_MPERF ); }/*
xen/arch/x86/acpi/cpufreq/powernow.c +10 -8
@@ -77,15 +77,15 @@ static void transition_pstate(void *drvc cmd = (struct drv_cmd *) drvcmd;if (cmd->turbo !=CPUFREQ_TURBO_UNSUPPORTED ) { -u32 lo, hi; -rdmsr (MSR_K8_HWCR , lo, hi); +uint64_t msr_content; + msr_content =rdmsr (MSR_K8_HWCR );if (cmd->turbo ==CPUFREQ_TURBO_ENABLED ) - lo &= ~MSR_HWCR_CPBDIS_MASK ; + msr_content &= ~MSR_HWCR_CPBDIS_MASK ;else - lo |=MSR_HWCR_CPBDIS_MASK ; -wrmsr (MSR_K8_HWCR , lo, hi); + msr_content |=MSR_HWCR_CPBDIS_MASK ; +wrmsr (MSR_K8_HWCR , msr_content); } -wrmsr (MSR_PSTATE_CTRL , cmd->val,0 ); +wrmsr (MSR_PSTATE_CTRL , cmd->val); } static int powernow_cpufreq_target(struct cpufreq_policy *policy,
@@ -194,7 +194,8 @@ static int powernow_cpufreq_cpu_init(strstruct powernow_cpufreq_data *data;unsigned int result =0 ;struct processor_performance *perf; -u32 max_hw_pstate, hi =0 , lo =0 ; +u32 max_hw_pstate, hi; +uint64_t msr_content;struct cpuinfo_x86 *c = &cpu_data[policy->cpu]; data = xmalloc(struct powernow_cpufreq_data);
@@ -226,7 +227,8 @@ static int powernow_cpufreq_cpu_init(str result = -ENODEV ; goto err_unreg; } -rdmsr (MSR_PSTATE_CUR_LIMIT , hi, lo); + msr_content =rdmsr (MSR_PSTATE_CUR_LIMIT ); + hi = (uint32_t )(msr_content >>32 ); max_hw_pstate = (hi &HW_PSTATE_MAX_MASK ) >>HW_PSTATE_MAX_SHIFT ;if (perf->control_register.space_id != perf->status_register.space_id) {
xen/arch/x86/acpi/suspend.c +13 -14
@@ -25,12 +25,12 @@ void save_rest_processor_state(void)unlazy_fpu (current);#if defined(CONFIG_X86_64 ) -rdmsrl (MSR_CSTAR , saved_cstar); -rdmsrl (MSR_LSTAR , saved_lstar); + saved_cstar =rdmsr (MSR_CSTAR ); + saved_lstar =rdmsr (MSR_LSTAR );if ( boot_cpu_data.x86_vendor ==X86_VENDOR_INTEL ) { -rdmsrl (MSR_IA32_SYSENTER_ESP , saved_sysenter_esp); -rdmsrl (MSR_IA32_SYSENTER_EIP , saved_sysenter_eip); + saved_sysenter_esp =rdmsr (MSR_IA32_SYSENTER_ESP ); + saved_sysenter_eip =rdmsr (MSR_IA32_SYSENTER_EIP ); }#endif }
@@ -43,24 +43,23 @@ void restore_rest_processor_state(void)#if defined(CONFIG_X86_64 )/* Recover syscall MSRs */ -wrmsrl (MSR_LSTAR , saved_lstar); -wrmsrl (MSR_CSTAR , saved_cstar); -wrmsr (MSR_STAR ,0 , (FLAT_RING3_CS32 <<16 ) | __HYPERVISOR_CS); +wrmsr (MSR_LSTAR , saved_lstar); +wrmsr (MSR_CSTAR , saved_cstar); +wrmsr (MSR_STAR , ( (uint64_t )((FLAT_RING3_CS32 <<16 ) | __HYPERVISOR_CS) <<32 ) );wrmsr (MSR_SYSCALL_MASK ,X86_EFLAGS_VM |X86_EFLAGS_RF |X86_EFLAGS_NT | -X86_EFLAGS_DF |X86_EFLAGS_IF |X86_EFLAGS_TF , -0U ); +X86_EFLAGS_DF |X86_EFLAGS_IF |X86_EFLAGS_TF );if ( boot_cpu_data.x86_vendor ==X86_VENDOR_INTEL ) {/* Recover sysenter MSRs */ -wrmsrl (MSR_IA32_SYSENTER_ESP , saved_sysenter_esp); -wrmsrl (MSR_IA32_SYSENTER_EIP , saved_sysenter_eip); -wrmsr (MSR_IA32_SYSENTER_CS , __HYPERVISOR_CS,0 ); +wrmsr (MSR_IA32_SYSENTER_ESP , saved_sysenter_esp); +wrmsr (MSR_IA32_SYSENTER_EIP , saved_sysenter_eip); +wrmsr (MSR_IA32_SYSENTER_CS , __HYPERVISOR_CS); }#else /* !defined(CONFIG_X86_64) */ if ( supervisor_mode_kernel && cpu_has_sep ) -wrmsr (MSR_IA32_SYSENTER_ESP , &this_cpu (init_tss).esp1,0 ); +wrmsr (MSR_IA32_SYSENTER_ESP , &this_cpu (init_tss).esp1);#endif /* Maybe load the debug registers. */
@@ -79,7 +78,7 @@ void restore_rest_processor_state(void)stts ();if (cpu_has_pat) -wrmsrl (MSR_IA32_CR_PAT , host_pat); +wrmsr (MSR_IA32_CR_PAT , host_pat);mtrr_bp_restore (); }
xen/arch/x86/apic.c +25 -23
98 lines not on this page · raw message
xen/arch/x86/cpu/amd.c +46 -36
163 lines not on this page · raw message
xen/arch/x86/cpu/common.c +5 -5
@@ -315,10 +315,10 @@ static void __cpuinit squash_the_stupid_ {if (cpu_has (c,X86_FEATURE_PN ) && disable_x86_serial_nr ) {/* Disable processor serial number */ -unsigned long lo,hi; -rdmsr (MSR_IA32_BBL_CR_CTL ,lo,hi); - lo |=0x200000 ; -wrmsr (MSR_IA32_BBL_CR_CTL ,lo,hi); +uint64_t msr_content; + msr_content =rdmsr (MSR_IA32_BBL_CR_CTL ); + msr_content |=0x200000 ; +wrmsr (MSR_IA32_BBL_CR_CTL ,msr_content);printk (KERN_NOTICE "CPU serial number disabled.\n" );clear_bit (X86_FEATURE_PN , c->x86_capability);
@@ -595,7 +595,7 @@ void __cpuinit cpu_init(void)printk ("Initializing CPU#%d\n" , cpu);if (cpu_has_pat) -wrmsrl (MSR_IA32_CR_PAT , host_pat); +wrmsr (MSR_IA32_CR_PAT , host_pat);/* Install correct page table. */ write_ptbase (current);
xen/arch/x86/cpu/intel.c +9 -8
@@ -43,6 +43,7 @@ struct movsl_mask movsl_mask __read_moststatic void __devinit set_cpuidmask (void ) {unsigned int eax, ebx, ecx, edx, model; +uint64_t msr_content;if (!(opt_cpuid_mask_ecx | opt_cpuid_mask_edx))return ;
@@ -55,9 +56,9 @@ static void __devinit set_cpuidmask(voidreturn ; } -wrmsr (MSR_IA32_CPUID_FEATURE_MASK1 , - opt_cpuid_mask_ecx ? : ~0u , - opt_cpuid_mask_edx ? : ~0u ); + msr_content = (uint64_t )(opt_cpuid_mask_edx ? : ~0u ) <<32 ; + msr_content |= opt_cpuid_mask_edx ? : ~0u ; +wrmsr (MSR_IA32_CPUID_FEATURE_MASK1 , msr_content); }void __devinit early_intel_workaround (struct cpuinfo_x86 *c)
@@ -75,15 +76,15 @@ void __devinit early_intel_workaround(st*/ static void __devinit Intel_errata_workarounds (struct cpuinfo_x86 *c) { -unsigned long lo, hi; +uint64_t msr_content;if ((c->x86 ==15 ) && (c->x86_model ==1 ) && (c->x86_mask ==1 )) { -rdmsr (MSR_IA32_MISC_ENABLE , lo, hi); -if ((lo & (1 <<9 )) ==0 ) { + msr_content =rdmsr (MSR_IA32_MISC_ENABLE ); +if ((msr_content & (1 <<9 )) ==0 ) {printk (KERN_INFO "CPU: C0 stepping P4 Xeon detected.\n" );printk (KERN_INFO "CPU: Disabling hardware prefetching (Errata 037)\n" ); - lo |= (1 <<9 );/* Disable hw prefetching */ -wrmsr (MSR_IA32_MISC_ENABLE , lo, hi); + msr_content |= (1 <<9 );/* Disable hw prefetching */ +wrmsr (MSR_IA32_MISC_ENABLE , msr_content); } } }
xen/arch/x86/cpu/mcheck/amd_f10.c +3 -3
@@ -74,9 +74,9 @@ amd_f10_handler(struct mc_info *mi, uint mc_ext.mc_msr[1 ].reg =MSR_F10_MC4_MISC2 ; mc_ext.mc_msr[2 ].reg =MSR_F10_MC4_MISC3 ; -mca_rdmsrl (MSR_F10_MC4_MISC1 , mc_ext.mc_msr[0 ].value); -mca_rdmsrl (MSR_F10_MC4_MISC2 , mc_ext.mc_msr[1 ].value); -mca_rdmsrl (MSR_F10_MC4_MISC3 , mc_ext.mc_msr[2 ].value); + mc_ext.mc_msr[0 ].value =mca_rdmsr (MSR_F10_MC4_MISC1 ); + mc_ext.mc_msr[1 ].value =mca_rdmsr (MSR_F10_MC4_MISC2 ); + mc_ext.mc_msr[2 ].value =mca_rdmsr (MSR_F10_MC4_MISC3 );x86_mcinfo_add (mi, &mc_ext);return MCA_EXTINFO_LOCAL ;
xen/arch/x86/cpu/mcheck/amd_k8.c +2 -2
@@ -95,8 +95,8 @@ enum mcheck_type amd_k8_mcheck_init(strumcequirk_amd_apply (quirkflag); }else {/* Enable error reporting of all errors */ -wrmsrl (MSR_IA32_MC0_CTL +4 * i,0xffffffffffffffffULL ); -wrmsrl (MSR_IA32_MC0_STATUS +4 * i,0x0ULL ); +mca_wrmsr (MSR_IA32_MCx_CTL (i),0xffffffffffffffffULL ); +mca_wrmsr (MSR_IA32_MCx_STATUS (i),0x0ULL );break ; } }
xen/arch/x86/cpu/mcheck/amd_nonfatal.c +4 -4
@@ -144,7 +144,7 @@ static void mce_amd_work_fn(void *data)uint64_t value;uint32_t counter; -mca_rdmsrl (MSR_IA32_MC4_MISC , value); + value =mca_rdmsr (MSR_IA32_MC4_MISC );/* Only the error counter field is of interest * Bit field is described in AMD K8 BKDG chapter 6.4.5.5 */
@@ -169,7 +169,7 @@ static void mce_amd_work_fn(void *data) value &= ~(0x60FFF00000000ULL );/* Counter enable */ value |= (1ULL <<51 ); -mca_wrmsrl (MSR_IA32_MC4_MISC , value); +mca_wrmsr (MSR_IA32_MC4_MISC , value);wmb (); } }
@@ -212,7 +212,7 @@ void amd_nonfatal_mcheck_init(struct cpu/* hw threshold registers present */ hw_threshold =1 ; -rdmsrl (MSR_IA32_MC4_MISC , value); + value =mca_rdmsr (MSR_IA32_MC4_MISC );if (value & (1ULL <<61 )) {/* Locked bit */ /* Locked by BIOS. Not available for use */
@@ -233,7 +233,7 @@ void amd_nonfatal_mcheck_init(struct cpu value &= ~(0x60FFF00000000ULL );/* Counter enable */ value |= (1ULL <<51 ); -wrmsrl (MSR_IA32_MC4_MISC , value); +mca_wrmsr (MSR_IA32_MC4_MISC , value);/* serialize */ wmb ();printk (XENLOG_INFO "MCA: Use hw thresholding to adjust polling frequency\n" );
xen/arch/x86/cpu/mcheck/k7.c +29 -29
98 lines not on this page · raw message
xen/arch/x86/cpu/mcheck/mce.c +26 -28
170 lines not on this page · raw message
xen/arch/x86/cpu/mcheck/mce.h +9 -6
@@ -83,15 +83,18 @@ extern struct intpose_ent *intpose_looku uint64_t *);extern void intpose_inval (unsigned int ,uint64_t ); -#define mca_rdmsrl (msr, var) do { \ - if (intpose_lookup(smp_processor_id(), msr, &var) == NULL) \ - rdmsrl(msr, var); \ -} while (0) +static inline uint64_t mca_rdmsr (unsigned int msr) +{ +uint64_t val; +if (intpose_lookup (smp_processor_id (), msr, &val) ==NULL ) +return rdmsr (msr); +return val; +}/* Write an MSR, invalidating any interposed value */ -#define mca_wrmsrl (msr, val) do { \ +#define mca_wrmsr (msr, val) do { \ intpose_inval(smp_processor_id(), msr); \ - wrmsrl(msr, val); \ + wrmsr(msr, val); \ } while (0)
xen/arch/x86/cpu/mcheck/mce_amd_quirks.c +5 -4
@@ -17,8 +17,9 @@* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <asm-x86/msr.h> -#include <asm-x86/processor.h> +#include <xen/types.h> +#include <asm/msr.h> +#include <asm/processor.h> #include "mce_quirks.h"
@@ -64,8 +65,8 @@ int mcequirk_amd_apply(enum mcequirk_amd* TBL walk error reporting, which trips off incorrectly * with AGP GART & 3ware & Cerberus. */ -wrmsrl (MSR_IA32_MC4_CTL , ~(1ULL <<10 )); -wrmsrl (MSR_IA32_MC4_STATUS ,0ULL ); +wrmsr (MSR_IA32_MC4_CTL , ~(1ULL <<10 )); +wrmsr (MSR_IA32_MC4_STATUS ,0ULL );break ; }
xen/arch/x86/cpu/mcheck/mce_intel.c +34 -33
160 lines not on this page · raw message
xen/arch/x86/cpu/mtrr/generic.c +85 -57
276 lines not on this page · raw message
xen/arch/x86/cpu/mtrr/main.c +2 -2
@@ -101,10 +101,10 @@ static int have_wrcomb(void)/* This function returns the number of variable MTRRs */ static void __init set_num_var_ranges (void ) { -unsigned long config =0 , dummy; +unsigned long config =0 ;if (use_intel ()) { -rdmsr (MTRRcap_MSR, config, dummy); + config =rdmsr (MTRRcap_MSR); }else if (is_cpu (AMD )) config =2 ;else if (is_cpu (CYRIX ) ||is_cpu (CENTAUR ))
xen/arch/x86/cpu/mtrr/mtrr.h +2 -3
@@ -60,8 +60,7 @@ extern int positive_have_wrcomb(void);struct set_mtrr_context {unsigned long flags;unsigned long cr4val; -u32 deftype_lo; -u32 deftype_hi; +uint64_t deftype;u32 ccr3; };
@@ -83,5 +82,5 @@ extern unsigned int num_var_ranges;void mtrr_state_warn (void );const char *mtrr_attrib_to_str (int x); -void mtrr_wrmsr (unsigned ,unsigned ,unsigned ); +void mtrr_wrmsr (unsigned int msr,uint64_t msr_content);
xen/arch/x86/cpu/mtrr/state.c +3 -4
@@ -31,7 +31,7 @@ void set_mtrr_prepare_save(struct set_mtif (use_intel ())/* Save MTRR state */ -rdmsr (MTRRdefType_MSR, ctxt->deftype_lo, ctxt->deftype_hi); + ctxt->deftype =rdmsr (MTRRdefType_MSR);else /* Cyrix ARRs - everything else were excluded at the top */ ctxt->ccr3 =getCx86 (CX86_CCR3 );
@@ -42,8 +42,7 @@ void set_mtrr_cache_disable(struct set_m {if (use_intel ())/* Disable MTRRs, and set the default type to uncached */ -mtrr_wrmsr (MTRRdefType_MSR, ctxt->deftype_lo &0xf300UL , - ctxt->deftype_hi); +mtrr_wrmsr (MTRRdefType_MSR, ctxt->deftype &0xf300UL );else if (is_cpu (CYRIX ))/* Cyrix ARRs - everything else were excluded at the top */ setCx86 (CX86_CCR3 , (ctxt->ccr3 &0x0f ) |0x10 );
@@ -60,7 +59,7 @@ void set_mtrr_done(struct set_mtrr_conte/* Restore MTRRdefType */ if (use_intel ())/* Intel (P6) standard MTRRs */ -mtrr_wrmsr (MTRRdefType_MSR, ctxt->deftype_lo, ctxt->deftype_hi); +mtrr_wrmsr (MTRRdefType_MSR, ctxt->deftype);else /* Cyrix ARRs - everything else was excluded at the top */ setCx86 (CX86_CCR3 , ctxt->ccr3);
xen/arch/x86/domain.c +3 -9
@@ -1089,21 +1089,15 @@ static void load_segments(struct vcpu *n {/* This can only be non-zero if selector is NULL. */ if ( nctxt->fs_base ) -wrmsr (MSR_FS_BASE , - nctxt->fs_base, - nctxt->fs_base>>32 ); +wrmsr (MSR_FS_BASE , nctxt->fs_base);/* Most kernels have non-zero GS base, so don't bother testing. */ /* (This is also a serialising instruction, avoiding AMD erratum #88.) */ -wrmsr (MSR_SHADOW_GS_BASE , - nctxt->gs_base_kernel, - nctxt->gs_base_kernel>>32 ); +wrmsr (MSR_SHADOW_GS_BASE , nctxt->gs_base_kernel);/* This can only be non-zero if selector is NULL. */ if ( nctxt->gs_base_user ) -wrmsr (MSR_GS_BASE , - nctxt->gs_base_user, - nctxt->gs_base_user>>32 ); +wrmsr (MSR_GS_BASE , nctxt->gs_base_user);/* If in kernel mode then switch the GS bases around. */ if ( (n->arch.flags & TF_kernel_mode) )
xen/arch/x86/e820.c +4 -4
@@ -457,8 +457,8 @@ static uint64_t mtrr_top_of_ram(void) } addr_mask = ((1ull << phys_bits) -1 ) & ~((1ull <<12 ) -1 ); -rdmsrl (MSR_MTRRcap, mtrr_cap); -rdmsrl (MSR_MTRRdefType, mtrr_def); + mtrr_cap =rdmsr (MSR_MTRRcap); + mtrr_def =rdmsr (MSR_MTRRdefType);if ( e820_verbose )printk (" MTRR cap: %" PRIx64" type: %" PRIx64"\n" , mtrr_cap, mtrr_def);
@@ -474,8 +474,8 @@ static uint64_t mtrr_top_of_ram(void) top =0 ;for ( i =0 ; i < (uint8_t )mtrr_cap; i++ ) { -rdmsrl (MSR_MTRRphysBase (i), base); -rdmsrl (MSR_MTRRphysMask (i), mask); + base =rdmsr (MSR_MTRRphysBase (i)); + mask =rdmsr (MSR_MTRRphysMask (i) );if ( e820_verbose ) printk(" MTRR[%d]: base %"PRIx64" mask %"PRIx64"\n",
xen/arch/x86/genapic/x2apic.c +10 -4
@@ -90,6 +90,7 @@ void send_IPI_mask_x2apic_phys(const cpu {unsigned int cpu, cfg;unsigned long flags; +uint64_t msr_content;/* * Ensure that any synchronisation data written in program order by this
@@ -107,8 +108,10 @@ void send_IPI_mask_x2apic_phys(const cpu cfg =APIC_DM_FIXED |0 /* no shorthand */ |APIC_DEST_PHYSICAL | vector; for_each_cpu_mask ( cpu, *cpumask ) -if ( cpu !=smp_processor_id () ) -apic_wrmsr (APIC_ICR , cfg,cpu_physical_id (cpu)); +if ( cpu !=smp_processor_id () ) { + msr_content = cfg | ((uint64_t )(cpu_physical_id (cpu)) <<32 ); +apic_wrmsr (APIC_ICR , msr_content); + }local_irq_restore (flags); }
@@ -117,6 +120,7 @@ void send_IPI_mask_x2apic_cluster(const {unsigned int cpu, cfg;unsigned long flags; +uint64_t msr_content;mb ();/* see the comment in send_IPI_mask_x2apic_phys() */
@@ -124,8 +128,10 @@ void send_IPI_mask_x2apic_cluster(const cfg =APIC_DM_FIXED |0 /* no shorthand */ |APIC_DEST_LOGICAL | vector; for_each_cpu_mask ( cpu, *cpumask ) -if ( cpu !=smp_processor_id () ) -apic_wrmsr (APIC_ICR , cfg, cpu_2_logical_apicid[cpu]); +if ( cpu !=smp_processor_id () ) { + msr_content = cfg | ((uint64_t )(cpu_2_logical_apicid[cpu]) <<32 ); +apic_wrmsr (APIC_ICR , msr_content); + }local_irq_restore (flags); }
xen/arch/x86/hvm/emulate.c +2 -17
@@ -825,16 +825,7 @@ static int hvmemul_read_msr(uint64_t *val, struct x86_emulate_ctxt *ctxt) { - struct cpu_user_regs _regs; -int rc; - - _regs.ecx = (uint32_t )reg; - -if ( (rc =hvm_msr_read_intercept (&_regs)) !=X86EMUL_OKAY ) -return rc; - - *val = ((uint64_t )(uint32_t )_regs.edx <<32 ) | (uint32_t )_regs.eax; -return X86EMUL_OKAY ; + return hvm_msr_read_intercept(reg, val); } static int hvmemul_write_msr(
@@ -842,13 +833,7 @@ static int hvmemul_write_msr(uint64_t val, struct x86_emulate_ctxt *ctxt) { - struct cpu_user_regs _regs; - - _regs.edx = (uint32_t )(val >>32 ); - _regs.eax = (uint32_t )val; - _regs.ecx = (uint32_t )reg; - -return hvm_msr_write_intercept (&_regs); + return hvm_msr_write_intercept(reg, val); } static int hvmemul_wbinvd(
xen/arch/x86/hvm/hvm.c +16 -20
@@ -2010,9 +2010,8 @@ void hvm_rdtsc_intercept(struct cpu_user regs->edx = (uint32_t )(tsc >>32 ); } -int hvm_msr_read_intercept (struct cpu_user_regs *regs) +int hvm_msr_read_intercept (unsigned int msr,uint64_t *msr_val) { -uint32_t ecx = regs->ecx;uint64_t msr_content =0 ;struct vcpu *v = current;uint64_t *var_range_base, *fixed_range_base;
@@ -2026,7 +2025,7 @@ int hvm_msr_read_intercept(struct cpu_ushvm_cpuid (1 , &cpuid[0 ], &cpuid[1 ], &cpuid[2 ], &cpuid[3 ]); mtrr = !!(cpuid[3 ] &bitmaskof (X86_FEATURE_MTRR )); -switch ( ecx ) +switch ( msr ) {case MSR_IA32_TSC : msr_content =hvm_get_guest_tsc (v);
@@ -2064,19 +2063,19 @@ int hvm_msr_read_intercept(struct cpu_uscase MSR_MTRRfix16K_A0000:if ( !mtrr ) goto gp_fault; - index = regs->ecx - MSR_MTRRfix16K_80000; + index = msr - MSR_MTRRfix16K_80000; msr_content = fixed_range_base[index +1 ];break ; case MSR_MTRRfix4K_C0000...MSR_MTRRfix4K_F8000:if ( !mtrr ) goto gp_fault; - index = regs->ecx - MSR_MTRRfix4K_C0000; + index = msr - MSR_MTRRfix4K_C0000; msr_content = fixed_range_base[index +3 ];break ; case MSR_IA32_MTRR_PHYSBASE0...MSR_IA32_MTRR_PHYSMASK7:if ( !mtrr ) goto gp_fault; - index = regs->ecx -MSR_IA32_MTRR_PHYSBASE0 ; + index = msr -MSR_IA32_MTRR_PHYSBASE0 ; msr_content = var_range_base[index];break ;
@@ -2091,18 +2090,17 @@ int hvm_msr_read_intercept(struct cpu_usbreak ;default : - ret =vmce_rdmsr (ecx, &msr_content); + ret =vmce_rdmsr (msr, &msr_content);if ( ret <0 ) goto gp_fault;else if ( ret )break ;/* ret == 0, This is not an MCE MSR, see other MSRs */ else if (!ret) -return hvm_funcs.msr_read_intercept (regs); +return hvm_funcs.msr_read_intercept (msr, &msr_content); } - regs->eax = (uint32_t )msr_content; - regs->edx = (uint32_t )(msr_content >>32 ); + *msr_val = msr_content;return X86EMUL_OKAY ; gp_fault:
@@ -2110,10 +2108,8 @@ gp_fault:return X86EMUL_EXCEPTION ; } -int hvm_msr_write_intercept (struct cpu_user_regs *regs) +int hvm_msr_write_intercept (unsigned int msr,uint64_t msr_content) { -uint32_t ecx = regs->ecx; -uint64_t msr_content = (uint32_t )regs->eax | ((uint64_t )regs->edx <<32 );struct vcpu *v = current;int index, mtrr;uint32_t cpuid[4 ];
@@ -2122,7 +2118,7 @@ int hvm_msr_write_intercept(struct cpu_uhvm_cpuid (1 , &cpuid[0 ], &cpuid[1 ], &cpuid[2 ], &cpuid[3 ]); mtrr = !!(cpuid[3 ] &bitmaskof (X86_FEATURE_MTRR )); -switch ( ecx ) +switch ( msr ) {case MSR_IA32_TSC :hvm_set_guest_tsc (v, msr_content);
@@ -2132,7 +2128,7 @@ int hvm_msr_write_intercept(struct cpu_u v->arch.hvm_vcpu.msr_tsc_aux = (uint32_t )msr_content;if ( cpu_has_rdtscp && (v->domain->arch.tsc_mode !=TSC_MODE_PVRDTSCP ) ) -wrmsrl (MSR_TSC_AUX , (uint32_t )msr_content); +wrmsr (MSR_TSC_AUX , (uint32_t )msr_content);break ;case MSR_IA32_APICBASE :
@@ -2164,7 +2160,7 @@ int hvm_msr_write_intercept(struct cpu_ucase MSR_MTRRfix16K_A0000:if ( !mtrr ) goto gp_fault; - index = regs->ecx - MSR_MTRRfix16K_80000 +1 ; + index = msr - MSR_MTRRfix16K_80000 +1 ;if ( !mtrr_fix_range_msr_set (&v->arch.hvm_vcpu.mtrr, index, msr_content) ) goto gp_fault;
@@ -2172,7 +2168,7 @@ int hvm_msr_write_intercept(struct cpu_u case MSR_MTRRfix4K_C0000...MSR_MTRRfix4K_F8000:if ( !mtrr ) goto gp_fault; - index = regs->ecx - MSR_MTRRfix4K_C0000 +3 ; + index = msr - MSR_MTRRfix4K_C0000 +3 ;if ( !mtrr_fix_range_msr_set (&v->arch.hvm_vcpu.mtrr, index, msr_content) ) goto gp_fault;
@@ -2181,7 +2177,7 @@ int hvm_msr_write_intercept(struct cpu_uif ( !mtrr ) goto gp_fault;if ( !mtrr_var_range_msr_set (&v->arch.hvm_vcpu.mtrr, - regs->ecx, msr_content) ) + msr, msr_content) ) goto gp_fault;break ;
@@ -2190,13 +2186,13 @@ int hvm_msr_write_intercept(struct cpu_ubreak ;default : - ret =vmce_wrmsr (ecx, msr_content); + ret =vmce_wrmsr (msr, msr_content);if ( ret <0 ) goto gp_fault;else if ( ret )break ;else if (!ret) -return hvm_funcs.msr_write_intercept (regs); +return hvm_funcs.msr_write_intercept (msr, msr_content); }return X86EMUL_OKAY ;
xen/arch/x86/hvm/svm/svm.c +46 -54
229 lines not on this page · raw message
xen/arch/x86/hvm/svm/vpmu.c +15 -23
@@ -110,11 +110,11 @@ static inline void context_restore(strucstruct amd_vpmu_context *ctxt = vpmu->context;for ( i =0 ; i <NUM_COUNTERS ; i++ ) -wrmsrl (AMD_F10H_CTRLS [i], ctxt->ctrls[i]); +wrmsr (AMD_F10H_CTRLS [i], ctxt->ctrls[i]);for ( i =0 ; i <NUM_COUNTERS ; i++ ) { -wrmsrl (AMD_F10H_COUNTERS [i], ctxt->counters[i]); +wrmsr (AMD_F10H_COUNTERS [i], ctxt->counters[i]);/* Force an interrupt to allow guest reset the counter, if the value is positive */
@@ -147,10 +147,10 @@ static inline void context_save(struct vstruct amd_vpmu_context *ctxt = vpmu->context;for ( i =0 ; i <NUM_COUNTERS ; i++ ) -rdmsrl (AMD_F10H_COUNTERS [i], ctxt->counters[i]); + ctxt->counters[i] =rdmsr (AMD_F10H_COUNTERS [i]);for ( i =0 ; i <NUM_COUNTERS ; i++ ) -rdmsrl (AMD_F10H_CTRLS [i], ctxt->ctrls[i]); + ctxt->ctrls[i] =rdmsr (AMD_F10H_CTRLS [i]); }static void amd_vpmu_save (struct vcpu *v)
@@ -167,42 +167,38 @@ static void amd_vpmu_save(struct vcpu *vapic_write (APIC_LVTPC , ctx->hw_lapic_lvtpc |APIC_LVT_MASKED ); } -static void context_update (struct cpu_user_regs *regs,u64 msr_content) +static void context_update (unsigned int msr,u64 msr_content) {int i; -u32 addr = regs->ecx;struct vcpu *v = current;struct vpmu_struct *vpmu =vcpu_vpmu (v);struct amd_vpmu_context *ctxt = vpmu->context;for ( i =0 ; i <NUM_COUNTERS ; i++ ) -if ( addr ==AMD_F10H_COUNTERS [i] ) +if ( msr ==AMD_F10H_COUNTERS [i] ) ctxt->counters[i] = msr_content;for ( i =0 ; i <NUM_COUNTERS ; i++ ) -if ( addr ==AMD_F10H_CTRLS [i] ) +if ( msr ==AMD_F10H_CTRLS [i] ) ctxt->ctrls[i] = msr_content; ctxt->hw_lapic_lvtpc =apic_read (APIC_LVTPC ); } -static int amd_vpmu_do_wrmsr (struct cpu_user_regs *regs) +static int amd_vpmu_do_wrmsr (unsigned int msr,uint64_t msr_content) { -u64 msr_content =0 ;struct vcpu *v = current;struct vpmu_struct *vpmu =vcpu_vpmu (v); - msr_content = (u32 )regs->eax | ((u64 )regs->edx <<32 ); -/* For all counters, enable guest only mode for HVM guest */ -if ( (get_pmu_reg_type (regs->ecx) ==MSR_TYPE_CTRL ) && +if ( (get_pmu_reg_type (msr) ==MSR_TYPE_CTRL ) && !(is_guest_mode (msr_content)) ) {set_guest_mode (msr_content); }/* check if the first counter is enabled */ -if ( (get_pmu_reg_type (regs->ecx) ==MSR_TYPE_CTRL ) && +if ( (get_pmu_reg_type (msr) ==MSR_TYPE_CTRL ) &&is_pmu_enabled (msr_content) && !(vpmu->flags &VPMU_RUNNING ) ) {if ( !acquire_pmu_ownership (PMU_OWNER_HVM ) )
@@ -212,7 +208,7 @@ static int amd_vpmu_do_wrmsr(struct cpu_ }/* stop saving & restore if guest stops first counter */ -if ( (get_pmu_reg_type (regs->ecx) ==MSR_TYPE_CTRL ) && +if ( (get_pmu_reg_type (msr) ==MSR_TYPE_CTRL ) && (is_pmu_enabled (msr_content) ==0 ) && (vpmu->flags &VPMU_RUNNING ) ) {apic_write (APIC_LVTPC ,PMU_APIC_VECTOR |APIC_LVT_MASKED );
@@ -221,20 +217,16 @@ static int amd_vpmu_do_wrmsr(struct cpu_ }/* Update vpmu context immediately */ -context_update (regs, msr_content); +context_update (msr, msr_content);/* Write to hw counters */ -wrmsrl (regs->ecx, msr_content); +wrmsr (msr, msr_content);return 1 ; } -static int amd_vpmu_do_rdmsr (struct cpu_user_regs *regs) +static int amd_vpmu_do_rdmsr (unsigned int msr,uint64_t *msr_val) { -u64 msr_content =0 ; - -rdmsrl (regs->ecx, msr_content); - regs->eax = msr_content &0xFFFFFFFF ; - regs->edx = msr_content >>32 ; + *msr_val =rdmsr (msr);return 1 ; }
xen/arch/x86/hvm/vmx/vmcs.c +29 -20
135 lines not on this page · raw message
xen/arch/x86/hvm/vmx/vmx.c +79 -81
338 lines not on this page · raw message
xen/arch/x86/hvm/vmx/vpmu_core2.c +22 -25
142 lines not on this page · raw message
xen/arch/x86/hvm/vpmu.c +4 -4
@@ -36,21 +36,21 @@static int __read_mostly opt_vpmu_enabled;boolean_param ("vpmu" , opt_vpmu_enabled); -int vpmu_do_wrmsr (struct cpu_user_regs *regs) +int vpmu_do_wrmsr (unsigned int msr,uint64_t msr_content) {struct vpmu_struct *vpmu =vcpu_vpmu (current);if ( vpmu->arch_vpmu_ops ) -return vpmu->arch_vpmu_ops->do_wrmsr (regs); +return vpmu->arch_vpmu_ops->do_wrmsr (msr, msr_content);return 0 ; } -int vpmu_do_rdmsr (struct cpu_user_regs *regs) +int vpmu_do_rdmsr (unsigned int msr,uint64_t *msr_val) {struct vpmu_struct *vpmu =vcpu_vpmu (current);if ( vpmu->arch_vpmu_ops ) -return vpmu->arch_vpmu_ops->do_rdmsr (regs); +return vpmu->arch_vpmu_ops->do_rdmsr (msr, msr_val);return 0 ; }
xen/arch/x86/microcode_amd.c +4 -5
@@ -47,7 +47,6 @@ struct equiv_cpu_entry *equiv_cpu_table;static int collect_cpu_info (int cpu,struct cpu_signature *csig) {struct cpuinfo_x86 *c = &cpu_data[cpu]; -uint32_t dummy;memset (csig,0 ,sizeof (*csig));
@@ -58,7 +57,7 @@ static int collect_cpu_info(int cpu, strreturn -EINVAL ; } -rdmsr (MSR_AMD_PATCHLEVEL , csig->rev, dummy); + csig->rev =rdmsr (MSR_AMD_PATCHLEVEL );printk (KERN_INFO "microcode: collect_cpu_info: patch_id=0x%x\n" , csig->rev);
@@ -126,7 +125,7 @@ static int apply_microcode(int cpu) {unsigned long flags;struct ucode_cpu_info *uci = &per_cpu (ucode_cpu_info, cpu); -uint32_t rev, dummy; +uint32_t rev;struct microcode_amd *mc_amd = uci->mc.mc_amd;/* We should bind the task to the CPU */
@@ -137,10 +136,10 @@ static int apply_microcode(int cpu)spin_lock_irqsave (µcode_update_lock, flags); -wrmsrl (MSR_AMD_PATCHLOADER , (unsigned long )&mc_amd->hdr.data_code); +wrmsr (MSR_AMD_PATCHLOADER , (unsigned long )&mc_amd->hdr.data_code);/* get patch id after patching */ -rdmsr (MSR_AMD_PATCHLEVEL , rev, dummy); + rev =rdmsr (MSR_AMD_PATCHLEVEL );spin_unlock_irqrestore (µcode_update_lock, flags);
xen/arch/x86/microcode_intel.c +11 -8
@@ -62,6 +62,7 @@ static DEFINE_SPINLOCK(microcode_update_static int collect_cpu_info (int cpu_num,struct cpu_signature *csig) {struct cpuinfo_x86 *c = &cpu_data[cpu_num]; +uint64_t msr_content;unsigned int val[2 ];BUG_ON (cpu_num !=smp_processor_id ());
@@ -81,15 +82,17 @@ static int collect_cpu_info(int cpu_num,if ( (c->x86_model >=5 ) || (c->x86 >6 ) ) {/* get processor flags from MSR 0x17 */ -rdmsr (MSR_IA32_PLATFORM_ID , val[0 ], val[1 ]); + msr_content =rdmsr (MSR_IA32_PLATFORM_ID ); + val[1 ] = msr_content >>32 ; csig->pf =1 << ((val[1 ] >>18 ) &7 ); } -wrmsr (MSR_IA32_UCODE_REV ,0 ,0 ); +wrmsr (MSR_IA32_UCODE_REV ,0 );/* see notes above for revision 1.07. Apparent chip bug */ sync_core ();/* get the current revision from MSR 0x8B */ -rdmsr (MSR_IA32_UCODE_REV , val[0 ], csig->rev); + msr_content =rdmsr (MSR_IA32_UCODE_REV ); + csig->rev = (uint32_t )msr_content;pr_debug ("microcode: collect_cpu_info : sig=0x%x, pf=0x%x, rev=0x%x\n" , csig->sig, csig->pf, csig->rev);
@@ -250,6 +253,7 @@ static int apply_microcode(int cpu) {unsigned long flags;unsigned int val[2 ]; +uint64_t msr_content;int cpu_num =raw_smp_processor_id ();struct ucode_cpu_info *uci = &per_cpu (ucode_cpu_info, cpu_num);
@@ -263,16 +267,15 @@ static int apply_microcode(int cpu)spin_lock_irqsave (µcode_update_lock, flags);/* write microcode via MSR 0x79 */ -wrmsr (MSR_IA32_UCODE_WRITE , - (unsigned long ) uci->mc.mc_intel->bits, - (unsigned long ) uci->mc.mc_intel->bits >>16 >>16 ); -wrmsr (MSR_IA32_UCODE_REV ,0 ,0 ); +wrmsr (MSR_IA32_UCODE_WRITE , (unsigned long ) uci->mc.mc_intel->bits); +wrmsr (MSR_IA32_UCODE_REV ,0 );/* see notes above for revision 1.07. Apparent chip bug */ sync_core ();/* get the current revision from MSR 0x8B */ -rdmsr (MSR_IA32_UCODE_REV , val[0 ], val[1 ]); + msr_content =rdmsr (MSR_IA32_UCODE_REV ); + val[1 ] = msr_content >>32 ;spin_unlock_irqrestore (µcode_update_lock, flags);if ( val[1 ] != uci->mc.mc_intel->hdr.rev )
xen/arch/x86/nmi.c +16 -16
@@ -147,7 +147,7 @@ static void disable_lapic_nmi_watchdog(vreturn ;switch (boot_cpu_data.x86_vendor) {case X86_VENDOR_AMD : -wrmsr (MSR_K7_EVNTSEL0 ,0 ,0 ); +wrmsr (MSR_K7_EVNTSEL0 ,0 );break ;case X86_VENDOR_INTEL :switch (boot_cpu_data.x86) {
@@ -155,14 +155,14 @@ static void disable_lapic_nmi_watchdog(vif (boot_cpu_data.x86_model >0xd )break ; -wrmsr (MSR_P6_EVNTSEL0 ,0 ,0 ); +wrmsr (MSR_P6_EVNTSEL0 ,0 );break ;case 15 :if (boot_cpu_data.x86_model >0x4 )break ; -wrmsr (MSR_P4_IQ_CCCR0 ,0 ,0 ); -wrmsr (MSR_P4_CRU_ESCR0 ,0 ,0 ); +wrmsr (MSR_P4_IQ_CCCR0 ,0 ); +wrmsr (MSR_P4_CRU_ESCR0 ,0 );break ; }break ;
@@ -219,7 +219,7 @@ static void __pminit clear_msr_range(unsunsigned int i;for (i =0 ; i < n; i++) -wrmsr (base+i,0 ,0 ); +wrmsr (base+i,0 ); }static inline void write_watchdog_counter (const char *descr)
@@ -229,7 +229,7 @@ static inline void write_watchdog_countedo_div (count, nmi_hz);if (descr)Dprintk ("setting %s to -0x%" PRIx64"\n" , descr, count); -wrmsrl (nmi_perfctr_msr,0 - count); +wrmsr (nmi_perfctr_msr,0 - count); } static void __pminit setup_k7_watchdog(void)
@@ -246,11 +246,11 @@ static void __pminit setup_k7_watchdog(v | K7_EVNTSEL_USR |K7_NMI_EVENT ; -wrmsr (MSR_K7_EVNTSEL0 , evntsel,0 ); +wrmsr (MSR_K7_EVNTSEL0 , evntsel);write_watchdog_counter ("K7_PERFCTR0" );apic_write (APIC_LVTPC ,APIC_DM_NMI ); evntsel |=K7_EVNTSEL_ENABLE ; -wrmsr (MSR_K7_EVNTSEL0 , evntsel,0 ); +wrmsr (MSR_K7_EVNTSEL0 , evntsel); } static void __pminit setup_p6_watchdog(unsigned counter)
@@ -267,18 +267,18 @@ static void __pminit setup_p6_watchdog(u | P6_EVNTSEL_USR | counter; -wrmsr (MSR_P6_EVNTSEL0 , evntsel,0 ); +wrmsr (MSR_P6_EVNTSEL0 , evntsel);write_watchdog_counter ("P6_PERFCTR0" );apic_write (APIC_LVTPC ,APIC_DM_NMI ); evntsel |=P6_EVNTSEL0_ENABLE ; -wrmsr (MSR_P6_EVNTSEL0 , evntsel,0 ); +wrmsr (MSR_P6_EVNTSEL0 , evntsel); } static int __pminit setup_p4_watchdog(void) { -unsigned int misc_enable, dummy; +uint64_t misc_enable; -rdmsr (MSR_IA32_MISC_ENABLE , misc_enable, dummy); + misc_enable =rdmsr (MSR_IA32_MISC_ENABLE );if (!(misc_enable &MSR_IA32_MISC_ENABLE_PERF_AVAIL ))return 0 ;
@@ -304,11 +304,11 @@ static int __pminit setup_p4_watchdog(voclear_msr_range (MSR_P4_BPU_CCCR0 ,18 );clear_msr_range (MSR_P4_BPU_PERFCTR0 ,18 ); -wrmsr (MSR_P4_CRU_ESCR0 ,P4_NMI_CRU_ESCR0 ,0 ); -wrmsr (MSR_P4_IQ_CCCR0 ,P4_NMI_IQ_CCCR0 & ~P4_CCCR_ENABLE ,0 ); +wrmsr (MSR_P4_CRU_ESCR0 ,P4_NMI_CRU_ESCR0 ); +wrmsr (MSR_P4_IQ_CCCR0 ,P4_NMI_IQ_CCCR0 & ~P4_CCCR_ENABLE );write_watchdog_counter ("P4_IQ_COUNTER0" );apic_write (APIC_LVTPC ,APIC_DM_NMI ); -wrmsr (MSR_P4_IQ_CCCR0 , nmi_p4_cccr_val,0 ); +wrmsr (MSR_P4_IQ_CCCR0 , nmi_p4_cccr_val);return 1 ; }
@@ -442,7 +442,7 @@ void nmi_watchdog_tick(struct cpu_user_r* - LVTPC is masked on interrupt and must be * unmasked by the LVTPC handler. */ -wrmsr (MSR_P4_IQ_CCCR0 , nmi_p4_cccr_val,0 ); +wrmsr (MSR_P4_IQ_CCCR0 , nmi_p4_cccr_val);apic_write (APIC_LVTPC ,APIC_DM_NMI ); }else if ( nmi_perfctr_msr ==MSR_P6_PERFCTR0 )
xen/arch/x86/oprofile/nmi_int.c +11 -22
@@ -35,14 +35,14 @@ static unsigned long saved_lvtpc[NR_CPUSstatic char *cpu_type; -static int passive_domain_msr_op_checks (struct cpu_user_regs *regs ,int *typep,int *indexp) +static int passive_domain_msr_op_checks (unsigned int msr,int *typep,int *indexp) {struct vpmu_struct *vpmu =vcpu_vpmu (current);if ( model ==NULL )return 0 ;if ( model->is_arch_pmu_msr ==NULL )return 0 ; -if ( !model->is_arch_pmu_msr ((u64 )regs->ecx, typep, indexp) ) +if ( !model->is_arch_pmu_msr (msr, typep, indexp) )return 0 ;if ( !(vpmu->flags &PASSIVE_DOMAIN_ALLOCATED ) )
@@ -51,29 +51,26 @@ static int passive_domain_msr_op_checks(return 1 ; } -int passive_domain_do_rdmsr (struct cpu_user_regs *regs) +int passive_domain_do_rdmsr (unsigned int msr,uint64_t *msr_val) {u64 msr_content;int type, index; -if ( !passive_domain_msr_op_checks (regs, &type, &index)) +if ( !passive_domain_msr_op_checks (msr, &type, &index))return 0 ; model->load_msr (current, type, index, &msr_content); - regs->eax = msr_content &0xFFFFFFFF ; - regs->edx = msr_content >>32 ; + *msr_val = msr_content;return 1 ; } -int passive_domain_do_wrmsr (struct cpu_user_regs *regs) +int passive_domain_do_wrmsr (unsigned int msr,uint64_t msr_content) { -u64 msr_content;int type, index; -if ( !passive_domain_msr_op_checks (regs, &type, &index)) +if ( !passive_domain_msr_op_checks (msr, &type, &index))return 0 ; - msr_content = (u32 )regs->eax | ((u64 )regs->edx <<32 ); model->save_msr (current, type, index, msr_content);return 1 ; }
@@ -109,15 +106,11 @@ static void nmi_cpu_save_registers(strucunsigned int i;for (i =0 ; i < nr_ctrs; ++i) { -rdmsr (counters[i].addr, - counters[i].saved.low, - counters[i].saved.high); + counters[i].value =rdmsr (counters[i].addr); }for (i =0 ; i < nr_ctrls; ++i) { -rdmsr (controls[i].addr, - controls[i].saved.low, - controls[i].saved.high); + controls[i].value =rdmsr (controls[i].addr); } }
@@ -227,15 +220,11 @@ static void nmi_restore_registers(structunsigned int i;for (i =0 ; i < nr_ctrls; ++i) { -wrmsr (controls[i].addr, - controls[i].saved.low, - controls[i].saved.high); +wrmsr (controls[i].addr, controls[i].value); }for (i =0 ; i < nr_ctrs; ++i) { -wrmsr (counters[i].addr, - counters[i].saved.low, - counters[i].saved.high); +wrmsr (counters[i].addr, counters[i].value); } }
xen/arch/x86/oprofile/op_model_athlon.c +31 -28
120 lines not on this page · raw message
xen/arch/x86/oprofile/op_model_p4.c +50 -48
79 lines not on this page · raw message
xen/arch/x86/oprofile/op_model_ppro.c +28 -28
56 lines not on this page · raw message
xen/arch/x86/traps.c +35 -30
65 lines not on this page · raw message
xen/include/asm-x86/apic.h +15 -26
41 lines not on this page · raw message
xen/include/asm-x86/msr.h +52 -57
109 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Part of the diff is not shown here. View the raw message.
Quoted 4 lines · On Wednesday 26 May 2010 18:47:36 Christoph Egger wrote:
Hi!
Attached is a patch which simplifies msr handling throughout xen kernel code.
This is a new version of this patch.
Signature · 6 lines
---to satisfy European Law for business letters: Advanced Micro Devices GmbH Einsteinring 24, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
xen/arch/x86/acpi/cpufreq/cpufreq.c +8 -8
@@ -137,13 +137,12 @@ struct drv_cmd {static void do_drv_read (void *drvcmd) {struct drv_cmd *cmd; -u32 h; cmd = (struct drv_cmd *)drvcmd;switch (cmd->type) {case SYSTEM_INTEL_MSR_CAPABLE : -rdmsr (cmd->addr.msr.reg, cmd->val, h); + cmd->val =rdmsr (cmd->addr.msr.reg);break ;case SYSTEM_IO_CAPABLE : acpi_os_read_port((acpi_io_address)cmd->addr.io.port,
@@ -157,15 +156,16 @@ static void do_drv_read(void *drvcmd)static void do_drv_write (void *drvcmd) {struct drv_cmd *cmd; -u32 lo, hi; +uint64_t msr_content; cmd = (struct drv_cmd *)drvcmd;switch (cmd->type) {case SYSTEM_INTEL_MSR_CAPABLE : -rdmsr (cmd->addr.msr.reg, lo, hi); - lo = (lo & ~INTEL_MSR_RANGE ) | (cmd->val &INTEL_MSR_RANGE ); -wrmsr (cmd->addr.msr.reg, lo, hi); + msr_content =rdmsr (cmd->addr.msr.reg); + msr_content = (msr_content & ~INTEL_MSR_RANGE ) + | (cmd->val &INTEL_MSR_RANGE ); +wrmsr (cmd->addr.msr.reg, msr_content);break ;case SYSTEM_IO_CAPABLE : acpi_os_write_port((acpi_io_address)cmd->addr.io.port,
@@ -252,8 +252,8 @@ static void read_measured_perf_ctrs(void {struct perf_pair *readin = _readin; -rdmsr (MSR_IA32_APERF , readin->aperf.split.lo, readin->aperf.split.hi); -rdmsr (MSR_IA32_MPERF , readin->mperf.split.lo, readin->mperf.split.hi); + readin->aperf.whole =rdmsr (MSR_IA32_APERF ); + readin->mperf.whole =rdmsr (MSR_IA32_MPERF ); }/*
xen/arch/x86/acpi/cpufreq/powernow.c +10 -8
@@ -77,15 +77,15 @@ static void transition_pstate(void *drvc cmd = (struct drv_cmd *) drvcmd;if (cmd->turbo !=CPUFREQ_TURBO_UNSUPPORTED ) { -u32 lo, hi; -rdmsr (MSR_K8_HWCR , lo, hi); +uint64_t msr_content; + msr_content =rdmsr (MSR_K8_HWCR );if (cmd->turbo ==CPUFREQ_TURBO_ENABLED ) - lo &= ~MSR_HWCR_CPBDIS_MASK ; + msr_content &= ~MSR_HWCR_CPBDIS_MASK ;else - lo |=MSR_HWCR_CPBDIS_MASK ; -wrmsr (MSR_K8_HWCR , lo, hi); + msr_content |=MSR_HWCR_CPBDIS_MASK ; +wrmsr (MSR_K8_HWCR , msr_content); } -wrmsr (MSR_PSTATE_CTRL , cmd->val,0 ); +wrmsr (MSR_PSTATE_CTRL , cmd->val); } static int powernow_cpufreq_target(struct cpufreq_policy *policy,
@@ -194,7 +194,8 @@ static int powernow_cpufreq_cpu_init(strstruct powernow_cpufreq_data *data;unsigned int result =0 ;struct processor_performance *perf; -u32 max_hw_pstate, hi =0 , lo =0 ; +u32 max_hw_pstate, hi; +uint64_t msr_content;struct cpuinfo_x86 *c = &cpu_data[policy->cpu]; data = xmalloc(struct powernow_cpufreq_data);
@@ -226,7 +227,8 @@ static int powernow_cpufreq_cpu_init(str result = -ENODEV ; goto err_unreg; } -rdmsr (MSR_PSTATE_CUR_LIMIT , hi, lo); + msr_content =rdmsr (MSR_PSTATE_CUR_LIMIT ); + hi = (uint32_t )(msr_content >>32 ); max_hw_pstate = (hi &HW_PSTATE_MAX_MASK ) >>HW_PSTATE_MAX_SHIFT ;if (perf->control_register.space_id != perf->status_register.space_id) {
xen/arch/x86/acpi/suspend.c +13 -14
@@ -25,12 +25,12 @@ void save_rest_processor_state(void)unlazy_fpu (current);#if defined(CONFIG_X86_64 ) -rdmsrl (MSR_CSTAR , saved_cstar); -rdmsrl (MSR_LSTAR , saved_lstar); + saved_cstar =rdmsr (MSR_CSTAR ); + saved_lstar =rdmsr (MSR_LSTAR );if ( boot_cpu_data.x86_vendor ==X86_VENDOR_INTEL ) { -rdmsrl (MSR_IA32_SYSENTER_ESP , saved_sysenter_esp); -rdmsrl (MSR_IA32_SYSENTER_EIP , saved_sysenter_eip); + saved_sysenter_esp =rdmsr (MSR_IA32_SYSENTER_ESP ); + saved_sysenter_eip =rdmsr (MSR_IA32_SYSENTER_EIP ); }#endif }
@@ -43,24 +43,23 @@ void restore_rest_processor_state(void)#if defined(CONFIG_X86_64 )/* Recover syscall MSRs */ -wrmsrl (MSR_LSTAR , saved_lstar); -wrmsrl (MSR_CSTAR , saved_cstar); -wrmsr (MSR_STAR ,0 , (FLAT_RING3_CS32 <<16 ) | __HYPERVISOR_CS); +wrmsr (MSR_LSTAR , saved_lstar); +wrmsr (MSR_CSTAR , saved_cstar); +wrmsr (MSR_STAR , ( (uint64_t )((FLAT_RING3_CS32 <<16 ) | __HYPERVISOR_CS) <<32 ) );wrmsr (MSR_SYSCALL_MASK ,X86_EFLAGS_VM |X86_EFLAGS_RF |X86_EFLAGS_NT | -X86_EFLAGS_DF |X86_EFLAGS_IF |X86_EFLAGS_TF , -0U ); +X86_EFLAGS_DF |X86_EFLAGS_IF |X86_EFLAGS_TF );if ( boot_cpu_data.x86_vendor ==X86_VENDOR_INTEL ) {/* Recover sysenter MSRs */ -wrmsrl (MSR_IA32_SYSENTER_ESP , saved_sysenter_esp); -wrmsrl (MSR_IA32_SYSENTER_EIP , saved_sysenter_eip); -wrmsr (MSR_IA32_SYSENTER_CS , __HYPERVISOR_CS,0 ); +wrmsr (MSR_IA32_SYSENTER_ESP , saved_sysenter_esp); +wrmsr (MSR_IA32_SYSENTER_EIP , saved_sysenter_eip); +wrmsr (MSR_IA32_SYSENTER_CS , __HYPERVISOR_CS); }#else /* !defined(CONFIG_X86_64) */ if ( supervisor_mode_kernel && cpu_has_sep ) -wrmsr (MSR_IA32_SYSENTER_ESP , &this_cpu (init_tss).esp1,0 ); +wrmsr (MSR_IA32_SYSENTER_ESP ,this_cpu (init_tss).esp1);#endif /* Maybe load the debug registers. */
@@ -79,7 +78,7 @@ void restore_rest_processor_state(void)stts ();if (cpu_has_pat) -wrmsrl (MSR_IA32_CR_PAT , host_pat); +wrmsr (MSR_IA32_CR_PAT , host_pat);mtrr_bp_restore (); }
xen/arch/x86/apic.c +25 -23
98 lines not on this page · raw message
xen/arch/x86/cpu/amd.c +46 -36
163 lines not on this page · raw message
xen/arch/x86/cpu/centaur.c +12 -11
@@ -17,7 +17,7 @@static void __init init_c3 (struct cpuinfo_x86 *c) { -u32 lo, hi; +uint32_t msr_content;/* Test for Centaur Extended Feature Flags presence */ if (cpuid_eax (0xC0000000 ) >=0xC0000001 ) {
@@ -25,17 +25,17 @@ static void __init init_c3(struct cpuinf/* enable ACE unit, if present and disabled */ if ((tmp & (ACE_PRESENT |ACE_ENABLED )) ==ACE_PRESENT ) { -rdmsr (MSR_VIA_FCR , lo, hi); - lo |=ACE_FCR ;/* enable ACE unit */ -wrmsr (MSR_VIA_FCR , lo, hi); + msr_content =rdmsr (MSR_VIA_FCR ); + msr_content |=ACE_FCR ;/* enable ACE unit */ +wrmsr (MSR_VIA_FCR , msr_content);printk (KERN_INFO "CPU: Enabled ACE h/w crypto\n" ); }/* enable RNG unit, if present and disabled */ if ((tmp & (RNG_PRESENT |RNG_ENABLED )) ==RNG_PRESENT ) { -rdmsr (MSR_VIA_RNG , lo, hi); - lo |=RNG_ENABLE ;/* enable RNG unit */ -wrmsr (MSR_VIA_RNG , lo, hi); + msr_content =rdmsr (MSR_VIA_RNG ); + msr_content |=RNG_ENABLE ;/* enable RNG unit */ +wrmsr (MSR_VIA_RNG , msr_content);printk (KERN_INFO "CPU: Enabled h/w RNG\n" ); }
@@ -47,9 +47,9 @@ static void __init init_c3(struct cpuinf/* Cyrix III family needs CX8 & PGE explicity enabled. */ if (c->x86_model >=6 && c->x86_model <=9 ) { -rdmsr (MSR_VIA_FCR , lo, hi); - lo |= (1 <<1 |1 <<7 ); -wrmsr (MSR_VIA_FCR , lo, hi); + msr_content =rdmsr (MSR_VIA_FCR ); + msr_content |= (1 <<1 |1 <<7 ); +wrmsr (MSR_VIA_FCR , msr_content);set_bit (X86_FEATURE_CX8 , c->x86_capability); }
@@ -71,7 +71,8 @@ static void __init init_centaur(struct cinit_c3 (c); } -static unsigned int centaur_size_cache (struct cpuinfo_x86 * c,unsigned int size) +static unsigned int +centaur_size_cache (struct cpuinfo_x86 * c,unsigned int size) {/* VIA C3 CPUs (670-68F) need further shifting. */ if ((c->x86 ==6 ) && ((c->x86_model ==7 ) || (c->x86_model ==8 )))
xen/arch/x86/cpu/common.c +6 -6
@@ -315,10 +315,10 @@ static void __cpuinit squash_the_stupid_ {if (cpu_has (c,X86_FEATURE_PN ) && disable_x86_serial_nr ) {/* Disable processor serial number */ -unsigned long lo,hi; -rdmsr (MSR_IA32_BBL_CR_CTL ,lo,hi); - lo |=0x200000 ; -wrmsr (MSR_IA32_BBL_CR_CTL ,lo,hi); +uint64_t msr_content; + msr_content =rdmsr (MSR_IA32_BBL_CR_CTL ); + msr_content |=0x200000 ; +wrmsr (MSR_IA32_BBL_CR_CTL ,msr_content);printk (KERN_NOTICE "CPU serial number disabled.\n" );clear_bit (X86_FEATURE_PN , c->x86_capability);
@@ -595,7 +595,7 @@ void __cpuinit cpu_init(void)printk ("Initializing CPU#%d\n" , cpu);if (cpu_has_pat) -wrmsrl (MSR_IA32_CR_PAT , host_pat); +wrmsr (MSR_IA32_CR_PAT , host_pat);/* Install correct page table. */ write_ptbase (current);
@@ -614,7 +614,7 @@ void __cpuinit cpu_init(void) t->ss0 = __HYPERVISOR_DS; t->esp0 =get_stack_bottom ();if ( supervisor_mode_kernel && cpu_has_sep ) -wrmsr (MSR_IA32_SYSENTER_ESP , &t->esp1,0 ); +wrmsr (MSR_IA32_SYSENTER_ESP , t->esp1);#elif defined(CONFIG_X86_64 )/* Bottom-of-stack must be 16-byte aligned! */ BUG_ON ((get_stack_bottom () &15 ) !=0 );
xen/arch/x86/cpu/intel.c +11 -14
@@ -46,6 +46,7 @@ struct movsl_mask movsl_mask __read_moststatic void __devinit set_cpuidmask (struct cpuinfo_x86 *c) {unsigned int model = c->x86_model; +uint64_t msr_content;if (!(opt_cpuid_mask_ecx | opt_cpuid_mask_edx | opt_cpuid_mask_ext_ecx | opt_cpuid_mask_ext_edx))
@@ -54,10 +55,10 @@ static void __devinit set_cpuidmask(struif (c->x86 !=0x6 )/* Only family 6 supports this feature */ return ; + msr_content = (opt_cpuid_mask_ecx ? : ~0u ) + | (uint64_t )(opt_cpuid_mask_edx ? : ~0u ) <<32 ;if ((model ==0x1d ) || ((model ==0x17 ) && (c->x86_mask >=4 ))) { -wrmsr (MSR_IA32_CPUID_FEATURE_MASK1 , - opt_cpuid_mask_ecx ? : ~0u , - opt_cpuid_mask_edx ? : ~0u ); +wrmsr (MSR_IA32_CPUID_FEATURE_MASK1 , msr_content); }/* * CPU supports this feature if the processor signature meets the following:
@@ -71,12 +72,8 @@ static void __devinit set_cpuidmask(stru || model == 0x2c || model == 0x2e || model == 0x2f) { -wrmsr (MSR_IA32_CPUID1_FEATURE_MASK , - opt_cpuid_mask_ecx ? : ~0u , - opt_cpuid_mask_edx ? : ~0u ); -wrmsr (MSR_IA32_CPUID80000001_FEATURE_MASK , - opt_cpuid_mask_ext_ecx ? : ~0u , - opt_cpuid_mask_ext_edx ? : ~0u ); + wrmsr(MSR_IA32_CPUID1_FEATURE_MASK, msr_content); + wrmsr(MSR_IA32_CPUID80000001_FEATURE_MASK, msr_content); } else { printk(XENLOG_ERR "Cannot set CPU feature mask on CPU#%d\n",
@@ -100,15 +97,15 @@ void __devinit early_intel_workaround(st*/ static void __devinit Intel_errata_workarounds (struct cpuinfo_x86 *c) { -unsigned long lo, hi; +uint64_t msr_content;if ((c->x86 ==15 ) && (c->x86_model ==1 ) && (c->x86_mask ==1 )) { -rdmsr (MSR_IA32_MISC_ENABLE , lo, hi); -if ((lo & (1 <<9 )) ==0 ) { + msr_content =rdmsr (MSR_IA32_MISC_ENABLE ); +if ((msr_content & (1 <<9 )) ==0 ) {printk (KERN_INFO "CPU: C0 stepping P4 Xeon detected.\n" );printk (KERN_INFO "CPU: Disabling hardware prefetching (Errata 037)\n" ); - lo |= (1 <<9 );/* Disable hw prefetching */ -wrmsr (MSR_IA32_MISC_ENABLE , lo, hi); + msr_content |= (1 <<9 );/* Disable hw prefetching */ +wrmsr (MSR_IA32_MISC_ENABLE , msr_content); } } }
xen/arch/x86/cpu/mcheck/amd_f10.c +3 -3
@@ -74,9 +74,9 @@ amd_f10_handler(struct mc_info *mi, uint mc_ext.mc_msr[1 ].reg =MSR_F10_MC4_MISC2 ; mc_ext.mc_msr[2 ].reg =MSR_F10_MC4_MISC3 ; -mca_rdmsrl (MSR_F10_MC4_MISC1 , mc_ext.mc_msr[0 ].value); -mca_rdmsrl (MSR_F10_MC4_MISC2 , mc_ext.mc_msr[1 ].value); -mca_rdmsrl (MSR_F10_MC4_MISC3 , mc_ext.mc_msr[2 ].value); + mc_ext.mc_msr[0 ].value =mca_rdmsr (MSR_F10_MC4_MISC1 ); + mc_ext.mc_msr[1 ].value =mca_rdmsr (MSR_F10_MC4_MISC2 ); + mc_ext.mc_msr[2 ].value =mca_rdmsr (MSR_F10_MC4_MISC3 );x86_mcinfo_add (mi, &mc_ext);return MCA_EXTINFO_LOCAL ;
xen/arch/x86/cpu/mcheck/amd_k8.c +2 -2
@@ -95,8 +95,8 @@ enum mcheck_type amd_k8_mcheck_init(strumcequirk_amd_apply (quirkflag); }else {/* Enable error reporting of all errors */ -wrmsrl (MSR_IA32_MC0_CTL +4 * i,0xffffffffffffffffULL ); -wrmsrl (MSR_IA32_MC0_STATUS +4 * i,0x0ULL ); +mca_wrmsr (MSR_IA32_MCx_CTL (i),0xffffffffffffffffULL ); +mca_wrmsr (MSR_IA32_MCx_STATUS (i),0x0ULL );break ; } }
xen/arch/x86/cpu/mcheck/amd_nonfatal.c +4 -4
@@ -144,7 +144,7 @@ static void mce_amd_work_fn(void *data)uint64_t value;uint32_t counter; -mca_rdmsrl (MSR_IA32_MC4_MISC , value); + value =mca_rdmsr (MSR_IA32_MC4_MISC );/* Only the error counter field is of interest * Bit field is described in AMD K8 BKDG chapter 6.4.5.5 */
@@ -169,7 +169,7 @@ static void mce_amd_work_fn(void *data) value &= ~(0x60FFF00000000ULL );/* Counter enable */ value |= (1ULL <<51 ); -mca_wrmsrl (MSR_IA32_MC4_MISC , value); +mca_wrmsr (MSR_IA32_MC4_MISC , value);wmb (); } }
@@ -212,7 +212,7 @@ void amd_nonfatal_mcheck_init(struct cpu/* hw threshold registers present */ hw_threshold =1 ; -rdmsrl (MSR_IA32_MC4_MISC , value); + value =mca_rdmsr (MSR_IA32_MC4_MISC );if (value & (1ULL <<61 )) {/* Locked bit */ /* Locked by BIOS. Not available for use */
@@ -233,7 +233,7 @@ void amd_nonfatal_mcheck_init(struct cpu value &= ~(0x60FFF00000000ULL );/* Counter enable */ value |= (1ULL <<51 ); -wrmsrl (MSR_IA32_MC4_MISC , value); +mca_wrmsr (MSR_IA32_MC4_MISC , value);/* serialize */ wmb ();printk (XENLOG_INFO "MCA: Use hw thresholding to adjust polling frequency\n" );
xen/arch/x86/cpu/mcheck/k7.c +29 -29
98 lines not on this page · raw message
xen/arch/x86/cpu/mcheck/mce.c +26 -28
170 lines not on this page · raw message
xen/arch/x86/cpu/mcheck/mce.h +9 -6
@@ -83,15 +83,18 @@ extern struct intpose_ent *intpose_looku uint64_t *);extern void intpose_inval (unsigned int ,uint64_t ); -#define mca_rdmsrl (msr, var) do { \ - if (intpose_lookup(smp_processor_id(), msr, &var) == NULL) \ - rdmsrl(msr, var); \ -} while (0) +static inline uint64_t mca_rdmsr (unsigned int msr) +{ +uint64_t val; +if (intpose_lookup (smp_processor_id (), msr, &val) ==NULL ) +return rdmsr (msr); +return val; +}/* Write an MSR, invalidating any interposed value */ -#define mca_wrmsrl (msr, val) do { \ +#define mca_wrmsr (msr, val) do { \ intpose_inval(smp_processor_id(), msr); \ - wrmsrl(msr, val); \ + wrmsr(msr, val); \ } while (0)
xen/arch/x86/cpu/mcheck/mce_amd_quirks.c +5 -4
@@ -17,8 +17,9 @@* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <asm-x86/msr.h> -#include <asm-x86/processor.h> +#include <xen/types.h> +#include <asm/msr.h> +#include <asm/processor.h> #include "mce_quirks.h"
@@ -64,8 +65,8 @@ int mcequirk_amd_apply(enum mcequirk_amd* TBL walk error reporting, which trips off incorrectly * with AGP GART & 3ware & Cerberus. */ -wrmsrl (MSR_IA32_MC4_CTL , ~(1ULL <<10 )); -wrmsrl (MSR_IA32_MC4_STATUS ,0ULL ); +wrmsr (MSR_IA32_MC4_CTL , ~(1ULL <<10 )); +wrmsr (MSR_IA32_MC4_STATUS ,0ULL );break ; }
xen/arch/x86/cpu/mcheck/mce_intel.c +34 -33
160 lines not on this page · raw message
xen/arch/x86/cpu/mtrr/amd.c +14 -11
@@ -9,20 +9,20 @@ static void amd_get_mtrr(unsigned int reg, unsigned long *base, unsigned long *size, mtrr_type * type) { - unsigned long low, high; + uint64_t msr_content; -rdmsr (MSR_K6_UWCCR , low, high); + msr_content =rdmsr (MSR_K6_UWCCR );/* Upper dword is region 1, lower is region 0 */ if (reg ==1 ) - low = high; + msr_content = (uint32_t )(msr_content >>32 );/* The base masks off on the right alignment */ - *base = (low &0xFFFE0000 ) >>PAGE_SHIFT ; + *base = (msr_content &0xFFFE0000 ) >>PAGE_SHIFT ; *type =0 ; -if (low &1 ) +if (msr_content &1 ) *type =MTRR_TYPE_UNCACHABLE ; -if (low &2 ) +if (msr_content &2 ) *type =MTRR_TYPE_WRCOMB ; -if (!(low &3 )) { +if (!(msr_content &3 )) { *size =0 ;return ; }
@@ -41,8 +41,8 @@ amd_get_mtrr(unsigned int reg, unsigned* +1 000 0000 0000 0100 * *128K ... */ - low = (~low) &0x1FFFC ; - *size = (low +4 ) << (15 -PAGE_SHIFT ); + msr_content = (~msr_content) &0x1FFFC ; + *size = (msr_content +4 ) << (15 -PAGE_SHIFT );return ; }
@@ -59,11 +59,14 @@ static void amd_set_mtrr(unsigned int re*/ {u32 regs[2 ]; +uint64_t msr_content;/* * Low is MTRR0 , High MTRR 1 */ -rdmsr (MSR_K6_UWCCR , regs[0 ], regs[1 ]); + msr_content =rdmsr (MSR_K6_UWCCR ); + regs[0 ] = (uint32_t )msr_content; + regs[1 ] = (uint32_t )(msr_content >>32 );/* * Blank to disable */
@@ -85,7 +88,7 @@ static void amd_set_mtrr(unsigned int re* disable local interrupts, write back the cache, set the mtrr */ wbinvd (); -wrmsr (MSR_K6_UWCCR , regs[0 ], regs[1 ]); +wrmsr (MSR_K6_UWCCR , regs[0 ] | (uint64_t )(regs[1 ]) <<32 ); }static int amd_validate_add_page (unsigned long base,unsigned long size,unsigned int type)
xen/arch/x86/cpu/mtrr/generic.c +85 -57
276 lines not on this page · raw message
xen/arch/x86/cpu/mtrr/main.c +2 -2
@@ -101,10 +101,10 @@ static int have_wrcomb(void)/* This function returns the number of variable MTRRs */ static void __init set_num_var_ranges (void ) { -unsigned long config =0 , dummy; +unsigned long config =0 ;if (use_intel ()) { -rdmsr (MTRRcap_MSR, config, dummy); + config =rdmsr (MTRRcap_MSR); }else if (is_cpu (AMD )) config =2 ;else if (is_cpu (CYRIX ) ||is_cpu (CENTAUR ))
xen/arch/x86/cpu/mtrr/mtrr.h +2 -3
@@ -60,8 +60,7 @@ extern int positive_have_wrcomb(void);struct set_mtrr_context {unsigned long flags;unsigned long cr4val; -u32 deftype_lo; -u32 deftype_hi; +uint64_t deftype;u32 ccr3; };
@@ -83,5 +82,5 @@ extern unsigned int num_var_ranges;void mtrr_state_warn (void );const char *mtrr_attrib_to_str (int x); -void mtrr_wrmsr (unsigned ,unsigned ,unsigned ); +void mtrr_wrmsr (unsigned int msr,uint64_t msr_content);
xen/arch/x86/cpu/mtrr/state.c +3 -4
@@ -31,7 +31,7 @@ void set_mtrr_prepare_save(struct set_mtif (use_intel ())/* Save MTRR state */ -rdmsr (MTRRdefType_MSR, ctxt->deftype_lo, ctxt->deftype_hi); + ctxt->deftype =rdmsr (MTRRdefType_MSR);else /* Cyrix ARRs - everything else were excluded at the top */ ctxt->ccr3 =getCx86 (CX86_CCR3 );
@@ -42,8 +42,7 @@ void set_mtrr_cache_disable(struct set_m {if (use_intel ())/* Disable MTRRs, and set the default type to uncached */ -mtrr_wrmsr (MTRRdefType_MSR, ctxt->deftype_lo &0xf300UL , - ctxt->deftype_hi); +mtrr_wrmsr (MTRRdefType_MSR, ctxt->deftype &0xf300UL );else if (is_cpu (CYRIX ))/* Cyrix ARRs - everything else were excluded at the top */ setCx86 (CX86_CCR3 , (ctxt->ccr3 &0x0f ) |0x10 );
@@ -60,7 +59,7 @@ void set_mtrr_done(struct set_mtrr_conte/* Restore MTRRdefType */ if (use_intel ())/* Intel (P6) standard MTRRs */ -mtrr_wrmsr (MTRRdefType_MSR, ctxt->deftype_lo, ctxt->deftype_hi); +mtrr_wrmsr (MTRRdefType_MSR, ctxt->deftype);else /* Cyrix ARRs - everything else was excluded at the top */ setCx86 (CX86_CCR3 , ctxt->ccr3);
xen/arch/x86/cpu/transmeta.c +5 -4
@@ -7,7 +7,8 @@static void __init init_transmeta (struct cpuinfo_x86 *c) { -unsigned int cap_mask, uk, max, dummy; +uint64_t cap_mask; +unsigned int max, dummy;unsigned int cms_rev1, cms_rev2;unsigned int cpu_rev, cpu_freq, cpu_flags, new_cpu_rev;char cpu_info[65 ];
@@ -68,10 +69,10 @@ static void __init init_transmeta(struct }/* Unhide possibly hidden capability flags */ -rdmsr (0x80860004 , cap_mask, uk); -wrmsr (0x80860004 , ~0 , uk); + cap_mask =rdmsr (0x80860004 ); +wrmsr (0x80860004 , ~0 ); c->x86_capability[0 ] =cpuid_edx (0x00000001 ); -wrmsr (0x80860004 , cap_mask, uk); +wrmsr (0x80860004 , cap_mask);/* If we can run i686 user-space code, call us an i686 */ #define USER686 (X86_FEATURE_TSC|X86_FEATURE_CX8|X86_FEATURE_CMOV)
xen/arch/x86/domain.c +3 -9
@@ -1089,21 +1089,15 @@ static void load_segments(struct vcpu *n {/* This can only be non-zero if selector is NULL. */ if ( nctxt->fs_base ) -wrmsr (MSR_FS_BASE , - nctxt->fs_base, - nctxt->fs_base>>32 ); +wrmsr (MSR_FS_BASE , nctxt->fs_base);/* Most kernels have non-zero GS base, so don't bother testing. */ /* (This is also a serialising instruction, avoiding AMD erratum #88.) */ -wrmsr (MSR_SHADOW_GS_BASE , - nctxt->gs_base_kernel, - nctxt->gs_base_kernel>>32 ); +wrmsr (MSR_SHADOW_GS_BASE , nctxt->gs_base_kernel);/* This can only be non-zero if selector is NULL. */ if ( nctxt->gs_base_user ) -wrmsr (MSR_GS_BASE , - nctxt->gs_base_user, - nctxt->gs_base_user>>32 ); +wrmsr (MSR_GS_BASE , nctxt->gs_base_user);/* If in kernel mode then switch the GS bases around. */ if ( (n->arch.flags & TF_kernel_mode) )
xen/arch/x86/e820.c +4 -4
@@ -457,8 +457,8 @@ static uint64_t mtrr_top_of_ram(void) } addr_mask = ((1ull << phys_bits) -1 ) & ~((1ull <<12 ) -1 ); -rdmsrl (MSR_MTRRcap, mtrr_cap); -rdmsrl (MSR_MTRRdefType, mtrr_def); + mtrr_cap =rdmsr (MSR_MTRRcap); + mtrr_def =rdmsr (MSR_MTRRdefType);if ( e820_verbose )printk (" MTRR cap: %" PRIx64" type: %" PRIx64"\n" , mtrr_cap, mtrr_def);
@@ -474,8 +474,8 @@ static uint64_t mtrr_top_of_ram(void) top =0 ;for ( i =0 ; i < (uint8_t )mtrr_cap; i++ ) { -rdmsrl (MSR_MTRRphysBase (i), base); -rdmsrl (MSR_MTRRphysMask (i), mask); + base =rdmsr (MSR_MTRRphysBase (i)); + mask =rdmsr (MSR_MTRRphysMask (i) );if ( e820_verbose ) printk(" MTRR[%d]: base %"PRIx64" mask %"PRIx64"\n",
xen/arch/x86/genapic/x2apic.c +10 -4
@@ -90,6 +90,7 @@ void send_IPI_mask_x2apic_phys(const cpu {unsigned int cpu, cfg;unsigned long flags; +uint64_t msr_content;/* * Ensure that any synchronisation data written in program order by this
@@ -107,8 +108,10 @@ void send_IPI_mask_x2apic_phys(const cpu cfg =APIC_DM_FIXED |0 /* no shorthand */ |APIC_DEST_PHYSICAL | vector; for_each_cpu_mask ( cpu, *cpumask ) -if ( cpu !=smp_processor_id () ) -apic_wrmsr (APIC_ICR , cfg,cpu_physical_id (cpu)); +if ( cpu !=smp_processor_id () ) { + msr_content = cfg | ((uint64_t )(cpu_physical_id (cpu)) <<32 ); +apic_wrmsr (APIC_ICR , msr_content); + }local_irq_restore (flags); }
@@ -117,6 +120,7 @@ void send_IPI_mask_x2apic_cluster(const {unsigned int cpu, cfg;unsigned long flags; +uint64_t msr_content;mb ();/* see the comment in send_IPI_mask_x2apic_phys() */
@@ -124,8 +128,10 @@ void send_IPI_mask_x2apic_cluster(const cfg =APIC_DM_FIXED |0 /* no shorthand */ |APIC_DEST_LOGICAL | vector; for_each_cpu_mask ( cpu, *cpumask ) -if ( cpu !=smp_processor_id () ) -apic_wrmsr (APIC_ICR , cfg, cpu_2_logical_apicid[cpu]); +if ( cpu !=smp_processor_id () ) { + msr_content = cfg | ((uint64_t )(cpu_2_logical_apicid[cpu]) <<32 ); +apic_wrmsr (APIC_ICR , msr_content); + }local_irq_restore (flags); }
xen/arch/x86/hvm/emulate.c +2 -17
@@ -825,16 +825,7 @@ static int hvmemul_read_msr(uint64_t *val, struct x86_emulate_ctxt *ctxt) { - struct cpu_user_regs _regs; -int rc; - - _regs.ecx = (uint32_t )reg; - -if ( (rc =hvm_msr_read_intercept (&_regs)) !=X86EMUL_OKAY ) -return rc; - - *val = ((uint64_t )(uint32_t )_regs.edx <<32 ) | (uint32_t )_regs.eax; -return X86EMUL_OKAY ; + return hvm_msr_read_intercept(reg, val); } static int hvmemul_write_msr(
@@ -842,13 +833,7 @@ static int hvmemul_write_msr(uint64_t val, struct x86_emulate_ctxt *ctxt) { - struct cpu_user_regs _regs; - - _regs.edx = (uint32_t )(val >>32 ); - _regs.eax = (uint32_t )val; - _regs.ecx = (uint32_t )reg; - -return hvm_msr_write_intercept (&_regs); + return hvm_msr_write_intercept(reg, val); } static int hvmemul_wbinvd(
xen/arch/x86/hvm/hvm.c +16 -20
@@ -2010,9 +2010,8 @@ void hvm_rdtsc_intercept(struct cpu_user regs->edx = (uint32_t )(tsc >>32 ); } -int hvm_msr_read_intercept (struct cpu_user_regs *regs) +int hvm_msr_read_intercept (unsigned int msr,uint64_t *msr_val) { -uint32_t ecx = regs->ecx;uint64_t msr_content =0 ;struct vcpu *v = current;uint64_t *var_range_base, *fixed_range_base;
@@ -2026,7 +2025,7 @@ int hvm_msr_read_intercept(struct cpu_ushvm_cpuid (1 , &cpuid[0 ], &cpuid[1 ], &cpuid[2 ], &cpuid[3 ]); mtrr = !!(cpuid[3 ] &bitmaskof (X86_FEATURE_MTRR )); -switch ( ecx ) +switch ( msr ) {case MSR_IA32_TSC : msr_content =hvm_get_guest_tsc (v);
@@ -2064,19 +2063,19 @@ int hvm_msr_read_intercept(struct cpu_uscase MSR_MTRRfix16K_A0000:if ( !mtrr ) goto gp_fault; - index = regs->ecx - MSR_MTRRfix16K_80000; + index = msr - MSR_MTRRfix16K_80000; msr_content = fixed_range_base[index +1 ];break ; case MSR_MTRRfix4K_C0000...MSR_MTRRfix4K_F8000:if ( !mtrr ) goto gp_fault; - index = regs->ecx - MSR_MTRRfix4K_C0000; + index = msr - MSR_MTRRfix4K_C0000; msr_content = fixed_range_base[index +3 ];break ; case MSR_IA32_MTRR_PHYSBASE0...MSR_IA32_MTRR_PHYSMASK7:if ( !mtrr ) goto gp_fault; - index = regs->ecx -MSR_IA32_MTRR_PHYSBASE0 ; + index = msr -MSR_IA32_MTRR_PHYSBASE0 ; msr_content = var_range_base[index];break ;
@@ -2091,18 +2090,17 @@ int hvm_msr_read_intercept(struct cpu_usbreak ;default : - ret =vmce_rdmsr (ecx, &msr_content); + ret =vmce_rdmsr (msr, &msr_content);if ( ret <0 ) goto gp_fault;else if ( ret )break ;/* ret == 0, This is not an MCE MSR, see other MSRs */ else if (!ret) -return hvm_funcs.msr_read_intercept (regs); +return hvm_funcs.msr_read_intercept (msr, &msr_content); } - regs->eax = (uint32_t )msr_content; - regs->edx = (uint32_t )(msr_content >>32 ); + *msr_val = msr_content;return X86EMUL_OKAY ; gp_fault:
@@ -2110,10 +2108,8 @@ gp_fault:return X86EMUL_EXCEPTION ; } -int hvm_msr_write_intercept (struct cpu_user_regs *regs) +int hvm_msr_write_intercept (unsigned int msr,uint64_t msr_content) { -uint32_t ecx = regs->ecx; -uint64_t msr_content = (uint32_t )regs->eax | ((uint64_t )regs->edx <<32 );struct vcpu *v = current;int index, mtrr;uint32_t cpuid[4 ];
@@ -2122,7 +2118,7 @@ int hvm_msr_write_intercept(struct cpu_uhvm_cpuid (1 , &cpuid[0 ], &cpuid[1 ], &cpuid[2 ], &cpuid[3 ]); mtrr = !!(cpuid[3 ] &bitmaskof (X86_FEATURE_MTRR )); -switch ( ecx ) +switch ( msr ) {case MSR_IA32_TSC :hvm_set_guest_tsc (v, msr_content);
@@ -2132,7 +2128,7 @@ int hvm_msr_write_intercept(struct cpu_u v->arch.hvm_vcpu.msr_tsc_aux = (uint32_t )msr_content;if ( cpu_has_rdtscp && (v->domain->arch.tsc_mode !=TSC_MODE_PVRDTSCP ) ) -wrmsrl (MSR_TSC_AUX , (uint32_t )msr_content); +wrmsr (MSR_TSC_AUX , (uint32_t )msr_content);break ;case MSR_IA32_APICBASE :
@@ -2164,7 +2160,7 @@ int hvm_msr_write_intercept(struct cpu_ucase MSR_MTRRfix16K_A0000:if ( !mtrr ) goto gp_fault; - index = regs->ecx - MSR_MTRRfix16K_80000 +1 ; + index = msr - MSR_MTRRfix16K_80000 +1 ;if ( !mtrr_fix_range_msr_set (&v->arch.hvm_vcpu.mtrr, index, msr_content) ) goto gp_fault;
@@ -2172,7 +2168,7 @@ int hvm_msr_write_intercept(struct cpu_u case MSR_MTRRfix4K_C0000...MSR_MTRRfix4K_F8000:if ( !mtrr ) goto gp_fault; - index = regs->ecx - MSR_MTRRfix4K_C0000 +3 ; + index = msr - MSR_MTRRfix4K_C0000 +3 ;if ( !mtrr_fix_range_msr_set (&v->arch.hvm_vcpu.mtrr, index, msr_content) ) goto gp_fault;
@@ -2181,7 +2177,7 @@ int hvm_msr_write_intercept(struct cpu_uif ( !mtrr ) goto gp_fault;if ( !mtrr_var_range_msr_set (&v->arch.hvm_vcpu.mtrr, - regs->ecx, msr_content) ) + msr, msr_content) ) goto gp_fault;break ;
@@ -2190,13 +2186,13 @@ int hvm_msr_write_intercept(struct cpu_ubreak ;default : - ret =vmce_wrmsr (ecx, msr_content); + ret =vmce_wrmsr (msr, msr_content);if ( ret <0 ) goto gp_fault;else if ( ret )break ;else if (!ret) -return hvm_funcs.msr_write_intercept (regs); +return hvm_funcs.msr_write_intercept (msr, msr_content); }return X86EMUL_OKAY ;
xen/arch/x86/hvm/svm/svm.c +46 -55
229 lines not on this page · raw message
xen/arch/x86/hvm/svm/vpmu.c +15 -23
@@ -110,11 +110,11 @@ static inline void context_restore(strucstruct amd_vpmu_context *ctxt = vpmu->context;for ( i =0 ; i <NUM_COUNTERS ; i++ ) -wrmsrl (AMD_F10H_CTRLS [i], ctxt->ctrls[i]); +wrmsr (AMD_F10H_CTRLS [i], ctxt->ctrls[i]);for ( i =0 ; i <NUM_COUNTERS ; i++ ) { -wrmsrl (AMD_F10H_COUNTERS [i], ctxt->counters[i]); +wrmsr (AMD_F10H_COUNTERS [i], ctxt->counters[i]);/* Force an interrupt to allow guest reset the counter, if the value is positive */
@@ -147,10 +147,10 @@ static inline void context_save(struct vstruct amd_vpmu_context *ctxt = vpmu->context;for ( i =0 ; i <NUM_COUNTERS ; i++ ) -rdmsrl (AMD_F10H_COUNTERS [i], ctxt->counters[i]); + ctxt->counters[i] =rdmsr (AMD_F10H_COUNTERS [i]);for ( i =0 ; i <NUM_COUNTERS ; i++ ) -rdmsrl (AMD_F10H_CTRLS [i], ctxt->ctrls[i]); + ctxt->ctrls[i] =rdmsr (AMD_F10H_CTRLS [i]); }static void amd_vpmu_save (struct vcpu *v)
@@ -167,42 +167,38 @@ static void amd_vpmu_save(struct vcpu *vapic_write (APIC_LVTPC , ctx->hw_lapic_lvtpc |APIC_LVT_MASKED ); } -static void context_update (struct cpu_user_regs *regs,u64 msr_content) +static void context_update (unsigned int msr,u64 msr_content) {int i; -u32 addr = regs->ecx;struct vcpu *v = current;struct vpmu_struct *vpmu =vcpu_vpmu (v);struct amd_vpmu_context *ctxt = vpmu->context;for ( i =0 ; i <NUM_COUNTERS ; i++ ) -if ( addr ==AMD_F10H_COUNTERS [i] ) +if ( msr ==AMD_F10H_COUNTERS [i] ) ctxt->counters[i] = msr_content;for ( i =0 ; i <NUM_COUNTERS ; i++ ) -if ( addr ==AMD_F10H_CTRLS [i] ) +if ( msr ==AMD_F10H_CTRLS [i] ) ctxt->ctrls[i] = msr_content; ctxt->hw_lapic_lvtpc =apic_read (APIC_LVTPC ); } -static int amd_vpmu_do_wrmsr (struct cpu_user_regs *regs) +static int amd_vpmu_do_wrmsr (unsigned int msr,uint64_t msr_content) { -u64 msr_content =0 ;struct vcpu *v = current;struct vpmu_struct *vpmu =vcpu_vpmu (v); - msr_content = (u32 )regs->eax | ((u64 )regs->edx <<32 ); -/* For all counters, enable guest only mode for HVM guest */ -if ( (get_pmu_reg_type (regs->ecx) ==MSR_TYPE_CTRL ) && +if ( (get_pmu_reg_type (msr) ==MSR_TYPE_CTRL ) && !(is_guest_mode (msr_content)) ) {set_guest_mode (msr_content); }/* check if the first counter is enabled */ -if ( (get_pmu_reg_type (regs->ecx) ==MSR_TYPE_CTRL ) && +if ( (get_pmu_reg_type (msr) ==MSR_TYPE_CTRL ) &&is_pmu_enabled (msr_content) && !(vpmu->flags &VPMU_RUNNING ) ) {if ( !acquire_pmu_ownership (PMU_OWNER_HVM ) )
@@ -212,7 +208,7 @@ static int amd_vpmu_do_wrmsr(struct cpu_ }/* stop saving & restore if guest stops first counter */ -if ( (get_pmu_reg_type (regs->ecx) ==MSR_TYPE_CTRL ) && +if ( (get_pmu_reg_type (msr) ==MSR_TYPE_CTRL ) && (is_pmu_enabled (msr_content) ==0 ) && (vpmu->flags &VPMU_RUNNING ) ) {apic_write (APIC_LVTPC ,PMU_APIC_VECTOR |APIC_LVT_MASKED );
@@ -221,20 +217,16 @@ static int amd_vpmu_do_wrmsr(struct cpu_ }/* Update vpmu context immediately */ -context_update (regs, msr_content); +context_update (msr, msr_content);/* Write to hw counters */ -wrmsrl (regs->ecx, msr_content); +wrmsr (msr, msr_content);return 1 ; } -static int amd_vpmu_do_rdmsr (struct cpu_user_regs *regs) +static int amd_vpmu_do_rdmsr (unsigned int msr,uint64_t *msr_val) { -u64 msr_content =0 ; - -rdmsrl (regs->ecx, msr_content); - regs->eax = msr_content &0xFFFFFFFF ; - regs->edx = msr_content >>32 ; + *msr_val =rdmsr (msr);return 1 ; }
xen/arch/x86/hvm/vmx/vmcs.c +29 -20
135 lines not on this page · raw message
xen/arch/x86/hvm/vmx/vmx.c +84 -87
361 lines not on this page · raw message
xen/arch/x86/hvm/vmx/vpmu_core2.c +22 -25
142 lines not on this page · raw message
xen/arch/x86/hvm/vpmu.c +4 -4
@@ -36,21 +36,21 @@static int __read_mostly opt_vpmu_enabled;boolean_param ("vpmu" , opt_vpmu_enabled); -int vpmu_do_wrmsr (struct cpu_user_regs *regs) +int vpmu_do_wrmsr (unsigned int msr,uint64_t msr_content) {struct vpmu_struct *vpmu =vcpu_vpmu (current);if ( vpmu->arch_vpmu_ops ) -return vpmu->arch_vpmu_ops->do_wrmsr (regs); +return vpmu->arch_vpmu_ops->do_wrmsr (msr, msr_content);return 0 ; } -int vpmu_do_rdmsr (struct cpu_user_regs *regs) +int vpmu_do_rdmsr (unsigned int msr,uint64_t *msr_val) {struct vpmu_struct *vpmu =vcpu_vpmu (current);if ( vpmu->arch_vpmu_ops ) -return vpmu->arch_vpmu_ops->do_rdmsr (regs); +return vpmu->arch_vpmu_ops->do_rdmsr (msr, msr_val);return 0 ; }
xen/arch/x86/microcode_amd.c +4 -5
@@ -47,7 +47,6 @@ struct equiv_cpu_entry *equiv_cpu_table;static int collect_cpu_info (int cpu,struct cpu_signature *csig) {struct cpuinfo_x86 *c = &cpu_data[cpu]; -uint32_t dummy;memset (csig,0 ,sizeof (*csig));
@@ -58,7 +57,7 @@ static int collect_cpu_info(int cpu, strreturn -EINVAL ; } -rdmsr (MSR_AMD_PATCHLEVEL , csig->rev, dummy); + csig->rev =rdmsr (MSR_AMD_PATCHLEVEL );printk (KERN_INFO "microcode: collect_cpu_info: patch_id=0x%x\n" , csig->rev);
@@ -126,7 +125,7 @@ static int apply_microcode(int cpu) {unsigned long flags;struct ucode_cpu_info *uci = &per_cpu (ucode_cpu_info, cpu); -uint32_t rev, dummy; +uint32_t rev;struct microcode_amd *mc_amd = uci->mc.mc_amd;/* We should bind the task to the CPU */
@@ -137,10 +136,10 @@ static int apply_microcode(int cpu)spin_lock_irqsave (µcode_update_lock, flags); -wrmsrl (MSR_AMD_PATCHLOADER , (unsigned long )&mc_amd->hdr.data_code); +wrmsr (MSR_AMD_PATCHLOADER , (unsigned long )&mc_amd->hdr.data_code);/* get patch id after patching */ -rdmsr (MSR_AMD_PATCHLEVEL , rev, dummy); + rev =rdmsr (MSR_AMD_PATCHLEVEL );spin_unlock_irqrestore (µcode_update_lock, flags);
xen/arch/x86/microcode_intel.c +11 -8
@@ -62,6 +62,7 @@ static DEFINE_SPINLOCK(microcode_update_static int collect_cpu_info (int cpu_num,struct cpu_signature *csig) {struct cpuinfo_x86 *c = &cpu_data[cpu_num]; +uint64_t msr_content;unsigned int val[2 ];BUG_ON (cpu_num !=smp_processor_id ());
@@ -81,15 +82,17 @@ static int collect_cpu_info(int cpu_num,if ( (c->x86_model >=5 ) || (c->x86 >6 ) ) {/* get processor flags from MSR 0x17 */ -rdmsr (MSR_IA32_PLATFORM_ID , val[0 ], val[1 ]); + msr_content =rdmsr (MSR_IA32_PLATFORM_ID ); + val[1 ] = msr_content >>32 ; csig->pf =1 << ((val[1 ] >>18 ) &7 ); } -wrmsr (MSR_IA32_UCODE_REV ,0 ,0 ); +wrmsr (MSR_IA32_UCODE_REV ,0 );/* see notes above for revision 1.07. Apparent chip bug */ sync_core ();/* get the current revision from MSR 0x8B */ -rdmsr (MSR_IA32_UCODE_REV , val[0 ], csig->rev); + msr_content =rdmsr (MSR_IA32_UCODE_REV ); + csig->rev = (uint32_t )msr_content;pr_debug ("microcode: collect_cpu_info : sig=0x%x, pf=0x%x, rev=0x%x\n" , csig->sig, csig->pf, csig->rev);
@@ -250,6 +253,7 @@ static int apply_microcode(int cpu) {unsigned long flags;unsigned int val[2 ]; +uint64_t msr_content;int cpu_num =raw_smp_processor_id ();struct ucode_cpu_info *uci = &per_cpu (ucode_cpu_info, cpu_num);
@@ -263,16 +267,15 @@ static int apply_microcode(int cpu)spin_lock_irqsave (µcode_update_lock, flags);/* write microcode via MSR 0x79 */ -wrmsr (MSR_IA32_UCODE_WRITE , - (unsigned long ) uci->mc.mc_intel->bits, - (unsigned long ) uci->mc.mc_intel->bits >>16 >>16 ); -wrmsr (MSR_IA32_UCODE_REV ,0 ,0 ); +wrmsr (MSR_IA32_UCODE_WRITE , (unsigned long ) uci->mc.mc_intel->bits); +wrmsr (MSR_IA32_UCODE_REV ,0 );/* see notes above for revision 1.07. Apparent chip bug */ sync_core ();/* get the current revision from MSR 0x8B */ -rdmsr (MSR_IA32_UCODE_REV , val[0 ], val[1 ]); + msr_content =rdmsr (MSR_IA32_UCODE_REV ); + val[1 ] = msr_content >>32 ;spin_unlock_irqrestore (µcode_update_lock, flags);if ( val[1 ] != uci->mc.mc_intel->hdr.rev )
xen/arch/x86/nmi.c +16 -16
@@ -147,7 +147,7 @@ static void disable_lapic_nmi_watchdog(vreturn ;switch (boot_cpu_data.x86_vendor) {case X86_VENDOR_AMD : -wrmsr (MSR_K7_EVNTSEL0 ,0 ,0 ); +wrmsr (MSR_K7_EVNTSEL0 ,0 );break ;case X86_VENDOR_INTEL :switch (boot_cpu_data.x86) {
@@ -155,14 +155,14 @@ static void disable_lapic_nmi_watchdog(vif (boot_cpu_data.x86_model >0xd )break ; -wrmsr (MSR_P6_EVNTSEL0 ,0 ,0 ); +wrmsr (MSR_P6_EVNTSEL0 ,0 );break ;case 15 :if (boot_cpu_data.x86_model >0x4 )break ; -wrmsr (MSR_P4_IQ_CCCR0 ,0 ,0 ); -wrmsr (MSR_P4_CRU_ESCR0 ,0 ,0 ); +wrmsr (MSR_P4_IQ_CCCR0 ,0 ); +wrmsr (MSR_P4_CRU_ESCR0 ,0 );break ; }break ;
@@ -219,7 +219,7 @@ static void __pminit clear_msr_range(unsunsigned int i;for (i =0 ; i < n; i++) -wrmsr (base+i,0 ,0 ); +wrmsr (base+i,0 ); }static inline void write_watchdog_counter (const char *descr)
@@ -229,7 +229,7 @@ static inline void write_watchdog_countedo_div (count, nmi_hz);if (descr)Dprintk ("setting %s to -0x%" PRIx64"\n" , descr, count); -wrmsrl (nmi_perfctr_msr,0 - count); +wrmsr (nmi_perfctr_msr,0 - count); } static void __pminit setup_k7_watchdog(void)
@@ -246,11 +246,11 @@ static void __pminit setup_k7_watchdog(v | K7_EVNTSEL_USR |K7_NMI_EVENT ; -wrmsr (MSR_K7_EVNTSEL0 , evntsel,0 ); +wrmsr (MSR_K7_EVNTSEL0 , evntsel);write_watchdog_counter ("K7_PERFCTR0" );apic_write (APIC_LVTPC ,APIC_DM_NMI ); evntsel |=K7_EVNTSEL_ENABLE ; -wrmsr (MSR_K7_EVNTSEL0 , evntsel,0 ); +wrmsr (MSR_K7_EVNTSEL0 , evntsel); } static void __pminit setup_p6_watchdog(unsigned counter)
@@ -267,18 +267,18 @@ static void __pminit setup_p6_watchdog(u | P6_EVNTSEL_USR | counter; -wrmsr (MSR_P6_EVNTSEL0 , evntsel,0 ); +wrmsr (MSR_P6_EVNTSEL0 , evntsel);write_watchdog_counter ("P6_PERFCTR0" );apic_write (APIC_LVTPC ,APIC_DM_NMI ); evntsel |=P6_EVNTSEL0_ENABLE ; -wrmsr (MSR_P6_EVNTSEL0 , evntsel,0 ); +wrmsr (MSR_P6_EVNTSEL0 , evntsel); } static int __pminit setup_p4_watchdog(void) { -unsigned int misc_enable, dummy; +uint64_t misc_enable; -rdmsr (MSR_IA32_MISC_ENABLE , misc_enable, dummy); + misc_enable =rdmsr (MSR_IA32_MISC_ENABLE );if (!(misc_enable &MSR_IA32_MISC_ENABLE_PERF_AVAIL ))return 0 ;
@@ -304,11 +304,11 @@ static int __pminit setup_p4_watchdog(voclear_msr_range (MSR_P4_BPU_CCCR0 ,18 );clear_msr_range (MSR_P4_BPU_PERFCTR0 ,18 ); -wrmsr (MSR_P4_CRU_ESCR0 ,P4_NMI_CRU_ESCR0 ,0 ); -wrmsr (MSR_P4_IQ_CCCR0 ,P4_NMI_IQ_CCCR0 & ~P4_CCCR_ENABLE ,0 ); +wrmsr (MSR_P4_CRU_ESCR0 ,P4_NMI_CRU_ESCR0 ); +wrmsr (MSR_P4_IQ_CCCR0 ,P4_NMI_IQ_CCCR0 & ~P4_CCCR_ENABLE );write_watchdog_counter ("P4_IQ_COUNTER0" );apic_write (APIC_LVTPC ,APIC_DM_NMI ); -wrmsr (MSR_P4_IQ_CCCR0 , nmi_p4_cccr_val,0 ); +wrmsr (MSR_P4_IQ_CCCR0 , nmi_p4_cccr_val);return 1 ; }
@@ -442,7 +442,7 @@ void nmi_watchdog_tick(struct cpu_user_r* - LVTPC is masked on interrupt and must be * unmasked by the LVTPC handler. */ -wrmsr (MSR_P4_IQ_CCCR0 , nmi_p4_cccr_val,0 ); +wrmsr (MSR_P4_IQ_CCCR0 , nmi_p4_cccr_val);apic_write (APIC_LVTPC ,APIC_DM_NMI ); }else if ( nmi_perfctr_msr ==MSR_P6_PERFCTR0 )
xen/arch/x86/oprofile/nmi_int.c +11 -22
@@ -35,14 +35,14 @@ static unsigned long saved_lvtpc[NR_CPUSstatic char *cpu_type; -static int passive_domain_msr_op_checks (struct cpu_user_regs *regs ,int *typep,int *indexp) +static int passive_domain_msr_op_checks (unsigned int msr,int *typep,int *indexp) {struct vpmu_struct *vpmu =vcpu_vpmu (current);if ( model ==NULL )return 0 ;if ( model->is_arch_pmu_msr ==NULL )return 0 ; -if ( !model->is_arch_pmu_msr ((u64 )regs->ecx, typep, indexp) ) +if ( !model->is_arch_pmu_msr (msr, typep, indexp) )return 0 ;if ( !(vpmu->flags &PASSIVE_DOMAIN_ALLOCATED ) )
@@ -51,29 +51,26 @@ static int passive_domain_msr_op_checks(return 1 ; } -int passive_domain_do_rdmsr (struct cpu_user_regs *regs) +int passive_domain_do_rdmsr (unsigned int msr,uint64_t *msr_val) {u64 msr_content;int type, index; -if ( !passive_domain_msr_op_checks (regs, &type, &index)) +if ( !passive_domain_msr_op_checks (msr, &type, &index))return 0 ; model->load_msr (current, type, index, &msr_content); - regs->eax = msr_content &0xFFFFFFFF ; - regs->edx = msr_content >>32 ; + *msr_val = msr_content;return 1 ; } -int passive_domain_do_wrmsr (struct cpu_user_regs *regs) +int passive_domain_do_wrmsr (unsigned int msr,uint64_t msr_content) { -u64 msr_content;int type, index; -if ( !passive_domain_msr_op_checks (regs, &type, &index)) +if ( !passive_domain_msr_op_checks (msr, &type, &index))return 0 ; - msr_content = (u32 )regs->eax | ((u64 )regs->edx <<32 ); model->save_msr (current, type, index, msr_content);return 1 ; }
@@ -109,15 +106,11 @@ static void nmi_cpu_save_registers(strucunsigned int i;for (i =0 ; i < nr_ctrs; ++i) { -rdmsr (counters[i].addr, - counters[i].saved.low, - counters[i].saved.high); + counters[i].value =rdmsr (counters[i].addr); }for (i =0 ; i < nr_ctrls; ++i) { -rdmsr (controls[i].addr, - controls[i].saved.low, - controls[i].saved.high); + controls[i].value =rdmsr (controls[i].addr); } }
@@ -227,15 +220,11 @@ static void nmi_restore_registers(structunsigned int i;for (i =0 ; i < nr_ctrls; ++i) { -wrmsr (controls[i].addr, - controls[i].saved.low, - controls[i].saved.high); +wrmsr (controls[i].addr, controls[i].value); }for (i =0 ; i < nr_ctrs; ++i) { -wrmsr (counters[i].addr, - counters[i].saved.low, - counters[i].saved.high); +wrmsr (counters[i].addr, counters[i].value); } }
xen/arch/x86/oprofile/op_model_athlon.c +31 -28
19 lines not on this page · raw message
xen/arch/x86/oprofile/op_model_p4.c +50 -48
98 lines not on this page · raw message
xen/arch/x86/oprofile/op_model_ppro.c +28 -28
56 lines not on this page · raw message
xen/arch/x86/traps.c +35 -30
65 lines not on this page · raw message
xen/include/asm-x86/apic.h +15 -26
41 lines not on this page · raw message
xen/include/asm-x86/msr.h +52 -57
109 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Part of the diff is not shown here. View the raw message.