* [PATCH v5 10/33] target-arm/arm-powerctl: wake up sleeping CPUs
[not found] <20161027151030.20863-1-alex.bennee@linaro.org>
@ 2016-10-27 15:10 ` Alex Bennée
2016-10-27 15:10 ` [PATCH v5 29/33] target-arm/powerctl: defer cpu reset work to CPU context Alex Bennée
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Alex Bennée @ 2016-10-27 15:10 UTC (permalink / raw)
To: pbonzini
Cc: qemu-devel, mttcg, fred.konrad, a.rigo, cota, bobby.prani, nikunj,
mark.burton, jan.kiszka, serge.fdrv, rth, peter.maydell,
claudio.fontana, Alex Bennée, Alexander Spyridakis,
open list:ARM
Testing with Alexander's bare metal syncronisation tests fails in MTTCG
leaving one CPU spinning forever waiting for the second CPU to wake up.
We simply need to kick the vCPU once we have processed the PSCI power on
call.
As the power control API is for system emulation only as is the
qemu_kick_cpu function we also ensure we only build arm-powerctl for
SoftMMU builds.
Tested-by: Alex Bennée <alex.bennee@linaro.org>
CC: Alexander Spyridakis <a.spyridakis@virtualopensystems.com>
Message-Id: <1439220437-23957-20-git-send-email-fred.konrad@greensocs.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
v3
- re-base caught arm_powerctl re-factor
- include cpu.h header for kick definition
- fix Makefile.objs to only build for softmmu
---
target-arm/Makefile.objs | 2 +-
target-arm/arm-powerctl.c | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/target-arm/Makefile.objs b/target-arm/Makefile.objs
index f206411..847fb52 100644
--- a/target-arm/Makefile.objs
+++ b/target-arm/Makefile.objs
@@ -9,4 +9,4 @@ obj-y += neon_helper.o iwmmxt_helper.o
obj-y += gdbstub.o
obj-$(TARGET_AARCH64) += cpu64.o translate-a64.o helper-a64.o gdbstub64.o
obj-y += crypto_helper.o
-obj-y += arm-powerctl.o
+obj-$(CONFIG_SOFTMMU) += arm-powerctl.o
diff --git a/target-arm/arm-powerctl.c b/target-arm/arm-powerctl.c
index 6519d52..fbb7a15 100644
--- a/target-arm/arm-powerctl.c
+++ b/target-arm/arm-powerctl.c
@@ -166,6 +166,8 @@ int arm_set_cpu_on(uint64_t cpuid, uint64_t entry, uint64_t context_id,
/* Start the new CPU at the requested address */
cpu_set_pc(target_cpu_state, entry);
+ qemu_cpu_kick(target_cpu_state);
+
/* We are good to go */
return QEMU_ARM_POWERCTL_RET_SUCCESS;
}
--
2.10.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v5 29/33] target-arm/powerctl: defer cpu reset work to CPU context
[not found] <20161027151030.20863-1-alex.bennee@linaro.org>
2016-10-27 15:10 ` [PATCH v5 10/33] target-arm/arm-powerctl: wake up sleeping CPUs Alex Bennée
@ 2016-10-27 15:10 ` Alex Bennée
2016-10-27 15:10 ` [PATCH v5 30/33] target-arm/cpu: don't reset TLB structures, use cputlb to do it Alex Bennée
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Alex Bennée @ 2016-10-27 15:10 UTC (permalink / raw)
To: pbonzini
Cc: qemu-devel, mttcg, fred.konrad, a.rigo, cota, bobby.prani, nikunj,
mark.burton, jan.kiszka, serge.fdrv, rth, peter.maydell,
claudio.fontana, Alex Bennée, open list:ARM
When switching a new vCPU on we want to complete a bunch of the setup
work before we start scheduling the vCPU thread. To do this cleanly we
defer vCPU setup to async work which will run the vCPUs execution
context as the thread is woken up. The scheduling of the work will kick
the vCPU awake.
This avoids potential races in MTTCG system emulation.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
target-arm/arm-powerctl.c | 144 +++++++++++++++++++++++++++-------------------
1 file changed, 86 insertions(+), 58 deletions(-)
diff --git a/target-arm/arm-powerctl.c b/target-arm/arm-powerctl.c
index fbb7a15..0ef4b29 100644
--- a/target-arm/arm-powerctl.c
+++ b/target-arm/arm-powerctl.c
@@ -48,11 +48,85 @@ CPUState *arm_get_cpu_by_id(uint64_t id)
return NULL;
}
+struct cpu_on_info {
+ uint64_t entry;
+ uint64_t context_id;
+ uint32_t target_el;
+ bool target_aa64;
+};
+
+
+static void arm_set_cpu_on_async_work(CPUState *target_cpu_state,
+ run_on_cpu_data data)
+{
+ ARMCPU *target_cpu = ARM_CPU(target_cpu_state);
+ struct cpu_on_info *info = (struct cpu_on_info *) data.host_ptr;
+
+ /* Initialize the cpu we are turning on */
+ cpu_reset(target_cpu_state);
+ target_cpu->powered_off = false;
+ target_cpu_state->halted = 0;
+
+ if (info->target_aa64) {
+ if ((info->target_el < 3) && arm_feature(&target_cpu->env, ARM_FEATURE_EL3)) {
+ /*
+ * As target mode is AArch64, we need to set lower
+ * exception level (the requested level 2) to AArch64
+ */
+ target_cpu->env.cp15.scr_el3 |= SCR_RW;
+ }
+
+ if ((info->target_el < 2) && arm_feature(&target_cpu->env, ARM_FEATURE_EL2)) {
+ /*
+ * As target mode is AArch64, we need to set lower
+ * exception level (the requested level 1) to AArch64
+ */
+ target_cpu->env.cp15.hcr_el2 |= HCR_RW;
+ }
+
+ target_cpu->env.pstate = aarch64_pstate_mode(info->target_el, true);
+ } else {
+ /* We are requested to boot in AArch32 mode */
+ static uint32_t mode_for_el[] = { 0,
+ ARM_CPU_MODE_SVC,
+ ARM_CPU_MODE_HYP,
+ ARM_CPU_MODE_SVC };
+
+ cpsr_write(&target_cpu->env, mode_for_el[info->target_el], CPSR_M,
+ CPSRWriteRaw);
+ }
+
+ if (info->target_el == 3) {
+ /* Processor is in secure mode */
+ target_cpu->env.cp15.scr_el3 &= ~SCR_NS;
+ } else {
+ /* Processor is not in secure mode */
+ target_cpu->env.cp15.scr_el3 |= SCR_NS;
+ }
+
+ /* We check if the started CPU is now at the correct level */
+ assert(info->target_el == arm_current_el(&target_cpu->env));
+
+ if (info->target_aa64) {
+ target_cpu->env.xregs[0] = info->context_id;
+ target_cpu->env.thumb = false;
+ } else {
+ target_cpu->env.regs[0] = info->context_id;
+ target_cpu->env.thumb = info->entry & 1;
+ info->entry &= 0xfffffffe;
+ }
+
+ /* Start the new CPU at the requested address */
+ cpu_set_pc(target_cpu_state, info->entry);
+ g_free(info);
+}
+
int arm_set_cpu_on(uint64_t cpuid, uint64_t entry, uint64_t context_id,
uint32_t target_el, bool target_aa64)
{
CPUState *target_cpu_state;
ARMCPU *target_cpu;
+ struct cpu_on_info *info;
DPRINTF("cpu %" PRId64 " (EL %d, %s) @ 0x%" PRIx64 " with R0 = 0x%" PRIx64
"\n", cpuid, target_el, target_aa64 ? "aarch64" : "aarch32", entry,
@@ -109,64 +183,18 @@ int arm_set_cpu_on(uint64_t cpuid, uint64_t entry, uint64_t context_id,
return QEMU_ARM_POWERCTL_INVALID_PARAM;
}
- /* Initialize the cpu we are turning on */
- cpu_reset(target_cpu_state);
- target_cpu->powered_off = false;
- target_cpu_state->halted = 0;
-
- if (target_aa64) {
- if ((target_el < 3) && arm_feature(&target_cpu->env, ARM_FEATURE_EL3)) {
- /*
- * As target mode is AArch64, we need to set lower
- * exception level (the requested level 2) to AArch64
- */
- target_cpu->env.cp15.scr_el3 |= SCR_RW;
- }
-
- if ((target_el < 2) && arm_feature(&target_cpu->env, ARM_FEATURE_EL2)) {
- /*
- * As target mode is AArch64, we need to set lower
- * exception level (the requested level 1) to AArch64
- */
- target_cpu->env.cp15.hcr_el2 |= HCR_RW;
- }
-
- target_cpu->env.pstate = aarch64_pstate_mode(target_el, true);
- } else {
- /* We are requested to boot in AArch32 mode */
- static uint32_t mode_for_el[] = { 0,
- ARM_CPU_MODE_SVC,
- ARM_CPU_MODE_HYP,
- ARM_CPU_MODE_SVC };
-
- cpsr_write(&target_cpu->env, mode_for_el[target_el], CPSR_M,
- CPSRWriteRaw);
- }
-
- if (target_el == 3) {
- /* Processor is in secure mode */
- target_cpu->env.cp15.scr_el3 &= ~SCR_NS;
- } else {
- /* Processor is not in secure mode */
- target_cpu->env.cp15.scr_el3 |= SCR_NS;
- }
-
- /* We check if the started CPU is now at the correct level */
- assert(target_el == arm_current_el(&target_cpu->env));
-
- if (target_aa64) {
- target_cpu->env.xregs[0] = context_id;
- target_cpu->env.thumb = false;
- } else {
- target_cpu->env.regs[0] = context_id;
- target_cpu->env.thumb = entry & 1;
- entry &= 0xfffffffe;
- }
-
- /* Start the new CPU at the requested address */
- cpu_set_pc(target_cpu_state, entry);
-
- qemu_cpu_kick(target_cpu_state);
+ /* To avoid racing with a CPU we are just kicking off we do the
+ * final bit of preparation for the work in the target CPUs
+ * context.
+ */
+ info = g_new(struct cpu_on_info, 1);
+ info->entry = entry;
+ info->context_id = context_id;
+ info->target_el = target_el;
+ info->target_aa64 = target_aa64;
+
+ async_run_on_cpu(target_cpu_state, arm_set_cpu_on_async_work,
+ RUN_ON_CPU_HOST_PTR(info));
/* We are good to go */
return QEMU_ARM_POWERCTL_RET_SUCCESS;
--
2.10.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v5 30/33] target-arm/cpu: don't reset TLB structures, use cputlb to do it
[not found] <20161027151030.20863-1-alex.bennee@linaro.org>
2016-10-27 15:10 ` [PATCH v5 10/33] target-arm/arm-powerctl: wake up sleeping CPUs Alex Bennée
2016-10-27 15:10 ` [PATCH v5 29/33] target-arm/powerctl: defer cpu reset work to CPU context Alex Bennée
@ 2016-10-27 15:10 ` Alex Bennée
2016-10-27 16:10 ` Richard Henderson
2016-10-27 15:10 ` [PATCH v5 31/33] target-arm: ensure BQL taken for ARM_CP_IO register access Alex Bennée
2016-10-27 15:10 ` [PATCH v5 32/33] target-arm: helpers which may affect global state need the BQL Alex Bennée
4 siblings, 1 reply; 9+ messages in thread
From: Alex Bennée @ 2016-10-27 15:10 UTC (permalink / raw)
To: pbonzini
Cc: qemu-devel, mttcg, fred.konrad, a.rigo, cota, bobby.prani, nikunj,
mark.burton, jan.kiszka, serge.fdrv, rth, peter.maydell,
claudio.fontana, Alex Bennée, open list:ARM
cputlb owns the TLB entries and knows how to safely update them in
MTTCG.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
target-arm/cpu.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/target-arm/cpu.c b/target-arm/cpu.c
index 1b9540e..ff8c594 100644
--- a/target-arm/cpu.c
+++ b/target-arm/cpu.c
@@ -121,7 +121,13 @@ static void arm_cpu_reset(CPUState *s)
acc->parent_reset(s);
+#ifdef CONFIG_SOFTMMU
+ memset(env, 0, offsetof(CPUARMState, tlb_table));
+ tlb_flush(s, 0);
+#else
memset(env, 0, offsetof(CPUARMState, features));
+#endif
+
g_hash_table_foreach(cpu->cp_regs, cp_reg_reset, cpu);
g_hash_table_foreach(cpu->cp_regs, cp_reg_check_reset, cpu);
--
2.10.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v5 31/33] target-arm: ensure BQL taken for ARM_CP_IO register access
[not found] <20161027151030.20863-1-alex.bennee@linaro.org>
` (2 preceding siblings ...)
2016-10-27 15:10 ` [PATCH v5 30/33] target-arm/cpu: don't reset TLB structures, use cputlb to do it Alex Bennée
@ 2016-10-27 15:10 ` Alex Bennée
2016-10-27 15:10 ` [PATCH v5 32/33] target-arm: helpers which may affect global state need the BQL Alex Bennée
4 siblings, 0 replies; 9+ messages in thread
From: Alex Bennée @ 2016-10-27 15:10 UTC (permalink / raw)
To: pbonzini
Cc: qemu-devel, mttcg, fred.konrad, a.rigo, cota, bobby.prani, nikunj,
mark.burton, jan.kiszka, serge.fdrv, rth, peter.maydell,
claudio.fontana, Alex Bennée, open list:ARM cores
Most ARMCPRegInfo structures just allow updating of the CPU field.
However some have more complex operations that *may* be have cross vCPU
effects therefor need to be serialised. The most obvious examples at the
moment are things that affect the GICv3 IRQ controller. To avoid
applying this requirement to all registers with custom access functions
we check for if the type is marked ARM_CP_IO.
By default all MMIO access to devices already takes the BQL to serialise
hardware emulation.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
hw/intc/arm_gicv3_cpuif.c | 3 +++
target-arm/op_helper.c | 39 +++++++++++++++++++++++++++++++++++----
2 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
index bca30c4..8ea4b5b 100644
--- a/hw/intc/arm_gicv3_cpuif.c
+++ b/hw/intc/arm_gicv3_cpuif.c
@@ -13,6 +13,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/main-loop.h"
#include "trace.h"
#include "gicv3_internal.h"
#include "cpu.h"
@@ -128,6 +129,8 @@ void gicv3_cpuif_update(GICv3CPUState *cs)
ARMCPU *cpu = ARM_CPU(cs->cpu);
CPUARMState *env = &cpu->env;
+ g_assert(qemu_mutex_iothread_locked());
+
trace_gicv3_cpuif_update(gicv3_redist_affid(cs), cs->hppi.irq,
cs->hppi.grp, cs->hppi.prio);
diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c
index cd94216..4f0c754 100644
--- a/target-arm/op_helper.c
+++ b/target-arm/op_helper.c
@@ -17,6 +17,7 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "qemu/osdep.h"
+#include "qemu/main-loop.h"
#include "cpu.h"
#include "exec/helper-proto.h"
#include "internals.h"
@@ -734,28 +735,58 @@ void HELPER(set_cp_reg)(CPUARMState *env, void *rip, uint32_t value)
{
const ARMCPRegInfo *ri = rip;
- ri->writefn(env, ri, value);
+ if (ri->type & ARM_CP_IO) {
+ qemu_mutex_lock_iothread();
+ ri->writefn(env, ri, value);
+ qemu_mutex_unlock_iothread();
+ } else {
+ ri->writefn(env, ri, value);
+ }
}
uint32_t HELPER(get_cp_reg)(CPUARMState *env, void *rip)
{
const ARMCPRegInfo *ri = rip;
+ uint32_t res;
- return ri->readfn(env, ri);
+ if (ri->type & ARM_CP_IO) {
+ qemu_mutex_lock_iothread();
+ res = ri->readfn(env, ri);
+ qemu_mutex_unlock_iothread();
+ } else {
+ res = ri->readfn(env, ri);
+ }
+
+ return res;
}
void HELPER(set_cp_reg64)(CPUARMState *env, void *rip, uint64_t value)
{
const ARMCPRegInfo *ri = rip;
- ri->writefn(env, ri, value);
+ if (ri->type & ARM_CP_IO) {
+ qemu_mutex_lock_iothread();
+ ri->writefn(env, ri, value);
+ qemu_mutex_unlock_iothread();
+ } else {
+ ri->writefn(env, ri, value);
+ }
}
uint64_t HELPER(get_cp_reg64)(CPUARMState *env, void *rip)
{
const ARMCPRegInfo *ri = rip;
+ uint64_t res;
+
+ if (ri->type & ARM_CP_IO) {
+ qemu_mutex_lock_iothread();
+ res = ri->readfn(env, ri);
+ qemu_mutex_unlock_iothread();
+ } else {
+ res = ri->readfn(env, ri);
+ }
- return ri->readfn(env, ri);
+ return res;
}
void HELPER(msr_i_pstate)(CPUARMState *env, uint32_t op, uint32_t imm)
--
2.10.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v5 32/33] target-arm: helpers which may affect global state need the BQL
[not found] <20161027151030.20863-1-alex.bennee@linaro.org>
` (3 preceding siblings ...)
2016-10-27 15:10 ` [PATCH v5 31/33] target-arm: ensure BQL taken for ARM_CP_IO register access Alex Bennée
@ 2016-10-27 15:10 ` Alex Bennée
4 siblings, 0 replies; 9+ messages in thread
From: Alex Bennée @ 2016-10-27 15:10 UTC (permalink / raw)
To: pbonzini
Cc: qemu-devel, mttcg, fred.konrad, a.rigo, cota, bobby.prani, nikunj,
mark.burton, jan.kiszka, serge.fdrv, rth, peter.maydell,
claudio.fontana, Alex Bennée, open list:ARM
As the arm_call_el_change_hook may affect global state (for example with
updating the global GIC state) we need to assert/take the BQL.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
target-arm/helper.c | 6 ++++++
target-arm/op_helper.c | 4 ++++
2 files changed, 10 insertions(+)
diff --git a/target-arm/helper.c b/target-arm/helper.c
index cb83ee2..ad93926 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -6662,6 +6662,12 @@ void arm_cpu_do_interrupt(CPUState *cs)
arm_cpu_do_interrupt_aarch32(cs);
}
+ /* Hooks may change global state so BQL should be held, also the
+ * BQL needs to be held for any modification of
+ * cs->interrupt_request.
+ */
+ g_assert(qemu_mutex_iothread_locked());
+
arm_call_el_change_hook(cpu);
if (!kvm_enabled()) {
diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c
index 4f0c754..41beabc 100644
--- a/target-arm/op_helper.c
+++ b/target-arm/op_helper.c
@@ -487,7 +487,9 @@ void HELPER(cpsr_write_eret)(CPUARMState *env, uint32_t val)
*/
env->regs[15] &= (env->thumb ? ~1 : ~3);
+ qemu_mutex_lock_iothread();
arm_call_el_change_hook(arm_env_get_cpu(env));
+ qemu_mutex_unlock_iothread();
}
/* Access to user mode registers from privileged modes. */
@@ -1013,7 +1015,9 @@ void HELPER(exception_return)(CPUARMState *env)
env->pc = env->elr_el[cur_el];
}
+ qemu_mutex_lock_iothread();
arm_call_el_change_hook(arm_env_get_cpu(env));
+ qemu_mutex_unlock_iothread();
return;
--
2.10.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v5 30/33] target-arm/cpu: don't reset TLB structures, use cputlb to do it
2016-10-27 15:10 ` [PATCH v5 30/33] target-arm/cpu: don't reset TLB structures, use cputlb to do it Alex Bennée
@ 2016-10-27 16:10 ` Richard Henderson
2016-10-28 8:38 ` Alex Bennée
0 siblings, 1 reply; 9+ messages in thread
From: Richard Henderson @ 2016-10-27 16:10 UTC (permalink / raw)
To: Alex Bennée, pbonzini
Cc: qemu-devel, mttcg, fred.konrad, a.rigo, cota, bobby.prani, nikunj,
mark.burton, jan.kiszka, serge.fdrv, peter.maydell,
claudio.fontana, open list:ARM
On 10/27/2016 08:10 AM, Alex Bennée wrote:
> cputlb owns the TLB entries and knows how to safely update them in
> MTTCG.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> target-arm/cpu.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/target-arm/cpu.c b/target-arm/cpu.c
> index 1b9540e..ff8c594 100644
> --- a/target-arm/cpu.c
> +++ b/target-arm/cpu.c
> @@ -121,7 +121,13 @@ static void arm_cpu_reset(CPUState *s)
>
> acc->parent_reset(s);
>
> +#ifdef CONFIG_SOFTMMU
> + memset(env, 0, offsetof(CPUARMState, tlb_table));
> + tlb_flush(s, 0);
> +#else
> memset(env, 0, offsetof(CPUARMState, features));
> +#endif
> +
Why special case this for softmmu? And don't we (or if not, shouldn't we)
handle the tlb_flush generically for reset?
r~
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v5 30/33] target-arm/cpu: don't reset TLB structures, use cputlb to do it
2016-10-27 16:10 ` Richard Henderson
@ 2016-10-28 8:38 ` Alex Bennée
2016-10-28 9:07 ` Peter Maydell
0 siblings, 1 reply; 9+ messages in thread
From: Alex Bennée @ 2016-10-28 8:38 UTC (permalink / raw)
To: Richard Henderson
Cc: pbonzini, qemu-devel, mttcg, fred.konrad, a.rigo, cota,
bobby.prani, nikunj, mark.burton, jan.kiszka, serge.fdrv,
peter.maydell, claudio.fontana, open list:ARM
Richard Henderson <rth@twiddle.net> writes:
> On 10/27/2016 08:10 AM, Alex Bennée wrote:
>> cputlb owns the TLB entries and knows how to safely update them in
>> MTTCG.
>>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>> target-arm/cpu.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/target-arm/cpu.c b/target-arm/cpu.c
>> index 1b9540e..ff8c594 100644
>> --- a/target-arm/cpu.c
>> +++ b/target-arm/cpu.c
>> @@ -121,7 +121,13 @@ static void arm_cpu_reset(CPUState *s)
>>
>> acc->parent_reset(s);
>>
>> +#ifdef CONFIG_SOFTMMU
>> + memset(env, 0, offsetof(CPUARMState, tlb_table));
>> + tlb_flush(s, 0);
>> +#else
>> memset(env, 0, offsetof(CPUARMState, features));
>> +#endif
>> +
>
> Why special case this for softmmu?
I didn't want to move cpu->features to the other side of CPU_COMMON in
cpu.h as there is an explicit statement about being reset. Adding
another variable just to be an endpoint of a memset also seemed
sub-optimal.
> And don't we (or if not, shouldn't we)
> handle the tlb_flush generically for reset?
Probably. tlb_flush seems to be one of those things liberally sprinkled
in the arch code for all sorts of things but certainly cpu_reset is one
we could make the call from generic code.
>
>
> r~
--
Alex Bennée
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v5 30/33] target-arm/cpu: don't reset TLB structures, use cputlb to do it
2016-10-28 8:38 ` Alex Bennée
@ 2016-10-28 9:07 ` Peter Maydell
2016-10-28 9:17 ` Alex Bennée
0 siblings, 1 reply; 9+ messages in thread
From: Peter Maydell @ 2016-10-28 9:07 UTC (permalink / raw)
To: Alex Bennée
Cc: Richard Henderson, Paolo Bonzini, QEMU Developers, MTTCG Devel,
KONRAD Frédéric, Alvise Rigo, Emilio G. Cota,
Pranith Kumar, Nikunj A Dadhania, Mark Burton, Jan Kiszka,
Fedorov Sergey, Claudio Fontana, open list:ARM
On 28 October 2016 at 09:38, Alex Bennée <alex.bennee@linaro.org> wrote:
>
> Richard Henderson <rth@twiddle.net> writes:
>> And don't we (or if not, shouldn't we)
>> handle the tlb_flush generically for reset?
>
> Probably. tlb_flush seems to be one of those things liberally sprinkled
> in the arch code for all sorts of things but certainly cpu_reset is one
> we could make the call from generic code.
I think the theory I formed last time I looked at it is that
if your CPU has no state which would require you to flush the
TLB when it changes, then there's no need to flush the TLB
on reset -- any entries still in the TLB from before reset are
still valid after reset. For ARM a CPU reset will reset state
like the ASID and the MMU-enabled bit which require a TLB flush
on change, so we have to call tlb_flush here.
You could argue that the set of CPUs which don't require a
tlb flush on reset are not worth trying to optimise for
like this and we should just do it generically.
thanks
-- PMM
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v5 30/33] target-arm/cpu: don't reset TLB structures, use cputlb to do it
2016-10-28 9:07 ` Peter Maydell
@ 2016-10-28 9:17 ` Alex Bennée
0 siblings, 0 replies; 9+ messages in thread
From: Alex Bennée @ 2016-10-28 9:17 UTC (permalink / raw)
To: Peter Maydell
Cc: Richard Henderson, Paolo Bonzini, QEMU Developers, MTTCG Devel,
KONRAD Frédéric, Alvise Rigo, Emilio G. Cota,
Pranith Kumar, Nikunj A Dadhania, Mark Burton, Jan Kiszka,
Fedorov Sergey, Claudio Fontana, open list:ARM
Peter Maydell <peter.maydell@linaro.org> writes:
> On 28 October 2016 at 09:38, Alex Bennée <alex.bennee@linaro.org> wrote:
>>
>> Richard Henderson <rth@twiddle.net> writes:
>>> And don't we (or if not, shouldn't we)
>>> handle the tlb_flush generically for reset?
>>
>> Probably. tlb_flush seems to be one of those things liberally sprinkled
>> in the arch code for all sorts of things but certainly cpu_reset is one
>> we could make the call from generic code.
>
> I think the theory I formed last time I looked at it is that
> if your CPU has no state which would require you to flush the
> TLB when it changes, then there's no need to flush the TLB
> on reset -- any entries still in the TLB from before reset are
> still valid after reset. For ARM a CPU reset will reset state
> like the ASID and the MMU-enabled bit which require a TLB flush
> on change, so we have to call tlb_flush here.
>
> You could argue that the set of CPUs which don't require a
> tlb flush on reset are not worth trying to optimise for
> like this and we should just do it generically.
Well it can't harm anyone. It would just mean all CPUs whatever their
semantics would have to re-fill the TLBs after a reset. I guess that
might be a concern for reset latency under TCG but I doubt anyone would
notice.
--
Alex Bennée
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-10-28 9:17 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20161027151030.20863-1-alex.bennee@linaro.org>
2016-10-27 15:10 ` [PATCH v5 10/33] target-arm/arm-powerctl: wake up sleeping CPUs Alex Bennée
2016-10-27 15:10 ` [PATCH v5 29/33] target-arm/powerctl: defer cpu reset work to CPU context Alex Bennée
2016-10-27 15:10 ` [PATCH v5 30/33] target-arm/cpu: don't reset TLB structures, use cputlb to do it Alex Bennée
2016-10-27 16:10 ` Richard Henderson
2016-10-28 8:38 ` Alex Bennée
2016-10-28 9:07 ` Peter Maydell
2016-10-28 9:17 ` Alex Bennée
2016-10-27 15:10 ` [PATCH v5 31/33] target-arm: ensure BQL taken for ARM_CP_IO register access Alex Bennée
2016-10-27 15:10 ` [PATCH v5 32/33] target-arm: helpers which may affect global state need the BQL Alex Bennée
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).