From patchwork Tue Mar 22 18:35:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 12788935 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 0ECA7C433FE for ; Tue, 22 Mar 2022 18:37:24 +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:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=zPg8+SBm6vH3XbzUT8Absg+dw4JipUb9AHyof5jesWA=; b=zs7jol3R9Ru2p8KtIMTrPvFTBC a1pqfoYhaCnkcsb0RlmUzYl27D1T1UvALTQVaMw7hjTy7NeRbnaG/uDKj4g1GEM8YbNg3nNdMnfPz iR9timEbJCSVIWNZ9+OHcQfmNZRhpKQa42lkgQHpVrPtJVYPBc95xQ5qRkk6DTdgtZcF6/yt+Cqr/ 6VYg5zlcMzriP8FPFS41Gm4+gop7ZpLX3CZHQ2srD3TYrC4tjFGsyQf5v7uvCTY4SRXo25FIGh5eG iFR4aIephFdq6MLX55o7tDONCCrcTpI/wEAvcPavEOn9lLGyM2M6k2zqHDw95Aih7SAacar1sgupG N70tBH8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nWjMN-00Bss0-98; Tue, 22 Mar 2022 18:35:59 +0000 Received: from mail-oo1-xc4a.google.com ([2607:f8b0:4864:20::c4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nWjMA-00Bsnh-5C for linux-arm-kernel@lists.infradead.org; Tue, 22 Mar 2022 18:35:48 +0000 Received: by mail-oo1-xc4a.google.com with SMTP id x8-20020a4a3948000000b00320c4f9ae47so12122633oog.15 for ; Tue, 22 Mar 2022 11:35:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=3PzR5vzjBym0Xrr1WAh6EkOFmL2w1PsYl+ih5Ad/dqk=; b=SGblp6gYJTNQJbOVKJuZHzVH1+KspPybgjStuKKj0ooDhsYubYE8RgbOz71CqIVIjr SP/4dvB0b76AjPGSoyzVZ1LBu501I1vwxlx8D1FWgRrsHFXbOuQci+fEdW5XRxq4bGOX 5rlIbDFc2u7S1S7WTteu0BD6kmSRpMILcW1q6F4oKF0zemBXr5gKSSOuPwbCiLDpRkkP 2c5b8tXImTSrhnxbW/JVf+0W7g3mBcSg64r10QY+/AJQ+fiXoTxUjbtz1cjBNvw8Aw0F Ls0OzeMV1Ac8oK7Yww2DOCYx+7o3/XAGcuiFnV2+o8Wh/vssPQd/XsBMgzi6x8gYr0UT yMcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=3PzR5vzjBym0Xrr1WAh6EkOFmL2w1PsYl+ih5Ad/dqk=; b=lmFTphEup8PcJuWscWm8l36LPPj54oQlopssfULnzIhyDr3dYzfmzZv00h+LWq6GFO EI+dUgY5chb0TMeN2aKihw+hKRWhCT4Or5WJt2Ke4eWB6N5+lDe7fj6rHkrEAdXGMRFr w+22EoYaqgngWlmCqMM8k4lbtokuG5G760fW1ZvuZgOtnR5TiXSbUFgXxaFqNHjxwWNc w8CQVJgQC192xmJbFAeq35QkZJch7as2s9GbRC+SggG4V1SvapnLnJRxlpIR4W8JWK2C pzdNdIYXeKtX8d8gPKQjE0Nt5zIpkJBM/no5K3gopR6qh2zuk/Hresg/j2FUYzk9XvE3 53cQ== X-Gm-Message-State: AOAM531qShXJyr5nS6+S9tHAJtdM6bbrFsaARhCiEW5jJTgxzJshcI65 +EB58awY0dRppg22oUACPtn6T/G7cbM= X-Google-Smtp-Source: ABdhPJzn9OAifeYpnFU+SY/qxn1hQQpBef9smelEDXHHVlma7uJiqUTGI5RF9LlKNBUY6ZOaiPTb3GAZ4wE= X-Received: from oupton.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:404]) (user=oupton job=sendgmr) by 2002:a05:6808:1283:b0:2ec:f440:e076 with SMTP id a3-20020a056808128300b002ecf440e076mr2801595oiw.157.1647974144916; Tue, 22 Mar 2022 11:35:44 -0700 (PDT) Date: Tue, 22 Mar 2022 18:35:36 +0000 In-Reply-To: <20220322183538.2757758-1-oupton@google.com> Message-Id: <20220322183538.2757758-2-oupton@google.com> Mime-Version: 1.0 References: <20220322183538.2757758-1-oupton@google.com> X-Mailer: git-send-email 2.35.1.894.gb6a874cedc-goog Subject: [PATCH v2 1/3] KVM: arm64: Generally disallow SMC64 for AArch32 guests From: Oliver Upton To: kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, Peter Shier , Ricardo Koller , Reiji Watanabe , Paolo Bonzini , Will Deacon , Oliver Upton , Andrew Jones X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220322_113546_226086_35C42A55 X-CRM114-Status: GOOD ( 11.85 ) 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 The only valid calling SMC calling convention from an AArch32 state is SMC32. Disallow any PSCI function that sets the SMC64 function ID bit when called from AArch32 rather than comparing against known SMC64 PSCI functions. Note that without this change KVM advertises the SMC64 flavor of SYSTEM_RESET2 to AArch32 guests. Fixes: d43583b890e7 ("KVM: arm64: Expose PSCI SYSTEM_RESET2 call to the guest") Acked-by: Will Deacon Reviewed-by: Reiji Watanabe Reviewed-by: Andrew Jones Signed-off-by: Oliver Upton --- arch/arm64/kvm/psci.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/arch/arm64/kvm/psci.c b/arch/arm64/kvm/psci.c index a433c3eac9b7..cd3ee947485f 100644 --- a/arch/arm64/kvm/psci.c +++ b/arch/arm64/kvm/psci.c @@ -216,15 +216,11 @@ static void kvm_psci_narrow_to_32bit(struct kvm_vcpu *vcpu) static unsigned long kvm_psci_check_allowed_function(struct kvm_vcpu *vcpu, u32 fn) { - switch(fn) { - case PSCI_0_2_FN64_CPU_SUSPEND: - case PSCI_0_2_FN64_CPU_ON: - case PSCI_0_2_FN64_AFFINITY_INFO: - /* Disallow these functions for 32bit guests */ - if (vcpu_mode_is_32bit(vcpu)) - return PSCI_RET_NOT_SUPPORTED; - break; - } + /* + * Prevent 32 bit guests from calling 64 bit PSCI functions. + */ + if ((fn & PSCI_0_2_64BIT) && vcpu_mode_is_32bit(vcpu)) + return PSCI_RET_NOT_SUPPORTED; return 0; }