Add Block-TLB support for hppa target
v2 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.
Patch series can be pulled from branch
https://github.com/hdeller/qemu-hppa.git hppa-btlb
v2:
- no code changes, just rephrased commit title and commit message of patches #3 and #4
Helge Deller (6):
target/hppa: Update to SeaBIOS-hppa version 9 target/hppa: Allow up to 16 BTLB entries target/hppa: Report and clear BTLBs via fw_cfg at startup 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
PATCH v2 1/6 target/hppa: Update to SeaBIOS-hppa version 9
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
roms/seabios-hppa +1 -1
@@ -1 +1 @@ -Subproject commit 673d2595d4f773cc266cbf8dbaf2f475a6adb949 +Subproject commit 763e3b73499db5fef94087bd310bfc8ccbcf7858
Signature · 1 line
2.41.0
PATCH v2 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
@@ -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
PATCH v2 3/6 target/hppa: Report and clear BTLBs via fw_cfg at startup
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
@@ -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
PATCH v2 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 are added later shall not overwrite any of the 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
@@ -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
@@ -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
@@ -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
PATCH v2 5/6 target/hppa: Extract diagnose immediate value
In reply to [email protected]From: Helge Deller <[email protected]>
Extract the immediate value given by the diagnose CPU instruction. This is 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
@@ -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
PATCH v2 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
@@ -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
@@ -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