All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: vgic-v4: Initialize GICv4.1 even in the absence of a virtual ITS
@ 2020-04-25  9:44 ` Marc Zyngier
  0 siblings, 0 replies; 9+ messages in thread
From: Marc Zyngier @ 2020-04-25  9:44 UTC (permalink / raw)
  To: linux-arm-kernel, kvm, kvmarm
  Cc: James Morse, Julien Thierry, Suzuki K Poulose, Zenghui Yu, Eric Auger

KVM now expects to be able to use HW-accelerated delivery of vSGIs
as soon as the guest has enabled thm. Unfortunately, we only
initialize the GICv4 context if we have a virtual ITS exposed to
the guest.

Fix it by always initializing the GICv4.1 context if it is
available on the host.

Fixes: 2291ff2f2a56 ("KVM: arm64: GICv4.1: Plumb SGI implementation selection in the distributor")
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 virt/kvm/arm/vgic/vgic-init.c    | 9 ++++++++-
 virt/kvm/arm/vgic/vgic-mmio-v3.c | 3 ++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c
index a963b9d766b73..8e6f350c3bcd1 100644
--- a/virt/kvm/arm/vgic/vgic-init.c
+++ b/virt/kvm/arm/vgic/vgic-init.c
@@ -294,8 +294,15 @@ int vgic_init(struct kvm *kvm)
 		}
 	}
 
-	if (vgic_has_its(kvm)) {
+	if (vgic_has_its(kvm))
 		vgic_lpi_translation_cache_init(kvm);
+
+	/*
+	 * If we have GICv4.1 enabled, unconditionnaly request enable the
+	 * v4 support so that we get HW-accelerated vSGIs. Otherwise, only
+	 * enable it if we present a virtual ITS to the guest.
+	 */
+	if (vgic_supports_direct_msis(kvm)) {
 		ret = vgic_v4_init(kvm);
 		if (ret)
 			goto out;
diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c
index e72dcc4542475..26b11dcd45524 100644
--- a/virt/kvm/arm/vgic/vgic-mmio-v3.c
+++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c
@@ -50,7 +50,8 @@ bool vgic_has_its(struct kvm *kvm)
 
 bool vgic_supports_direct_msis(struct kvm *kvm)
 {
-	return kvm_vgic_global_state.has_gicv4 && vgic_has_its(kvm);
+	return (kvm_vgic_global_state.has_gicv4_1 ||
+		(kvm_vgic_global_state.has_gicv4 && vgic_has_its(kvm)));
 }
 
 /*
-- 
2.26.2


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

* [PATCH] KVM: arm64: vgic-v4: Initialize GICv4.1 even in the absence of a virtual ITS
@ 2020-04-25  9:44 ` Marc Zyngier
  0 siblings, 0 replies; 9+ messages in thread
From: Marc Zyngier @ 2020-04-25  9:44 UTC (permalink / raw)
  To: linux-arm-kernel, kvm, kvmarm

KVM now expects to be able to use HW-accelerated delivery of vSGIs
as soon as the guest has enabled thm. Unfortunately, we only
initialize the GICv4 context if we have a virtual ITS exposed to
the guest.

Fix it by always initializing the GICv4.1 context if it is
available on the host.

Fixes: 2291ff2f2a56 ("KVM: arm64: GICv4.1: Plumb SGI implementation selection in the distributor")
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 virt/kvm/arm/vgic/vgic-init.c    | 9 ++++++++-
 virt/kvm/arm/vgic/vgic-mmio-v3.c | 3 ++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c
index a963b9d766b73..8e6f350c3bcd1 100644
--- a/virt/kvm/arm/vgic/vgic-init.c
+++ b/virt/kvm/arm/vgic/vgic-init.c
@@ -294,8 +294,15 @@ int vgic_init(struct kvm *kvm)
 		}
 	}
 
