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; } From patchwork Tue Mar 22 18:35:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 12788936 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 984B4C433F5 for ; Tue, 22 Mar 2022 18:37:28 +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=73SJBr6hA2tdPmh0gHjsCrZoEJIkebV1Ucdgmv/BW88=; b=VdM5cZvho5mkenerI7OT4/r3R8 Hs5I2Bp6MzUtlUVpeni73Zv53s5X6LSqdG2F5MPsiqliaQ1vw1f6kUBaO7AH0Sk3KU8hGpiugVSZ/ mwQ4IrKWxo12++uocjDn/4MwMVVJlUfPwL/8fM3I9Kc5k7uuJWlhvYmo3lafy3TI4fQeh4iwF/F3f DO1Tk9NQG+ElVVisOGeLBl7Xi6LI26VZjxpxOzcPlhiasOYEi2a5jixW+WgNj36PFcwUPvoaRo3ue W705CMsW28mGKmiwzz1MYcz9+oJhco+S/Vd611IB7gzJ+SJ3XdAf+ldLyRmkSqaW9/udjx6TwlhTz UIRMbb5g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nWjMY-00Bsvf-VG; Tue, 22 Mar 2022 18:36:11 +0000 Received: from mail-il1-x14a.google.com ([2607:f8b0:4864:20::14a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nWjMC-00BsoU-0W for linux-arm-kernel@lists.infradead.org; Tue, 22 Mar 2022 18:35:49 +0000 Received: by mail-il1-x14a.google.com with SMTP id j12-20020a056e02154c00b002c81c9084b9so3834192ilu.22 for ; Tue, 22 Mar 2022 11:35:46 -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=tnmr6FcY2JLhce32y9oAbKJR7f3jp9JaOpVAL3BoK3A=; b=GxSnt/O3uM4E7Ryuar3lRQb3ZogNtuTF21itlU478JfimK/CQKTWdC9abGJl5jGsFh vsCpeMIIxraZrqRAwjKKOTB0V//WU8dg4cRVKC5Q0oAggoKE61LbaN2rbGZvkGP8/uOI j74qp5vzLIA/wwHG8BgfrxsjGVbP6uB+Zf/aYbxfEVInJprXmyWl37BtVnmB2T3XX6u1 1rCCQ1bgNVvEq9m2lW4tSlCy3pGPNhFI7/hNOXDvATOYcr4EOtfhnIbMlmth4ZA3l6pq 8WyopLOxPV6FWc3VIk5u2CKXW37WMVKpQ+2nVJy6NA9Y65KSYa++PFSfzbm7x68qpJ47 G89g== 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=tnmr6FcY2JLhce32y9oAbKJR7f3jp9JaOpVAL3BoK3A=; b=3o/4ehdy0uEE1JpI/X0IkJbPykMAMhGBazrgM5XocKUhi+3FiohOwQ24c+XLHf+yhh 8Q+uJkaNpe5nC96l8Q7LcWkpWVq6QhhxKtgKMKueXfsgw6h5e8/qvo9xeIhjn7pRKpd7 cv/jWmVsF5nUat9aXWe1m8c86gKVRPyGkwbvkVpTCwOInAMaVbHK0HE3II4TqS4WbdfB tBsBhoLMn/vA5gDhv+1Ldu5VW1Tv3FvgjqV53gIYLqs1iGC00KqwZdmuQPzBZbU7V8Tg 5sIGg53+/N8TAkSJPMo9G16ZRJA1rP1LMQdbk3O2BYjSIv6Gai5mvNCbksrki861nx9G SrQA== X-Gm-Message-State: AOAM531FtmrAOjRwtwCCL1cWk7LTWGww/nJbflz5mSAoOhsJXaAFNwbD Fh0Lrehlcpl0JKKQIwXz4IDheVmmpvA= X-Google-Smtp-Source: ABdhPJyqOQMpygQKbMQI+YxY6NGJvNzmxA9fxDwQQ/eBULRiqPtajRMzQcxcfqJ1BaMG0pno7t9pgoH7orM= X-Received: from oupton.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:404]) (user=oupton job=sendgmr) by 2002:a05:6638:3e13:b0:321:446d:2977 with SMTP id co19-20020a0566383e1300b00321446d2977mr5465994jab.178.1647974146089; Tue, 22 Mar 2022 11:35:46 -0700 (PDT) Date: Tue, 22 Mar 2022 18:35:37 +0000 In-Reply-To: <20220322183538.2757758-1-oupton@google.com> Message-Id: <20220322183538.2757758-3-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 2/3] KVM: arm64: Actually prevent SMC64 SYSTEM_RESET2 from AArch32 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220322_113548_078406_80929597 X-CRM114-Status: GOOD ( 14.22 ) 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 SMCCC does not allow the SMC64 calling convention to be used from AArch32. While KVM checks to see if the calling convention is allowed in PSCI_1_0_FN_PSCI_FEATURES, it does not actually prevent calls to unadvertised PSCI v1.0+ functions. Hoist the check to see if the requested function is allowed into kvm_psci_call(), thereby preventing SMC64 calls from AArch32 for all PSCI versions. Fixes: d43583b890e7 ("KVM: arm64: Expose PSCI SYSTEM_RESET2 call to the guest") Acked-by: Will Deacon Reviewed-by: Reiji Watanabe Signed-off-by: Oliver Upton --- arch/arm64/kvm/psci.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kvm/psci.c b/arch/arm64/kvm/psci.c index cd3ee947485f..d24ccc77500b 100644 --- a/arch/arm64/kvm/psci.c +++ b/arch/arm64/kvm/psci.c @@ -232,10 +232,6 @@ static int kvm_psci_0_2_call(struct kvm_vcpu *vcpu) unsigned long val; int ret = 1; - val = kvm_psci_check_allowed_function(vcpu, psci_fn); - if (val) - goto out; - switch (psci_fn) { case PSCI_0_2_FN_PSCI_VERSION: /* @@ -303,7 +299,6 @@ static int kvm_psci_0_2_call(struct kvm_vcpu *vcpu) break; } -out: smccc_set_retval(vcpu, val, 0, 0, 0); return ret; } @@ -423,6 +418,15 @@ static int kvm_psci_0_1_call(struct kvm_vcpu *vcpu) */ int kvm_psci_call(struct kvm_vcpu *vcpu) { + u32 psci_fn = smccc_get_function(vcpu); + unsigned long val; + + val = kvm_psci_check_allowed_function(vcpu, psci_fn); + if (val) { + smccc_set_retval(vcpu, val, 0, 0, 0); + return 1; + } + switch (kvm_psci_version(vcpu)) { case KVM_ARM_PSCI_1_1: return kvm_psci_1_x_call(vcpu, 1); From patchwork Tue Mar 22 18:35:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 12788937 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 C4E9BC433F5 for ; Tue, 22 Mar 2022 18:37:33 +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=n5c5oqTCjyiEZT1DC12tY+P2tKGzt/lA28ImkDF1DAM=; b=i0CI+u/vZCQL4dwy0AAmTiFQ7w vMcDJo8Qva9wo8epkcm04BSd6JQJ+Xh4az2JGgds6VnjnQdcwFn0ZfOJXZVY7RovtGXZkLTbe4TLn avFp92rzOuJd8V0d1a+cxGat5I4CZLJ9dOTnKGRvMwWY4jNtdOCTr4d1wtmXDs1iCK7GnP5/GD/wq 4nAUx9DGehactFdB+9Ob2mJLVO9LKyRobrcCs4/CHQ6raj0/WeieNjIpx2VQREFQZ7iJ3KRqHtOSg ZYERJGMV8XvVvG6iJ1YlohFSWO4YjGWpGnTcWNPLoBvGUkwUWoYSQdlmE/9GrXiDLHawEVYb9Ua2I iDG2EfhQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nWjMl-00Bt0e-At; Tue, 22 Mar 2022 18:36:23 +0000 Received: from mail-io1-xd4a.google.com ([2607:f8b0:4864:20::d4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nWjMD-00Bsoe-98 for linux-arm-kernel@lists.infradead.org; Tue, 22 Mar 2022 18:35:50 +0000 Received: by mail-io1-xd4a.google.com with SMTP id h14-20020a05660208ce00b00645c339411bso13001076ioz.8 for ; Tue, 22 Mar 2022 11:35:47 -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=lGW+qCdwzMwtGGlVg3y2ePu73Q+JTzIqWyWeB9h5azY=; b=Q4h5St4bE4rOW155Wn3EO80R//PDfJqRJZaeS2M2PHHwYAb5zLlzGAVLgI+8KcM5ue vASo5TsEVfEDWKQe/g/0ORUybF8ztFa/MVDOQTAcoaq+H538ch/z0Yxpf5sxOtMhO/mj 1NvKR21tAZKlMkbhpGRqDnpFi0D2OUA2wDtnJwJEzaeaHmJNhVRNzuckM5UlO7U51Ccc YITlUK4lhH8zzVZtT2cDQSglIjKg4ygFpPgqjdjQ65imS+SRIzOc+5z7sPxPB2ce2sdq 735gTDGZlMN8ChNHrTDGsmrGpERbIKbMzkO6tB3B2eNNL7XLUe98wL3O7tuwW3BJpocx qdZA== 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=lGW+qCdwzMwtGGlVg3y2ePu73Q+JTzIqWyWeB9h5azY=; b=cz7i9iJurAbjK2AQXGHKuYZdTcinDxLU8rZl5rjlIY2dvZbAC6Pqm2ouSCgmC5Gn9a +d9T5r6CYjKTUqefq9f7qtxXvtwxmiyXKVTMmJwQI8ClPD2IHbWHQ54DrMD+9ANBDIN0 ZpU8zQsqBM8eM1pAsmWEVDVbUaZ8KzVL4pOdXq3e9f5T57lpTEC2F3s1Y9+Kml6wfqAy Wf4v9gGY+cEa5LdaNZlJcAnwG3kx4PdgoukEsjYpjjiViSGXYCotqoCBGS2QGOh/zJXd +AvLo1tvt3i9jCxdHSSCrcEkakeJ0EXh/n3y8/0DAO5dlKAJwuumxAb6+ePBTQqylyxx VvnA== X-Gm-Message-State: AOAM5316wkfX25NCLpq13ozwX5tPRfGqIqIXxAPirj4W7xB4KX0WKYKj ba+rq1edRkSVwffujda8fNPyL53FSyQ= X-Google-Smtp-Source: ABdhPJxYqKXNgdI2Nn0wjD8p/zp8eXY/Rgm3sPEio6NQXm4jTPjyEFh8n9PKO7v2VGbk1KOuPT1TekwRGKE= X-Received: from oupton.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:404]) (user=oupton job=sendgmr) by 2002:a92:d486:0:b0:2c7:b549:ede7 with SMTP id p6-20020a92d486000000b002c7b549ede7mr12361089ilg.84.1647974147115; Tue, 22 Mar 2022 11:35:47 -0700 (PDT) Date: Tue, 22 Mar 2022 18:35:38 +0000 In-Reply-To: <20220322183538.2757758-1-oupton@google.com> Message-Id: <20220322183538.2757758-4-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 3/3] KVM: arm64: Drop unneeded minor version check from PSCI v1.x handler 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220322_113549_381925_0A982B92 X-CRM114-Status: GOOD ( 11.82 ) 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 We already sanitize the guest's PSCI version when it is being written by userspace, rejecting unsupported version numbers. Additionally, the 'minor' parameter to kvm_psci_1_x_call() is a constant known at compile time for all callsites. Though it is benign, the additional check against the PSCI kvm_psci_1_x_call() is unnecessary and likely to be missed the next time KVM raises its maximum PSCI version. Drop the check altogether and rely on sanitization when the PSCI version is set by userspace. No functional change intended. Signed-off-by: Oliver Upton --- arch/arm64/kvm/psci.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/arm64/kvm/psci.c b/arch/arm64/kvm/psci.c index d24ccc77500b..0b1b588f1f9b 100644 --- a/arch/arm64/kvm/psci.c +++ b/arch/arm64/kvm/psci.c @@ -310,9 +310,6 @@ static int kvm_psci_1_x_call(struct kvm_vcpu *vcpu, u32 minor) unsigned long val; int ret = 1; - if (minor > 1) - return -EINVAL; - switch(psci_fn) { case PSCI_0_2_FN_PSCI_VERSION: val = minor == 0 ? KVM_ARM_PSCI_1_0 : KVM_ARM_PSCI_1_1;