From mboxrd@z Thu Jan 1 00:00:00 1970 From: Scott Wood Subject: Re: [PATCH 2/5] booke: exit to guest userspace for unimplemented hcalls in kvm Date: Mon, 15 Jul 2013 13:07:58 -0500 Message-ID: <1373911678.8183.309@snotra> References: <1373886679-19581-3-git-send-email-Bharat.Bhushan@freescale.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; delsp=Yes; format=Flowed Content-Transfer-Encoding: 8BIT Cc: , , , , Bharat Bhushan , Bharat Bhushan To: Bharat Bhushan Return-path: In-Reply-To: <1373886679-19581-3-git-send-email-Bharat.Bhushan@freescale.com> (from r65777@freescale.com on Mon Jul 15 06:11:16 2013) Content-Disposition: inline Sender: kvm-ppc-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 07/15/2013 06:11:16 AM, Bharat Bhushan wrote: > Exit to guest user space if kvm does not implement the hcall. > > Signed-off-by: Bharat Bhushan > --- > arch/powerpc/kvm/booke.c | 47 > +++++++++++++++++++++++++++++++++++++------ > arch/powerpc/kvm/powerpc.c | 1 + > include/uapi/linux/kvm.h | 1 + > 3 files changed, 42 insertions(+), 7 deletions(-) > > diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c > index 17722d8..c8b41b4 100644 > --- a/arch/powerpc/kvm/booke.c > +++ b/arch/powerpc/kvm/booke.c > @@ -1005,9 +1005,25 @@ int kvmppc_handle_exit(struct kvm_run *run, > struct kvm_vcpu *vcpu, > break; > > #ifdef CONFIG_KVM_BOOKE_HV > - case BOOKE_INTERRUPT_HV_SYSCALL: > + case BOOKE_INTERRUPT_HV_SYSCALL: { > + int i; > if (!(vcpu->arch.shared->msr & MSR_PR)) { > - kvmppc_set_gpr(vcpu, 3, kvmppc_kvm_pv(vcpu)); > + r = kvmppc_kvm_pv(vcpu); > + if (r != EV_UNIMPLEMENTED) { > + /* except unimplemented return to guest > */ > + kvmppc_set_gpr(vcpu, 3, r); > + kvmppc_account_exit(vcpu, > SYSCALL_EXITS); > + r = RESUME_GUEST; > + break; > + } > + /* Exit to userspace for unimplemented hcalls > in kvm */ > + run->epapr_hcall.nr = kvmppc_get_gpr(vcpu, 11); > + run->epapr_hcall.ret = 0; > + for (i = 0; i < 8; i++) > + run->epapr_hcall.args[i] = > kvmppc_get_gpr(vcpu, 3 + i); You need to clear the upper half of each register if CONFIG_PPC64=y and MSR_CM is not set. > + vcpu->arch.hcall_needed = 1; The existing code for hcall_needed restores 9 return arguments, rather than the 8 that are defined for this interface. Thus, you'll be restoring one word of padding into the guest -- which could be arbitrary userspace data that shouldn't be leaked. r12 is volatile in the ePAPR hcall ABI so simply clobbering it isn't a problem, though. -Scott