From patchwork Thu Nov 16 15:39:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 119053 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5734438qgn; Thu, 16 Nov 2017 07:39:35 -0800 (PST) X-Google-Smtp-Source: AGs4zMZdeVrney6ZwhjZsuLfnVF/LjydYPDyIIlpHA/+PYZ0kL37LGWMY9cYJXEYc7Fj+lDIkzIk X-Received: by 10.98.186.13 with SMTP id k13mr2267467pff.166.1510846775705; Thu, 16 Nov 2017 07:39:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510846775; cv=none; d=google.com; s=arc-20160816; b=dVBysjVMhjzYqUuUudmhJK2U8OHdysYCZZc5CtbSOZYdanpXPW12D7GbWl++A4uv0C Y3rdmDtaK22cPkbP3apGeP3vsOj9t5k2KTCDMTxntjg8AAncNmRKpPbDFF8BmlEwsN3B ZiiRspWYlw8lVCO9MhXi2KTv2jRxTtWyd2mqCwuuBq9pOAvYUmPeyvs49pVZSzqLbyXc mAhszZct15xOB2utcqqJmH5RLhxECwAr6IzS+gAsy34yGym2jIizRwPcDVHReVJjUpe6 V3AaaalYUZl3iuJnHCQnnBfgD5s6mMOo/RIXv2kTcRTV4lifVetXCM7hZE4lEFNMmmFq ay0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=5fi3uEl+4MxzbaZ2+bcLcHw5MtrOENCEb4BKCKASycs=; b=WKlk10C8epcuBv8ZqW+XiPTvBvEkicl70Eg2WnMgcjOBqEb9Sz3G/vE8iN/E5ffRgR PM3PmgRuNv+tqwV8MypYQ0PSmsFUnIu/PqOT0QnbYyye0u2Sdm2SeCyV1LdiHTjZKyFF 5wPLirhDgImBSUdvSGeLzbn2Z1ScrJexGi6dydz8U4DUeIrxiGeOpfGZOQwGEiNZFLlm mj8qf2q2YWQHfMxKwpb6a0Lo5CObG2fooH16aQdKrnrvn+9e3thxMg29YEAeaSR7S1VO I2HbPdUDhbo13M4a6fx1A0fPyX4t0e6BsTLUJq+BKzKeZ5uqnr4BzPjatDDAFIDadSjH 1BVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S5y/KGhw; 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 x5si1156918pfx.313.2017.11.16.07.39.35; Thu, 16 Nov 2017 07:39:35 -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=S5y/KGhw; 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 S965229AbdKPPjc (ORCPT + 28 others); Thu, 16 Nov 2017 10:39:32 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:39202 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935613AbdKPPjZ (ORCPT ); Thu, 16 Nov 2017 10:39:25 -0500 Received: by mail-wm0-f65.google.com with SMTP id l8so1038885wmg.4 for ; Thu, 16 Nov 2017 07:39:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5fi3uEl+4MxzbaZ2+bcLcHw5MtrOENCEb4BKCKASycs=; b=S5y/KGhwsn5kK6KOLeGGZaBRfOas4zfGst1G9ploRJA49OSjwRMiO4LObiVNJYHcxC 667CmW840UyWArvA2+adMUELNh+f1gOHhcplGH7pJ9NoFulrl6jCUBFEt/RAu4Ea3XWH 87sRJAEDYbIjF7CPtoH2Bni+YS4ZZj0oPi+FQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5fi3uEl+4MxzbaZ2+bcLcHw5MtrOENCEb4BKCKASycs=; b=L1m5824KukIV7vqdfsUypxyRvV3tIi6mhTObcDVYa7z6e8EJh6XrYq5h78+WbRbNrP Y/vlaT3ADsBDG0AKOnmNFgcCTty5oKCpVfxm2HiXT5mN34qGieP9VpthYD8oYP4eWM0Q 20itXvN0re9MW8O5hQ4oHurpqgu4oAlLdZRmH+HuixFlHPGswYFD0Wv0AVVmoak46O60 RWW0MUjmVKfonqgAMn2WmvEIzBQ1GZIYrJM0mJ4nzybjTBJIQITbVHKiVpeD4fwKZKR5 uh+nSYvIyIhY1wjI+DTzmdEY0T7t+keRDoVD4WFAM/UVtOo6uDF72oejQgE/C7iuElW0 /quQ== X-Gm-Message-State: AJaThX4hGlRFe5ZMAUicqNxCa3hVVBek9vkokgYvjPHbIPheBC9wZYJE jp0AFVBSaSCbQsb14NIxMpH+8w== X-Received: by 10.28.225.87 with SMTP id y84mr1943247wmg.68.1510846764358; Thu, 16 Nov 2017 07:39:24 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id p28sm3677373wmf.2.2017.11.16.07.39.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Nov 2017 07:39:23 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 0B5C63E03EC; Thu, 16 Nov 2017 15:39:22 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: 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 Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Russell King , Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 1/3] kvm: arm debug: introduce helper for single-step Date: Thu, 16 Nov 2017 15:39:19 +0000 Message-Id: <20171116153921.21991-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171116153921.21991-1-alex.bennee@linaro.org> References: <20171116153921.21991-1-alex.bennee@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After emulating instructions we may want return to user-space to handle a single-step. If single-step is enabled the helper set the run structure for return and returns true. Signed-off-by: Alex Bennée Reviewed-by: Julien Thierry --- v2 - kvm_arm_maybe_return_debug -> kvm_arm_handle_step_debug - return bool, true if return to userspace is required --- arch/arm/include/asm/kvm_host.h | 5 +++++ arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/debug.c | 22 ++++++++++++++++++++++ 3 files changed, 28 insertions(+) -- 2.15.0 diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h index 4a879f6ff13b..26a1ea6c6542 100644 --- a/arch/arm/include/asm/kvm_host.h +++ b/arch/arm/include/asm/kvm_host.h @@ -285,6 +285,11 @@ static inline void kvm_arm_init_debug(void) {} static inline void kvm_arm_setup_debug(struct kvm_vcpu *vcpu) {} static inline void kvm_arm_clear_debug(struct kvm_vcpu *vcpu) {} static inline void kvm_arm_reset_debug_ptr(struct kvm_vcpu *vcpu) {} +static inline bool kvm_arm_handle_step_debug(struct kvm_vcpu *vcpu, + struct kvm_run *run) +{ + return false; +} int kvm_arm_vcpu_arch_set_attr(struct kvm_vcpu *vcpu, struct kvm_device_attr *attr); diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index e923b58606e2..bbfd6a2adb2b 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -369,6 +369,7 @@ void kvm_arm_init_debug(void); void kvm_arm_setup_debug(struct kvm_vcpu *vcpu); void kvm_arm_clear_debug(struct kvm_vcpu *vcpu); void kvm_arm_reset_debug_ptr(struct kvm_vcpu *vcpu); +bool kvm_arm_handle_step_debug(struct kvm_vcpu *vcpu, struct kvm_run *run); int kvm_arm_vcpu_arch_set_attr(struct kvm_vcpu *vcpu, struct kvm_device_attr *attr); int kvm_arm_vcpu_arch_get_attr(struct kvm_vcpu *vcpu, diff --git a/arch/arm64/kvm/debug.c b/arch/arm64/kvm/debug.c index dbadfaf850a7..95afd22a4634 100644 --- a/arch/arm64/kvm/debug.c +++ b/arch/arm64/kvm/debug.c @@ -221,3 +221,25 @@ void kvm_arm_clear_debug(struct kvm_vcpu *vcpu) } } } + + +/* + * When KVM has successfully emulated the instruction we might want to + * return to user space with a KVM_EXIT_DEBUG. We can only do this + * once the emulation is complete though so for userspace emulations + * we have to wait until we have re-entered KVM before calling this + * helper. + * + * Return true (and set exit_reason) to return to userspace or false + * if no further action required. + */ + +bool kvm_arm_handle_step_debug(struct kvm_vcpu *vcpu, struct kvm_run *run) +{ + if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) { + run->exit_reason = KVM_EXIT_DEBUG; + run->debug.arch.hsr = ESR_ELx_EC_SOFTSTP_LOW << ESR_ELx_EC_SHIFT; + return true; + } + return false; +} From patchwork Thu Nov 16 15:39:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 119055 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5734854qgn; Thu, 16 Nov 2017 07:40:01 -0800 (PST) X-Google-Smtp-Source: AGs4zMYB1BgZulepzLThMu0yyK3ivHWJbudC17xbjgIrRS5nvL0Phv9uZ1O00/+q2lRZLA3AKXQ5 X-Received: by 10.98.186.13 with SMTP id k13mr2268618pff.166.1510846801566; Thu, 16 Nov 2017 07:40:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510846801; cv=none; d=google.com; s=arc-20160816; b=ujChIsXVm+fSpYXc1EXrEmVuTMu+czKIF1yMqmUGCh4KhxEfBZUbxE3UGg8sIHFniJ qIh1AyyfWP/ZXnUnyWa78CZUh/7IjFcM+OxJBIZA63JrZNt/9cK/KY013aTAZBToGc7u EOMUQWMDGsTL0znt7VSzlXphkMK/WHd+kNjU2kIGx5sxWXAC0E7ZXL5YDni5aXQUZCt+ QOysDctTQ0ws36IqMpaj6wpLjnS87DcXIajB0kjLhgqtKk+iINWaYs9KMY8pT9LXDk6P Ljz2IU6udQjds3HqTMuDK60W5NynKobfOuiDuOY+SrmIEZdbaOl9UA+7tzr6dkJLgQEy K8Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=slpupatpw0H5CEBDfNoAa38imSLd9H2hQ5fwhN9ClgM=; b=cC5FeFyspu900W3utBXsVQbUUa2sfbk7IZwOq/XHYaj8aLbQUl0IMZ3KmF4ZD+V/fa flmXaIRPJBy9kcpk+onClhYfbbAW2oZctcTcijI8HPy6JZ89Z1dSwq/plGdni2Eb/JEt MC5PYijOAOAssctGmVmuxzmUJxbmKJFYtUyfWxEm5HqrwBQCJN5dsWlrMnwPI/z644P1 UnLKJlrTFXV77M98mrhgCnR6i5PjTIam0QA44/0qFLTYblaGY8sSN5Iu6EdkxEkCTSdc 3zWADYlCTnCFsddlXnQxSQ1yXpA1RTEn020dsFMLX6qbHxhfdRQNb7Y0YHeC840gtCQy qqJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EGjta8sv; 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 x5si1156918pfx.313.2017.11.16.07.40.01; Thu, 16 Nov 2017 07:40:01 -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=EGjta8sv; 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 S935697AbdKPPj6 (ORCPT + 28 others); Thu, 16 Nov 2017 10:39:58 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:38050 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933881AbdKPPj2 (ORCPT ); Thu, 16 Nov 2017 10:39:28 -0500 Received: by mail-wm0-f67.google.com with SMTP id z3so1062749wme.3 for ; Thu, 16 Nov 2017 07:39:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=slpupatpw0H5CEBDfNoAa38imSLd9H2hQ5fwhN9ClgM=; b=EGjta8svYFrnc10lGrCuaJMwxX1lw3PhDah2isnz7TWa4fyx7k+PVozKa8Ftg91cHF CYpC/yVDSCTBB5LhkMcc3RVlUQkqykKVL2hlzbfi4mTqgI5xIPONFQlvY9XqY7LtNksq qggqY6CG36c+qLLKbkIoyovSdOhHOUfSg7baY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=slpupatpw0H5CEBDfNoAa38imSLd9H2hQ5fwhN9ClgM=; b=VcH6UvfUOUv7g68Ip09tDLpzIdFv9jFqjLIsms7xVVyn4l6GQkMwuDL8JTM+y6VWbo TXu2e59E8DPAvXA02qD6Pe+dZTnVai3gcfFTid9HuTCmgI/OjQOQglwqa+M+0BJl2Svt CMGalMr9VA2XqEIrjoPcXZZv8+JD2Iiqzxce5FgQPuy0HZexQo/CoEbZ5bvR2QJi+Phy 7X7RC7udizz7NtcAqSLm8fzSfnR472xzoiFMYJ7IBFzLHJqdKkXIbOTsSObyMRUQAxNe Ci7IRgKmj9pVdccRUDrVBI9c3M/pdv2SWmMlnUDM7xFrGvCNHYR26OzHzm18UOQWt3H3 4p4A== X-Gm-Message-State: AJaThX7RncvrRK5mYAZJt9o3QaDifBC3zwMTxi4ODxQ1N8NPcH9+Uq4K lE6F9tEZcMiK1yfgh4CCISwa8A== X-Received: by 10.28.70.131 with SMTP id t125mr1778583wma.92.1510846766528; Thu, 16 Nov 2017 07:39:26 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id l16sm4355131wma.19.2017.11.16.07.39.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Nov 2017 07:39:23 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 2F3A93E0412; Thu, 16 Nov 2017 15:39:22 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: 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 Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 2/3] kvm: arm64: handle single-stepping trapped instructions Date: Thu, 16 Nov 2017 15:39:20 +0000 Message-Id: <20171116153921.21991-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171116153921.21991-1-alex.bennee@linaro.org> References: <20171116153921.21991-1-alex.bennee@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If we are using guest debug to single-step the guest we need to ensure we exit after emulating the instruction. This only affects instructions completely emulated by the kernel. For userspace emulated instructions we need to exit and return to complete the emulation. The kvm_arm_handle_step_debug() helper sets up the necessary exit state if needed. Signed-off-by: Alex Bennée Reviewed-by: Julien Thierry --- v2 - use helper from patch 1 - if (handled > 0) instead of if (handled) so errors propagate --- arch/arm64/kvm/handle_exit.c | 47 +++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 14 deletions(-) -- 2.15.0 diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c index 7debb74843a0..af1c804742f6 100644 --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -178,6 +178,38 @@ static exit_handle_fn kvm_get_exit_handler(struct kvm_vcpu *vcpu) return arm_exit_handlers[hsr_ec]; } +/* + * We may be single-stepping an emulated instruction. If the emulation + * has been completed in-kernel we can return to userspace with a + * KVM_EXIT_DEBUG, otherwise the userspace needs to complete its + * emulation first. + */ + +static int handle_trap_exceptions(struct kvm_vcpu *vcpu, struct kvm_run *run) +{ + int handled; + + /* + * See ARM ARM B1.14.1: "Hyp traps on instructions + * that fail their condition code check" + */ + if (!kvm_condition_valid(vcpu)) { + kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu)); + handled = 1; + } else { + exit_handle_fn exit_handler; + + exit_handler = kvm_get_exit_handler(vcpu); + handled = exit_handler(vcpu, run); + } + + /* helper sets exit_reason if we need to return to userspace */ + if (handled > 0 && kvm_arm_handle_step_debug(vcpu, run)) + handled = 0; + + return handled; +} + /* * Return > 0 to return to guest, < 0 on error, 0 (and set exit_reason) on * proper exit to userspace. @@ -185,8 +217,6 @@ static exit_handle_fn kvm_get_exit_handler(struct kvm_vcpu *vcpu) int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run, int exception_index) { - exit_handle_fn exit_handler; - if (ARM_SERROR_PENDING(exception_index)) { u8 hsr_ec = ESR_ELx_EC(kvm_vcpu_get_hsr(vcpu)); @@ -214,18 +244,7 @@ int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run, kvm_inject_vabt(vcpu); return 1; case ARM_EXCEPTION_TRAP: - /* - * See ARM ARM B1.14.1: "Hyp traps on instructions - * that fail their condition code check" - */ - if (!kvm_condition_valid(vcpu)) { - kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu)); - return 1; - } - - exit_handler = kvm_get_exit_handler(vcpu); - - return exit_handler(vcpu, run); + return handle_trap_exceptions(vcpu, run); case ARM_EXCEPTION_HYP_GONE: /* * EL2 has been reset to the hyp-stub. This happens when a guest From patchwork Thu Nov 16 15:39:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 119054 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5734688qgn; Thu, 16 Nov 2017 07:39:49 -0800 (PST) X-Google-Smtp-Source: AGs4zMbmbH4bgY2AB4pIq5+pnaENtGThuhnSWUY0CANumloTU22oHHLhE1JtY7ndbCK67yi0occ7 X-Received: by 10.84.238.140 with SMTP id v12mr2074940plk.356.1510846789287; Thu, 16 Nov 2017 07:39:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510846789; cv=none; d=google.com; s=arc-20160816; b=Vcb/YgB8VHWtg39piAUvaRRrjwPiWlPEyYYWwM7WsRoO1oeyGBiWVHXkQibX9/ysdR QaC6zsg7leeJJaHBgmzEaffV5DYSa6xeJpC2BpB840tSnqB7wDpeGRHR/CRt9xAdj4m7 08gp5saYzVEy4kah5R5SDicFn9yg48oh+CmUfrFlG7eKB61+vkfZl9iz3aQKli3LMx4B m9kJIJ+VkdcYocoRMU6+OGJ9hbdR3g6+E4lX5XdQXpbVfw7naI2P0Pajz4pbnvPxLqJH XRRUR9SFH06yFBB9Wn2hH9c6STL17YBxJBBt8zblEBnx/7dDZ+yZ/sm2lIXtMTArnizc fzGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=vQQJ10t1lIqeeOaF2rAFpUln0qYoIa5cY0eg26tvcGk=; b=goPhBYXUn9vyJHgVjkBJmSNXo2w7t1vtA+C5/UcZzgbhNU/TYqc1o5HfQ1OZpLroVL +vd64bJg6iTpp6E42QI6xI2F7dR3wq86pKuEZ1FrvIN7+GBDuDs96C9ykoUVsmagLEMY wYCzUdem3Y20Zt4SfKujykblpfkd4Z2fyg1OXhGpY4jNzPHRyT7I4JyvybMnl5M1HcXv yguQYo1+mlU1lG5dUXsUdvdXmr+FWj+OAmjkgq7Ia19geC8zpMVif56ia1U/MZzl5pAh yGNgaeQC+4VwsiMmtuLuacelD0Bm7SMI07W4G/cZrgcYC4G99tZ1yJDMU+Pem77Fbngd 10rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gtmUTmny; 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 x5si1156918pfx.313.2017.11.16.07.39.49; Thu, 16 Nov 2017 07:39:49 -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=gtmUTmny; 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 S965272AbdKPPjr (ORCPT + 28 others); Thu, 16 Nov 2017 10:39:47 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:57161 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935676AbdKPPj0 (ORCPT ); Thu, 16 Nov 2017 10:39:26 -0500 Received: by mail-wr0-f196.google.com with SMTP id u98so1468597wrb.13 for ; Thu, 16 Nov 2017 07:39:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vQQJ10t1lIqeeOaF2rAFpUln0qYoIa5cY0eg26tvcGk=; b=gtmUTmnyvfWM9aX+TFiIMfV6rtof0RF7YXgUvrRm/MBcCn6FiNr3RQyHKFTQkq+5Y5 e4MuKPvHvQiOdCpgOirvVSq7Zs4y2cLMjou2kMf//+DxxM5cdRUVRzNKqGFNFPMYgL9L 4weIDLJ2eDUKDXkD2gHkCVOUjRlOJE6ero6Lc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vQQJ10t1lIqeeOaF2rAFpUln0qYoIa5cY0eg26tvcGk=; b=ZWH82MAJR1Y2cTaiZgO75SgVINeVxHXH+n7dayeE8sI3W9fGhI8M12Tm9K2mJo/cYL sMDv8UJJuneingY+2+yVk7WEQSuuZMtyVHHmhnt6cw7hSBuix5vBbbiCnziPiOxYyTWA 7ro4N+/VwObD0F+hrASkyVCqmyuTfBVCsXCkQ2kls3btACh0CgMgknCWKS2tCGnFw5pT 16ihn3NuOnGNOY+ucIpxZih1YSsJSI/KTvIRJS/AlVY4btE43m5UeuxJcgccZiBHkrjL z4ls/A7f3XNzvF20WjSWlidbiowde+mawvf0joZQ1hCSZ1idoz5qDQxMMbBHa/fTNhwq CYwA== X-Gm-Message-State: AJaThX7G4OetoBveaJRImvPw0cgX9a/HMbAIIAkIdOj5AZxJ2T3hmoYA Oudc0vU5dMDHobJyjVFIDVPoU1Rz8RQ= X-Received: by 10.223.139.3 with SMTP id n3mr1963510wra.166.1510846765555; Thu, 16 Nov 2017 07:39:25 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id m64sm1272694wmb.10.2017.11.16.07.39.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Nov 2017 07:39:23 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 4EE983E0426; Thu, 16 Nov 2017 15:39:22 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: 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 Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 3/3] kvm: arm64: handle single-step of userspace mmio instructions Date: Thu, 16 Nov 2017 15:39:21 +0000 Message-Id: <20171116153921.21991-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171116153921.21991-1-alex.bennee@linaro.org> References: <20171116153921.21991-1-alex.bennee@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The system state of KVM when using userspace emulation is not complete until we return into KVM_RUN. To handle mmio related updates we wait until they have been committed and then schedule our KVM_EXIT_DEBUG. The kvm_arm_handle_step_debug() helper tells us if we need to return and sets up the exit_reason for us. Signed-off-by: Alex Bennée --- v2 - call helper directly from kvm_arch_vcpu_ioctl_run v3 - return 0 (ioctl success) instead of 1 --- virt/kvm/arm/arm.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.15.0 Reviewed-by: Julien Thierry diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index 95cba0799828..b40440defca1 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c @@ -625,6 +625,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) ret = kvm_handle_mmio_return(vcpu, vcpu->run); if (ret) return ret; + if (kvm_arm_handle_step_debug(vcpu, vcpu->run)) + return 0; + } if (run->immediate_exit)