[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zr9ZgDIhUEzUlOFa@google.com>
Date: Fri, 16 Aug 2024 06:52:00 -0700
From: Sean Christopherson <seanjc@...gle.com>
To: Jacob Pan <jacob.jun.pan@...ux.intel.com>
Cc: X86 Kernel <x86@...nel.org>, LKML <linux-kernel@...r.kernel.org>,
Thomas Gleixner <tglx@...utronix.de>, Dave Hansen <dave.hansen@...el.com>,
"H. Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Xin Li <xin3.li@...el.com>, linux-perf-users@...r.kernel.org,
Peter Zijlstra <peterz@...radead.org>, Paolo Bonzini <pbonzini@...hat.com>,
Tony Luck <tony.luck@...el.com>, Andy Lutomirski <luto@...nel.org>, acme@...nel.org,
kan.liang@...ux.intel.com, Andi Kleen <andi.kleen@...el.com>,
Nikolay Borisov <nik.borisov@...e.com>, Sohil Mehta <sohil.mehta@...el.com>,
Zeng Guang <guang.zeng@...el.com>
Subject: Re: [PATCH v4 11/11] KVM: X86: Use common code for PV IPIs in linux guest
"x86/kvm:" for the scope. "KVM: x86:" is for host-side KVM, this is guest code.
On Tue, Jul 09, 2024, Jacob Pan wrote:
> 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.
Please state what the patch actually does, not what it can do. For folks that
aren't intimately familiar with FRED (read: me), that second sentence in particular
is wildly unhelpful. I had to download yet another version of the FRED spec, and
decipher the poorly documented software-defined encoding scheme introduced by this
series just to understand what this patch does.
And the order of patches in this series is broken. Overloading the vector *before*
switching the PV IPI code to __prepare_ICR() will result in KVM sending garbage
to the host. I.e. _all_ IPI implementations need to be made safe before the NMI
source reporting code can be introduced.
> Originally-by: Zeng Guang <guang.zeng@...el.com>
> Signed-off-by: Jacob Pan <jacob.jun.pan@...ux.intel.com>
> ---
> v4: Refine comments, no functional change.
> ---
> 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);
Rather than force KVM to throw in junk dest+shorthand, what about adding a
__prepare_ICR_vector()? Then KVM doesn't need to arbitrarily pass zeroes, and
even __prepare_ICR() itself benefits (IMO), e.g. this is nice and easy to read:
static inline unsigned int __prepare_ICR(unsigned int shortcut, int vector,
unsigned int dest)
{
return shortcut | dest | __prepare_ICR_vector(vector);
}
Powered by blists - more mailing lists