From: Hollis Blanchard Subject: Re: [kvm-devel] [RFC][PATCH 3/4] kvm-vmx: KVM_EXIT_DEBUG on =?utf-8?q?=23BP=09exceptions?= Date: Thu, 22 May 2008 09:26:51 -0500 Message-ID: <200805220926.52133.hollisb@us.ibm.com> References: <482D9198.7040801@web.de> <4834474B.7030600@qumranet.com> <483575C2.1040303@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Cc: Avi Kivity , kvm-devel To: Jan Kiszka Return-path: Received: from e4.ny.us.ibm.com ([32.97.182.144]:52167 "EHLO e4.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750827AbYEVO2P (ORCPT ); Thu, 22 May 2008 10:28:15 -0400 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e4.ny.us.ibm.com (8.13.8/8.13.8) with ESMTP id m4MESCSY025352 for ; Thu, 22 May 2008 10:28:12 -0400 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v8.7) with ESMTP id m4MEQuF5152026 for ; Thu, 22 May 2008 10:26:56 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m4MEQtqv027361 for ; Thu, 22 May 2008 10:26:56 -0400 In-Reply-To: <483575C2.1040303@web.de> Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: On Thursday 22 May 2008 08:31:46 Jan Kiszka wrote: > Avi Kivity wrote: > > Jan Kiszka wrote: > >> In order to allow the gdbstub of QEMU to push (soft) breakpoint handling > >> completely into the gdb frontend, this patch enables guest exits also > >> for #BP exceptions - in case guest debugging was turned on. > >> > >> Along this enhancement, this patch also fixes the flag manipulation for > >> the singlestep mode. > >> > > > > Suppose userspace determines the exception is due to a guest > > breakpoint. How does it inject the debug exception? > > Good question. Is there no "inject exception #XX" mechanism in kvm yet? > > Will need this, as my current impression is that we better keep track of > breakpoints at qemu level to tell guest soft-BPs apart from host > injected ones. Would you suggest to add a separate IOCTL for exception > injection then? Or should the new guest debug IOCTL contain a flag that > signals "inject breakpoint trap" (both for guest soft-BP hits as well as > guests already in single step mode)? In addition to injecting debug interrupts, qemu should also be able to inject machine checks, for the case of undecoded MMIO accesses. As long as qemu can access the complete register state (e.g. including "reason for machine check" registers), I don't think the injection interface *needs* to be more complicated than "exception number". OTOH, I can see the argument for atomic injection operations, so to support that you'd end up with a sub-structure like kvm_exit, something like: struct kvm_inject_arch { u32 exception_type; union { struct machine_check { u32 mcsr; } mc; struct debug { } debug; }; } This stuff is completely arch-specific, so making a common "inject" ioctl number that simply calls arch function (like GET_SREGS) would be appropriate. -- Hollis Blanchard IBM Linux Technology Center