mirror of
https://github.com/qemu/qemu.git
synced 2026-07-09 01:56:21 +00:00
target/arm: Implement translate_for_debug
Implement the translate_for_debug method instead of the get_phys_addr_attrs_debug one. This allows us to pass the caller the lg_page_size from our internal GetPhysAddrResult struct. Awkwardly, translate_for_debug's "true on success" convention is the opposite of the one we use internally in ptw.c, so we have to be careful about the sense of the return values. This corresponds to the way that arm_cpu_tlb_fill_align() also has to return true when get_phys_addr() returns false. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-id: 20260417173105.1648172-17-peter.maydell@linaro.org Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-ID: <20260430093810.2762539-18-peter.maydell@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
committed by
Philippe Mathieu-Daudé
parent
00f3bd9345
commit
abefca8e7f
@@ -2498,7 +2498,7 @@ static vaddr aarch64_untagged_addr(CPUState *cs, vaddr x)
|
||||
|
||||
static const struct SysemuCPUOps arm_sysemu_ops = {
|
||||
.has_work = arm_cpu_has_work,
|
||||
.get_phys_addr_attrs_debug = arm_cpu_get_phys_addr_attrs_debug,
|
||||
.translate_for_debug = arm_cpu_translate_for_debug,
|
||||
.asidx_from_attrs = arm_asidx_from_attrs,
|
||||
.write_elf32_note = arm_cpu_write_elf32_note,
|
||||
.write_elf64_note = arm_cpu_write_elf64_note,
|
||||
|
||||
@@ -1260,9 +1260,6 @@ extern const VMStateDescription vmstate_arm_cpu;
|
||||
void arm_cpu_do_interrupt(CPUState *cpu);
|
||||
void arm_v7m_cpu_do_interrupt(CPUState *cpu);
|
||||
|
||||
hwaddr arm_cpu_get_phys_addr_attrs_debug(CPUState *cpu, vaddr addr,
|
||||
MemTxAttrs *attrs);
|
||||
|
||||
typedef struct ARMGranuleProtectionConfig {
|
||||
/* GPCCR_EL3 */
|
||||
uint64_t gpccr;
|
||||
|
||||
@@ -1540,6 +1540,10 @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
|
||||
|
||||
void arm_log_exception(CPUState *cs);
|
||||
|
||||
/* Implementation of SysemuCPUOps::translate_for_debug */
|
||||
bool arm_cpu_translate_for_debug(CPUState *cs, vaddr addr,
|
||||
TranslateForDebugResult *result);
|
||||
|
||||
#endif /* !CONFIG_USER_ONLY */
|
||||
|
||||
/*
|
||||
|
||||
@@ -3942,8 +3942,9 @@ bool get_phys_addr(CPUARMState *env, vaddr address,
|
||||
memop, result, fi);
|
||||
}
|
||||
|
||||
static hwaddr arm_cpu_get_phys_addr(CPUARMState *env, vaddr addr,
|
||||
MemTxAttrs *attrs, ARMMMUIdx mmu_idx)
|
||||
static bool arm_cpu_get_phys_addr(CPUARMState *env, vaddr addr,
|
||||
TranslateForDebugResult *result,
|
||||
ARMMMUIdx mmu_idx)
|
||||
{
|
||||
S1Translate ptw = {
|
||||
.in_mmu_idx = mmu_idx,
|
||||
@@ -3954,26 +3955,31 @@ static hwaddr arm_cpu_get_phys_addr(CPUARMState *env, vaddr addr,
|
||||
};
|
||||
GetPhysAddrResult res = {};
|
||||
ARMMMUFaultInfo fi = {};
|
||||
bool ret = get_phys_addr_gpc(env, &ptw, addr, MMU_DATA_LOAD, 0, &res, &fi);
|
||||
*attrs = res.f.attrs;
|
||||
bool fault = get_phys_addr_gpc(env, &ptw, addr, MMU_DATA_LOAD, 0, &res, &fi);
|
||||
|
||||
if (ret) {
|
||||
return -1;
|
||||
if (!fault) {
|
||||
/* translation succeeded */
|
||||
result->physaddr = res.f.phys_addr;
|
||||
result->attrs = res.f.attrs;
|
||||
result->lg_page_size = res.f.lg_page_size;
|
||||
}
|
||||
return res.f.phys_addr;
|
||||
return fault;
|
||||
}
|
||||
|
||||
hwaddr arm_cpu_get_phys_addr_attrs_debug(CPUState *cs, vaddr addr,
|
||||
MemTxAttrs *attrs)
|
||||
bool arm_cpu_translate_for_debug(CPUState *cs, vaddr addr,
|
||||
TranslateForDebugResult *result)
|
||||
{
|
||||
ARMCPU *cpu = ARM_CPU(cs);
|
||||
CPUARMState *env = &cpu->env;
|
||||
ARMMMUIdx mmu_idx = arm_mmu_idx(env);
|
||||
|
||||
hwaddr res = arm_cpu_get_phys_addr(env, addr, attrs, mmu_idx);
|
||||
|
||||
if (res != -1) {
|
||||
return res;
|
||||
/*
|
||||
* Note that this function returns true on translation success,
|
||||
* but arm_cpu_get_phys_addr() and all the other get_phys_addr
|
||||
* style functions in this file return true on failure.
|
||||
*/
|
||||
if (!arm_cpu_get_phys_addr(env, addr, result, mmu_idx)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3984,11 +3990,12 @@ hwaddr arm_cpu_get_phys_addr_attrs_debug(CPUState *cs, vaddr addr,
|
||||
switch (mmu_idx) {
|
||||
case ARMMMUIdx_E10_1:
|
||||
case ARMMMUIdx_E10_1_PAN:
|
||||
return arm_cpu_get_phys_addr(env, addr, attrs, ARMMMUIdx_E10_0);
|
||||
return !arm_cpu_get_phys_addr(env, addr, result, ARMMMUIdx_E10_0);
|
||||
case ARMMMUIdx_E20_2:
|
||||
case ARMMMUIdx_E20_2_PAN:
|
||||
return arm_cpu_get_phys_addr(env, addr, attrs, ARMMMUIdx_E20_0);
|
||||
return !arm_cpu_get_phys_addr(env, addr, result, ARMMMUIdx_E20_0);
|
||||
default:
|
||||
return -1;
|
||||
/* translation failed */
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user