aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2023-11-29 09:17:42 +0100
committerIngo Molnar <mingo@kernel.org>2023-11-29 09:17:43 +0100
commit34227b01e10cec78ad6b07ae63f02098735a4213 (patch)
tree1095284186ac792ceae62eec056faf5b4df8d52b
parentc956a527f70c823595b53be26fa0d56430466c25 (diff)
parentfe22bc430c9d24394e541e16e0941a075f02fcb7 (diff)
downloadqueue-34227b01e10cec78ad6b07ae63f02098735a4213.tar.gz
Merge branch into tip/master: 'x86/paravirt'
# New commits in x86/paravirt: fe22bc430c9d ("x86/paravirt: Make the struct paravirt_patch_site packed") 5c22c4726e4a ("x86/paravirt: Use relative reference for the original instruction offset") Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/include/asm/paravirt.h8
-rw-r--r--arch/x86/include/asm/paravirt_types.h8
-rw-r--r--arch/x86/kernel/alternative.c8
-rw-r--r--arch/x86/kernel/callthunks.c2
4 files changed, 12 insertions, 14 deletions
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index 6c8ff12140aea9..693c61dbdd9c3f 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -743,16 +743,14 @@ void native_pv_lock_init(void) __init;
#else /* __ASSEMBLY__ */
-#define _PVSITE(ptype, ops, word, algn) \
+#define _PVSITE(ptype, ops) \
771:; \
ops; \
772:; \
.pushsection .parainstructions,"a"; \
- .align algn; \
- word 771b; \
+ .long 771b-.; \
.byte ptype; \
.byte 772b-771b; \
- _ASM_ALIGN; \
.popsection
@@ -760,7 +758,7 @@ void native_pv_lock_init(void) __init;
#ifdef CONFIG_PARAVIRT_XXL
#define PARA_PATCH(off) ((off) / 8)
-#define PARA_SITE(ptype, ops) _PVSITE(ptype, ops, .quad, 8)
+#define PARA_SITE(ptype, ops) _PVSITE(ptype, ops)
#define PARA_INDIRECT(addr) *addr(%rip)
#ifdef CONFIG_DEBUG_ENTRY
diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
index 772d03487520e5..f4fb2e3ec7b8a4 100644
--- a/arch/x86/include/asm/paravirt_types.h
+++ b/arch/x86/include/asm/paravirt_types.h
@@ -5,10 +5,10 @@
#ifndef __ASSEMBLY__
/* These all sit in the .parainstructions section to tell us what to patch. */
struct paravirt_patch_site {
- u8 *instr; /* original instructions */
+ s32 instr_offset; /* original instructions */
u8 type; /* type of this instruction */
u8 len; /* length of original instruction */
-};
+} __packed;
#endif
#ifdef CONFIG_PARAVIRT
@@ -263,11 +263,9 @@ extern struct paravirt_patch_template pv_ops;
#define _paravirt_alt(insn_string, type) \
"771:\n\t" insn_string "\n" "772:\n" \
".pushsection .parainstructions,\"a\"\n" \
- _ASM_ALIGN "\n" \
- _ASM_PTR " 771b\n" \
+ " .long 771b-.\n" \
" .byte " type "\n" \
" .byte 772b-771b\n" \
- _ASM_ALIGN "\n" \
".popsection\n"
/* Generate patchable code, with the default asm parameters. */
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 73be3931e4f060..be35c8ccf8267b 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -1431,20 +1431,22 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
{
struct paravirt_patch_site *p;
char insn_buff[MAX_PATCH_LEN];
+ u8 *instr;
for (p = start; p < end; p++) {
unsigned int used;
+ instr = (u8 *)&p->instr_offset + p->instr_offset;
BUG_ON(p->len > MAX_PATCH_LEN);
/* prep the buffer with the original instructions */
- memcpy(insn_buff, p->instr, p->len);
- used = paravirt_patch(p->type, insn_buff, (unsigned long)p->instr, p->len);
+ memcpy(insn_buff, instr, p->len);
+ used = paravirt_patch(p->type, insn_buff, (unsigned long)instr, p->len);
BUG_ON(used > p->len);
/* Pad the rest with nops */
add_nops(insn_buff + used, p->len - used);
- text_poke_early(p->instr, insn_buff, p->len);
+ text_poke_early(instr, insn_buff, p->len);
}
}
extern struct paravirt_patch_site __start_parainstructions[],
diff --git a/arch/x86/kernel/callthunks.c b/arch/x86/kernel/callthunks.c
index e9ad518a5003cd..57e5c2e75c2a79 100644
--- a/arch/x86/kernel/callthunks.c
+++ b/arch/x86/kernel/callthunks.c
@@ -240,7 +240,7 @@ patch_paravirt_call_sites(struct paravirt_patch_site *start,
struct paravirt_patch_site *p;
for (p = start; p < end; p++)
- patch_call(p->instr, ct);
+ patch_call((void *)&p->instr_offset + p->instr_offset, ct);
}
static __init_or_module void