target/arm: Add support for FEAT_TLBIOS and FEAT_TLBIRANGE
v5 cover target/arm: Add support for FEAT_TLBIOS and FEAT_TLBIRANGE
ARMv8.4 adds the mandatory FEAT_TLBIOS and FEAT_TLBIRANGE. They provides TLBI maintenance instructions that extend to the Outer Shareable domain and that apply to a range of input addresses.
Changes from v4 to v5:
o Split changes to cputlb.c and exec_all.c into a separate commit.
o Return a bool from tlb_flush_page_bits_locked to indicate if a full flush has been done.
o Update flush_page_range_bits_* to exit early when a full flush has been done.
o Run tb_flush_jmp_cache in a separate loop.
o Don't check for 2 regimes for cases where we know there's only one.
Rebecca Cran (4):
accel/tcg: Add TLB invalidation support for ranges of addresses target/arm: Add support for FEAT_TLBIRANGE target/arm: Add support for FEAT_TLBIOS
target/arm: set ID_AA64ISAR0.TLB to 2 for max AARCH64 CPU type
accel/tcg/cputlb.c | 130 ++++++- include/exec/exec-all.h | 45 +++ target/arm/cpu.h | 10 + target/arm/cpu64.c | 1 + target/arm/helper.c | 369 ++++++++++++++++++++ 5 files changed, 552 insertions(+), 3 deletions(-)
Signature · 1 line
2.26.2
PATCH v5 1/4 accel/tcg: Add TLB invalidation support for ranges of addresses
Add functions to support the FEAT_TLBIRANGE ARMv8.4 feature that adds TLB invalidation instructions to invalidate ranges of addresses.
--- accel/tcg/cputlb.c | 130 +++++++++++++++++++- include/exec/exec-all.h | 45 +++++++ 2 files changed, 172 insertions(+), 3 deletions(-)
accel/tcg/cputlb.c +127 -3
@@ -709,7 +709,7 @@ void tlb_flush_page_all_cpus_synced(CPUState *src, target_ulong addr)tlb_flush_page_by_mmuidx_all_cpus_synced (src, addr,ALL_MMUIDX_BITS ); } -static void tlb_flush_page_bits_locked (CPUArchState *env,int midx, +static bool tlb_flush_page_bits_locked (CPUArchState *env,int midx,target_ulong page,unsigned bits) {CPUTLBDesc *d = &env_tlb (env)->d[midx];
@@ -729,7 +729,7 @@ static void tlb_flush_page_bits_locked(CPUArchState *env, int midx, TARGET_FMT_lx"/" TARGET_FMT_lx")\n" , midx, page, mask);tlb_flush_one_mmuidx_locked (env, midx,get_clock_realtime ()); -return ; +return true; }/* Check if we need to flush due to large pages. */
@@ -738,13 +738,14 @@ static void tlb_flush_page_bits_locked(CPUArchState *env, int midx, TARGET_FMT_lx"/" TARGET_FMT_lx")\n" , midx, d->large_page_addr, d->large_page_mask);tlb_flush_one_mmuidx_locked (env, midx,get_clock_realtime ()); -return ; +return true; }if (tlb_flush_entry_mask_locked (tlb_entry (env, midx, page), page, mask)) {tlb_n_used_entries_dec (env, midx); }tlb_flush_vtlb_page_mask_locked (env, midx, page, mask); +return false; } typedef struct {
@@ -943,6 +944,129 @@ void tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CPUState *src_cpu, } } +typedef struct { +target_ulong addr; +target_ulong length; +uint16_t idxmap; +uint16_t bits; +}TLBFlushPageRangeBitsByMMUIdxData ; + +static void +tlb_flush_page_range_bits_by_mmuidx_async_0 (CPUState *cpu, +target_ulong addr, +target_ulong length, +uint16_t idxmap, +unsigned bits) +{ +CPUArchState *env = cpu->env_ptr; +int mmu_idx; +target_ulong l; +target_ulong page = addr; +bool full_flush; + +assert_cpu_is_self (cpu); + +tlb_debug ("page addr:" TARGET_FMT_lx"/%u len: " TARGET_FMT_lx +" mmu_map:0x%x\n" , + addr, bits, length, idxmap); + +qemu_spin_lock (&env_tlb (env)->c.lock); +for (mmu_idx =0 ; mmu_idx <NB_MMU_MODES ; mmu_idx++) { +if ((idxmap >> mmu_idx) &1 ) { +for (l =0 ; l < length; l +=TARGET_PAGE_SIZE ) { + page = addr + l; + full_flush =tlb_flush_page_bits_locked (env, mmu_idx, + page, bits); +if (full_flush) { +break ; + } + } + } + } +qemu_spin_unlock (&env_tlb (env)->c.lock); + +for (l =0 ; l < length; l +=TARGET_PAGE_SIZE ) { +tb_flush_jmp_cache (cpu, page); + } +} + +static void +tlb_flush_page_range_bits_by_mmuidx_async_1 (CPUState *cpu, +run_on_cpu_data data) +{ +TLBFlushPageRangeBitsByMMUIdxData *d = data.host_ptr; + +tlb_flush_page_range_bits_by_mmuidx_async_0 (cpu, d->addr, d->length, + d->idxmap, d->bits); + +g_free (d); +} + +void tlb_flush_page_range_bits_by_mmuidx (CPUState *cpu, +target_ulong addr, +target_ulong length, +uint16_t idxmap, +unsigned bits) +{ +TLBFlushPageRangeBitsByMMUIdxData d; +TLBFlushPageRangeBitsByMMUIdxData *p; + +/* This should already be page aligned */ + addr &=TARGET_PAGE_BITS ; + + d.addr = addr &TARGET_PAGE_MASK ; + d.idxmap = idxmap; + d.bits = bits; + d.length = length; + +if (qemu_cpu_is_self (cpu)) { +tlb_flush_page_range_bits_by_mmuidx_async_0 (cpu, addr, length, + idxmap, bits); + }else { + p =g_new (TLBFlushPageRangeBitsByMMUIdxData,1 ); + +/* Allocate a structure, freed by the worker. */ + *p = d; +async_run_on_cpu (cpu, tlb_flush_page_range_bits_by_mmuidx_async_1, +RUN_ON_CPU_HOST_PTR (p)); + } +} + +void tlb_flush_page_range_bits_by_mmuidx_all_cpus_synced (CPUState *src_cpu, +target_ulong addr, +target_ulong length, +uint16_t idxmap, +unsigned bits) +{ +TLBFlushPageRangeBitsByMMUIdxData d; +TLBFlushPageRangeBitsByMMUIdxData *p; +CPUState *dst_cpu; + +/* This should already be page aligned */ + addr &=TARGET_PAGE_BITS ; + + d.addr = addr; + d.idxmap = idxmap; + d.bits = bits; + d.length = length; + +/* Allocate a separate data block for each destination cpu. */ +CPU_FOREACH (dst_cpu) { +if (dst_cpu != src_cpu) { + p =g_new (TLBFlushPageRangeBitsByMMUIdxData,1 ); + *p = d; +async_run_on_cpu (dst_cpu, + tlb_flush_page_range_bits_by_mmuidx_async_1, +RUN_ON_CPU_HOST_PTR (p)); + } + } + + p =g_new (TLBFlushPageRangeBitsByMMUIdxData,1 ); + *p = d; +async_safe_run_on_cpu (src_cpu, tlb_flush_page_range_bits_by_mmuidx_async_1, +RUN_ON_CPU_HOST_PTR (p)); +} +/* update the TLBs so that writes to code in the virtual page 'addr' can be detected */ void tlb_protect_code (ram_addr_t ram_addr)
include/exec/exec-all.h +45 -0
57 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH v5 2/4 target/arm: Add support for FEAT_TLBIRANGE
In reply to Rebecca CranARMv8.4 adds the mandatory FEAT_TLBIRANGE. It provides TLBI maintenance instructions that apply to a range of input addresses.
--- target/arm/cpu.h | 5 + target/arm/helper.c | 294 ++++++++++++++++++++ 2 files changed, 299 insertions(+)
target/arm/cpu.h +5 -0
@@ -4038,6 +4038,11 @@ static inline bool isar_feature_aa64_pauth_arch(const ARMISARegisters *id)return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,APA ) !=0 ; } +static inline bool isar_feature_aa64_tlbirange (const ARMISARegisters *id) +{ +return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,TLB ) ==2 ; +} +static inline bool isar_feature_aa64_sb (const ARMISARegisters *id) {return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,SB ) !=0 ;
target/arm/helper.c +294 -0
312 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH v5 3/4 target/arm: Add support for FEAT_TLBIOS
In reply to Rebecca CranARMv8.4 adds the mandatory FEAT_TLBIOS. It provides TLBI maintenance instructions that extend to the Outer Shareable domain.
--- target/arm/cpu.h | 5 ++ target/arm/helper.c | 75 ++++++++++++++++++++ 2 files changed, 80 insertions(+)
target/arm/cpu.h +5 -0
@@ -4043,6 +4043,11 @@ static inline bool isar_feature_aa64_tlbirange(const ARMISARegisters *id)return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,TLB ) ==2 ; } +static inline bool isar_feature_aa64_tlbios (const ARMISARegisters *id) +{ +return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,TLB ) !=0 ; +} +static inline bool isar_feature_aa64_sb (const ARMISARegisters *id) {return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,SB ) !=0 ;
target/arm/helper.c +75 -0
87 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH v5 4/4 target/arm: set ID_AA64ISAR0.TLB to 2 for max AARCH64 CPU type
In reply to Rebecca CranIndicate support for FEAT_TLBIOS and FEAT_TLBIRANGE by setting ID_AA64ISAR0.TLB to 2 for the max AARCH64 CPU type.
--- target/arm/cpu64.c | 1 + 1 file changed, 1 insertion(+)
target/arm/cpu64.c +1 -0
@@ -651,6 +651,7 @@ static void aarch64_max_initfn(Object *obj) t =FIELD_DP64 (t,ID_AA64ISAR0 ,DP ,1 ); t =FIELD_DP64 (t,ID_AA64ISAR0 ,FHM ,1 ); t =FIELD_DP64 (t,ID_AA64ISAR0 ,TS ,2 );/* v8.5-CondM */ + t =FIELD_DP64 (t,ID_AA64ISAR0 ,TLB ,2 );/* FEAT_TLBIRANGE */ t =FIELD_DP64 (t,ID_AA64ISAR0 ,RNDR ,1 ); cpu->isar.id_aa64isar0 = t;
Signature · 1 line
2.26.2
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [PATCH v5 0/4] target/arm: Add support for FEAT_TLBIOS and FEAT_TLBIRANGE
=== 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/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
39b3c36 target/arm: set ID_AA64ISAR0.TLB to 2 for max AARCH64 CPU type e3bc253 target/arm: Add support for FEAT_TLBIOS
94e5cc1 target/arm: Add support for FEAT_TLBIRANGE
85f8baf accel/tcg: Add TLB invalidation support for ranges of addresses
=== OUTPUT BEGIN ===
1/4 Checking commit 85f8baff74da (accel/tcg: Add TLB invalidation support for ranges of addresses)
WARNING: line over 80 characters
#238: FILE: include/exec/exec-all.h:354:
+static inline void tlb_flush_page_range_bits_by_mmuidx_all_cpus_synced(CPUState *src_cpu,
WARNING: line over 80 characters
#239: FILE: include/exec/exec-all.h:355:
+ target_ulong addr,
ERROR: line over 90 characters
#240: FILE: include/exec/exec-all.h:356:
+ target_ulong length,
WARNING: line over 80 characters
#241: FILE: include/exec/exec-all.h:357:
+ uint16_t idxmap,
WARNING: line over 80 characters
#242: FILE: include/exec/exec-all.h:358:
+ unsigned bits)
total: 1 errors, 4 warnings, 217 lines checked
Patch 1/4 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
2/4 Checking commit 94e5cc1394b4 (target/arm: Add support for FEAT_TLBIRANGE)
3/4 Checking commit e3bc253926cd (target/arm: Add support for FEAT_TLBIOS)
4/4 Checking commit 39b3c36068b4 (target/arm: set ID_AA64ISAR0.TLB to 2 for max AARCH64 CPU type) === OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]