From patchwork Mon Dec 4 14:03:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10090371 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E30AE60329 for ; Mon, 4 Dec 2017 14:05:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBEE02842D for ; Mon, 4 Dec 2017 14:05:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0C6D2877F; Mon, 4 Dec 2017 14:05:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,URIBL_DBL_ABUSE_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F8FF2842D for ; Mon, 4 Dec 2017 14:05:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754306AbdLDOFo (ORCPT ); Mon, 4 Dec 2017 09:05:44 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:43130 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752488AbdLDOEG (ORCPT ); Mon, 4 Dec 2017 09:04:06 -0500 Received: by mail-wr0-f196.google.com with SMTP id z34so17415123wrz.10 for ; Mon, 04 Dec 2017 06:04:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=christofferdall-dk.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3CMNdB7iJi3DvINvq0odIh/GBCIHpAw40rBq/VrH2i0=; b=jI8MkmgKsf9y9HPXxkvLzBBBHbrCvbM3c0Yej7BgkyJ/XJwETwA96NPMhF+MnnTqyo UJPfxcBacosk/mrH3q7xgXvbh/62oi0LlwpwqW84esGL6W5IiV9mUmYTfF+9eVRkLaqz cV+vmpyvN+P+pf3+kANrJ1paCnrb69a7+of59QE+TejfY7iUfM7tc5kvtrshST21h1Gq 0TYgVLWGL3slnDnH63yqx4Humxn/uPJpW/lw483sdZPgQSJoe12fgz0V10ZaOfsjYrEa oHnIB2dZVv1IW0siiwyqGSh7uGo3Zoj96O6tYvqKe0ov2vuVIl6/rYyQOxeuSzqfd3Gk OKng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=3CMNdB7iJi3DvINvq0odIh/GBCIHpAw40rBq/VrH2i0=; b=A/84FfwyvRaxzW5vPrtWtq5L9dU6NjvBvAIWXOO+jTp217Tn+DiNMdFgKXTdDIThOX ssmrj7l9PEkX57bF6CoiOZg7Mru76gZUvtFUmkvHUAE9JzJ4m+9s+mvuOaQCYTA8hdWW X1avUYLqI4kfUYYrTw8/uGoedko7uglfChHjtm8onQ+JZAE7BYEKSy8ePV3FgYIGvCjA yvV+C5igaEqEk1iKE1TmoDiCduQsBJKXhpbDlaULVirw/fiOgFU5gODwptvDXcHIDqeC 7lZaF4npj9mgGXoQTVRzKfS0JzZs+N3REdLlm58nkyLf1/2Tj9sMwDxAgIVVPVEQGEtp MX2g== X-Gm-Message-State: AJaThX5gqNYSb743kSHrCouYLxzl7on/2FHfrfOTcn8895fDzslHDBez BJN/bk0d3DikfanlDlh92qjl4Q== X-Google-Smtp-Source: AGs4zMb2cfvSGiAi5SJYj+V1NI/SiUnp/jtPPrW56RHkwDGJi07HY/5A+D+Bd5MfKYfT4x6A9HjvwQ== X-Received: by 10.223.172.146 with SMTP id o18mr12988842wrc.128.1512396245568; Mon, 04 Dec 2017 06:04:05 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id g7sm22794279wra.38.2017.12.04.06.04.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Dec 2017 06:04:04 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, Marc Zyngier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Christoffer Dall Subject: [PULL 13/19] kvm: arm64: handle single-step during SError exceptions Date: Mon, 4 Dec 2017 15:03:42 +0100 Message-Id: <20171204140348.21965-11-cdall@kernel.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171204135637.21620-1-cdall@kernel.org> References: <20171204135637.21620-1-cdall@kernel.org> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Alex Bennée When an SError arrives during single-step both the SError and debug exceptions may be pending when the step is completed, and the architecture doesn't define the ordering of the two. This means that we can observe en SError even though we've just completed a step, without receiving a debug exception. 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. Acked-by: Marc Zyngier Reviewed-by: Christoffer Dall Signed-off-by: Alex Bennée Signed-off-by: Christoffer Dall --- arch/arm64/kvm/handle_exit.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c index 029c28dd25e9..304203fa9e33 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" @@ -252,7 +253,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: