virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Chris Wright <chrisw@sous-sol.org>
To: akpm@osdl.org, ak@muc.de
Cc: Rusty Russell <rusty@rustcorp.com.au>,
	Jeremy Fitzhardinge <jeremy@goop.org>,
	Zachary Amsden <zach@vmware.com>,
	linux-kernel@vger.kernel.org, virtualization@lists.osdl.org
Subject: [PATCH 3/7] More generic paravirtualization entry point.
Date: Sat, 28 Oct 2006 00:00:03 -0700	[thread overview]
Message-ID: <20061029024605.950760000@sous-sol.org> (raw)
In-Reply-To: 20061029024504.760769000@sous-sol.org

[-- Attachment #1: 011-paravirt-head.S.patch --]
[-- Type: text/plain, Size: 3420 bytes --]

1) Each hypervisor writes a probe function to detect whether we are
   running under that hypervisor.  paravirt_probe() registers this
   function.

2) If vmlinux is booted with ring != 0, we call all the probe
   functions (with registers except %esp intact) in link order: the
   winner will not return.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Zachary Amsden <zach@vmware.com>

---
 arch/i386/kernel/Makefile      |    2 ++
 arch/i386/kernel/head.S        |   33 +++++++++++++++++++++++++++++++++
 arch/i386/kernel/paravirt.c    |    6 +++++-
 arch/i386/kernel/vmlinux.lds.S |    6 ++++++
 include/asm-i386/paravirt.h    |    5 +++++
 5 files changed, 51 insertions(+), 1 deletion(-)

--- linux-2.6-pv.orig/arch/i386/kernel/Makefile
+++ linux-2.6-pv/arch/i386/kernel/Makefile
@@ -39,6 +39,8 @@ obj-$(CONFIG_VM86)		+= vm86.o
 obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
 obj-$(CONFIG_HPET_TIMER) 	+= hpet.o
 obj-$(CONFIG_K8_NB)		+= k8.o
+
+# Make sure this is linked after any other paravirt_ops structs: see head.S
 obj-$(CONFIG_PARAVIRT)		+= paravirt.o
 
 EXTRA_AFLAGS   := -traditional
--- linux-2.6-pv.orig/arch/i386/kernel/head.S
+++ linux-2.6-pv/arch/i386/kernel/head.S
@@ -55,6 +55,12 @@
  */
 ENTRY(startup_32)
 
+#ifdef CONFIG_PARAVIRT
+        movl %cs, %eax
+        testl $0x3, %eax
+        jnz startup_paravirt
+#endif
+
 /*
  * Set segments to known values.
  */
@@ -486,6 +492,33 @@ ignore_int:
 #endif
 	iret
 
+#ifdef CONFIG_PARAVIRT
+startup_paravirt:
+	cld
+ 	movl $(init_thread_union+THREAD_SIZE),%esp
+
+	/* We take pains to preserve all the regs. */
+	pushl	%edx
+	pushl	%ecx
+	pushl	%eax
+
+	/* paravirt.o is last in link, and that probe fn never returns */
+	pushl	$__start_paravirtprobe
+1:
+	movl	0(%esp), %eax
+	pushl	(%eax)
+	movl	8(%esp), %eax
+	call	*(%esp)
+	popl	%eax
+
+	movl	4(%esp), %eax
+	movl	8(%esp), %ecx
+	movl	12(%esp), %edx
+
+	addl	$4, (%esp)
+	jmp	1b
+#endif
+
 /*
  * Real beginning of normal "text" segment
  */
--- linux-2.6-pv.orig/arch/i386/kernel/paravirt.c
+++ linux-2.6-pv/arch/i386/kernel/paravirt.c
@@ -392,7 +392,11 @@ static int __init print_banner(void)
 	return 0;
 }
 core_initcall(print_banner);
- 
+
+/* We simply declare start_kernel to be the paravirt probe of last resort. */
+asmlinkage void __init start_kernel(void);
+paravirt_probe(start_kernel);
+  
 struct paravirt_ops paravirt_ops = {
 	.name = "bare hardware",
 	.paravirt_enabled = 0,
--- linux-2.6-pv.orig/arch/i386/kernel/vmlinux.lds.S
+++ linux-2.6-pv/arch/i386/kernel/vmlinux.lds.S
@@ -60,6 +60,12 @@ SECTIONS
 	CONSTRUCTORS
 	} :data
 
+  __start_paravirtprobe = .;
+  .paravirtprobe : AT(ADDR(.paravirtprobe) - LOAD_OFFSET) {
+	*(.paravirtprobe)
+  }
+  __stop_paravirtprobe = .;
+
   . = ALIGN(4096);
   __nosave_begin = .;
   .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) { *(.data.nosave) }
--- linux-2.6-pv.orig/include/asm-i386/paravirt.h
+++ linux-2.6-pv/include/asm-i386/paravirt.h
@@ -120,6 +120,11 @@ struct paravirt_ops
 	void (fastcall *iret)(void);
 };
 
