pause_all_vcpus() TCG bug?
Hello,
This is today's function, with annotations and question inline:
void pause_all_vcpus(void)
{
CPUArchState *penv = first_cpu;
qemu_clock_enable(vm_clock, false);
while (penv) {
CPUState *pcpu = ENV_GET_CPU(penv);
pcpu->stop = true;
qemu_cpu_kick(pcpu);
penv = penv->next_cpu;
}/* So, at this point penv == NULL. */
if (qemu_in_vcpu_thread()) {
cpu_stop_current();
if (!kvm_enabled()) {
while (penv) {/* Looks like this can never be true then? */
/* Is penv = first_cpu; missing? */
CPUState *pcpu = ENV_GET_CPU(penv);
pcpu->stop = 0;/* 0 instead of false may hint at a mismerge... */
pcpu->stopped = true;
penv = penv->next_cpu;
}
return;
}
}
while (!all_vcpus_paused()) {
qemu_cond_wait(&qemu_pause_cond, &qemu_global_mutex);
penv = first_cpu;
while (penv) {
qemu_cpu_kick(ENV_GET_CPU(penv));
penv = penv->next_cpu;
}
}
}Thanks,
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Quoted 29 lines · Andreas Färber
Hello,
This is today's function, with annotations and question inline:
void
pause_all_vcpus(void){ CPUArchState *penv = first_cpu; qemu_clock_enable(vm_clock, false); while (penv) { CPUState *pcpu = ENV_GET_CPU(penv); pcpu->stop = true; qemu_cpu_kick(pcpu); penv = penv->next_cpu; }/* So, at this point penv == NULL. */
if (qemu_in_vcpu_thread()) { cpu_stop_current(); if (!kvm_enabled()) { while (penv) {/* Looks like this can never be true then? */
/* Is penv =first_cpu; missing? */CPUState *pcpu = ENV_GET_CPU(penv); pcpu->stop = 0;
Quoted 8 lines
/* 0 instead of false may hint at a mismerge... */
pcpu->stopped = true; penv = penv->next_cpu; } return; } }
This certainly looks odd. This bug seems to have
been present since this patch was first committed
(d798e9745, January last year, by Jan.)
-- PMM
Quoted 19 lines · Peter Maydell
Quoted 18 lines · Andreas Färber
Hello,
This is today's function, with annotations and question inline:
void
pause_all_vcpus(void){ CPUArchState *penv = first_cpu; qemu_clock_enable(vm_clock, false); while (penv) { CPUState *pcpu = ENV_GET_CPU(penv); pcpu->stop = true; qemu_cpu_kick(pcpu); penv = penv->next_cpu; }/* So, at this point penv == NULL. */
Quoted 7 lines
Quoted 7 lines
if (qemu_in_vcpu_thread()) { cpu_stop_current(); if (!kvm_enabled()) { while (penv) {/* Looks like this can never be true then? */
/* Is penv =first_cpu; missing? */
Yeah, obviously. It practically didn't matter so far for the use case of pause/resume_all_vcpus over a vcpu itself (kvmvapic). Feel free to fix.
Quoted 5 lines
Quoted 5 lines
CPUState *pcpu = ENV_GET_CPU(penv); pcpu->stop = 0;/* 0 instead of false may hint at a mismerge... */
Nope, stop was uint32_t at that time.
Jan
Quoted 14 lines
Quoted 7 lines
pcpu->stopped = true; penv = penv->next_cpu; } return; } }This certainly looks odd. This bug seems to have
been present since this patch was first committed
(d798e9745, January last year, by Jan.)-- PMM
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE Corporate Competence Center Embedded Linux