[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH livepatch-hooks-4 1/1] livepatch: always print XENLOG_ERR information



A lot of legitimate error messages were hidden behind debug printk
only. Most of these messages can be triggered by loading a malformed
hotpatch payload and are priceless for understanding issues with such
payloads.
Thus, always display all relevant XENLOG_ERR messages.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@xxxxxxxxx>
Reviewed-by: Amit Shah <aams@xxxxxxxxx>
Reviewed-by: Martin Mazein <amazein@xxxxxxxxx>
Reviewed-by: Bjoern Doebel <doebel@xxxxxxxxx>
---
 xen/arch/x86/livepatch.c | 16 ++++++++--------
 xen/common/livepatch.c   | 38 +++++++++++++++++++-------------------
 2 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/xen/arch/x86/livepatch.c b/xen/arch/x86/livepatch.c
index 406eb910cc..436ee40fe1 100644
--- a/xen/arch/x86/livepatch.c
+++ b/xen/arch/x86/livepatch.c
@@ -126,7 +126,7 @@ int arch_livepatch_verify_elf(const struct livepatch_elf 
*elf)
          hdr->e_ident[EI_CLASS] != ELFCLASS64 ||
          hdr->e_ident[EI_DATA] != ELFDATA2LSB )
     {
-        dprintk(XENLOG_ERR, LIVEPATCH "%s: Unsupported ELF Machine type!\n",
+        printk(XENLOG_ERR LIVEPATCH "%s: Unsupported ELF Machine type!\n",
                 elf->name);
         return -EOPNOTSUPP;
     }
@@ -152,7 +152,7 @@ int arch_livepatch_perform_rel(struct livepatch_elf *elf,
                                const struct livepatch_elf_sec *base,
                                const struct livepatch_elf_sec *rela)
 {
-    dprintk(XENLOG_ERR, LIVEPATCH "%s: SHT_REL relocation unsupported\n",
+    printk(XENLOG_ERR LIVEPATCH "%s: SHT_REL relocation unsupported\n",
             elf->name);
     return -EOPNOTSUPP;
 }
@@ -172,19 +172,19 @@ int arch_livepatch_perform_rela(struct livepatch_elf *elf,
 
         if ( symndx == STN_UNDEF )
         {
-            dprintk(XENLOG_ERR, LIVEPATCH "%s: Encountered STN_UNDEF\n",
+            printk(XENLOG_ERR LIVEPATCH "%s: Encountered STN_UNDEF\n",
                     elf->name);
             return -EOPNOTSUPP;
         }
         else if ( symndx >= elf->nsym )
         {
-            dprintk(XENLOG_ERR, LIVEPATCH "%s: Relative relocation wants 
symbol@%u which is past end!\n",
+            printk(XENLOG_ERR LIVEPATCH "%s: Relative relocation wants 
symbol@%u which is past end!\n",
                     elf->name, symndx);
             return -EINVAL;
         }
         else if ( !elf->sym[symndx].sym )
         {
-            dprintk(XENLOG_ERR, LIVEPATCH "%s: No symbol@%u\n",
+            printk(XENLOG_ERR LIVEPATCH "%s: No symbol@%u\n",
                     elf->name, symndx);
             return -EINVAL;
         }
@@ -222,14 +222,14 @@ int arch_livepatch_perform_rela(struct livepatch_elf *elf,
             *(int32_t *)dest = val;
             if ( (int64_t)val != *(int32_t *)dest )
             {
-                dprintk(XENLOG_ERR, LIVEPATCH "%s: Overflow in relocation %u 
in %s for %s!\n",
+                printk(XENLOG_ERR LIVEPATCH "%s: Overflow in relocation %u in 
%s for %s!\n",
                         elf->name, i, rela->name, base->name);
                 return -EOVERFLOW;
             }
             break;
 
         default:
-            dprintk(XENLOG_ERR, LIVEPATCH "%s: Unhandled relocation %lu\n",
+            printk(XENLOG_ERR LIVEPATCH "%s: Unhandled relocation %lu\n",
                     elf->name, ELF64_R_TYPE(r->r_info));
             return -EOPNOTSUPP;
         }
@@ -238,7 +238,7 @@ int arch_livepatch_perform_rela(struct livepatch_elf *elf,
     return 0;
 
  bad_offset:
-    dprintk(XENLOG_ERR, LIVEPATCH "%s: Relative relocation offset is past %s 
section!\n",
+    printk(XENLOG_ERR LIVEPATCH "%s: Relative relocation offset is past %s 
section!\n",
             elf->name, base->name);
     return -EINVAL;
 }
diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c
index c4a107d91c..585ec9819a 100644
--- a/xen/common/livepatch.c
+++ b/xen/common/livepatch.c
@@ -217,7 +217,7 @@ static int resolve_old_address(struct livepatch_func *f,
         f->old_addr = (void *)livepatch_symbols_lookup_by_name(f->name);
         if ( !f->old_addr )
         {
-            dprintk(XENLOG_ERR, LIVEPATCH "%s: Could not resolve old address 
of %s\n",
+            printk(XENLOG_ERR LIVEPATCH "%s: Could not resolve old address of 
%s\n",
                     elf->name, f->name);
             return -ENOENT;
         }
@@ -336,7 +336,7 @@ static int move_payload(struct payload *payload, struct 
livepatch_elf *elf)
     text_buf = vmalloc_xen(size * PAGE_SIZE);
     if ( !text_buf )
     {
-        dprintk(XENLOG_ERR, LIVEPATCH "%s: Could not allocate memory for 
payload!\n",
+        printk(XENLOG_ERR LIVEPATCH "%s: Could not allocate memory for 
payload!\n",
                 elf->name);
         rc = -ENOMEM;
         goto out;
@@ -434,7 +434,7 @@ static bool section_ok(const struct livepatch_elf *elf,
 
     if ( sec->sec->sh_size % sz )
     {
-        dprintk(XENLOG_ERR, LIVEPATCH "%s: Wrong size %"PRIuElfWord" of %s 
(must be multiple of %zu)\n",
+        printk(XENLOG_ERR LIVEPATCH "%s: Wrong size %"PRIuElfWord" of %s (must 
be multiple of %zu)\n",
                 elf->name, sec->sec->sh_size, sec->name, sz);
         return false;
     }
@@ -456,7 +456,7 @@ static int check_xen_build_id(const struct payload *payload)
         return rc;
 
     if ( payload->xen_dep.len != len || memcmp(id, payload->xen_dep.p, len) ) {
-        dprintk(XENLOG_ERR, "%s%s: check against hypervisor build-id 
failed!\n",
+        printk(XENLOG_ERR LIVEPATCH "%s%s: check against hypervisor build-id 
failed!\n",
                 LIVEPATCH, payload->name);
         return -EINVAL;
     }
@@ -479,21 +479,21 @@ static int check_special_sections(const struct 
livepatch_elf *elf)
         sec = livepatch_elf_sec_by_name(elf, names[i]);
         if ( !sec )
         {
-            dprintk(XENLOG_ERR, LIVEPATCH "%s: %s is missing!\n",
+            printk(XENLOG_ERR LIVEPATCH "%s: %s is missing!\n",
                     elf->name, names[i]);
             return -EINVAL;
         }
 
         if ( !sec->sec->sh_size )
         {
-            dprintk(XENLOG_ERR, LIVEPATCH "%s: %s is empty!\n",
+            printk(XENLOG_ERR LIVEPATCH "%s: %s is empty!\n",
                     elf->name, names[i]);
             return -EINVAL;
         }
 
         if ( test_and_set_bit(i, found) )
         {
-            dprintk(XENLOG_ERR, LIVEPATCH "%s: %s was seen more than once!\n",
+            printk(XENLOG_ERR LIVEPATCH "%s: %s was seen more than once!\n",
                     elf->name, names[i]);
             return -EINVAL;
         }
@@ -529,21 +529,21 @@ static int check_patching_sections(const struct 
livepatch_elf *elf)
         sec = livepatch_elf_sec_by_name(elf, names[i]);
         if ( !sec )
         {
-            dprintk(XENLOG_INFO, LIVEPATCH "%s: %s is missing!\n",
+            dprintk(XENLOG_DEBUG, LIVEPATCH "%s: %s is missing!\n",
                     elf->name, names[i]);
             continue; /* This section is optional */
         }
 
         if ( !sec->sec->sh_size )
         {
-            dprintk(XENLOG_ERR, LIVEPATCH "%s: %s is empty!\n",
+            printk(XENLOG_ERR LIVEPATCH "%s: %s is empty!\n",
                     elf->name, names[i]);
             return -EINVAL;
         }
 
         if ( test_and_set_bit(i, found) )
         {
-            dprintk(XENLOG_ERR, LIVEPATCH "%s: %s was seen more than once!\n",
+            printk(XENLOG_ERR LIVEPATCH "%s: %s was seen more than once!\n",
                     elf->name, names[i]);
             return -EINVAL;
         }
@@ -615,7 +615,7 @@ static int prepare_payload(struct payload *payload,
 
             if ( f->version != LIVEPATCH_PAYLOAD_VERSION )
             {
-                dprintk(XENLOG_ERR, LIVEPATCH "%s: Wrong version (%u). 
Expected %d!\n",
+                printk(XENLOG_ERR LIVEPATCH "%s: Wrong version (%u). Expected 
%d!\n",
                         elf->name, f->version, LIVEPATCH_PAYLOAD_VERSION);
                 return -EOPNOTSUPP;
             }
@@ -623,7 +623,7 @@ static int prepare_payload(struct payload *payload,
             /* 'old_addr', 'new_addr', 'new_size' can all be zero. */
             if ( !f->old_size )
             {
-                dprintk(XENLOG_ERR, LIVEPATCH "%s: Address or size fields are 
zero!\n",
+                printk(XENLOG_ERR LIVEPATCH "%s: Address or size fields are 
zero!\n",
                         elf->name);
                 return -EINVAL;
             }
@@ -762,14 +762,14 @@ static int prepare_payload(struct payload *payload,
             if ( (instr < region->start && instr >= region->end) ||
                  (replacement < region->start && replacement >= region->end) )
             {
-                dprintk(XENLOG_ERR, LIVEPATCH "%s Alt patching outside 
payload: %p!\n",
+                printk(XENLOG_ERR LIVEPATCH "%s Alt patching outside payload: 
%p!\n",
                         elf->name, instr);
                 return -EINVAL;
             }
         }
         apply_alternatives(start, end);
 #else
-        dprintk(XENLOG_ERR, LIVEPATCH "%s: We don't support alternative 
patching!\n",
+        printk(XENLOG_ERR LIVEPATCH "%s: We don't support alternative 
patching!\n",
                 elf->name);
         return -EOPNOTSUPP;
 #endif
@@ -792,7 +792,7 @@ static int prepare_payload(struct payload *payload,
         region->ex = s;
         region->ex_end = e;
 #else
-        dprintk(XENLOG_ERR, LIVEPATCH "%s: We don't support .ex_table!\n",
+        printk(XENLOG_ERR LIVEPATCH "%s: We don't support .ex_table!\n",
                 elf->name);
         return -EOPNOTSUPP;
 #endif
@@ -901,7 +901,7 @@ static int build_symbol_table(struct payload *payload,
             if ( symbols_lookup_by_name(symtab[i].name) ||
                  livepatch_symbols_lookup_by_name(symtab[i].name) )
             {
-                dprintk(XENLOG_ERR, LIVEPATCH "%s: duplicate new symbol: %s\n",
+                printk(XENLOG_ERR LIVEPATCH "%s: duplicate new symbol: %s\n",
                         elf->name, symtab[i].name);
                 xfree(symtab);
                 xfree(strtab);
@@ -1652,7 +1652,7 @@ static int build_id_dep(struct payload *payload, bool_t 
internal)
     if ( payload->dep.len != len ||
          memcmp(id, payload->dep.p, len) )
     {
-        dprintk(XENLOG_ERR, "%s%s: check against %s build-id failed!\n",
+        printk(XENLOG_ERR LIVEPATCH "%s%s: check against %s build-id 
failed!\n",
                 LIVEPATCH, payload->name, name);
         return -EINVAL;
     }
@@ -1712,7 +1712,7 @@ static int livepatch_action(struct 
xen_sysctl_livepatch_action *action)
             /* We should be the last applied one. */
             if ( p != data )
             {
-                dprintk(XENLOG_ERR, "%s%s: can't unload. Top is %s!\n",
+                printk(XENLOG_ERR LIVEPATCH "%s%s: can't unload. Top is %s!\n",
                         LIVEPATCH, data->name, p->name);
                 rc = -EBUSY;
                 break;
@@ -1748,7 +1748,7 @@ static int livepatch_action(struct 
xen_sysctl_livepatch_action *action)
              */
             if ( data->reverted && !data->safe_to_reapply )
             {
-                dprintk(XENLOG_ERR, "%s%s: can't revert as payload has .data. 
Please unload!\n",
+                printk(XENLOG_ERR LIVEPATCH "%s%s: can't revert as payload has 
.data. Please unload!\n",
                         LIVEPATCH, data->name);
                 data->rc = -EINVAL;
                 break;
-- 
2.16.5




Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Ralf Herbrich
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879




_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.