All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PULL 53/54] target/arm: Advertise support for FEAT_BBM level 2
Date: Thu, 28 Apr 2022 15:39:57 +0100	[thread overview]
Message-ID: <20220428143958.2451229-54-peter.maydell@linaro.org> (raw)
In-Reply-To: <20220428143958.2451229-1-peter.maydell@linaro.org>

The description in the Arm ARM of the requirements of FEAT_BBM is
admirably clear on the guarantees it provides software, but slightly
more obscure on what that means for implementations.  The description
of the equivalent SMMU feature in the SMMU specification (IHI0070D.b
section 3.21.1) is perhaps a bit more detailed and includes some
example valid implementation choices. (The SMMU version of this
feature is slightly tighter than the CPU version: the CPU is permitted
to raise TLB Conflict aborts in some situations that the SMMU may
not. This doesn't matter for QEMU because we don't want to do TLB
Conflict aborts anyway.)

The informal summary of FEAT_BBM is that it is about permitting an OS
to switch a range of memory between "covered by a huge page" and
"covered by a sequence of normal pages" without having to engage in
the 'break-before-make' dance that has traditionally been
necessary. The 'break-before-make' sequence is:

 * replace the old translation table entry with an invalid entry
 * execute a DSB insn
 * execute a broadcast TLB invalidate insn
 * execute a DSB insn
 * write the new translation table entry
 * execute a DSB insn

The point of this is to ensure that no TLB can simultaneously contain
TLB entries for the old and the new entry, which would traditionally
be UNPREDICTABLE (allowing the CPU to generate a TLB Conflict fault
or to use a random mishmash of values from the old and the new
entry).  FEAT_BBM level 2 says "for the specific case where the only
thing that changed is the size of the block, the TLB is guaranteed
not to do weird things even if there are multiple entries for an
address", which means that software can now do:

 * replace old translation table entry with new entry
 * DSB
 * broadcast TLB invalidate
 * DSB

As the SMMU spec notes, valid ways to do this include:

 * if there are multiple entries in the TLB for an address,
   choose one of them and use it, ignoring the others
 * if there are multiple entries in the TLB for an address,
   throw them all out and do a page table walk to get a new one

QEMU's page table walk implementation for Arm CPUs already meets the
requirements for FEAT_BBM level 2. When we cache an entry in our TCG
TLB, we do so only for the specific (non-huge) page that the address
is in, and there is no way for the TLB data structure to ever have
more than one TLB entry for that page. (We handle huge pages only in
that we track what part of the address space is covered by huge pages
so that a TLB invalidate operation for an address in a huge page
results in an invalidation of the whole TLB.) We ignore the Contiguous
bit in page table entries, so we don't have to do anything for the
parts of FEAT_BBM that deal with changis to the Contiguous bit.

FEAT_BBM level 2 also requires that the nT bit in block descriptors
must be ignored; since commit 39a1fd25287f5dece5 we do this.

It's therefore safe for QEMU to advertise FEAT_BBM level 2 by
setting ID_AA64MMFR2_EL1.BBM to 2.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20220426160422.2353158-3-peter.maydell@linaro.org
---
 docs/system/arm/emulation.rst | 1 +
 target/arm/cpu64.c            | 1 +
 2 files changed, 2 insertions(+)

diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst
index 6ed2417f6fc..c3bd0676a87 100644
--- a/docs/system/arm/emulation.rst
+++ b/docs/system/arm/emulation.rst
@@ -9,6 +9,7 @@ the following architecture extensions:
 - FEAT_AA32HPD (AArch32 hierarchical permission disables)
 - FEAT_AA32I8MM (AArch32 Int8 matrix multiplication instructions)
 - FEAT_AES (AESD and AESE instructions)
