From patchwork Fri Mar 18 19:38: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: 12785856 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 32904C433F5 for ; Fri, 18 Mar 2022 19:40:38 +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:Mime-Version: Message-Id:Date: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=b1yXEx2cNNvTQzbSg0iAdb23m6rDzpbQUeHutKG8I04=; b=i3P GKBHZ9lCV5LNDcRGh8RD2myS1dSgTkhsndkRmuHWjktL+FILx0i2YegkCuOoyvtnckdeC2qfJCeBw dFks8Ulm6SJJxjtA9N8oLq1E2sAkOMIoDIEd1f4JxAjhPYIbLn7Q3VyGvHj0OTNEOudSFdhBzQGj4 FG2AebdzcnmMh7jUISV6sUJLcL+rP7JvqfNX8B8CyJeeTQom3qnjVwdGaNmKcvDHj+7XWp6SqrQAz /uWiTUhEMFaSY9RDSzoR8q1rwNCMrcv/PS1Nch4qTWpyHojSzQy4VrGmGqbb5imISiW9vkm1cueTY adQsSGtN/m4sklcqB+rglqKH+tCzyUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nVIRh-002hAS-Kn; Fri, 18 Mar 2022 19:39:33 +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 1nVIRA-002gyB-Jm for linux-arm-kernel@lists.infradead.org; Fri, 18 Mar 2022 19:39:02 +0000 Received: by mail-io1-xd4a.google.com with SMTP id e11-20020a5d8e0b000000b006412cf3f627so5679431iod.17 for ; Fri, 18 Mar 2022 12:38:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=H8l1nRqzc+GH0BYge+CcpqHIz0FnRWt0KDTVYGKXJUU=; b=bY3JkUnzKDMAFmYEofE7g0/RUbdybRqH8McyL3QCx/wwKqxP1R9oyMHfVxLU5Rn4au FQ01pJ+bKjV63b/BCTyaEsUMyYtRT80x+3wKXVcME/neBa76g27i9HbIvWdUltAeJHcy JCCC8QEiBVS0FlkELwjk1JW6HbLmmjbCn8gjott5uKeZYtMyOpS4gbqEQ9OHhjb1RMDG v9D3fEDlSHu0jaYcfOcoEHaZs/YaN6yiFk21fcmdpWc4tqQMHlb0VVEr9ERPjBnN7Pxh gv6Wr+muHYlEezdujn0d4ObZu+RHGGZAOpm7c8GEGOmAA+JbioAndNxPLUuDwMUFCuEe SzzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=H8l1nRqzc+GH0BYge+CcpqHIz0FnRWt0KDTVYGKXJUU=; b=Nl5Zr+pNiaj9vdNrEZeyUMYMWyMT+9IGDp11ptzSCFscb+wnOHcknZsjsFZBXPneE3 uMgxwY4BuoefaSwR8pZz0TXjliQCl4vcpLVqvSvKP3yc8h0MXfl+AnjmOHkqD/cjkc9V ZlLA4IQcBnzsvMTOgHf9h2CYOuZeaGr7TLHqnousoNqjXsycqn3l5n3NZm9gsZdpN6sx tcW8KzeIL1M3eKZrbt62bn3HUIP4c+IKYi4eU9wwe4oENxSvomkMY09EXNf9s6+RWRFY LBCm7xZyz1Fmf7N3UaqhyeQdGkXcGby29S5d2Vei1Kaf9koE00PcsnPfqQWSF+VqsMhN gpoA== X-Gm-Message-State: AOAM531LtCVd1hpld3zsFWgZh7jsEKOaVUbtBaW1hQTDKptoJ3RP1Xht Hc9gmTSSE43hymdIhJ8tZ9cHcmhMfV8= X-Google-Smtp-Source: ABdhPJyFMO/w4ywussCXIJDpEfAaloVYed9xixsAdo9QBRfZRiXxwrIxNYxqhyOTk46we5JCHvMjyNz5a4k= X-Received: from oupton.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:404]) (user=oupton job=sendgmr) by 2002:a92:ca08:0:b0:2c7:f1c6:3377 with SMTP id j8-20020a92ca08000000b002c7f1c63377mr3395684ils.28.1647632330197; Fri, 18 Mar 2022 12:38:50 -0700 (PDT) Date: Fri, 18 Mar 2022 19:38:29 +0000 Message-Id: <20220318193831.482349-1-oupton@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.35.1.894.gb6a874cedc-goog Subject: [PATCH 0/2] KVM: arm64: Fixes for SMC64 SYSTEM_RESET2 calls 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-20220318_123900_661119_4981E98C X-CRM114-Status: GOOD ( 10.30 ) 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 This series addresses a couple of issues with how KVM exposes SMC64 calls to its guest. It is currently possible for an AArch32 guest to discover the SMC64 SYSTEM_RESET2 function (via PSCI_1_0_FN_PSCI_FEATURES) and even make a call to it. SMCCC does not allow for 64 bit calls to be made from a 32 bit state. Patch 1 cleans up the way we filter SMC64 calls in PSCI. Using a switch with case statements for each possibly-filtered function is asking for trouble. Instead, pivot off of the bit that indicates the desired calling convention. This plugs the PSCI_FEATURES hole for SYSTEM_RESET2. Patch 2 adds a check to the PSCI v1.x call handler in KVM, bailing out early if the guest is not allowed to use a particular function. This closes the door on calls to 64-bit SYSTEM_RESET2 from AArch32. My first crack at this [1] was missing the fix for direct calls to SYSTEM_RESET2. Taking the patch out of that series and sending separately. Applies on top of today's kvmarm pull, commit: 21ea45784275 ("KVM: arm64: fix typos in comments") [1]: https://patchwork.kernel.org/project/kvm/patch/20220311174001.605719-3-oupton@google.com/ Oliver Upton (2): KVM: arm64: Generally disallow SMC64 for AArch32 guests KVM: arm64: Actually prevent SMC64 SYSTEM_RESET2 from AArch32 arch/arm64/kvm/psci.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) Acked-by: Will Deacon