Skip to content

Commit 1fcd331

Browse files
committed
HVM-582 remove more XXXs
HVM-583 KVM DTrace probes should all use KVM_TRACE macros
1 parent aca837d commit 1fcd331

File tree

5 files changed

+50
-194
lines changed

5 files changed

+50
-194
lines changed

kvm.c

+13-53
Original file line numberDiff line numberDiff line change
@@ -449,16 +449,10 @@ kvm_ctx_restore(void *arg)
449449
kvm_arch_vcpu_load(vcpu, cpu);
450450
}
451451

452-
#ifdef XXX_KVM_DECLARATION
453-
#define pfn_valid(pfn) ((pfn < physmax) && (pfn != PFN_INVALID))
454-
#else
455-
#define pfn_valid(pfn) (pfn != PFN_INVALID)
456-
#endif
457-
458452
inline int
459453
kvm_is_mmio_pfn(pfn_t pfn)
460454
{
461-
if (pfn_valid(pfn)) {
455+
if (pfn != PFN_INVALID) {
462456
#ifdef XXX
463457
struct page *page = compound_head(pfn_to_page(pfn));
464458
return (PageReserved(page));
@@ -936,8 +930,6 @@ __kvm_set_memory_region(struct kvm *kvmp,
936930
* - kvm_is_visible_gfn (mmu_check_roots)
937931
*/
938932
kvm_arch_flush_shadow(kvmp);
939-
940-
/* XXX: how many bytes to free??? */
941933
kmem_free(old_memslots, sizeof (struct kvm_memslots));
942934
}
943935

@@ -1299,18 +1291,8 @@ kvm_read_guest_atomic(struct kvm *kvm, gpa_t gpa, void *data, unsigned long len)
12991291
if (kvm_is_error_hva(addr))
13001292
return (-EFAULT);
13011293

1302-
#ifdef XXX
1303-
pagefault_disable();
1304-
#else
1305-
XXX_KVM_PROBE;
1306-
#endif
1307-
13081294
r = copyin((caddr_t)addr + offset, data, len);
1309-
#ifdef XXX
1310-
pagefault_enable();
1311-
#else
1312-
XXX_KVM_PROBE;
1313-
#endif
1295+
13141296
if (r)
13151297
return (-EFAULT);
13161298

@@ -1329,7 +1311,6 @@ kvm_write_guest_page(struct kvm *kvm,
13291311
if (kvm_is_error_hva(addr))
13301312
return (-EFAULT);
13311313

1332-
/* XXX - addr could be user or kernel */
13331314
if (addr >= kernelbase) {
13341315
bcopy(data, (caddr_t)(addr + offset), len);
13351316
} else {
@@ -1778,25 +1759,15 @@ kvm_init(void *opaque)
17781759

17791760

17801761
void
1781-
kvm_guest_exit(void)
1762+
kvm_guest_exit(struct kvm_vcpu *vcpu)
17821763
{
1783-
#ifdef XXX
1784-
account_system_vtime(current);
1785-
current->flags &= ~PF_VCPU;
1786-
#else
1787-
XXX_KVM_PROBE;
1788-
#endif
1764+
KVM_TRACE1(guest__exit, struct kvm_vcpu *, vcpu);
17891765
}
17901766

17911767
void
1792-
kvm_guest_enter(void)
1768+
kvm_guest_enter(struct kvm_vcpu *vcpu)
17931769
{
1794-
#ifdef XXX
1795-
account_system_vtime(current);
1796-
current->flags |= PF_VCPU;
1797-
#else
1798-
XXX_KVM_PROBE;
1799-
#endif
1770+
KVM_TRACE1(guest__entry, struct kvm_vcpu *, vcpu);
18001771
}
18011772

18021773
/*
@@ -2017,21 +1988,13 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int md, cred_t *cr, int *rv)
20171988
minor_t minor;
20181989
kvm_devstate_t *ksp;
20191990
void *argp = (void *)arg;
1991+
struct kvm_pit_config pit;
20201992

20211993
minor = getminor(dev);
20221994
ksp = ddi_get_soft_state(kvm_state, minor);
20231995
if (ksp == NULL)
20241996
return (ENXIO);
20251997

2026-
union {
2027-
struct kvm_pit_state ps;
2028-
struct kvm_pit_state2 ps2;
2029-
#ifdef XXX_KVM_DECLARATION
2030-
struct kvm_memory_alias alias;
2031-
#endif
2032-
struct kvm_pit_config pit_config;
2033-
} u;
2034-
20351998
struct {
20361999
int cmd; /* command */
20372000
void *func; /* function to call */
@@ -2211,8 +2174,7 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int md, cred_t *cr, int *rv)
22112174
break;
22122175

22132176
case KVM_CREATE_PIT2:
2214-
if (copyin(argp, &u.pit_config,
2215-
sizeof (struct kvm_pit_config)) != 0) {
2177+
if (copyin(argp, &pit, sizeof (struct kvm_pit_config)) != 0) {
22162178
rval = EFAULT;
22172179
break;
22182180
}
@@ -2227,7 +2189,7 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int md, cred_t *cr, int *rv)
22272189
}
22282190

22292191
if (cmd == KVM_CREATE_PIT) {
2230-
u.pit_config.flags = KVM_PIT_SPEAKER_DUMMY;
2192+
pit.flags = KVM_PIT_SPEAKER_DUMMY;
22312193
} else {
22322194
ASSERT(cmd == KVM_CREATE_PIT2);
22332195
}
@@ -2237,7 +2199,7 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int md, cred_t *cr, int *rv)
22372199
if (kvmp->arch.vpit != NULL) {
22382200
rval = EEXIST;
22392201
} else if ((kvmp->arch.vpit = kvm_create_pit(kvmp,
2240-
u.pit_config.flags)) == NULL) {
2202+
pit.flags)) == NULL) {
22412203
rval = ENOMEM;
22422204
}
22432205

