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 56A2FECAAA1 for ; Fri, 9 Sep 2022 12:47:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229986AbiIIMrp (ORCPT ); Fri, 9 Sep 2022 08:47:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229486AbiIIMrl (ORCPT ); Fri, 9 Sep 2022 08:47:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6452E128C19 for ; Fri, 9 Sep 2022 05:47:38 -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 96CA461FD8 for ; Fri, 9 Sep 2022 12:47:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 012B9C433D7; Fri, 9 Sep 2022 12:47:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662727657; bh=8Iwo+623tVRzD2r3vitAeyrtiK1yPqT3anVJSO2QxeU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=HVMWq27rMWjzFRjQBSNAD3qRkTHd7Y0T6effGiKvHeS8XFp2qBogFa96RrHaXuD4N ydUipwlHUvfHcKeE4v0ZAdfdtD+zqnKJGbLhwXRRPEMTRRbWtNOMp5A8vqqBv2CLc9 +NC6pQ3udz//0LQNMphNEw3QxFY+5Kni2XA99rKRVtW8xcTu7RwUqtc9GqBMMQy7v7 PZBy/SsvEogbP9A6d6qbMBYsmj/vHK5XLK4qibz99ycfSwDr4Olzod7NxZ6b3t0oIT EmPyzHkuMih687aiVYMJF9IkXJq2slByeQv56EWavPfEnLPs2yYACqvOPppCWjiqfI UjCT1NnFUeEWg== Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oWdPy-009BXu-Pl; Fri, 09 Sep 2022 13:47:34 +0100 MIME-Version: 1.0 Date: Fri, 09 Sep 2022 13:47:34 +0100 From: Marc Zyngier To: Catalin Marinas Cc: Elliot Berman , Will Deacon , 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 In-Reply-To: References: <20220902040122.346654-1-quic_eberman@quicinc.com> User-Agent: Roundcube Webmail/1.4.13 Message-ID: <485617e0d3635c1961ab30c1ad930c81@kernel.org> X-Sender: maz@kernel.org Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: catalin.marinas@arm.com, quic_eberman@quicinc.com, will@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, dbrazdil@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-09-09 13:44, Catalin Marinas wrote: > 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()? That's be indeed preferable. Thanks, M. -- Jazz is not dead. It just smells funny...