Received: by 10.223.164.202 with SMTP id h10csp679153wrb; Thu, 23 Nov 2017 04:39:38 -0800 (PST) X-Google-Smtp-Source: AGs4zMYc1OPcigENnFk7HNwToKoBaK8HKCfXUZ2C78/JTO4j+y6nAo/WNjUvAlwctMySapKU5wfQ X-Received: by 10.84.254.68 with SMTP id a4mr24459130pln.353.1511440778096; Thu, 23 Nov 2017 04:39:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511440778; cv=none; d=google.com; s=arc-20160816; b=Eno6sfbLnaCbLcL9eOLkgofWIxBUWTdYiWATUcfoA7LwLV5MI4vhVhxtMGwP2zDF4F p3nsDk1kjL6b9SYUBRKKvRACxzAkmUflLSPwmXoiGX5brsBSojk55Wcm+SF+LSfQ2HTO lrQFtle3PY4YA5Adhyvjh+a6tVlRz8s3bAiEQQwlYVwTX2yM7RvJqHZYrTrntf8wIvZE U1oVp6Wu7qB2BJCc9kEk9W262Q2ZAHap03cVAjSxCcZj80FO3nWnUwnxtxM8OUHgHRWu n3EsMy2zTkufoUYKkxtaH7GgR06u91BWlC2PtBeUHTc2FP3rJhFQRY8PjgQJjgn6hi+x F0Yw== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=Hk7NeNoVqrcWTy5KedqcH6XoxEoS4XLSuyEebGzv4zQ=; b=f0dIRBVwxAaWuTAuAgU76JUd/wt43/yvUZ+GzwyUs1qXfVlQQcC8r+qZWGI+ryWMlg v9zWGt6ACUZ0VZe8ro+XdDecjt9NA4eP0wC7sYnKcdGpbbZ0GhMoNZIDfdKYg+tEaImP 2wQ0uUm4Z22tqq2/ojNL+ezjY98vb7phf7BwOWFURR48J3A/CyaF28dfD0pxPJ3hx3hm fToIBfF4N9LNn+Y3YWYdjq3RJ+iyk+uBMRAYu0tuSd1+qVd+khil3nZyQ3kw1gXhNX7Q yD8SSIKpERaTIsabWEiRmbvawcDX55dwgdflJxbIC8HiRWeBEhos3wul3g39oir3r8yd C5Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iTLkQHJB; 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 f5si15705101pgt.456.2017.11.23.04.39.26; Thu, 23 Nov 2017 04:39:38 -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=iTLkQHJB; 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 S1752696AbdKWMiy (ORCPT + 75 others); Thu, 23 Nov 2017 07:38:54 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:39630 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751968AbdKWMiw (ORCPT ); Thu, 23 Nov 2017 07:38:52 -0500 Received: by mail-wm0-f67.google.com with SMTP id x63so16222661wmf.4 for ; Thu, 23 Nov 2017 04:38:52 -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:content-transfer-encoding:in-reply-to :user-agent; bh=Hk7NeNoVqrcWTy5KedqcH6XoxEoS4XLSuyEebGzv4zQ=; b=iTLkQHJBzU1cNFWodad/OIRyonpp+8kfZnZJFZRgo7vkTKp3Z7vMY2+58VtgTtkG97 sMdzMXpYqwZtDzbMzPMCfPeucGCWorSKvkDM4BN/yu563hyGATLWO+NXuu8Ar/T+tVjt Ongc/g56cop1i352ng3waO43XtIL6bsjCVBws= 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:content-transfer-encoding :in-reply-to:user-agent; bh=Hk7NeNoVqrcWTy5KedqcH6XoxEoS4XLSuyEebGzv4zQ=; b=PttSnzsZm6OFYZDy5G7w6e+s4k5URCHeCJdDLaGu4mqo38mMwac/bBGdVKAEs4VcVx B8290YeqUQY7l5LzIxiNFIqcs34KZQpBuZCvgOciGUpp6HqjbwU0FvwLGZCTuN2Xro9y RIs99UnHKDexg9K3l0fwiiCkUI7nCXVK4QFjIl4IdWm6rFQDaQAiwQ34Sex88+5nVpjy T4u5CKbKxDVKoTW4ds/MWvAcdlWl9jU8SSnhsN4W2X/NsfoNoj0DMs2XhbjMY5hk/90f 8/ZOWdffmtWtckIa0dFieLebrnyWDy5tXuKFC7lc/7ThmjxnXxf+dj62ZUgxD+ADFE9j KTKw== X-Gm-Message-State: AJaThX6VQ8MgqVS5Kzj4c0rsmE4Up61yxk5WOukpKnl29GC0NZFI3WQW Jt781E/hnU8hLFwQ7XVtSHvcSA== X-Received: by 10.28.190.12 with SMTP id o12mr6758840wmf.148.1511440731371; Thu, 23 Nov 2017 04:38:51 -0800 (PST) Received: from localhost (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id x127sm3334671wmb.10.2017.11.23.04.38.49 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 23 Nov 2017 04:38:49 -0800 (PST) Date: Thu, 23 Nov 2017 13:39:01 +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 , Dave Martin , James Morse , open list Subject: Re: [PATCH v1 2/2] kvm: arm64: handle single-step of hyp emulated mmio instructions Message-ID: <20171123123901.GZ28855@cbox> References: <20171123121134.11050-1-alex.bennee@linaro.org> <20171123121134.11050-3-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20171123121134.11050-3-alex.bennee@linaro.org> 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 On Thu, Nov 23, 2017 at 12:11:34PM +0000, Alex Benn�e wrote: > There is a fast-path of MMIO emulation inside hyp mode. The handling > of single-step is broadly the same as kvm_arm_handle_step_debug() > except we just setup ESR/HSR so handle_exit() does the correct thing > as we exit. > > For the case of an emulated illegal access causing an SError we will > exit via the ARM_EXCEPTION_EL1_SERROR path in handle_exit(). We behave > as we would during a real SError and clear the DBG_SPSR_SS bit for the > emulated instruction. > > Signed-off-by: Alex Benn�e > --- > arch/arm64/kvm/hyp/switch.c | 37 ++++++++++++++++++++++++++++++------- > 1 file changed, 30 insertions(+), 7 deletions(-) > > diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c > index 525c01f48867..f7c651f3a8c0 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) > { > @@ -269,7 +270,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); > > @@ -282,6 +287,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) > @@ -342,13 +355,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; > exit_code = ARM_EXCEPTION_EL1_SERROR; > } > > @@ -363,8 +384,10 @@ int __hyp_text __kvm_vcpu_run(struct kvm_vcpu *vcpu) > int ret = __vgic_v3_perform_cpuif_access(vcpu); > > if (ret == 1) { > - __skip_instr(vcpu); > - goto again; > + if (__skip_instr(vcpu)) > + goto again; > + else > + exit_code = ARM_EXCEPTION_TRAP; > } > > /* 0 falls through to be handled out of EL2 */ > -- > 2.15.0 > Reviewed-by: Christoffer Dall From 1584858833746559310@xxx Thu Nov 23 12:12:44 +0000 2017 X-GM-THRID: 1584858833746559310 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread