#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)
 {
        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;
 }
 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;
        }
 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;
        }
        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);
                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 false;
        }
 }
        struct kvm_lapic *target = vcpu->arch.apic;
        u32 mda = kvm_apic_mda(vcpu, dest, source, target);
 
-       apic_debug("target %p, source %p, dest 0x%x, "
-                  "dest_mode 0x%x, short_hand 0x%x\n",
-                  target, source, dest, dest_mode, short_hand);
-
        ASSERT(target);
        switch (short_hand) {
        case APIC_DEST_NOSHORT:
        case APIC_DEST_ALLBUT:
                return target != source;
        default:
-               apic_debug("kvm: apic: Bad dest shorthand value %x\n",
-                          short_hand);
                return false;
        }
 }
                        smp_wmb();
                        kvm_make_request(KVM_REQ_EVENT, vcpu);
                        kvm_vcpu_kick(vcpu);
-               } else {
-                       apic_debug("Ignoring de-assert INIT to vcpu %d\n",
-                                  vcpu->vcpu_id);
                }
                break;
 
        case APIC_DM_STARTUP:
-               apic_debug("SIPI to vcpu %d vector 0x%02x\n",
-                          vcpu->vcpu_id, vector);
                result = 1;
                apic->sipi_vector = vector;
                /* make sure sipi_vector is visible for the receiver */
 
        trace_kvm_apic_ipi(icr_low, irq.dest_id);
 
-       apic_debug("icr_high 0x%x, icr_low 0x%x, "
-                  "short_hand 0x%x, dest 0x%x, trig_mode 0x%x, level 0x%x, "
-                  "dest_mode 0x%x, delivery_mode 0x%x, vector 0x%x, "
-                  "msi_redir_hint 0x%x\n",
-                  icr_high, icr_low, irq.shorthand, irq.dest_id,
-                  irq.trig_mode, irq.level, irq.dest_mode, irq.delivery_mode,
-                  irq.vector, irq.msi_redir_hint);
-
        kvm_irq_delivery_to_apic(apic->vcpu->kvm, apic, &irq, NULL);
 }
 
 
        switch (offset) {
        case APIC_ARBPRI:
-               apic_debug("Access APIC ARBPRI register which is for P6\n");
                break;
 
        case APIC_TMCCT:        /* Timer CCR */
        if (!apic_x2apic_mode(apic))
                valid_reg_mask |= APIC_REG_MASK(APIC_ARBPRI);
 
-       if (offset > 0x3f0 || !(valid_reg_mask & APIC_REG_MASK(offset))) {
-               apic_debug("KVM_APIC_READ: read reserved register %x\n",
-                          offset);
+       if (offset > 0x3f0 || !(valid_reg_mask & APIC_REG_MASK(offset)))
                return 1;
-       }
 
        result = __apic_read(apic, offset & ~0xf);
 
        tmp1 = tdcr & 0xf;
        tmp2 = ((tmp1 & 0x3) | ((tmp1 & 0x8) >> 1)) + 1;
        apic->divide_count = 0x1 << (tmp2 & 0x7);
-
-       apic_debug("timer divide count is 0x%x\n",
-                                  apic->divide_count);
 }
 
 static void limit_periodic_timer_frequency(struct kvm_lapic *apic)
 
        limit_periodic_timer_frequency(apic);
 
