@@ -32,10 +32,6 @@
#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 {
@@ -702,8 +702,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) )
@@ -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);
@@ -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)
+
extern void add_nops(void *insns, unsigned int len);
/* Similar to apply_alternatives except it can be run with IRQs enabled. */
extern void apply_alternatives_nocheck(struct alt_instr *start,