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]
Date:	Tue, 16 Oct 2012 18:57:16 +0200
From:	Borislav Petkov <bp@...en8.de>
To:	Fenghua Yu <fenghua.yu@...el.com>
Cc:	Ingo Molnar <mingo@...e.hu>, Thomas Gleixner <tglx@...utronix.de>,
	H Peter Anvin <hpa@...or.com>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Asit K Mallick <asit.k.mallick@...el.com>,
	Tony Luck <tony.luck@...el.com>,
	Arjan Dan De Ven <arjan@...ux.intel.com>,
	Suresh B Siddha <suresh.b.siddha@...el.com>,
	Len Brown <len.brown@...el.com>,
	"Srivatssa S. Bhat" <srivatsa.bhat@...ux.vnet.ibm.com>,
	Randy Dunlap <rdunlap@...otime.net>,
	Chen Gong <gong.chen@...ux.intel.com>,
	linux-kernel <linux-kernel@...r.kernel.org>,
	linux-pm <linux-pm@...r.kernel.org>, x86 <x86@...nel.org>
Subject: Re: [PATCH v9 08/12] x86, hotplug: Wake up CPU0 via NMI instead of
 INIT, SIPI, SIPI

On Fri, Oct 12, 2012 at 09:09:45AM -0700, Fenghua Yu wrote:
> From: Fenghua Yu <fenghua.yu@...el.com>
> 
> Instead of waiting for STARTUP after INITs, BSP will execute the BIOS boot-strap
> code which is not a desired behavior for waking up BSP. To avoid the boot-strap
> code, wake up CPU0 by NMI instead.
> 
> This works to wake up soft offlined CPU0 only. If CPU0 is hard offlined (i.e.
> physically hot removed and then hot added), NMI won't wake it up. We'll change
> this code in the future to wake up hard offlined CPU0 if real platform and
> request are available.
> 
> AP is still waken up as before by INIT, SIPI, SIPI sequence.
> 
> Signed-off-by: Fenghua Yu <fenghua.yu@...el.com>
> ---
>  arch/x86/include/asm/cpu.h |    1 +
>  arch/x86/kernel/smpboot.c  |  112 +++++++++++++++++++++++++++++++++++++++++--
>  2 files changed, 107 insertions(+), 6 deletions(-)

[ … ]

> @@ -727,8 +745,47 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
>  	 */
>  	if (apic->wakeup_secondary_cpu)
>  		boot_error = apic->wakeup_secondary_cpu(apicid, start_ip);
> -	else
> -		boot_error = wakeup_secondary_cpu_via_init(apicid, start_ip);
> +	else {
> +		if (cpu)
> +			/*
> +			 * Wake up AP by INIT, INIT, STARTUP sequence.
> +			 */
> +			boot_error = wakeup_secondary_cpu_via_init(apicid,
> +								   start_ip);
> +		else {
> +			/*
> +			 * Instead of waiting for STARTUP after INITs, BSP will
> +			 * execute the BIOS boot-strap code which is not a
> +			 * desired behavior for waking up BSP. To avoid the
> +			 * boot-strap code, wake up CPU0 by NMI instead.
> +			 *
> +			 * This works to wake up soft offlined CPU0 only. If
> +			 * CPU0 is hard offlined (i.e. physically hot removed
> +			 * and then hot added), NMI won't wake it up. We'll
> +			 * change this code in the future to wake up hard
> +			 * offlined CPU0 if real platform and request are
> +			 * available.
> +			 */
> +			int id;
> +
> +			enable_start_cpu0 = 1;
> +			/*
> +			 * Register a NMI handler to help wake up CPU0.
> +			 */
> +			boot_error = register_nmi_handler(NMI_LOCAL,
> +					 wakeup_cpu0_nmi, 0, "wake_cpu0");
> +
> +			if (!boot_error) {
> +				cpu0_nmi_registered = 1;
> +				if (apic->dest_logical == APIC_DEST_LOGICAL)
> +					id = cpu0_logical_apicid;
> +				else
> +					id = apicid;
> +				boot_error = wakeup_secondary_cpu_via_nmi(id,
> +								start_ip);
> +			}

This whole else-part for cpu 0 could be carved out into a separate
function so that you can save yourself the awkward code indentation and
make this a lot more readable.

Thanks.

-- 
Regards/Gruss,
Boris.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