lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
 <BN7PR02MB41484D4FC07F44033068A5A2D4D62@BN7PR02MB4148.namprd02.prod.outlook.com>
Date: Mon, 10 Mar 2025 22:23:24 +0000
From: Michael Kelley <mhklinux@...look.com>
To: Nuno Das Neves <nunodasneves@...ux.microsoft.com>, Stanislav Kinsburskii
	<skinsburskii@...ux.microsoft.com>
CC: "linux-hyperv@...r.kernel.org" <linux-hyperv@...r.kernel.org>,
	"x86@...nel.org" <x86@...nel.org>, "linux-arm-kernel@...ts.infradead.org"
	<linux-arm-kernel@...ts.infradead.org>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>, "linux-arch@...r.kernel.org"
	<linux-arch@...r.kernel.org>, "linux-acpi@...r.kernel.org"
	<linux-acpi@...r.kernel.org>, "kys@...rosoft.com" <kys@...rosoft.com>,
	"haiyangz@...rosoft.com" <haiyangz@...rosoft.com>, "wei.liu@...nel.org"
	<wei.liu@...nel.org>, "decui@...rosoft.com" <decui@...rosoft.com>,
	"catalin.marinas@....com" <catalin.marinas@....com>, "will@...nel.org"
	<will@...nel.org>, "tglx@...utronix.de" <tglx@...utronix.de>,
	"mingo@...hat.com" <mingo@...hat.com>, "bp@...en8.de" <bp@...en8.de>,
	"dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>, "hpa@...or.com"
	<hpa@...or.com>, "daniel.lezcano@...aro.org" <daniel.lezcano@...aro.org>,
	"joro@...tes.org" <joro@...tes.org>, "robin.murphy@....com"
	<robin.murphy@....com>, "arnd@...db.de" <arnd@...db.de>,
	"jinankjain@...ux.microsoft.com" <jinankjain@...ux.microsoft.com>,
	"muminulrussell@...il.com" <muminulrussell@...il.com>,
	"mrathor@...ux.microsoft.com" <mrathor@...ux.microsoft.com>,
	"ssengar@...ux.microsoft.com" <ssengar@...ux.microsoft.com>,
	"apais@...ux.microsoft.com" <apais@...ux.microsoft.com>,
	"Tianyu.Lan@...rosoft.com" <Tianyu.Lan@...rosoft.com>,
	"stanislav.kinsburskiy@...il.com" <stanislav.kinsburskiy@...il.com>,
	"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
	"vkuznets@...hat.com" <vkuznets@...hat.com>, "prapal@...ux.microsoft.com"
	<prapal@...ux.microsoft.com>, "muislam@...rosoft.com"
	<muislam@...rosoft.com>, "anrayabh@...ux.microsoft.com"
	<anrayabh@...ux.microsoft.com>, "rafael@...nel.org" <rafael@...nel.org>,
	"lenb@...nel.org" <lenb@...nel.org>, "corbet@....net" <corbet@....net>
Subject: RE: [PATCH v5 08/10] x86: hyperv: Add mshv_handler irq handler and
 setup function

From: Nuno Das Neves <nunodasneves@...ux.microsoft.com> Sent: Monday, March 10, 2025 2:47 PM
> 
> On 3/7/2025 9:38 AM, Michael Kelley wrote:
> > From: Nuno Das Neves <nunodasneves@...ux.microsoft.com> Sent: Friday, February 28,
> 2025 4:38 PM
> >>
> >> On 2/26/2025 3:43 PM, Stanislav Kinsburskii wrote:
> >>> On Wed, Feb 26, 2025 at 03:08:02PM -0800, Nuno Das Neves wrote:
> >>>> This will handle SYNIC interrupts such as intercepts, doorbells, and
> >>>> scheduling messages intended for the mshv driver.
> >>>>
> >>>> Signed-off-by: Nuno Das Neves <nunodasneves@...ux.microsoft.com>
> >>>> Reviewed-by: Wei Liu <wei.liu@...nel.org>
> >>>> Reviewed-by: Tianyu Lan <tiala@...rosoft.com>
> >>>> ---
> >>>>  arch/x86/kernel/cpu/mshyperv.c | 9 +++++++++
> >>>>  drivers/hv/hv_common.c         | 5 +++++
> >>>>  include/asm-generic/mshyperv.h | 1 +
> >>>>  3 files changed, 15 insertions(+)
> >>>>
> >>>> diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> >>>> index 0116d0e96ef9..616e9a5d77b4 100644
> >>>> --- a/arch/x86/kernel/cpu/mshyperv.c
> >>>> +++ b/arch/x86/kernel/cpu/mshyperv.c
> >>>> @@ -107,6 +107,7 @@ void hv_set_msr(unsigned int reg, u64 value)
> >>>>  }
> >>>>  EXPORT_SYMBOL_GPL(hv_set_msr);
> >>>>
> >>>> +static void (*mshv_handler)(void);
> >>>>  static void (*vmbus_handler)(void);
> >>>>  static void (*hv_stimer0_handler)(void);
> >>>>  static void (*hv_kexec_handler)(void);
> >>>> @@ -117,6 +118,9 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_hyperv_callback)
> >>>>  	struct pt_regs *old_regs = set_irq_regs(regs);
> >>>>
> >>>>  	inc_irq_stat(irq_hv_callback_count);
> >>>> +	if (mshv_handler)
> >>>> +		mshv_handler();
> >>>
> >>> Can mshv_handler be defined as a weak symbol doing nothing instead
> >>> of defining it a null pointer?
> >>> This should allow to simplify this code and get rid of
> >>> hv_setup_mshv_handler, which looks redundant.
> >>>
> >> Interesting, I tested this and it does seems to work! It seems like
> >> a good change, thanks.
> >
> > Just be a bit careful. When CONFIG_HYPERV=n, mshyperv.c still gets
> > built even through none of the other Hyper-V related files do.  There
> > are #ifdef CONFIG_HYPERV in mshyperv.c to eliminate references to
> > Hyper-V files that wouldn't be built. I'd suggest doing a test build with
> > that configuration to make sure it's all clean.
> >
> Thanks Michael - I don't think it would be an issue since the __weak version
> would be defined in mshyperv.c itself, replacing the function pointer.

Yes, sounds right to me.

> 
> However, I went and tested this __weak version again with CONFIG_MSHV_ROOT=m
> and it does not actually work. Everything seems ok at first (it compiles,
> can insert the module), but upon starting a guest, the interrupts don't get
> delivered to the root (or rather, they don't get handled by mshv_hander()).
> 
> This seems to match with what the ld docs say - There's an option
> LD_DYNAMIC_LINK to allow __weak symbols to be overridden by the dynamic
> linker, but this is not enabled in the kernel.
> 

Yeah, I recall learning the hard way that a symbol defined in a module doesn't
override a __weak symbol in the kernel image. At the time, I gave up and took
a different path, and didn't get as far as looking at 'ld' options like you did. :-)

Michael

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