Skip to contentSkip to conversation

x86 hvm: msr-handling cleanup

PATCH New Christoph Egger 1 participant 1 message Jun 9, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86 hvm: msr-handling cleanup

Hi!

Attached patch cleans up hvm msr handling. This patch is extracted from the big msr cleanup 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/hvm/emulate.c +2 -17
diff -r 65b27a094ec8 xen/arch/x86/hvm/emulate.c
@@ -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 +27 -32

168 lines not on this page · raw message

xen/arch/x86/hvm/svm/svm.c +42 -46

204 lines not on this page · raw message

xen/arch/x86/hvm/vmx/vmx.c +82 -83

318 lines not on this page · raw message

xen/arch/x86/oprofile/nmi_int.c +7 -12
diff -r 65b27a094ec8 xen/arch/x86/oprofile/nmi_int.c
@@ -35,14 +35,14 @@ static unsigned long saved_lvtpc[NR_CPUS
 
 static 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,24 @@ 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_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;
 
-	model->load_msr(current, type, index, &msr_content);
-	regs->eax = msr_content & 0xFFFFFFFF;
-	regs->edx = msr_content >> 32;
+	model->load_msr(current, type, index, 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;
 }
xen/include/asm-x86/hvm/hvm.h +2 -2
diff -r 65b27a094ec8 xen/include/asm-x86/hvm/hvm.h
@@ -138,8 +138,8 @@ struct hvm_function_table {
         unsigned int *ecx, unsigned int *edx);
     void (*wbinvd_intercept)(void);
     void (*fpu_dirty_intercept)(void);
-    int (*msr_read_intercept)(struct cpu_user_regs *regs);
-    int (*msr_write_intercept)(struct cpu_user_regs *regs);
+    int (*msr_read_intercept)(unsigned int msr, uint64_t *msr_content);
+    int (*msr_write_intercept)(unsigned int msr, uint64_t msr_content);
     void (*invlpg_intercept)(unsigned long vaddr);
     void (*set_uc_mode)(struct vcpu *v);
     void (*set_info_guest)(struct vcpu *v);
xen/include/asm-x86/hvm/support.h +2 -2
diff -r 65b27a094ec8 xen/include/asm-x86/hvm/support.h
@@ -133,7 +133,7 @@ int hvm_set_efer(uint64_t value);
 int hvm_set_cr0(unsigned long value);
 int hvm_set_cr3(unsigned long value);
 int hvm_set_cr4(unsigned long value);
-int hvm_msr_read_intercept(struct cpu_user_regs *regs);
-int hvm_msr_write_intercept(struct cpu_user_regs *regs);
+int hvm_msr_read_intercept(unsigned int msr, uint64_t *msr_content);
+int hvm_msr_write_intercept(unsigned int msr, uint64_t msr_content);
 
 #endif /* __ASM_X86_HVM_SUPPORT_H__ */
xen/include/asm-x86/xenoprof.h +2 -2
diff -r 65b27a094ec8 xen/include/asm-x86/xenoprof.h
@@ -64,8 +64,8 @@ void xenoprof_backtrace(
                  "xenoprof/x86 with autotranslated mode enabled"    \
                  "isn't supported yet\n");                          \
     } while (0)
-int passive_domain_do_rdmsr(struct cpu_user_regs *regs);
-int passive_domain_do_wrmsr(struct cpu_user_regs *regs);
+int passive_domain_do_rdmsr(unsigned int msr, uint64_t *msr_content);
+int passive_domain_do_wrmsr(unsigned int msr, uint64_t msr_content);
 void passive_domain_destroy(struct vcpu *v);
 
 #endif /* __ASM_X86_XENOPROF_H__ */

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel