x86/arm64: Expose the ALT_[ORIG|REPL]_PTR macros to header files.
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Fri, 12 Aug 2016 20:11:27 +0000 (16:11 -0400)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Fri, 9 Sep 2016 15:48:21 +0000 (11:48 -0400)
That way common code can use the same macro to access
the most common attributes without much #ifdef.

Take advantage of it right away in the livepatch code.

Note: on ARM we use tabs to conform to the style of the file.

Acked-by: Julien Grall <julien.grall@arm.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
xen/arch/arm/alternative.c
xen/common/livepatch.c
xen/include/asm-arm/alternative.h
xen/include/asm-x86/alternative.h

index 7203baed8a96f63a9f396eaac3d1a10c088a15cd..2168393186e1eba41e8a2bdf8efcd5cd6480b9c0 100644 (file)
 #include <asm/insn.h>
 #include <asm/page.h>
 
-#define __ALT_PTR(a,f)      (u32 *)((void *)&(a)->f + (a)->f)
-#define ALT_ORIG_PTR(a)     __ALT_PTR(a, orig_offset)
-#define ALT_REPL_PTR(a)     __ALT_PTR(a, alt_offset)
-
 extern const struct alt_instr __alt_instructions[], __alt_instructions_end[];
 
 struct alt_region {
index a6010eb00bf31a6098487fb99ea4cfaf6b54a0d2..440e9141a389cd6fa9389e625104a17516ca7ecf 100644 (file)
@@ -621,8 +621,8 @@ static int prepare_payload(struct payload *payload,
 
         for ( a = start; a < end; a++ )
         {
-            const void *instr = &a->instr_offset + a->instr_offset;
-            const void *replacement = &a->repl_offset + a->repl_offset;
+            const void *instr = ALT_ORIG_PTR(a);
+            const void *replacement = ALT_REPL_PTR(a);
 
             if ( (instr < region->start && instr >= region->end) ||
                  (replacement < region->start && replacement >= region->end) )
index 4287bac36631c0d13b7a7531174433b9a76fe168..f25d3a7697a9a74ef731f8d9594cb1db8e49acfa 100644 (file)
@@ -21,6 +21,11 @@ struct alt_instr {
        u8  alt_len;            /* size of new instruction(s), <= orig_len */
 };
 
+/* Xen: helpers used by common code. */
+#define __ALT_PTR(a,f)         ((u32 *)((void *)&(a)->f + (a)->f))
+#define ALT_ORIG_PTR(a)                __ALT_PTR(a, orig_offset)
+#define ALT_REPL_PTR(a)                __ALT_PTR(a, alt_offset)
+
 void __init apply_alternatives_all(void);
 int apply_alternatives(void *start, size_t length);
 
index bce959f93f65f8bf5e96c03e34510fb8fad9f80f..63b036400dff483f56c3ea552123919fa938ad4a 100644 (file)
@@ -23,6 +23,10 @@ struct alt_instr {
     u8  replacementlen;     /* length of new instruction, <= instrlen */
 };
 
+#define __ALT_PTR(a,f)      ((u8 *)((void *)&(a)->f + (a)->f))
+#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);