From patchwork Thu Nov 23 12:11:33 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: 119516 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp727430qgn; Thu, 23 Nov 2017 04:12:02 -0800 (PST) X-Google-Smtp-Source: AGs4zMbvDoysAS3PQ50MD8fsMwz5YEZR5z05hMYNBG/tQGCJIpRe46UAm65lqeQowlzguSR2IcXK X-Received: by 10.98.2.201 with SMTP id 192mr22547704pfc.183.1511439122808; Thu, 23 Nov 2017 04:12:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511439122; cv=none; d=google.com; s=arc-20160816; b=DgMlP0R9uP/xcz3MBR/aHkeldMWd1Hfyt2llrEGFnUEGbf2zybjjxuTsCAKO70D3We XyZ8IJu6X79feHrMtKymb0oCHMPI4jtFG27eK+aukganqUVjckNWXussX3/1IZ7ik0zK 4l7jD2tQjQPgjJYo9miebwB3aCpZidE6G4bens5FXZhYsE6Qs5tBwc3wW4dylsSlS8Hy EQOPlDQoi/wmfcAdXXg+zaElLy3mFHeLloRpptTm6My12QwMdK9OsOOpBpra1DXLwDxE fnfG6EvY3Qr8OkMCn1i/uxbckRL8rMw1qhMy3U4A5jdgZU2mVAS/EhY6I0WwQhfI1WlP TKTA== 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=CF+Rgeu9y1EHGZLB8sSnelci5j8qpDVmyeNIbilAac8=; b=0VU/pYKa3VPb3/grDmFXsc/hQl3z4t+URxw4Y0ifoxsP+6DwagkoDoSnmkT4grKDAf yo0rsVJMvr3CTl9R0dsNQawqgqIkAXHhuNhN0p3Oh7bMuUtVrLOg95jvKtIFnddvEEfj E9h+filKiFVH9uytP7jWn6hXEz+4FgNDOQlB6+jKXbKwfOhf697SrBMHFKzIAfNcrJ3a 0qZU3jgLVlflkN9oP5uNNHBzntjpKlrLZnfENZRC1BAWQLH1AWh75b6B3OTErrUYxUix nrwQfnh8bYKSq9jxCtb6j7dhRjZpfpK4wK0F4xSbfSrDaX1ihQs609PlbaenuwsDGl8R teuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WANXRpv2; 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 q24si17716717pfi.54.2017.11.23.04.12.02; Thu, 23 Nov 2017 04:12:02 -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=WANXRpv2; 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 S1752772AbdKWMMB (ORCPT + 28 others); Thu, 23 Nov 2017 07:12:01 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:42418 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752370AbdKWMLi (ORCPT ); Thu, 23 Nov 2017 07:11:38 -0500 Received: by mail-wm0-f67.google.com with SMTP id l188so14694118wma.1 for ; Thu, 23 Nov 2017 04:11:37 -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=CF+Rgeu9y1EHGZLB8sSnelci5j8qpDVmyeNIbilAac8=; b=WANXRpv2AgtyCzUi5fjulQDAOJLdL78IwNVgPCStxTfFr60+U2DyE7tFVE5EtfIl44 EdHKUnN4tr23qjdy8Cw2KsqE5dgCj7YTraZh5DBIDRNJPQE2VHWpBuApuxv00BuywZf8 ZRziCRxItYz3S0VHNN1qOLx4pHxG2781KgvoM= 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=CF+Rgeu9y1EHGZLB8sSnelci5j8qpDVmyeNIbilAac8=; b=tQ+ncfS++DED6x4H2VomoshkkXQlK2ytB9tNwrKQrDP6WW5DOyuVq5sQu/dsMFmKlG nP2UzZgQQG+j8Pmm5N/4eKDNKJ1KyWjOD84y5xzoKs27oO+dTnnkUpkmlPUYvuLgUxqc +LgGionJqR7hVXdNf13b9CH4/RL3/l5HxEQVuVD1zi6y6IpQuIrbMaKCEIVoTdQ78Gqn y8njPrb+fe4joAGFtuLQB6fWT8vqUfOhdH2vJvuS03u/JmJDaJOyPq19MjrDhxKUWt/M tDMJWBrbLA96Aj6lqgZuVfnfezaJ9FLNrL7ilqfIJVAwDmVNI1tR9E+bbxsER40miKD6 9yDQ== X-Gm-Message-State: AJaThX4psdrZSSLafU47drLIKivRLyXrMG6fWup3mR1xUYijSJ8PY+u+ CztYYydhBVspftipalA+s7abOA== X-Received: by 10.28.118.19 with SMTP id r19mr7080544wmc.10.1511439097104; Thu, 23 Nov 2017 04:11:37 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id p28sm22998398wmf.2.2017.11.23.04.11.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 04:11:36 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 3093A3E0338; Thu, 23 Nov 2017 12:11:35 +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 v1 1/2] kvm: arm64: handle single-step during SError exceptions Date: Thu, 23 Nov 2017 12:11:33 +0000 Message-Id: <20171123121134.11050-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171123121134.11050-1-alex.bennee@linaro.org> References: <20171123121134.11050-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 When an SError arrives during single-step it may be delivered before the step completes. In that case the DBG_SPSR_SS bit will have flipped as the instruction executed. After handling the abort in handle_exit() we test to see if the bit is clear and we were single-stepping before deciding if we need to exit to user space. Signed-off-by: Alex Bennée --- arch/arm64/kvm/handle_exit.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.15.0 Reviewed-by: Christoffer Dall diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c index 3e645ec9e751..3ba8c4a3bcff 100644 --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -28,6 +28,7 @@ #include #include #include +#include #define CREATE_TRACE_POINTS #include "trace.h" @@ -250,7 +251,12 @@ int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run, return 1; case ARM_EXCEPTION_EL1_SERROR: kvm_inject_vabt(vcpu); - return 1; + /* We may still need to return for single-step */ + if (!(*vcpu_cpsr(vcpu) & DBG_SPSR_SS) + && kvm_arm_handle_step_debug(vcpu, run)) + return 0; + else + return 1; case ARM_EXCEPTION_TRAP: return handle_trap_exceptions(vcpu, run); case ARM_EXCEPTION_HYP_GONE: