From: Jan Kiszka <jan.kiszka@siemens.com>
To: Avi Kivity <avi@qumranet.com>
Cc: kvm-devel <kvm@vger.kernel.org>,
Hollis Blanchard <hollisb@us.ibm.com>,
Jerone Young <jyoung5@us.ibm.com>,
Joerg Roedel <joerg.roedel@amd.com>
Subject: Re: [PATCH 1/11] QEMU/KVM: Fix deadlocks in monitor and debugger
Date: Tue, 27 May 2008 15:00:39 +0200 [thread overview]
Message-ID: <483C05F7.8040104@siemens.com> (raw)
In-Reply-To: <483BD633.3080302@qumranet.com>
Avi Kivity wrote:
> Jan Kiszka wrote:
>> Some monitor commands as well as the vm_stop() issued by the gdbstub on
>> external interruption so far deadlock on vcpu locks in the kernel. Patch
>> below resolves the issue by temporarily or permanently stopping all vcpu
>> threads before issuing the related KVM IOCTLs. It enables, e.g., to
>> break into guest code spinning in the vcpu and to use things like "info
>> cpus" in the monitor.
>>
>
> I implemented the alternative on_vcpu() approach for this (similar to
> smp_call_function_single in the kernel) which solves the livelock
> without resorting to stopping the VM.
I assume this pattern should then be applied to kvm_guest_debug (and
later on kvm_set_guest_debug) as well? You missed to fix that bug.
Here is a quick patch to complete the work, will post rebased versions
of my remaining patches later today:
-----------
Use on_vcpu to call into kvm_guest_debug. Fix on_vpuc usage in
kvm_load_registers.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
qemu/qemu-kvm.c | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
Index: b/qemu/qemu-kvm.c
===================================================================
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -187,7 +187,7 @@ static void kvm_do_load_registers(void *
void kvm_load_registers(CPUState *env)
{
if (kvm_enabled())
- on_vcpu(env->cpu_index, kvm_do_load_registers, env);
+ on_vcpu(env, kvm_do_load_registers, env);
}
static void kvm_do_save_registers(void *_env)
@@ -816,23 +816,37 @@ int kvm_qemu_init_env(CPUState *cenv)
return kvm_arch_qemu_init_env(cenv);
}
+struct kvm_guest_debug_data {
+ struct kvm_debug_guest dbg;
+ int err;
+};
+
+void kvm_invoke_guest_debug(void *data)
+{
+ struct kvm_guest_debug_data *dbg_data = data;
+
+ dbg_data->err = kvm_guest_debug(kvm_context, cpu_single_env->cpu_index,
+ &dbg_data->dbg);
+}
+
int kvm_update_debugger(CPUState *env)
{
- struct kvm_debug_guest dbg;
+ struct kvm_guest_debug_data data;
int i;
- memset(dbg.breakpoints, 0, sizeof(dbg.breakpoints));
+ memset(data.dbg.breakpoints, 0, sizeof(data.dbg.breakpoints));
- dbg.enabled = 0;
+ data.dbg.enabled = 0;
if (env->nb_breakpoints || env->singlestep_enabled) {
- dbg.enabled = 1;
+ data.dbg.enabled = 1;
for (i = 0; i < 4 && i < env->nb_breakpoints; ++i) {
- dbg.breakpoints[i].enabled = 1;
- dbg.breakpoints[i].address = env->breakpoints[i];
+ data.dbg.breakpoints[i].enabled = 1;
+ data.dbg.breakpoints[i].address = env->breakpoints[i];
}
- dbg.singlestep = env->singlestep_enabled;
+ data.dbg.singlestep = env->singlestep_enabled;
}
- return kvm_guest_debug(kvm_context, env->cpu_index, &dbg);
+ on_vcpu(env, kvm_invoke_guest_debug, &data);
+ return data.err;
}
next prev parent reply other threads:[~2008-05-27 13:01 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-26 22:05 [PATCH 0/11] Rework guest debug interface / x86 debug register support -v2 Jan Kiszka
2008-05-26 22:09 ` [PATCH 1/11] QEMU/KVM: Fix deadlocks in monitor and debugger Jan Kiszka
2008-05-27 9:36 ` Avi Kivity
2008-05-27 13:00 ` Jan Kiszka [this message]
2008-05-27 13:09 ` Avi Kivity
2008-05-26 22:09 ` [PATCH 2/11] QEMU/KVM: Cleanup and improve kvm_load/save_registers usage Jan Kiszka
2008-06-09 19:16 ` Anthony Liguori
2008-06-12 12:38 ` Avi Kivity
2008-05-26 22:09 ` [PATCH 3/11] QEMU/KVM: Proper vm_stop on debug events Jan Kiszka
2008-05-26 22:09 ` [PATCH 4/11] QEMU: Enhance cpu_break/watchpoint API and gdbstub integration Jan Kiszka
2008-05-26 22:10 ` [PATCH 5/11] QEMU: Improve SMP debugging support Jan Kiszka
2008-05-26 22:10 ` [PATCH 6/11] QEMU/KVM: Introduce single vcpu pause/resume Jan Kiszka
2008-05-26 22:10 ` [PATCH 7/11] QEMU/KVM: New guest debugging interface Jan Kiszka
2008-05-27 18:31 ` Jan Kiszka
2008-05-26 22:10 ` [PATCH 8/11] QEMU/KVM: Support for SMP guest debugging Jan Kiszka
2008-05-26 22:10 ` [PATCH 9/11] KVM: New guest debugging interface Jan Kiszka
2008-05-26 22:10 ` [PATCH 10/11] KVM-x86: Properly virtualize debug registers Jan Kiszka
2008-05-26 22:10 ` [PATCH 11/11] KVM-x86: Wire up host-managed " Jan Kiszka
2008-05-27 9:50 ` [PATCH 0/11] Rework guest debug interface / x86 debug register support -v2 Avi Kivity
2008-05-27 10:44 ` Jan Kiszka
2008-05-27 18:46 ` Hollis Blanchard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=483C05F7.8040104@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=avi@qumranet.com \
--cc=hollisb@us.ibm.com \
--cc=joerg.roedel@amd.com \
--cc=jyoung5@us.ibm.com \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox