[PATCH v3 11/11] KVM: X86: Use common code for PV IPIs in linux guest

Jacob Pan posted 11 patches 1 year, 5 months ago
[PATCH v3 11/11] KVM: X86: Use common code for PV IPIs in linux guest
Posted by Jacob Pan 1 year, 5 months ago
Paravirtual apic hooks to enable PV IPIs for KVM if the "send IPI"
hypercall is available. Reuse common code for ICR preparation which
covers NMI-source reporting if in effect.

Originally-by: Zeng Guang <guang.zeng@intel.com>
Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
---
 arch/x86/kernel/kvm.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 263f8aed4e2c..a45d60aa0302 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -516,15 +516,7 @@ static void __send_ipi_mask(const struct cpumask *mask, int vector)
 
 	local_irq_save(flags);
 
-	switch (vector) {
-	default:
-		icr = APIC_DM_FIXED | vector;
-		break;
-	case NMI_VECTOR:
-		icr = APIC_DM_NMI;
-		break;
-	}
-
+	icr = __prepare_ICR(0, vector, 0);
 	for_each_cpu(cpu, mask) {
 		apic_id = per_cpu(x86_cpu_to_apicid, cpu);
 		if (!ipi_bitmap) {
-- 
2.25.1
Re: [PATCH v3 11/11] KVM: X86: Use common code for PV IPIs in linux guest
Posted by Xin Li 1 year, 5 months ago
On 6/28/2024 1:18 PM, Jacob Pan wrote:
> Paravirtual apic hooks to enable PV IPIs for KVM if the "send IPI"

s/Paravirtual apic/Paravirtualize APIC/

> hypercall is available. Reuse common code for ICR preparation which
> covers NMI-source reporting if in effect.

I see a lot of "NMI source". Should we use "NMI-source" in all places?

> 
> Originally-by: Zeng Guang <guang.zeng@intel.com>
> Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
> ---
>   arch/x86/kernel/kvm.c | 10 +---------
>   1 file changed, 1 insertion(+), 9 deletions(-)
> 
> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> index 263f8aed4e2c..a45d60aa0302 100644
> --- a/arch/x86/kernel/kvm.c
> +++ b/arch/x86/kernel/kvm.c
> @@ -516,15 +516,7 @@ static void __send_ipi_mask(const struct cpumask *mask, int vector)
>   
>   	local_irq_save(flags);
>   
> -	switch (vector) {
> -	default:
> -		icr = APIC_DM_FIXED | vector;
> -		break;
> -	case NMI_VECTOR:
> -		icr = APIC_DM_NMI;
> -		break;
> -	}
> -
> +	icr = __prepare_ICR(0, vector, 0);
>   	for_each_cpu(cpu, mask) {
>   		apic_id = per_cpu(x86_cpu_to_apicid, cpu);
>   		if (!ipi_bitmap) {
Re: [PATCH v3 11/11] KVM: X86: Use common code for PV IPIs in linux guest
Posted by Jacob Pan 1 year, 5 months ago
On Sat, 29 Jun 2024 11:38:10 -0700, Xin Li <xin@zytor.com> wrote:

> On 6/28/2024 1:18 PM, Jacob Pan wrote:
> > Paravirtual apic hooks to enable PV IPIs for KVM if the "send IPI"  
> 
> s/Paravirtual apic/Paravirtualize APIC/

Paravirtual APIC makes sense to me. This is also the same language used in
previous commits.

How about:

"The paravirtual APIC hooks in KVM, some of which are used for sending PV
IPIs, can reuse common code for ICR preparation. This shared code also
encompasses NMI-source reporting when in effect."

> > hypercall is available. Reuse common code for ICR preparation which
> > covers NMI-source reporting if in effect.  
> 
> I see a lot of "NMI source". Should we use "NMI-source" in all places?
Not really, here NMI-source is a compound modifier before noun "reporting".

For other places, hyphen(-) is not needed if it is just a noun. e.g.
"partial due to unknown NMI sources"

I will go through the patchset to make sure they are consistent.

> > 
> > Originally-by: Zeng Guang <guang.zeng@intel.com>
> > Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
> > ---
> >   arch/x86/kernel/kvm.c | 10 +---------
> >   1 file changed, 1 insertion(+), 9 deletions(-)
> > 
> > diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> > index 263f8aed4e2c..a45d60aa0302 100644
> > --- a/arch/x86/kernel/kvm.c
> > +++ b/arch/x86/kernel/kvm.c
> > @@ -516,15 +516,7 @@ static void __send_ipi_mask(const struct cpumask
> > *mask, int vector) 
> >   	local_irq_save(flags);
> >   
> > -	switch (vector) {
> > -	default:
> > -		icr = APIC_DM_FIXED | vector;
> > -		break;
> > -	case NMI_VECTOR:
> > -		icr = APIC_DM_NMI;
> > -		break;
> > -	}
> > -
> > +	icr = __prepare_ICR(0, vector, 0);
> >   	for_each_cpu(cpu, mask) {
> >   		apic_id = per_cpu(x86_cpu_to_apicid, cpu);
> >   		if (!ipi_bitmap) {  
> 


Thanks,

Jacob
Re: [PATCH v3 11/11] KVM: X86: Use common code for PV IPIs in linux guest
Posted by Xin Li 1 year, 5 months ago
On 7/1/2024 9:38 AM, Jacob Pan wrote:
> 
> On Sat, 29 Jun 2024 11:38:10 -0700, Xin Li <xin@zytor.com> wrote:
> 
>> On 6/28/2024 1:18 PM, Jacob Pan wrote:
>>> Paravirtual apic hooks to enable PV IPIs for KVM if the "send IPI"
>>
>> s/Paravirtual apic/Paravirtualize APIC/
> 
> Paravirtual APIC makes sense to me. This is also the same language used in
> previous commits.

"Paravirtual apic hooks to enable..."

It needs to start with a verb, I can't read it as adj.

> 
> How about:
> 
> "The paravirtual APIC hooks in KVM, some of which are used for sending PV
> IPIs, can reuse common code for ICR preparation. This shared code also
> encompasses NMI-source reporting when in effect."

LGTM.

> 
>>> hypercall is available. Reuse common code for ICR preparation which
>>> covers NMI-source reporting if in effect.
>>
>> I see a lot of "NMI source". Should we use "NMI-source" in all places?
> Not really, here NMI-source is a compound modifier before noun "reporting".
> 
> For other places, hyphen(-) is not needed if it is just a noun. e.g.
> "partial due to unknown NMI sources"
> 
> I will go through the patchset to make sure they are consistent.

Right, make them consistent.