qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: Anton Johansson <anjo@rev.ng>
Subject: [PULL 08/47] target/arm: Replace TARGET_PAGE_ENTRY_EXTRA
Date: Tue,  3 Oct 2023 10:30:13 -0700	[thread overview]
Message-ID: <20231003173052.1601813-9-richard.henderson@linaro.org> (raw)
In-Reply-To: <20231003173052.1601813-1-richard.henderson@linaro.org>

From: Anton Johansson <anjo@rev.ng>

TARGET_PAGE_ENTRY_EXTRA is a macro that allows guests to specify additional
fields for caching with the full TLB entry.  This macro is replaced with
a union in CPUTLBEntryFull, thus making CPUTLB target-agnostic at the
cost of slightly inflated CPUTLBEntryFull for non-arm guests.

Note, this is needed to ensure that fields in CPUTLB don't vary in
offset between various targets.

(arm is the only guest actually making use of this feature.)

Signed-off-by: Anton Johansson <anjo@rev.ng>
Message-Id: <20230912153428.17816-2-anjo@rev.ng>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/exec/cpu-defs.h        | 18 +++++++++++++++---
 target/arm/cpu-param.h         | 12 ------------
 target/arm/ptw.c               |  4 ++--
 target/arm/tcg/mte_helper.c    |  2 +-
 target/arm/tcg/sve_helper.c    |  2 +-
 target/arm/tcg/tlb_helper.c    |  4 ++--
 target/arm/tcg/translate-a64.c |  2 +-
 7 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h
index 350287852e..46d2ac570f 100644
--- a/include/exec/cpu-defs.h
+++ b/include/exec/cpu-defs.h
@@ -135,9 +135,21 @@ typedef struct CPUTLBEntryFull {
      * This may be used to cache items from the guest cpu
      * page tables for later use by the implementation.
      */
-#ifdef TARGET_PAGE_ENTRY_EXTRA
-    TARGET_PAGE_ENTRY_EXTRA
-#endif
+    union {
+        /*
+         * Cache the attrs and shareability fields from the page table entry.
+         *
+         * For ARMMMUIdx_Stage2*, pte_attrs is the S2 descriptor bits [5:2].
+         * Otherwise, pte_attrs is the same as the MAIR_EL1 8-bit format.
+         * For shareability and guarded, as in the SH and GP fields respectively
+         * of the VMSAv8-64 PTEs.
+         */
+        struct {
+            uint8_t pte_attrs;
+            uint8_t shareability;
+            bool guarded;
+        } arm;
+    } extra;
 } CPUTLBEntryFull;
 #endif /* CONFIG_SOFTMMU */
 
diff --git a/target/arm/cpu-param.h b/target/arm/cpu-param.h
index b3b35f7aa1..f9b462a98f 100644
--- a/target/arm/cpu-param.h
+++ b/target/arm/cpu-param.h
@@ -31,18 +31,6 @@
 # define TARGET_PAGE_BITS_VARY
 # define TARGET_PAGE_BITS_MIN  10
 
-/*
- * Cache the attrs and shareability fields from the page table entry.
- *
- * For ARMMMUIdx_Stage2*, pte_attrs is the S2 descriptor bits [5:2].
- * Otherwise, pte_attrs is the same as the MAIR_EL1 8-bit format.
- * For shareability and guarded, as in the SH and GP fields respectively
- * of the VMSAv8-64 PTEs.
- */
-# define TARGET_PAGE_ENTRY_EXTRA  \
-    uint8_t pte_attrs;            \
-    uint8_t shareability;         \
-    bool guarded;
 #endif
 
 #endif
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
index bfbab26b9b..95db9ec4c3 100644
--- a/target/arm/ptw.c
+++ b/target/arm/ptw.c
@@ -579,7 +579,7 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
         }
         ptw->out_phys = full->phys_addr | (addr & ~TARGET_PAGE_MASK);
         ptw->out_rw = full->prot & PAGE_WRITE;
-        pte_attrs = full->pte_attrs;
+        pte_attrs = full->extra.arm.pte_attrs;
         ptw->out_space = full->attrs.space;
 #else
         g_assert_not_reached();
@@ -2036,7 +2036,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
 
         /* When in aarch64 mode, and BTI is enabled, remember GP in the TLB. */
         if (aarch64 && cpu_isar_feature(aa64_bti, cpu)) {
-            result->f.guarded = extract64(attrs, 50, 1); /* GP */
+            result->f.extra.arm.guarded = extract64(attrs, 50, 1); /* GP */
         }
     }
 
