[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 09/17] accel/tcg: Add force_aligned to CPUTLBEntryFull
From: |
Richard Henderson |
Subject: |
[PATCH v5 09/17] accel/tcg: Add force_aligned to CPUTLBEntryFull |
Date: |
Sun, 25 Sep 2022 10:51:16 +0000 |
Support per-page natural alignment checking. This will be
used by Arm for pages mapped with memory type Device.
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/exec/cpu-defs.h | 3 +++
accel/tcg/cputlb.c | 20 +++++++++++++-------
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h
index 7c0ba93826..d0acbb4d35 100644
--- a/include/exec/cpu-defs.h
+++ b/include/exec/cpu-defs.h
@@ -167,6 +167,9 @@ typedef struct CPUTLBEntryFull {
/* @byte_swap indicates that all accesses use inverted endianness. */
bool byte_swap;
+ /* @force_aligned indicates that all accesses must be aligned. */
+ bool force_aligned;
+
/*
* Allow target-specific additions to this structure.
* This may be used to cache items from the guest cpu
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index 1a5a6bd98b..01a89b4a1f 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -1146,7 +1146,7 @@ void tlb_set_page_full(CPUState *cpu, int mmu_idx,
/* Repeat the MMU check and TLB fill on every access. */
address |= TLB_INVALID_MASK;
}
- if (full->byte_swap) {
+ if (full->byte_swap || full->force_aligned) {
address |= TLB_SLOW_PATH;
}
@@ -1944,16 +1944,19 @@ load_helper(CPUArchState *env, target_ulong addr,
MemOpIdx oi,
/* Handle anything that isn't just a straight memory access. */
if (unlikely(tlb_addr & ~TARGET_PAGE_MASK)) {
- CPUTLBEntryFull *full;
+ CPUTLBEntryFull *full = &env_tlb(env)->d[mmu_idx].fulltlb[index];
bool need_swap;
/* For anything that is unaligned, recurse through full_load. */
if ((addr & (size - 1)) != 0) {
+ /* Honor per-page alignment requirements. */
+ if (full->force_aligned) {
+ cpu_unaligned_access(env_cpu(env), addr, access_type,
+ mmu_idx, retaddr);
+ }
goto do_unaligned_access;
}
- full = &env_tlb(env)->d[mmu_idx].fulltlb[index];
-
/* Handle watchpoints. */
if (unlikely(tlb_addr & TLB_WATCHPOINT)) {
/* On watchpoint hit, this will longjmp out. */
@@ -2349,16 +2352,19 @@ store_helper(CPUArchState *env, target_ulong addr,
uint64_t val,
/* Handle anything that isn't just a straight memory access. */
if (unlikely(tlb_addr & ~TARGET_PAGE_MASK)) {
- CPUTLBEntryFull *full;
+ CPUTLBEntryFull *full = &env_tlb(env)->d[mmu_idx].fulltlb[index];
bool need_swap;
/* For anything that is unaligned, recurse through byte stores. */
if ((addr & (size - 1)) != 0) {
+ /* Honor per-page alignment requirements. */
+ if (full->force_aligned) {
+ cpu_unaligned_access(env_cpu(env), addr, MMU_DATA_STORE,
+ mmu_idx, retaddr);
+ }
goto do_unaligned_access;
}
- full = &env_tlb(env)->d[mmu_idx].fulltlb[index];
-
/* Handle watchpoints. */
if (unlikely(tlb_addr & TLB_WATCHPOINT)) {
/* On watchpoint hit, this will longjmp out. */
--
2.34.1
- Re: [PATCH v5 03/17] accel/tcg: Suppress auto-invalidate in probe_access_internal, (continued)
- [PATCH v5 04/17] accel/tcg: Introduce probe_access_full, Richard Henderson, 2022/09/25
- [PATCH v5 05/17] accel/tcg: Introduce tlb_set_page_full, Richard Henderson, 2022/09/25
- [PATCH v5 06/17] include/exec: Introduce TARGET_PAGE_ENTRY_EXTRA, Richard Henderson, 2022/09/25
- [PATCH v5 07/17] target/sparc: Use tlb_set_page_full, Richard Henderson, 2022/09/25
- [PATCH v5 08/17] accel/tcg: Move byte_swap from MemTxAttrs to CPUTLBEntryFull, Richard Henderson, 2022/09/25
- [PATCH v5 09/17] accel/tcg: Add force_aligned to CPUTLBEntryFull,
Richard Henderson <=
- [PATCH v5 10/17] accel/tcg: Remove PageDesc code_bitmap, Richard Henderson, 2022/09/25
- [PATCH v5 11/17] accel/tcg: Use bool for page_find_alloc, Richard Henderson, 2022/09/25
- [PATCH v5 12/17] accel/tcg: Use DisasContextBase in plugin_gen_tb_start, Richard Henderson, 2022/09/25
- [PATCH v5 13/17] accel/tcg: Do not align tb->page_addr[0], Richard Henderson, 2022/09/25
- [PATCH v5 14/17] include/hw/core: Create struct CPUJumpCache, Richard Henderson, 2022/09/25
- [PATCH v5 15/17] accel/tcg: Introduce tb_pc and tb_pc_log, Richard Henderson, 2022/09/25