-       apic_debug("%s: bus cycle is %" PRId64 "ns, now 0x%016"
-                  PRIx64 ", "
-                  "timer initial count 0x%x, period %lldns, "
-                  "expire @ 0x%016" PRIx64 ".\n", __func__,
-                  APIC_BUS_CYCLE_NS, ktime_to_ns(now),
-                  kvm_lapic_get_reg(apic, APIC_TMICT),
-                  apic->lapic_timer.period,
-                  ktime_to_ns(ktime_add_ns(now,
-                               apic->lapic_timer.period)));
-
        apic->lapic_timer.tscdeadline = kvm_read_l1_tsc(apic->vcpu, tscl) +
                nsec_to_cycles(apic->vcpu, apic->lapic_timer.period);
        apic->lapic_timer.target_expiration = ktime_add_ns(now, apic->lapic_timer.period);
        if (apic->lvt0_in_nmi_mode != lvt0_in_nmi_mode) {
                apic->lvt0_in_nmi_mode = lvt0_in_nmi_mode;
                if (lvt0_in_nmi_mode) {
-                       apic_debug("Receive NMI setting on APIC_LVT0 "
-                                  "for cpu %d\n", apic->vcpu->vcpu_id);
                        atomic_inc(&apic->vcpu->kvm->arch.vapics_in_nmi_mode);
                } else
                        atomic_dec(&apic->vcpu->kvm->arch.vapics_in_nmi_mode);
        case APIC_TDCR: {
                uint32_t old_divisor = apic->divide_count;
 
-               if (val & 4)
-                       apic_debug("KVM_WRITE:TDCR %x\n", val);
                kvm_lapic_set_reg(apic, APIC_TDCR, val);
                update_divide_count(apic);
                if (apic->divide_count != old_divisor &&
                break;
        }
        case APIC_ESR:
-               if (apic_x2apic_mode(apic) && val != 0) {
-                       apic_debug("KVM_WRITE:ESR not zero %x\n", val);
+               if (apic_x2apic_mode(apic) && val != 0)
                        ret = 1;
-               }
                break;
 
        case APIC_SELF_IPI:
                ret = 1;
                break;
        }
-       if (ret)
-               apic_debug("Local APIC Write to read-only register %x\n", reg);
+
        return ret;
 }
 EXPORT_SYMBOL_GPL(kvm_lapic_reg_write);
         * 32/64/128 bits registers must be accessed thru 32 bits.
         * Refer SDM 8.4.1
         */
-       if (len != 4 || (offset & 0xf)) {
-               /* Don't shout loud, $infamous_os would cause only noise. */
-               apic_debug("apic write: bad size=%d %lx\n", len, (long)address);
+       if (len != 4 || (offset & 0xf))
                return 0;
-       }
 
        val = *(u32*)data;
 
-       /* too common printing */
-       if (offset != APIC_EOI)
-               apic_debug("%s: offset 0x%x with length 0x%x, and value is "
-                          "0x%x\n", __func__, offset, len, val);
-
-       kvm_lapic_reg_write(apic, offset, val);
+       kvm_lapic_reg_write(apic, offset & 0xff0, val);
 
        return 0;
 }
        if ((value & MSR_IA32_APICBASE_ENABLE) &&
             apic->base_address != APIC_DEFAULT_PHYS_BASE)
                pr_warn_once("APIC base relocation is unsupported by KVM");
-
-       /* with FSB delivery interrupt, we can restart APIC functionality */
-       apic_debug("apic base msr is 0x%016" PRIx64 ", and base address is "
-                  "0x%lx.\n", apic->vcpu->arch.apic_base, apic->base_address);
-
 }
 
 void kvm_lapic_reset(struct kvm_vcpu *vcpu, bool init_event)
        if (!apic)
                return;
 
-       apic_debug("%s\n", __func__);
-
        /* Stop the timer in case it's a reset to an active apic */
        hrtimer_cancel(&apic->lapic_timer.timer);
 
 
        vcpu->arch.apic_arb_prio = 0;
        vcpu->arch.apic_attention = 0;
-
-       apic_debug("%s: vcpu=%p, id=0x%x, base_msr="
-                  "0x%016" PRIx64 ", base_address=0x%0lx.\n", __func__,
-                  vcpu, kvm_lapic_get_reg(apic, APIC_ID),
-                  vcpu->arch.apic_base, apic->base_address);
 }
 
 /*
        struct kvm_lapic *apic;
 
        ASSERT(vcpu != NULL);
-       apic_debug("apic_init %d\n", vcpu->vcpu_id);
 
        apic = kzalloc(sizeof(*apic), GFP_KERNEL_ACCOUNT);
        if (!apic)
        if (!lapic_in_kernel(vcpu) || !apic_x2apic_mode(apic))
                return 1;
 
-       if (reg == APIC_DFR || reg == APIC_ICR2) {
-               apic_debug("KVM_APIC_READ: read x2apic reserved register %x\n",
-                          reg);
+       if (reg == APIC_DFR || reg == APIC_ICR2)
                return 1;
-       }
 
        if (kvm_lapic_reg_read(apic, reg, 4, &low))
                return 1;
                /* evaluate pending_events before reading the vector */
                smp_rmb();
                sipi_vector = apic->sipi_vector;
-               apic_debug("vcpu %d received sipi with vector # %x\n",
-                        vcpu->vcpu_id, sipi_vector);
                kvm_vcpu_deliver_sipi_vector(vcpu, sipi_vector);
                vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
        }