|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] x86: disable CR0.WP while applying alternatives
commit 36c672b559d35e088b181c67538b1ed5bacb0da5
Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Thu Feb 25 13:06:16 2016 +0100
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Feb 25 13:06:16 2016 +0100
x86: disable CR0.WP while applying alternatives
In preparation for marking .text as read-only, care needs to be taken not to
fault while applying alternatives.
Swapping back to RW mappings is a possibility, but would require additional
TLB management. A temporary disabling of CR0.WP is cleaner.
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
xen/arch/x86/alternative.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/xen/arch/x86/alternative.c b/xen/arch/x86/alternative.c
index 9d54df1..0a0ce15 100644
--- a/xen/arch/x86/alternative.c
+++ b/xen/arch/x86/alternative.c
@@ -147,11 +147,15 @@ static void __init apply_alternatives(struct alt_instr
*start, struct alt_instr
struct alt_instr *a;
u8 *instr, *replacement;
u8 insnbuf[MAX_PATCH_LEN];
+ unsigned long cr0 = read_cr0();
ASSERT(!local_irq_is_enabled());
printk(KERN_INFO "alt table %p -> %p\n", start, end);
+ /* Disable WP to allow application of alternatives to read-only pages. */
+ write_cr0(cr0 & ~X86_CR0_WP);
+
/*
* The scan order should be from start to end. A later scanned
* alternative code can overwrite a previous scanned alternative code.
@@ -181,6 +185,9 @@ static void __init apply_alternatives(struct alt_instr
*start, struct alt_instr
a->instrlen - a->replacementlen);
text_poke_early(instr, insnbuf, a->instrlen);
}
+
+ /* Reinstate WP. */
+ write_cr0(cr0);
}
void __init alternative_instructions(void)
--
generated by git-patchbot for /home/xen/git/xen.git#master
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |