Skip to contentSkip to conversation

a bugfix to the oprofile code

PATCH In review Nitin A Kamble 1 participant 2 messages Jan 14, 2009 – Jan 15, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 a bugfix to the oprofile code

Keir,
The checks in the function passive_domain_do_rdmsr() were not sufficient. Also the same checks were done in the function passive_domain_do_wrmsr(). So these common checks are moved in a new single function passive_domain_msr_op_checks().

Please Apply,
Thanks & Regards,
Nitin

exporting patch:
# HG changeset patch
# User Nitin A Kamble <[email protected]>
# Date 1231854695 28800
# Branch pmu_bugfix
# Node ID 05673257cd479e1bd03f706e738ac8001dcac4a2
# Parent e2f36d066b7b66a538bbe240d46f49bede51d9ed
The checks in the function passive_domain_do_rdmsr() were not sufficient. Also the same checks were done in the function passive_domain_do_wrmsr(). So these common checks are moved in a new single function passive_domain_msr_op_checks().

xen/arch/x86/oprofile/nmi_int.c +18 -18
diff -r e2f36d066b7b -r 05673257cd47 xen/arch/x86/oprofile/nmi_int.c
@@ -38,19 +38,29 @@
 extern int is_active(struct domain *d);
 extern int is_passive(struct domain *d);
 
+static int passive_domain_msr_op_checks(struct cpu_user_regs *regs ,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) )
+		return 0;
+
+	if ( !(vpmu->flags & PASSIVE_DOMAIN_ALLOCATED) )
+		if ( ! model->allocated_msr(current) )
+			return 0;
+	return 1;
+}
+
 int passive_domain_do_rdmsr(struct cpu_user_regs *regs)
 {
 	u64 msr_content;
 	int type, index;
-	struct vpmu_struct *vpmu = vcpu_vpmu(current);
 
-	if ( model->is_arch_pmu_msr == NULL )
+	if ( !passive_domain_msr_op_checks(regs, &type, &index))
 		return 0;
-	if ( !model->is_arch_pmu_msr((u64)regs->ecx, &type, &index) )
-		return 0;
-	if ( !(vpmu->flags & PASSIVE_DOMAIN_ALLOCATED) )
-		if ( ! model->allocated_msr(current) )
-			return 0;
 
 	model->load_msr(current, type, index, &msr_content);
 	regs->eax = msr_content & 0xFFFFFFFF;
@@ -58,23 +68,13 @@
 	return 1;
 }
 
-
 int passive_domain_do_wrmsr(struct cpu_user_regs *regs)
 {
 	u64 msr_content;
 	int type, index;
-	struct vpmu_struct *vpmu = vcpu_vpmu(current);
 
-	if ( model == NULL )
+	if ( !passive_domain_msr_op_checks(regs, &type, &index))
 		return 0;
-	if ( model->is_arch_pmu_msr == NULL )
-		return 0;
-	if ( !model->is_arch_pmu_msr((u64)regs->ecx, &type, &index) )
-		return 0;
-
-	if ( !(vpmu->flags & PASSIVE_DOMAIN_ALLOCATED) )
-		if ( ! model->allocated_msr(current) )
-			return 0;
 
 	msr_content = (u32)regs->eax | ((u64)regs->edx << 32);
 	model->save_msr(current, type, index, msr_content);

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

#1 lore raw

CCing Renato.

Thanks & Regards,
Nitin
Linux Open Source Technology Center, Intel Corporation
----------------------------------------------------------------------------
The Mind is like a parachute; it works much better when it's open.

Quoted 13 lines

-----Original Message-----
From: Nitin A Kamble [mailto:[email protected]]
Sent: Wednesday, January 14, 2009 1:59 PM
To: [email protected]
Cc: [email protected]; Nakajima, Jun; Kamble, Nitin A
Subject: [Patch] a bugfix to the oprofile code

Keir,
The checks in the function passive_domain_do_rdmsr() were not sufficient. Also the same checks were done in the function passive_domain_do_wrmsr(). So these common checks are moved in a new single function passive_domain_msr_op_checks().

Quoted 6 lines

Please Apply,
Thanks & Regards,
Nitin

exporting patch:
# HG changeset patch
# User Nitin A Kamble <[email protected]>
# Date 1231854695 28800
# Branch pmu_bugfix
# Node ID 05673257cd479e1bd03f706e738ac8001dcac4a2
# Parent e2f36d066b7b66a538bbe240d46f49bede51d9ed
The checks in the function passive_domain_do_rdmsr() were not sufficient. Also the same checks were done in the function passive_domain_do_wrmsr(). So these common checks are moved in a new single function passive_domain_msr_op_checks().

xen/arch/x86/oprofile/nmi_int.c +18 -18
diff -r e2f36d066b7b -r 05673257cd47 xen/arch/x86/oprofile/nmi_int.c
@@ -38,19 +38,29 @@
 extern int is_active(struct domain *d);
 extern int is_passive(struct domain *d);
 
+static int passive_domain_msr_op_checks(struct cpu_user_regs *regs ,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) )
+		return 0;
+
+	if ( !(vpmu->flags & PASSIVE_DOMAIN_ALLOCATED) )
+		if ( ! model->allocated_msr(current) )
+			return 0;
+	return 1;
+}
+
 int passive_domain_do_rdmsr(struct cpu_user_regs *regs)
 {
 	u64 msr_content;
 	int type, index;
-	struct vpmu_struct *vpmu = vcpu_vpmu(current);
 
-	if ( model->is_arch_pmu_msr == NULL )
+	if ( !passive_domain_msr_op_checks(regs, &type, &index))
 		return 0;
-	if ( !model->is_arch_pmu_msr((u64)regs->ecx, &type, &index) )
-		return 0;
-	if ( !(vpmu->flags & PASSIVE_DOMAIN_ALLOCATED) )
-		if ( ! model->allocated_msr(current) )
-			return 0;
 
 	model->load_msr(current, type, index, &msr_content);
 	regs->eax = msr_content & 0xFFFFFFFF;
@@ -58,23 +68,13 @@
 	return 1;
 }
 
-
 int passive_domain_do_wrmsr(struct cpu_user_regs *regs)
 {
 	u64 msr_content;
 	int type, index;
-	struct vpmu_struct *vpmu = vcpu_vpmu(current);
 
-	if ( model == NULL )
+	if ( !passive_domain_msr_op_checks(regs, &type, &index))
 		return 0;
-	if ( model->is_arch_pmu_msr == NULL )
-		return 0;
-	if ( !model->is_arch_pmu_msr((u64)regs->ecx, &type, &index) )
-		return 0;
-
-	if ( !(vpmu->flags & PASSIVE_DOMAIN_ALLOCATED) )
-		if ( ! model->allocated_msr(current) )
-			return 0;
 
 	msr_content = (u32)regs->eax | ((u64)regs->edx << 32);
 	model->save_msr(current, type, index, msr_content);

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