Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp3222955rwn; Sat, 10 Sep 2022 07:24:51 -0700 (PDT) X-Google-Smtp-Source: AA6agR56W3V3b+sfeACwXNy4knH6jCOwVZkEOXtEsL32q8w7NvlPB153DKXgKKC1LaGaHdiYYRoQ X-Received: by 2002:a17:90b:1894:b0:200:b12e:9db0 with SMTP id mn20-20020a17090b189400b00200b12e9db0mr14591619pjb.219.1662819891310; Sat, 10 Sep 2022 07:24:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662819891; cv=none; d=google.com; s=arc-20160816; b=CIBfZDeOrovQOWAMxqyZmPbp7vBm40hhm8y9CITZavXVkYNdn4fkyc5JWxWG7qZhr+ WgkvxpwwPNdOdOxpmBZWRCWc80N+riTMByEA9GSwUlqTwYHj0jo7UqSbpMR0HFwhw6Wt 0gzNbvqGihBYRQPIRLlX4T9Y3N2rqWwgWRg+CN6GsfOXnsBRl8YgJY43JyhsBgX99Dtj XHi9XEXN01lxRNP2OK2PoBOShXIaBbPy+kLTeUoTGFHQ760Kch9Y3837qs+ruM/fdaam wVXFnbI6YCZ9nYSnaM2GFfVHuZ/Sh9Dy8IO/+hSSmnCg7XEO8dH5ypusGgkpKGNhQm2F 8Wyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=L1Rft148x8jGTwyHoI7HFn4MKN+BiCEo/TaugrzHqC4=; b=R6auioWOYaoqMY/Rt5DdUWezRA4yuU4Z+rPnLRSu2h87Y6n78SJZfgUfSJqJSyjG8b YJmPzG06Q9lIwFghfek9qSu9mZ9nGEzrcaiQdDMRRFxAmFeS2tGABY929FtwK+BTbHN2 N7XRIj6iRR2FAQRZZqOvS8J/VNQ+PeMbk0Ibx4cl5MOUirM1Wwb5TI8PWiCE0Q8tKDtg jOBnVlYz9RXAwWIwBzzgg2Z+MTlEGi7c6loJql9HAh+5YBVsKxRaQWAJQbv+rjm2Q95w A726ZEBvfoLO64SnEYhXz1GEoX2wt5gxguxlgY3b24Iv/rwmpVcUynZjWFv4wji3elHl Q7cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Y2L6TAeE; 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 e25-20020a62aa19000000b0052f44beb0d1si2324874pff.291.2022.09.10.07.24.38; Sat, 10 Sep 2022 07:24:51 -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=Y2L6TAeE; 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 S229563AbiIJOUm (ORCPT + 99 others); Sat, 10 Sep 2022 10:20:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229549AbiIJOUk (ORCPT ); Sat, 10 Sep 2022 10:20:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E51365208F for ; Sat, 10 Sep 2022 07:20: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 4795060C59 for ; Sat, 10 Sep 2022 14:20:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A03B6C433D6; Sat, 10 Sep 2022 14:20:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662819637; bh=jtLoTUmzkJ28HBfAIdRhrITf/Pt98gaT25ffER4L1Zg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Y2L6TAeE7bTtjKAjjbCb02y30jqC4k746YIQuIYasaKbR3Nhwt/2GroO/mWwCmAJV Jr6WbYaecTzQboH2+lwF/B+IMRbaJJ8p8xFc8TYEE2OoOgnwUJw8parus0Up5F9eZo KUel8MVI6oqnx3DbWRnZrZ1dvNKvkWtetIBxPWlJ5VH9hvCnzaXHEg2MxiKpIWV5Cn FmpsrIxyVnKZTLh8bW8r4xSl/q5dk4IvVFNihUGawMvcq8hdhpzB0KoaZ3354BzVaO i+Xi3DSchx2ShW39yEJKhRTV9dlNwDJBtgs0A0bLHG+m0e/R2JzGc/lcjUqieERwqz hbUetZ+gXip9g== Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oX1LX-009PO7-Bn; Sat, 10 Sep 2022 15:20:35 +0100 Date: Sat, 10 Sep 2022 15:20:35 +0100 Message-ID: <871qsjqpjg.wl-maz@kernel.org> From: Marc Zyngier To: Will Deacon Cc: Elliot Berman , Catalin Marinas , James Morse , Alexandru Elisei , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu Subject: Re: [PATCH v2] KVM: arm64: Only set KVM_MODE_PROTECTED if is_hyp_mode_available() In-Reply-To: <20220910134342.GA959@willie-the-truck> References: <20220909144552.3000716-1-quic_eberman@quicinc.com> <05057e2a-1a85-69ba-ffcd-584d4090467a@quicinc.com> <878rmrr3xw.wl-maz@kernel.org> <20220910134342.GA959@willie-the-truck> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: will@kernel.org, quic_eberman@quicinc.com, catalin.marinas@arm.com, 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 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 Sat, 10 Sep 2022 14:43:44 +0100, Will Deacon wrote: > > On Sat, Sep 10, 2022 at 10:09:31AM +0100, Marc Zyngier wrote: > > On Fri, 09 Sep 2022 18:55:18 +0100, > > Elliot Berman wrote: > > > > > > > > > > > > On 9/9/2022 10:28 AM, Catalin Marinas wrote: > > > > On Fri, Sep 09, 2022 at 07:45:52AM -0700, Elliot Berman wrote: > > > >> Do not switch kvm_mode to KVM_MODE_PROTECTED if hypervisor mode is not > > > >> available. This prevents "Protected KVM" cpu capability being reported > > > >> when Linux is booting in EL1 and would not have KVM enabled. > > > >> > > > >> Signed-off-by: Elliot Berman > > > >> --- > > > >> arch/arm64/kvm/arm.c | 4 +++- > > > >> 1 file changed, 3 insertions(+), 1 deletion(-) > > > >> > > > >> diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > > > >> index 8fe73ee5fa84..861f4b388879 100644 > > > >> --- a/arch/arm64/kvm/arm.c > > > >> +++ b/arch/arm64/kvm/arm.c > > > >> @@ -2272,7 +2272,9 @@ static int __init early_kvm_mode_cfg(char *arg) > > > >> return -EINVAL; > > > >> if (strcmp(arg, "protected") == 0) { > > > >> - if (!is_kernel_in_hyp_mode()) > > > >> + if (!is_hyp_mode_available()) > > > >> + kvm_mode = KVM_MODE_DEFAULT; > > > > > > > > I think kvm_mode is already KVM_MODE_DEFAULT at this point. You may want > > > > to print a warning instead. > > > > > > > > > > Does it make sense to print warning for kvm-arm.mode=nvhe as well? > > > > In general, specifying a kvm-arm.mode when no hypervisor mode is > > available should be reported as a warning. > > As long as this is pr_warn() rather than WARN() then I agree. Otherwise, > kernels with a kvm-arm.mode hardcoded in CONFIG_CMDLINE (e.g. Android's > GKI) will make for noisy guests. Indeed, pr_warn() is what I had in mind. A WARN() would be pretty overkill, as there is nothing majorly wrong with booting at EL1, just an impossibility to honour the request from the command line. M. -- Without deviation from the norm, progress is not possible.