[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250414140812.GH5600@noisy.programming.kicks-ass.net>
Date: Mon, 14 Apr 2025 16:08:12 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Uros Bizjak <ubizjak@...il.com>
Cc: x86@...nel.org, kys@...rosoft.com, haiyangz@...rosoft.com,
wei.liu@...nel.org, decui@...rosoft.com, tglx@...utronix.de,
mingo@...hat.com, bp@...en8.de, dave.hansen@...ux.intel.com,
hpa@...or.com, jpoimboe@...nel.org,
pawan.kumar.gupta@...ux.intel.com, seanjc@...gle.com,
pbonzini@...hat.com, ardb@...nel.org, kees@...nel.org,
Arnd Bergmann <arnd@...db.de>, gregkh@...uxfoundation.org,
linux-hyperv@...r.kernel.org, linux-kernel@...r.kernel.org,
kvm@...r.kernel.org, linux-efi@...r.kernel.org,
samitolvanen@...gle.com, ojeda@...nel.org
Subject: Re: [PATCH 4/6] x86,hyperv: Clean up hv_do_hypercall()
On Mon, Apr 14, 2025 at 04:06:41PM +0200, Uros Bizjak wrote:
>
>
> On 14. 04. 25 13:11, Peter Zijlstra wrote:
> > What used to be a simple few instructions has turned into a giant mess
> > (for x86_64). Not only does it use static_branch wrong, it mixes it
> > with dynamic branches for no apparent reason.
> >
> > Notably it uses static_branch through an out-of-line function call,
> > which completely defeats the purpose, since instead of a simple
> > JMP/NOP site, you get a CALL+RET+TEST+Jcc sequence in return, which is
> > absolutely idiotic.
> >
> > Add to that a dynamic test of hyperv_paravisor_present, something
> > which is set once and never changed.
> >
> > Replace all this idiocy with a single direct function call to the
> > right hypercall variant.
> >
> > Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
> > ---
> > arch/x86/hyperv/hv_init.c | 21 ++++++
> > arch/x86/hyperv/ivm.c | 14 ++++
> > arch/x86/include/asm/mshyperv.h | 137 +++++++++++-----------------------------
> > arch/x86/kernel/cpu/mshyperv.c | 18 +++--
> > 4 files changed, 88 insertions(+), 102 deletions(-)
> >
> > --- a/arch/x86/hyperv/hv_init.c
> > +++ b/arch/x86/hyperv/hv_init.c
> > @@ -35,7 +35,28 @@
> > #include <linux/highmem.h>
> > void *hv_hypercall_pg;
> > +
> > +#ifdef CONFIG_X86_64
> > +u64 hv_pg_hypercall(u64 control, u64 param1, u64 param2)
> > +{
> > + u64 hv_status;
> > +
> > + if (!hv_hypercall_pg)
> > + return U64_MAX;
> > +
> > + register u64 __r8 asm("r8") = param2;
> > + asm volatile (CALL_NOSPEC
> > + : "=a" (hv_status), ASM_CALL_CONSTRAINT,
> > + "+c" (control), "+d" (param1)
> > + : "r" (__r8),
>
> r8 is call-clobbered register, so you should use "+r" (__r8) to properly
> clobber it:
Ah, okay.
Powered by blists - more mailing lists