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 X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A824C47082 for ; Mon, 7 Jun 2021 19:30:03 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 201E261001 for ; Mon, 7 Jun 2021 19:30:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 201E261001 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GhGsgryvxqROpOyJ8awe+T+vsczuo2UYLvzSc+7XOs8=; b=Z/yrDEurT3qzI8 Z0Y57i5cAb+H+UjNAA3T06A8ZzqO6Jc1xhxZRg8ymxTrP8DzfK3vBqqPOn7Er6PEtAzNLDqIu9zOw iGrywCcei/V3BW3IUUKkmUA1GwF/cLqUJ1WNG8UAb9htgZ+cfAejoD0y8voJDVP5KexWelPMS4itd kKCoLRmcRPGns+9eS8j3xaH2/h8mD3+uufJy7ElsxO0JRUIM298k3hikytqYr8niCLnfqq4VVD7jn dskQP4cGYRZqKC+Tkirc3jWXkXnQRhTSZTNyNSc3HAIj8oNaB4B9LQEZ8BaCsXWkDyCp2eKtDjbAI WYDCHs++eaMnoYgsmUvA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqKvD-005B1W-PH; Mon, 07 Jun 2021 19:28:27 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqKvA-005B1A-Ts for linux-arm-kernel@lists.infradead.org; Mon, 07 Jun 2021 19:28:26 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 53433610E7; Mon, 7 Jun 2021 19:28:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623094104; bh=LgMVcXHCCZU1jYKLjL4s5tdikm1++Ag5rp8bnWWw3lE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=g/tE2FBq7fiZ7DeyFtkCLJgQkpMjzxLkRQjgPuKLy5ypbUnd25TCSPOrsAVFYPXOE 5tCsqbGyEn5D2Ui856zBHz0kh1PacpRxrFlpYpTcY2KSwWHewJNH3ffXWyu6TYuzFl YatR/862y2R+Qmj8R9Kiou+zGCJXfHsFx2490HUHCrGqTv8OEpXfSzJjGZIHzZEACt K7Tw0F0i8ZYTgh6ARZ9b+tX41CtivZqpI9SdJQVmNf9UBb1fWp8u7PHXQA9XvpptaM Dtv95JMfcK/BBjx/Woi+DnMMAu954VAV/pyucIzW7JA8rLz+FUCY+6pPu8t/1RMl1l cYqHZYN/buthw== Date: Mon, 7 Jun 2021 20:28:18 +0100 From: Will Deacon To: Mark Rutland Cc: kvmarm@lists.cs.columbia.edu, Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Christoffer Dall , Paolo Bonzini , Fuad Tabba , Quentin Perret , Sean Christopherson , David Brazdil , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 1/4] KVM: arm64: Ignore 'kvm-arm.mode=protected' when using VHE Message-ID: <20210607192818.GA7929@willie-the-truck> References: <20210603183347.1695-1-will@kernel.org> <20210603183347.1695-2-will@kernel.org> <20210604140117.GA69333@C02TD0UTHF1T.local> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210604140117.GA69333@C02TD0UTHF1T.local> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210607_122825_019201_B79A4D07 X-CRM114-Status: GOOD ( 23.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jun 04, 2021 at 03:01:17PM +0100, Mark Rutland wrote: > On Thu, Jun 03, 2021 at 07:33:44PM +0100, Will Deacon wrote: > > Ignore 'kvm-arm.mode=protected' when using VHE so that kvm_get_mode() > > only returns KVM_MODE_PROTECTED on systems where the feature is available. > > IIUC, since the introduction of the idreg-override code, and the > mutate_to_vhe stuff, passing 'kvm-arm.mode=protected' should make the > kernel stick to EL1, right? So this should only affect M1 (or other HW > with a similar impediment). It's not just about the M1, unfortunately. You can boot with: "kvm-arm.mode=protected id_aa64mmfr1.vh=1" which will force VHE mode, so we should fail protected mode in that case. > One minor comment below; otherwise: > > Acked-by: Mark Rutland Thanks, I'll keep the tag but please yell if you want me to drop it. > > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > > index efed2830d141..dc1f2e747828 100644 > > --- a/arch/arm64/kernel/cpufeature.c > > +++ b/arch/arm64/kernel/cpufeature.c > > @@ -1773,15 +1773,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) > > { > > - if (kvm_get_mode() != KVM_MODE_PROTECTED) > > - return false; > > - > > - if (is_kernel_in_hyp_mode()) { > > - pr_warn("Protected KVM not available with VHE\n"); > > - return false; > > - } > > - > > - return true; > > + return kvm_get_mode() == KVM_MODE_PROTECTED; > > } > > #endif /* CONFIG_KVM */ > > > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > > index 1cb39c0803a4..8d5e23198dfd 100644 > > --- a/arch/arm64/kvm/arm.c > > +++ b/arch/arm64/kvm/arm.c > > @@ -2121,7 +2121,11 @@ static int __init early_kvm_mode_cfg(char *arg) > > return -EINVAL; > > > > if (strcmp(arg, "protected") == 0) { > > - kvm_mode = KVM_MODE_PROTECTED; > > + if (!is_kernel_in_hyp_mode()) > > + kvm_mode = KVM_MODE_PROTECTED; > > + else > > + pr_warn_once("Protected KVM not available with VHE\n"); > > ... assuming this is only for M1, it might be better to say: > > Protected KVM not available on this hardware > > ... since that doesn't suggest that other VHE-capable HW is also not > PKVM-capable. I'm just moving the existing string here, but as above, it's not M1 specific. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel