From patchwork Tue Mar 22 18:35:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 12788934 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 3F84AC433F5 for ; Tue, 22 Mar 2022 18:37:12 +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=mFoQTiRwv7S+0vp0x9sTcBLfrkMl7zLk34M2lf8HFkU=; b=WOe 6Ci7fVCQ+B3g+VZqCu5xTSuAHehUap1q+OBiHyPlEPiCzYfkY+LlxMNh+xSQKrU96FRIwffCjxjUA 0Nkp7eTKJUbdIAZVNKaWNQ3C3582pHdAAWopoeirTiQ4KL6oNvT3dYiEmc20bYt1WI3OKin/+4zPi OYET5gZ+c+VRUELs3+XqCkDwFz2a4xMpJ6Nn1QzruFXkAP0+7DxuJ/5gkZxhdZJhpDwA8WXglf9lC TjOkXvqXWL5fnvGv0CaW7a03yAg7aoNyy4sL/gcPoinb+Caup9L2f4AUBo/4H1bweLMWrAOaHcJDp 7QPaNzb1z4qo28mml/TMhwHo83VD3dw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nWjMC-00Bsp5-Tj; Tue, 22 Mar 2022 18:35:49 +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 1nWjM9-00BsnZ-SG for linux-arm-kernel@lists.infradead.org; Tue, 22 Mar 2022 18:35:47 +0000 Received: by mail-oo1-xc4a.google.com with SMTP id z25-20020a4a6559000000b003247904266fso6497630oog.1 for ; Tue, 22 Mar 2022 11:35:44 -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=5SgsMWfo3s1L8LtQzUYqsFC2nGQvlmxjA5TrVXlNF5o=; b=NX/BKlXFUX08TaXDOkYcmlRKl5vaPl5VlRDyAV1k+AuDKOzI1MZXJ5+22dygCqBHx0 cndVmYMiBZ8nmrVLXS7wr6r6xMVjqUptm/oFwkxO8iNVzx+jkh9rRiaya/P07+3MpJ04 PJViSnNZvSINYM+HXpkl74vp6GVfLa5lg8R/MzRO2JEF9yr9GzaPdDsd1M4R7DOnsPnL GY4FOgGYGPB1d8cgw93lNLO7qXMe/gl/08vQDPIOX1VpM1MxuhjQ7CPtWAeOg9CIuqab h8WEqyqK+VHesnwGBityrclGfO6IJCwPfj6gqm7TZCeFBV2aliXaT2f3+d6CEFOzHXMT ycVg== 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=5SgsMWfo3s1L8LtQzUYqsFC2nGQvlmxjA5TrVXlNF5o=; b=LZ0acnXSJsQNjq95f89apOhoRk+gz0FF9qSI/ZZUsi+vaWhWP55A/9oSGkEee9OHfJ CWCrAm2oBCvzTwYBKD4XBgL3hBy/xDJrCG0V2D4aW8ne71TgRuhG4UDogPrFmj9MfSTW WNNwHqsF/7P4B7Yxj1e1rWtVwFe4cTibvDcxWoFpL3wC6ZM2+ntwCAeoN2TwPAg3+d4Q ueBnUB3z5ESHKZ4JBHZGEGvSWZbY5OGYoM3zMhVv8iAj3GiIcxgfyFCilvi52O48aC5n zCc9CggSg9bYl1Za/GVelL3oS1eydysagoqGh7GfD16qbsykd0Vtet5dIBp4Z7FfduyF DKHA== X-Gm-Message-State: AOAM5305uYJd7aefUq6kk0jXMTRPpuaKxbnZ74cDFe4S8tGcCG1J5vUW Lyg0Iv+Lf+O1hQFnyNUDr1ymeNrdkMc= X-Google-Smtp-Source: ABdhPJzHEAq3Ahy4FlfkKxUuOF9jkElOWpjOAJdQhPLkwUNZPQY2dc71XrglzJC9u5kFBcUHDcv+k9hh18A= X-Received: from oupton.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:404]) (user=oupton job=sendgmr) by 2002:a05:6808:1a97:b0:2ec:a246:ad01 with SMTP id bm23-20020a0568081a9700b002eca246ad01mr2796378oib.54.1647974143817; Tue, 22 Mar 2022 11:35:43 -0700 (PDT) Date: Tue, 22 Mar 2022 18:35:35 +0000 Message-Id: <20220322183538.2757758-1-oupton@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.35.1.894.gb6a874cedc-goog Subject: [PATCH v2 0/3] 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-20220322_113545_956942_F36EC702 X-CRM114-Status: GOOD ( 11.32 ) 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. Lastly, patch 3 is a nit to remove a superfluous check in the hopes of avoiding trouble the next time we raise KVM's PSCI version. Applies on top of kvmarm/next at commit: 21ea45784275 ("KVM: arm64: fix typos in comments") v1: http://lore.kernel.org/r/20220318193831.482349-1-oupton@google.com v1 -> v2: - Collect Acks and Reviews (Reiji, Will) - Hoist SMC64 filtering all the way up to kvm_psci_call() (Reiji) Oliver Upton (3): KVM: arm64: Generally disallow SMC64 for AArch32 guests KVM: arm64: Actually prevent SMC64 SYSTEM_RESET2 from AArch32 KVM: arm64: Drop unneeded minor version check from PSCI v1.x handler arch/arm64/kvm/psci.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-)