[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] xen/arm: Introduce flags_has_rwx helper
commit 0b61063c6e260780bc624e834d0acd99290d52d3 Author: Luca Fancellu <luca.fancellu@xxxxxxx> AuthorDate: Mon Jul 21 09:31:43 2025 +0100 Commit: Michal Orzel <michal.orzel@xxxxxxx> CommitDate: Wed Jul 23 09:49:24 2025 +0200 xen/arm: Introduce flags_has_rwx helper Introduce flags_has_rwx() function that will check if a mapping is both writable and executable when modifying or updating the mapping. This check was already present in pt.c but since it will be used also for MPU systems, it's wrapped into a function now. Signed-off-by: Luca Fancellu <luca.fancellu@xxxxxxx> Signed-off-by: Hari Limaye <hari.limaye@xxxxxxx> Reviewed-by: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx> Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx> --- xen/arch/arm/include/asm/mm.h | 2 ++ xen/arch/arm/mm.c | 15 +++++++++++++++ xen/arch/arm/mmu/pt.c | 9 +-------- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/include/asm/mm.h b/xen/arch/arm/include/asm/mm.h index 011bc1fd30..fb79aeb088 100644 --- a/xen/arch/arm/include/asm/mm.h +++ b/xen/arch/arm/include/asm/mm.h @@ -192,6 +192,8 @@ extern unsigned long frametable_base_pdx; /* Boot-time pagetable setup */ extern void setup_pagetables(void); +/* Check that the mapping flag has no W and X together */ +bool flags_has_rwx(unsigned int flags); /* Map FDT in boot pagetable */ extern void *early_fdt_map(paddr_t fdt_paddr); /* Remove early mappings */ diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 0613c19169..77e21f5f29 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -24,6 +24,21 @@ unsigned long frametable_base_pdx __read_mostly; +bool flags_has_rwx(unsigned int flags) +{ + /* + * The hardware was configured to forbid mapping both writable and + * executable. + * When modifying/creating mapping (i.e _PAGE_PRESENT is set), + * prevent any update if this happen. + */ + if ( (flags & _PAGE_PRESENT) && !PAGE_RO_MASK(flags) && + !PAGE_XN_MASK(flags) ) + return true; + else + return false; +} + void flush_page_to_ram(unsigned long mfn, bool sync_icache) { void *v = map_domain_page(_mfn(mfn)); diff --git a/xen/arch/arm/mmu/pt.c b/xen/arch/arm/mmu/pt.c index 4726e713ef..621b47dbf5 100644 --- a/xen/arch/arm/mmu/pt.c +++ b/xen/arch/arm/mmu/pt.c @@ -610,14 +610,7 @@ static int xen_pt_update(unsigned long virt, */ const mfn_t root = maddr_to_mfn(READ_SYSREG64(TTBR0_EL2)); - /* - * The hardware was configured to forbid mapping both writeable and - * executable. - * When modifying/creating mapping (i.e _PAGE_PRESENT is set), - * prevent any update if this happen. - */ - if ( (flags & _PAGE_PRESENT) && !PAGE_RO_MASK(flags) && - !PAGE_XN_MASK(flags) ) + if ( flags_has_rwx(flags) ) { mm_printk("Mappings should not be both Writeable and Executable.\n"); return -EINVAL; -- generated by git-patchbot for /home/xen/git/xen.git#staging
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |