[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <24b80006-dcea-4a76-b5c8-e147d9191ed2@suse.com>
Date: Tue, 3 Dec 2024 07:47:54 +0100
From: Juergen Gross <jgross@...e.com>
To: Xin Li <xin@...or.com>, Kevin Loughlin <kevinloughlin@...gle.com>,
Andrew Cooper <andrew.cooper3@...rix.com>
Cc: linux-kernel@...r.kernel.org, seanjc@...gle.com, pbonzini@...hat.com,
tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
dave.hansen@...ux.intel.com, x86@...nel.org, hpa@...or.com,
kvm@...r.kernel.org, thomas.lendacky@....com, pgonda@...gle.com,
sidtelang@...gle.com, mizhang@...gle.com, virtualization@...ts.linux.dev,
xen-devel@...ts.xenproject.org, bcm-kernel-feedback-list@...adcom.com
Subject: Re: [RFC PATCH 1/2] x86, lib, xenpv: Add WBNOINVD helper functions
On 03.12.24 05:09, Xin Li wrote:
> On 12/2/2024 5:44 PM, Kevin Loughlin wrote:
>> On Mon, Dec 2, 2024 at 5:28 PM Andrew Cooper <andrew.cooper3@...rix.com> wrote:
>>>
>>> On 03/12/2024 12:59 am, Kevin Loughlin wrote:
>>>> diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
>>>> index d4eb9e1d61b8..c040af2d8eff 100644
>>>> --- a/arch/x86/include/asm/paravirt.h
>>>> +++ b/arch/x86/include/asm/paravirt.h
>>>> @@ -187,6 +187,13 @@ static __always_inline void wbinvd(void)
>>>> PVOP_ALT_VCALL0(cpu.wbinvd, "wbinvd", ALT_NOT_XEN);
>>>> }
>>>>
>>>> +extern noinstr void pv_native_wbnoinvd(void);
>>>> +
>>>> +static __always_inline void wbnoinvd(void)
>>>> +{
>>>> + PVOP_ALT_VCALL0(cpu.wbnoinvd, "wbnoinvd", ALT_NOT_XEN);
>>>> +}
>>>
>>> Given this, ...
>>>
>>>> diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
>>>> index fec381533555..a66b708d8a1e 100644
>>>> --- a/arch/x86/kernel/paravirt.c
>>>> +++ b/arch/x86/kernel/paravirt.c
>>>> @@ -149,6 +154,7 @@ struct paravirt_patch_template pv_ops = {
>>>> .cpu.write_cr0 = native_write_cr0,
>>>> .cpu.write_cr4 = native_write_cr4,
>>>> .cpu.wbinvd = pv_native_wbinvd,
>>>> + .cpu.wbnoinvd = pv_native_wbnoinvd,
>>>> .cpu.read_msr = native_read_msr,
>>>> .cpu.write_msr = native_write_msr,
>>>> .cpu.read_msr_safe = native_read_msr_safe,
>>>
>>> this, and ...
>>>
>>>> diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
>>>> index d6818c6cafda..a5c76a6f8976 100644
>>>> --- a/arch/x86/xen/enlighten_pv.c
>>>> +++ b/arch/x86/xen/enlighten_pv.c
>>>> @@ -1162,6 +1162,7 @@ static const typeof(pv_ops) xen_cpu_ops __initconst = {
>>>> .write_cr4 = xen_write_cr4,
>>>>
>>>> .wbinvd = pv_native_wbinvd,
>>>> + .wbnoinvd = pv_native_wbnoinvd,
>>>>
>>>> .read_msr = xen_read_msr,
>>>> .write_msr = xen_write_msr,
>>>
>>> this, what is the point having a paravirt hook which is wired to
>>> native_wbnoinvd() in all cases?
>>>
>>> That just seems like overhead for overhead sake.
>>
>> I'm mirroring what's done for WBINVD here, which was changed to a
>> paravirt hook in 10a099405fdf ("cpuidle, xenpv: Make more PARAVIRT_XXL
>> noinstr clean") in order to avoid calls out to instrumented code as
>> described in the commit message in more detail. I believe a hook is
>> similarly required for WBNOINVD, but please let me know if you
>> disagree. Thanks!
>
> Then the question is why we need to add WBINVD/WBNOINVD to the paravirt
> hooks.
>
We don't.
The wbinvd hook is a leftover from lguest times.
I'll send a patch to remove it.
Juergen
P.S.: As the paravirt maintainer I would have preferred to be Cc-ed in the
initial patch mail.
Powered by blists - more mailing lists