Received: by 10.223.164.202 with SMTP id h10csp541450wrb; Thu, 23 Nov 2017 02:20:59 -0800 (PST) X-Google-Smtp-Source: AGs4zMYmDpsueWxH0oQmb/bndFLc4aQb3AtZvjUyHwexfoqv2iukVxrSMtpmzH41y5F0OadNVyw0 X-Received: by 10.84.133.79 with SMTP id 73mr4903164plf.308.1511432459712; Thu, 23 Nov 2017 02:20:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511432459; cv=none; d=google.com; s=arc-20160816; b=QgRZ01PFNcLJlf7wwolvlq0ySfJFtQgtEmiUQgavLYXjeA3iUYjbCIJ539cSx9lhWk PP48rBiejAmbolpOs06ozV/gLeJS27/nT9BeBvBFEJDu7Ru/HzbRTXIDpIsyyUhWyINZ 7f0NefBkMaegVGnrxuDfORWHp2MiT9bSJg9V1BxUlPP4Cl05xdAUG6owOc4pS/BHH1/l /YGwBEgokjZWIcv29E0H5yN1oLtQR3i5H0p7IQkVR4GiGdY28RkCEDK3tXeOZOZSkPTy HbrfBBiD2YfPwvKEH60oeKiwNYTA3ejuEF82JrxKRHe/68wJPQ5YQ7FkNNpRKVRl3OTG qKGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=pEl41wYf/DLRv5BBybVBfBWbpfWS0nNF95b+0+nwurc=; b=mYd1TmX71wUTj4HHx729Tu8O5Lv++CQZ+NOzFcCcwSXVSYMhGXaOVmn+befP7dzolc mNOpCaqcjKAHMJ3S1HaPt9mQ+TBn/jpl7T5kzYoaMWcTb8u7axjKuM6bI3DCok7EvQ/e OnPNcK1M8PSFxEitE/M9S8RaOpr5wkjn8xw5heH4dJjzwmkG6T8QAZi2UvnQDyJbxtfj q98R5q2Tp1/JJT6RtxxE3RPD1gS9F7dutChJFL8LEIwpuDIVl4NfNn9lwVgb1Ty7Bw7b tCezh3cNnrPXSZvhOSeV8tES2a/ouh3vg11LRTaoTs9AO0UP3RyLtb1vmENvrCUFyQus dzMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fm1DetT6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5si15548887pgq.427.2017.11.23.02.20.48; Thu, 23 Nov 2017 02:20:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fm1DetT6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752722AbdKWKUA (ORCPT + 77 others); Thu, 23 Nov 2017 05:20:00 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:42084 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751375AbdKWKT6 (ORCPT ); Thu, 23 Nov 2017 05:19:58 -0500 Received: by mail-wm0-f65.google.com with SMTP id l188so13989808wma.1 for ; Thu, 23 Nov 2017 02:19:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=pEl41wYf/DLRv5BBybVBfBWbpfWS0nNF95b+0+nwurc=; b=Fm1DetT61q7gmcGTGs3RD4tpCxgTwqi7STuPEj26jCR9zCs64BHoeIEHeqbSjGKZ8g xmxDaf6oTGLdwLVmYmsUbkiKGsK4Aw/gPy0k4FXphZC1VBIonfJyW2O4NbVyDXwTz9fi 4hV6PQqHhahdTyGOXGOc9qPXJszrbTJcr2d4o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=pEl41wYf/DLRv5BBybVBfBWbpfWS0nNF95b+0+nwurc=; b=d4hEaLj/OcbLbrNyFPWK4twTJ1eN1wa9hHTN7eZeO5o2hv64jKoFKowGYPUa6rwRL3 hynTiFvgaBugohfTUcCJXqIsEqoM8GDGoKijKqFMwi8Vrph6SSiIvMvrL9B/+FCIoxkJ sgKMCwfHhXeh6ofg49FaufH1SCSR3CgLlrh2brkk9LQ+TcsRmzXIOAH2j+F+8iWaszMZ 8LzM696k8bYTb52RyKdnwpsJTUUkjaxdWokWZAXWgOOU/xB3jAl8mO885Xfo/U+3z+HZ /y5RZigbOAzCPiPs8zZ0yLKEnAKIk+keFqQbHiaS8afBXVPQmrCss73LaajUfeCnFJZ+ E1aA== X-Gm-Message-State: AJaThX5ifJ1o0J0skYTFv7m4Ik1++/qlcNoJyt8Jtgb+EI0iLjYYmUN6 7ymGZVIZDVmetbPVeHhVI2iChw== X-Received: by 10.28.74.213 with SMTP id n82mr7102094wmi.15.1511432397014; Thu, 23 Nov 2017 02:19:57 -0800 (PST) Received: from localhost (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id d63sm21294382wmh.3.2017.11.23.02.19.55 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 23 Nov 2017 02:19:56 -0800 (PST) Date: Thu, 23 Nov 2017 11:20:07 +0100 From: Christoffer Dall To: Alex =?iso-8859-1?Q?Benn=E9e?= Cc: julien.thierry@arm.com, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org, marc.zyngier@arm.com, Catalin Marinas , Will Deacon , David Daney , Eric Auger , James Morse , open list Subject: Re: [RFC PATCH] kvm: arm64: handle single-step of hyp emulated mmio instructions Message-ID: <20171123102007.GX28855@cbox> References: <20171122170747.12192-1-alex.bennee@linaro.org> <20171122204158.GW28855@cbox> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171122204158.GW28855@cbox> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replying to myself here, because I'm an idiot... On Wed, Nov 22, 2017 at 09:41:58PM +0100, Christoffer Dall wrote: [...] > > > case ARM_EXCEPTION_TRAP: > > return handle_trap_exceptions(vcpu, run); > > case ARM_EXCEPTION_HYP_GONE: > > diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c > > index 945e79c641c4..a6712f179b52 100644 > > --- a/arch/arm64/kvm/hyp/switch.c > > +++ b/arch/arm64/kvm/hyp/switch.c > > @@ -22,6 +22,7 @@ > > #include > > #include > > #include > > +#include > > > > static bool __hyp_text __fpsimd_enabled_nvhe(void) > > { > > @@ -263,7 +264,11 @@ static bool __hyp_text __populate_fault_info(struct kvm_vcpu *vcpu) > > return true; > > } > > > > -static void __hyp_text __skip_instr(struct kvm_vcpu *vcpu) > > +/* Skip an instruction which has been emulated. Returns true if > > + * execution can continue or false if we need to exit hyp mode because > > + * single-step was in effect. > > + */ > > +static bool __hyp_text __skip_instr(struct kvm_vcpu *vcpu) > > { > > *vcpu_pc(vcpu) = read_sysreg_el2(elr); > > > > @@ -276,6 +281,14 @@ static void __hyp_text __skip_instr(struct kvm_vcpu *vcpu) > > } > > > > write_sysreg_el2(*vcpu_pc(vcpu), elr); > > + > > + if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) { > > + vcpu->arch.fault.esr_el2 = > > + (ESR_ELx_EC_SOFTSTP_LOW << ESR_ELx_EC_SHIFT) | 0x22; > > + return false; > > + } else { > > + return true; > > + } > > } > > > > int __hyp_text __kvm_vcpu_run(struct kvm_vcpu *vcpu) > > @@ -336,13 +349,21 @@ int __hyp_text __kvm_vcpu_run(struct kvm_vcpu *vcpu) > > int ret = __vgic_v2_perform_cpuif_access(vcpu); > > > > if (ret == 1) { > > - __skip_instr(vcpu); > > - goto again; > > + if (__skip_instr(vcpu)) > > + goto again; > > + else > > + exit_code = ARM_EXCEPTION_TRAP; > > } > > > > if (ret == -1) { > > - /* Promote an illegal access to an SError */ > > - __skip_instr(vcpu); > > + /* Promote an illegal access to an > > + * SError. If we would be returning > > + * due to single-step clear the SS > > + * bit so handle_exit knows what to > > + * do after dealing with the error. > > + */ > > + if (!__skip_instr(vcpu)) > > + *vcpu_cpsr(vcpu) &= ~DBG_SPSR_SS; > > Could this be overriding guest state if the guest is debugging itself > and we don't have (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) ? > ... this is nonsense, __kvm_skip_intr will check for KVM_GUESTDBG_SINGLESTEP, so there's no issue here. Sorry about the noise. -Christoffer From 1584800335801952519@xxx Wed Nov 22 20:42:56 +0000 2017 X-GM-THRID: 1584786859261112723 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread