From patchwork Wed Feb 23 04:18:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 1596475 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=CYh6ORu7; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=bRtQOIBW; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K3N8k1CXkz9sG2 for ; Wed, 23 Feb 2022 15:19:18 +1100 (AEDT) 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=bnEcVKzZD+RTx/AB9YzpB1NJMVqcYFRrnFGb16YCrlM=; b=CYh6ORu7vGYDc2GcQpKVeqm7q8 +NiESXf3wDPocaDh5lH9p7iIVo5MC73N2rUtxRz6GNcYUHSqYYWxB+hldDMdWSr50XfOXKctcnuhb 4ril5TThK1DO0ihnOdCtgdSq5sytcti1euMH5fH2z343N7TE64GDX9FkXYqvU6sB9uB5F9Vwkbwwd xK/VgCmQ8fkhWMy8fA/2ARcWYEMoP8mazMnnHJzCxbH0a9Ie6Ejk+WmMN6J9srsRqA/Sjr9OYL3tk St+qYP/92rIiAORUcV1LYWWsgKG1pWyazjyD15L3SytsZW/Bwn0/42a5qnAAV5j/6HYLP3OhFBgvI J/Eke0Kw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMj7T-00CmIC-Va; Wed, 23 Feb 2022 04:19:15 +0000 Received: from mail-io1-xd49.google.com ([2607:f8b0:4864:20::d49]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMj7Q-00CmG3-Jf for kvm-riscv@lists.infradead.org; Wed, 23 Feb 2022 04:19:14 +0000 Received: by mail-io1-xd49.google.com with SMTP id y11-20020a056602164b00b00640ddd94d80so5845063iow.11 for ; Tue, 22 Feb 2022 20:19:10 -0800 (PST) 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=uWbRYWTJnCUA8B0m1XqBGGOg6aYqCe4xM0wdu1aYSFo=; b=bRtQOIBWnzglQDthYZQEg4R64vK2cq/f77YtdtQkrhMtj29gKK28wkyzLwvgdgXxlq U/MgFH/VrWkqymNlz2aBFl/uqvxMJBEElXcvrOGGd7f2yeoyZSly9DxJCRIop7YDhD5v TvgaN2nxJQH3Y6BQnVszO0fCUPiY1btF3S/xUV1gCpxo7HFoFzHKwBGg4+RJvrZax5d5 otsZVN27i7gRsxm4mUOeXAt8qgEF4cyMLmHRlSjTVupL999U0egKcdjm7mWMlKFUZJg1 FX8CiZd1idDFLVGGZK/JZQIn9GfJfFPeqmhaNmCOFcvVorhaWVFoGo24Q2XZXy5iUMe9 ucHg== 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=uWbRYWTJnCUA8B0m1XqBGGOg6aYqCe4xM0wdu1aYSFo=; b=No/Q2O8w8kAU1lZSvawwDMGR/zsZ/Ty8o36ftabSt+31mEIADbm2V7oNqIPjE0oCPK cd7fZS5CEnKelbQQlIPZWlxGO23O85FqigLRFs3gdZzl6GEF8dVYWgo+/0xtCI6i00HW f/63+Bb3h9NVidRN+PTUdMR2iQ/hfghZ//W5TYPIluY6ALp9bHZpK7WLTbKD/5TfDeT2 YIDIGeqDjD/m7TxzPvfuTRUR+e3CmAaiiGLwQBfB48+XphJtLkbNj8x/+DMcOK96ZrVf kq8xONa7ndVV0yOFG7dw2OylA9ZXOFgrbNZvTkizF9cEKFqaLyTmQY27ABMf5g9sw+zJ fn7Q== X-Gm-Message-State: AOAM532D2kNSWW0cJfJ3zWBjXYgxj793vFMju1iL8VOwuE6sHEUlpO87 hAp0S6ujxRbmghCYoxk/LnYU3arO+40= X-Google-Smtp-Source: ABdhPJyvsx2h/KZBIMiFVVSt3DhBBXlspYS8MfSfF2nPMCpfqGuyTsJgaKVrZ1Bx7e3kEjpyTSXSWt1l5gI= X-Received: from oupton.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:404]) (user=oupton job=sendgmr) by 2002:a6b:7d44:0:b0:641:347:477a with SMTP id d4-20020a6b7d44000000b006410347477amr10352933ioq.160.1645589950392; Tue, 22 Feb 2022 20:19:10 -0800 (PST) Date: Wed, 23 Feb 2022 04:18:29 +0000 In-Reply-To: <20220223041844.3984439-1-oupton@google.com> Message-Id: <20220223041844.3984439-5-oupton@google.com> Mime-Version: 1.0 References: <20220223041844.3984439-1-oupton@google.com> X-Mailer: git-send-email 2.35.1.473.g83b2b277ed-goog Subject: [PATCH v3 04/19] KVM: arm64: Clean up SMC64 PSCI filtering for AArch32 guests From: Oliver Upton To: kvmarm@lists.cs.columbia.edu Cc: Paolo Bonzini , Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Anup Patel , Atish Patra , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, Peter Shier , Reiji Watanabe , Ricardo Koller , Raghavendra Rao Ananta , Jing Zhang , Oliver Upton , Andrew Jones X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220222_201912_670550_50DEF92A X-CRM114-Status: UNSURE ( 9.97 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -7.7 (-------) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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 know [...] Content analysis details: (-7.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:d49 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_MED DKIMwl.org - Medium trust sender X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.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. Signed-off-by: Oliver Upton Reviewed-by: Reiji Watanabe Reviewed-by: Andrew Jones --- 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 de1cf554929d..4335cd5193b8 100644 --- a/arch/arm64/kvm/psci.c +++ b/arch/arm64/kvm/psci.c @@ -229,15 +229,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; }