@@ -2739,11 +2701,9 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int md, cred_t *cr, int *rv)
27392701
*rv = 0;
27402702
break;
27412703
}
2704+
27422705
default:
2743-
#ifndef XXX
2744-
XXX_KVM_PROBE;
2745-
DTRACE_PROBE1(kvm__xxx__ioctl, int, cmd);
2746-
#endif
2706+
KVM_TRACE1(bad__ioctl, int, cmd);
27472707
rval = EINVAL; /* x64, others may do other things... */
27482708
}
27492709

@@ -2820,7 +2780,7 @@ kvm_devmap(dev_t dev, devmap_cookie_t dhp, offset_t off, size_t len,
28202780
PAGESIZE*2, PROT_READ | PROT_WRITE | PROT_USER, DEVMAP_DEFAULTS,
28212781
NULL);
28222782

2823-
*maplen = PAGESIZE*2;
2783+
*maplen = PAGESIZE * 2;
28242784

28252785
return (res);
28262786
}

kvm_host.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,8 @@ extern void kvm_free_irq_source_id(struct kvm *, int);
444444
/* For vcpu->arch.iommu_flags */
445445
#define KVM_IOMMU_CACHE_COHERENCY 0x1
446446

447-
extern void kvm_guest_enter(void);
448-
extern void kvm_guest_exit(void);
447+
extern void kvm_guest_enter(struct kvm_vcpu *);
448+
extern void kvm_guest_exit(struct kvm_vcpu *);
449449

450450
#ifndef KVM_ARCH_HAS_UNALIAS_INSTANTIATION
451451
#define unalias_gfn_instantiation unalias_gfn

kvm_impl.h

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#define XXX_KVM_SYNC_PROBE DTRACE_PROBE2(kvm__xxx__sync, \
1414
char *, __FILE__, int, __LINE__)
1515

