Skip to contentSkip to conversation

svm last branch recording MSR emulation

PATCH In review Markus Rechberger 2 participants 2 messages Jan 25, 2008 – Jan 27, 2008 1 message not in the archive KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 svm last branch recording MSR emulation

Hi,

this patch adds support for the lbr MSR emulation, it also enables support for Windows XP 64bit guests.

svm.c renamed from svm.c.orig +28 -0
@@ -1099,6 +1100,21 @@
 	case MSR_IA32_SYSENTER_ESP:
 		*data = svm->vmcb->save.sysenter_esp;
 		break;
+	case MSR_IA32_DEBUGCTLMSR:
+		*data = svm->vmcb->save.dbgctl;
+		break;
+	case MSR_IA32_LASTBRANCHFROMIP:
+		*data = svm->vmcb->save.br_from;
+		break;
+	case MSR_IA32_LASTBRANCHTOIP:
+		*data = svm->vmcb->save.br_to;
+		break;
+	case MSR_IA32_LASTINTFROMIP:
+		*data = svm->vmcb->save.last_excp_from;
+		break;
+	case MSR_IA32_LASTINTTOIP:
+		*data = svm->vmcb->save.last_excp_to;
+		break;
 	default:
 		return kvm_get_msr_common(vcpu, ecx, data);
 	}
@@ -1171,6 +1187,19 @@
 		if (data != 0)
 			goto unhandled;
 		break;
+	case MSR_IA32_DEBUGCTLMSR:
+		svm->vmcb->save.dbgctl = data;
+		if (svm->vmcb->save.dbgctl && svm_has(SVM_FEATURE_LBRV)) {
+			void *msrpm_va;
+			svm->vmcb->control.lbr_ctl = 1;
+			msrpm_va = page_address(pfn_to_page(msrpm_base >> PAGE_SHIFT));
+			set_msr_interception(msrpm_va, MSR_IA32_DEBUGCTLMSR, 0, 0);
+			set_msr_interception(msrpm_va, MSR_IA32_LASTBRANCHFROMIP, 0, 0);
+			set_msr_interception(msrpm_va, MSR_IA32_LASTBRANCHTOIP, 0, 0);
+			set_msr_interception(msrpm_va, MSR_IA32_LASTINTFROMIP, 0, 0);
+			set_msr_interception(msrpm_va, MSR_IA32_LASTINTTOIP, 0, 0);
+		}
+		break;
 	default:
 	unhandled:
 		return kvm_set_msr_common(vcpu, ecx, data);

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 6 lines · Markus Rechberger

this patch adds support for the lbr MSR emulation, it also enables support for Windows XP 64bit guests.

svm.c line 1194

Quoted 8 lines
svm.c renamed from svm.c.orig +4 -0
@@ -1171,6 +1187,19 @@
 		if (data != 0)
 			goto unhandled;
 		break;
+	case MSR_IA32_DEBUGCTLMSR:
+		svm->vmcb->save.dbgctl = data;
+		if (svm->vmcb->save.dbgctl && svm_has(SVM_FEATURE_LBRV)) {
+			void *msrpm_va;
 

blank line

svm.c line 1204

Quoted 11 lines
svm.c renamed from svm.c.orig +9 -0
+			svm->vmcb->control.lbr_ctl = 1;
+			msrpm_va = page_address(pfn_to_page(msrpm_base >> PAGE_SHIFT));
+			set_msr_interception(msrpm_va, MSR_IA32_DEBUGCTLMSR, 0, 0);
+			set_msr_interception(msrpm_va, MSR_IA32_LASTBRANCHFROMIP, 0, 0);
+			set_msr_interception(msrpm_va, MSR_IA32_LASTBRANCHTOIP, 0, 0);
+			set_msr_interception(msrpm_va, MSR_IA32_LASTINTFROMIP, 0, 0);
+			set_msr_interception(msrpm_va, MSR_IA32_LASTINTTOIP, 0, 0);
+		}
+		break;
 	default:
 	unhandled:

What is the performance impact (for example, on user/test/x86/vmexit.flat when modified to set a bit in debugctl)?

Is it not better to enable LBR virtualization only when the guest enables LBR (but avoid it when other bits are enabled)?

Can we disable LBR virtualization when the guest disables LBR?

Signature · 7 lines
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/