Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp649991imu; Fri, 9 Nov 2018 03:58:21 -0800 (PST) X-Google-Smtp-Source: AJdET5fJi0jyCrhIpRbiSk3z1oU4MsqOUyqd41rVfzhIAQ6HP3tFpVCOhb7FGdsnwr88BLQ15dax X-Received: by 2002:a63:561b:: with SMTP id k27mr7217928pgb.271.1541764701494; Fri, 09 Nov 2018 03:58:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541764701; cv=none; d=google.com; s=arc-20160816; b=utbvwuS0mKDv009yU1jGmz5kC1L3pV2BlddHMljSjosouC4+9zkOdHl8mytiSNrnpn AmDN/rlp3Xpl1av+qKgkKYztjYV1RH9luqp57H9tEW5snHlyDZBSRN+6GgoQa6c5xu0+ VT3jL9ojXZkEzCVDlaWRBefSzoSEhR/z8a+ubxkqc4pj5ewJiQPH7obqUuPr6wDmnquj 3y1N2GD6ZNmlR8Yd/y/pKy6AhwiTy1Srm2kUQscTk30zCptnKXzCYw1xH7N/dJpx+U4e 5ST5FtzXNh6UCTj5bT1gKv/4Xh/xW04F7xSiNKLSzNuL8SB028eD4mbcY4FwLcovcG2L cQsw== 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; bh=kvTKQE5+2djTb0Oo3FYDf/nnXAjYtcRNrP0adwu6YKc=; b=EG6yLdeT4MYngWapwPDcrMBsxvdR6tVjZrRaeRQO7G8mAPxNHcAYhM37ghKEgeaawJ iXJe9mMftRQB9KFPpK4Lyb4JBiwRizKpBJcb/enjj7WbKIAYczysyWnan7qvetV0rtUh orTa3/RL+HbWx35ar/fegB+Z4LDg+KdOvqb3Ctd3ytyBFb3s8PbsVgOjS27Nuer/D5mB rwkbwhpiddpsVqwAwU+5NWvwJnKgv/dImZPKCO22RhreopisOVWRlGKXYlmO/q4vVBca mx3g7wGWOEme2GMubK4vOWx7DMq04tNUjquYwd3MvY9QK6EEiKcXvQ/V75Awv9+IqcLw kCIg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z2si6635524pgs.267.2018.11.09.03.58.05; Fri, 09 Nov 2018 03:58:21 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728331AbeKIVhc (ORCPT + 99 others); Fri, 9 Nov 2018 16:37:32 -0500 Received: from foss.arm.com ([217.140.101.70]:58152 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727560AbeKIVhc (ORCPT ); Fri, 9 Nov 2018 16:37:32 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C612A80D; Fri, 9 Nov 2018 03:57:13 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0708E3F718; Fri, 9 Nov 2018 03:57:11 -0800 (PST) Date: Fri, 9 Nov 2018 11:56:44 +0000 From: Mark Rutland To: Peter Maydell Cc: Alex =?utf-8?Q?Benn=C3=A9e?= , kvm-devel , Marc Zyngier , Catalin Marinas , Will Deacon , open list , Christoffer Dall , kvmarm@lists.cs.columbia.edu, arm-mail-list Subject: Re: [RFC PATCH] KVM: arm64: don't single-step for non-emulated faults Message-ID: <20181109115644.f4qjqnv2kogoke42@lakrids.cambridge.arm.com> References: <20181107171031.22573-1-alex.bennee@linaro.org> <20181107180120.urnvkcrkh46ytsdb@lakrids.cambridge.arm.com> <20181107180829.sex54bxhd5wyqvan@lakrids.cambridge.arm.com> <87r2fv68us.fsf@linaro.org> <20181108135122.llmfsel32dbe2q7o@lakrids.cambridge.arm.com> <87pnvf63u2.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 08, 2018 at 02:38:43PM +0000, Peter Maydell wrote: > On 8 November 2018 at 14:28, Alex Bennée wrote: > > > > Mark Rutland writes: > >> One problem is that I couldn't spot when we advance the PC for an MMIO > >> trap. I presume we do that in the kernel, *after* the MMIO trap, but I > >> can't see where that happens. > > > > Nope it gets done before during decode_hsr in mmio.c: > > > > /* > > * The MMIO instruction is emulated and should not be re-executed > > * in the guest. > > */ > > kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu)); > > I think that this attempt to do the PC-advance early is > probably an underlying problem that is not helping the > code structure here. > > An enhancement that's been floated previously is that the > MMIO emulation in userspace should be able to report back > to KVM "nope, that access should generate a guest synchronous > external abort (with ESR_EL1.EA = 0/1)". > If we have that, then we definitely need to not advance the > PC until after userspace has done the emulation and told > us whether the memory access succeeded or not... Yup. I think that we absolutely want to do all the CPU state advancement (PC, SS bit, etc) at the point we apply the effects of the instruction. Not before we emulate the instruction, and not higher/lower in the call stack. We have a big problem in that guest-directed singlestep and host-directed singlestep don't compose, and given that host-directed singlestep doesn't work reliably today I'd be tempted to rip that out until we've fixed guest-directed singlestep. We should have a story for how host-directed debug is handled transparently from the PoV of a guest using guest-directed debug. Thanks, Mark.