target/arm: Few accel cleanups
cover target/arm: Few accel cleanups
Based-on: <[email protected]>
"arm: Fixes and preparatory cleanups for split-accel"
Philippe Mathieu-Daudé (6):
target/arm: Only set CPU_INTERRUPT_EXITTB for TCG target/arm: Only allow disabling NEON when using TCG target/arm: Better describe PMU depends on TCG or HVF target/arm: Re-use arm_is_psci_call() in HVF target/arm: Share ARM_PSCI_CALL trace event between TCG and HVF target/arm: Allow arm_cpu_tlb_fill_align optionally set
CPUTLBEntryFull
target/arm/cpu.c | 4 ++-- target/arm/helper.c | 2 +- target/arm/hvf/hvf.c | 7 ++++--- target/arm/machine.c | 10 +++++----- target/arm/tcg/psci.c | 3 +++ target/arm/tcg/tlb_helper.c | 4 +++- target/arm/trace-events | 3 +++ 7 files changed, 21 insertions(+), 12 deletions(-)
Signature · 1 line
2.49.0
PATCH 1/6 target/arm: Only set CPU_INTERRUPT_EXITTB for TCG
Commit 34c45d53026 ("target-arm: kvm - re-inject guest debug exceptions") removed CPU_INTERRUPT_EXITTB from KVM, but it also appears on HVF. Better to restrict it to TCG.
--- target/arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/helper.c +1 -1
@@ -10929,7 +10929,7 @@ void arm_cpu_do_interrupt(CPUState *cs)arm_call_el_change_hook (cpu); -if (!kvm_enabled ()) { +if (tcg_enabled ()) { cs->interrupt_request |=CPU_INTERRUPT_EXITTB ; } }
Signature · 1 line
2.49.0
Re: [PATCH 1/6] target/arm: Only set CPU_INTERRUPT_EXITTB for TCG
Quoted 9 lines · Philippe Mathieu-Daudé
Commit
34c45d53026("target-arm: kvm - re-inject guest debug exceptions") removedCPU_INTERRUPT_EXITTBfrom KVM, but it also appears on HVF. Better to restrict it to TCG.Suggested-by Richard Henderson<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- target/arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
r~
Re: [PATCH 1/6] target/arm: Only set CPU_INTERRUPT_EXITTB for TCG
In reply to Philippe Mathieu-DaudéQuoted 9 lines · Philippe Mathieu-Daudé
Commit
34c45d53026("target-arm: kvm - re-inject guest debug exceptions") removedCPU_INTERRUPT_EXITTBfrom KVM, but it also appears on HVF. Better to restrict it to TCG.Suggested-by Richard Henderson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH 2/6 target/arm: Only allow disabling NEON when using TCG
In reply to Philippe Mathieu-DaudéOnly allow disabling NEON when using TCG.
This avoids confusing user experience:
$ qemu-system-aarch64 -M virt -accel hvf \
-cpu host,neon=off,vfp=off,vfp-d32=off
qemu-system-aarch64: AArch64 CPUs must have both VFP and Neon or neither $ qemu-system-aarch64 -M virt -accel hvf \
-cpu host,neon=off,vfp=off,vfp-d32=off
qemu-system-aarch64: ARM CPUs must have both VFP-D32 and Neon or neither $ qemu-system-aarch64 -M virt -accel hvf \
-cpu host,neon=off,vfp=off,vfp-d32=off
qemu-system-aarch64: can't apply global host-arm-cpu.vfp-d32=off: Property 'host-arm-cpu.vfp-d32' not found--- target/arm/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/cpu.c +1 -1
@@ -1810,7 +1810,7 @@ static void arm_cpu_post_init(Object *obj)if (arm_feature (&cpu->env,ARM_FEATURE_NEON )) { cpu->has_neon = true; -if (!kvm_enabled ()) { +if (tcg_enabled () ||qtest_enabled ()) {qdev_property_add_static (DEVICE (obj), &arm_cpu_has_neon_property); } }
Signature · 1 line
2.49.0
Re: [PATCH 2/6] target/arm: Only allow disabling NEON when using TCG
Quoted 26 lines · Philippe Mathieu-Daudé
Only allow disabling NEON when using TCG.
This avoids confusing user experience:
$ qemu-system-aarch64 -M virt -accel hvf \ -cpu host,neon=off,vfp=off,vfp-d32=off qemu-system-aarch64: AArch64 CPUs must have both VFP and Neon or neither$ qemu-system-aarch64 -M virt -accel hvf \ -cpu host,neon=off,vfp=off,vfp-d32=off qemu-system-aarch64: ARM CPUs must have both VFP-D32 and Neon or neither$ qemu-system-aarch64 -M virt -accel hvf \ -cpu host,neon=off,vfp=off,vfp-d32=off qemu-system-aarch64: can't apply global host-arm-cpu.vfp-d32=off: Property 'host-arm-cpu.vfp-d32' not foundSigned-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/arm/cpu.c +0
-0
target/arm/cpu.c static void arm_cpu_post_init(Object *obj) · line 1816
Quoted 8 lines
target/arm/cpu.c +1
-1@@ -1810,7 +1810,7 @@ static void arm_cpu_post_init(Object *obj)if (arm_feature (&cpu->env,ARM_FEATURE_NEON )) { cpu->has_neon = true; -if (!kvm_enabled ()) { +if (tcg_enabled () ||qtest_enabled ()) {qdev_property_add_static (DEVICE (obj), &arm_cpu_has_neon_property); } }
r~
Re: [PATCH 2/6] target/arm: Only allow disabling NEON when using TCG
In reply to Philippe Mathieu-DaudéQuoted 12 lines · Philippe Mathieu-Daudé
Only allow disabling NEON when using TCG.
This avoids confusing user experience:
$ qemu-system-aarch64 -M virt -accel hvf \ -cpu host,neon=off,vfp=off,vfp-d32=off qemu-system-aarch64: AArch64 CPUs must have both VFP and Neon or neither$ qemu-system-aarch64 -M virt -accel hvf \ -cpu host,neon=off,vfp=off,vfp-d32=off qemu-system-aarch64: ARM CPUs must have both VFP-D32 and Neon or neither
Quoted 8 lines
$ qemu-system-aarch64 -M virt -accel hvf \ -cpu host,neon=off,vfp=off,vfp-d32=off qemu-system-aarch64: can't apply global host-arm-cpu.vfp-d32=off: Property 'host-arm-cpu.vfp-d32' not foundSigned-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Re: [PATCH 2/6] target/arm: Only allow disabling NEON when using TCG
In reply to Philippe Mathieu-DaudéQuoted 9 lines · Philippe Mathieu-Daudé
Only allow disabling NEON when using TCG.
This avoids confusing user experience:
$ qemu-system-aarch64 -M virt -accel hvf \ -cpu host,neon=off,vfp=off,vfp-d32=off qemu-system-aarch64: AArch64 CPUs must have both VFP and Neon or neither
Quoted 7 lines
$ qemu-system-aarch64 -M virt -accel hvf \ -cpu host,neon=off,vfp=off,vfp-d32=off qemu-system-aarch64: ARM CPUs must have both VFP-D32 and Neon or neither$ qemu-system-aarch64 -M virt -accel hvf \ -cpu host,neon=off,vfp=off,vfp-d32=off qemu-system-aarch64: can't apply global host-arm-cpu.vfp-d32=off: Property 'host-arm-cpu.vfp-d32' not found
I don't know about users, but I'm definitely confused. Aren't these three all the same command line ? What's the problem it's trying to show ?
-- PMM
Re: [PATCH 2/6] target/arm: Only allow disabling NEON when using TCG
Quoted 14 lines · Peter Maydell
Quoted 13 lines · Philippe Mathieu-Daudé
Only allow disabling NEON when using TCG.
This avoids confusing user experience:
$ qemu-system-aarch64 -M virt -accel hvf \ -cpu host,neon=off,vfp=off,vfp-d32=off qemu-system-aarch64: AArch64 CPUs must have both VFP and Neon or neither$ qemu-system-aarch64 -M virt -accel hvf \ -cpu host,neon=off,vfp=off,vfp-d32=off qemu-system-aarch64: ARM CPUs must have both VFP-D32 and Neon or neither
Quoted 7 lines
Quoted 3 lines
$ qemu-system-aarch64 -M virt -accel hvf \ -cpu host,neon=off,vfp=off,vfp-d32=off qemu-system-aarch64: can't apply global host-arm-cpu.vfp-d32=off: Property 'host-arm-cpu.vfp-d32' not foundI don't know about users, but I'm definitely confused. Aren't these three all the same command line ? What's the problem it's trying to show ?
I should have only shared this confusing example:
$ qemu-system-aarch64 -M virt -accel hvf -cpu host,vfp-d32=off qemu-system-aarch64: can't apply global host-arm-cpu.vfp-d32=off: Property 'host-arm-cpu.vfp-d32' not found
Re: [PATCH 2/6] target/arm: Only allow disabling NEON when using TCG
Quoted 24 lines · Philippe Mathieu-Daudé
Quoted 14 lines · Peter Maydell
Quoted 13 lines · Philippe Mathieu-Daudé
Only allow disabling NEON when using TCG.
This avoids confusing user experience:
$ qemu-system-aarch64 -M virt -accel hvf \ -cpu host,neon=off,vfp=off,vfp-d32=off qemu-system-aarch64: AArch64 CPUs must have both VFP and Neon or neither$ qemu-system-aarch64 -M virt -accel hvf \ -cpu host,neon=off,vfp=off,vfp-d32=off qemu-system-aarch64: ARM CPUs must have both VFP-D32 and Neon or neitherQuoted 7 lines
Quoted 3 lines
$ qemu-system-aarch64 -M virt -accel hvf \ -cpu host,neon=off,vfp=off,vfp-d32=off qemu-system-aarch64: can't apply global host-arm-cpu.vfp-d32=off: Property 'host-arm-cpu.vfp-d32' not foundI don't know about users, but I'm definitely confused. Aren't these three all the same command line ? What's the problem it's trying to show ?
Quoted 5 lines
I should have only shared this confusing example:
$ qemu-system-aarch64 -M virt -accel hvf -cpu host,vfp-d32=off qemu-system-aarch64: can't apply global host-arm-cpu.vfp-d32=off: Property 'host-arm-cpu.vfp-d32' not found
That seems correct, though ? We say
* Allow user to turn off VFP and Neon support, but only for TCG --
* KVM does not currently allow us to lie to the guest about its
* ID/feature registers, so the guest always sees what the host has.
and hvf is currently the same. The bug the patch is fixing looks like it is that -accel hvf lets us say '-cpu host,neon=off' but it won't actually do what the user might be intending. So we should avoid creating the property, as we already do for KVM.
(The other odd thing here is that hvf CPUs don't support AArch32, but ARM_FEATURE_NEON is about AArch32. But that's a separate thing and we'd need to cross-check that nothing aarch64 is incorrectly looking at that feature flag before we suppressed it for CPUs without any AArch32 support.)
-- PMM
PATCH 3/6 target/arm: Better describe PMU depends on TCG or HVF
In reply to Philippe Mathieu-DaudéSimplify PMU logic by rewriting '!KVM' as 'TCG || HVF' (ignoring QTest, because vCPUs are not available there).
--- target/arm/cpu.c | 2 +- target/arm/machine.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
target/arm/cpu.c +1 -1
@@ -2352,7 +2352,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)if (arm_feature (env,ARM_FEATURE_PMU )) {pmu_init (cpu); -if (!kvm_enabled ()) { +if (tcg_enabled () ||hvf_enabled ()) {arm_register_pre_el_change_hook (cpu, &pmu_pre_el_change,0 );arm_register_el_change_hook (cpu, &pmu_post_el_change,0 ); }
target/arm/machine.c +5 -5
@@ -1,7 +1,7 @@#include "qemu/osdep.h" #include "cpu.h" #include "qemu/error-report.h" -#include "system/kvm.h" +#include "system/hvf.h" #include "system/tcg.h" #include "kvm_arm.h" #include "internals.h"
@@ -853,7 +853,7 @@ static int cpu_pre_save(void *opaque) {ARMCPU *cpu = opaque; -if (!kvm_enabled ()) { +if (tcg_enabled () ||hvf_enabled ()) {pmu_op_start (&cpu->env); }
@@ -888,7 +888,7 @@ static int cpu_post_save(void *opaque) {ARMCPU *cpu = opaque; -if (!kvm_enabled ()) { +if (tcg_enabled () ||hvf_enabled ()) {pmu_op_finish (&cpu->env); }
@@ -921,7 +921,7 @@ static int cpu_pre_load(void *opaque)*/ env->irq_line_state =UINT32_MAX ; -if (!kvm_enabled ()) { +if (tcg_enabled () ||hvf_enabled ()) {pmu_op_start (env); }
@@ -1013,7 +1013,7 @@ static int cpu_post_load(void *opaque, int version_id) } } -if (!kvm_enabled ()) { +if (tcg_enabled () ||hvf_enabled ()) {pmu_op_finish (env); }
Signature · 1 line
2.49.0
Re: [PATCH 3/6] target/arm: Better describe PMU depends on TCG or HVF
Quoted 63 lines · Philippe Mathieu-Daudé
Simplify PMU logic by rewriting '!KVM' as 'TCG || HVF' (ignoring QTest, because vCPUs are not available there).
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/cpu.c | 2 +- target/arm/machine.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)target/arm/cpu.c +1
-1@@ -2352,7 +2352,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)if (arm_feature (env,ARM_FEATURE_PMU )) {pmu_init (cpu); -if (!kvm_enabled ()) { +if (tcg_enabled () ||hvf_enabled ()) {arm_register_pre_el_change_hook (cpu, &pmu_pre_el_change,0 );arm_register_el_change_hook (cpu, &pmu_post_el_change,0 ); }target/arm/machine.c +4
-4@@ -1,7 +1,7 @@#include "qemu/osdep.h" #include "cpu.h" #include "qemu/error-report.h" -#include "system/kvm.h" +#include "system/hvf.h" #include "system/tcg.h" #include "kvm_arm.h" #include "internals.h" @@ -853,7 +853,7 @@ static int cpu_pre_save(void *opaque) {ARMCPU *cpu = opaque; -if (!kvm_enabled ()) { +if (tcg_enabled () ||hvf_enabled ()) {pmu_op_start (&cpu->env); }@@ -888,7 +888,7 @@ static int cpu_post_save(void *opaque) {ARMCPU *cpu = opaque; -if (!kvm_enabled ()) { +if (tcg_enabled () ||hvf_enabled ()) {pmu_op_finish (&cpu->env); }@@ -921,7 +921,7 @@ static int cpu_pre_load(void *opaque)*/ env->irq_line_state =UINT32_MAX ; -if (!kvm_enabled ()) { +if (tcg_enabled () ||hvf_enabled ()) {pmu_op_start (env); }
target/arm/machine.c static int cpu_post_load(void *opaque, int version_id) · line 1019
Quoted 8 lines
target/arm/machine.c +1
-1@@ -1013,7 +1013,7 @@ static int cpu_post_load(void *opaque, int version_id) } } -if (!kvm_enabled ()) { +if (tcg_enabled () ||hvf_enabled ()) {pmu_op_finish (env); }
If I understand correctly, this is supported for tcg and hvf, but not kvm, right?
I'm just a bit confused by commit description mentioning "simplify logic", which is more "make it explicit".
Thanks,
Pierrick
Re: [PATCH 3/6] target/arm: Better describe PMU depends on TCG or HVF
In reply to Philippe Mathieu-DaudéQuoted 63 lines · Philippe Mathieu-Daudé
Simplify PMU logic by rewriting '!KVM' as 'TCG || HVF' (ignoring QTest, because vCPUs are not available there).
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/cpu.c | 2 +- target/arm/machine.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)target/arm/cpu.c +1
-1@@ -2352,7 +2352,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)if (arm_feature (env,ARM_FEATURE_PMU )) {pmu_init (cpu); -if (!kvm_enabled ()) { +if (tcg_enabled () ||hvf_enabled ()) {arm_register_pre_el_change_hook (cpu, &pmu_pre_el_change,0 );arm_register_el_change_hook (cpu, &pmu_post_el_change,0 ); }target/arm/machine.c +4
-4@@ -1,7 +1,7 @@#include "qemu/osdep.h" #include "cpu.h" #include "qemu/error-report.h" -#include "system/kvm.h" +#include "system/hvf.h" #include "system/tcg.h" #include "kvm_arm.h" #include "internals.h" @@ -853,7 +853,7 @@ static int cpu_pre_save(void *opaque) {ARMCPU *cpu = opaque; -if (!kvm_enabled ()) { +if (tcg_enabled () ||hvf_enabled ()) {pmu_op_start (&cpu->env); }@@ -888,7 +888,7 @@ static int cpu_post_save(void *opaque) {ARMCPU *cpu = opaque; -if (!kvm_enabled ()) { +if (tcg_enabled () ||hvf_enabled ()) {pmu_op_finish (&cpu->env); }@@ -921,7 +921,7 @@ static int cpu_pre_load(void *opaque)*/ env->irq_line_state =UINT32_MAX ; -if (!kvm_enabled ()) { +if (tcg_enabled () ||hvf_enabled ()) {pmu_op_start (env); }
target/arm/machine.c static int cpu_post_load(void *opaque, int version_id) · line 1019
Quoted 8 lines
target/arm/machine.c +1
-1@@ -1013,7 +1013,7 @@ static int cpu_post_load(void *opaque, int version_id) } } -if (!kvm_enabled ()) { +if (tcg_enabled () ||hvf_enabled ()) {pmu_op_finish (env); }
If I understand correctly, this is supported for tcg and hvf, but not kvm, right?
I'm just a bit confused by commit description mentioning "simplify logic", which is more "make it explicit".
Thanks,
Pierrick
PATCH 4/6 target/arm: Re-use arm_is_psci_call() in HVF
In reply to Philippe Mathieu-DaudéRe-use arm_is_psci_call() instead of open-coding it.
--- target/arm/hvf/hvf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/arm/hvf/hvf.c +2 -2
@@ -2084,7 +2084,7 @@ int hvf_vcpu_exec(CPUState *cpu)break ;case EC_AA64_HVC :cpu_synchronize_state (cpu); -if (arm_cpu->psci_conduit ==QEMU_PSCI_CONDUIT_HVC ) { +if (arm_is_psci_call (arm_cpu,EXCP_HVC )) {if (!hvf_handle_psci_call (cpu)) {trace_hvf_unknown_hvc (env->pc, env->xregs[0 ]);/* SMCCC 1.3 section 5.2 says every unknown SMCCC call returns -1 */
@@ -2097,7 +2097,7 @@ int hvf_vcpu_exec(CPUState *cpu)break ;case EC_AA64_SMC :cpu_synchronize_state (cpu); -if (arm_cpu->psci_conduit ==QEMU_PSCI_CONDUIT_SMC ) { +if (arm_is_psci_call (arm_cpu,EXCP_SMC )) { advance_pc = true;if (!hvf_handle_psci_call (cpu)) {
Signature · 1 line
2.49.0
Re: [PATCH 4/6] target/arm: Re-use arm_is_psci_call() in HVF
Quoted 6 lines · Philippe Mathieu-Daudé
Re-use
arm_is_psci_call()instead of open-coding it.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- target/arm/hvf/hvf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
r~
Re: [PATCH 4/6] target/arm: Re-use arm_is_psci_call() in HVF
In reply to Philippe Mathieu-DaudéQuoted 6 lines · Philippe Mathieu-Daudé
Re-use
arm_is_psci_call()instead of open-coding it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/hvf/hvf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
PATCH 5/6 target/arm: Share ARM_PSCI_CALL trace event between TCG and HVF
In reply to Philippe Mathieu-DaudéIt is useful to compare PSCI calls of the same guest running under TCG or HVF.
--- target/arm/hvf/hvf.c | 3 ++- target/arm/tcg/psci.c | 3 +++ target/arm/trace-events | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-)
target/arm/hvf/hvf.c +2 -1
@@ -34,6 +34,7 @@#include "target/arm/multiprocessing.h" #include "target/arm/gtimer.h" #include "trace.h" +#include "../trace.h" #include "migration/vmstate.h" #include "gdbstub/enums.h"
@@ -1149,7 +1150,7 @@ static bool hvf_handle_psci_call(CPUState *cpu)int target_el =1 ;int32_t ret =0 ; -trace_hvf_psci_call (param[0 ], param[1 ], param[2 ], param[3 ], +trace_arm_psci_call (param[0 ], param[1 ], param[2 ], param[3 ],arm_cpu_mp_affinity (arm_cpu));switch (param[0 ]) {
target/arm/tcg/psci.c +3 -0
@@ -25,6 +25,7 @@#include "internals.h" #include "arm-powerctl.h" #include "target/arm/multiprocessing.h" +#include "../trace.h" bool arm_is_psci_call (ARMCPU *cpu,int excp_type) {
@@ -79,6 +80,8 @@ void arm_handle_psci_call(ARMCPU *cpu)*/ param[i] =is_a64 (env) ? env->xregs[i] : env->regs[i]; } +trace_arm_psci_call (param[0 ], param[1 ], param[2 ], param[3 ], +arm_cpu_mp_affinity (cpu));if ((param[0 ] &QEMU_PSCI_0_2_64BIT ) && !is_a64 (env)) { ret =QEMU_PSCI_RET_NOT_SUPPORTED ;
target/arm/trace-events +3 -0
@@ -13,3 +13,6 @@ arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d" # kvm.c kvm_arm_fixup_msi_route(uint64_t iova, uint64_t gpa) "MSI iova = 0x%"PRIx64" is translated into 0x%"PRIx64 + +# tcg/psci.c and hvf/hvf.c +arm_psci_call(uint64_t x0, uint64_t x1, uint64_t x2, uint64_t x3, uint32_t cpuid) "PSCI Call x0=0x%016"PRIx64" x1=0x%016"PRIx64" x2=0x%016"PRIx64" x3=0x%016"PRIx64" cpuid=0x%x"
Signature · 1 line
2.49.0
Re: [PATCH 5/6] target/arm: Share ARM_PSCI_CALL trace event between TCG and HVF
Quoted 23 lines · Philippe Mathieu-Daudé
It is useful to compare PSCI calls of the same guest running under TCG or HVF.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/hvf/hvf.c | 3 ++- target/arm/tcg/psci.c | 3 +++ target/arm/trace-events | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-)target/arm/hvf/hvf.c +1
-0@@ -34,6 +34,7 @@#include "target/arm/multiprocessing.h" #include "target/arm/gtimer.h" #include "trace.h" +#include "../trace.h" #include "migration/vmstate.h" #include "gdbstub/enums.h"
target/arm/hvf/hvf.c static bool hvf_handle_psci_call(CPUState *cpu) · line 1154
Quoted 6 lines
target/arm/hvf/hvf.c +1
-1@@ -1149,7 +1150,7 @@ static bool hvf_handle_psci_call(CPUState *cpu)int target_el =1 ;int32_t ret =0 ; -trace_hvf_psci_call (param[0 ], param[1 ], param[2 ], param[3 ], +trace_arm_psci_call (param[0 ], param[1 ], param[2 ], param[3 ],arm_cpu_mp_affinity (arm_cpu));
Lacks removal of the hvf trace?
r~
Quoted 34 lines
target/arm/hvf/hvf.c +0
-0switch (param[0 ]) {target/arm/tcg/psci.c +3
-0@@ -25,6 +25,7 @@#include "internals.h" #include "arm-powerctl.h" #include "target/arm/multiprocessing.h" +#include "../trace.h" bool arm_is_psci_call (ARMCPU *cpu,int excp_type) {@@ -79,6 +80,8 @@ void arm_handle_psci_call(ARMCPU *cpu)*/ param[i] =is_a64 (env) ? env->xregs[i] : env->regs[i]; } +trace_arm_psci_call (param[0 ], param[1 ], param[2 ], param[3 ], +arm_cpu_mp_affinity (cpu));if ((param[0 ] &QEMU_PSCI_0_2_64BIT ) && !is_a64 (env)) { ret =QEMU_PSCI_RET_NOT_SUPPORTED ;target/arm/trace-events +3
-0@@ -13,3 +13,6 @@ arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d" # kvm.c kvm_arm_fixup_msi_route(uint64_t iova, uint64_t gpa) "MSI iova = 0x%"PRIx64" is translated into 0x%"PRIx64 + +# tcg/psci.c and hvf/hvf.c +arm_psci_call(uint64_t x0, uint64_t x1, uint64_t x2, uint64_t x3, uint32_t cpuid) "PSCI Call x0=0x%016"PRIx64" x1=0x%016"PRIx64" x2=0x%016"PRIx64" x3=0x%016"PRIx64" cpuid=0x%x"
Re: [PATCH 5/6] target/arm: Share ARM_PSCI_CALL trace event between TCG and HVF
Quoted 22 lines · Richard Henderson
Quoted 21 lines · Philippe Mathieu-Daudé
It is useful to compare PSCI calls of the same guest running under TCG or HVF.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
target/arm/hvf/hvf.c | 3 ++-
target/arm/tcg/psci.c | 3 +++
target/arm/trace-events | 3 +++3 files changed, 8 insertions(+), 1 deletion(-)target/arm/hvf/hvf.c +1
-0@@ -34,6 +34,7 @@ #include "target/arm/multiprocessing.h" #include "target/arm/gtimer.h" #include "trace.h" +#include "../trace.h" #include "migration/vmstate.h" #include "gdbstub/enums.h"
Quoted 8 lines
target/arm/hvf/hvf.c static bool hvf_handle_psci_call(CPUState *cpu) · line 1153
Quoted 6 lines
target/arm/hvf/hvf.c +1
-1@@ -1149,7 +1150,7 @@ static bool hvf_handle_psci_call(CPUState *cpu) int target_el = 1; int32_t ret = 0; - trace_hvf_psci_call(param[0], param[1], param[2], param[3], + trace_arm_psci_call(param[0], param[1], param[2], param[3], arm_cpu_mp_affinity(arm_cpu));Lacks removal of the hvf trace?
Oops indeed...
Re: [PATCH 5/6] target/arm: Share ARM_PSCI_CALL trace event between TCG and HVF
In reply to Philippe Mathieu-DaudéQuoted 57 lines · Philippe Mathieu-Daudé
It is useful to compare PSCI calls of the same guest running under TCG or HVF.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/hvf/hvf.c | 3 ++- target/arm/tcg/psci.c | 3 +++ target/arm/trace-events | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-)target/arm/hvf/hvf.c +2
-1@@ -34,6 +34,7 @@#include "target/arm/multiprocessing.h" #include "target/arm/gtimer.h" #include "trace.h" +#include "../trace.h" #include "migration/vmstate.h" #include "gdbstub/enums.h" @@ -1149,7 +1150,7 @@ static bool hvf_handle_psci_call(CPUState *cpu)int target_el =1 ;int32_t ret =0 ; -trace_hvf_psci_call (param[0 ], param[1 ], param[2 ], param[3 ], +trace_arm_psci_call (param[0 ], param[1 ], param[2 ], param[3 ],arm_cpu_mp_affinity (arm_cpu));switch (param[0 ]) {target/arm/tcg/psci.c +3
-0@@ -25,6 +25,7 @@#include "internals.h" #include "arm-powerctl.h" #include "target/arm/multiprocessing.h" +#include "../trace.h" bool arm_is_psci_call (ARMCPU *cpu,int excp_type) {@@ -79,6 +80,8 @@ void arm_handle_psci_call(ARMCPU *cpu)*/ param[i] =is_a64 (env) ? env->xregs[i] : env->regs[i]; } +trace_arm_psci_call (param[0 ], param[1 ], param[2 ], param[3 ], +arm_cpu_mp_affinity (cpu));if ((param[0 ] &QEMU_PSCI_0_2_64BIT ) && !is_a64 (env)) { ret =QEMU_PSCI_RET_NOT_SUPPORTED ;target/arm/trace-events +0
-0
target/arm/trace-events arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d" · line 18
Quoted 6 lines
target/arm/trace-events +3
-0@@ -13,3 +13,6 @@ arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d" # kvm.c kvm_arm_fixup_msi_route(uint64_t iova, uint64_t gpa) "MSI iova = 0x%"PRIx64" is translated into 0x%"PRIx64 + +# tcg/psci.c and hvf/hvf.c +arm_psci_call(uint64_t x0, uint64_t x1, uint64_t x2, uint64_t x3, uint32_t cpuid) "PSCI Call x0=0x%016"PRIx64" x1=0x%016"PRIx64" x2=0x%016"PRIx64" x3=0x%016"PRIx64" cpuid=0x%x"
Just a nit, using 'target/arm/trace.h' might be more readable than '../trace.h'.
Re: [PATCH 5/6] target/arm: Share ARM_PSCI_CALL trace event between TCG and HVF
Quoted 12 lines · Pierrick Bouvier
Quoted 10 lines · Philippe Mathieu-Daudé
It is useful to compare PSCI calls of the same guest running under TCG or HVF.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/hvf/hvf.c | 3 ++- target/arm/tcg/psci.c | 3 +++ target/arm/trace-events | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-)
Quoted 13 lines
target/arm/hvf/hvf.c line 37
Quoted 9 lines
target/arm/hvf/hvf.c +1
-0@@ -34,6 +34,7 @@#include "target/arm/multiprocessing.h" #include "target/arm/gtimer.h" #include "trace.h" +#include "../trace.h" Just a nit, using '
target/arm/trace.h' might be more readable than '../trace.h'.
Mmm. docs/devel/tracing.rst rather discourages this:
# While it is possible to include a trace.h file from outside a source file's own
# sub-directory, this is discouraged in general. It is strongly preferred that
# all events be declared directly in the sub-directory that uses them. The only # exception is where there are some shared trace events defined in the top level # directory trace-events file.
I don't know if we want to loosen that to permit events that are shared between multiple subdirs (cc'ing the trace subsystem maintainers for their view).
git grep 'include.*trace.h' | grep -v '"trace.h"'| grep -v 'trace.h:'|less
suggests that the only current place where we're including a trace.h not in the same directory is linux-user, where we opt to use the full linux-user/trace.h path. So probably for consistency we should use target/arm/trace.h here.
(That grep also shows up that hw/uefi is missing its trace.h header and the .c files are including trace-hw_uefi.h directly...)
-- PMM
Re: [PATCH 5/6] target/arm: Share ARM_PSCI_CALL trace event between TCG and HVF
Quoted 33 lines · Peter Maydell
Quoted 12 lines · Pierrick Bouvier
Quoted 10 lines · Philippe Mathieu-Daudé
It is useful to compare PSCI calls of the same guest running under TCG or HVF.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/hvf/hvf.c | 3 ++- target/arm/tcg/psci.c | 3 +++ target/arm/trace-events | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-)Quoted 13 lines
target/arm/hvf/hvf.c line 37
Quoted 9 lines
target/arm/hvf/hvf.c +1
-0@@ -34,6 +34,7 @@#include "target/arm/multiprocessing.h" #include "target/arm/gtimer.h" #include "trace.h" +#include "../trace.h" Just a nit, using '
target/arm/trace.h' might be more readable than '../trace.h'.Mmm.
docs/devel/tracing.rstrather discourages this:# While it is possible to include a
trace.hfile from outside a source file's own
# sub-directory, this is discouraged in general. It is strongly preferred that
Quoted 7 lines
# all events be declared directly in the sub-directory that uses them. The only # exception is where there are some shared trace events defined in the top level # directory trace-events file.I don't know if we want to loosen that to permit events that are shared between multiple subdirs (cc'ing the trace subsystem maintainers for their view).
Code is generated from the trace-events files and my main concern is that the build dependencies on the generated code may not be obvious if a trace event from somewhere far away in the source tree hierarchy is used. You might hit linker errors because the .o files needed for the trace events are not being linked in.
I would try to stick with what's described in tracing.rst to avoid difficulties now or in the future.
Quoted 14 lines
git grep 'include.*trace.h' | grep -v '"trace.h"'| grep -v 'trace.h:'|less
suggests that the only current place where we're including a
trace.hnot in the same directory is linux-user, where we opt to use the fulllinux-user/trace.hpath. So probably for consistency we should usetarget/arm/trace.hhere.(That grep also shows up that hw/uefi is missing its
trace.hheader and the .c files are includingtrace-hw_uefi.hdirectly...)-- PMM
Re: [PATCH 5/6] target/arm: Share ARM_PSCI_CALL trace event between TCG and HVF
Quoted 43 lines · Stefan Hajnoczi
Quoted 33 lines · Peter Maydell
Quoted 12 lines · Pierrick Bouvier
Quoted 10 lines · Philippe Mathieu-Daudé
It is useful to compare PSCI calls of the same guest running under TCG or HVF.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/hvf/hvf.c | 3 ++- target/arm/tcg/psci.c | 3 +++ target/arm/trace-events | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-)Quoted 13 lines
target/arm/hvf/hvf.c line 37
Quoted 9 lines
target/arm/hvf/hvf.c +1
-0@@ -34,6 +34,7 @@#include "target/arm/multiprocessing.h" #include "target/arm/gtimer.h" #include "trace.h" +#include "../trace.h" Just a nit, using '
target/arm/trace.h' might be more readable than '../trace.h'.Mmm.
docs/devel/tracing.rstrather discourages this:# While it is possible to include a
trace.hfile from outside a source file's own
# sub-directory, this is discouraged in general. It is strongly preferred thatQuoted 7 lines
# all events be declared directly in the sub-directory that uses them. The only # exception is where there are some shared trace events defined in the top level # directory trace-events file.I don't know if we want to loosen that to permit events that are shared between multiple subdirs (cc'ing the trace subsystem maintainers for their view).
Quoted 8 lines
Code is generated from the trace-events files and my main concern is that the build dependencies on the generated code may not be obvious if a trace event from somewhere far away in the source tree hierarchy is used. You might hit linker errors because the .o files needed for the trace events are not being linked in.
I would try to stick with what's described in
tracing.rstto avoid difficulties now or in the future.
So how should we deal with "two different source files in different subdirectories both want to emit trace event X" ? Creating a utility function that can live in the parent dir just to wrap the trace event seems a bit inefficient.
I agree that using a trace event from a long way away across the source tree is probably a bad idea, but "immediate parent directory" doesn't seem too likely to cause issues ?
-- PMM
Re: [PATCH 5/6] target/arm: Share ARM_PSCI_CALL trace event between TCG and HVF
In reply to Peter MaydellQuoted 41 lines · Peter Maydell
Quoted 12 lines · Pierrick Bouvier
Quoted 10 lines · Philippe Mathieu-Daudé
It is useful to compare PSCI calls of the same guest running under TCG or HVF.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/hvf/hvf.c | 3 ++- target/arm/tcg/psci.c | 3 +++ target/arm/trace-events | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-)Quoted 13 lines
target/arm/hvf/hvf.c line 37
Quoted 9 lines
target/arm/hvf/hvf.c +1
-0@@ -34,6 +34,7 @@#include "target/arm/multiprocessing.h" #include "target/arm/gtimer.h" #include "trace.h" +#include "../trace.h" Just a nit, using '
target/arm/trace.h' might be more readable than '../trace.h'.Mmm.
docs/devel/tracing.rstrather discourages this:# While it is possible to include a
trace.hfile from outside a source file's own
# sub-directory, this is discouraged in general. It is strongly preferred that# all events be declared directly in the sub-directory that uses them. The only # exception is where there are some shared trace events defined in the top level # directory trace-events file.I don't know if we want to loosen that to permit events that are shared between multiple subdirs (cc'ing the trace subsystem maintainers for their view).
Quoted 6 lines
git grep 'include.*trace.h' | grep -v '"trace.h"'| grep -v 'trace.h:'|less
suggests that the only current place where we're including a
trace.hnot in the same directory is linux-user, where we opt to use the fulllinux-user/trace.hpath. So probably for consistency we should usetarget/arm/trace.hhere.
IMHO using the up-level relative paths is desirable, as it reinforces the intent that we shouldn't be pulling in trace events from arbitrary different sub-trees of the codebase, only the current dir & its (near) parents.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH 6/6 target/arm: Allow arm_cpu_tlb_fill_align optionally set CPUTLBEntryFull
In reply to Philippe Mathieu-Daudé--- target/arm/tcg/tlb_helper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
target/arm/tcg/tlb_helper.c +3 -1
@@ -349,7 +349,9 @@ bool arm_cpu_tlb_fill_align(CPUState *cs, CPUTLBEntryFull *out, vaddr address, &res, fi)) { res.f.extra.arm.pte_attrs = res.cacheattrs.attrs; res.f.extra.arm.shareability = res.cacheattrs.shareability; - *out = res.f; +if (out) { + *out = res.f; + }return true; }if (probe) {
Signature · 1 line
2.49.0
Re: [PATCH 6/6] target/arm: Allow arm_cpu_tlb_fill_align optionally set CPUTLBEntryFull
Quoted 10 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/tcg/tlb_helper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)target/arm/tcg/tlb_helper.c +0
-0
target/arm/tcg/tlb_helper.c bool arm_cpu_tlb_fill_align(CPUState *cs, CPUTLBEntryFull *out, vaddr address, · line 357
Quoted 10 lines
target/arm/tcg/tlb_helper.c +3
-1@@ -349,7 +349,9 @@ bool arm_cpu_tlb_fill_align(CPUState *cs, CPUTLBEntryFull *out, vaddr address, &res, fi)) { res.f.extra.arm.pte_attrs = res.cacheattrs.attrs; res.f.extra.arm.shareability = res.cacheattrs.shareability; - *out = res.f; +if (out) { + *out = res.f; + }return true; }if (probe) {
Why? There's no other way to get the phys addr result. Are you only calling this for the raise-exception side effect?
r~
Re: [PATCH 6/6] target/arm: Allow arm_cpu_tlb_fill_align optionally set CPUTLBEntryFull
Quoted 17 lines · Richard Henderson
Quoted 16 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
target/arm/tcg/tlb_helper.c| 4 +++-1 file changed, 3 insertions(+), 1 deletion(-)target/arm/tcg/tlb_helper.c +1
-1@@ -349,7 +349,9 @@ bool arm_cpu_tlb_fill_align(CPUState *cs, CPUTLBEntryFull *out, vaddr address, &res, fi)) { res.f.extra.arm.pte_attrs = res.cacheattrs.attrs; res.f.extra.arm.shareability = res.cacheattrs.shareability; - *out = res.f; + if (out) {
Quoted 8 lines
Quoted 5 lines
target/arm/tcg/tlb_helper.c +2
-0+ *out = res.f; + } return true; }if (probe) {
Why? There's no other way to get the phys addr result. Are you only calling this for the raise-exception side effect?
Yes:
-- >8 --
@@ -2121,6 +2121,25 @@ int hvf_vcpu_exec(CPUState *cpu)
hvf_raise_exception(cpu, EXCP_UDEF, syn_uncategorized(), 1);
}
break;
+ case EC_INSNABORT: {
+ uint32_t set = (syndrome >> 12) & 3;
+ bool fnv = (syndrome >> 10) & 1;
+ bool ea = (syndrome >> 9) & 1;
+ bool s1ptw = (syndrome >> 7) & 1;
+ uint32_t ifsc = (syndrome >> 0) & 0x3f;+
+ trace_hvf_insn_abort(env->pc, set, fnv, ea, s1ptw, ifsc);
+
+ cpu_synchronize_state(cpu);
+ if (tcg_enabled()) {
+ ret = EXCP_EMULATE;
+ arm_cpu_tlb_fill_align(cpu, NULL, env->pc, MMU_INST_FETCH,
+ arm_env_mmu_index(env), MO_32, 4, false, -1);
+ }
+ break;
+ }
default:
cpu_synchronize_state(cpu);
trace_hvf_exit(syndrome, ec, env->pc);---
I see probe_access_full_mmu() uses discard_tlb, I can use a similar stack variable if you rather.
Re: [PATCH 6/6] target/arm: Allow arm_cpu_tlb_fill_align optionally set CPUTLBEntryFull
In reply to Philippe Mathieu-DaudéQuoted 10 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/tcg/tlb_helper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)target/arm/tcg/tlb_helper.c +0
-0
target/arm/tcg/tlb_helper.c bool arm_cpu_tlb_fill_align(CPUState *cs, CPUTLBEntryFull *out, vaddr address, · line 357
Quoted 10 lines
target/arm/tcg/tlb_helper.c +3
-1@@ -349,7 +349,9 @@ bool arm_cpu_tlb_fill_align(CPUState *cs, CPUTLBEntryFull *out, vaddr address, &res, fi)) { res.f.extra.arm.pte_attrs = res.cacheattrs.attrs; res.f.extra.arm.shareability = res.cacheattrs.shareability; - *out = res.f; +if (out) { + *out = res.f; + }return true; }if (probe) {
Would that be possible to provide more context about why it's needed?
The goal of tlb_fill_align is precisely to return a new CPUTLBEntryFull, while checking all the protection to access this page and generating a page fault if needed.
In case you just want to check if an address is valid, arm_cpu_get_phys_page_attrs_debug might be a better choice (checking for return value -1 in case of error).
Thanks,
Pierrick