From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7980ECAAD3 for ; Fri, 9 Sep 2022 12:44:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231675AbiIIMo1 (ORCPT ); Fri, 9 Sep 2022 08:44:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229765AbiIIMoY (ORCPT ); Fri, 9 Sep 2022 08:44:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52149E3 for ; Fri, 9 Sep 2022 05:44:22 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id E078061FD8 for ; Fri, 9 Sep 2022 12:44:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73FCDC433D6; Fri, 9 Sep 2022 12:44:19 +0000 (UTC) Date: Fri, 9 Sep 2022 13:44:15 +0100 From: Catalin Marinas To: Elliot Berman Cc: Will Deacon , Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, David Brazdil Subject: Re: [PATCH] KVM: arm64: Report Protected KVM cap only if KVM is enabled Message-ID: References: <20220902040122.346654-1-quic_eberman@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220902040122.346654-1-quic_eberman@quicinc.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 01, 2022 at 09:01:22PM -0700, Elliot Berman wrote: > If "kvm-arm.mode=protected" is present on kernel command line, but the > kernel doesn't actually support KVM because it booted from EL1, the > ARM64_KVM_PROTECTED_MODE capability is misleadingly reported as present. > Fix this by adding a check whether we booted from EL2. > > Cc: Will Deacon > Cc: David Brazdil > Cc: Marc Zyngier > Signed-off-by: Elliot Berman > --- > arch/arm64/kernel/cpufeature.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > index 8d88433de81d..866667be0651 100644 > --- a/arch/arm64/kernel/cpufeature.c > +++ b/arch/arm64/kernel/cpufeature.c > @@ -1974,7 +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) > { > - return kvm_get_mode() == KVM_MODE_PROTECTED; > + return is_hyp_mode_available() && kvm_get_mode() == KVM_MODE_PROTECTED; > } > #endif /* CONFIG_KVM */ Could we not fix this in early_kvm_mode_cfg()? -- Catalin