Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1934086rwn; Fri, 9 Sep 2022 06:21:17 -0700 (PDT) X-Google-Smtp-Source: AA6agR4IUo3I/3+ui3bcb+XS9uudbpYKhQZcvgi1y1eAPGbF5dSB3Z/6KQuP/RVh+5ADJFAQ3Vm+ X-Received: by 2002:a17:907:1c89:b0:734:d05c:582e with SMTP id nb9-20020a1709071c8900b00734d05c582emr9977488ejc.282.1662729677255; Fri, 09 Sep 2022 06:21:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662729677; cv=none; d=google.com; s=arc-20160816; b=vc3AFxWEdPgCKB8M7YTUzRY10zRhdXPuPuBA087VcGP0VOtgdYIyzcHNMt5CuIPgZE 5+QaZtojbOf6poWORD5AWEdZU2EdLzzZDIrjwQs/YiVVAPanbkeB+A9l/ilC/AmWIVZ/ tlQ5GAJWzhvHOoke2Tu6ffWyHnVinO4eHo/2vmNGWtcO276LLVTI+r7t4BRvjP7w9ZUO th3VYu387QKoFnb0NZv7EMvsda7T3BFwao7Vxq1xDBfo/mylYw3HOkhom/omFfWXuNSg 6kI1cnLX+S3b6yFPuMarZsDhsrl5p8O3FsICyToiy/YQlIBBX3nj0EKgWwK4+4iiT9+k I3nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:user-agent :references:in-reply-to:subject:cc:to:from:date:mime-version :dkim-signature; bh=o6+pqFCCR9KFwUWWFy7mAAEsPsVpr5GFfye4e+JeXaw=; b=DaW3dacY4kiviBjPx9Gmdyni7VFKo3yJeQE81SiVYeTPt3Akqzzm/kP46VjTuW0nM3 e1oLFxsD06i1AefrC5kWG/jbEDwjq11XJFdOcKku1lOelAyqIWOjppC9l94LL2+U/EJC m8tHPSZQOKpEXYydmOxAffEGESC3fH0sHPjO6OPnvQkUt8y6NsErRE8nmQhhwzC3Ekqf 0i8YU1MUUc6canDlXpaYp4AD6JuA+6SdVT64UVKoOm3ZHsxSEUXYB+bD5HC2jpStuPr1 5a6d+/GgeTZnzKu56eT2ffnMpV4Jb++gs7MaqtHN406JUIOPH/cnheKuDJ2aNJ4+szy5 5eag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HVMWq27r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r13-20020a05640251cd00b0044f2fb68fe6si462870edd.495.2022.09.09.06.20.51; Fri, 09 Sep 2022 06:21:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HVMWq27r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231555AbiIIMro (ORCPT + 99 others); Fri, 9 Sep 2022 08:47:44 -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 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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...