From: Rusty Russell <rusty@rustcorp.com.au>
To: Andi Kleen <ak@suse.de>
Cc: Chris Wright <chrisw@sous-sol.org>,
virtualization@lists.osdl.org, linux-kernel@vger.kernel.org,
akpm@osdl.org, ak@muc.de
Subject: Re: [PATCH 6/7] Add APIC accessors to paravirt-ops.
Date: Mon, 30 Oct 2006 14:28:55 +1100 [thread overview]
Message-ID: <1162178936.9802.34.camel@localhost.localdomain> (raw)
In-Reply-To: <200610290831.21062.ak@suse.de>
On Sun, 2006-10-29 at 08:31 -0800, Andi Kleen wrote:
> It would be nicer if you renamed the functions in apic.h to native_apic_*
> and then do
...
> This might apply to at least some of the other paravirt ops too.
Yes. I've done the obvious candidates below (as well as responding to
some of your other points). Many ops are one-liners, and I don't want
to cause too much additional churn.
Cheers!
Rusty.
Subject: Paravirtualization Kleenups
1) Add "cheatsheet" comments to entry.S about macros.
2) Use weak alias for init_IRQ -> native_init_IRQ in !CONFIG_PARAVIRT case.
This removes an #ifdef.
3) Use shiny new start_kernel.h rather than another declaration.
4) Avoid duplication in paravirt.c: rename set_ldt to native_set_ldt,
and use macro in !PARAVIRT case.
5) Same trick for apic ops.
There are other cases where we could use a renaming+macro similar
trick to avoid duplication, but they're generally one-liners.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
diff -r ea3bae5ebb37 arch/i386/kernel/entry.S
--- a/arch/i386/kernel/entry.S Mon Oct 30 11:37:19 2006 +1100
+++ b/arch/i386/kernel/entry.S Mon Oct 30 11:48:34 2006 +1100
@@ -52,6 +52,19 @@
#include <asm/percpu.h>
#include <asm/dwarf2.h>
#include "irq_vectors.h"
+
+/*
+ * We use macros for low-level operations which need to be overridden
+ * for paravirtualization. The following will never clobber any registers:
+ * INTERRUPT_RETURN (aka. "iret")
+ * GET_CR0_INTO_EAX (aka. "movl %cr0, %eax")
+ * ENABLE_INTERRUPTS_SYSEXIT (aka "sti; sysexit").
+ *
+ * For DISABLE_INTERRUPTS/ENABLE_INTERRUPTS (aka "cli"/"sti"), you must
+ * specify what registers can be overwritten (CLBR_NONE, CLBR_EAX/EDX/ECX/ANY).
+ * Allowing a register to be clobbered can shrink the paravirt replacement
+ * enough to patch inline, increasing performance.
+ */
#define nr_syscalls ((syscall_table_size)/4)
diff -r ea3bae5ebb37 arch/i386/kernel/i8259.c
--- a/arch/i386/kernel/i8259.c Mon Oct 30 11:37:19 2006 +1100
+++ b/arch/i386/kernel/i8259.c Mon Oct 30 11:57:55 2006 +1100
@@ -392,6 +392,9 @@ void __init init_ISA_irqs (void)
}
}
+/* Overridden in paravirt.c */
+void init_IRQ(void) __attribute__((weak, alias("native_init_IRQ")));
+
void __init native_init_IRQ(void)
{
int i;
diff -r ea3bae5ebb37 arch/i386/kernel/paravirt.c
--- a/arch/i386/kernel/paravirt.c Mon Oct 30 11:37:19 2006 +1100
+++ b/arch/i386/kernel/paravirt.c Mon Oct 30 12:31:48 2006 +1100
@@ -19,6 +19,7 @@
#include <linux/module.h>
#include <linux/efi.h>
#include <linux/bcd.h>
+#include <linux/start_kernel.h>
#include <asm/bug.h>
#include <asm/paravirt.h>
@@ -135,6 +136,11 @@ static fastcall void native_set_debugreg
}
}
+void init_IRQ(void)
+{
+ paravirt_ops.init_IRQ();
+}
+
static fastcall void native_clts(void)
{
asm volatile ("clts");
@@ -296,22 +302,6 @@ static fastcall void native_load_tr_desc
asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
}
-static fastcall void native_set_ldt(const void *addr, unsigned int entries)
-{
- if (likely(entries == 0))
- __asm__ __volatile__("lldt %w0"::"q" (0));
- else {
- unsigned cpu = smp_processor_id();
- __u32 a, b;
-
- pack_descriptor(&a, &b, (unsigned long)addr,
- entries * sizeof(struct desc_struct) - 1,
- DESCTYPE_LDT, 0);
- write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT, a, b);
- __asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8));
- }
-}
-
static fastcall void native_load_gdt(const struct Xgt_desc_struct *dtr)
{
asm volatile("lgdt %0"::"m" (*dtr));
@@ -385,26 +375,6 @@ static fastcall void native_io_delay(voi
asm volatile("outb %al,$0x80");
}
-#ifdef CONFIG_X86_LOCAL_APIC
-/*
- * Basic functions for reading and writing APIC registers
- */
-static fastcall void native_apic_write(unsigned long reg, unsigned long v)
-{
- *((volatile unsigned long *)(APIC_BASE+reg)) = v;
-}
-
-static fastcall void native_apic_write_atomic(unsigned long reg, unsigned long v)
-{
- xchg((volatile unsigned long *)(APIC_BASE+reg), v);
-}
-
-static fastcall unsigned long native_apic_read(unsigned long reg)
-{
- return *((volatile unsigned long *)(APIC_BASE+reg));
-}
-#endif /* CONFIG_X86_LOCAL_APIC */
-
static fastcall void native_flush_tlb(void)
{
__native_flush_tlb();
@@ -508,7 +478,6 @@ core_initcall(print_banner);
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 = {
diff -r ea3bae5ebb37 include/asm-i386/apic.h
--- a/include/asm-i386/apic.h Mon Oct 30 11:37:19 2006 +1100
+++ b/include/asm-i386/apic.h Mon Oct 30 12:41:07 2006 +1100
@@ -40,21 +40,27 @@ extern void generic_apic_probe(void);
#ifdef CONFIG_PARAVIRT
#include <asm/paravirt.h>
#else
-static __inline void apic_write(unsigned long reg, unsigned long v)
+#define apic_write native_apic_write
+#define apic_write_atomic native_apic_write_atomic
+#define apic_read native_apic_read
+#endif
+
+static __inline fastcall void native_apic_write(unsigned long reg,
+ unsigned long v)
{
*((volatile unsigned long *)(APIC_BASE+reg)) = v;
}
-static __inline void apic_write_atomic(unsigned long reg, unsigned long v)
+static __inline fastcall void native_apic_write_atomic(unsigned long reg,
+ unsigned long v)
{
xchg((volatile unsigned long *)(APIC_BASE+reg), v);
}
-static __inline unsigned long apic_read(unsigned long reg)
+static __inline fastcall unsigned long native_apic_read(unsigned long reg)
{
return *((volatile unsigned long *)(APIC_BASE+reg));
}
-#endif
static __inline__ void apic_wait_icr_idle(void)
{
diff -r ea3bae5ebb37 include/asm-i386/desc.h
--- a/include/asm-i386/desc.h Mon Oct 30 11:37:19 2006 +1100
+++ b/include/asm-i386/desc.h Mon Oct 30 12:40:20 2006 +1100
@@ -92,7 +92,11 @@ static inline void write_dt_entry(void *
lp[1] = entry_high;
}
-static inline void set_ldt(void *addr, unsigned int entries)
+#define set_ldt native_set_ldt
+#endif /* CONFIG_PARAVIRT */
+
+static inline fastcall void native_set_ldt(const void *addr,
+ unsigned int entries)
{
if (likely(entries == 0))
__asm__ __volatile__("lldt %w0"::"q" (0));
@@ -107,7 +111,6 @@ static inline void set_ldt(void *addr, u
__asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8));
}
}
-#endif /* CONFIG_PARAVIRT */
static inline void _set_gate(int gate, unsigned int type, void *addr, unsigned short seg)
{
diff -r ea3bae5ebb37 include/asm-i386/irq.h
--- a/include/asm-i386/irq.h Mon Oct 30 11:37:19 2006 +1100
+++ b/include/asm-i386/irq.h Mon Oct 30 12:01:31 2006 +1100
@@ -41,14 +41,7 @@ extern void fixup_irqs(cpumask_t map);
extern void fixup_irqs(cpumask_t map);
#endif
+void init_IRQ(void);
void __init native_init_IRQ(void);
-#ifdef CONFIG_PARAVIRT
-#include <asm/paravirt.h>
-#else
-static inline void init_IRQ(void)
-{
- native_init_IRQ();
-}
-#endif /* CONFIG_PARAVIRT */
#endif /* _ASM_IRQ_H */
diff -r ea3bae5ebb37 include/asm-i386/paravirt.h
--- a/include/asm-i386/paravirt.h Mon Oct 30 11:37:19 2006 +1100
+++ b/include/asm-i386/paravirt.h Mon Oct 30 12:18:58 2006 +1100
@@ -153,11 +153,6 @@ extern struct paravirt_ops paravirt_ops;
extern struct paravirt_ops paravirt_ops;
#define paravirt_enabled() (paravirt_ops.paravirt_enabled)
-
-static inline void init_IRQ(void)
-{
- paravirt_ops.init_IRQ();
-}
static inline void load_esp0(struct tss_struct *tss,
struct thread_struct *thread)
next prev parent reply other threads:[~2006-10-30 3:28 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 ` [PATCH 3/7] More generic paravirtualization entry point Chris Wright
2006-10-29 16:41 ` 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 [this message]
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=1162178936.9802.34.camel@localhost.localdomain \
--to=rusty@rustcorp.com.au \
--cc=ak@muc.de \
--cc=ak@suse.de \
--cc=akpm@osdl.org \
--cc=chrisw@sous-sol.org \
--cc=linux-kernel@vger.kernel.org \
--cc=virtualization@lists.osdl.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;
as well as URLs for NNTP newsgroup(s).