All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Elliot Berman <quic_eberman@quicinc.com>,
	linux-kernel@vger.kernel.org, Will Deacon <will@kernel.org>,
	kvmarm@lists.cs.columbia.edu,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] KVM: arm64: Report Protected KVM cap only if KVM is enabled
Date: Fri, 09 Sep 2022 13:47:34 +0100	[thread overview]
Message-ID: <485617e0d3635c1961ab30c1ad930c81@kernel.org> (raw)
In-Reply-To: <Yxs1H3+iI8Y7+Zbu@arm.com>

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 <will@kernel.org>
>> Cc: David Brazdil <dbrazdil@google.com>
>> Cc: Marc Zyngier <maz@kernel.org>
>> Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
>> ---
>>  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...
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Elliot Berman <quic_eberman@quicinc.com>,
	Will Deacon <will@kernel.org>, James Morse <james.morse@arm.com>,
	Alexandru Elisei <alexandru.elisei@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
	David Brazdil <dbrazdil@google.com>
Subject: Re: [PATCH] KVM: arm64: Report Protected KVM cap only if KVM is enabled
Date: Fri, 09 Sep 2022 13:47:34 +0100	[thread overview]
Message-ID: <485617e0d3635c1961ab30c1ad930c81@kernel.org> (raw)
In-Reply-To: <Yxs1H3+iI8Y7+Zbu@arm.com>

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 <will@kernel.org>
>> Cc: David Brazdil <dbrazdil@google.com>
>> Cc: Marc Zyngier <maz@kernel.org>
>> Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
>> ---
>>  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...

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Elliot Berman <quic_eberman@quicinc.com>,
	Will Deacon <will@kernel.org>, James Morse <james.morse@arm.com>,
	Alexandru Elisei <alexandru.elisei@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
	David Brazdil <dbrazdil@google.com>
Subject: Re: [PATCH] KVM: arm64: Report Protected KVM cap only if KVM is enabled
Date: Fri, 09 Sep 2022 13:47:34 +0100	[thread overview]
Message-ID: <485617e0d3635c1961ab30c1ad930c81@kernel.org> (raw)
In-Reply-To: <Yxs1H3+iI8Y7+Zbu@arm.com>

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 <will@kernel.org>
>> Cc: David Brazdil <dbrazdil@google.com>
>> Cc: Marc Zyngier <maz@kernel.org>
>> Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
>> ---
>>  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...

  reply	other threads:[~2022-09-09 12:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-02  4:01 [PATCH] KVM: arm64: Report Protected KVM cap only if KVM is enabled Elliot Berman
2022-09-02  4:01 ` Elliot Berman
2022-09-02  4:01 ` Elliot Berman
2022-09-09 12:44 ` Catalin Marinas
2022-09-09 12:44   ` Catalin Marinas
2022-09-09 12:44   ` Catalin Marinas
2022-09-09 12:47   ` Marc Zyngier [this message]
2022-09-09 12:47     ` Marc Zyngier
2022-09-09 12:47     ` Marc Zyngier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=485617e0d3635c1961ab30c1ad930c81@kernel.org \
    --to=maz@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_eberman@quicinc.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.