All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] KVM: arm64: Only set KVM_MODE_PROTECTED if is_hyp_mode_available()
@ 2022-09-09 14:45 ` Elliot Berman
  0 siblings, 0 replies; 17+ messages in thread
From: Elliot Berman @ 2022-09-09 14:45 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Marc Zyngier, James Morse,
	Alexandru Elisei, Suzuki K Poulose
  Cc: Elliot Berman, linux-arm-kernel, linux-kernel, kvmarm

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 <quic_eberman@quicinc.com>
---
 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;
+		else if (!is_kernel_in_hyp_mode())
 			kvm_mode = KVM_MODE_PROTECTED;
 		else
 			pr_warn_once("Protected KVM not available with VHE\n");

base-commit: 0982c8d859f8f7022b9fd44d421c7ec721bb41f9
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2] KVM: arm64: Only set KVM_MODE_PROTECTED if is_hyp_mode_available()
@ 2022-09-09 14:45 ` Elliot Berman
  0 siblings, 0 replies; 17+ messages in thread
From: Elliot Berman @ 2022-09-09 14:45 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Marc Zyngier, James Morse,
	Alexandru Elisei, Suzuki K Poulose
  Cc: Elliot Berman, linux-arm-kernel, linux-kernel, kvmarm

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 <quic_eberman@quicinc.com>
---
 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;
+		else if (!is_kernel_in_hyp_mode())
 			kvm_mode = KVM_MODE_PROTECTED;
 		else
 			pr_warn_once("Protected KVM not available with VHE\n");

base-commit: 0982c8d859f8f7022b9fd44d421c7ec721bb41f9
-- 
2.25.1


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

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2] KVM: arm64: Only set KVM_MODE_PROTECTED if is_hyp_mode_available()
@ 2022-09-09 14:45 ` Elliot Berman
  0 siblings, 0 replies; 17+ messages in thread
From: Elliot Berman @ 2022-09-09 14:45 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Marc Zyngier, James Morse,
	Alexandru Elisei, Suzuki K Poulose
  Cc: Elliot Berman, linux-kernel, linux-arm-kernel, kvmarm

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 <quic_eberman@quicinc.com>
---
 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;
+		else if (!is_kernel_in_hyp_mode())
 			kvm_mode = KVM_MODE_PROTECTED;
 		else
 			pr_warn_once("Protected KVM not available with VHE\n");

base-commit: 0982c8d859f8f7022b9fd44d421c7ec721bb41f9
-- 
2.25.1

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] KVM: arm64: Only set KVM_MODE_PROTECTED if is_hyp_mode_available()
  2022-09-09 14:45 ` Elliot Berman
  (?)
@ 2022-09-09 17:28   ` Catalin Marinas
  -1 siblings, 0 replies; 17+ messages in thread
From: Catalin Marinas @ 2022-09-09 17:28 UTC (permalink / raw)
  To: Elliot Berman
  Cc: Will Deacon, Marc Zyngier, James Morse, Alexandru Elisei,
	Suzuki K Poulose, linux-arm-kernel, linux-kernel, kvmarm

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 <quic_eberman@quicinc.com>
> ---
>  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.

-- 
Catalin

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] KVM: arm64: Only set KVM_MODE_PROTECTED if is_hyp_mode_available()
@ 2022-09-09 17:28   ` Catalin Marinas
  0 siblings, 0 replies; 17+ messages in thread
From: Catalin Marinas @ 2022-09-09 17:28 UTC (permalink / raw)
  To: Elliot Berman
  Cc: Marc Zyngier, linux-kernel, Will Deacon, kvmarm, linux-arm-kernel

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 <quic_eberman@quicinc.com>
> ---
>  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.

-- 
Catalin
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] KVM: arm64: Only set KVM_MODE_PROTECTED if is_hyp_mode_available()
@ 2022-09-09 17:28   ` Catalin Marinas
  0 siblings, 0 replies; 17+ messages in thread
From: Catalin Marinas @ 2022-09-09 17:28 UTC (permalink / raw)
  To: Elliot Berman
  Cc: Will Deacon, Marc Zyngier, James Morse, Alexandru Elisei,
	Suzuki K Poulose, linux-arm-kernel, linux-kernel, kvmarm

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 <quic_eberman@quicinc.com>
> ---
>  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.

-- 
Catalin

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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] KVM: arm64: Only set KVM_MODE_PROTECTED if is_hyp_mode_available()
  2022-09-09 17:28   ` Catalin Marinas
  (?)
@ 2022-09-09 17:55     ` Elliot Berman
  -1 siblings, 0 replies; 17+ messages in thread
From: Elliot Berman @ 2022-09-09 17:55 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Will Deacon, Marc Zyngier, James Morse, Alexandru Elisei,
	Suzuki K Poulose, linux-arm-kernel, linux-kernel, kvmarm



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 <quic_eberman@quicinc.com>
>> ---
>>   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?

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] KVM: arm64: Only set KVM_MODE_PROTECTED if is_hyp_mode_available()
@ 2022-09-09 17:55     ` Elliot Berman
  0 siblings, 0 replies; 17+ messages in thread
From: Elliot Berman @ 2022-09-09 17:55 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Will Deacon, Marc Zyngier, James Morse, Alexandru Elisei,
	Suzuki K Poulose, linux-arm-kernel, linux-kernel, kvmarm



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 <quic_eberman@quicinc.com>
>> ---
>>   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?

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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] KVM: arm64: Only set KVM_MODE_PROTECTED if is_hyp_mode_available()
@ 2022-09-09 17:55     ` Elliot Berman
  0 siblings, 0 replies; 17+ messages in thread
From: Elliot Berman @ 2022-09-09 17:55 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Marc Zyngier, linux-kernel, Will Deacon, kvmarm, linux-arm-kernel



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 <quic_eberman@quicinc.com>
>> ---
>>   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?
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] KVM: arm64: Only set KVM_MODE_PROTECTED if is_hyp_mode_available()
  2022-09-09 17:55     ` Elliot Berman
@ 2022-09-10  9:09       ` Marc Zyngier
  -1 siblings, 0 replies; 17+ messages in thread
From: Marc Zyngier @ 2022-09-10  9:09 UTC (permalink / raw)
  To: Elliot Berman
  Cc: Catalin Marinas, linux-kernel, Will Deacon, kvmarm, linux-arm-kernel

On Fri, 09 Sep 2022 18:55:18 +0100,
Elliot Berman <quic_eberman@quicinc.com> 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 <quic_eberman@quicinc.com>
> >> ---
> >>   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.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] KVM: arm64: Only set KVM_MODE_PROTECTED if is_hyp_mode_available()
@ 2022-09-10  9:09       ` Marc Zyngier
  0 siblings, 0 replies; 17+ messages in thread
From: Marc Zyngier @ 2022-09-10  9:09 UTC (permalink / raw)
  To: Elliot Berman
  Cc: Catalin Marinas, Will Deacon, James Morse, Alexandru Elisei,
	Suzuki K Poulose, linux-arm-kernel, linux-kernel, kvmarm

On Fri, 09 Sep 2022 18:55:18 +0100,
Elliot Berman <quic_eberman@quicinc.com> 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 <quic_eberman@quicinc.com>
> >> ---
> >>   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.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] KVM: arm64: Only set KVM_MODE_PROTECTED if is_hyp_mode_available()
  2022-09-10  9:09       ` Marc Zyngier
  (?)
@ 2022-09-10 13:43         ` Will Deacon
  -1 siblings, 0 replies; 17+ messages in thread
From: Will Deacon @ 2022-09-10 13:43 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Elliot Berman, Catalin Marinas, James Morse, Alexandru Elisei,
	Suzuki K Poulose, linux-arm-kernel, linux-kernel, kvmarm

On Sat, Sep 10, 2022 at 10:09:31AM +0100, Marc Zyngier wrote:
> On Fri, 09 Sep 2022 18:55:18 +0100,
> Elliot Berman <quic_eberman@quicinc.com> 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 <quic_eberman@quicinc.com>
> > >> ---
> > >>   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.

Will

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] KVM: arm64: Only set KVM_MODE_PROTECTED if is_hyp_mode_available()
@ 2022-09-10 13:43         ` Will Deacon
  0 siblings, 0 replies; 17+ messages in thread
From: Will Deacon @ 2022-09-10 13:43 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Elliot Berman, Catalin Marinas, linux-kernel, kvmarm, linux-arm-kernel

On Sat, Sep 10, 2022 at 10:09:31AM +0100, Marc Zyngier wrote:
> On Fri, 09 Sep 2022 18:55:18 +0100,
> Elliot Berman <quic_eberman@quicinc.com> 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 <quic_eberman@quicinc.com>
> > >> ---
> > >>   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.

Will
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] KVM: arm64: Only set KVM_MODE_PROTECTED if is_hyp_mode_available()
@ 2022-09-10 13:43         ` Will Deacon
  0 siblings, 0 replies; 17+ messages in thread
