Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1895747rwn; Fri, 9 Sep 2022 05:52:28 -0700 (PDT) X-Google-Smtp-Source: AA6agR48qLSlAT6gulsbuGbSCagCY56+gTLQRwXPFC6WNpyAmNah6wQjTCQpJs5WLrH7qfOeYU3A X-Received: by 2002:a63:982:0:b0:434:aafc:fc60 with SMTP id 124-20020a630982000000b00434aafcfc60mr12099242pgj.551.1662727948493; Fri, 09 Sep 2022 05:52:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662727948; cv=none; d=google.com; s=arc-20160816; b=gWvYK3HqMOUhYgTvPIQEhGHUbhlDUYlTZyQxU1Eo0eWxMV5ToP5XC7OhFA5J0AFWem umG753e9v/LW+f858scwoPYglNnlITLQ/rjCYPKQ4yrAz3DsBwP/wiq/9YzSBS7FdH8T ByOhyPooRI5dHPD9sedKn4efqCJ6cJ8/RCydj/ohfQvwsx9ucbFpIzT1M5S0BTS15J1c bmKRVXvuC0YlZUpQQ8EQAgTG/3LonygJYremxERI6LdpKwZZCz4gwx86t995DdOejAoV nk62RSC1lfy0gHSviLbnNCWAVTngsjcl6aa+26zeJgM7Q4E7X5uUw2xffB2kETL+8V79 S0gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=yovKVaDuLJnNM7nJMyqIbwapIeQWeEd7Qk4gWoogit4=; b=nWEYuhCK0/1AuezuU+LSQTXnzhZZTNVM57rOajDg3wLLiJwMrlzXou+OWo4xdnLsZ1 Z3Qw8Sx2h4bady+Gb/ocMP2542ZcBUeNlFT1jGmwzPZhMB7xchqVm71tMy8mr6PeVWT4 QYg5EEp2+YvtBA20osoylWnuwRSKb+vbj4pVqIot0vLMFeOqsW7qfYumqxk3dW6fcgmE ndu7U5QctVdpQ2e4GWAGlq33y6rgQ2qPy2zzwCPb5SGQ8pDa5b6LwWKg02xnURxts8l4 bgjLZPaXAFWwhtuz74tIHy3Cf4iWR2pWx5km6Iyig+zhWT/BgxURAiXvOmXpl+xIVIpA bIOQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i3-20020a170902cf0300b00176d79dd436si507642plg.192.2022.09.09.05.52.16; Fri, 09 Sep 2022 05:52:28 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231649AbiIIMo0 (ORCPT + 99 others); Fri, 9 Sep 2022 08:44:26 -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> X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,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 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