Re: [PATCH] kvm: x86: ioapic and apic debug macros cleanup

2019-07-15 Thread Paolo Bonzini
On 05/07/19 19:08, Yi Wang wrote:
> The ioapic_debug and apic_debug have been not used
> for years, and kvm tracepoints are enough for debugging,
> so remove them as Paolo suggested.
> 
> However, there may be something wrong when pv evi get/put
> user, so it's better to retain some log there.
> 
> Signed-off-by: Yi Wang 
> ---
>  arch/x86/kvm/ioapic.c | 15 
>  arch/x86/kvm/lapic.c  | 98 
> +--
>  2 files changed, 9 insertions(+), 104 deletions(-)
> 
> diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c
> index 1add1bc..d859ae8 100644
> --- a/arch/x86/kvm/ioapic.c
> +++ b/arch/x86/kvm/ioapic.c
> @@ -45,11 +45,6 @@
>  #include "lapic.h"
>  #include "irq.h"
>  
> -#if 0
> -#define ioapic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg)
> -#else
> -#define ioapic_debug(fmt, arg...)
> -#endif
>  static int ioapic_service(struct kvm_ioapic *vioapic, int irq,
>   bool line_status);
>  
> @@ -294,7 +289,6 @@ static void ioapic_write_indirect(struct kvm_ioapic 
> *ioapic, u32 val)
>   default:
>   index = (ioapic->ioregsel - 0x10) >> 1;
>  
> - ioapic_debug("change redir index %x val %x\n", index, val);
>   if (index >= IOAPIC_NUM_PINS)
>   return;
>   e = &ioapic->redirtbl[index];
> @@ -343,12 +337,6 @@ static int ioapic_service(struct kvm_ioapic *ioapic, int 
> irq, bool line_status)
>   entry->fields.remote_irr))
>   return -1;
>  
> - ioapic_debug("dest=%x dest_mode=%x delivery_mode=%x "
> -  "vector=%x trig_mode=%x\n",
> -  entry->fields.dest_id, entry->fields.dest_mode,
> -  entry->fields.delivery_mode, entry->fields.vector,
> -  entry->fields.trig_mode);
> -
>   irqe.dest_id = entry->fields.dest_id;
>   irqe.vector = entry->fields.vector;
>   irqe.dest_mode = entry->fields.dest_mode;
> @@ -515,7 +503,6 @@ static int ioapic_mmio_read(struct kvm_vcpu *vcpu, struct 
> kvm_io_device *this,
>   if (!ioapic_in_range(ioapic, addr))
>   return -EOPNOTSUPP;
>  
> - ioapic_debug("addr %lx\n", (unsigned long)addr);
>   ASSERT(!(addr & 0xf));  /* check alignment */
>  
>   addr &= 0xff;
> @@ -558,8 +545,6 @@ static int ioapic_mmio_write(struct kvm_vcpu *vcpu, 
> struct kvm_io_device *this,
>   if (!ioapic_in_range(ioapic, addr))
>   return -EOPNOTSUPP;
>  
> - ioapic_debug("ioapic_mmio_write addr=%p len=%d val=%p\n",
> -  (void*)addr, len, val);
>   ASSERT(!(addr & 0xf));  /* check alignment */
>  
>   switch (len) {
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 4dabc31..0f3b57e 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -52,9 +52,6 @@
>  #define PRIu64 "u"
>  #define PRIo64 "o"
>  
> -/* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
> -#define apic_debug(fmt, arg...) do {} while (0)
> -
>  /* 14 is the version for Xeon and Pentium 8.4.8*/
>  #define APIC_VERSION (0x14UL | ((KVM_APIC_LVT_NUM - 1) << 
> 16))
>  #define LAPIC_MMIO_LENGTH(1 << 12)
> @@ -631,7 +628,7 @@ static bool pv_eoi_get_pending(struct kvm_vcpu *vcpu)
>  {
>   u8 val;
>   if (pv_eoi_get_user(vcpu, &val) < 0)
> - apic_debug("Can't read EOI MSR value: 0x%llx\n",
> + printk(KERN_WARNING "Can't read EOI MSR value: 0x%llx\n",
>  (unsigned long long)vcpu->arch.pv_eoi.msr_val);
>   return val & 0x1;
>  }
> @@ -639,7 +636,7 @@ static bool pv_eoi_get_pending(struct kvm_vcpu *vcpu)
>  static void pv_eoi_set_pending(struct kvm_vcpu *vcpu)
>  {
>   if (pv_eoi_put_user(vcpu, KVM_PV_EOI_ENABLED) < 0) {
> - apic_debug("Can't set EOI MSR value: 0x%llx\n",
> + printk(KERN_WARNING "Can't set EOI MSR value: 0x%llx\n",
>  (unsigned long long)vcpu->arch.pv_eoi.msr_val);
>   return;
>   }
> @@ -649,7 +646,7 @@ static void pv_eoi_set_pending(struct kvm_vcpu *vcpu)
>  static void pv_eoi_clr_pending(struct kvm_vcpu *vcpu)
>  {
>   if (pv_eoi_put_user(vcpu, KVM_PV_EOI_DISABLED) < 0) {
> - apic_debug("Can't clear EOI MSR value: 0x%llx\n",
> + printk(KERN_WARNING "Can't clear EOI MSR value: 0x%llx\n",
>  (unsigned long long)vcpu->arch.pv_eoi.msr_val);
>   return;
>   }
> @@ -683,9 +680,6 @@ static bool __apic_update_ppr(struct kvm_lapic *apic, u32 
> *new_ppr)
>   else
>   ppr = isrv & 0xf0;
>  
> - apic_debug("vlapic %p, ppr 0x%x, isr 0x%x, isrv 0x%x",
> -apic, ppr, isr, isrv);
> -
>   *new_ppr = ppr;
>   if (old_ppr != ppr)
>   kvm_lapic_set_reg(apic, APIC_PROCPRI, ppr);
> @@ -762,8 +756,6 @@ static bool kvm_apic_match_logical_addr(struct kvm_lapic 
> *apic, u32 mda)
>   return ((logical_id >> 4) == (mda >> 4))

Re: [PATCH] kvm: x86: ioapic and apic debug macros cleanup

2019-07-14 Thread Yi Wang
Hi Paolo,
Would you help to review this patch, plz?
Many thanks.

---
Best wishes
Yi Wang

> 在 2019年7月6日,01:08,Yi Wang  写道:
> 
> The ioapic_debug and apic_debug have been not used
> for years, and kvm tracepoints are enough for debugging,
> so remove them as Paolo suggested.
> 
> However, there may be something wrong when pv evi get/put
> user, so it's better to retain some log there.
> 
> Signed-off-by: Yi Wang 
> ---
> arch/x86/kvm/ioapic.c | 15 
> arch/x86/kvm/lapic.c  | 98 +--
> 2 files changed, 9 insertions(+), 104 deletions(-)
> 
> diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c
> index 1add1bc..d859ae8 100644
> --- a/arch/x86/kvm/ioapic.c
> +++ b/arch/x86/kvm/ioapic.c
> @@ -45,11 +45,6 @@
> #include "lapic.h"
> #include "irq.h"
> 
> -#if 0
> -#define ioapic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg)
> -#else
> -#define ioapic_debug(fmt, arg...)
> -#endif
> static int ioapic_service(struct kvm_ioapic *vioapic, int irq,
>bool line_status);
> 
> @@ -294,7 +289,6 @@ static void ioapic_write_indirect(struct kvm_ioapic 
> *ioapic, u32 val)
>default:
>index = (ioapic->ioregsel - 0x10) >> 1;
> 
> -ioapic_debug("change redir index %x val %x\n", index, val);
>if (index >= IOAPIC_NUM_PINS)
>return;
>e = &ioapic->redirtbl[index];
> @@ -343,12 +337,6 @@ static int ioapic_service(struct kvm_ioapic *ioapic, int 
> irq, bool line_status)
>entry->fields.remote_irr))
>return -1;
> 
> -ioapic_debug("dest=%x dest_mode=%x delivery_mode=%x "
> - "vector=%x trig_mode=%x\n",
> - entry->fields.dest_id, entry->fields.dest_mode,
> - entry->fields.delivery_mode, entry->fields.vector,
> - entry->fields.trig_mode);
> -
>irqe.dest_id = entry->fields.dest_id;
>irqe.vector = entry->fields.vector;
>irqe.dest_mode = entry->fields.dest_mode;
> @@ -515,7 +503,6 @@ static int ioapic_mmio_read(struct kvm_vcpu *vcpu, struct 
> kvm_io_device *this,
>if (!ioapic_in_range(ioapic, addr))
>return -EOPNOTSUPP;
> 
> -ioapic_debug("addr %lx\n", (unsigned long)addr);
>ASSERT(!(addr & 0xf));/* check alignment */
> 
>addr &= 0xff;
> @@ -558,8 +545,6 @@ static int ioapic_mmio_write(struct kvm_vcpu *vcpu, 
> struct kvm_io_device *this,
>if (!ioapic_in_range(ioapic, addr))
>return -EOPNOTSUPP;
> 
> -ioapic_debug("ioapic_mmio_write addr=%p len=%d val=%p\n",
> - (void*)addr, len, val);
>ASSERT(!(addr & 0xf));/* check alignment */
> 
>switch (len) {
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 4dabc31..0f3b57e 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -52,9 +52,6 @@
> #define PRIu64 "u"
> #define PRIo64 "o"
> 
> -/* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
> -#define apic_debug(fmt, arg...) do {} while (0)
> -
> /* 14 is the version for Xeon and Pentium 8.4.8*/
> #define APIC_VERSION(0x14UL | ((KVM_APIC_LVT_NUM - 1) << 16))
> #define LAPIC_MMIO_LENGTH(1 << 12)
> @@ -631,7 +628,7 @@ static bool pv_eoi_get_pending(struct kvm_vcpu *vcpu)
> {
>u8 val;
>if (pv_eoi_get_user(vcpu, &val) < 0)
> -apic_debug("Can't read EOI MSR value: 0x%llx\n",
> +printk(KERN_WARNING "Can't read EOI MSR value: 0x%llx\n",
>   (unsigned long long)vcpu->arch.pv_eoi.msr_val);
>return val & 0x1;
> }
> @@ -639,7 +636,7 @@ static bool pv_eoi_get_pending(struct kvm_vcpu *vcpu)
> static void pv_eoi_set_pending(struct kvm_vcpu *vcpu)
> {
>if (pv_eoi_put_user(vcpu, KVM_PV_EOI_ENABLED) < 0) {
> -apic_debug("Can't set EOI MSR value: 0x%llx\n",
> +printk(KERN_WARNING "Can't set EOI MSR value: 0x%llx\n",
>   (unsigned long long)vcpu->arch.pv_eoi.msr_val);
>return;
>}
> @@ -649,7 +646,7 @@ static void pv_eoi_set_pending(struct kvm_vcpu *vcpu)
> static void pv_eoi_clr_pending(struct kvm_vcpu *vcpu)
> {
>if (pv_eoi_put_user(vcpu, KVM_PV_EOI_DISABLED) < 0) {
> -apic_debug("Can't clear EOI MSR value: 0x%llx\n",
> +printk(KERN_WARNING "Can't clear EOI MSR value: 0x%llx\n",
>   (unsigned long long)vcpu->arch.pv_eoi.msr_val);
>return;
>}
> @@ -683,9 +680,6 @@ static bool __apic_update_ppr(struct kvm_lapic *apic, u32 
> *new_ppr)
>else
>ppr = isrv & 0xf0;
> 
> -apic_debug("vlapic %p, ppr 0x%x, isr 0x%x, isrv 0x%x",
> -   apic, ppr, isr, isrv);
> -
>*new_ppr = ppr;
>if (old_ppr != ppr)
>kvm_lapic_set_reg(apic, APIC_PROCPRI, ppr);
> @@ -762,8 +756,6 @@ static bool kvm_apic_match_logical_addr(struct kvm_lapic 
> *apic, u32 mda)
>return ((logical_id >> 4) == (mda >> 4))
>   && (logical_id & mda & 0xf) != 0;
>default:
> -apic_debug("Bad DFR vcpu %d: %08x\n",
> -   apic->vcpu->vcpu_id, kvm_lapic_get_reg(apic, APIC_DFR));
>return f

[PATCH] kvm: x86: ioapic and apic debug macros cleanup

2019-07-05 Thread Yi Wang
The ioapic_debug and apic_debug have been not used
for years, and kvm tracepoints are enough for debugging,
so remove them as Paolo suggested.

However, there may be something wrong when pv evi get/put
user, so it's better to retain some log there.

Signed-off-by: Yi Wang 
---
 arch/x86/kvm/ioapic.c | 15 
 arch/x86/kvm/lapic.c  | 98 +--
 2 files changed, 9 insertions(+), 104 deletions(-)

diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c
index 1add1bc..d859ae8 100644
--- a/arch/x86/kvm/ioapic.c
+++ b/arch/x86/kvm/ioapic.c
@@ -45,11 +45,6 @@
 #include "lapic.h"
 #include "irq.h"
 
-#if 0
-#define ioapic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg)
-#else
-#define ioapic_debug(fmt, arg...)
-#endif
 static int ioapic_service(struct kvm_ioapic *vioapic, int irq,
bool line_status);
 
@@ -294,7 +289,6 @@ static void ioapic_write_indirect(struct kvm_ioapic 
*ioapic, u32 val)
default:
index = (ioapic->ioregsel - 0x10) >> 1;
 
-   ioapic_debug("change redir index %x val %x\n", index, val);
if (index >= IOAPIC_NUM_PINS)
return;
e = &ioapic->redirtbl[index];
@@ -343,12 +337,6 @@ static int ioapic_service(struct kvm_ioapic *ioapic, int 
irq, bool line_status)
entry->fields.remote_irr))
return -1;
 
-   ioapic_debug("dest=%x dest_mode=%x delivery_mode=%x "
-"vector=%x trig_mode=%x\n",
-entry->fields.dest_id, entry->fields.dest_mode,
-entry->fields.delivery_mode, entry->fields.vector,
-entry->fields.trig_mode);
-
irqe.dest_id = entry->fields.dest_id;
irqe.vector = entry->fields.vector;
irqe.dest_mode = entry->fields.dest_mode;
@@ -515,7 +503,6 @@ static int ioapic_mmio_read(struct kvm_vcpu *vcpu, struct 
kvm_io_device *this,
if (!ioapic_in_range(ioapic, addr))
return -EOPNOTSUPP;
 
-   ioapic_debug("addr %lx\n", (unsigned long)addr);
ASSERT(!(addr & 0xf));  /* check alignment */
 
addr &= 0xff;
@@ -558,8 +545,6 @@ static int ioapic_mmio_write(struct kvm_vcpu *vcpu, struct 
kvm_io_device *this,
if (!ioapic_in_range(ioapic, addr))
return -EOPNOTSUPP;
 
-   ioapic_debug("ioapic_mmio_write addr=%p len=%d val=%p\n",
-(void*)addr, len, val);
ASSERT(!(addr & 0xf));  /* check alignment */
 
switch (len) {
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 4dabc31..0f3b57e 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -52,9 +52,6 @@
 #define PRIu64 "u"
 #define PRIo64 "o"
 
-/* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
-#define apic_debug(fmt, arg...) do {} while (0)
-
 /* 14 is the version for Xeon and Pentium 8.4.8*/
 #define APIC_VERSION   (0x14UL | ((KVM_APIC_LVT_NUM - 1) << 
16))
 #define LAPIC_MMIO_LENGTH  (1 << 12)
@@ -631,7 +628,7 @@ static bool pv_eoi_get_pending(struct kvm_vcpu *vcpu)
 {
u8 val;
if (pv_eoi_get_user(vcpu, &val) < 0)
-   apic_debug("Can't read EOI MSR value: 0x%llx\n",
+   printk(KERN_WARNING "Can't read EOI MSR value: 0x%llx\n",
   (unsigned long long)vcpu->arch.pv_eoi.msr_val);
return val & 0x1;
 }
@@ -639,7 +636,7 @@ static bool pv_eoi_get_pending(struct kvm_vcpu *vcpu)
 static void pv_eoi_set_pending(struct kvm_vcpu *vcpu)
 {
if (pv_eoi_put_user(vcpu, KVM_PV_EOI_ENABLED) < 0) {
-   apic_debug("Can't set EOI MSR value: 0x%llx\n",
+   printk(KERN_WARNING "Can't set EOI MSR value: 0x%llx\n",
   (unsigned long long)vcpu->arch.pv_eoi.msr_val);
return;
}
@@ -649,7 +646,7 @@ static void pv_eoi_set_pending(struct kvm_vcpu *vcpu)
 static void pv_eoi_clr_pending(struct kvm_vcpu *vcpu)
 {
if (pv_eoi_put_user(vcpu, KVM_PV_EOI_DISABLED) < 0) {
-   apic_debug("Can't clear EOI MSR value: 0x%llx\n",
+   printk(KERN_WARNING "Can't clear EOI MSR value: 0x%llx\n",
   (unsigned long long)vcpu->arch.pv_eoi.msr_val);
return;
}
@@ -683,9 +680,6 @@ static bool __apic_update_ppr(struct kvm_lapic *apic, u32 
*new_ppr)
else
ppr = isrv & 0xf0;
 
-   apic_debug("vlapic %p, ppr 0x%x, isr 0x%x, isrv 0x%x",
-  apic, ppr, isr, isrv);
-
*new_ppr = ppr;
if (old_ppr != ppr)
kvm_lapic_set_reg(apic, APIC_PROCPRI, ppr);
@@ -762,8 +756,6 @@ static bool kvm_apic_match_logical_addr(struct kvm_lapic 
*apic, u32 mda)
return ((logical_id >> 4) == (mda >> 4))
   && (logical_id & mda & 0xf) != 0;
default:
-   apic_debug("Bad DFR vcpu %d: %08x\n",
-  apic->vcpu->vcpu_id, kvm