Message ID | 20190423103855.1257968-1-jakub.jermar@kernkonzept.com |
---|---|
State | New |
Headers | show |
Series | mips: Decide to map PAGE_EXEC in map_address | expand |
Patchew URL: https://patchew.org/QEMU/20190423103855.1257968-1-jakub.jermar@kernkonzept.com/ Hi, This series seems to have some coding style problems. See output below for more information: Type: series Message-id: 20190423103855.1257968-1-jakub.jermar@kernkonzept.com Subject: [Qemu-devel] [PATCH] mips: Decide to map PAGE_EXEC in map_address === TEST SCRIPT BEGIN === #!/bin/bash git rev-parse base > /dev/null || exit 0 git config --local diff.renamelimit 0 git config --local diff.renames True git config --local diff.algorithm histogram ./scripts/checkpatch.pl --mailback base.. === TEST SCRIPT END === Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 From https://github.com/patchew-project/qemu * [new tag] patchew/20190423103855.1257968-1-jakub.jermar@kernkonzept.com -> patchew/20190423103855.1257968-1-jakub.jermar@kernkonzept.com Switched to a new branch 'test' 40e0d72157 mips: Decide to map PAGE_EXEC in map_address === OUTPUT BEGIN === ERROR: braces {} are necessary for all arms of this statement #47: FILE: target/mips/helper.c:104: + if (!(n ? tlb->XI1 : tlb->XI0)) [...] total: 1 errors, 0 warnings, 52 lines checked Commit 40e0d7215724 (mips: Decide to map PAGE_EXEC in map_address) has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS. === OUTPUT END === Test command exited with code: 1 The full log is available at http://patchew.org/logs/20190423103855.1257968-1-jakub.jermar@kernkonzept.com/testing.checkpatch/?type=message. --- Email generated automatically by Patchew [https://patchew.org/]. Please send your feedback to patchew-devel@redhat.com
diff --git a/target/mips/helper.c b/target/mips/helper.c index c44cdca3b5..f182935fcf 100644 --- a/target/mips/helper.c +++ b/target/mips/helper.c @@ -43,7 +43,7 @@ int no_mmu_map_address (CPUMIPSState *env, hwaddr *physical, int *prot, target_ulong address, int rw, int access_type) { *physical = address; - *prot = PAGE_READ | PAGE_WRITE; + *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; return TLBRET_MATCH; } @@ -61,7 +61,7 @@ int fixed_mmu_map_address (CPUMIPSState *env, hwaddr *physical, int *prot, else *physical = address; - *prot = PAGE_READ | PAGE_WRITE; + *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; return TLBRET_MATCH; } @@ -101,6 +101,8 @@ int r4k_map_address (CPUMIPSState *env, hwaddr *physical, int *prot, *prot = PAGE_READ; if (n ? tlb->D1 : tlb->D0) *prot |= PAGE_WRITE; + if (!(n ? tlb->XI1 : tlb->XI0)) + *prot |= PAGE_EXEC; return TLBRET_MATCH; } return TLBRET_DIRTY; @@ -182,7 +184,7 @@ static int get_seg_physical_address(CPUMIPSState *env, hwaddr *physical, } else { /* The segment is unmapped */ *physical = physical_base | (real_address & segmask); - *prot = PAGE_READ | PAGE_WRITE; + *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; return TLBRET_MATCH; } } @@ -913,8 +915,8 @@ int mips_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw, } if (ret == TLBRET_MATCH) { tlb_set_page(cs, address & TARGET_PAGE_MASK, - physical & TARGET_PAGE_MASK, prot | PAGE_EXEC, - mmu_idx, TARGET_PAGE_SIZE); + physical & TARGET_PAGE_MASK, prot, mmu_idx, + TARGET_PAGE_SIZE); ret = 0; } else if (ret < 0) #endif @@ -936,8 +938,8 @@ int mips_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw, address, rw, access_type, mmu_idx); if (ret == TLBRET_MATCH) { tlb_set_page(cs, address & TARGET_PAGE_MASK, - physical & TARGET_PAGE_MASK, prot | PAGE_EXEC, - mmu_idx, TARGET_PAGE_SIZE); + physical & TARGET_PAGE_MASK, prot, mmu_idx, + TARGET_PAGE_SIZE); ret = 0; return ret; }
This commit addresses QEMU Bug #1825311: mips_cpu_handle_mmu_fault renders all accessed pages executable It allows finer-grained control over whether the accessed page should be executable by moving the decision to the underlying map_address function, which has more information for this. As a result, pages that have the XI bit set in the TLB and are accessed for read/write, don't suddenly end up being executable. Signed-off-by: Jakub Jermář <jakub.jermar@kernkonzept.com> --- target/mips/helper.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)