* [PATCH 0/6] SVM: complete support for kvmtrace
@ 2008-04-30 15:55 Joerg Roedel
2008-04-30 15:55 ` [PATCH] VMX: move APIC_ACCESS trace entry to generic code Joerg Roedel
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Joerg Roedel @ 2008-04-30 15:55 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel
This series of patches adds the missing kvmtrace markers to the SVM specific
code paths in KVM. Further it adds a new trace event for TDP page faults.
The diffstat:
arch/x86/kvm/lapic.c | 4 ++++
arch/x86/kvm/svm.c | 45 ++++++++++++++++++++++++++++++++++++++++++---
arch/x86/kvm/vmx.c | 2 --
arch/x86/kvm/x86.c | 25 ++++++++++++++++++++-----
include/asm-x86/kvm.h | 1 +
5 files changed, 67 insertions(+), 10 deletions(-)
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] VMX: move APIC_ACCESS trace entry to generic code
2008-04-30 15:55 [PATCH 0/6] SVM: complete support for kvmtrace Joerg Roedel
@ 2008-04-30 15:55 ` Joerg Roedel
2008-04-30 15:56 ` [PATCH] SVM: implement dedicated NMI exit handler Joerg Roedel
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Joerg Roedel @ 2008-04-30 15:55 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel, Joerg Roedel
This patch moves the trace entry for APIC accesses from the VMX code to the
generic lapic code. This way APIC accesses from SVM will also be traced.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kvm/lapic.c | 4 ++++
arch/x86/kvm/vmx.c | 2 --
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 57ac4e4..f42d5a7 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -572,6 +572,8 @@ static u32 __apic_read(struct kvm_lapic *apic, unsigned int offset)
{
u32 val = 0;
+ KVMTRACE_1D(APIC_ACCESS, apic->vcpu, (u32)offset, handler);
+
if (offset >= LAPIC_MMIO_LENGTH)
return 0;
@@ -695,6 +697,8 @@ static void apic_mmio_write(struct kvm_io_device *this,
offset &= 0xff0;
+ KVMTRACE_1D(APIC_ACCESS, apic->vcpu, (u32)offset, handler);
+
switch (offset) {
case APIC_ID: /* Local APIC ID */
apic_set_reg(apic, APIC_ID, val);
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 79cdbe8..26c4f02 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2550,8 +2550,6 @@ static int handle_apic_access(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
exit_qualification = vmcs_read64(EXIT_QUALIFICATION);
offset = exit_qualification & 0xffful;
- KVMTRACE_1D(APIC_ACCESS, vcpu, (u32)offset, handler);
-
er = emulate_instruction(vcpu, kvm_run, 0, 0, 0);
if (er != EMULATE_DONE) {
--
1.5.3.7
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] SVM: implement dedicated NMI exit handler
2008-04-30 15:55 [PATCH 0/6] SVM: complete support for kvmtrace Joerg Roedel
2008-04-30 15:55 ` [PATCH] VMX: move APIC_ACCESS trace entry to generic code Joerg Roedel
@ 2008-04-30 15:56 ` Joerg Roedel
2008-04-30 15:56 ` [PATCH] SVM: implement dedicated INTR " Joerg Roedel
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Joerg Roedel @ 2008-04-30 15:56 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel, Joerg Roedel
With an exit handler for NMI intercepts its possible to account them using
kvmtrace.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kvm/svm.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index ab22615..6dce863 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1081,6 +1081,11 @@ static int io_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
return kvm_emulate_pio(&svm->vcpu, kvm_run, in, size, port);
}
+static int nmi_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
+{
+ return 1;
+}
+
static int nop_on_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
{
return 1;
@@ -1365,7 +1370,7 @@ static int (*svm_exit_handlers[])(struct vcpu_svm *svm,
[SVM_EXIT_EXCP_BASE + NM_VECTOR] = nm_interception,
[SVM_EXIT_EXCP_BASE + MC_VECTOR] = mc_interception,
[SVM_EXIT_INTR] = nop_on_interception,
- [SVM_EXIT_NMI] = nop_on_interception,
+ [SVM_EXIT_NMI] = nmi_interception,
[SVM_EXIT_SMI] = nop_on_interception,
[SVM_EXIT_INIT] = nop_on_interception,
[SVM_EXIT_VINTR] = interrupt_window_interception,
--
1.5.3.7
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] SVM: implement dedicated INTR exit handler
2008-04-30 15:55 [PATCH 0/6] SVM: complete support for kvmtrace Joerg Roedel
2008-04-30 15:55 ` [PATCH] VMX: move APIC_ACCESS trace entry to generic code Joerg Roedel
2008-04-30 15:56 ` [PATCH] SVM: implement dedicated NMI exit handler Joerg Roedel
@ 2008-04-30 15:56 ` Joerg Roedel
2008-04-30 15:56 ` [PATCH] x86: add missing kvmtrace bits Joerg Roedel
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Joerg Roedel @ 2008-04-30 15:56 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel, Joerg Roedel
With an exit handler for INTR intercepts its possible to account them using
kvmtrace.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kvm/svm.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 6dce863..ca83c8a 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1086,6 +1086,12 @@ static int nmi_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
return 1;
}
+static int intr_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
+{
+ ++svm->vcpu.stat.irq_exits;
+ return 1;
+}
+
static int nop_on_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
{
return 1;
@@ -1369,7 +1375,7 @@ static int (*svm_exit_handlers[])(struct vcpu_svm *svm,
[SVM_EXIT_EXCP_BASE + PF_VECTOR] = pf_interception,
[SVM_EXIT_EXCP_BASE + NM_VECTOR] = nm_interception,
[SVM_EXIT_EXCP_BASE + MC_VECTOR] = mc_interception,
- [SVM_EXIT_INTR] = nop_on_interception,
+ [SVM_EXIT_INTR] = intr_interception,
[SVM_EXIT_NMI] = nmi_interception,
[SVM_EXIT_SMI] = nop_on_interception,
[SVM_EXIT_INIT] = nop_on_interception,
--
1.5.3.7
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] x86: add missing kvmtrace bits
2008-04-30 15:55 [PATCH 0/6] SVM: complete support for kvmtrace Joerg Roedel
` (2 preceding siblings ...)
2008-04-30 15:56 ` [PATCH] SVM: implement dedicated INTR " Joerg Roedel
@ 2008-04-30 15:56 ` Joerg Roedel
2008-04-30 15:56 ` [PATCH] SVM: add missing kvmtrace markers Joerg Roedel
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Joerg Roedel @ 2008-04-30 15:56 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel, Joerg Roedel
This patch adds some kvmtrace bits to the generic x86 code
where it is instrumented from SVM.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kvm/x86.c | 25 ++++++++++++++++++++-----
1 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 578a0c1..eae6ad5 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1971,6 +1971,7 @@ int emulate_invlpg(struct kvm_vcpu *vcpu, gva_t address)
int emulate_clts(struct kvm_vcpu *vcpu)
{
+ KVMTRACE_0D(CLTS, vcpu, handler);
kvm_x86_ops->set_cr0(vcpu, vcpu->arch.cr0 & ~X86_CR0_TS);
return X86EMUL_CONTINUE;
}
@@ -2551,27 +2552,41 @@ void realmode_lmsw(struct kvm_vcpu *vcpu, unsigned long msw,
unsigned long realmode_get_cr(struct kvm_vcpu *vcpu, int cr)
{
+ unsigned long value;
+
kvm_x86_ops->decache_cr4_guest_bits(vcpu);
switch (cr) {
case 0:
- return vcpu->arch.cr0;
+ value = vcpu->arch.cr0;
+ break;
case 2:
- return vcpu->arch.cr2;
+ value = vcpu->arch.cr2;
+ break;
case 3:
- return vcpu->arch.cr3;
+ value = vcpu->arch.cr3;
+ break;
case 4:
- return vcpu->arch.cr4;
+ value = vcpu->arch.cr4;
+ break;
case 8:
- return kvm_get_cr8(vcpu);
+ value = kvm_get_cr8(vcpu);
+ break;
default:
vcpu_printf(vcpu, "%s: unexpected cr %u\n", __func__, cr);
return 0;
}
+ KVMTRACE_3D(CR_READ, vcpu, (u32)cr, (u32)value,
+ (u32)((u64)value >> 32), handler);
+
+ return value;
}
void realmode_set_cr(struct kvm_vcpu *vcpu, int cr, unsigned long val,
unsigned long *rflags)
{
+ KVMTRACE_3D(CR_WRITE, vcpu, (u32)cr, (u32)val,
+ (u32)((u64)val >> 32), handler);
+
switch (cr) {
case 0:
kvm_set_cr0(vcpu, mk_cr_64(vcpu->arch.cr0, val));
--
1.5.3.7
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] SVM: add missing kvmtrace markers
2008-04-30 15:55 [PATCH 0/6] SVM: complete support for kvmtrace Joerg Roedel
` (3 preceding siblings ...)
2008-04-30 15:56 ` [PATCH] x86: add missing kvmtrace bits Joerg Roedel
@ 2008-04-30 15:56 ` Joerg Roedel
2008-04-30 15:56 ` [PATCH] SVM: add tracing support for TDP page faults Joerg Roedel
2008-04-30 18:05 ` [PATCH 0/6] SVM: complete support for kvmtrace Avi Kivity
6 siblings, 0 replies; 8+ messages in thread
From: Joerg Roedel @ 2008-04-30 15:56 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel, Joerg Roedel
This patch adds the missing kvmtrace markers to the svm
module of kvm.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kvm/svm.c | 26 +++++++++++++++++++++++++-
1 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index ca83c8a..db90984 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -949,7 +949,9 @@ static void new_asid(struct vcpu_svm *svm, struct svm_cpu_data *svm_data)
static unsigned long svm_get_dr(struct kvm_vcpu *vcpu, int dr)
{
- return to_svm(vcpu)->db_regs[dr];
+ unsigned long val = to_svm(vcpu)->db_regs[dr];
+ KVMTRACE_2D(DR_READ, vcpu, (u32)dr, (u32)val, handler);
+ return val;
}
static void svm_set_dr(struct kvm_vcpu *vcpu, int dr, unsigned long value,
@@ -1004,6 +1006,12 @@ static int pf_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
fault_address = svm->vmcb->control.exit_info_2;
error_code = svm->vmcb->control.exit_info_1;
+
+ if (!npt_enabled)
+ KVMTRACE_3D(PAGE_FAULT, &svm->vcpu, error_code,
+ (u32)fault_address, (u32)(fault_address >> 32),
+ handler);
+
return kvm_mmu_page_fault(&svm->vcpu, fault_address, error_code);
}
@@ -1083,12 +1091,14 @@ static int io_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
static int nmi_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
{
+ KVMTRACE_0D(NMI, &svm->vcpu, handler);
return 1;
}
static int intr_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
{
++svm->vcpu.stat.irq_exits;
+ KVMTRACE_0D(INTR, &svm->vcpu, handler);
return 1;
}
@@ -1230,6 +1240,9 @@ static int rdmsr_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
if (svm_get_msr(&svm->vcpu, ecx, &data))
kvm_inject_gp(&svm->vcpu, 0);
else {
+ KVMTRACE_3D(MSR_READ, &svm->vcpu, ecx, (u32)data,
+ (u32)(data >> 32), handler);
+
svm->vmcb->save.rax = data & 0xffffffff;
svm->vcpu.arch.regs[VCPU_REGS_RDX] = data >> 32;
svm->next_rip = svm->vmcb->save.rip + 2;
@@ -1315,6 +1328,10 @@ static int wrmsr_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
u32 ecx = svm->vcpu.arch.regs[VCPU_REGS_RCX];
u64 data = (svm->vmcb->save.rax & -1u)
| ((u64)(svm->vcpu.arch.regs[VCPU_REGS_RDX] & -1u) << 32);
+
+ KVMTRACE_3D(MSR_WRITE, &svm->vcpu, ecx, (u32)data, (u32)(data >> 32),
+ handler);
+
svm->next_rip = svm->vmcb->save.rip + 2;
if (svm_set_msr(&svm->vcpu, ecx, data))
kvm_inject_gp(&svm->vcpu, 0);
@@ -1334,6 +1351,8 @@ static int msr_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
static int interrupt_window_interception(struct vcpu_svm *svm,
struct kvm_run *kvm_run)
{
+ KVMTRACE_0D(PEND_INTR, &svm->vcpu, handler);
+
svm->vmcb->control.intercept &= ~(1ULL << INTERCEPT_VINTR);
svm->vmcb->control.int_ctl &= ~V_IRQ_MASK;
/*
@@ -1408,6 +1427,9 @@ static int handle_exit(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
struct vcpu_svm *svm = to_svm(vcpu);
u32 exit_code = svm->vmcb->control.exit_code;
+ KVMTRACE_3D(VMEXIT, vcpu, exit_code, (u32)svm->vmcb->save.rip,
+ (u32)((u64)svm->vmcb->save.rip >> 32), entryexit);
+
if (npt_enabled) {
int mmu_reload = 0;
if ((vcpu->arch.cr0 ^ svm->vmcb->save.cr0) & X86_CR0_PG) {
@@ -1481,6 +1503,8 @@ static inline void svm_inject_irq(struct vcpu_svm *svm, int irq)
{
struct vmcb_control_area *control;
+ KVMTRACE_1D(INJ_VIRQ, &svm->vcpu, (u32)irq, handler);
+
control = &svm->vmcb->control;
control->int_vector = irq;
control->int_ctl &= ~V_INTR_PRIO_MASK;
--
1.5.3.7
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] SVM: add tracing support for TDP page faults
2008-04-30 15:55 [PATCH 0/6] SVM: complete support for kvmtrace Joerg Roedel
` (4 preceding siblings ...)
2008-04-30 15:56 ` [PATCH] SVM: add missing kvmtrace markers Joerg Roedel
@ 2008-04-30 15:56 ` Joerg Roedel
2008-04-30 18:05 ` [PATCH 0/6] SVM: complete support for kvmtrace Avi Kivity
6 siblings, 0 replies; 8+ messages in thread
From: Joerg Roedel @ 2008-04-30 15:56 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel, Joerg Roedel
To distinguish between real page faults and nested page faults they should be
traced as different events. This is implemented by this patch.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kvm/svm.c | 4 ++++
include/asm-x86/kvm.h | 1 +
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index db90984..5528121 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1011,6 +1011,10 @@ static int pf_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
KVMTRACE_3D(PAGE_FAULT, &svm->vcpu, error_code,
(u32)fault_address, (u32)(fault_address >> 32),
handler);
+ else
+ KVMTRACE_3D(TDP_FAULT, &svm->vcpu, error_code,
+ (u32)fault_address, (u32)(fault_address >> 32),
+ handler);
return kvm_mmu_page_fault(&svm->vcpu, fault_address, error_code);
}
diff --git a/include/asm-x86/kvm.h b/include/asm-x86/kvm.h
index 80eefef..6f18408 100644
--- a/include/asm-x86/kvm.h
+++ b/include/asm-x86/kvm.h
@@ -228,5 +228,6 @@ struct kvm_pit_state {
#define KVM_TRC_CLTS (KVM_TRC_HANDLER + 0x12)
#define KVM_TRC_LMSW (KVM_TRC_HANDLER + 0x13)
#define KVM_TRC_APIC_ACCESS (KVM_TRC_HANDLER + 0x14)
+#define KVM_TRC_TDP_FAULT (KVM_TRC_HANDLER + 0x15)
#endif
--
1.5.3.7
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 0/6] SVM: complete support for kvmtrace
2008-04-30 15:55 [PATCH 0/6] SVM: complete support for kvmtrace Joerg Roedel
` (5 preceding siblings ...)
2008-04-30 15:56 ` [PATCH] SVM: add tracing support for TDP page faults Joerg Roedel
@ 2008-04-30 18:05 ` Avi Kivity
6 siblings, 0 replies; 8+ messages in thread
From: Avi Kivity @ 2008-04-30 18:05 UTC (permalink / raw)
To: Joerg Roedel; +Cc: kvm-devel
Joerg Roedel wrote:
> This series of patches adds the missing kvmtrace markers to the SVM specific
> code paths in KVM. Further it adds a new trace event for TDP page faults.
>
>
Thanks, applied all. Please use git format-patch -n (or format.numbered
= auto) so that patch order is explicit.
--
Any sufficiently difficult bug is indistinguishable from a feature.
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-04-30 18:05 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-30 15:55 [PATCH 0/6] SVM: complete support for kvmtrace Joerg Roedel
2008-04-30 15:55 ` [PATCH] VMX: move APIC_ACCESS trace entry to generic code Joerg Roedel
2008-04-30 15:56 ` [PATCH] SVM: implement dedicated NMI exit handler Joerg Roedel
2008-04-30 15:56 ` [PATCH] SVM: implement dedicated INTR " Joerg Roedel
2008-04-30 15:56 ` [PATCH] x86: add missing kvmtrace bits Joerg Roedel
2008-04-30 15:56 ` [PATCH] SVM: add missing kvmtrace markers Joerg Roedel
2008-04-30 15:56 ` [PATCH] SVM: add tracing support for TDP page faults Joerg Roedel
2008-04-30 18:05 ` [PATCH 0/6] SVM: complete support for kvmtrace Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox