From patchwork Thu Nov 9 17:00: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: 118469 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1154228edl; Thu, 9 Nov 2017 09:01:17 -0800 (PST) X-Google-Smtp-Source: ABhQp+Q3mqDXdnN028at13jLEab7bL8yzyfZQWwN7pDgxud1KNLDDmqXII2kFoOvIeb1io4Cncpm X-Received: by 10.99.138.194 with SMTP id y185mr1063774pgd.290.1510246877361; Thu, 09 Nov 2017 09:01:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510246877; cv=none; d=google.com; s=arc-20160816; b=TaB5eWQjox+6ZykHqW9HsW2XLOV75IvVjUszn/c5nGtoLSuJQKdv6yPRPZOOQIGLKI 2vSfK9sK/84UHZOMEarNqAeS2HYbtQ7CXKM/gmaBCeTA+T9fFvDFr99MtqWvi7BrD+yL +sYxu799+D1Rb9q19jHKVmai3kyJDFsZ8KWS7RwwK1T+WWCT6puozU8+lqkNU5R0keri bpMbpYLMs0UH/BORm1ApNHAXSAUod7hJRaEZeBwr+way8F2jAfpFCHhfG1P5PGy7Qo2O 3TJTlDA5DLKUGQWexIWfsbcTu9DAo2foGWCr3jnqle4lkykXoGHeFGLbMiM5vn0nlGPP lezA== 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=XIx5BIGLo7HnFAZHupTGZAVVsZz1nNYmnmudk/N+eFA=; b=mQqTLSf36SU59jVLGBDNWBSByGlLjH8u25AmAJxgMGUp65pbAT6OWs4nURvlEz50wK 4JDt6qBSNnxyDjRQ19+5tI6SuwrSO8BHsNO2ULYNDUgkicPeL0iC2cYrq8U0pYnWI5OY lATep3H1nm6jTmk9jwoRZK8t8L1cF4VZBskSjKVndrxjVkFLKqrVdckfwTnNrfVDOOX7 fU1HGz+jzerfWNyxfAbEnqzS+czlEl3Prw/3nPOBicaNfS9HDhFM1dcrkRYov16hWtym M7CCuQXBChgyuUpOM+hCTOZVyArF2ig5IJD7ruz435Qil+LR6Xn3Xk0sFRv1YQzavpkM 6LDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dA4VEx/I; 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 68si7210774pfq.46.2017.11.09.09.01.17; Thu, 09 Nov 2017 09:01:17 -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=dA4VEx/I; 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 S1752655AbdKIRBP (ORCPT + 23 others); Thu, 9 Nov 2017 12:01:15 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:45298 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753538AbdKIRAZ (ORCPT ); Thu, 9 Nov 2017 12:00:25 -0500 Received: by mail-wm0-f66.google.com with SMTP id y80so18505300wmd.0 for ; Thu, 09 Nov 2017 09:00: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=XIx5BIGLo7HnFAZHupTGZAVVsZz1nNYmnmudk/N+eFA=; b=dA4VEx/Ig/1mcZXysTAE0mMDeVcDb8B4x3uwlRTu1gJx8pyZHkidpNzJo6jEj/6Q1F 0eH9mD2Qdn+A3Y5HCNHJKkwIa4vYa2ODTcaZtvTrgX3/YgW+B/fLUzi5ptQgZkHYtIDP lcSPVyajiqlG+qM6TyKzF25xIWf0h9bmKvMwI= 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=XIx5BIGLo7HnFAZHupTGZAVVsZz1nNYmnmudk/N+eFA=; b=OqtB+sgQZug67VDM/LevmpORYBMjhUZbY+tEp7aEvbrQCC4/w1vIBJ+lYlHByJ7BG+ OKeBryqV4aIW0wRCFsGJEf78uucV6ZZxQ5qxH3jatjY5ykDpV3w5a+9Miv/GkrfyOeGV YpllYpJ22FdmkPiF/VxCj+J6Td6g94GI14AunwG94MlSRMbbqWMhNvJWbBQo1vFrtJpi EHJx1gfNjzjlgkS1KmzyE56IdeYCrWIngPo4J1I1kmrIN99DYkxxgRrIkdEx7LsHK9Cs qtLQuL4JYP5X8Sj58J3yOS/4IiM6dX/CTwCfDrNVj7nm5KKxqA3pXVk/6PBZApI2B6ZU dYqw== X-Gm-Message-State: AJaThX6DF67RrxhXQ6gKDRTtD5FHKyBHdIilib9YL8/qbeA5iDVincb5 dLJxXljE2AxV0Y699mFfTjL6MQ== X-Received: by 10.28.90.85 with SMTP id o82mr380057wmb.69.1510246824318; Thu, 09 Nov 2017 09:00:24 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 128sm8964755wmi.28.2017.11.09.09.00.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Nov 2017 09:00:22 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 35A053E01F7; Thu, 9 Nov 2017 17:00: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 v2 1/3] kvm: arm debug: introduce helper for single-step Date: Thu, 9 Nov 2017 17:00:19 +0000 Message-Id: <20171109170021.2984-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171109170021.2984-1-alex.bennee@linaro.org> References: <20171109170021.2984-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 --- 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 | 2 ++ arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/debug.c | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+) -- 2.14.2 Reviewed-by: Julien Thierry diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h index 4a879f6ff13b..a2e881d6108e 100644 --- a/arch/arm/include/asm/kvm_host.h +++ b/arch/arm/include/asm/kvm_host.h @@ -285,6 +285,8 @@ 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) {} 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 9 17:00: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: 118467 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1153324edl; Thu, 9 Nov 2017 09:00:33 -0800 (PST) X-Google-Smtp-Source: ABhQp+TuSKlDKcI2d/PvUMdnYQpqkQaGTZQw348Em0W7LZZNkSP1m7wJ6FC7TOBcjywArtD3svj5 X-Received: by 10.159.216.145 with SMTP id s17mr1009682plp.297.1510246833068; Thu, 09 Nov 2017 09:00:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510246833; cv=none; d=google.com; s=arc-20160816; b=Qtn1lY8oXtONrtu9ExQWeQztgCQy4Rd8NmWdOTHu4Mi+QoUb2X6tvgvzp3Oi/YrJFo SrSieKEdH15TUz9kkBQWLt4yU3lVy5yg/hkbaUDIyruqVgryX9kXVzSPPPbuofquHRNq v0EALRdD0W5WH4iXcy8aiZUSHooBZIjMppwUiWPko6lL16YQaTpZYhaNRCylpZe2pSJi ToHX0uwBbj/zgG3CzpctrmBJmbAjabLyIn3J/YUxqhrurwGBtX6oysd/iSgUwRhut22V jmWQMXElkIulm7Rf2CtdEBujiSmY7DtiNgBfAX83je4j61V+UgkPfZSK5DYYdyt2CYT9 ovGw== 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=V6HCRLgqa9ErgrXDTIirUcDf6PpujyqfQP8dm4aQeDI=; b=ZEpht45m4YFP/6uI1SHGItM7ZJDNFDM6IEUoVB+pin6U3zP3qOe+RRrrWE0BWHBbBT NLZL0f1uLWR1xDvbBbJUcyxvgulB8HGwglXx0bbtotvz5UxSEC4S7+ANN75Xhfb9Pk7V TaUgFxRypM98KcUaNoe2Am2ucxGYFE/gyz1vqq/CkHjywSKz0RwCH3u/2jJ4txqFTO5w ZhYmB8tdiOZhKeQRDT82cWbUBwOKlzLtHcUxUx+QKVhWktwFgtwOmBerXGnrEWtGUTcI 4oe4TQGnmAxtSy+K79OlLGB29aTWIwSU9YAUO0udXQ1K7uNr/4hWXVphiOKB8ujY4PNN Qusg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=havQvlqc; 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 m12si6651801plt.65.2017.11.09.09.00.32; Thu, 09 Nov 2017 09:00:33 -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=havQvlqc; 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 S1754102AbdKIRA3 (ORCPT + 23 others); Thu, 9 Nov 2017 12:00:29 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:33676 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754080AbdKIRA1 (ORCPT ); Thu, 9 Nov 2017 12:00:27 -0500 Received: by mail-wm0-f66.google.com with SMTP id r68so2968217wmr.0 for ; Thu, 09 Nov 2017 09:00: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=V6HCRLgqa9ErgrXDTIirUcDf6PpujyqfQP8dm4aQeDI=; b=havQvlqcBCpW8VQKFVjgkzBILNpTmrCupPEsGdcx59tqwrqRSmq5YX6E4uguOTwn3k lu5XPx1T+L59Ouyo8+sp/WoEIXb+4MIij6nHKiimTPEFhtsSjdOY4C2SShKM+c1z9ody 9eQWJW9Gxzj9i3hLb+CwGc5VYHwz68GIYZ5Wg= 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=V6HCRLgqa9ErgrXDTIirUcDf6PpujyqfQP8dm4aQeDI=; b=O3572T50xo4AV2XiZosE+XMguS3w9OBtZng7ddxQkRsVgT6Cepynnrr/OsjbzW6Loz n7LPl24YdiynfY5xTr/xdC6RXdEsE0FAfw+iaW84hBWmkhFG47JSWCoJuXJkX4Bi2NHu mTgq8vQEUehS+mOk6s48owoGSVmu6ZTvnj49hhCyXP4+E1HEJAa5a35KnoGIzYZIxaVP EWBTh0Of4bR2qM7jqHJpCreMwVplWxhnxWdOIVQqA9Wiq5lJGukECqQjk3YmllPqFJO1 pNkCvihiFzNdfodBhddvLQO+aQVnFaLWGMTmU+NlIZJ0EM1VPzM4vpcmsSs7XUarJgWq Aa9Q== X-Gm-Message-State: AJaThX45Wilzdb9x8ABzs0SCjg180mSzFwx8VqsY1zMcPbh0k1adjxtg piQq2JPzumzFuNfjcGf6qpPfSg== X-Received: by 10.28.69.8 with SMTP id s8mr343101wma.65.1510246826444; Thu, 09 Nov 2017 09:00:26 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 25sm7341808wrv.8.2017.11.09.09.00.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Nov 2017 09:00:24 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 567A03E0349; Thu, 9 Nov 2017 17:00: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 v2 2/3] kvm: arm64: handle single-stepping trapped instructions Date: Thu, 9 Nov 2017 17:00:20 +0000 Message-Id: <20171109170021.2984-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171109170021.2984-1-alex.bennee@linaro.org> References: <20171109170021.2984-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 --- 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.14.2 Reviewed-by: Julien Thierry 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 9 17:00: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: 118468 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1153742edl; Thu, 9 Nov 2017 09:00:53 -0800 (PST) X-Google-Smtp-Source: ABhQp+SjFz+s8JkXJw8TgGbh5/SYS2PmYr2SbP20s8XiIUr2JFKbaHSXIZYo4MjWySJekVX40GQZ X-Received: by 10.99.38.129 with SMTP id m123mr1053923pgm.53.1510246853650; Thu, 09 Nov 2017 09:00:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510246853; cv=none; d=google.com; s=arc-20160816; b=sEQ1SZzCucado3Yt01M3zvGaO6fw1HMyxWph3F1Kciml+Gd4GPkfN440BaQJOqLDkW YHJ50UA9Ybnw1VIWo88VyPaaHVmA6TzTzoIDIperF95DYgYaH8tQ8hsv4AJstNgsiWmj kZ9udcvioiwu5PTMWolIddiJJrY1V2IGH+TlCekR4HirK047k5fBpHAcUGdaJC2Y5oQ5 XTzpU7Y42tCdWhNqQBfGShJQmKE54ScSAa08xth+ggHTVVb5ER4W4aNnQAGMxipMWdbW vjOtANKNs9K4BclzQ8imP4jrm9uCx/ZhjrElQjea9EPAzO0xcvSb7OaJqJFqah1Vk1t1 JdpA== 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=0kwfNOPHCOS5a9cl6azOuqXOg0BkH0nP9G+GtCoKMII=; b=oBh9ugFTg6S4jzbP18M12KCMGbB+G41yUpPMxaQ+68J9IUL0MASbYQypQ3NQmQ0etl b9VZ6Rwwb9IGwZ+HJzxvZmJymVH2DmsoG+yKDhtXbs1+HUq8tXRpKW6Dr+/qLuKe9ZQV pTbQK2JS1me37c5Xqng46+87Sye2UzbRYW9ScxWRZ6gapReAiIddwEzngU42a4QgWkaS 3lvIcBFz0q2Psb/w8lrdrt4iKpMgLcGCAP/8qL7K1Qj87h5PABlYd+OEPLLWHymaS527 aMIxfKA5ZyTSELsLEYk4B3rGoKuczCNxbCNMAr/hLYu+yqejbL9yx3YhJ1ix0mbJguRZ +efA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aEZtK+BB; 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 68si7210774pfq.46.2017.11.09.09.00.53; Thu, 09 Nov 2017 09:00:53 -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=aEZtK+BB; 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 S1753803AbdKIRAw (ORCPT + 23 others); Thu, 9 Nov 2017 12:00:52 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:47961 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753956AbdKIRA0 (ORCPT ); Thu, 9 Nov 2017 12:00:26 -0500 Received: by mail-wr0-f194.google.com with SMTP id k61so6223755wrc.4 for ; Thu, 09 Nov 2017 09:00: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=0kwfNOPHCOS5a9cl6azOuqXOg0BkH0nP9G+GtCoKMII=; b=aEZtK+BB65FzZcywHFF0hCMV8RXNjkWMese1n5BALHO6WXpGu1OAOjUbMC3ZSRzzju Df2C2ZK6TULAJnJkge1Nenu61iq5PGAVfo21lExBccWrLxa0CRBZM5gyBpgrQJ1txpE2 RPoL+i7MA/GkKGJ58dTd5E9EXBkB4f6+GqR4E= 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=0kwfNOPHCOS5a9cl6azOuqXOg0BkH0nP9G+GtCoKMII=; b=HEKv9IyuLTJ0/oASj2VB6bFDddGvENi6aQL2u7NYi8EgB7yjQV2q1+CH0UrDiCUUIP QklZFUwQDLHloAUpUzpgisXRta9S6h/mlNZBYjmuPVi+mLUh4EDnflHnv/96lORNSMiv 3CH2SlUUhpe7lG1NYOumQ9ZJF53W0YyasVioTNi3aJwCAAanQ/P7MwSX5sP9KoMNr0j1 caE84FYx5cXY9Jglu7Kf99NxnZyqjbyWsyM9Hpfm1LNuBNBm399EoyrG4JuPa/ihuErB K/Pb0e41Y88SyWQ9kF9Nm93WM24WXn+rhflA0EECeBdHnA4xWPS1k156maSec9QfLhTH Jx5Q== X-Gm-Message-State: AJaThX77nCZrcWpyy5ufdXzUmBjZp9HHpIdcjswu9LeUknBa5644nY5N Rgt8w93N24NaRuOHx7OEGA6nOA== X-Received: by 10.223.184.47 with SMTP id h44mr923898wrf.11.1510246825316; Thu, 09 Nov 2017 09:00:25 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id o70sm20941986wrb.62.2017.11.09.09.00.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Nov 2017 09:00:24 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 772783E03B5; Thu, 9 Nov 2017 17:00: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 v2 3/3] kvm: arm64: handle single-step of userspace mmio instructions Date: Thu, 9 Nov 2017 17:00:21 +0000 Message-Id: <20171109170021.2984-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171109170021.2984-1-alex.bennee@linaro.org> References: <20171109170021.2984-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 --- virt/kvm/arm/arm.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.14.2 diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index 95cba0799828..2991adfaca9d 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 1; + } if (run->immediate_exit)