qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 15/33] target/nios2: Use hw/registerfields.h for CR_TLBMIS


From: Richard Henderson
Subject: Re: [PATCH v4 15/33] target/nios2: Use hw/registerfields.h for CR_TLBMISC fields
Date: Tue, 8 Mar 2022 09:37:35 -1000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0

On 3/8/22 00:46, Peter Maydell wrote:
@@ -130,24 +128,25 @@ void helper_mmu_write_tlbacc(CPUNios2State *env, uint32_t 
v)
  void helper_mmu_write_tlbmisc(CPUNios2State *env, uint32_t v)
  {
      Nios2CPU *cpu = env_archcpu(env);
+    uint32_t new_pid = FIELD_EX32(v, CR_TLBMISC, PID);
+    uint32_t old_pid = FIELD_EX32(env->mmu.tlbmisc_wr, CR_TLBMISC, PID);
+    uint32_t way = FIELD_EX32(v, CR_TLBMISC, WAY);

-    trace_nios2_mmu_write_tlbmisc(v >> CR_TLBMISC_WAY_SHIFT,
+    trace_nios2_mmu_write_tlbmisc(way,
                                    (v & CR_TLBMISC_RD) ? 'R' : '.',
                                    (v & CR_TLBMISC_WR) ? 'W' : '.',
                                    (v & CR_TLBMISC_DBL) ? '2' : '.',
                                    (v & CR_TLBMISC_BAD) ? 'B' : '.',
                                    (v & CR_TLBMISC_PERM) ? 'P' : '.',
                                    (v & CR_TLBMISC_D) ? 'D' : '.',
-                                  (v & CR_TLBMISC_PID_MASK) >> 4);
+                                  new_pid);

-    if ((v & CR_TLBMISC_PID_MASK) !=
-        (env->mmu.tlbmisc_wr & CR_TLBMISC_PID_MASK)) {
-        mmu_flush_pid(env, (env->mmu.tlbmisc_wr & CR_TLBMISC_PID_MASK) >>
-                           CR_TLBMISC_PID_SHIFT);
+    if (new_pid != old_pid) {
+        mmu_flush_pid(env, old_pid);
      }
+
      /* if tlbmisc.RD == 1 then trigger a TLB read on writes to TLBMISC */
      if (v & CR_TLBMISC_RD) {
-        int way = (v >> CR_TLBMISC_WAY_SHIFT);
          int vpn = FIELD_EX32(env->mmu.pteaddr_wr, CR_PTEADDR, VPN);
          Nios2TLBEntry *entry =
              &env->mmu.tlb[(way * cpu->tlb_num_ways) +


Any reason for hoisting the declaration of 'way' up to the top of the
function ?

For use in the tracepoint, rather than extracting it twice.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]