From: Will Deacon @ 2022-09-10 13:43 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Elliot Berman, Catalin Marinas, James Morse, Alexandru Elisei,
	Suzuki K Poulose, linux-arm-kernel, linux-kernel, kvmarm

On Sat, Sep 10, 2022 at 10:09:31AM +0100, Marc Zyngier wrote:
> On Fri, 09 Sep 2022 18:55:18 +0100,
> Elliot Berman <quic_eberman@quicinc.com> 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 <quic_eberman@quicinc.com>
> > >> ---
> > >>   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.

Will

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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] KVM: arm64: Only set KVM_MODE_PROTECTED if is_hyp_mode_available()
  2022-09-10 13:43         ` Will Deacon
  (?)
@ 2022-09-10 14:20           ` Marc Zyngier
  -1 siblings, 0 replies; 17+ messages in thread
From: Marc Zyngier @ 2022-09-10 14:20 UTC (permalink / raw)
  To: Will Deacon
  Cc: Elliot Berman, Catalin Marinas, James Morse, Alexandru Elisei,
	Suzuki K Poulose, linux-arm-kernel, linux-kernel, kvmarm

On Sat, 10 Sep 2022 14:43:44 +0100,
Will Deacon <will@kernel.org> 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 <quic_eberman@quicinc.com> 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 <quic_eberman@quicinc.com>
> > > >> ---
> > > >>   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.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] KVM: arm64: Only set KVM_MODE_PROTECTED if is_hyp_mode_available()
@ 2022-09-10 14:20           ` Marc Zyngier
  0 siblings, 0 replies; 17+ messages in thread
From: Marc Zyngier @ 2022-09-10 14:20 UTC (permalink / raw)
  To: Will Deacon
  Cc: Elliot Berman, Catalin Marinas, linux-kernel, kvmarm, linux-arm-kernel

On Sat, 10 Sep 2022 14:43:44 +0100,
Will Deacon <will@kernel.org> 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 <quic_eberman@quicinc.com> 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 <quic_eberman@quicinc.com>
> > > >> ---
> > > >>   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.
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] KVM: arm64: Only set KVM_MODE_PROTECTED if is_hyp_mode_available()
@ 2022-09-10 14:20           ` Marc Zyngier
  0 siblings, 0 replies; 17+ messages in thread
From: Marc Zyngier @ 2022-09-10 14:20 UTC (permalink / raw)
  To: Will Deacon
  Cc: Elliot Berman, Catalin Marinas, James Morse, Alexandru Elisei,
	Suzuki K Poulose, linux-arm-kernel, linux-kernel, kvmarm

On Sat, 10 Sep 2022 14:43:44 +0100,
Will Deacon <will@kernel.org> 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 <quic_eberman@quicinc.com> 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 <quic_eberman@quicinc.com>
> > > >> ---
> > > >>   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.

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

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-09-10 14:24 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-09 14:45 [PATCH v2] KVM: arm64: Only set KVM_MODE_PROTECTED if is_hyp_mode_available() Elliot Berman
2022-09-09 14:45 ` Elliot Berman
2022-09-09 14:45 ` Elliot Berman
2022-09-09 17:28 ` Catalin Marinas
2022-09-09 17:28   ` Catalin Marinas
2022-09-09 17:28   ` Catalin Marinas
2022-09-09 17:55   ` Elliot Berman
2022-09-09 17:55     ` Elliot Berman
2022-09-09 17:55     ` Elliot Berman
2022-09-10  9:09     ` Marc Zyngier
2022-09-10  9:09       ` Marc Zyngier
2022-09-10 13:43       ` Will Deacon
2022-09-10 13:43         ` Will Deacon
2022-09-10 13:43         ` Will Deacon
2022-09-10 14:20         ` Marc Zyngier
2022-09-10 14:20           ` Marc Zyngier
2022-09-10 14:20           ` Marc Zyngier

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.