[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] x86/mm: Refine address alignment checks in modify_xen_mappings_lite()
commit 3c9e76cd875e12c88cfc8f0b2770c525da8d6894 Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> AuthorDate: Tue Mar 19 19:38:48 2024 +0000 Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CommitDate: Thu Mar 28 11:25:07 2024 +0000 x86/mm: Refine address alignment checks in modify_xen_mappings_lite() Require 's' to be superpage aligned if given over a superpage mapping. This is expected to be the case in practice, and prevents v getting misaligned over superpages during the processing loop. Remove the requirement for 'e' to be page aligned. All this is doing is forcing work for the caller just to satisfy an assertion. Reported-by: Jan Beulich <JBeulich@xxxxxxxx> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> --- xen/arch/x86/mm.c | 11 +++++++---- xen/common/virtual_region.c | 8 ++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 62f5b811bb..631da8d7d2 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5900,9 +5900,10 @@ int destroy_xen_mappings(unsigned long s, unsigned long e) * * Must be limited to XEN_VIRT_{START,END}, i.e. over l2_xenmap[]. * Must be called with present flags, and over present mappings. - * It is the callers responsibility to not pass s or e in the middle of - * superpages if changing the permission on the whole superpage is going to be - * a problem. + * Must be called with 's' on a page/superpage boundary. + * + * 'e' has no alignment requirements, but the whole page/superpage containing + * the non-inclusive boundary will be updated. */ void init_or_livepatch modify_xen_mappings_lite( unsigned long s, unsigned long e, unsigned int nf) @@ -5917,7 +5918,7 @@ void init_or_livepatch modify_xen_mappings_lite( ASSERT(flags & _PAGE_PRESENT); ASSERT(IS_ALIGNED(s, PAGE_SIZE) && s >= XEN_VIRT_START); - ASSERT(IS_ALIGNED(e, PAGE_SIZE) && e <= XEN_VIRT_END); + ASSERT(e <= XEN_VIRT_END); while ( v < e ) { @@ -5929,6 +5930,8 @@ void init_or_livepatch modify_xen_mappings_lite( if ( l2e_get_flags(l2e) & _PAGE_PSE ) { + ASSERT(IS_ALIGNED(v, 1UL << L2_PAGETABLE_SHIFT)); + l2e_write_atomic(pl2e, l2e_from_intpte((l2e.l2 & ~fm) | flags)); v += 1UL << L2_PAGETABLE_SHIFT; diff --git a/xen/common/virtual_region.c b/xen/common/virtual_region.c index b4325bcda7..142f21e181 100644 --- a/xen/common/virtual_region.c +++ b/xen/common/virtual_region.c @@ -93,11 +93,11 @@ void relax_virtual_region_perms(void) list_for_each_entry_rcu( region, &virtual_region_list, list ) { modify_xen_mappings_lite((unsigned long)region->text_start, - PAGE_ALIGN((unsigned long)region->text_end), + (unsigned long)region->text_end, PAGE_HYPERVISOR_RWX); if ( region->rodata_start ) modify_xen_mappings_lite((unsigned long)region->rodata_start, - PAGE_ALIGN((unsigned long)region->rodata_end), + (unsigned long)region->rodata_end, PAGE_HYPERVISOR_RW); } rcu_read_unlock(&rcu_virtual_region_lock); @@ -111,11 +111,11 @@ void tighten_virtual_region_perms(void) list_for_each_entry_rcu( region, &virtual_region_list, list ) { modify_xen_mappings_lite((unsigned long)region->text_start, - PAGE_ALIGN((unsigned long)region->text_end), + (unsigned long)region->text_end, PAGE_HYPERVISOR_RX); if ( region->rodata_start ) modify_xen_mappings_lite((unsigned long)region->rodata_start, - PAGE_ALIGN((unsigned long)region->rodata_end), + (unsigned long)region->rodata_end, PAGE_HYPERVISOR_RO); } rcu_read_unlock(&rcu_virtual_region_lock); -- generated by git-patchbot for /home/xen/git/xen.git#master
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |