[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [Very RFC PATCH 1/3] mm/arm: Introduce modify_xen_mappings
Which is only used by Livepatch code. The purpose behind this call is to modify the page table entries flags. Specifically the .ro and .nx flags. The current mechanism puts cache attributes in the flags and the .ro and .nx are locked down and assumed to be .ro=0, nx=1. Livepatch needs .nx=0 and also .ro to be set to 1. We introduce a new 'flags' where bit 0 determines the .ro and bit 1 determines the .nx. TODO: - Get ARM64 idea of how they want to do this. - Add #define for R and NX bits for flag (if ARM folks like my idea). Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> -- Cc: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx> Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx> Cc: Julien Grall <julien.grall@xxxxxxx> Cc Jan Beulich <jbeulich@xxxxxxxx> Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- xen/arch/arm/mm.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 4e256c2..eca7cdd 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -836,6 +836,7 @@ static int create_xen_table(lpae_t *entry) enum xenmap_operation { INSERT, REMOVE, + MODIFY, RESERVE }; @@ -877,18 +878,27 @@ static int create_xen_entries(enum xenmap_operation op, } if ( op == RESERVE ) break; + pte = mfn_to_xen_entry(mfn, ai); pte.pt.table = 1; write_pte(&third[third_table_offset(addr)], pte); break; + case MODIFY: case REMOVE: if ( !third[third_table_offset(addr)].pt.valid ) { - printk("create_xen_entries: trying to remove a non-existing mapping addr=%lx\n", - addr); + printk("create_xen_entries: trying to %s a non-existing mapping addr=%lx\n", + op == REMOVE ? "remove" : "modify", addr); return -EINVAL; } - pte.bits = 0; + if ( op == REMOVE ) + pte.bits = 0; + else + { + pte = third[third_table_offset(addr)]; + pte.pt.ro = (ai >> 1) & 0x1; + pte.pt.xn = ai & 0x1; + } write_pte(&third[third_table_offset(addr)], pte); break; default: @@ -922,6 +932,13 @@ void destroy_xen_mappings(unsigned long v, unsigned long e) create_xen_entries(REMOVE, v, 0, (e - v) >> PAGE_SHIFT, 0); } +void modify_xen_mappings(unsigned long s, unsigned long e, unsigned int flags) +{ + /* TODO: #define for ro and nx flags. */ + ASSERT((flags & 0x3) == flags); + create_xen_entries(MODIFY, s, 0, (e - s) >> PAGE_SHIFT, flags); +} + enum mg { mg_clear, mg_ro, mg_rw, mg_rx }; static void set_pte_flags_on_range(const char *p, unsigned long l, enum mg mg) { -- 2.4.11 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |