diff options
author | Peter Maydell | 2016-07-11 18:17:02 +0200 |
---|---|---|
committer | Peter Maydell | 2016-07-11 18:17:02 +0200 |
commit | 7de2cc8f787a9cf8edff616c75ea9e73a86db9ca (patch) | |
tree | 96b2f3dc264a479d9cfc1e8918b38346d94dafdd /cputlb.c | |
parent | Merge remote-tracking branch 'remotes/ehabkost/tags/x86-pull-request' into st... (diff) | |
parent | translate-all: Fix user-mode self-modifying code in 2 page long TB (diff) | |
download | qemu-7de2cc8f787a9cf8edff616c75ea9e73a86db9ca.tar.gz qemu-7de2cc8f787a9cf8edff616c75ea9e73a86db9ca.tar.xz qemu-7de2cc8f787a9cf8edff616c75ea9e73a86db9ca.zip |
Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20160708' into staging
two self-modifying code fixes
# gpg: Signature made Fri 08 Jul 2016 21:28:50 BST
# gpg: using RSA key 0xAD1270CC4DD0279B
# gpg: Good signature from "Richard Henderson <rth7680@gmail.com>"
# gpg: aka "Richard Henderson <rth@redhat.com>"
# gpg: aka "Richard Henderson <rth@twiddle.net>"
# Primary key fingerprint: 9CB1 8DDA F8E8 49AD 2AFC 16A4 AD12 70CC 4DD0 279B
* remotes/rth/tags/pull-tcg-20160708:
translate-all: Fix user-mode self-modifying code in 2 page long TB
cputlb: Fix for self-modifying writes across page boundaries
cputlb: Add address parameter to VICTIM_TLB_HIT
cputlb: Move VICTIM_TLB_HIT out of line
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'cputlb.c')
-rw-r--r-- | cputlb.c | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -498,6 +498,35 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr) return qemu_ram_addr_from_host_nofail(p); } +/* Return true if ADDR is present in the victim tlb, and has been copied + back to the main tlb. */ +static bool victim_tlb_hit(CPUArchState *env, size_t mmu_idx, size_t index, + size_t elt_ofs, target_ulong page) +{ + size_t vidx; + for (vidx = 0; vidx < CPU_VTLB_SIZE; ++vidx) { + CPUTLBEntry *vtlb = &env->tlb_v_table[mmu_idx][vidx]; + target_ulong cmp = *(target_ulong *)((uintptr_t)vtlb + elt_ofs); + + if (cmp == page) { + /* Found entry in victim tlb, swap tlb and iotlb. */ + CPUTLBEntry tmptlb, *tlb = &env->tlb_table[mmu_idx][index]; + CPUIOTLBEntry tmpio, *io = &env->iotlb[mmu_idx][index]; + CPUIOTLBEntry *vio = &env->iotlb_v[mmu_idx][vidx]; + + tmptlb = *tlb; *tlb = *vtlb; *vtlb = tmptlb; + tmpio = *io; *io = *vio; *vio = tmpio; + return true; + } + } + return false; +} + +/* Macro to call the above, with local variables from the use context. */ +#define VICTIM_TLB_HIT(TY, ADDR) \ + victim_tlb_hit(env, mmu_idx, index, offsetof(CPUTLBEntry, TY), \ + (ADDR) & TARGET_PAGE_MASK) + #define MMUSUFFIX _mmu #define SHIFT 0 |