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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 EB75BC07E94 for ; Fri, 4 Jun 2021 14:01:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD67F61406 for ; Fri, 4 Jun 2021 14:01:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230209AbhFDODP (ORCPT ); Fri, 4 Jun 2021 10:03:15 -0400 Received: from foss.arm.com ([217.140.110.172]:39748 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230124AbhFDODP (ORCPT ); Fri, 4 Jun 2021 10:03:15 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 706D82B; Fri, 4 Jun 2021 07:01:28 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.6.137]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 27BBE3F774; Fri, 4 Jun 2021 07:01:24 -0700 (PDT) Date: Fri, 4 Jun 2021 15:01:17 +0100 From: Mark Rutland To: Will Deacon 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: <20210604140117.GA69333@C02TD0UTHF1T.local> References: <20210603183347.1695-1-will@kernel.org> <20210603183347.1695-2-will@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210603183347.1695-2-will@kernel.org> Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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). One minor comment below; otherwise: Acked-by: Mark Rutland > > Cc: David Brazdil > Signed-off-by: Will Deacon > --- > Documentation/admin-guide/kernel-parameters.txt | 1 - > arch/arm64/kernel/cpufeature.c | 10 +--------- > arch/arm64/kvm/arm.c | 6 +++++- > 3 files changed, 6 insertions(+), 11 deletions(-) > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > index cb89dbdedc46..e85dbdf1ee8e 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -2300,7 +2300,6 @@ > > protected: nVHE-based mode with support for guests whose > state is kept private from the host. > - Not valid if the kernel is running in EL2. > > Defaults to VHE/nVHE based on hardware support. > > 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. Thanks, Mark. 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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 18E3FC07E94 for ; Fri, 4 Jun 2021 14:01:43 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 83F0960FE7 for ; Fri, 4 Jun 2021 14:01:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83F0960FE7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id F22714B0FB; Fri, 4 Jun 2021 10:01:41 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kIzOU57QmCAr; Fri, 4 Jun 2021 10:01:36 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 8B5854B0E9; Fri, 4 Jun 2021 10:01:36 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 2B5DC4B0D8 for ; Fri, 4 Jun 2021 10:01:35 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WMMY-8I9HUnM for ; Fri, 4 Jun 2021 10:01:28 -0400 (EDT) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mm01.cs.columbia.edu (Postfix) with ESMTP id DB2B54B09E for ; Fri, 4 Jun 2021 10:01:28 -0400 (EDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 706D82B; Fri, 4 Jun 2021 07:01:28 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.6.137]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 27BBE3F774; Fri, 4 Jun 2021 07:01:24 -0700 (PDT) Date: Fri, 4 Jun 2021 15:01:17 +0100 From: Mark Rutland To: Will Deacon Subject: Re: [PATCH 1/4] KVM: arm64: Ignore 'kvm-arm.mode=protected' when using VHE Message-ID: <20210604140117.GA69333@C02TD0UTHF1T.local> References: <20210603183347.1695-1-will@kernel.org> <20210603183347.1695-2-will@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210603183347.1695-2-will@kernel.org> Cc: kvm@vger.kernel.org, Marc Zyngier , linux-arm-kernel@lists.infradead.org, Sean Christopherson , Paolo Bonzini , kvmarm@lists.cs.columbia.edu X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu 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). One minor comment below; otherwise: Acked-by: Mark Rutland > > Cc: David Brazdil > Signed-off-by: Will Deacon > --- > Documentation/admin-guide/kernel-parameters.txt | 1 - > arch/arm64/kernel/cpufeature.c | 10 +--------- > arch/arm64/kvm/arm.c | 6 +++++- > 3 files changed, 6 insertions(+), 11 deletions(-) > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > index cb89dbdedc46..e85dbdf1ee8e 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -2300,7 +2300,6 @@ > > protected: nVHE-based mode with support for guests whose > state is kept private from the host. > - Not valid if the kernel is running in EL2. > > Defaults to VHE/nVHE based on hardware support. > > 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. Thanks, Mark. _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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=-14.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 9DEE2C4708F for ; Fri, 4 Jun 2021 14:03:17 +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 6821F61404 for ; Fri, 4 Jun 2021 14:03:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6821F61404 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com 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=3w3LYJgroKMopqSPqwqhnRLHCs8ghvfbpAq4ERgE33s=; b=2+nRVJy5epZ5sl /QE/j+S5bg3e9nF1Qt0UWmziZpoUWvbq2rXcuNroPSJSxuz66iUNCvhKMYXnyUlnSwXksukgFxF4Y P9mqc5N5XZIa4NqLAHujfHmfR5GDKxViANCm0PU3rer7HSF/6Ef5DIE1jb0D+93y30r7Yd8EMBzFh edeabhLvBp2+v0dP3bzXXS5hNB0+KxxPH8qYNT8oKl4RVA8nW7tjzBjK1Vub/jpipiJgX3opV3hwk AX7fpjxb1g0yk39eMTd0YwoxrjCKYWa7lOWCec7K9Oj7SG4TQwDv+f77HuE0xUUpOwWXCwvUUSgdz YR0mkfAHbchYMneiQK7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lpAOI-00DpRR-To; Fri, 04 Jun 2021 14:01:39 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lpAOB-00DpQF-4J for linux-arm-kernel@lists.infradead.org; Fri, 04 Jun 2021 14:01:35 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 706D82B; Fri, 4 Jun 2021 07:01:28 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.6.137]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 27BBE3F774; Fri, 4 Jun 2021 07:01:24 -0700 (PDT) Date: Fri, 4 Jun 2021 15:01:17 +0100 From: Mark Rutland To: Will Deacon 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: <20210604140117.GA69333@C02TD0UTHF1T.local> References: <20210603183347.1695-1-will@kernel.org> <20210603183347.1695-2-will@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210603183347.1695-2-will@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210604_070131_293273_267C002E X-CRM114-Status: GOOD ( 23.39 ) 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 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). One minor comment below; otherwise: Acked-by: Mark Rutland > > Cc: David Brazdil > Signed-off-by: Will Deacon > --- > Documentation/admin-guide/kernel-parameters.txt | 1 - > arch/arm64/kernel/cpufeature.c | 10 +--------- > arch/arm64/kvm/arm.c | 6 +++++- > 3 files changed, 6 insertions(+), 11 deletions(-) > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > index cb89dbdedc46..e85dbdf1ee8e 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -2300,7 +2300,6 @@ > > protected: nVHE-based mode with support for guests whose > state is kept private from the host. > - Not valid if the kernel is running in EL2. > > Defaults to VHE/nVHE based on hardware support. > > 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. Thanks, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel