From patchwork Wed Mar 9 18:13:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 12775408 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44E0CC433F5 for ; Wed, 9 Mar 2022 18:14:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :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=XIToC6dMgUrZwMohCrHDGSwbsr8dMybTiSKak0yR8UM=; b=PaC57IWml06Zhj 4M/dnAHWHcCnhH+IlQBC/up9SB9Awsh9tGAW5jYaGOq23xtLUJiglKzR98vypJHctf0VXn/x4EGHV iITxMj0IfKjRlLGK8abkgBGuod5qdMwk79XvWMhVgGqhLdDyBvP4at+3Mdijl4xZHbvAlI0fkhT3V CpK34IysAIzVD7y6aPBi8KLdUUm3wNJrbD5eC5Pr3bhWvzyj1oykMeEXDa9EF+4CtJ5v5Hd8qRHEv WVW16GvqUv6g69FnE5jdmLw+/33PgQMjZtwXkW/dMb+9f3EVgxW4Xcq6SwhkgDdGlCP6jxTohs475 bKL4xP3vRrvQ4H4KRTkQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nS0oS-00A1s7-Bt; Wed, 09 Mar 2022 18:13:28 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nS0oP-00A1r5-6a for linux-arm-kernel@lists.infradead.org; Wed, 09 Mar 2022 18:13:26 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 754B861631; Wed, 9 Mar 2022 18:13:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45ECCC340E8; Wed, 9 Mar 2022 18:13:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646849602; bh=lyggJlXndKJKDnziS0BOwCX9JVHL04zmV0yEEEp8eGw=; h=From:To:Cc:Subject:Date:From; b=cIxCCctPMem2NI35nWHGiSJ5+I2A4y5VacGJ+61FL2HnZgfVbAAWqY9OHmcJ01RIs EgKmez5rNwoevHVNayWlb3ey7cH5DVdVbUNTrSRNg+/A4ovH/ZN3gXrV7QHCg3DMtV JskZ5L21U0tHd5g9clh0dmZUPxQKmnCDkC412PvIXwA1FkiMhUxYxB4tX2125NbyrJ 5wlloMmq2RrGoSwWWxQUcAIvM7qZCJ6pwuiS7AZnXVzY4acOWPDJ+TrDPCbd4zH85U 0w8fREeDpKTW9v/VlLtH70aa5KOHzAYtgKZ0+wRl2E2ZgNrufyhmqjGdevL0IrpL4P Tcv5ZFToZvGsg== From: Will Deacon To: kvmarm@lists.cs.columbia.edu Cc: maz@kernel.org, linux-arm-kernel@lists.infradead.org, Will Deacon , Andrew Walbran Subject: [PATCH] KVM: arm64: Really propagate PSCI SYSTEM_RESET2 arguments to userspace Date: Wed, 9 Mar 2022 18:13:08 +0000 Message-Id: <20220309181308.982-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-20220309_101325_298432_3A41477A X-CRM114-Status: GOOD ( 14.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Commit d43583b890e7 ("KVM: arm64: Expose PSCI SYSTEM_RESET2 call to the guest") hooked up the SYSTEM_RESET2 PSCI call for guests but failed to preserve its arguments for userspace, instead overwriting them with zeroes via smccc_set_retval(). As Linux only passes zeroes for these arguments, this appeared to be working for Linux guests. Oh well. Don't call smccc_set_retval() for a SYSTEM_RESET2 heading to userspace and instead set X0 (and only X0) explicitly to PSCI_RET_INTERNAL_FAILURE just in case the vCPU re-enters the guest. Fixes: d43583b890e7 ("KVM: arm64: Expose PSCI SYSTEM_RESET2 call to the guest") Reported-by: Andrew Walbran Signed-off-by: Will Deacon --- arch/arm64/kvm/psci.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kvm/psci.c b/arch/arm64/kvm/psci.c index ecb4b74cb12a..b0c920717632 100644 --- a/arch/arm64/kvm/psci.c +++ b/arch/arm64/kvm/psci.c @@ -367,14 +367,14 @@ static int kvm_psci_1_x_call(struct kvm_vcpu *vcpu, u32 minor) if (minor >= 1) { arg = smccc_get_arg1(vcpu); - if (arg > PSCI_1_1_RESET_TYPE_SYSTEM_WARM_RESET && - arg < PSCI_1_1_RESET_TYPE_VENDOR_START) { - val = PSCI_RET_INVALID_PARAMS; - } else { + if (arg <= PSCI_1_1_RESET_TYPE_SYSTEM_WARM_RESET || + arg >= PSCI_1_1_RESET_TYPE_VENDOR_START) { kvm_psci_system_reset2(vcpu); - val = PSCI_RET_INTERNAL_FAILURE; - ret = 0; + vcpu_set_reg(vcpu, 0, PSCI_RET_INTERNAL_FAILURE); + return 0; } + + val = PSCI_RET_INVALID_PARAMS; break; }; fallthrough;