-	if (vgic_has_its(kvm)) {
+	if (vgic_has_its(kvm))
 		vgic_lpi_translation_cache_init(kvm);
+
+	/*
+	 * If we have GICv4.1 enabled, unconditionnaly request enable the
+	 * v4 support so that we get HW-accelerated vSGIs. Otherwise, only
+	 * enable it if we present a virtual ITS to the guest.
+	 */
+	if (vgic_supports_direct_msis(kvm)) {
 		ret = vgic_v4_init(kvm);
 		if (ret)
 			goto out;
diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c
index e72dcc4542475..26b11dcd45524 100644
--- a/virt/kvm/arm/vgic/vgic-mmio-v3.c
+++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c
@@ -50,7 +50,8 @@ bool vgic_has_its(struct kvm *kvm)
 
 bool vgic_supports_direct_msis(struct kvm *kvm)
 {
-	return kvm_vgic_global_state.has_gicv4 && vgic_has_its(kvm);
+	return (kvm_vgic_global_state.has_gicv4_1 ||
+		(kvm_vgic_global_state.has_gicv4 && vgic_has_its(kvm)));
 }
 
 /*
-- 
2.26.2

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

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

* [PATCH] KVM: arm64: vgic-v4: Initialize GICv4.1 even in the absence of a virtual ITS
@ 2020-04-25  9:44 ` Marc Zyngier
  0 siblings, 0 replies; 9+ messages in thread
From: Marc Zyngier @ 2020-04-25  9:44 UTC (permalink / raw)
  To: linux-arm-kernel, kvm, kvmarm
  Cc: Zenghui Yu, Eric Auger, James Morse, Julien Thierry, Suzuki K Poulose

KVM now expects to be able to use HW-accelerated delivery of vSGIs
as soon as the guest has enabled thm. Unfortunately, we only
initialize the GICv4 context if we have a virtual ITS exposed to
the guest.

Fix it by always initializing the GICv4.1 context if it is
available on the host.

Fixes: 2291ff2f2a56 ("KVM: arm64: GICv4.1: Plumb SGI implementation selection in the distributor")
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 virt/kvm/arm/vgic/vgic-init.c    | 9 ++++++++-
 virt/kvm/arm/vgic/vgic-mmio-v3.c | 3 ++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c
index a963b9d766b73..8e6f350c3bcd1 100644
--- a/virt/kvm/arm/vgic/vgic-init.c
+++ b/virt/kvm/arm/vgic/vgic-init.c
@@ -294,8 +294,15 @@ int vgic_init(struct kvm *kvm)
 		}
 	}
 
-	if (vgic_has_its(kvm)) {
+	if (vgic_has_its(kvm))
 		vgic_lpi_translation_cache_init(kvm);
+
+	/*
+	 * If we have GICv4.1 enabled, unconditionnaly request enable the
+	 * v4 support so that we get HW-accelerated vSGIs. Otherwise, only
+	 * enable it if we present a virtual ITS to the guest.
+	 */
+	if (vgic_supports_direct_msis(kvm)) {
 		ret = vgic_v4_init(kvm);
 		if (ret)
 			goto out;
diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c
index e72dcc4542475..26b11dcd45524 100644
--- a/virt/kvm/arm/vgic/vgic-mmio-v3.c
+++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c
@@ -50,7 +50,8 @@ bool vgic_has_its(struct kvm *kvm)
 
 bool vgic_supports_direct_msis(struct kvm *kvm)
 {
-	return kvm_vgic_global_state.has_gicv4 && vgic_has_its(kvm);
+	return (kvm_vgic_global_state.has_gicv4_1 ||
+		(kvm_vgic_global_state.has_gicv4 && vgic_has_its(kvm)));
 }
 
 /*
-- 
2.26.2


_______________________________________________
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] 9+ messages in thread

* Re: [PATCH] KVM: arm64: vgic-v4: Initialize GICv4.1 even in the absence of a virtual ITS
  2020-04-25  9:44 ` Marc Zyngier
  (?)
@ 2020-04-30 11:24   ` Zenghui Yu
  -1 siblings, 0 replies; 9+ messages in thread
From: Zenghui Yu @ 2020-04-30 11:24 UTC (permalink / raw)
  To: Marc Zyngier, linux-arm-kernel, kvm, kvmarm
  Cc: James Morse, Julien Thierry, Suzuki K Poulose, Eric Auger

Hi Marc,

On 2020/4/25 17:44, Marc Zyngier wrote:
> KVM now expects to be able to use HW-accelerated delivery of vSGIs
> as soon as the guest has enabled thm. Unfortunately, we only
them
> initialize the GICv4 context if we have a virtual ITS exposed to
> the guest.
> 
> Fix it by always initializing the GICv4.1 context if it is
> available on the host.
> 
> Fixes: 2291ff2f2a56 ("KVM: arm64: GICv4.1: Plumb SGI implementation selection in the distributor")
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> ---
>   virt/kvm/arm/vgic/vgic-init.c    | 9 ++++++++-
>   virt/kvm/arm/vgic/vgic-mmio-v3.c | 3 ++-
>   2 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c
> index a963b9d766b73..8e6f350c3bcd1 100644
> --- a/virt/kvm/arm/vgic/vgic-init.c
> +++ b/virt/kvm/arm/vgic/vgic-init.c
> @@ -294,8 +294,15 @@ int vgic_init(struct kvm *kvm)
>   		}
>   	}
>   
> -	if (vgic_has_its(kvm)) {
> +	if (vgic_has_its(kvm))
>   		vgic_lpi_translation_cache_init(kvm);
> +
> +	/*
> +	 * If we have GICv4.1 enabled, unconditionnaly request enable the
> +	 * v4 support so that we get HW-accelerated vSGIs. Otherwise, only
> +	 * enable it if we present a virtual ITS to the guest.
> +	 */
> +	if (vgic_supports_direct_msis(kvm)) {
>   		ret = vgic_v4_init(kvm);
>   		if (ret)
>   			goto out;
> diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c
> index e72dcc4542475..26b11dcd45524 100644
> --- a/virt/kvm/arm/vgic/vgic-mmio-v3.c
> +++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c
> @@ -50,7 +50,8 @@ bool vgic_has_its(struct kvm *kvm)
>   
>   bool vgic_supports_direct_msis(struct kvm *kvm)
>   {
> -	return kvm_vgic_global_state.has_gicv4 && vgic_has_its(kvm);
> +	return (kvm_vgic_global_state.has_gicv4_1 ||
> +		(kvm_vgic_global_state.has_gicv4 && vgic_has_its(kvm)));
>   }

Not related to this patch, but I think that the function name can be
improved a bit after this change. It now indicates whether the vGIC
supports direct MSIs injection *or* direct SGIs injection, not just
MSIs. And if vgic_has_its() is false, we don't even support MSIs.

The fix itself looks correct to me,

Reviewed-by: Zenghui Yu <yuzenghui@huawei.com>


Thanks.


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

* Re: [PATCH] KVM: arm64: vgic-v4: Initialize GICv4.1 even in the absence of a virtual ITS
@ 2020-04-30 11:24   ` Zenghui Yu
  0 siblings, 0 replies; 9+ messages in thread
From: Zenghui Yu @ 2020-04-30 11:24 UTC (permalink / raw)
  To: Marc Zyngier, linux-arm-kernel, kvm, kvmarm

Hi Marc,

On 2020/4/25 17:44, Marc Zyngier wrote:
> KVM now expects to be able to use HW-accelerated delivery of vSGIs
> as soon as the guest has enabled thm. Unfortunately, we only
them
> initialize the GICv4 context if we have a virtual ITS exposed to
> the guest.
> 
> Fix it by always initializing the GICv4.1 context if it is
> available on the host.
> 
> Fixes: 2291ff2f2a56 ("KVM: arm64: GICv4.1: Plumb SGI implementation selection in the distributor")
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> ---
>   virt/kvm/arm/vgic/vgic-init.c    | 9 ++++++++-
>   virt/kvm/arm/vgic/vgic-mmio-v3.c | 3 ++-
>   2 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c
> index a963b9d766b73..8e6f350c3bcd1 100644
> --- a/virt/kvm/arm/vgic/vgic-init.c
> +++ b/virt/kvm/arm/vgic/vgic-init.c
> @@ -294,8 +294,15 @@ int vgic_init(struct kvm *kvm)
>   		}
>   	}
>   
> -	if (vgic_has_its(kvm)) {
> +	if (vgic_has_its(kvm))
>   		vgic_lpi_translation_cache_init(kvm);
> +
> +	/*
> +	 * If we have GICv4.1 enabled, unconditionnaly request enable the
> +	 * v4 support so that we get HW-accelerated vSGIs. Otherwise, only
> +	 * enable it if we present a virtual ITS to the guest.
> +	 */
> +	if (vgic_supports_direct_msis(kvm)) {
>   		ret = vgic_v4_init(kvm);
>   		if (ret)
>   			goto out;
> diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c
> index e72dcc4542475..26b11dcd45524 100644
> --- a/virt/kvm/arm/vgic/vgic-mmio-v3.c
> +++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c
> @@ -50,7 +50,8 @@ bool vgic_has_its(struct kvm *kvm)
>   
>   bool vgic_supports_direct_msis(struct kvm *kvm)
>   {
> -	return kvm_vgic_global_state.has_gicv4 && vgic_has_its(kvm);
> +	return (kvm_vgic_global_state.has_gicv4_1 ||
> +		(kvm_vgic_global_state.has_gicv4 && vgic_has_its(kvm)));
>   }

Not related to this patch, but I think that the function name can be
improved a bit after this change. It now indicates whether the vGIC
supports direct MSIs injection *or* direct SGIs injection, not just
MSIs. And if vgic_has_its() is false, we don't even support MSIs.

The fix itself looks correct to me,

Reviewed-by: Zenghui Yu <yuzenghui@huawei.com>


Thanks.

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

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

* Re: [PATCH] KVM: arm64: vgic-v4: Initialize GICv4.1 even in the absence of a virtual ITS
@ 2020-04-30 11:24   ` Zenghui Yu
  0 siblings, 0 replies; 9+ messages in thread
From: Zenghui Yu @ 2020-04-30 11:24 UTC (permalink / raw)
  To: Marc Zyngier, linux-arm-kernel, kvm, kvmarm
  Cc: Eric Auger, James Morse, Julien Thierry, Suzuki K Poulose

Hi Marc,

On 2020/4/25 17:44, Marc Zyngier wrote:
> KVM now expects to be able to use HW-accelerated delivery of vSGIs
> as soon as the guest has enabled thm. Unfortunately, we only
them
> initialize the GICv4 context if we have a virtual ITS exposed to
> the guest.
> 
> Fix it by always initializing the GICv4.1 context if it is
> available on the host.
> 
> Fixes: 2291ff2f2a56 ("KVM: arm64: GICv4.1: Plumb SGI implementation selection in the distributor")
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> ---
>   virt/kvm/arm/vgic/vgic-init.c    | 9 ++++++++-
>   virt/kvm/arm/vgic/vgic-mmio-v3.c | 3 ++-
>   2 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c
> index a963b9d766b73..8e6f350c3bcd1 100644
> --- a/virt/kvm/arm/vgic/vgic-init.c
> +++ b/virt/kvm/arm/vgic/vgic-init.c
> @@ -294,8 +294,15 @@ int vgic_init(struct kvm *kvm)
>   		}
>   	}
>   
> -	if (vgic_has_its(kvm)) {
> +	if (vgic_has_its(kvm))
>   		vgic_lpi_translation_cache_init(kvm);
> +
> +	/*
> +	 * If we have GICv4.1 enabled, unconditionnaly request enable the
> +	 * v4 support so that we get HW-accelerated vSGIs. Otherwise, only
> +	 * enable it if we present a virtual ITS to the guest.
> +	 */
> +	if (vgic_supports_direct_msis(kvm)) {
>   		ret = vgic_v4_init(kvm);
>   		if (ret)
>   			goto out;
> diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c
> index e72dcc4542475..26b11dcd45524 100644
> --- a/virt/kvm/arm/vgic/vgic-mmio-v3.c
> +++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c
> @@ -50,7 +50,8 @@ bool vgic_has_its(struct kvm *kvm)
>   
>   bool vgic_supports_direct_msis(struct kvm *kvm)
>   {
> -	return kvm_vgic_global_state.has_gicv4 && vgic_has_its(kvm);
> +	return (kvm_vgic_global_state.has_gicv4_1 ||
> +		(kvm_vgic_global_state.has_gicv4 && vgic_has_its(kvm)));
>   }

Not related to this patch, but I think that the function name can be
improved a bit after this change. It now indicates whether the vGIC
supports direct MSIs injection *or* direct SGIs injection, not just
MSIs. And if vgic_has_its() is false, we don't even support MSIs.

The fix itself looks correct to me,

Reviewed-by: Zenghui Yu <yuzenghui@huawei.com>


Thanks.


_______________________________________________
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] 9+ messages in thread

* Re: [PATCH] KVM: arm64: vgic-v4: Initialize GICv4.1 even in the absence of a virtual ITS
  2020-04-30 11:24   ` Zenghui Yu
  (?)
@ 2020-04-30 11:39     ` Marc Zyngier
  -1 siblings, 0 replies; 9+ messages in thread
From: Marc Zyngier @ 2020-04-30 11:39 UTC (permalink / raw)
  To: Zenghui Yu
  Cc: linux-arm-kernel, kvm, kvmarm, James Morse, Julien Thierry,
	Suzuki K Poulose, Eric Auger

Hi Zenghui,

On 2020-04-30 12:24, Zenghui Yu wrote:
> Hi Marc,
> 
> On 2020/4/25 17:44, Marc Zyngier wrote:
>> KVM now expects to be able to use HW-accelerated delivery of vSGIs
>> as soon as the guest has enabled thm. Unfortunately, we only
> them
>> initialize the GICv4 context if we have a virtual ITS exposed to
>> the guest.
>> 
>> Fix it by always initializing the GICv4.1 context if it is
>> available on the host.
>> 
>> Fixes: 2291ff2f2a56 ("KVM: arm64: GICv4.1: Plumb SGI implementation 
>> selection in the distributor")
>> Signed-off-by: Marc Zyngier <maz@kernel.org>
>> ---
>>   virt/kvm/arm/vgic/vgic-init.c    | 9 ++++++++-
>>   virt/kvm/arm/vgic/vgic-mmio-v3.c | 3 ++-
>>   2 files changed, 10 insertions(+), 2 deletions(-)
>> 
>> diff --git a/virt/kvm/arm/vgic/vgic-init.c 
>> b/virt/kvm/arm/vgic/vgic-init.c
>> index a963b9d766b73..8e6f350c3bcd1 100644
>> --- a/virt/kvm/arm/vgic/vgic-init.c
>> +++ b/virt/kvm/arm/vgic/vgic-init.c
>> @@ -294,8 +294,15 @@ int vgic_init(struct kvm *kvm)
>>   		}
>>   	}
>>   -	if (vgic_has_its(kvm)) {
>> +	if (vgic_has_its(kvm))
>>   		vgic_lpi_translation_cache_init(kvm);
>> +
>> +	/*
>> +	 * If we have GICv4.1 enabled, unconditionnaly request enable the
>> +	 * v4 support so that we get HW-accelerated vSGIs. Otherwise, only
>> +	 * enable it if we present a virtual ITS to the guest.
>> +	 */
>> +	if (vgic_supports_direct_msis(kvm)) {
>>   		ret = vgic_v4_init(kvm);
>>   		if (ret)
>>   			goto out;
>> diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c 
>> b/virt/kvm/arm/vgic/vgic-mmio-v3.c
>> index e72dcc4542475..26b11dcd45524 100644
>> --- a/virt/kvm/arm/vgic/vgic-mmio-v3.c
>> +++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c
>> @@ -50,7 +50,8 @@ bool vgic_has_its(struct kvm *kvm)
>>     bool vgic_supports_direct_msis(struct kvm *kvm)
>>   {
>> -	return kvm_vgic_global_state.has_gicv4 && vgic_has_its(kvm);
>> +	return (kvm_vgic_global_state.has_gicv4_1 ||
>> +		(kvm_vgic_global_state.has_gicv4 && vgic_has_its(kvm)));
>>   }
> 
> Not related to this patch, but I think that the function name can be
> improved a bit after this change. It now indicates whether the vGIC
> supports direct MSIs injection *or* direct SGIs injection, not just
> MSIs. And if vgic_has_its() is false, we don't even support MSIs.

Yes, I noticed that too. But in the spirit of keeping the change minimal
and avoid later conflicts with potential fixes, I decided against 
changing
it right now.

> The fix itself looks correct to me,
> 
> Reviewed-by: Zenghui Yu <yuzenghui@huawei.com>

Thanks,

         M.
-- 
Jazz is not dead. It just smells funny...

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

* Re: [PATCH] KVM: arm64: vgic-v4: Initialize GICv4.1 even in the absence of a virtual ITS
@ 2020-04-30 11:39     ` Marc Zyngier
  0 siblings, 0 replies; 9+ messages in thread
From: Marc Zyngier @ 2020-04-30 11:39 UTC (permalink / raw)
  To: Zenghui Yu; +Cc: kvm, linux-arm-kernel, kvmarm

Hi Zenghui,

On 2020-04-30 12:24, Zenghui Yu wrote:
> Hi Marc,
> 
> On 2020/4/25 17:44, Marc Zyngier wrote:
>> KVM now expects to be able to use HW-accelerated delivery of vSGIs
>> as soon as the guest has enabled thm. Unfortunately, we only
> them
>> initialize the GICv4 context if we have a virtual ITS exposed to
>> the guest.
>> 
>> Fix it by always initializing the GICv4.1 context if it is
>> available on the host.
>> 
>> Fixes: 2291ff2f2a56 ("KVM: arm64: GICv4.1: Plumb SGI implementation 
>> selection in the distributor")
>> Signed-off-by: Marc Zyngier <maz@kernel.org>
>> ---
>>   virt/kvm/arm/vgic/vgic-init.c    | 9 ++++++++-
>>   virt/kvm/arm/vgic/vgic-mmio-v3.c | 3 ++-
>>   2 files changed, 10 insertions(+), 2 deletions(-)
>> 
>> diff --git a/virt/kvm/arm/vgic/vgic-init.c 
>> b/virt/kvm/arm/vgic/vgic-init.c
>> index a963b9d766b73..8e6f350c3bcd1 100644
>> --- a/virt/kvm/arm/vgic/vgic-init.c
>> +++ b/virt/kvm/arm/vgic/vgic-init.c
>> @@ -294,8 +294,15 @@ int vgic_init(struct kvm *kvm)
>>   		}
>>   	}
>>   -	if (vgic_has_its(kvm)) {
>> +	if (vgic_has_its(kvm))
>>   		vgic_lpi_translation_cache_init(kvm);
>> +
>> +	/*
>> +	 * If we have GICv4.1 enabled, unconditionnaly request enable the
>> +	 * v4 support so that we get HW-accelerated vSGIs. Otherwise, only
>> +	 * enable it if we present a virtual ITS to the guest.
>> +	 */
>> +	if (vgic_supports_direct_msis(kvm)) {
>>   		ret = vgic_v4_init(kvm);
>>   		if (ret)
>>   			goto out;
>> diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c 
>> b/virt/kvm/arm/vgic/vgic-mmio-v3.c
>> index e72dcc4542475..26b11dcd45524 100644
>> --- a/virt/kvm/arm/vgic/vgic-mmio-v3.c
>> +++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c
>> @@ -50,7 +50,8 @@ bool vgic_has_its(struct kvm *kvm)
>>     bool vgic_supports_direct_msis(struct kvm *kvm)
>>   {
>> -	return kvm_vgic_global_state.has_gicv4 && vgic_has_its(kvm);
>> +	return (kvm_vgic_global_state.has_gicv4_1 ||
>> +		(kvm_vgic_global_state.has_gicv4 && vgic_has_its(kvm)));
>>   }
> 
> Not related to this patch, but I think that the function name can be
> improved a bit after this change. It now indicates whether the vGIC
> supports direct MSIs injection *or* direct SGIs injection, not just
> MSIs. And if vgic_has_its() is false, we don't even support MSIs.

Yes, I noticed that too. But in the spirit of keeping the change minimal
and avoid later conflicts with potential fixes, I decided against 
changing
it right now.

> The fix itself looks correct to me,
> 
> Reviewed-by: Zenghui Yu <yuzenghui@huawei.com>

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] 9+ messages in thread

* Re: [PATCH] KVM: arm64: vgic-v4: Initialize GICv4.1 even in the absence of a virtual ITS
@ 2020-04-30 11:39     ` Marc Zyngier
  0 siblings, 0 replies; 9+ messages in thread
From: Marc Zyngier @ 2020-04-30 11:39 UTC (permalink / raw)
  To: Zenghui Yu
  Cc: kvm, Suzuki K Poulose, Eric Auger, James Morse, linux-arm-kernel,
	kvmarm, Julien Thierry

Hi Zenghui,

On 2020-04-30 12:24, Zenghui Yu wrote:
> Hi Marc,
> 
> On 2020/4/25 17:44, Marc Zyngier wrote:
>> KVM now expects to be able to use HW-accelerated delivery of vSGIs
>> as soon as the guest has enabled thm. Unfortunately, we only
> them
>> initialize the GICv4 context if we have a virtual ITS exposed to
>> the guest.
>> 
>> Fix it by always initializing the GICv4.1 context if it is
>> available on the host.
>> 
>> Fixes: 2291ff2f2a56 ("KVM: arm64: GICv4.1: Plumb SGI implementation 
>> selection in the distributor")
>> Signed-off-by: Marc Zyngier <maz@kernel.org>
>> ---
>>   virt/kvm/arm/vgic/vgic-init.c    | 9 ++++++++-
>>   virt/kvm/arm/vgic/vgic-mmio-v3.c | 3 ++-
>>   2 files changed, 10 insertions(+), 2 deletions(-)
>> 
>> diff --git a/virt/kvm/arm/vgic/vgic-init.c 
>> b/virt/kvm/arm/vgic/vgic-init.c
>> index a963b9d766b73..8e6f350c3bcd1 100644
>> --- a/virt/kvm/arm/vgic/vgic-init.c
>> +++ b/virt/kvm/arm/vgic/vgic-init.c
>> @@ -294,8 +294,15 @@ int vgic_init(struct kvm *kvm)
>>   		}
>>   	}
>>   -	if (vgic_has_its(kvm)) {
>> +	if (vgic_has_its(kvm))
>>   		vgic_lpi_translation_cache_init(kvm);
>> +
>> +	/*
>> +	 * If we have GICv4.1 enabled, unconditionnaly request enable the
>> +	 * v4 support so that we get HW-accelerated vSGIs. Otherwise, only
>> +	 * enable it if we present a virtual ITS to the guest.
>> +	 */
>> +	if (vgic_supports_direct_msis(kvm)) {
>>   		ret = vgic_v4_init(kvm);
>>   		if (ret)
>>   			goto out;
>> diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c 
>> b/virt/kvm/arm/vgic/vgic-mmio-v3.c
>> index e72dcc4542475..26b11dcd45524 100644
>> --- a/virt/kvm/arm/vgic/vgic-mmio-v3.c
>> +++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c
>> @@ -50,7 +50,8 @@ bool vgic_has_its(struct kvm *kvm)
>>     bool vgic_supports_direct_msis(struct kvm *kvm)
>>   {
>> -	return kvm_vgic_global_state.has_gicv4 && vgic_has_its(kvm);
>> +	return (kvm_vgic_global_state.has_gicv4_1 ||
>> +		(kvm_vgic_global_state.has_gicv4 && vgic_has_its(kvm)));
>>   }
> 
> Not related to this patch, but I think that the function name can be
> improved a bit after this change. It now indicates whether the vGIC
> supports direct MSIs injection *or* direct SGIs injection, not just
> MSIs. And if vgic_has_its() is false, we don't even support MSIs.

Yes, I noticed that too. But in the spirit of keeping the change minimal
and avoid later conflicts with potential fixes, I decided against 
changing
it right now.

> The fix itself looks correct to me,
> 
> Reviewed-by: Zenghui Yu <yuzenghui@huawei.com>

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

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

end of thread, other threads:[~2020-04-30 11:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-25  9:44 [PATCH] KVM: arm64: vgic-v4: Initialize GICv4.1 even in the absence of a virtual ITS Marc Zyngier
2020-04-25  9:44 ` Marc Zyngier
2020-04-25  9:44 ` Marc Zyngier
2020-04-30 11:24 ` Zenghui Yu
2020-04-30 11:24   ` Zenghui Yu
2020-04-30 11:24   ` Zenghui Yu
2020-04-30 11:39   ` Marc Zyngier
2020-04-30 11:39     ` Marc Zyngier
2020-04-30 11:39     ` 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.