Skip to contentSkip to conversation

addition of loglevel for printf in Xen HV

RFC PATCH Superseded Steven Rostedt 1 participant 2 messages Oct 2, 2006

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 addition of loglevel for printf in Xen HV

In the current implementation, the logging in the Hypervisor is basically at two levels. The developer can print "always" or "verbose".
The always print is when the developer uses "printk/printf" in the
hypervisor. The "verbose" is when the developer uses DPRINTK, since the DPRINTK macro is only defined when the "verbose" flag is set.

Now the problem we are having, is that when we send out a distribution, we want enough information to be printed if one of our customers has a problem. But we also don't want to have so much printed that it affects the performance of the system. Or worst yet, if the system has a serial console attached, one of the DomU's could in essence cause a DoS attack on the whole system by causing the DomU to do certain errors that causes a thousand prints to the serial console. These prints are done with interrupts disabled, so the system suffers large latencies for each print.

Since it would be helpful to have prints for different environments, I've introduced with this patch a Linux like loglevel from 0-7. When the user sets the loglevel to 0, only emergency prints are preformed, and when 7 is selected, all prints are done.

Here's the list of levels that I have added:

#define XEN_EMERG   "<0>"
#define XEN_ALERT   "<1>"
#define XEN_CRIT    "<2>"
#define XEN_ERR     "<3>"
#define XEN_WARNING "<4>"
#define XEN_GUEST   "<5>"
#define XEN_INFO    "<6>"
#define XEN_DEBUG   "<7>"

Basically, these correspond to their Linux equivalents. The one difference, is that the KERN_NOTICE was replaced by XEN_GUEST. The XEN_GUEST is the level that a guest can "at will" cause this print. So a distribution can set the print log level to 4 (XEN_WARNING) and all prints that are of errors and can be used for debugging are now available, without the prints that allow a Guest to cause a DoS.

I also added the keyhandlers '0' to '7' to allow the user to change the loglevel on a running system to the corresponding key. This is similar to the way Linux uses sysrq to change its log levels.

Two things that are not implemented with this patch but should be, and thus the RFC in the subject.

1. How to default the log level on build. Should the verbose now be a number, and not a config? i.e. VERBOSE=4

2. How the user in Linux can change the log level (from dom0). Should we add a hypercall or some other method to allow the user to change the logging?

Also, I made a pass though to assign all DPRINTK a log level. I may not have done this correctly. But a loglevel of 7 is now the same a VERBOSE=y and a loglevel of 0 is almost the same of a VERBOSE=n. There was a couple of places where XEN_EMERG was used.

This patch really does need to go in. Whether in its current form, or modified greatly. The ability to give the developer a level of printing is a great asset. That is why Linux has this ability.

-- Steve

xen/arch/ia64/vmx/vlsapic.c +2 -2
diff -r 96a77ef725b8 xen/arch/ia64/vmx/vlsapic.c
@@ -389,7 +389,7 @@ void vlsapic_reset(VCPU *vcpu)
     vcpu->arch.arch_vmx.vlapic.vcpu = vcpu;
     hvm_vioapic_add_lapic(&vcpu->arch.arch_vmx.vlapic, vcpu);
 #endif