diff --git a/target/arm/tcg/mte_helper.c b/target/arm/tcg/mte_helper.c
index 2dd7eb3edb..70ac876105 100644
--- a/target/arm/tcg/mte_helper.c
+++ b/target/arm/tcg/mte_helper.c
@@ -137,7 +137,7 @@ static uint8_t *allocation_tag_mem_probe(CPUARMState *env, int ptr_mmu_idx,
     assert(!(flags & TLB_INVALID_MASK));
 
     /* If the virtual page MemAttr != Tagged, access unchecked. */
-    if (full->pte_attrs != 0xf0) {
+    if (full->extra.arm.pte_attrs != 0xf0) {
         return NULL;
     }
 
diff --git a/target/arm/tcg/sve_helper.c b/target/arm/tcg/sve_helper.c
index 7c103fc9f7..f006d152cc 100644
--- a/target/arm/tcg/sve_helper.c
+++ b/target/arm/tcg/sve_helper.c
@@ -5373,7 +5373,7 @@ bool sve_probe_page(SVEHostPage *info, bool nofault, CPUARMState *env,
     info->tagged = (flags & PAGE_ANON) && (flags & PAGE_MTE);
 #else
     info->attrs = full->attrs;
-    info->tagged = full->pte_attrs == 0xf0;
+    info->tagged = full->extra.arm.pte_attrs == 0xf0;
 #endif
 
     /* Ensure that info->host[] is relative to addr, not addr + mem_off. */
diff --git a/target/arm/tcg/tlb_helper.c b/target/arm/tcg/tlb_helper.c
index b22b2a4c6e..59bff8b452 100644
--- a/target/arm/tcg/tlb_helper.c
+++ b/target/arm/tcg/tlb_helper.c
@@ -334,8 +334,8 @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
             address &= TARGET_PAGE_MASK;
         }
 
-        res.f.pte_attrs = res.cacheattrs.attrs;
-        res.f.shareability = res.cacheattrs.shareability;
+        res.f.extra.arm.pte_attrs = res.cacheattrs.attrs;
+        res.f.extra.arm.shareability = res.cacheattrs.shareability;
 
         tlb_set_page_full(cs, mmu_idx, address, &res.f);
         return true;
diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c
index 97f25b4451..6523bfb339 100644
--- a/target/arm/tcg/translate-a64.c
+++ b/target/arm/tcg/translate-a64.c
@@ -13904,7 +13904,7 @@ static bool is_guarded_page(CPUARMState *env, DisasContext *s)
                               false, &host, &full, 0);
     assert(!(flags & TLB_INVALID_MASK));
 
-    return full->guarded;
+    return full->extra.arm.guarded;
 #endif
 }
 
