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

[Xen-changelog] [xen master] alternatives: x86 rename and change parameters on ARM



commit 0b3102be2261de5376723fb6d40465cd7f9cb162
Author:     Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
AuthorDate: Tue Aug 16 22:20:54 2016 -0400
Commit:     Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
CommitDate: Fri Sep 9 11:48:21 2016 -0400

    alternatives: x86 rename and change parameters on ARM
    
    On x86 we squash 'apply_alternatives' in to
    'alternative_instructions' (who was its sole user)
    and 'apply_alternatives_nocheck' to 'apply_alternatives'.
    
    On ARM we change the parameters for 'apply_alternatives'
    to be of 'const struct alt_instr *' instead of void pointer and
    size length.
    
    We also add 'const' and make the arguments be on the
    proper offset.
    
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> [x86 bits]
    Reviewed-by: Julien Grall <julien.grall@xxxxxxx> [ARM bits]
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
---
 xen/arch/arm/alternative.c        |  4 ++--
 xen/arch/x86/alternative.c        | 29 ++++++++++++-----------------
 xen/common/livepatch.c            |  2 +-
 xen/include/asm-arm/alternative.h |  2 +-
 xen/include/asm-x86/alternative.h |  7 +++----
 5 files changed, 19 insertions(+), 25 deletions(-)

diff --git a/xen/arch/arm/alternative.c b/xen/arch/arm/alternative.c
index 2168393..b9c2b3a 100644
--- a/xen/arch/arm/alternative.c
+++ b/xen/arch/arm/alternative.c
@@ -209,11 +209,11 @@ void __init apply_alternatives_all(void)
     BUG_ON(ret);
 }
 
-int apply_alternatives(void *start, size_t length)
+int apply_alternatives(const struct alt_instr *start, const struct alt_instr 
*end)
 {
     const struct alt_region region = {
         .begin = start,
-        .end = start + length,
+        .end = end,
     };
 
     return __apply_alternatives(&region);
diff --git a/xen/arch/x86/alternative.c b/xen/arch/x86/alternative.c
index be40b13..05e3eb8 100644
--- a/xen/arch/x86/alternative.c
+++ b/xen/arch/x86/alternative.c
@@ -144,9 +144,10 @@ static void *init_or_livepatch text_poke(void *addr, const 
void *opcode, size_t
  * APs have less capabilities than the boot processor are not handled.
  * Tough. Make sure you disable such features by hand.
  */
-void init_or_livepatch apply_alternatives_nocheck(struct alt_instr *start, 
struct alt_instr *end)
+void init_or_livepatch apply_alternatives(const struct alt_instr *start,
+                                          const struct alt_instr *end)
 {
-    struct alt_instr *a;
+    const struct alt_instr *a;
     u8 *instr, *replacement;
     u8 insnbuf[MAX_PATCH_LEN];
 
@@ -187,24 +188,10 @@ void init_or_livepatch apply_alternatives_nocheck(struct 
alt_instr *start, struc
  * This routine is called with local interrupt disabled and used during
  * bootup.
  */
-void __init apply_alternatives(struct alt_instr *start, struct alt_instr *end)
-{
-    unsigned long cr0 = read_cr0();
-
-    ASSERT(!local_irq_is_enabled());
-
-    /* Disable WP to allow application of alternatives to read-only pages. */
-    write_cr0(cr0 & ~X86_CR0_WP);
-
-    apply_alternatives_nocheck(start, end);
-
-    /* Reinstate WP. */
-    write_cr0(cr0);
-}
-
 void __init alternative_instructions(void)
 {
     nmi_callback_t *saved_nmi_callback;
+    unsigned long cr0 = read_cr0();
 
     arch_init_ideal_nops();
 
@@ -225,7 +212,15 @@ void __init alternative_instructions(void)
      * expect a machine check to cause undue problems during to code
      * patching.
      */
+    ASSERT(!local_irq_is_enabled());
+
+    /* Disable WP to allow application of alternatives to read-only pages. */
+    write_cr0(cr0 & ~X86_CR0_WP);
+
     apply_alternatives(__alt_instructions, __alt_instructions_end);
 
+    /* Reinstate WP. */
+    write_cr0(cr0);
+
     set_nmi_callback(saved_nmi_callback);
 }
diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c
index 440e914..282da74 100644
--- a/xen/common/livepatch.c
+++ b/xen/common/livepatch.c
@@ -632,7 +632,7 @@ static int prepare_payload(struct payload *payload,
                 return -EINVAL;
             }
         }
-        apply_alternatives_nocheck(start, end);
+        apply_alternatives(start, end);
     }
 
     sec = livepatch_elf_sec_by_name(elf, ".ex_table");
diff --git a/xen/include/asm-arm/alternative.h 
b/xen/include/asm-arm/alternative.h
index f25d3a7..9f88fd9 100644
--- a/xen/include/asm-arm/alternative.h
+++ b/xen/include/asm-arm/alternative.h
@@ -27,7 +27,7 @@ struct alt_instr {
 #define ALT_REPL_PTR(a)                __ALT_PTR(a, alt_offset)
 
 void __init apply_alternatives_all(void);
-int apply_alternatives(void *start, size_t length);
+int apply_alternatives(const struct alt_instr *start, const struct alt_instr 
*end);
 
 #define ALTINSTR_ENTRY(feature)                                                
      \
        " .word 661b - .\n"                             /* label           */ \
diff --git a/xen/include/asm-x86/alternative.h 
b/xen/include/asm-x86/alternative.h
index 63b0364..67fc0d2 100644
--- a/xen/include/asm-x86/alternative.h
+++ b/xen/include/asm-x86/alternative.h
@@ -27,10 +27,9 @@ struct alt_instr {
 #define ALT_ORIG_PTR(a)     __ALT_PTR(a, instr_offset)
 #define ALT_REPL_PTR(a)     __ALT_PTR(a, repl_offset)
 
-/* Similar to apply_alternatives except it can be run with IRQs enabled. */
-extern void apply_alternatives_nocheck(struct alt_instr *start,
-                                       struct alt_instr *end);
-extern void apply_alternatives(struct alt_instr *start, struct alt_instr *end);
+/* Similar to alternative_instructions except it can be run with IRQs enabled. 
*/
+extern void apply_alternatives(const struct alt_instr *start,
+                               const struct alt_instr *end);
 extern void alternative_instructions(void);
 
 #define OLDINSTR(oldinstr)      "661:\n\t" oldinstr "\n662:\n"
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

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