-    DPRINTK("VLSAPIC inservice base=%p\n", &VLSAPIC_INSVC(vcpu,0) );
+    DPRINTK(XEN_INFO "VLSAPIC inservice base=%p\n", &VLSAPIC_INSVC(vcpu,0) );
 }
 
 /*
@@ -518,7 +518,7 @@ int vmx_vcpu_pend_interrupt(VCPU *vcpu, 
     int ret;
 
     if (vector & ~0xff) {
-        DPRINTK("vmx_vcpu_pend_interrupt: bad vector\n");
+        DPRINTK(XEN_GUEST "vmx_vcpu_pend_interrupt: bad vector\n");
         return -1;
     }
     local_irq_save(spsr);
xen/arch/ia64/vmx/vmx_hypercall.c +1 -1
diff -r 96a77ef725b8 xen/arch/ia64/vmx/vmx_hypercall.c
@@ -79,7 +79,7 @@ do_hvm_op(unsigned long op, XEN_GUEST_HA
     }
 
     default:
-        DPRINTK("Bad HVM op %ld.\n", op);
+        DPRINTK(XEN_GUEST "Bad HVM op %ld.\n", op);
         rc = -ENOSYS;
     }
     return rc;
xen/arch/ia64/vmx/vmx_init.c +1 -1
diff -r 96a77ef725b8 xen/arch/ia64/vmx/vmx_init.c
@@ -277,7 +277,7 @@ static void vmx_create_event_channels(st
 			p = get_vio(v->domain, o->vcpu_id);
 			o->arch.arch_vmx.xen_port = p->vp_eport =
 			                alloc_unbound_xen_event_channel(o, 0);
-			DPRINTK("Allocated port %d for hvm.\n",
+			DPRINTK(XEN_GUEST "Allocated port %d for hvm.\n",
 			        o->arch.arch_vmx.xen_port);
 		}
 	}
xen/arch/ia64/xen/dom0_ops.c +2 -1
diff -r 96a77ef725b8 xen/arch/ia64/xen/dom0_ops.c
@@ -252,7 +252,8 @@ do_dom0vp_op(unsigned long cmd,
     case IA64_DOM0VP_phystomach:
         ret = ____lookup_domain_mpa(d, arg0 << PAGE_SHIFT);
         if (ret == INVALID_MFN) {
-            DPRINTK("%s:%d INVALID_MFN ret: 0x%lx\n", __func__, __LINE__, ret);
+            DPRINTK(XEN_INFO "%s:%d INVALID_MFN ret: 0x%lx\n",
+                     __func__, __LINE__, ret);
         } else {
             ret = (ret & _PFN_MASK) >> PAGE_SHIFT;//XXX pte_pfn()
         }
xen/arch/ia64/xen/domain.c +1 -1
diff -r 96a77ef725b8 xen/arch/ia64/xen/domain.c
@@ -625,7 +625,7 @@ int shadow_mode_control(struct domain *d
 	//struct vcpu *v;
 
 	if (unlikely(d == current->domain)) {
-		DPRINTK("Don't try to do a shadow op on yourself!\n");
+		DPRINTK(XEN_GUEST "Don't try to do a shadow op on yourself!\n");
 		return -EINVAL;
 	}   
 
xen/arch/ia64/xen/irq.c +8 -4
diff -r 96a77ef725b8 xen/arch/ia64/xen/irq.c
@@ -377,7 +377,7 @@ int pirq_guest_bind(struct vcpu *v, int 
     {
         if ( desc->action != NULL )
         {
-            DPRINTK("Cannot bind IRQ %d to guest. In use by '%s'.\n",
+            DPRINTK(XEN_GUEST "Cannot bind IRQ %d to guest. In use by '%s'.\n",
                     irq, desc->action->name);
             rc = -EBUSY;
             goto out;
@@ -386,7 +386,8 @@ int pirq_guest_bind(struct vcpu *v, int 
         action = xmalloc(irq_guest_action_t);
         if ( (desc->action = (struct irqaction *)action) == NULL )
         {
-            DPRINTK("Cannot bind IRQ %d to guest. Out of memory.\n", irq);
+            DPRINTK(XEN_GUEST "Cannot bind IRQ %d to guest. Out of memory.\n",
+                    irq);
             rc = -ENOMEM;
             goto out;
         }
@@ -410,7 +411,8 @@ int pirq_guest_bind(struct vcpu *v, int 
     }
     else if ( !will_share || !action->shareable )
     {
-        DPRINTK("Cannot bind IRQ %d to guest. Will not share with others.\n",
+        DPRINTK(XEN_GUEST "Cannot bind IRQ %d to guest. "
+                           "Will not share with others.\n",
                 irq);
         rc = -EBUSY;
         goto out;
@@ -418,7 +420,9 @@ int pirq_guest_bind(struct vcpu *v, int 
 
     if ( action->nr_guests == IRQ_MAX_GUESTS )
     {
-        DPRINTK("Cannot bind IRQ %d to guest. Already at max share.\n", irq);
+        DPRINTK(XEN_GUEST "Cannot bind IRQ %d to guest. "
+                           "Already at max share.\n",
+                            irq);
         rc = -EBUSY;
         goto out;
     }
xen/arch/ia64/xen/mm.c +26 -19

156 lines not on this page · raw message

xen/arch/ia64/xen/vcpu.c +1 -1
diff -r 96a77ef725b8 xen/arch/ia64/xen/vcpu.c
@@ -1442,7 +1442,7 @@ again:
 			set_metaphysical_rr0();
 		}
 		if (bundle->i64[0] == 0 && bundle->i64[1] == 0) {
-			DPRINTK("%s gip 0x%lx\n", __func__, gip);
+			DPRINTK(XEN_INFO "%s gip 0x%lx\n", __func__, gip);
 			return 0;
 		}
 		return 1;
xen/arch/powerpc/mm.c +1 -1
diff -r 96a77ef725b8 xen/arch/powerpc/mm.c
@@ -268,7 +268,7 @@ int allocate_rma(struct domain *d, unsig
 
     d->arch.rma_page = alloc_domheap_pages(d, order, 0);
     if (d->arch.rma_page == NULL) {
-        DPRINTK("Could not allocate order=%d RMA for domain %u\n",
+        DPRINTK(XEN_GUEST "Could not allocate order=%d RMA for domain %u\n",
                 order, d->domain_id);
         return -ENOMEM;
     }
xen/arch/powerpc/shadow.c +2 -2
diff -r 96a77ef725b8 xen/arch/powerpc/shadow.c
@@ -120,14 +120,14 @@ int shadow_domctl(struct domain *d,
 {
     if ( unlikely(d == current->domain) )
     {
-        DPRINTK("Don't try to do a shadow op on yourself!\n");
+        DPRINTK(XEN_GUEST "Don't try to do a shadow op on yourself!\n");
         return -EINVAL;
     }
 
     switch ( sc->op )
     {
     case XEN_DOMCTL_SHADOW_OP_OFF:
-         DPRINTK("Shadow is mandatory!\n");
+         DPRINTK(XEN_GUEST "Shadow is mandatory!\n");
          return -EINVAL;
 
     case XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION:
xen/arch/x86/domain.c +2 -1
diff -r 96a77ef725b8 xen/arch/x86/domain.c
@@ -556,7 +556,8 @@ static void load_segments(struct vcpu *n
              put_user(regs->r11,           rsp-10) |
              put_user(regs->rcx,           rsp-11) )
         {
-            DPRINTK("Error while creating failsafe callback frame.\n");
+            DPRINTK(XEN_GUEST "Error while creating failsafe "
+                    "callback frame.\n");
             domain_crash(n->domain);
         }
 
xen/arch/x86/extable.c +1 -1
diff -r 96a77ef725b8 xen/arch/x86/extable.c
@@ -74,7 +74,7 @@ search_pre_exception_table(struct cpu_us
     unsigned long addr = (unsigned long)regs->eip;
     unsigned long fixup = search_one_table(
         __start___pre_ex_table, __stop___pre_ex_table-1, addr);
-    DPRINTK("Pre-exception: %p -> %p\n", _p(addr), _p(fixup));
+    DPRINTK(XEN_INFO "Pre-exception: %p -> %p\n", _p(addr), _p(fixup));
 #ifdef PERF_COUNTERS
     if ( fixup )
         perfc_incrc(exception_fixed);
xen/arch/x86/hvm/hvm.c +14 -11
diff -r 96a77ef725b8 xen/arch/x86/hvm/hvm.c
@@ -192,7 +192,8 @@ void hvm_create_event_channels(struct vc
             p = get_vio(v->domain, o->vcpu_id);
             o->arch.hvm_vcpu.xen_port = p->vp_eport =
                 alloc_unbound_xen_event_channel(o, 0);
-            DPRINTK("Allocated port %d for hvm.\n", o->arch.hvm_vcpu.xen_port);
+            DPRINTK(XEN_INFO "Allocated port %d for hvm.\n",
+                    o->arch.hvm_vcpu.xen_port);
         }
     }
 }
@@ -343,7 +344,8 @@ static void hvm_vcpu_down(void)
     struct domain *d = v->domain;
     int online_count = 0;
 
-    DPRINTK("DOM%d/VCPU%d: going offline.\n", d->domain_id, v->vcpu_id);
+    DPRINTK(XEN_GUEST "DOM%d/VCPU%d: going offline.\n",
+           d->domain_id, v->vcpu_id);
 
     /* Doesn't halt us immediately, but we'll never return to guest context. */
     set_bit(_VCPUF_down, &v->vcpu_flags);
