From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Graf Subject: Re: [PATCH 4/4] kvmppc/booke: exit_nr fixup for guest debug single step Date: Wed, 03 Feb 2010 12:19:07 +0100 Message-ID: <4B695BAB.2070000@suse.de> References: <1265183633-2230-1-git-send-email-yu.liu@freescale.com> <1265183633-2230-2-git-send-email-yu.liu@freescale.com> <1265183633-2230-3-git-send-email-yu.liu@freescale.com> <1265183633-2230-4-git-send-email-yu.liu@freescale.com> <1265183633-2230-5-git-send-email-yu.liu@freescale.com> <0A1FE637C2C7E148B9573BB60CC630E5762ADE@zch01exm26.fsl.freescale.net> <4B694C6C.3020903@suse.de> <0A1FE637C2C7E148B9573BB60CC630E5762AFC@zch01exm26.fsl.freescale.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: hollis-yUx37fBWTUITNcAmw9vGhQ@public.gmane.org, kvm-ppc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Liu Yu-B13201 Return-path: In-Reply-To: <0A1FE637C2C7E148B9573BB60CC630E5762AFC-bKEhWGtIRUJ4Lp7cDGe+DVjVikpgYyvb5NbjCUgZEJk@public.gmane.org> Sender: kvm-ppc-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: kvm.vger.kernel.org Liu Yu-B13201 wrote: > > > >> -----Original Message----- >> From: Alexander Graf [mailto:agraf-l3A5Bk7waGM@public.gmane.org] >> Sent: Wednesday, February 03, 2010 6:14 PM >> To: Liu Yu-B13201 >> Cc: hollis-yUx37fBWTUITNcAmw9vGhQ@public.gmane.org; kvm-ppc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; >> kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org >> Subject: Re: [PATCH 4/4] kvmppc/booke: exit_nr fixup for >> guest debug single step >> >> Liu Yu-B13201 wrote: >> >>> >>> >>> >>> >>>> -----Original Message----- >>>> From: kvm-ppc-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org >>>> [mailto:kvm-ppc-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org] On Behalf Of Alexander Graf >>>> Sent: Wednesday, February 03, 2010 5:03 PM >>>> To: Liu Yu-B13201 >>>> Cc: hollis-yUx37fBWTUITNcAmw9vGhQ@public.gmane.org; kvm-ppc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; >>>> kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; Liu Yu-B13201 >>>> Subject: Re: [PATCH 4/4] kvmppc/booke: exit_nr fixup for >>>> guest debug single step >>>> >>>> >>>> Am 03.02.2010 um 08:53 schrieb Liu Yu : >>>> >>>> >>>> >>>>> As BOOKE doesn't have hardware support for virtualization, >>>>> hardware never know who's guest and host. >>>>> >>>>> When enable hardware single step in guest, >>>>> we cannot disabled it at the point we switch back to host. >>>>> >>>>> >>>> Why not? We directly arrive in our code. So we can just >>>> disable it, no? >>>> >>>> Or does that break when you'd try to debug the guest >>>> interrupt handlers? >>>> >>>> >>> That's the hardware limitition. >>> Assume received itlb miss interrupt, but it doesn't clear >>> >> MSR_DE in MSR, >> >>> so on the exit path single step still work and then debug >>> >> interrupt is >> >>> triggled. >>> >>> >> MSRDE is set to 0 by critical class interrupts >> unless Category E.ED is supported, by Debug >> interrupts, and by Machine Check interrupts, >> and is left unchanged by all other interrupts. >> >> Great. >> >> So when single stepping is enabled, you jump into the guest, >> get an itlb >> miss, get out, still have DE set, get in KVM's own DE handler and can >> process things from there. >> >> Could you check if the debug instruction was on PR=0? If so, you can >> just rfi and be good, right? >> >> > > Hr? > The moment we found this happen we've already saved the guest and loaded host on exit path > Rfi will make exit path again which means save guest again. > Well the guest saving code is in our hands. So we can just modify the debug interrupt handler in booke_interrupts.S to check for PR=0 first thing and then decide whether to save to guest state or return to the host kernel. I think that'd make it a lot cleaner. Alex