From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11B8EC433DB for ; Fri, 26 Feb 2021 18:13:01 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 6E5F864F1B for ; Fri, 26 Feb 2021 18:13:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6E5F864F1B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id E04B34B0EC; Fri, 26 Feb 2021 13:12:59 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@kernel.org Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id e70qDMpZEFId; Fri, 26 Feb 2021 13:12:58 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id F089F4B308; Fri, 26 Feb 2021 13:12:57 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 3EE784B2E4 for ; Fri, 26 Feb 2021 13:12:56 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1HZVI2tBpiVV for ; Fri, 26 Feb 2021 13:12:55 -0500 (EST) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 43C3A4B190 for ; Fri, 26 Feb 2021 13:12:55 -0500 (EST) Received: by mail.kernel.org (Postfix) with ESMTPSA id D7B7B64E85; Fri, 26 Feb 2021 18:12:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614363173; bh=nAk4WrgY8B1ZZvvFfv8YJ7MnbT4maSdfShrZmvw4D64=; h=From:To:Cc:Subject:Date:From; b=oRVWGsLXznLVXC6SDWZGUxWKLSP5iTK6CsaJ6BXqEDc/NllJ8K40KI/TxRQPsinkB 3+JjvMXwYe5xM4nRSRWg92AmWm6FkR0+QPL2cg1ehaH8LO+Dj6wBBh2NnGuTMXQHC/ 6+MJJJUtJlKOsnwgcW1TqZ5EUg6n4PfpmJzMTkhiibEoxkK81AC38RSDSpwzAoHk3m aNWV4oY0kKviXBM1bFZMclEl1ZkvB81TLxFmmkIVjZGVg65UOOXyNkE/JlciG9/iRX 2b8PB8XAbpGkod0dKqAlwP5tHrnaJjQpZBLA5OL2aJjM2B58Wc+Woxwu8g7wBf5ksk IKha1ce9e8GVQ== From: Will Deacon To: kvmarm@lists.cs.columbia.edu, maz@kernel.org Subject: [PATCH] KVM: arm64: Avoid corrupting vCPU context register in guest exit Date: Fri, 26 Feb 2021 18:12:11 +0000 Message-Id: <20210226181211.14542-1-will@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Cc: kernel-team@android.com, stable@vger.kernel.org, Will Deacon , linux-arm-kernel@lists.infradead.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu Commit 7db21530479f ("KVM: arm64: Restore hyp when panicking in guest context") tracks the currently running vCPU, clearing the pointer to NULL on exit from a guest. Unfortunately, the use of 'set_loaded_vcpu' clobbers x1 to point at the kvm_hyp_ctxt instead of the vCPU context, causing the subsequent RAS code to go off into the weeds when it saves the DISR assuming that the CPU context is embedded in a struct vCPU. Leave x1 alone and use x3 as a temporary register instead when clearing the vCPU on the guest exit path. Cc: Marc Zyngier Cc: Andrew Scull Cc: Fixes: 7db21530479f ("KVM: arm64: Restore hyp when panicking in guest context") Suggested-by: Quentin Perret Signed-off-by: Will Deacon --- This was pretty awful to debug! arch/arm64/kvm/hyp/entry.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/entry.S b/arch/arm64/kvm/hyp/entry.S index b0afad7a99c6..0c66a1d408fd 100644 --- a/arch/arm64/kvm/hyp/entry.S +++ b/arch/arm64/kvm/hyp/entry.S @@ -146,7 +146,7 @@ SYM_INNER_LABEL(__guest_exit, SYM_L_GLOBAL) // Now restore the hyp regs restore_callee_saved_regs x2 - set_loaded_vcpu xzr, x1, x2 + set_loaded_vcpu xzr, x2, x3 alternative_if ARM64_HAS_RAS_EXTN // If we have the RAS extensions we can consume a pending error -- 2.30.1.766.gb4fecdf3b7-goog _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B067CC433DB for ; Fri, 26 Feb 2021 18:14:07 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4F4ED64E85 for ; Fri, 26 Feb 2021 18:14:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4F4ED64E85 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=Oow4Pl3nIV+BoYuqJQrWmimKZaTxLxs3Lpk5q13DFSc=; b=0/ON5rMtxRASxwuO6DFp9JzKtd zg7f2QYxyI9RonbFo43bvamZRDMTsgvGWJZKWUT7snIXrQUJWOFvZ3uLXA236VhIqc6WcfXpTW+HB BJzLgjqumSyBUO+A5NZat1l7xf6yCuuxNe8hms9mYWaBJeaygxFIW+6kJqs6s9lcYT6T2mwMWKnMJ LMZCK4DPCVyW1ozDZMpJdwzpcjymA2QCfnvf4wutf8Br3Xu6onsUx+5KRBAHEC/NkDLUEwfaOZOsg ytcw/qtDf9eo/9PKvIaFnmA8eUlfdTH6DJbEBXdH1Ilj9BTBUTf3NG3eIRItNDz1f8ng5QJbAZBM8 z75Pq+UA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lFhbk-0002ZO-6t; Fri, 26 Feb 2021 18:12:56 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lFhbi-0002Yu-63 for linux-arm-kernel@lists.infradead.org; Fri, 26 Feb 2021 18:12:54 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id D7B7B64E85; Fri, 26 Feb 2021 18:12:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614363173; bh=nAk4WrgY8B1ZZvvFfv8YJ7MnbT4maSdfShrZmvw4D64=; h=From:To:Cc:Subject:Date:From; b=oRVWGsLXznLVXC6SDWZGUxWKLSP5iTK6CsaJ6BXqEDc/NllJ8K40KI/TxRQPsinkB 3+JjvMXwYe5xM4nRSRWg92AmWm6FkR0+QPL2cg1ehaH8LO+Dj6wBBh2NnGuTMXQHC/ 6+MJJJUtJlKOsnwgcW1TqZ5EUg6n4PfpmJzMTkhiibEoxkK81AC38RSDSpwzAoHk3m aNWV4oY0kKviXBM1bFZMclEl1ZkvB81TLxFmmkIVjZGVg65UOOXyNkE/JlciG9/iRX 2b8PB8XAbpGkod0dKqAlwP5tHrnaJjQpZBLA5OL2aJjM2B58Wc+Woxwu8g7wBf5ksk IKha1ce9e8GVQ== From: Will Deacon To: kvmarm@lists.cs.columbia.edu, maz@kernel.org Subject: [PATCH] KVM: arm64: Avoid corrupting vCPU context register in guest exit Date: Fri, 26 Feb 2021 18:12:11 +0000 Message-Id: <20210226181211.14542-1-will@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210226_131254_324275_52526384 X-CRM114-Status: GOOD ( 12.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Quentin Perret , kernel-team@android.com, stable@vger.kernel.org, Andrew Scull , Will Deacon , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Commit 7db21530479f ("KVM: arm64: Restore hyp when panicking in guest context") tracks the currently running vCPU, clearing the pointer to NULL on exit from a guest. Unfortunately, the use of 'set_loaded_vcpu' clobbers x1 to point at the kvm_hyp_ctxt instead of the vCPU context, causing the subsequent RAS code to go off into the weeds when it saves the DISR assuming that the CPU context is embedded in a struct vCPU. Leave x1 alone and use x3 as a temporary register instead when clearing the vCPU on the guest exit path. Cc: Marc Zyngier Cc: Andrew Scull Cc: Fixes: 7db21530479f ("KVM: arm64: Restore hyp when panicking in guest context") Suggested-by: Quentin Perret Signed-off-by: Will Deacon --- This was pretty awful to debug! arch/arm64/kvm/hyp/entry.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/entry.S b/arch/arm64/kvm/hyp/entry.S index b0afad7a99c6..0c66a1d408fd 100644 --- a/arch/arm64/kvm/hyp/entry.S +++ b/arch/arm64/kvm/hyp/entry.S @@ -146,7 +146,7 @@ SYM_INNER_LABEL(__guest_exit, SYM_L_GLOBAL) // Now restore the hyp regs restore_callee_saved_regs x2 - set_loaded_vcpu xzr, x1, x2 + set_loaded_vcpu xzr, x2, x3 alternative_if ARM64_HAS_RAS_EXTN // If we have the RAS extensions we can consume a pending error -- 2.30.1.766.gb4fecdf3b7-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7F2CC433DB for ; Fri, 26 Feb 2021 18:13:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 72C8264F17 for ; Fri, 26 Feb 2021 18:13:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229752AbhBZSNi (ORCPT ); Fri, 26 Feb 2021 13:13:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:54278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229571AbhBZSNd (ORCPT ); Fri, 26 Feb 2021 13:13:33 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D7B7B64E85; Fri, 26 Feb 2021 18:12:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614363173; bh=nAk4WrgY8B1ZZvvFfv8YJ7MnbT4maSdfShrZmvw4D64=; h=From:To:Cc:Subject:Date:From; b=oRVWGsLXznLVXC6SDWZGUxWKLSP5iTK6CsaJ6BXqEDc/NllJ8K40KI/TxRQPsinkB 3+JjvMXwYe5xM4nRSRWg92AmWm6FkR0+QPL2cg1ehaH8LO+Dj6wBBh2NnGuTMXQHC/ 6+MJJJUtJlKOsnwgcW1TqZ5EUg6n4PfpmJzMTkhiibEoxkK81AC38RSDSpwzAoHk3m aNWV4oY0kKviXBM1bFZMclEl1ZkvB81TLxFmmkIVjZGVg65UOOXyNkE/JlciG9/iRX 2b8PB8XAbpGkod0dKqAlwP5tHrnaJjQpZBLA5OL2aJjM2B58Wc+Woxwu8g7wBf5ksk IKha1ce9e8GVQ== From: Will Deacon To: kvmarm@lists.cs.columbia.edu, maz@kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel-team@android.com, Will Deacon , Andrew Scull , stable@vger.kernel.org, Quentin Perret Subject: [PATCH] KVM: arm64: Avoid corrupting vCPU context register in guest exit Date: Fri, 26 Feb 2021 18:12:11 +0000 Message-Id: <20210226181211.14542-1-will@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Commit 7db21530479f ("KVM: arm64: Restore hyp when panicking in guest context") tracks the currently running vCPU, clearing the pointer to NULL on exit from a guest. Unfortunately, the use of 'set_loaded_vcpu' clobbers x1 to point at the kvm_hyp_ctxt instead of the vCPU context, causing the subsequent RAS code to go off into the weeds when it saves the DISR assuming that the CPU context is embedded in a struct vCPU. Leave x1 alone and use x3 as a temporary register instead when clearing the vCPU on the guest exit path. Cc: Marc Zyngier Cc: Andrew Scull Cc: Fixes: 7db21530479f ("KVM: arm64: Restore hyp when panicking in guest context") Suggested-by: Quentin Perret Signed-off-by: Will Deacon --- This was pretty awful to debug! arch/arm64/kvm/hyp/entry.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/entry.S b/arch/arm64/kvm/hyp/entry.S index b0afad7a99c6..0c66a1d408fd 100644 --- a/arch/arm64/kvm/hyp/entry.S +++ b/arch/arm64/kvm/hyp/entry.S @@ -146,7 +146,7 @@ SYM_INNER_LABEL(__guest_exit, SYM_L_GLOBAL) // Now restore the hyp regs restore_callee_saved_regs x2 - set_loaded_vcpu xzr, x1, x2 + set_loaded_vcpu xzr, x2, x3 alternative_if ARM64_HAS_RAS_EXTN // If we have the RAS extensions we can consume a pending error -- 2.30.1.766.gb4fecdf3b7-goog