mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zachary Amsden <zach@vmware.com>
To: Greg KH <gregkh@suse.de>
Cc: Yinghai Lu <yinghai@kernel.org>,
	Huang Ying <ying.huang@intel.com>,
	Jeremy Fitzhardinge <jeremy@goop.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	"norman@thebacks.co.uk" <norman@thebacks.co.uk>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Alok Kataria <alokkataria1@gmail.com>,
	"bruno.premont@restena.lu" <bruno.premont@restena.lu>,
	"xl@xlsigned.net" <xl@xlsigned.net>,
	"dsd@gentoo.org" <dsd@gentoo.org>
Subject: Re: [PATCH] Fix VMI crash on boot in 2.6.27, 2.6.28 kernels
Date: Thu, 11 Dec 2008 14:23:11 -0800	[thread overview]
Message-ID: <1229034191.8766.63.camel@bodhitayantram.eng.vmware.com> (raw)
In-Reply-To: <20081211033105.GA31972@suse.de>

[-- Attachment #1: Type: text/plain, Size: 511 bytes --]

On Wed, 2008-12-10 at 19:31 -0800, Greg KH wrote:

> > +#ifdef CONFIG_VMI
> > +	/* VMI may relocate the fixmap; do this before touching ioremap area */
> > +	vmi_init();
> > +#endif
> 
> Shouldn't the #ifdef not be needed here if the .h files are set up
> properly for the vmi_init prototype?  Please try to keep them out of .c
> files wherever possible.

Yes, they should.  Judging by setup.c though, you would think the
opposite... in any case I fixed it.  Please apply - and yes, I tested
compile both ways.

[-- Attachment #2: x86-vmi-boot-ioremap-fix-take-3.patch --]
[-- Type: text/x-patch, Size: 3076 bytes --]

VMI initialiation can relocate the fixmap, causing early_ioremap
to malfunction if it is initialized before the relocation.
To fix this, VMI activation is split into two phases; the detection,
which must happen before setting up ioremap, and the activation,
which must happen after parsing early boot parameters.

This fixes a crash on boot when VMI is enabled under VMware.

Signed-off-by: Zachary Amsden <zach@vmware.com>

diff --git a/arch/x86/include/asm/vmi.h b/arch/x86/include/asm/vmi.h
index b7c0dea..128958a 100644
--- a/arch/x86/include/asm/vmi.h
+++ b/arch/x86/include/asm/vmi.h
@@ -223,9 +223,15 @@ struct pci_header {
 } __attribute__((packed));
 
 /* Function prototypes for bootstrapping */
+#ifdef CONFIG_VMI
 extern void vmi_init(void);
+extern void vmi_activate(void);
 extern void vmi_bringup(void);
-extern void vmi_apply_boot_page_allocations(void);
+#else
+#define vmi_init()
+#define vmi_activate()
+#define vmi_bringup()
+#endif
 
 /* State needed to start an application processor in an SMP system. */
 struct vmi_ap_state {
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 9d5674f..bdec76e 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -794,6 +794,9 @@ void __init setup_arch(char **cmdline_p)
 	printk(KERN_INFO "Command line: %s\n", boot_command_line);
 #endif
 
+	/* VMI may relocate the fixmap; do this before touching ioremap area */
+	vmi_init();
+
 	early_cpu_init();
 	early_ioremap_init();
 
@@ -880,13 +883,8 @@ void __init setup_arch(char **cmdline_p)
 	check_efer();
 #endif
 
-#if defined(CONFIG_VMI) && defined(CONFIG_X86_32)
-	/*
-	 * Must be before kernel pagetables are setup
-	 * or fixmap area is touched.
-	 */
-	vmi_init();
-#endif
+	/* Must be before kernel pagetables are setup */
+	vmi_activate();
 
 	/* after early param, so could get panic from serial */
 	reserve_early_setup_data();
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 7b10933..f71f96f 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -294,9 +294,7 @@ static void __cpuinit start_secondary(void *unused)
 	 * fragile that we want to limit the things done here to the
 	 * most necessary things.
 	 */
-#ifdef CONFIG_VMI
 	vmi_bringup();
-#endif
 	cpu_init();
 	preempt_disable();
 	smp_callin();
diff --git a/arch/x86/kernel/vmi_32.c b/arch/x86/kernel/vmi_32.c
index 8b6c393..22fd657 100644
--- a/arch/x86/kernel/vmi_32.c
+++ b/arch/x86/kernel/vmi_32.c
@@ -960,8 +960,6 @@ static inline int __init activate_vmi(void)
 
 void __init vmi_init(void)
 {
-	unsigned long flags;
-
 	if (!vmi_rom)
 		probe_vmi_rom();
 	else
@@ -973,13 +971,21 @@ void __init vmi_init(void)
 
 	reserve_top_address(-vmi_rom->virtual_top);
 
-	local_irq_save(flags);
-	activate_vmi();
-
 #ifdef CONFIG_X86_IO_APIC
 	/* This is virtual hardware; timer routing is wired correctly */
 	no_timer_check = 1;
 #endif
+}
+
+void vmi_activate(void)
+{
+	unsigned long flags;
+
+	if (!vmi_rom)
+		return;
+
+	local_irq_save(flags);
+	activate_vmi();
 	local_irq_restore(flags & X86_EFLAGS_IF);
 }
 

  reply	other threads:[~2008-12-11 21:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-10  0:50 [PATCH] Fix VMI crash on boot in 2.6.27+ kernels Zachary Amsden
2008-12-10  0:44 ` Greg KH
2008-12-10  7:30   ` Zachary Amsden
2008-12-10  1:15 ` Yinghai Lu
2008-12-10  1:48   ` H. Peter Anvin
2008-12-10  7:31     ` Zachary Amsden
2008-12-10  9:05       ` H. Peter Anvin
2008-12-10  7:36   ` Zachary Amsden
2008-12-11  0:06   ` Zachary Amsden
2008-12-11  0:20     ` Yinghai Lu
2008-12-11  3:31       ` Greg KH
2008-12-11 22:23         ` Zachary Amsden [this message]
2008-12-11 21:45           ` [PATCH] Fix VMI crash on boot in 2.6.27, 2.6.28 kernels Greg KH
2008-12-11 23:37             ` H. Peter Anvin
2008-12-12  5:37             ` Zachary Amsden
2008-12-11  5:44       ` [PATCH] Fix VMI crash on boot in 2.6.27+ kernels Zachary Amsden

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1229034191.8766.63.camel@bodhitayantram.eng.vmware.com \
    --to=zach@vmware.com \
    --cc=akpm@linux-foundation.org \
    --cc=alokkataria1@gmail.com \
    --cc=bruno.premont@restena.lu \
    --cc=dsd@gentoo.org \
    --cc=gregkh@suse.de \
    --cc=hpa@zytor.com \
    --cc=jeremy@goop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=norman@thebacks.co.uk \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=xl@xlsigned.net \
    --cc=ying.huang@intel.com \
    --cc=yinghai@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome