Skip to contentSkip to conversation

Add Block-TLB support for hppa target

PATCH Superseded [email protected] 1 participant 7 messages Sep 13, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#2 lore raw

PATCH 2/6 target/hppa: Allow up to 16 BTLB entries

In reply to [email protected]

From: Helge Deller <[email protected]>

Reserve 16 out of the 256 TLB entries for Block-TLBs.

---
 target/hppa/cpu.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
target/hppa/cpu.h +7 -1
index fa13694dab..23852d89b2 100644
@@ -211,8 +211,14 @@ typedef struct CPUArchState {
     target_ureg shadow[7];   /* shadow registers */
 
     /* ??? The number of entries isn't specified by the architecture.  */
+#ifdef TARGET_HPPA64
+#define HPPA_BTLB_FIXED         0       /* BTLBs are not supported in 64-bit machines */
+#else
+#define HPPA_BTLB_FIXED         16
+#endif
+#define HPPA_BTLB_VARIABLE      0
 #define HPPA_TLB_ENTRIES        256
-#define HPPA_BTLB_ENTRIES       0
+#define HPPA_BTLB_ENTRIES       (HPPA_BTLB_FIXED + HPPA_BTLB_VARIABLE)
 
     /* ??? Implement a unified itlb/dtlb for the moment.  */
     /* ??? We should use a more intelligent data structure.  */
Signature · 1 line
2.41.0
#3 lore raw

PATCH 3/6 target/hppa: Provide qemu version via fw_cfg to firmware

In reply to [email protected]

From: Helge Deller <[email protected]>

Report the new number of TLB entries (without BTLBs) to the guest and drop reporting of BTLB entries which weren't used at all.

Clear all BTLB and TLB entries at machine reset.

---
 hw/hppa/machine.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
hw/hppa/machine.c +5 -5
index 866e11d208..cf28cb9586 100644
@@ -133,14 +133,10 @@ static FWCfgState *create_fw_cfg(MachineState *ms)
     fw_cfg_add_file(fw_cfg, "/etc/firmware-min-version",
                     g_memdup(&val, sizeof(val)), sizeof(val));
 
-    val = cpu_to_le64(HPPA_TLB_ENTRIES);
+    val = cpu_to_le64(HPPA_TLB_ENTRIES - HPPA_BTLB_ENTRIES);
     fw_cfg_add_file(fw_cfg, "/etc/cpu/tlb_entries",
                     g_memdup(&val, sizeof(val)), sizeof(val));
 
-    val = cpu_to_le64(HPPA_BTLB_ENTRIES);
-    fw_cfg_add_file(fw_cfg, "/etc/cpu/btlb_entries",
-                    g_memdup(&val, sizeof(val)), sizeof(val));
-
     val = cpu_to_le64(HPA_POWER_BUTTON);
     fw_cfg_add_file(fw_cfg, "/etc/power-button-addr",
                     g_memdup(&val, sizeof(val)), sizeof(val));
@@ -433,6 +429,10 @@ static void hppa_machine_reset(MachineState *ms, ShutdownCause reason)
 
         cs->exception_index = -1;
         cs->halted = 0;
+
+        /* clear any existing TLB and BTLB entries */
+        memset(cpu[i]->env.tlb, 0, sizeof(cpu[i]->env.tlb));
+        cpu[i]->env.tlb_last = HPPA_BTLB_ENTRIES;
     }
 
     /* already initialized by machine_hppa_init()? */
Signature · 1 line
2.41.0
#4 lore raw

PATCH 4/6 target/hppa: Add BTLB support to hppa TLB functions

In reply to [email protected]

From: Helge Deller <[email protected]>

Change the TLB code to store the Block-TLBs at the beginning of the TLB table. New 4k-TLB entries which which are added later shall not overwrite those BTLB entries.

Make sure that when the TLB is cleared by the OS via the ptlbe instruction, the Block-TLBs will not be dropped.

---
 target/hppa/cpu.h        |  3 +-
 target/hppa/int_helper.c |  2 +-
 target/hppa/mem_helper.c | 87 +++++++++++++++++++++++++++-------------
 target/hppa/op_helper.c  |  3 +-
 4 files changed, 65 insertions(+), 30 deletions(-)
target/hppa/cpu.h +2 -1
index 23852d89b2..730f35231a 100644
@@ -350,7 +350,8 @@ bool hppa_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
 void hppa_cpu_do_interrupt(CPUState *cpu);
 bool hppa_cpu_exec_interrupt(CPUState *cpu, int int_req);
 int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx,
-                              int type, hwaddr *pphys, int *pprot);
+                              int type, hwaddr *pphys, int *pprot,
+                              hppa_tlb_entry **tlb_entry);
 extern const MemoryRegionOps hppa_io_eir_ops;
 extern const VMStateDescription vmstate_hppa_cpu;
 void hppa_cpu_alarm_timer(void *);
target/hppa/int_helper.c +1 -1
index bebc732c97..3ab9934a1d 100644
@@ -154,7 +154,7 @@ void hppa_cpu_do_interrupt(CPUState *cs)
 
                     vaddr = hppa_form_gva_psw(old_psw, iasq_f, vaddr);
                     t = hppa_get_physical_address(env, vaddr, MMU_KERNEL_IDX,
-                                                  0, &paddr, &prot);
+                                                  0, &paddr, &prot, NULL);
                     if (t >= 0) {
                         /* We can't re-load the instruction.  */
                         env->cr[CR_IIR] = 0;
target/hppa/mem_helper.c +60 -27

188 lines not on this page · raw message

target/hppa/op_helper.c +2 -1
index f25a5a72aa..837e2b3117 100644
@@ -179,7 +179,8 @@ target_ureg HELPER(probe)(CPUHPPAState *env, target_ulong addr,
         return 0;
     }
 
-    excp = hppa_get_physical_address(env, addr, level, 0, &phys, &prot);
+    excp = hppa_get_physical_address(env, addr, level, 0, &phys,
+                                     &prot, NULL);
     if (excp >= 0) {
         if (env->psw & PSW_Q) {
             /* ??? Needs tweaking for hppa64.  */
Signature · 1 line
2.41.0
#6 lore raw

PATCH 6/6 target/hppa: Wire up diag instruction to support BTLB

In reply to [email protected]

From: Helge Deller <[email protected]>

Wire up the hppa diag instruction to support Block-TLBs when called with the 0x100 value.

The diag_btlb() helper function does all necessary steps to emulate the PDC BTLB firmware function, which includes providing BTLB info, adding a new BTLB, deleting a BTLB and removing all BTLBs.

---
 target/hppa/helper.h     |  1 +
 target/hppa/mem_helper.c | 92 ++++++++++++++++++++++++++++++++++++++++
 target/hppa/translate.c  | 15 +++++--
 3 files changed, 105 insertions(+), 3 deletions(-)
target/hppa/helper.h +1 -0
index c7e35ce8c7..647f043c85 100644
@@ -95,4 +95,5 @@ DEF_HELPER_FLAGS_2(ptlb, TCG_CALL_NO_RWG, void, env, tl)
 DEF_HELPER_FLAGS_1(ptlbe, TCG_CALL_NO_RWG, void, env)
 DEF_HELPER_FLAGS_2(lpa, TCG_CALL_NO_WG, tr, env, tl)
 DEF_HELPER_FLAGS_1(change_prot_id, TCG_CALL_NO_RWG, void, env)
+DEF_HELPER_1(diag_btlb, void, env)
 #endif
target/hppa/mem_helper.c +92 -0

95 lines not on this page · raw message

target/hppa/translate.c +12 -3
index c04dc15228..650bbcfe95 100644
@@ -4042,9 +4042,18 @@ static bool trans_fmpyfadd_d(DisasContext *ctx, arg_fmpyfadd_d *a)
 
 static bool trans_diag(DisasContext *ctx, arg_diag *a)
 {
-    qemu_log_mask(LOG_UNIMP, "DIAG opcode ignored\n");
-    cond_free(&ctx->null_cond);
-    return true;
+    nullify_over(ctx);
+    CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
+#ifndef CONFIG_USER_ONLY
+    if (a->i == 0x100) {
+        /* emulate PDC BTLB, called by SeaBIOS-hppa */
+        gen_helper_diag_btlb(cpu_env);
+    } else
+#endif
+    {
+        qemu_log_mask(LOG_UNIMP, "DIAG opcode 0x%04x ignored\n", a->i);
+    }
+    return nullify_end(ctx);
 }
 
 static void hppa_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
Signature · 1 line
2.41.0
#1 lore raw

PATCH 1/6 target/hppa: Update to SeaBIOS-hppa version 9

In reply to [email protected]

From: Helge Deller <[email protected]>

Enhancements:
- Support for Block-TLB (BTLB) on 32-bit CPUs

---
 pc-bios/hppa-firmware.img | Bin 720216 -> 732376 bytes
 roms/seabios-hppa         |   2 +-
 2 files changed, 1 insertion(+), 1 deletion(-)
pc-bios/hppa-firmware.img binary +0 -0
index 0fa3808f163ea60766272188a634d9296f2b5be4..c7196143b180af6e02d1d93591f2684e82f3fb0d 100644
GIT binary patch
roms/seabios-hppa +1 -1
index 673d2595d4..763e3b7349 160000
@@ -1 +1 @@
-Subproject commit 673d2595d4f773cc266cbf8dbaf2f475a6adb949
+Subproject commit 763e3b73499db5fef94087bd310bfc8ccbcf7858
Signature · 1 line
2.41.0
#0 lore raw

cover Add Block-TLB support for hppa target

From: Helge Deller <[email protected]>

All 32-bit hppa CPUs allow a fixed number of TLB entries to have a different page size than the default 4k.
Those are called "Block-TLBs" and are created at startup by the operating system and managed by the firmware of hppa machines through the firmware PDC_BLOCK_TLB call.

This patchset adds the necessary glue to SeaBIOS-hppa and qemu to allow up to 16 BTLB entries in the emulation.

Helge Deller (6):
target/hppa: Update to SeaBIOS-hppa version 9 target/hppa: Allow up to 16 BTLB entries target/hppa: Provide qemu version via fw_cfg to firmware target/hppa: Add BTLB support to hppa TLB functions target/hppa: Extract diagnose immediate value target/hppa: Wire up diag instruction to support BTLB

 hw/hppa/machine.c         |  10 +--
 pc-bios/hppa-firmware.img | Bin 720216 -> 732376 bytes
 roms/seabios-hppa         |   2 +-
 target/hppa/cpu.h         |  11 ++-
 target/hppa/helper.h      |   1 +
 target/hppa/insns.decode  |   2 +-
 target/hppa/int_helper.c  |   2 +-
 target/hppa/mem_helper.c  | 179 ++++++++++++++++++++++++++++++++------
 target/hppa/op_helper.c   |   3 +-
 target/hppa/translate.c   |  15 +++-
 10 files changed, 184 insertions(+), 41 deletions(-)
Signature · 1 line
2.41.0
#5 lore raw

PATCH 5/6 target/hppa: Extract diagnose immediate value

From: Helge Deller <[email protected]>

Extract the immediate value given by the diagnose CPU instruction. This will be needed to distinguish the various diagnose calls.

---
 target/hppa/insns.decode | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/hppa/insns.decode +1 -1
index 27341d27b2..aebe03ccfd 100644
@@ -528,4 +528,4 @@ fdiv_d          001110 ..... ..... 011 ..... ... .....  @f0e_d_3
 xmpyu           001110 ..... ..... 010 .0111 .00 t:5    r1=%ra64 r2=%rb64
 
 # diag
-diag            000101 ----- ----- ---- ---- ---- ----
+diag            000101 i:26
Signature · 1 line
2.41.0