From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simon Martin Subject: Re: Stack switching in a PV guest Date: Mon, 16 Dec 2013 10:50:10 -0300 Message-ID: <121927688.20131216105010@gmail.com> References: <1387200969.10247.36.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1387200969.10247.36.camel@kazak.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: Simon Martin , xen-devel List-Id: xen-devel@lists.xenproject.org Thanks Ian, >> I am currently trying to implement multitasking inside my little PV. >> This is done by a a simple stack switch. >> > Need more details of what you have done to advise properly I think. For the moment I have just intercepted the main hypervisor callback. I have simplified to the bare minimum what I am doing here (removed the nested hypercall handling and storing the register file in a static memory area). As long as I don't touch the stack pointer then it works quite happily. As soon as point it to a different stack then everything falls over. > Perhaps you need to be using HYPERVISOR_iret, or perhaps you need to > make sure that your stack frame actually returns you to the correct > context (which I expect hypervisor context is not). I have checked using gdb and when it gets to the iretq statement in HYPERVISOR_iret the stack is as follows %rsp -> valid instruction pointer %rsp+8 -> same CS as the original stack frame. %rsp+16 -> 0 (initial rFLAGS) Regards.