+/* Mark a paravirt probe function. */
+#define paravirt_probe(fn)						\
+	static void (*__paravirtprobe_##fn)(void) __attribute_used__	\
+		__attribute__((__section__(".paravirtprobe"))) = fn
+
 extern struct paravirt_ops paravirt_ops;
 
 #define paravirt_enabled() (paravirt_ops.paravirt_enabled)

--

  parent reply	other threads:[~2006-10-28  7:00 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-29  2:45 [PATCH 0/7] x86 paravirtualization infrastructure Chris Wright
2006-10-28  7:00 ` [PATCH 1/7] header and stubs for paravirtualizing critical operations Chris Wright
2006-10-29 16:40   ` Andi Kleen
2006-10-28  7:00 ` [PATCH 2/7] Patch inline replacements for common paravirt operations Chris Wright
2006-10-28  7:00 ` Chris Wright [this message]
2006-10-29 16:41   ` [PATCH 3/7] More generic paravirtualization entry point Andi Kleen
2006-10-28  7:00 ` [PATCH 4/7] Allow selected bug checks to be skipped by paravirt kernels Chris Wright
2006-11-01 12:17   ` Pavel Machek
2006-11-01 22:40     ` Dave Jones
2006-11-01 23:24     ` Zachary Amsden
2006-11-02 10:20       ` Pavel Machek
2006-11-02 11:04         ` Zachary Amsden
2006-10-28  7:00 ` [PATCH 5/7] Allow disabling legacy power management modes with " Chris Wright
2006-10-28  7:00 ` [PATCH 6/7] Add APIC accessors to paravirt-ops Chris Wright
2006-10-29 16:31   ` Andi Kleen
2006-10-30  3:28     ` Rusty Russell
2006-10-30 23:11       ` Andi Kleen
2006-10-30 23:42         ` Chris Wright
2006-10-30 23:46           ` Andi Kleen
2006-10-30 23:55             ` Chris Wright
2006-10-31  1:45             ` Rusty Russell
2006-11-01 10:25         ` Rusty Russell
2006-11-01 10:27         ` [PATCH 1/7] paravirtualization: header and stubs for paravirtualizing critical operations Rusty Russell
2006-11-01 10:28           ` [PATCH 2/7] paravirtualization: Patch inline replacements for common paravirt operations Rusty Russell
2006-11-01 10:29             ` [PATCH 3/7] paravirtualization: More generic paravirtualization entry point Rusty Russell
2006-11-01 10:30               ` [PATCH 4/7] paravirtualization: Allow selected bug checks to be skipped by paravirt kernels Rusty Russell
2006-11-01 10:31                 ` [PATCH 5/7] paravirtualization: Allow disabling legacy power management modes with " Rusty Russell
2006-11-01 10:32                   ` [PATCH 6/7] paravirtualization: Add APIC accessors to paravirt-ops Rusty Russell
2006-11-01 10:34                     ` [PATCH 7/7] paravirtualization: Add mmu virtualization " Rusty Russell
2006-11-01 23:31                     ` [PATCH 6/7] paravirtualization: Add APIC accessors " Andrew Morton
2006-11-02  0:46                       ` Rusty Russell
2006-11-01 23:29                 ` [PATCH 4/7] paravirtualization: Allow selected bug checks to be skipped by paravirt kernels Andrew Morton
2006-11-01 23:58                   ` Jeremy Fitzhardinge
2006-11-02  0:01                   ` Rusty Russell
2006-11-01 23:27             ` [PATCH 2/7] paravirtualization: Patch inline replacements for common paravirt operations Andrew Morton
2006-11-02  0:47               ` Rusty Russell
2006-11-02  0:54                 ` Zachary Amsden
2006-11-01 10:45           ` [PATCH 1/7] paravirtualization: header and stubs for paravirtualizing critical operations Arjan van de Ven
2006-11-01 17:27             ` Andi Kleen
2006-11-01 23:32             ` Rusty Russell
2006-11-02  7:13           ` Andrew Morton
2006-11-02  7:44             ` Oleg Verych
2006-11-03  2:56           ` Andi Kleen
2006-11-03 20:35             ` Zachary Amsden
2006-11-03 21:09               ` Andi Kleen
2006-11-05  4:43                 ` Rusty Russell
2006-11-05  4:59                   ` Zachary Amsden
2006-11-05  5:08                     ` Rusty Russell
2006-11-05  5:46                   ` Andi Kleen
2006-11-05  6:18                     ` Andrew Morton
2006-11-05  6:21                     ` Rusty Russell
2006-11-05  6:57                       ` Andi Kleen
2006-11-18  2:08           ` john stultz
2006-10-28  7:00 ` [PATCH 7/7] Add mmu virtualization to paravirt-ops Chris Wright

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=20061029024605.950760000@sous-sol.org \
    --to=chrisw@sous-sol.org \
    --cc=ak@muc.de \
    --cc=akpm@osdl.org \
    --cc=jeremy@goop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=virtualization@lists.osdl.org \
    --cc=zach@vmware.com \
    /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;
as well as URLs for NNTP newsgroup(s).