From patchwork Thu Jun 9 12:12:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 12875483 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 71C3BC43334 for ; Thu, 9 Jun 2022 12:22:05 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EPO4E116VejiN8O3PhfKGgF89GZYtSHJhMBHr62QE9I=; b=R4Fl3+bGM+wyMP QthoB7BbVtEQf3/W0liRLbWRRSpGXLtcDBYr4UcAJH4zpLl0suonCS2aV8UlUnkCSsOpZqEA68Of+ /w5OOuaBCRY5TUDKnPceJkkZr+INgtwyGcIwZarWz8nPufEciThMUlbNNSdwO4N7P5EIP6gBIZ2uu UWDSYb5HzODsUerzD+Tnv/2Ohv343lwKa/RDUMu8maoGEMypu6CnYhnCjGLhQ6y5+S19510YCj4mt G8P9DXrn7QV8Mq76hzaBW2pxbinRpwyOkF8y5gd/3vsJWNVR47ngdIF0cKWExsVVvRq3FYmSEY1Xy jQehfCpBasvixmdtpB2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzH9i-001gdj-66; Thu, 09 Jun 2022 12:20:54 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzH1h-001cq1-Oc for linux-arm-kernel@lists.infradead.org; Thu, 09 Jun 2022 12:12:39 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6980FB82D52; Thu, 9 Jun 2022 12:12:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BD85C341C0; Thu, 9 Jun 2022 12:12:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654776755; bh=Mbdzwq+/LSDhpTjAr+4Im28oBh5q/AlLTEBka/3LM4M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I8YFNZU5ljPunq4/7iQewiGaxXNSBDeb41QAi5HBCpirWUELTNHwjvbXczz4649DS eHoJ1HkGSm3LdzAGw3Tp0pi9pOQZvI/0PJ22ad7svKf5mj3ExNiZPdBFvWyUKpkn1J ZuqRZRputXWqDysLVTxjUEX32xIetduM61YV0dWFRtYtc6I1Sh3kF232U10BtE8ekc dKh22ImSklI7NekFN5ob/O1bb04RszCwPbGbhZoyWqCiGoA3VuKh6ZjBeeGyT9S7EJ DPnbaN5rC5Oc7P/fkgVKrz3L9quoeNcgBg4jdsq7XbXcXgvR9zIcWJP8lZFR56hGsg am0Zh8ff5aczw== From: Will Deacon To: kvmarm@lists.cs.columbia.edu Cc: Will Deacon , Marc Zyngier , Alexandru Elisei , kernel-team@android.com, linux-arm-kernel@lists.infradead.org, David Brazdil , Mark Rutland Subject: [PATCH 3/6] KVM: arm64: Ignore 'kvm-arm.mode=protected' when using VHE Date: Thu, 9 Jun 2022 13:12:20 +0100 Message-Id: <20220609121223.2551-4-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220609121223.2551-1-will@kernel.org> References: <20220609121223.2551-1-will@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220609_051238_003016_402FBE10 X-CRM114-Status: GOOD ( 15.23 ) 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 Ignore 'kvm-arm.mode=protected' when using VHE so that kvm_get_mode() only returns KVM_MODE_PROTECTED on systems where the feature is available. Cc: David Brazdil Acked-by: Mark Rutland Signed-off-by: Will Deacon --- Documentation/admin-guide/kernel-parameters.txt | 1 - arch/arm64/kernel/cpufeature.c | 10 +--------- arch/arm64/kvm/arm.c | 6 +++++- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 8090130b544b..97c16aa2f53f 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2469,7 +2469,6 @@ protected: nVHE-based mode with support for guests whose state is kept private from the host. - Not valid if the kernel is running in EL2. Defaults to VHE/nVHE based on hardware support. Setting mode to "protected" will disable kexec and hibernation diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 42ea2bd856c6..79fac13ab2ef 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1974,15 +1974,7 @@ static void cpu_enable_mte(struct arm64_cpu_capabilities const *cap) #ifdef CONFIG_KVM static bool is_kvm_protected_mode(const struct arm64_cpu_capabilities *entry, int __unused) { - if (kvm_get_mode() != KVM_MODE_PROTECTED) - return false; - - if (is_kernel_in_hyp_mode()) { - pr_warn("Protected KVM not available with VHE\n"); - return false; - } - - return true; + return kvm_get_mode() == KVM_MODE_PROTECTED; } #endif /* CONFIG_KVM */ diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 0da0f06037db..a0188144a122 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -2273,7 +2273,11 @@ static int __init early_kvm_mode_cfg(char *arg) return -EINVAL; if (strcmp(arg, "protected") == 0) { - kvm_mode = KVM_MODE_PROTECTED; + if (!is_kernel_in_hyp_mode()) + kvm_mode = KVM_MODE_PROTECTED; + else + pr_warn_once("Protected KVM not available with VHE\n"); + return 0; }