kvmarm.lists.cs.columbia.edu archive mirror
 help / color / mirror / Atom feed
* [PATCH] kvmtool: arm64: Report missing support for 32bit guests
@ 2020-07-01 14:20 Suzuki K Poulose
  2020-07-01 15:42 ` Marc Zyngier
  2020-07-03 12:07 ` Will Deacon
  0 siblings, 2 replies; 5+ messages in thread
From: Suzuki K Poulose @ 2020-07-01 14:20 UTC (permalink / raw)
  To: kvm; +Cc: andre.przywara, Sami Mujawar, Will Deacon, kvmarm, linux-arm-kernel

When the host doesn't support 32bit guests, the kvmtool fails
without a proper message on what is wrong. i.e,

 $ lkvm run -c 1 Image --aarch32
  # lkvm run -k Image -m 256 -c 1 --name guest-105618
  Fatal: Unable to initialise vcpu

Given that there is no other easy way to check if the host supports 32bit
guests, it is always good to report this by checking the capability, rather
than leaving the users to hunt this down by looking at the code!

After this patch:

 $ lkvm run -c 1 Image --aarch32
  # lkvm run -k Image -m 256 -c 1 --name guest-105695
  Fatal: 32bit guests are not supported

Cc: Will Deacon <will@kernel.org>
Reported-by: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 arm/kvm-cpu.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arm/kvm-cpu.c b/arm/kvm-cpu.c
index 554414f..2acecae 100644
--- a/arm/kvm-cpu.c
+++ b/arm/kvm-cpu.c
@@ -46,6 +46,10 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
 		.features = ARM_VCPU_FEATURE_FLAGS(kvm, cpu_id)
 	};
 
+	if (kvm->cfg.arch.aarch32_guest &&
+	    !kvm__supports_extension(kvm, KVM_CAP_ARM_EL1_32BIT))
+		die("32bit guests are not supported\n");
+
 	vcpu = calloc(1, sizeof(struct kvm_cpu));
 	if (!vcpu)
 		return NULL;
-- 
2.24.1

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

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

* Re: [PATCH] kvmtool: arm64: Report missing support for 32bit guests
  2020-07-01 14:20 [PATCH] kvmtool: arm64: Report missing support for 32bit guests Suzuki K Poulose
@ 2020-07-01 15:42 ` Marc Zyngier
  2020-07-02 15:37   ` Suzuki K Poulose
  2020-07-03 12:07 ` Will Deacon
  1 sibling, 1 reply; 5+ messages in thread
From: Marc Zyngier @ 2020-07-01 15:42 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: kvm, andre.przywara, Sami Mujawar, Will Deacon, kvmarm, linux-arm-kernel

On 2020-07-01 15:20, Suzuki K Poulose wrote:
> When the host doesn't support 32bit guests, the kvmtool fails
> without a proper message on what is wrong. i.e,
> 
>  $ lkvm run -c 1 Image --aarch32
>   # lkvm run -k Image -m 256 -c 1 --name guest-105618
>   Fatal: Unable to initialise vcpu
> 
> Given that there is no other easy way to check if the host supports 
> 32bit
> guests, it is always good to report this by checking the capability, 
> rather
> than leaving the users to hunt this down by looking at the code!
> 
> After this patch:
> 
>  $ lkvm run -c 1 Image --aarch32
>   # lkvm run -k Image -m 256 -c 1 --name guest-105695
>   Fatal: 32bit guests are not supported

Fancy!

> 
> Cc: Will Deacon <will@kernel.org>
> Reported-by: Sami Mujawar <sami.mujawar@arm.com>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>  arm/kvm-cpu.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arm/kvm-cpu.c b/arm/kvm-cpu.c
> index 554414f..2acecae 100644
> --- a/arm/kvm-cpu.c
> +++ b/arm/kvm-cpu.c
> @@ -46,6 +46,10 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm,
> unsigned long cpu_id)
>  		.features = ARM_VCPU_FEATURE_FLAGS(kvm, cpu_id)
>  	};
> 
> +	if (kvm->cfg.arch.aarch32_guest &&
> +	    !kvm__supports_extension(kvm, KVM_CAP_ARM_EL1_32BIT))

Can you please check that this still compiles for 32bit host?

> +		die("32bit guests are not supported\n");
> +
>  	vcpu = calloc(1, sizeof(struct kvm_cpu));
>  	if (!vcpu)
>  		return NULL;

With the above detail checked,

Acked-by: Marc Zyngier <maz@kernel.org>

         M.
-- 
Who you jivin' with that Cosmik Debris?
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

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

* Re: [PATCH] kvmtool: arm64: Report missing support for 32bit guests
  2020-07-01 15:42 ` Marc Zyngier
@ 2020-07-02 15:37   ` Suzuki K Poulose
  2020-07-02 15:51     ` Marc Zyngier
  0 siblings, 1 reply; 5+ messages in thread
From: Suzuki K Poulose @ 2020-07-02 15:37 UTC (permalink / raw)
  To: maz; +Cc: kvm, andre.przywara, sami.mujawar, will, kvmarm, linux-arm-kernel

Hi Marc

On 07/01/2020 04:42 PM, Marc Zyngier wrote:
> On 2020-07-01 15:20, Suzuki K Poulose wrote:
>> When the host doesn't support 32bit guests, the kvmtool fails
>> without a proper message on what is wrong. i.e,
>>
>>  $ lkvm run -c 1 Image --aarch32
>>   # lkvm run -k Image -m 256 -c 1 --name guest-105618
>>   Fatal: Unable to initialise vcpu
>>
>> Given that there is no other easy way to check if the host supports 32bit
>> guests, it is always good to report this by checking the capability, 
>> rather
>> than leaving the users to hunt this down by looking at the code!
>>
>> After this patch:
>>
>>  $ lkvm run -c 1 Image --aarch32
>>   # lkvm run -k Image -m 256 -c 1 --name guest-105695
>>   Fatal: 32bit guests are not supported
> 
> Fancy!
> 
>>
>> Cc: Will Deacon <will@kernel.org>
>> Reported-by: Sami Mujawar <sami.mujawar@arm.com>
>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
>> ---
>>  arm/kvm-cpu.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/arm/kvm-cpu.c b/arm/kvm-cpu.c
>> index 554414f..2acecae 100644
>> --- a/arm/kvm-cpu.c
>> +++ b/arm/kvm-cpu.c
>> @@ -46,6 +46,10 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm,
>> unsigned long cpu_id)
>>          .features = ARM_VCPU_FEATURE_FLAGS(kvm, cpu_id)
>>      };
>>
>> +    if (kvm->cfg.arch.aarch32_guest &&
>> +        !kvm__supports_extension(kvm, KVM_CAP_ARM_EL1_32BIT))
> 
> Can you please check that this still compiles for 32bit host?

Yes, it does. I have built this on an arm32 rootfs with make ARCH=arm.
The kvm->cfg.arch is common across arm/arm64 and is defined here :

arm/include/arm-common/kvm-config-arch.h

And the aarch32 command line option is only available on aarch64 host.
So this is safe on an arm32 host.

> 
>> +        die("32bit guests are not supported\n");
>> +
>>      vcpu = calloc(1, sizeof(struct kvm_cpu));
>>      if (!vcpu)
>>          return NULL;
> 
> With the above detail checked,
> 
> Acked-by: Marc Zyngier <maz@kernel.org>

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

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

* Re: [PATCH] kvmtool: arm64: Report missing support for 32bit guests
  2020-07-02 15:37   ` Suzuki K Poulose
@ 2020-07-02 15:51     ` Marc Zyngier
  0 siblings, 0 replies; 5+ messages in thread
From: Marc Zyngier @ 2020-07-02 15:51 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: kvm, andre.przywara, sami.mujawar, will, kvmarm, linux-arm-kernel

On 2020-07-02 16:37, Suzuki K Poulose wrote:
> Hi Marc
> 
> On 07/01/2020 04:42 PM, Marc Zyngier wrote:
>> On 2020-07-01 15:20, Suzuki K Poulose wrote:
>>> When the host doesn't support 32bit guests, the kvmtool fails
>>> without a proper message on what is wrong. i.e,
>>> 
>>>  $ lkvm run -c 1 Image --aarch32
>>>   # lkvm run -k Image -m 256 -c 1 --name guest-105618
>>>   Fatal: Unable to initialise vcpu
>>> 
>>> Given that there is no other easy way to check if the host supports 
>>> 32bit
>>> guests, it is always good to report this by checking the capability, 
>>> rather
>>> than leaving the users to hunt this down by looking at the code!
>>> 
>>> After this patch:
>>> 
>>>  $ lkvm run -c 1 Image --aarch32
>>>   # lkvm run -k Image -m 256 -c 1 --name guest-105695
>>>   Fatal: 32bit guests are not supported
>> 
>> Fancy!
>> 
>>> 
>>> Cc: Will Deacon <will@kernel.org>
>>> Reported-by: Sami Mujawar <sami.mujawar@arm.com>
>>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
>>> ---
>>>  arm/kvm-cpu.c | 4 ++++
>>>  1 file changed, 4 insertions(+)
>>> 
>>> diff --git a/arm/kvm-cpu.c b/arm/kvm-cpu.c
>>> index 554414f..2acecae 100644
>>> --- a/arm/kvm-cpu.c
>>> +++ b/arm/kvm-cpu.c
>>> @@ -46,6 +46,10 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm 
>>> *kvm,
>>> unsigned long cpu_id)
>>>          .features = ARM_VCPU_FEATURE_FLAGS(kvm, cpu_id)
>>>      };
>>> 
>>> +    if (kvm->cfg.arch.aarch32_guest &&
>>> +        !kvm__supports_extension(kvm, KVM_CAP_ARM_EL1_32BIT))
>> 
>> Can you please check that this still compiles for 32bit host?
> 
> Yes, it does. I have built this on an arm32 rootfs with make ARCH=arm.
> The kvm->cfg.arch is common across arm/arm64 and is defined here :
> 
> arm/include/arm-common/kvm-config-arch.h

I was worried about the availability of KVM_CAP_ARM_EL1_32BIT,
but being a capability, it is common to all arches. It is
KVM_ARM_VCPU_EL1_32BIT that is 32bit only, but that's not what
you are using. Too many flags! ;-)

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

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

* Re: [PATCH] kvmtool: arm64: Report missing support for 32bit guests
  2020-07-01 14:20 [PATCH] kvmtool: arm64: Report missing support for 32bit guests Suzuki K Poulose
  2020-07-01 15:42 ` Marc Zyngier
@ 2020-07-03 12:07 ` Will Deacon
  1 sibling, 0 replies; 5+ messages in thread
From: Will Deacon @ 2020-07-03 12:07 UTC (permalink / raw)
  To: Suzuki K Poulose, kvm
  Cc: Will Deacon, catalin.marinas, andre.przywara, Sami Mujawar,
	kernel-team, kvmarm, linux-arm-kernel

On Wed, 1 Jul 2020 15:20:02 +0100, Suzuki K Poulose wrote:
> When the host doesn't support 32bit guests, the kvmtool fails
> without a proper message on what is wrong. i.e,
> 
>  $ lkvm run -c 1 Image --aarch32
>   # lkvm run -k Image -m 256 -c 1 --name guest-105618
>   Fatal: Unable to initialise vcpu
> 
> [...]

Applied to kvmtool (master), thanks!

[1/1] kvmtool: arm64: Report missing support for 32bit guests
      https://git.kernel.org/will/kvmtool/c/351d931f496a

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

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

end of thread, other threads:[~2020-07-03 12:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-01 14:20 [PATCH] kvmtool: arm64: Report missing support for 32bit guests Suzuki K Poulose
2020-07-01 15:42 ` Marc Zyngier
2020-07-02 15:37   ` Suzuki K Poulose
2020-07-02 15:51     ` Marc Zyngier
2020-07-03 12:07 ` Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).