@@ -359,7 +361,8 @@ static void hvm_vcpu_down(void)
     /* ... Shut down the domain if not. */
     if ( online_count == 0 )
     {
-        DPRINTK("DOM%d: all CPUs offline -- powering off.\n", d->domain_id);
+        DPRINTK(XEN_GUEST "DOM%d: all CPUs offline -- powering off.\n",
+                d->domain_id);
         domain_shutdown(d, SHUTDOWN_poweroff);
     }
 }
@@ -499,7 +502,7 @@ void hvm_do_hypercall(struct cpu_user_re
 
     if ( (pregs->eax >= NR_hypercalls) || !hvm_hypercall_table[pregs->eax] )
     {
-        DPRINTK("HVM vcpu %d:%d did a bad hypercall %d.\n",
+        DPRINTK(XEN_GUEST "HVM vcpu %d:%d did a bad hypercall %d.\n",
                 current->domain->domain_id, current->vcpu_id,
                 pregs->eax);
         pregs->eax = -ENOSYS;
@@ -545,7 +548,7 @@ static long do_memory_op_compat32(int cm
     }
 
     default:
-        DPRINTK("memory_op %d.\n", cmd);
+        DPRINTK(XEN_GUEST "memory_op %d.\n", cmd);
         rc = -ENOSYS;
         break;
     }
@@ -578,7 +581,7 @@ void hvm_do_hypercall(struct cpu_user_re
     pregs->rax = (uint32_t)pregs->eax; /* mask in case compat32 caller */
     if ( (pregs->rax >= NR_hypercalls) || !hvm_hypercall64_table[pregs->rax] )
     {
-        DPRINTK("HVM vcpu %d:%d did a bad hypercall %ld.\n",
+        DPRINTK(XEN_GUEST "HVM vcpu %d:%d did a bad hypercall %ld.\n",
                 current->domain->domain_id, current->vcpu_id,
                 pregs->rax);
         pregs->rax = -ENOSYS;
@@ -629,7 +632,7 @@ int hvm_bringup_ap(int vcpuid, int tramp
 
     if ( bsp->vcpu_id != 0 )
     {
-        DPRINTK("Not calling hvm_bringup_ap from BSP context.\n");
+        DPRINTK(XEN_GUEST "Not calling hvm_bringup_ap from BSP context.\n");
         domain_crash_synchronous();
     }
 
@@ -638,7 +641,7 @@ int hvm_bringup_ap(int vcpuid, int tramp
 
     if ( (ctxt = xmalloc(struct vcpu_guest_context)) == NULL )
     {
-        DPRINTK("Failed to allocate memory in hvm_bringup_ap.\n");
+        DPRINTK(XEN_GUEST "Failed to allocate memory in hvm_bringup_ap.\n");
         return -ENOMEM;
     }
 
@@ -652,13 +655,13 @@ int hvm_bringup_ap(int vcpuid, int tramp
 
     if ( rc != 0 )
     {
-        DPRINTK("AP %d bringup failed in boot_vcpu %x.\n", vcpuid, rc);
+        DPRINTK(XEN_GUEST "AP %d bringup failed in boot_vcpu %x.\n", vcpuid, rc);
         return rc;
     }
 
     if ( test_and_clear_bit(_VCPUF_down, &d->vcpu[vcpuid]->vcpu_flags) )
         vcpu_wake(d->vcpu[vcpuid]);
-    DPRINTK("AP %d bringup suceeded.\n", vcpuid);
+    DPRINTK(XEN_INFO "AP %d bringup suceeded.\n", vcpuid);
 
     xfree(ctxt);
 
@@ -717,7 +720,7 @@ long do_hvm_op(unsigned long op, XEN_GUE
 
     default:
     {
-        DPRINTK("Bad HVM op %ld.\n", op);
+        DPRINTK(XEN_GUEST "Bad HVM op %ld.\n", op);
         rc = -ENOSYS;
         break;
     }
xen/arch/x86/hvm/instrlen.c +2 -2
diff -r 96a77ef725b8 xen/arch/x86/hvm/instrlen.c
@@ -317,7 +317,7 @@ done_prefixes:
 
         if ( modrm_mod == 3 )
         {
-            DPRINTK("Cannot parse ModRM.mod == 3.\n");
+            DPRINTK(XEN_GUEST "Cannot parse ModRM.mod == 3.\n");
             goto cannot_emulate;
         }
 
@@ -444,7 +444,7 @@ done:
     return length;
 
 cannot_emulate:
-    DPRINTK("Cannot emulate %02x at address %lx (eip %lx, mode %d)\n",
+    DPRINTK(XEN_GUEST "Cannot emulate %02x at address %lx (eip %lx, mode %d)\n",
             b, (unsigned long)_regs.eip, (unsigned long)regs->eip, mode);
     return -1;
 }
xen/arch/x86/hvm/svm/svm.c +1 -1
diff -r 96a77ef725b8 xen/arch/x86/hvm/svm/svm.c
@@ -806,7 +806,7 @@ static void svm_final_setup_guest(struct
 
     if ( !shadow_mode_external(d) )
     {
-        DPRINTK("Can't init HVM for dom %u vcpu %u: "
+        DPRINTK(XEN_WARNING "Can't init HVM for dom %u vcpu %u: "
                 "not in shadow external mode\n", d->domain_id, v->vcpu_id);
         domain_crash(d);
     }
xen/arch/x86/hvm/vmx/vmcs.c +1 -1
diff -r 96a77ef725b8 xen/arch/x86/hvm/vmx/vmcs.c
@@ -145,7 +145,7 @@ static struct vmcs_struct *vmx_alloc_vmc
 
     if ( (vmcs = alloc_xenheap_page()) == NULL )
     {
-        DPRINTK("Failed to allocate VMCS.\n");
+        DPRINTK(XEN_GUEST "Failed to allocate VMCS.\n");
         return NULL;
     }
 
xen/arch/x86/hvm/vmx/vmx.c +4 -4
diff -r 96a77ef725b8 xen/arch/x86/hvm/vmx/vmx.c
@@ -71,7 +71,7 @@ static int vmx_initialize_guest_resource
 
     if ( !shadow_mode_external(d) )
     {
-        DPRINTK("Can't init HVM for dom %u vcpu %u: "
+        DPRINTK(XEN_WARNING "Can't init HVM for dom %u vcpu %u: "
                 "not in shadow external mode\n", 
                 d->domain_id, v->vcpu_id);
         domain_crash(d);
@@ -83,7 +83,7 @@ static int vmx_initialize_guest_resource
 
         if ( (rc = vmx_create_vmcs(vc)) != 0 )
         {
-            DPRINTK("Failed to create VMCS for vcpu %d: err=%d.\n",
+            DPRINTK(XEN_WARNING "Failed to create VMCS for vcpu %d: err=%d.\n",
                     vc->vcpu_id, rc);
             return 0;
         }
@@ -92,14 +92,14 @@ static int vmx_initialize_guest_resource
 
         if ( (io_bitmap_a = alloc_xenheap_pages(IO_BITMAP_ORDER)) == NULL )
         {
-            DPRINTK("Failed to allocate io bitmap b for vcpu %d.\n",
+            DPRINTK(XEN_WARNING "Failed to allocate io bitmap b for vcpu %d.\n",
                     vc->vcpu_id);
             return 0;
         }
 
         if ( (io_bitmap_b = alloc_xenheap_pages(IO_BITMAP_ORDER)) == NULL )
         {
-            DPRINTK("Failed to allocate io bitmap b for vcpu %d.\n",
+            DPRINTK(XEN_WARNING "Failed to allocate io bitmap b for vcpu %d.\n",
                     vc->vcpu_id);
             return 0;
         }
xen/arch/x86/io_apic.c +2 -1
diff -r 96a77ef725b8 xen/arch/x86/io_apic.c
@@ -1983,7 +1983,8 @@ int ioapic_guest_read(unsigned long phys
 }
 
 #define WARN_BOGUS_WRITE(f, a...)                                       \
-    DPRINTK("\n%s: apic=%d, pin=%d, old_irq=%d, new_irq=%d\n"           \
+    DPRINTK(XEN_INFO "\n%s: "                                           \
+            "apic=%d, pin=%d, old_irq=%d, new_irq=%d\n"                 \
             "%s: old_entry=%08x, new_entry=%08x\n"                      \
             "%s: " f, __FUNCTION__, apic, pin, old_irq, new_irq,        \
             __FUNCTION__, *(u32 *)&old_rte, *(u32 *)&new_rte,           \
xen/arch/x86/irq.c +7 -4
diff -r 96a77ef725b8 xen/arch/x86/irq.c
@@ -432,7 +432,7 @@ int pirq_guest_bind(struct vcpu *v, int 
     {
         if ( desc->action != NULL )
         {
-            DPRINTK("Cannot bind IRQ %d to guest. In use by '%s'.\n",
+            DPRINTK(XEN_GUEST "Cannot bind IRQ %d to guest. In use by '%s'.\n",
                     irq, desc->action->name);
             rc = -EBUSY;
             goto out;
@@ -441,7 +441,8 @@ int pirq_guest_bind(struct vcpu *v, int 
         action = xmalloc(irq_guest_action_t);
         if ( (desc->action = (struct irqaction *)action) == NULL )
         {
-            DPRINTK("Cannot bind IRQ %d to guest. Out of memory.\n", irq);
+            DPRINTK(XEN_GUEST "Cannot bind IRQ %d to guest. Out of memory.\n",
+                    irq);
             rc = -ENOMEM;
             goto out;
         }
@@ -464,7 +465,8 @@ int pirq_guest_bind(struct vcpu *v, int 
     }
     else if ( !will_share || !action->shareable )
     {
-        DPRINTK("Cannot bind IRQ %d to guest. Will not share with others.\n",
+        DPRINTK(XEN_GUEST "Cannot bind IRQ %d to guest. "
+               "Will not share with others.\n",
                 irq);
         rc = -EBUSY;
         goto out;
@@ -484,7 +486,8 @@ int pirq_guest_bind(struct vcpu *v, int 
 
     if ( action->nr_guests == IRQ_MAX_GUESTS )
     {
-        DPRINTK("Cannot bind IRQ %d to guest. Already at max share.\n", irq);
+        DPRINTK(XEN_GUEST "Cannot bind IRQ %d to guest. "
+               "Already at max share.\n", irq);
         rc = -EBUSY;
         goto out;
     }
xen/arch/x86/mm.c +2 -2
diff -r 96a77ef725b8 xen/arch/x86/mm.c
@@ -2258,7 +2258,7 @@ int do_mmu_update(
             {
                 if ( shadow_mode_refcounts(d) )
                 {
-                    DPRINTK("mmu update on shadow-refcounted domain!");
+                    DPRINTK(XEN_INFO "mmu update on shadow-refcounted domain!");
                     break;
                 }
 
@@ -2622,7 +2622,7 @@ int steal_page(
         x = y;
         if (unlikely((x & (PGC_count_mask|PGC_allocated)) !=
                      (1 | PGC_allocated)) || unlikely(_nd != _d)) { 
-            DPRINTK("gnttab_transfer: Bad page %p: ed=%p(%u), sd=%p,"
+            DPRINTK(XEN_GUEST "gnttab_transfer: Bad page %p: ed=%p(%u), sd=%p,"
                     " caf=%08x, taf=%" PRtype_info "\n", 
                     (void *) page_to_mfn(page),
                     d, d->domain_id, unpickle_domptr(_nd), x, 
xen/arch/x86/mm/shadow/common.c +1 -1
diff -r 96a77ef725b8 xen/arch/x86/mm/shadow/common.c
@@ -3041,7 +3041,7 @@ int shadow_domctl(struct domain *d,
 
     if ( unlikely(d == current->domain) )
     {
-        DPRINTK("Don't try to do a shadow op on yourself!\n");
+        DPRINTK(XEN_GUEST "Don't try to do a shadow op on yourself!\n");
         return -EINVAL;
     }
 
xen/arch/x86/platform_hypercall.c +1 -1
diff -r 96a77ef725b8 xen/arch/x86/platform_hypercall.c
@@ -125,7 +125,7 @@ long do_platform_op(XEN_GUEST_HANDLE(xen
         case QUIRK_IOAPIC_GOOD_REGSEL:
 #ifndef sis_apic_bug
             sis_apic_bug = (quirk_id == QUIRK_IOAPIC_BAD_REGSEL);
-            DPRINTK("Domain 0 says that IO-APIC REGSEL is %s\n",
+            DPRINTK(XEN_INFO "Domain 0 says that IO-APIC REGSEL is %s\n",
                     sis_apic_bug ? "bad" : "good");
 #else
             BUG_ON(sis_apic_bug != (quirk_id == QUIRK_IOAPIC_BAD_REGSEL));
xen/arch/x86/traps.c +15 -13
diff -r 96a77ef725b8 xen/arch/x86/traps.c
@@ -407,7 +407,8 @@ static inline int do_trap(int trapnr, ch
 
     if ( likely((fixup = search_exception_table(regs->eip)) != 0) )
     {
-        DPRINTK("Trap %d: %p -> %p\n", trapnr, _p(regs->eip), _p(fixup));
+        DPRINTK(XEN_EMERG "Trap %d: %p -> %p\n",
+                trapnr, _p(regs->eip), _p(fixup));
         regs->eip = fixup;
         return 0;
     }
@@ -475,7 +476,7 @@ int wrmsr_hypervisor_regs(
 
         if ( idx > 0 )
         {
-            DPRINTK("Dom%d: Out of range index %u to MSR %08x\n",
+            DPRINTK(XEN_GUEST "Dom%d: Out of range index %u to MSR %08x\n",
                     d->domain_id, idx, 0x40000000);
             return 0;
         }
@@ -485,7 +486,7 @@ int wrmsr_hypervisor_regs(
         if ( !mfn_valid(mfn) ||
              !get_page_and_type(mfn_to_page(mfn), d, PGT_writable_page) )
         {
-            DPRINTK("Dom%d: Bad GMFN %lx (MFN %lx) to MSR %08x\n",
+            DPRINTK(XEN_GUEST "Dom%d: Bad GMFN %lx (MFN %lx) to MSR %08x\n",
                     d->domain_id, gmfn, mfn, 0x40000000);
             return 0;
         }
@@ -832,17 +833,18 @@ static int __spurious_page_fault(
         return 0;
 
  spurious:
-    DPRINTK("Spurious fault in domain %u:%u at addr %lx, e/c %04x\n",
+    DPRINTK(XEN_WARNING "Spurious fault in domain %u:%u "
+            "at addr %lx, e/c %04x\n",
             current->domain->domain_id, current->vcpu_id,
             addr, regs->error_code);
 #if CONFIG_PAGING_LEVELS >= 4
-    DPRINTK(" l4e = %"PRIpte"\n", l4e_get_intpte(l4e));
+    DPRINTK(XEN_WARNING " l4e = %"PRIpte"\n", l4e_get_intpte(l4e));
 #endif
 #if CONFIG_PAGING_LEVELS >= 3
-    DPRINTK(" l3e = %"PRIpte"\n", l3e_get_intpte(l3e));
-#endif
-    DPRINTK(" l2e = %"PRIpte"\n", l2e_get_intpte(l2e));
-    DPRINTK(" l1e = %"PRIpte"\n", l1e_get_intpte(l1e));
+    DPRINTK(XEN_WARNING " l3e = %"PRIpte"\n", l3e_get_intpte(l3e));
+#endif
+    DPRINTK(XEN_WARNING " l2e = %"PRIpte"\n", l2e_get_intpte(l2e));
+    DPRINTK(XEN_WARNING " l1e = %"PRIpte"\n", l1e_get_intpte(l1e));
 #ifndef NDEBUG
     show_registers(regs);
 #endif
@@ -1313,7 +1315,7 @@ static int emulate_privileged_op(struct 
         case 0: /* Write CR0 */
             if ( (*reg ^ read_cr0()) & ~X86_CR0_TS )
             {
-                DPRINTK("Attempt to change unmodifiable CR0 flags.\n");
+                DPRINTK(XEN_GUEST "Attempt to change unmodifiable CR0 flags.\n");
                 goto fail;
             }
             (void)do_fpu_taskswitch(!!(*reg & X86_CR0_TS));
@@ -1333,7 +1335,7 @@ static int emulate_privileged_op(struct 
         case 4:
             if ( *reg != (read_cr4() & ~(X86_CR4_PGE|X86_CR4_PSE)) )
             {
-                DPRINTK("Attempt to change CR4 flags.\n");
+                DPRINTK(XEN_GUEST "Attempt to change CR4 flags.\n");
                 goto fail;
             }
             break;
@@ -1381,7 +1383,7 @@ static int emulate_privileged_op(struct 
 
             if ( (rdmsr_safe(regs->ecx, l, h) != 0) ||
                  (regs->eax != l) || (regs->edx != h) )
-                DPRINTK("Domain attempted WRMSR %p from "
+                DPRINTK(XEN_GUEST "Domain attempted WRMSR %p from "
                         "%08x:%08x to %08lx:%08lx.\n",
                         _p(regs->ecx), h, l, (long)regs->edx, (long)regs->eax);
             break;
@@ -1510,7 +1512,7 @@ asmlinkage int do_general_protection(str
 
     if ( likely((fixup = search_exception_table(regs->eip)) != 0) )
     {
-        DPRINTK("GPF (%04x): %p -> %p\n",
+        DPRINTK(XEN_WARNING "GPF (%04x): %p -> %p\n",
                 regs->error_code, _p(regs->eip), _p(fixup));
         regs->eip = fixup;
         return 0;
xen/arch/x86/x86_32/seg_fixup.c +24 -24

172 lines not on this page · raw message

xen/arch/x86/x86_64/traps.c +4 -2
diff -r 96a77ef725b8 xen/arch/x86/x86_64/traps.c
@@ -206,7 +206,8 @@ unsigned long do_iret(void)
     if ( unlikely(copy_from_user(&iret_saved, (void *)regs->rsp,
                                  sizeof(iret_saved))) )
     {
-        DPRINTK("Fault while reading IRET context from guest stack\n");
+        DPRINTK(XEN_GUEST "Fault while reading IRET context from "
+                "guest stack\n");
         domain_crash_synchronous();
     }
 
@@ -215,7 +216,8 @@ unsigned long do_iret(void)
     {
         if ( unlikely(pagetable_is_null(v->arch.guest_table_user)) )
         {
-            DPRINTK("Guest switching to user mode with no user page tables\n");
+            DPRINTK(XEN_GUEST "Guest switching to user mode with no "
+                    "user page tables\n");
             domain_crash_synchronous();
         }
         toggle_guest_mode(v);
xen/common/event_channel.c +2 -1
diff -r 96a77ef725b8 xen/common/event_channel.c
@@ -40,7 +40,8 @@
 
 #define ERROR_EXIT(_errno)                                          \
     do {                                                            \
-        DPRINTK("EVTCHNOP failure: domain %d, error %d, line %d\n", \
+        DPRINTK(XEN_GUEST                                           \
+                "EVTCHNOP failure: domain %d, error %d, line %d\n", \
                 current->domain->domain_id, (_errno), __LINE__);    \
         rc = (_errno);                                              \
         goto out;                                                   \
xen/common/grant_table.c +28 -21

174 lines not on this page · raw message

xen/common/keyhandler.c +15 -0
diff -r 96a77ef725b8 xen/common/keyhandler.c
@@ -247,6 +247,13 @@ extern void perfc_reset(unsigned char ke
 extern void perfc_reset(unsigned char key);
 #endif
 
+static void do_set_log(unsigned char key,  struct cpu_user_regs *regs)
+{
+    print_log_level = key - '0';
+    /* always show this :-) */
+    printk(XEN_EMERG "loglevel set to %d\n", print_log_level);
+}
+
 static void do_debug_key(unsigned char key, struct cpu_user_regs *regs)
 {
     (void)debugger_trap_fatal(0xf001, regs);
@@ -257,6 +264,7 @@ static void do_debug_key(unsigned char k
 
 void initialize_keytable(void)
 {
+    int i;
     open_softirq(KEYPRESS_SOFTIRQ, keypress_softirq);
 
     register_irq_keyhandler(
@@ -279,6 +287,13 @@ void initialize_keytable(void)
     register_keyhandler(
         'P', perfc_reset,    "reset performance counters");
 #endif
+
+    for ( i = 0 ; i <= LOG_MAX ; i++ )
+    {
+        char buf[STR_MAX];
+        sprintf(buf, "set log level to %d", i);
+        register_irq_keyhandler('0'+i, do_set_log, buf);
+    }
 
     register_irq_keyhandler('%', do_debug_key,   "Trap to xendbg");
 }
xen/common/memory.c +5 -5
diff -r 96a77ef725b8 xen/common/memory.c
@@ -61,7 +61,7 @@ increase_reservation(
         if ( unlikely((page = alloc_domheap_pages(
             d, extent_order, memflags)) == NULL) )
         {
-            DPRINTK("Could not allocate order=%d extent: "
+            DPRINTK(XEN_GUEST "Could not allocate order=%d extent: "
                     "id=%d memflags=%x (%ld of %d)\n",
                     extent_order, d->domain_id, memflags, i, nr_extents);
             return i;
@@ -114,7 +114,7 @@ populate_physmap(
         if ( unlikely((page = alloc_domheap_pages(
             d, extent_order, memflags)) == NULL) )
         {
-            DPRINTK("Could not allocate order=%d extent: "
+            DPRINTK(XEN_GUEST "Could not allocate order=%d extent: "
                     "id=%d memflags=%x (%ld of %d)\n",
                     extent_order, d->domain_id, memflags, i, nr_extents);
             goto out;
@@ -153,7 +153,7 @@ guest_remove_page(
     mfn = gmfn_to_mfn(d, gmfn);
     if ( unlikely(!mfn_valid(mfn)) )
     {
-        DPRINTK("Domain %u page number %lx invalid\n",
+        DPRINTK(XEN_GUEST "Domain %u page number %lx invalid\n",
                 d->domain_id, gmfn);
         return 0;
     }
@@ -161,7 +161,7 @@ guest_remove_page(
     page = mfn_to_page(mfn);
     if ( unlikely(!get_page(page, d)) )
     {
-        DPRINTK("Bad page free for domain %u\n", d->domain_id);
+        DPRINTK(XEN_GUEST "Bad page free for domain %u\n", d->domain_id);
         return 0;
     }
 
@@ -174,7 +174,7 @@ guest_remove_page(
     if ( unlikely(!page_is_removable(page)) )
     {
         /* We'll make this a guest-visible error in future, so take heed! */
-        DPRINTK("Dom%d freeing in-use page %lx (pseudophys %lx):"
+        DPRINTK(XEN_GUEST "Dom%d freeing in-use page %lx (pseudophys %lx):"
                 " count=%lx type=%lx\n",
                 d->domain_id, mfn, get_gpfn_from_mfn(mfn),
                 (unsigned long)page->count_info, page->u.inuse.type_info);
xen/common/multicall.c +1 -1
diff -r 96a77ef725b8 xen/common/multicall.c
@@ -24,7 +24,7 @@ do_multicall(
 
     if ( unlikely(__test_and_set_bit(_MCSF_in_multicall, &mcs->flags)) )
     {
-        DPRINTK("Multicall reentry is disallowed.\n");
+        DPRINTK(XEN_GUEST "Multicall reentry is disallowed.\n");
         return -EINVAL;
     }
 
xen/common/page_alloc.c +3 -2
diff -r 96a77ef725b8 xen/common/page_alloc.c
@@ -542,7 +542,8 @@ int assign_pages(
 
     if ( unlikely(test_bit(_DOMF_dying, &d->domain_flags)) )
     {
-        DPRINTK("Cannot assign page to domain%d -- dying.\n", d->domain_id);
+        DPRINTK(XEN_GUEST "Cannot assign page to domain%d -- dying.\n",
+                d->domain_id);
         goto fail;
     }
 
@@ -550,7 +551,7 @@ int assign_pages(
     {
         if ( unlikely((d->tot_pages + (1 << order)) > d->max_pages) )
         {
-            DPRINTK("Over-allocation for domain %u: %u > %u\n",
+            DPRINTK(XEN_GUEST "Over-allocation for domain %u: %u > %u\n",
                     d->domain_id, d->tot_pages + (1 << order), d->max_pages);
             goto fail;
         }
xen/common/schedule.c +1 -1
diff -r 96a77ef725b8 xen/common/schedule.c
@@ -468,7 +468,7 @@ long do_set_timer_op(s_time_t timeout)
          * timeout in this case can burn a lot of CPU. We therefore go for a
          * reasonable middleground of triggering a timer event in 100ms.
          */
-        DPRINTK("Warning: huge timeout set by domain %d (vcpu %d):"
+        DPRINTK(XEN_GUEST "Warning: huge timeout set by domain %d (vcpu %d):"
                 " %"PRIx64"\n",
                 v->domain->domain_id, v->vcpu_id, (uint64_t)timeout);
         set_timer(&v->timer, NOW() + MILLISECS(100));
xen/common/trace.c +1 -1
diff -r 96a77ef725b8 xen/common/trace.c
@@ -131,7 +131,7 @@ static int tb_set_size(int size)
      */
     if ( (opt_tbuf_size != 0) || (size <= 0) )
     {
-        DPRINTK("tb_set_size from %d to %d not implemented\n",
+        DPRINTK(XEN_GUEST "tb_set_size from %d to %d not implemented\n",
                 opt_tbuf_size, size);
         return -EINVAL;
     }
xen/drivers/char/console.c +17 -0
diff -r 96a77ef725b8 xen/drivers/char/console.c
@@ -294,6 +294,8 @@ static inline void __putstr(const char *
     }
 }
 
+int print_log_level = PRINT_LOG_DEFAULT;
+
 void printf(const char *fmt, ...)
 {
     static char   buf[1024];
@@ -302,6 +304,7 @@ void printf(const char *fmt, ...)
     va_list       args;
     char         *p, *q;
     unsigned long flags;
+    int           level = PRINT_LOG_DEFAULT;
 
     spin_lock_irqsave(&console_lock, flags);
 
@@ -310,6 +313,19 @@ void printf(const char *fmt, ...)
     va_end(args);        
 
     p = buf;
+    if ( (p[0] == '<') && (p[1] >= '0')
+         && (p[1] <= ('0' + LOG_MAX))
+         && (p[2] == '>') )
+    {
+        level = p[1] - '0';
+        p += 3;
+    }
+
+    if ( level > print_log_level )
+    {
+        goto out;
+    }
+
     while ( (q = strchr(p, '\n')) != NULL )
     {
         *q = '\0';
@@ -329,6 +345,7 @@ void printf(const char *fmt, ...)
         start_of_line = 0;
     }
 
+ out:
     spin_unlock_irqrestore(&console_lock, flags);
 }
 
xen/include/asm-ia64/mm.h +1 -1
diff -r 96a77ef725b8 xen/include/asm-ia64/mm.h
@@ -170,7 +170,7 @@ static inline int get_page(struct page_i
 	    unlikely((nx & PGC_count_mask) == 0) ||	/* Count overflow? */
 	    unlikely((x >> 32) != _domain)) {		/* Wrong owner? */
 
-	    DPRINTK("Error pfn %lx: rd=%p, od=%p, caf=%016lx, taf=%"
+	    DPRINTK(XEN_GUEST "Error pfn %lx: rd=%p, od=%p, caf=%016lx, taf=%"
 		PRtype_info "\n", page_to_mfn(page), domain,
 		unpickle_domptr(x >> 32), x, page->u.inuse.type_info);
 	    return 0;
xen/include/asm-x86/mm.h +2 -1
diff -r 96a77ef725b8 xen/include/asm-x86/mm.h
@@ -214,7 +214,8 @@ static inline int get_page(struct page_i
              unlikely(d != _domain) )                /* Wrong owner? */
         {
             if ( !_shadow_mode_refcounts(domain) )
-                DPRINTK("Error pfn %lx: rd=%p, od=%p, caf=%08x, taf=%" 
+                DPRINTK(XEN_GUEST
+                        "Error pfn %lx: rd=%p, od=%p, caf=%08x, taf=%"
                         PRtype_info "\n",
                         page_to_mfn(page), domain, unpickle_domptr(d),
                         x, page->u.inuse.type_info);
xen/include/xen/config.h +21 -12
diff -r 96a77ef725b8 xen/include/xen/config.h
@@ -13,25 +13,34 @@
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 
 /* Linux syslog levels. */
-#define KERN_NOTICE  ""
-#define KERN_WARNING ""
-#define KERN_DEBUG   ""
-#define KERN_INFO    ""
-#define KERN_ERR     ""
-#define KERN_CRIT    ""
-#define KERN_EMERG   ""
-#define KERN_ALERT   ""
+#define XEN_EMERG   "<0>"
+#define XEN_ALERT   "<1>"
+#define XEN_CRIT    "<2>"
+#define XEN_ERR     "<3>"
+#define XEN_WARNING "<4>"
+#define XEN_GUEST   "<5>"
+#define XEN_INFO    "<6>"
+#define XEN_DEBUG   "<7>"
+
+#define KERN_EMERG   XEN_EMERG
+#define KERN_ALERT   XEN_ALERT
+#define KERN_CRIT    XEN_CRIT
+#define KERN_ERR     XEN_ERR
+#define KERN_WARNING XEN_WARNING
+#define KERN_NOTICE  XEN_GUEST
+#define KERN_INFO    XEN_INFO
+#define KERN_DEBUG   XEN_DEBUG
+
+#define LOG_MAX 7
+
+#define PRINT_LOG_DEFAULT 5
 
 /* Linux 'checker' project. */
 #define __iomem
 #define __user
 
-#ifdef VERBOSE
 #define DPRINTK(_f, _a...) printk("(file=%s, line=%d) " _f, \
                            __FILE__ , __LINE__ , ## _a )
-#else
-#define DPRINTK(_f, _a...) ((void)0)
-#endif
 
 #ifndef __ASSEMBLY__
 #include <xen/compiler.h>
xen/include/xen/lib.h +1 -0
diff -r 96a77ef725b8 xen/include/xen/lib.h
@@ -57,6 +57,7 @@ extern void panic(const char *format, ..
 extern void panic(const char *format, ...)
     __attribute__ ((format (printf, 1, 2)));
 extern long vm_assist(struct domain *, unsigned int, unsigned int);
+extern int print_log_level;
 
 /* vsprintf.c */
 extern int sprintf(char * buf, const char * fmt, ...)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel