From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paul Mackerras Date: Mon, 20 May 2019 06:17:00 +0000 Subject: Re: [RFC PATCH v2 08/10] KVM: PPC: Ultravisor: Return to UV for hcalls from SVM Message-Id: <20190520061700.GC21382@blackberry> List-Id: References: <20190518142524.28528-1-cclaudio@linux.ibm.com> <20190518142524.28528-9-cclaudio@linux.ibm.com> In-Reply-To: <20190518142524.28528-9-cclaudio@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Claudio Carvalho Cc: Madhavan Srinivasan , Michael Anderson , Ram Pai , kvm-ppc@vger.kernel.org, Bharata B Rao , linuxppc-dev@ozlabs.org, Sukadev Bhattiprolu , Thiago Jung Bauermann , Anshuman Khandual On Sat, May 18, 2019 at 11:25:22AM -0300, Claudio Carvalho wrote: > From: Sukadev Bhattiprolu > > All hcalls from a secure VM go to the ultravisor from where they are > reflected into the HV. When we (HV) complete processing such hcalls, > we should return to the UV rather than to the guest kernel. This paragraph in the patch description, and the comment in book3s_hv_rmhandlers.S, are confusing and possibly misleading in focussing on returns from hcalls, when the change is needed for any sort of entry to the guest from the hypervisor, whether it is a return from an hcall, a return from a hypervisor interrupt, or the first time that a guest vCPU is run. This paragraph needs to explain that to enter a secure guest, we have to go through the ultravisor, therefore we do a ucall when we are entering a secure guest. [snip] > +/* > + * The hcall we just completed was from Ultravisor. Use UV_RETURN > + * ultra call to return to the Ultravisor. Results from the hcall > + * are already in the appropriate registers (r3:12), except for > + * R6,7 which we used as temporary registers above. Restore them, > + * and set R0 to the ucall number (UV_RETURN). > + */ This needs to say something like "We are entering a secure guest, so we have to invoke the ultravisor to do that. If we are returning from a hcall, the results are already ...". > +ret_to_ultra: > + lwz r6, VCPU_CR(r4) > + mtcr r6 > + LOAD_REG_IMMEDIATE(r0, UV_RETURN) > + ld r7, VCPU_GPR(R7)(r4) > + ld r6, VCPU_GPR(R6)(r4) > + ld r4, VCPU_GPR(R4)(r4) > + sc 2 > > /* > * Enter the guest on a P9 or later system where we have exactly > -- > 2.20.1 Paul.