Skip to contentSkip to conversation

arm/monitor: Add support for 'info tlb' command

PATCH Superseded Changbin Du 4 participants 5 messages Nov 13, 2020 – Nov 14, 2020

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm/monitor: Add support for 'info tlb' command

This adds hmp 'info tlb' command support for the arm platform. The limitation is that this only implements a page walker for ARMv8-A AArch64 Long Descriptor format, 32bit addressing is not supported yet.

---
 hmp-commands-info.hx   |   3 +-
 target/arm/helper.c    |  17 +---
 target/arm/internals.h |  16 ++++
 target/arm/monitor.c   | 187 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 206 insertions(+), 17 deletions(-)
hmp-commands-info.hx +2 -1
index 117ba25f91..1b5b3f2616 100644
@@ -222,7 +222,8 @@ SRST
 ERST
 
 #if defined(TARGET_I386) || defined(TARGET_SH4) || defined(TARGET_SPARC) || \
-    defined(TARGET_PPC) || defined(TARGET_XTENSA) || defined(TARGET_M68K)
+    defined(TARGET_PPC) || defined(TARGET_XTENSA) || defined(TARGET_M68K) || \
+    defined(TARGET_ARM)
     {
         .name       = "tlb",
         .args_type  = "",
target/arm/helper.c +1 -16
index 11b0803df7..c73a08943b 100644
@@ -9974,8 +9974,7 @@ static inline uint64_t regime_sctlr(CPUARMState *env, ARMMMUIdx mmu_idx)
 #ifndef CONFIG_USER_ONLY
 
 /* Return true if the specified stage of address translation is disabled */
-static inline bool regime_translation_disabled(CPUARMState *env,
-                                               ARMMMUIdx mmu_idx)
+bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx)
 {
     if (arm_feature(env, ARM_FEATURE_M)) {
         switch (env->v7m.mpu_ctrl[regime_is_secure(env, mmu_idx)] &
@@ -10021,20 +10020,6 @@ static inline bool regime_translation_big_endian(CPUARMState *env,
     return (regime_sctlr(env, mmu_idx) & SCTLR_EE) != 0;
 }
 
-/* Return the TTBR associated with this translation regime */
-static inline uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx,
-                                   int ttbrn)
-{
-    if (mmu_idx == ARMMMUIdx_Stage2) {
-        return env->cp15.vttbr_el2;
-    }
-    if (ttbrn == 0) {
-        return env->cp15.ttbr0_el[regime_el(env, mmu_idx)];
-    } else {
-        return env->cp15.ttbr1_el[regime_el(env, mmu_idx)];
-    }
-}
-
 #endif /* !CONFIG_USER_ONLY */
 
 /* Convert a possible stage1+2 MMU index into the appropriate
target/arm/internals.h +16 -0
index 5460678756..12f883c636 100644
@@ -949,6 +949,8 @@ static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx)
     }
 }
 
+bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx);
+
 /* Return the TCR controlling this translation regime */
 static inline TCR *regime_tcr(CPUARMState *env, ARMMMUIdx mmu_idx)
 {
@@ -958,6 +960,20 @@ static inline TCR *regime_tcr(CPUARMState *env, ARMMMUIdx mmu_idx)
     return &env->cp15.tcr_el[regime_el(env, mmu_idx)];
 }
 
+/* Return the TTBR associated with this translation regime */
+static inline uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx,
+                                   int ttbrn)
+{
+    if (mmu_idx == ARMMMUIdx_Stage2) {
+        return env->cp15.vttbr_el2;
+    }
+    if (ttbrn == 0) {
+        return env->cp15.ttbr0_el[regime_el(env, mmu_idx)];
+    } else {
+        return env->cp15.ttbr1_el[regime_el(env, mmu_idx)];
+    }
+}
+
 /* Return the FSR value for a debug exception (watchpoint, hardware
  * breakpoint or BKPT insn) targeting the specified exception level.
  */
target/arm/monitor.c +187 -0

196 lines not on this page · raw message

Signature · 1 line
2.25.1
#1 lore raw
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:

Message-id: [email protected]
Type: series
Subject: [PATCH] arm/monitor: Add support for 'info tlb' command

=== 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'
a33e6e7 arm/monitor: Add support for 'info tlb' command

=== OUTPUT BEGIN ===
WARNING: line over 80 characters
#141: FILE: target/arm/monitor.c:267:
+print_pte_lpae(Monitor *mon, uint32_t tableattrs, int va_bits, target_ulong vaddr,

ERROR: spaces required around that '=' (ctx:VxW)
#174: FILE: target/arm/monitor.c:300:

+    int ptshift= pg_shift + (max_level - cur_level) * stride;
                ^

WARNING: line over 80 characters
#195: FILE: target/arm/monitor.c:321:
+ print_pte_lpae(mon, tableattrs, va_bits, vstart, paddr, pgsize, pte);

WARNING: line over 80 characters
#268: FILE: target/arm/monitor.c:394:
+ walk_pte_lpae(mon, true, 0, base, vstart, cur_level, stride, va_bits);

total: 1 errors, 3 warnings, 262 lines checked

Commit a33e6e7e0edd (arm/monitor: Add support for 'info tlb' command) has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== 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]

#2 lore raw
In reply to Changbin Du
Quoted 5 lines · Changbin Du

This adds hmp 'info tlb' command support for the arm platform. The limitation is that this only implements a page walker for ARMv8-A AArch64 Long Descriptor format, 32bit addressing is not supported yet.

"info tlb" needs its own entirely independent implementation of a page-table walk? I see this is how x86 has done it ,but it seems like a recipe for the info command being perpetually behind what we actually implement...

thanks
-- PMM

#3 lore raw
Quoted 11 lines · * Peter Maydell ([email protected]) wrote:
Quoted 5 lines · Changbin Du

This adds hmp 'info tlb' command support for the arm platform. The limitation is that this only implements a page walker for ARMv8-A AArch64 Long Descriptor format, 32bit addressing is not supported yet.

"info tlb" needs its own entirely independent implementation of a page-table walk? I see this is how x86 has done it ,but it seems like a recipe for the info command being perpetually behind what we actually implement...

I think the challenge is you want 'info tlb' to be quite easy to read from a debuggers point of view and robust at pointing out things that are odd; I'd hope at least you can use most of the macros to extract fields etc

Dave

Quoted 3 lines

thanks
-- PMM

Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
#4 lore raw
Quoted 13 lines · Dr. David Alan Gilbert
Quoted 11 lines · * Peter Maydell ([email protected]) wrote:
Quoted 5 lines · Changbin Du

This adds hmp 'info tlb' command support for the arm platform. The limitation is that this only implements a page walker for ARMv8-A AArch64 Long Descriptor format, 32bit addressing is not supported yet.

"info tlb" needs its own entirely independent implementation of a page-table walk? I see this is how x86 has done it ,but it seems like a recipe for the info command being perpetually behind what we actually implement...

Quoted 5 lines

I think the challenge is you want 'info tlb' to be quite easy to read from a debuggers point of view and robust at pointing out things that are odd; I'd hope at least you can use most of the macros to extract fields etc

Actually I refered to function get_phys_addr_lpae() and try to use definitions what I found. But most of the bit definitions are hardcode.

I have fixed the code style issues in V2. Thanks for your kind review!

Quoted 8 lines

Dave

Quoted 3 lines

thanks
-- PMM

Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Signature · 2 lines
Cheers,
Changbin Du