+- FEAT_BBM at level 2 (Translation table break-before-make levels)
 - FEAT_BF16 (AArch64 BFloat16 instructions)
 - FEAT_BTI (Branch Target Identification)
 - FEAT_DIT (Data Independent Timing instructions)
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
index ec2d159163f..2974cbc0d35 100644
--- a/target/arm/cpu64.c
+++ b/target/arm/cpu64.c
@@ -840,6 +840,7 @@ static void aarch64_max_initfn(Object *obj)
     t = FIELD_DP64(t, ID_AA64MMFR2, ST, 1); /* TTST */
     t = FIELD_DP64(t, ID_AA64MMFR2, VARANGE, 1); /* FEAT_LVA */
     t = FIELD_DP64(t, ID_AA64MMFR2, TTL, 1); /* FEAT_TTL */
+    t = FIELD_DP64(t, ID_AA64MMFR2, BBM, 2); /* FEAT_BBM at level 2 */
     cpu->isar.id_aa64mmfr2 = t;
 
     t = cpu->isar.id_aa64zfr0;
-- 
2.25.1



  parent reply	other threads:[~2022-04-28 15:26 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-28 14:39 [PULL 00/54] target-arm queue Peter Maydell
2022-04-28 14:39 ` [PULL 01/54] target/arm: Use tcg_constant in gen_probe_access Peter Maydell
2022-04-28 14:39 ` [PULL 02/54] target/arm: Use tcg_constant in gen_mte_check* Peter Maydell
2022-04-28 14:39 ` [PULL 03/54] target/arm: Use tcg_constant in gen_exception* Peter Maydell
2022-04-28 14:39 ` [PULL 04/54] target/arm: Use tcg_constant in gen_adc_CC Peter Maydell
2022-04-28 14:39 ` [PULL 05/54] target/arm: Use tcg_constant in handle_msr_i Peter Maydell
2022-04-28 14:39 ` [PULL 06/54] target/arm: Use tcg_constant in handle_sys Peter Maydell
2022-04-28 14:39 ` [PULL 07/54] target/arm: Use tcg_constant in disas_exc Peter Maydell
2022-04-28 14:39 ` [PULL 08/54] target/arm: Use tcg_constant in gen_compare_and_swap_pair Peter Maydell
2022-04-28 14:39 ` [PULL 09/54] target/arm: Use tcg_constant in disas_ld_lit Peter Maydell
2022-04-28 14:39 ` [PULL 10/54] target/arm: Use tcg_constant in disas_ldst_* Peter Maydell
2022-04-28 14:39 ` [PULL 11/54] target/arm: Use tcg_constant in disas_add_sum_imm* Peter Maydell
2022-04-28 14:39 ` [PULL 12/54] target/arm: Use tcg_constant in disas_movw_imm Peter Maydell
2022-04-28 14:39 ` [PULL 13/54] target/arm: Use tcg_constant in shift_reg_imm Peter Maydell
2022-04-28 14:39 ` [PULL 14/54] target/arm: Use tcg_constant in disas_cond_select Peter Maydell
2022-04-28 14:39 ` [PULL 15/54] target/arm: Use tcg_constant in handle_{rev16,crc32} Peter Maydell
2022-04-28 14:39 ` [PULL 16/54] target/arm: Use tcg_constant in disas_data_proc_2src Peter Maydell
2022-04-28 14:39 ` [PULL 17/54] target/arm: Use tcg_constant in disas_fp* Peter Maydell
2022-04-28 14:39 ` [PULL 18/54] target/arm: Use tcg_constant in simd shift expanders Peter Maydell
2022-04-28 14:39 ` [PULL 19/54] target/arm: Use tcg_constant in simd fp/int conversion Peter Maydell
2022-04-28 14:39 ` [PULL 20/54] target/arm: Use tcg_constant in 2misc expanders Peter Maydell
2022-04-28 14:39 ` [PULL 21/54] target/arm: Use tcg_constant in balance of translate-a64.c Peter Maydell
2022-04-28 14:39 ` [PULL 22/54] target/arm: Use tcg_constant for aa32 exceptions Peter Maydell
2022-04-28 14:39 ` [PULL 23/54] target/arm: Use tcg_constant for disas_iwmmxt_insn Peter Maydell
2022-04-28 14:39 ` [PULL 24/54] target/arm: Use tcg_constant for gen_{msr,mrs} Peter Maydell
2022-04-28 14:39 ` [PULL 25/54] target/arm: Use tcg_constant for vector shift expanders Peter Maydell
2022-04-28 14:39 ` [PULL 26/54] target/arm: Use tcg_constant for do_coproc_insn Peter Maydell
2022-04-28 14:39 ` [PULL 27/54] target/arm: Use tcg_constant for gen_srs Peter Maydell
2022-04-28 14:39 ` [PULL 28/54] target/arm: Use tcg_constant for op_s_{rri,rxi}_rot Peter Maydell
2022-04-28 14:39 ` [PULL 29/54] target/arm: Use tcg_constant for MOVW, UMAAL, CRC32 Peter Maydell
2022-04-28 14:39 ` [PULL 30/54] target/arm: Use tcg_constant for v7m MRS, MSR Peter Maydell
2022-04-28 14:39 ` [PULL 31/54] target/arm: Use tcg_constant for TT, SAT, SMMLA Peter Maydell
2022-04-28 14:39 ` [PULL 32/54] target/arm: Use tcg_constant in LDM, STM Peter Maydell
2022-04-28 14:39 ` [PULL 33/54] target/arm: Use tcg_constant in CLRM, DLS, WLS, LE Peter Maydell
2022-04-28 14:39 ` [PULL 34/54] target/arm: Use tcg_constant in trans_CPS_v7m Peter Maydell
2022-04-28 14:39 ` [PULL 35/54] target/arm: Use tcg_constant in trans_CSEL Peter Maydell
2022-04-28 14:39 ` [PULL 36/54] target/arm: Use tcg_constant for trans_INDEX_* Peter Maydell
2022-04-28 14:39 ` [PULL 37/54] target/arm: Use tcg_constant in SINCDEC, INCDEC Peter Maydell
2022-04-28 14:39 ` [PULL 38/54] target/arm: Use tcg_constant in FCPY, CPY Peter Maydell
2022-04-28 14:39 ` [PULL 39/54] target/arm: Use tcg_constant in {incr, wrap}_last_active Peter Maydell
2022-04-28 14:39 ` [PULL 40/54] target/arm: Use tcg_constant in do_clast_scalar Peter Maydell
2022-04-28 14:39 ` [PULL 41/54] target/arm: Use tcg_constant in WHILE Peter Maydell
2022-04-28 14:39 ` [PULL 42/54] target/arm: Use tcg_constant in LD1, ST1 Peter Maydell
2022-04-28 14:39 ` [PULL 43/54] target/arm: Use tcg_constant in SUBR Peter Maydell
2022-04-28 14:39 ` [PULL 44/54] target/arm: Use tcg_constant in do_zzi_{sat, ool}, do_fp_imm Peter Maydell
2022-04-28 14:39 ` [PULL 45/54] target/arm: Use tcg_constant for predicate descriptors Peter Maydell
2022-04-28 14:39 ` [PULL 46/54] target/arm: Use tcg_constant for do_brk{2,3} Peter Maydell
2022-04-28 14:39 ` [PULL 47/54] target/arm: Use tcg_constant for vector descriptor Peter Maydell
2022-04-28 14:39 ` [PULL 48/54] target/arm: Disable cryptographic instructions when neon is disabled Peter Maydell
2022-04-28 14:39 ` [PULL 49/54] target/arm: Use field names for accessing DBGWCRn Peter Maydell
2022-04-28 14:39 ` [PULL 50/54] hw/arm/smmuv3: Cache event fault record Peter Maydell
2022-04-28 14:39 ` [PULL 51/54] hw/arm/smmuv3: Add space in guest error message Peter Maydell
2022-04-28 14:39 ` [PULL 52/54] target/arm: Advertise support for FEAT_TTL Peter Maydell
2022-04-28 14:39 ` Peter Maydell [this message]
2022-04-28 14:39 ` [PULL 54/54] hw/arm/smmuv3: Advertise support for SMMUv3.2-BBML2 Peter Maydell
2022-04-28 17:10 ` [PULL 00/54] target-arm queue 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=20220428143958.2451229-54-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.