From: Mukesh Rathor Subject: Re: Stack switching in a PV guest Date: Fri, 20 Dec 2013 16:51:54 -0800 Message-ID: <20131220165154.37a87adf@mantra.us.oracle.com> References: <1351251014.20131216115608@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Simon Martin Cc: Ian Campbell , Jan Beulich , xen-devel List-Id: xen-devel@lists.xenproject.org On Fri, 20 Dec 2013 14:12:55 +0000 "Simon Martin" wrote: > Hi Jan > > > >> Furthermore, the guest's kernel stack wants to be switched via > >> __HYPERVISOR_stack_switch, or else the next interrupt/exception > >> would end up still using the old stack. > I think I've finally got my head round using HYPERVISOR_stack_switch. > It seems to replace all my stack magic, and at least it's not > crashing now. > > However, I now have a different problem. I am running my context > switch off of a single shot timer. When the timer fires Xen transfers > control to my PV guest via the hypercall_callback. > > The hypercall_callback handler stores the current CPU register file, > however the stored rsp always points to the hypercall stack, not the > stack that was active in my PV at the moment the timer event fired. > > I need to store the PV stack pointer so I can recover it later when > my scheduler activates it. I have looked back up the stack and I > don't really see where my active stack pointer is. Any idea where I > can get it? > > Regards. May I recommend taking a look at PVH, it would simplify things a lot for you. Take a look at what linux PVH does, you could start with linux PVH patches: "[PATCH v11] PVH support for Linux kernel." email by konrad on xen-devel. If you have any questions, I can help, next year tho. Mukesh