16+
#define KVM_TRACE(name) \
17+
DTRACE_PROBE(kvm__##name);
18+
1619
#define KVM_TRACE1(name, type1, arg1) \
1720
DTRACE_PROBE1(kvm__##name, type1, arg1);
1821

kvm_vmx.c

+13-14
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ __invvpid(int ext, uint16_t vpid, gva_t gva)
433433
uint64_t gva;
434434
} operand = { vpid, 0, gva };
435435

436-
DTRACE_PROBE2(kvm__vmx__invvpid, int, vpid, uint64_t, gva);
436+
KVM_TRACE2(vmx__invvpid, int, vpid, uint64_t, gva);
437437

438438
/* BEGIN CSTYLED */
439439
__asm__ volatile (ASM_VMX_INVVPID
@@ -450,7 +450,7 @@ __invept(int ext, uint64_t eptp, gpa_t gpa)
450450
uint64_t eptp, gpa;
451451
} operand = {eptp, gpa};
452452

453-
DTRACE_PROBE2(kvm__vmx__invept, uint64_t, eptp, uint64_t, gpa);
453+
KVM_TRACE2(vmx__invept, uint64_t, eptp, uint64_t, gpa);
454454

455455
/* BEGIN CSTYLED */
456456
__asm__ volatile (ASM_VMX_INVEPT
@@ -477,7 +477,7 @@ vmcs_clear(uint64_t vmcs_pa)
477477
{
478478
unsigned char error;
479479

480-
DTRACE_PROBE1(kvm__vmx__vmclear, uint64_t, vmcs_pa);
480+
KVM_TRACE1(vmx__vmclear, uint64_t, vmcs_pa);
481481

482482
/*CSTYLED*/
483483
__asm__ volatile (__ex(ASM_VMX_VMCLEAR_RAX) "\n\tsetna %0\n"
@@ -552,7 +552,7 @@ vmcs_readl(unsigned long field)
552552
__asm__ volatile (ASM_VMX_VMREAD_RDX_RAX
553553
: "=a"(value) : "d"(field) : "cc");
554554

555-
DTRACE_PROBE2(kvm__vmx__vmread, long, field, long, value);
555+
KVM_TRACE2(vmx__vmread, long, field, long, value);
556556

557557
return (value);
558558
}
@@ -594,7 +594,7 @@ __vmwrite(unsigned long field, unsigned long value)
594594
: "=q"(err) : "a" (value), "d" (field)
595595
: "cc", "memory");
596596

597-
DTRACE_PROBE3(kvm__vmx__vmwrite, long, field,
597+
KVM_TRACE3(vmx__vmwrite, long, field,
598598
long, value, uint8_t, err);
599599

600600
/* XXX the following should be ifdef debug... */
@@ -841,7 +841,7 @@ vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
841841

842842
current_vmcs[cpu] = vmx->vmcs;
843843

844-
DTRACE_PROBE1(kvm__vmx__vmptrld, uint64_t, phys_addr);
844+
KVM_TRACE1(vmx__vmptrld, uint64_t, phys_addr);
845845

846846
/*CSTYLED*/
847847
__asm__ volatile (ASM_VMX_VMPTRLD_RAX "; setna %0"
@@ -1308,7 +1308,7 @@ vmx_hardware_enable(void *garbage)
13081308
FEATURE_CONTROL_VMXON_ENABLED);
13091309
}
13101310

1311-
DTRACE_PROBE1(kvm__vmx__vmxon, uint64_t, phys_addr);
1311+
KVM_TRACE1(vmx__vmxon, uint64_t, phys_addr);
13121312

13131313
setcr4(getcr4() | X86_CR4_VMXE); /* FIXME: not cpu hotplug safe */
13141314
/* BEGIN CSTYLED */
@@ -1329,7 +1329,7 @@ vmx_hardware_enable(void *garbage)
13291329
static void
13301330
kvm_cpu_vmxoff(void)
13311331
{
1332-
DTRACE_PROBE(kvm__vmx__vmxoff);
1332+
KVM_TRACE(vmx__vmxoff);
13331333

13341334
/* BEGIN CSTYLED */
13351335
__asm__ volatile ((ASM_VMX_VMXOFF) : : : "cc");
@@ -3254,8 +3254,7 @@ handle_cr(struct kvm_vcpu *vcpu)
32543254
exit_qualification = vmcs_readl(EXIT_QUALIFICATION);
32553255
cr = exit_qualification & 15;
32563256
reg = (exit_qualification >> 8) & 15;
3257-
DTRACE_PROBE3(kvm__cr, int, cr, int, reg, int,
3258-
(exit_qualification >> 4) & 3);
3257+
KVM_TRACE3(cr, int, cr, int, reg, int, (exit_qualification >> 4) & 3);
32593258
switch ((exit_qualification >> 4) & 3) {
32603259
case 0: /* mov to cr */
32613260
val = kvm_register_read(vcpu, reg);
@@ -3903,7 +3902,7 @@ vmx_handle_exit(struct kvm_vcpu *vcpu)
39033902

39043903
/* Always read the guest rip when exiting */
39053904
rip = vmcs_readl(GUEST_RIP);
3906-
DTRACE_PROBE2(kvm__vexit, unsigned long, rip, uint32_t, exit_reason);
3905+
KVM_TRACE2(vexit, unsigned long, rip, uint32_t, exit_reason);
39073906

39083907
/* If guest state is invalid, start emulating */
39093908
if (vmx->emulation_required && emulate_invalid_guest_state)
@@ -4128,7 +4127,7 @@ vmx_vcpu_run(struct kvm_vcpu *vcpu)
41284127
if (test_bit(VCPU_REGS_RIP, (unsigned long *)&vcpu->arch.regs_dirty))
41294128
vmcs_writel(GUEST_RIP, vcpu->arch.regs[VCPU_REGS_RIP]);
41304129

4131-
DTRACE_PROBE1(kvm__vrun, unsigned long, vcpu->arch.regs[VCPU_REGS_RIP]);
4130+
KVM_TRACE1(vrun, unsigned long, vcpu->arch.regs[VCPU_REGS_RIP]);
41324131

41334132
/*
41344133
* When single-stepping over STI and MOV SS, we must clear the
@@ -4146,9 +4145,9 @@ vmx_vcpu_run(struct kvm_vcpu *vcpu)
41464145
vmcs_writel(HOST_CR0, read_cr0());
41474146

41484147
if (vmx->launched) {
4149-
DTRACE_PROBE1(kvm__vmx__vmresume, struct vcpu_vmx *, vmx);
4148+
KVM_TRACE1(vmx__vmresume, struct vcpu_vmx *, vmx);
41504149
} else {
4151-
DTRACE_PROBE1(kvm__vmx__vmlaunch, struct vcpu_vmx *, vmx);
4150+
KVM_TRACE1(vmx__vmlaunch, struct vcpu_vmx *, vmx);
41524151
}
41534152

41544153
__asm__(

0 commit comments

Comments
 (0)