Skip to contentSkip to conversation

paravirt: refactor struct paravirt_ops into smaller pv_*_ops

RFC PATCH In review Jeremy Fitzhardinge 1 participant 1 message Oct 12, 2007 PARAVIRT_OPS interface

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/2 paravirt: refactor struct paravirt_ops into smaller pv_*_ops

[ Changes since last post: updated lguest; fixed a couple of bugs. ]

This patch refactors the paravirt_ops structure into groups of functionally related ops:

pv_info - random info, rather than function entrypoints pv_init_ops - functions used at boot time (some for module_init too) pv_misc_ops - lazy mode, which didn't fit well anywhere else pv_time_ops - time-related functions
pv_cpu_ops - various privileged instruction ops pv_irq_ops - operations for managing interrupt state pv_apic_ops - APIC operations
pv_mmu_ops - operations for managing pagetables

There are several motivations for this:

1. Some of these ops will be general to all x86, and some will be i386/x86-64 specific. This makes it easier to share common stuff while allowing separate implementations where needed.

2. At the moment we must export all of paravirt_ops, but modules only need selected parts of it. This allows us to export on a case by case basis (and also choose which export license we want to apply).

3. Functional groupings make things a bit more readable.

struct paravirt_ops still exists as a container for the pv_* structures; this is mainly so that each function pointer has a unique offset for use as a patch-site identifier.

Cc Andi Kleen <[email protected]>
Cc Zach Amsden <[email protected]>
Cc Rusty Russell <[email protected]>
Cc Avi Kivity <[email protected]>
Cc Anthony Liguory <[email protected]>
Cc "Glauber de Oliveira Costa" <[email protected]>
Cc "Nakajima, Jun" <[email protected]>
---
 arch/i386/kernel/alternative.c         |    4 
 arch/i386/kernel/asm-offsets.c         |   12 
 arch/i386/kernel/entry.S               |    2 
 arch/i386/kernel/paravirt.c            |  348 ++++++++++++++-----------
 arch/i386/kernel/vmi.c                 |  168 ++++++------
 arch/i386/xen/enlighten.c              |  152 ++++++-----
 drivers/lguest/core.c                  |    2 
 drivers/lguest/lguest.c                |  110 ++++----
 drivers/lguest/lguest_bus.c            |    2 
 include/asm-i386/paravirt.h            |  436 +++++++++++++++++---------------
 include/asm-i386/pgtable-3level-defs.h |    2 
 11 files changed, 684 insertions(+), 554 deletions(-)

===================================================================

arch/i386/kernel/alternative.c +2 -2
@@ -368,8 +368,8 @@ void apply_paravirt(struct paravirt_patc
 		BUG_ON(p->len > MAX_PATCH_LEN);
 		/* prep the buffer with the original instructions */
 		memcpy(insnbuf, p->instr, p->len);
-		used = paravirt_ops.patch(p->instrtype, p->clobbers, insnbuf,
-					  (unsigned long)p->instr, p->len);
+		used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
+					 (unsigned long)p->instr, p->len);
 
 		BUG_ON(used > p->len);
 

===================================================================

arch/i386/kernel/asm-offsets.c +6 -6
@@ -116,12 +116,12 @@ void foo(void)
 
 #ifdef CONFIG_PARAVIRT
 	BLANK();
-	OFFSET(PARAVIRT_enabled, paravirt_ops, paravirt_enabled);
-	OFFSET(PARAVIRT_irq_disable, paravirt_ops, irq_disable);
-	OFFSET(PARAVIRT_irq_enable, paravirt_ops, irq_enable);
-	OFFSET(PARAVIRT_irq_enable_sysexit, paravirt_ops, irq_enable_sysexit);
-	OFFSET(PARAVIRT_iret, paravirt_ops, iret);
-	OFFSET(PARAVIRT_read_cr0, paravirt_ops, read_cr0);
+	OFFSET(PARAVIRT_enabled, pv_info, paravirt_enabled);
+	OFFSET(PARAVIRT_irq_disable, paravirt_ops, pv_irq_ops.irq_disable);
+	OFFSET(PARAVIRT_irq_enable, paravirt_ops, pv_irq_ops.irq_enable);
+	OFFSET(PARAVIRT_irq_enable_sysexit, paravirt_ops, pv_cpu_ops.irq_enable_sysexit);
+	OFFSET(PARAVIRT_iret, paravirt_ops, pv_cpu_ops.iret);
+	OFFSET(PARAVIRT_read_cr0, paravirt_ops, pv_cpu_ops.read_cr0);
 #endif
 
 #ifdef CONFIG_XEN

===================================================================

arch/i386/kernel/entry.S +1 -1
@@ -434,7 +434,7 @@ ldt_ss:
 	 * is still available to implement the setting of the high
 	 * 16-bits in the INTERRUPT_RETURN paravirt-op.
 	 */
-	cmpl $0, paravirt_ops+PARAVIRT_enabled
+	cmpl $0, pv_info+PARAVIRT_enabled
 	jne restore_nocheck
 #endif
 

===================================================================

arch/i386/kernel/paravirt.c +195 -153

423 lines not on this page · raw message

===================================================================

arch/i386/kernel/vmi.c +84 -84

267 lines not on this page · raw message

===================================================================

arch/i386/xen/enlighten.c +88 -64

255 lines not on this page · raw message

===================================================================

drivers/lguest/core.c +1 -1
@@ -694,7 +694,7 @@ static int __init init(void)
 
 	/* Lguest can't run under Xen, VMI or itself.  It does Tricky Stuff. */
 	if (paravirt_enabled()) {
-		printk("lguest is afraid of %s\n", paravirt_ops.name);
+		printk("lguest is afraid of %s\n", pv_info.name);
 		return -EPERM;
 	}
 

===================================================================

drivers/lguest/lguest.c +62 -48

133 lines not on this page · raw message

===================================================================

drivers/lguest/lguest_bus.c +1 -1
@@ -201,7 +201,7 @@ static void scan_devices(void)
  * "struct lguest_device_desc" array. */
 static int __init lguest_bus_init(void)
 {
-	if (strcmp(paravirt_ops.name, "lguest") != 0)
+	if (strcmp(pv_info.name, "lguest") != 0)
 		return 0;
 
 	/* Devices are in a single page above top of "normal" mem */

===================================================================

include/asm-i386/paravirt.h +243 -193

943 lines not on this page · raw message

===================================================================

include/asm-i386/pgtable-3level-defs.h +1 -1
@@ -2,7 +2,7 @@
 #define _I386_PGTABLE_3LEVEL_DEFS_H
 
 #ifdef CONFIG_PARAVIRT
-#define SHARED_KERNEL_PMD	(paravirt_ops.shared_kernel_pmd)
+#define SHARED_KERNEL_PMD	(pv_info.shared_kernel_pmd)
 #else
 #define SHARED_KERNEL_PMD	1
 #endif