-- 
2.34.1



  parent reply	other threads:[~2023-10-03 17:37 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-03 17:30 [PULL 00/47] tcg patch queue Richard Henderson
2023-10-03 17:30 ` [PULL 01/47] accel: Rename accel_cpu_realizefn() -> accel_cpu_realize() Richard Henderson
2023-10-03 17:30 ` [PULL 02/47] accel: Rename AccelCPUClass::cpu_realizefn() -> cpu_target_realize() Richard Henderson
2023-10-03 17:30 ` [PULL 03/47] accel: Rename accel_cpu_realize() -> accel_cpu_common_realize() Richard Henderson
2023-10-03 17:30 ` [PULL 04/47] accel: Introduce accel_cpu_common_unrealize() stub Richard Henderson
2023-10-03 17:30 ` [PULL 05/47] accel: Declare AccelClass::cpu_common_[un]realize() handlers Richard Henderson
2023-10-03 17:30 ` [PULL 06/47] accel/tcg: Have tcg_exec_realizefn() return a boolean Richard Henderson
2023-10-03 17:30 ` [PULL 07/47] accel/tcg: Restrict tcg_exec_[un]realizefn() to TCG Richard Henderson
2023-10-03 17:30 ` Richard Henderson [this message]
2023-10-03 17:30 ` [PULL 09/47] accel/tcg: Move CPUTLB definitions from cpu-defs.h Richard Henderson
2023-10-03 17:30 ` [PULL 10/47] qom: Propagate alignment through type system Richard Henderson
2023-10-03 17:30 ` [PULL 11/47] target/arm: Remove size and alignment for cpu subclasses Richard Henderson
2023-10-03 17:30 ` [PULL 12/47] target/*: Add instance_align to all cpu base classes Richard Henderson
2023-10-03 17:30 ` [PULL 13/47] accel/tcg: Validate placement of CPUNegativeOffsetState Richard Henderson
2023-10-03 17:30 ` [PULL 14/47] accel/tcg: Move CPUNegativeOffsetState into CPUState Richard Henderson
2023-10-03 17:30 ` [PULL 15/47] accel/tcg: Remove CPUState.icount_decr_ptr Richard Henderson
2023-10-03 17:30 ` [PULL 16/47] accel/tcg: Move can_do_io to CPUNegativeOffsetState Richard Henderson
2023-10-03 17:30 ` [PULL 17/47] accel/tcg: Remove cpu_neg() Richard Henderson
2023-10-03 17:30 ` [PULL 18/47] tcg: Rename cpu_env to tcg_env Richard Henderson
2023-10-03 17:30 ` [PULL 19/47] accel/tcg: Replace CPUState.env_ptr with cpu_env() Richard Henderson
2023-10-03 17:30 ` [PULL 20/47] accel/tcg: Remove cpu_set_cpustate_pointers Richard Henderson
2023-10-03 17:30 ` [PULL 21/47] accel/tcg: Remove env_neg() Richard Henderson
2023-10-03 17:30 ` [PULL 22/47] tcg: Remove TCGContext.tlb_fast_offset Richard Henderson
2023-10-03 17:30 ` [PULL 23/47] accel/tcg: Modify tlb_*() to use CPUState Richard Henderson
2023-10-03 17:30 ` [PULL 24/47] accel/tcg: Modify probe_access_internal() " Richard Henderson
2023-10-03 17:30 ` [PULL 25/47] accel/tcg: Modify memory access functions " Richard Henderson
2023-10-03 17:30 ` [PULL 26/47] accel/tcg: Modify atomic_mmu_lookup() " Richard Henderson
2023-10-03 17:30 ` [PULL 27/47] accel/tcg: Use CPUState in atomicity helpers Richard Henderson
2023-10-03 17:30 ` [PULL 28/47] accel/tcg: Remove env_tlb() Richard Henderson
2023-10-03 17:30 ` [PULL 29/47] accel/tcg: Unify user and softmmu do_[st|ld]*_mmu() Richard Henderson
2023-10-03 17:30 ` [PULL 30/47] accel/tcg: move ld/st helpers to ldst_common.c.inc Richard Henderson
2023-10-03 17:30 ` [PULL 31/47] exec: Make EXCP_FOO definitions target agnostic Richard Henderson
2023-10-03 17:30 ` [PULL 32/47] exec: Move cpu_loop_foo() target agnostic functions to 'cpu-common.h' Richard Henderson
2023-10-03 17:30 ` [PULL 33/47] accel/tcg: Restrict dump_exec_info() declaration Richard Henderson
2023-10-03 17:30 ` [PULL 34/47] accel: Make accel-blocker.o target agnostic Richard Henderson
2023-10-03 17:30 ` [PULL 35/47] accel: Rename accel-common.c -> accel-target.c Richard Henderson
2023-10-03 17:30 ` [PULL 36/47] exec: Rename cpu.c -> cpu-target.c Richard Henderson
2023-10-03 17:30 ` [PULL 37/47] exec: Rename target specific page-vary.c -> page-vary-target.c Richard Henderson
2023-10-03 17:30 ` [PULL 38/47] accel/tcg: Rename target-specific 'internal.h' -> 'internal-target.h' Richard Henderson
2023-10-03 17:30 ` [PULL 39/47] accel/tcg: Make monitor.c a target-agnostic unit Richard Henderson
2023-10-03 17:30 ` [PULL 40/47] accel/tcg: Make icount.o a target agnostic unit Richard Henderson
2023-10-03 17:30 ` [PULL 41/47] accel/tcg: Make cpu-exec-common.c " Richard Henderson
2023-10-03 17:30 ` [PULL 42/47] tcg: Remove argument to tcg_prologue_init Richard Henderson
2023-10-03 17:30 ` [PULL 43/47] tcg: Split out tcg init functions to tcg/startup.h Richard Henderson
2023-10-03 17:30 ` [PULL 44/47] linux-user/hppa: Fix struct target_sigcontext layout Richard Henderson
2023-10-03 17:30 ` [PULL 45/47] build: Remove --enable-gprof Richard Henderson
2023-10-03 17:30 ` [PULL 46/47] tests/avocado: Re-enable MIPS Malta tests (GitLab issue #1884 fixed) Richard Henderson
2023-10-03 17:30 ` [PULL 47/47] tcg/loongarch64: Fix buid error Richard Henderson
2023-10-04 14:57 ` [PULL 00/47] tcg patch queue Stefan Hajnoczi
2023-10-04 16:28   ` Richard Henderson
2023-10-04 16:46     ` Stefan Hajnoczi
2023-10-04 17:08       ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231003173052.1601813-9-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=anjo@rev.ng \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).