Skip to contentSkip to conversation

x86/xen for v2.6.32

GIT PULL Ingo Molnar 3 participants 5 messages Sep 11, 2009 – Sep 12, 2009

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

Linus,

Please pull the latest x86-xen-for-linus git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git x86-xen-for-linus

Thanks,

Ingo

------------------>
Jeremy Fitzhardinge (3):
xen: make -fstack-protector work under Xen
xen: only enable interrupts while actually blocking for spinlock
x86: split __phys_addr out into separate file

Yang Xiaowei (1):
xen: use stronger barrier after unlocking lock

 arch/x86/mm/Makefile     |    6 ++-
 arch/x86/mm/ioremap.c    |   72 +-------------------------
 arch/x86/mm/physaddr.c   |   70 ++++++++++++++++++++++++
 arch/x86/mm/physaddr.h   |   10 ++++
 arch/x86/xen/Makefile    |    2 +
 arch/x86/xen/enlighten.c |  131 +++++++++++++++++++++++++++++++++++++++-------
 arch/x86/xen/smp.c       |    1 +
 arch/x86/xen/spinlock.c  |   28 ++++++----
 drivers/xen/Makefile     |    3 +
 9 files changed, 222 insertions(+), 101 deletions(-)
 create mode 100644 arch/x86/mm/physaddr.c
 create mode 100644 arch/x86/mm/physaddr.h
arch/x86/mm/Makefile +5 -1
index eefdeee..9b5a9f5 100644
@@ -1,5 +1,9 @@
 obj-y	:=  init.o init_$(BITS).o fault.o ioremap.o extable.o pageattr.o mmap.o \
-	    pat.o pgtable.o gup.o
+	    pat.o pgtable.o physaddr.o gup.o
+
+# Make sure __phys_addr has no stackprotector
+nostackp := $(call cc-option, -fno-stack-protector)
+CFLAGS_physaddr.o		:= $(nostackp)
 
 obj-$(CONFIG_SMP)		+= tlb.o
 
arch/x86/mm/ioremap.c +1 -71

78 lines not on this page · raw message

arch/x86/mm/physaddr.c new file +70 -0

70 lines not on this page · raw message

arch/x86/mm/physaddr.h new file +10 -0
new file mode 100644
index 0000000..a3cd5a0
@@ -0,0 +1,10 @@
+#include <asm/processor.h>
+
+static inline int phys_addr_valid(resource_size_t addr)
+{
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
+	return !(addr >> boot_cpu_data.x86_phys_bits);
+#else
+	return 1;
+#endif
+}
arch/x86/xen/Makefile +2 -0
index 7410640..3bb4fc2 100644
@@ -8,6 +8,7 @@ endif
 # Make sure early boot has no stackprotector
 nostackp := $(call cc-option, -fno-stack-protector)
 CFLAGS_enlighten.o		:= $(nostackp)
+CFLAGS_mmu.o			:= $(nostackp)
 
 obj-y		:= enlighten.o setup.o multicalls.o mmu.o irq.o \
 			time.o xen-asm.o xen-asm_$(BITS).o \
@@ -16,3 +17,4 @@ obj-y		:= enlighten.o setup.o multicalls.o mmu.o irq.o \
 obj-$(CONFIG_SMP)		+= smp.o
 obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= spinlock.o
 obj-$(CONFIG_XEN_DEBUG_FS)	+= debugfs.o
+
arch/x86/xen/enlighten.c +112 -19

192 lines not on this page · raw message

arch/x86/xen/smp.c +1 -0
index 429834e..fe03eee 100644
@@ -236,6 +236,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
 	ctxt->user_regs.ss = __KERNEL_DS;
 #ifdef CONFIG_X86_32
 	ctxt->user_regs.fs = __KERNEL_PERCPU;
+	ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
 #else
 	ctxt->gs_base_kernel = per_cpu_offset(cpu);
 #endif
arch/x86/xen/spinlock.c +18 -10
index 5601506..36a5141 100644
@@ -187,7 +187,6 @@ static noinline int xen_spin_lock_slow(struct raw_spinlock *lock, bool irq_enabl
 	struct xen_spinlock *prev;
 	int irq = __get_cpu_var(lock_kicker_irq);
 	int ret;
-	unsigned long flags;
 	u64 start;
 
 	/* If kicker interrupts not initialized yet, just spin */
@@ -199,16 +198,12 @@ static noinline int xen_spin_lock_slow(struct raw_spinlock *lock, bool irq_enabl
 	/* announce we're spinning */
 	prev = spinning_lock(xl);
 
-	flags = __raw_local_save_flags();
-	if (irq_enable) {
-		ADD_STATS(taken_slow_irqenable, 1);
-		raw_local_irq_enable();
-	}
-
 	ADD_STATS(taken_slow, 1);
 	ADD_STATS(taken_slow_nested, prev != NULL);
 
 	do {
+		unsigned long flags;
+
 		/* clear pending */
 		xen_clear_irq_pending(irq);
 
@@ -228,6 +223,12 @@ static noinline int xen_spin_lock_slow(struct raw_spinlock *lock, bool irq_enabl
 			goto out;
 		}
 
+		flags = __raw_local_save_flags();
+		if (irq_enable) {
+			ADD_STATS(taken_slow_irqenable, 1);
+			raw_local_irq_enable();
+		}
+
 		/*
 		 * Block until irq becomes pending.  If we're
 		 * interrupted at this point (after the trylock but
@@ -238,13 +239,15 @@ static noinline int xen_spin_lock_slow(struct raw_spinlock *lock, bool irq_enabl
 		 * pending.
 		 */
 		xen_poll_irq(irq);
+
+		raw_local_irq_restore(flags);
+
 		ADD_STATS(taken_slow_spurious, !xen_test_irq_pending(irq));
 	} while (!xen_test_irq_pending(irq)); /* check for spurious wakeups */
 
 	kstat_incr_irqs_this_cpu(irq, irq_to_desc(irq));
 
 out:
-	raw_local_irq_restore(flags);
 	unspinning_lock(xl, prev);
 	spin_time_accum_blocked(start);
 
@@ -323,8 +326,13 @@ static void xen_spin_unlock(struct raw_spinlock *lock)
 	smp_wmb();		/* make sure no writes get moved after unlock */
 	xl->lock = 0;		/* release lock */
 
-	/* make sure unlock happens before kick */
-	barrier();
+	/*
+	 * Make sure unlock happens before checking for waiting
+	 * spinners.  We need a strong barrier to enforce the
+	 * write-read ordering to different memory locations, as the
+	 * CPU makes no implied guarantees about their ordering.
+	 */
+	mb();
 
 	if (unlikely(xl->spinners))
 		xen_spin_unlock_slow(xl);
drivers/xen/Makefile +3 -0
index ec2a39b..7c28434 100644
@@ -1,6 +1,9 @@
 obj-y	+= grant-table.o features.o events.o manage.o
 obj-y	+= xenbus/
 
+nostackp := $(call cc-option, -fno-stack-protector)
+CFLAGS_features.o			:= $(nostackp)
+
 obj-$(CONFIG_HOTPLUG_CPU)	+= cpu_hotplug.o
 obj-$(CONFIG_XEN_XENCOMM)	+= xencomm.o
 obj-$(CONFIG_XEN_BALLOON)	+= balloon.o
#1 lore raw

On Fri, 11 Sep 2009, Ingo Molnar wrote:

[...]

Quoted 17 lines
arch/x86/xen/enlighten.c +17 -0
+static __init void xen_load_gdt_boot(const struct desc_ptr *dtr)
+{
+	unsigned long va = dtr->address;
+	unsigned int size = dtr->size + 1;
+	unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
+	unsigned long frames[pages];
+	int f;
+
+	/*
+	 * A GDT can be up to 64k in size, which corresponds to 8192
+	 * 8-byte entries, or 16 4k pages..
+	 */
+
+	BUG_ON(size > 65536);
+	BUG_ON(va & ~PAGE_MASK);
+
+	for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {

arch/x86/xen/enlighten.c static void xen_load_gdt(const struct desc_ptr *dtr) · line 401

Quoted 10 lines
arch/x86/xen/enlighten.c +10 -0
+		pte_t pte;
+		unsigned long pfn, mfn;
+
+		pfn = virt_to_pfn(va);
+		mfn = pfn_to_mfn(pfn);
+
+		pte = pfn_pte(pfn, PAGE_KERNEL_RO);
+
+		if (HYPERVISOR_update_va_mapping((unsigned long)va, pte, 0))
+			BUG();

[...]

Why is this cast of 'va' needed? As far as I can see, 'va' already has the correct type of "unsigned long".
Pointless casts do more harm than good, let's remove this one :-)

Sorry that all I could comment on was this trivial thing, but I thought it better to comment than keep silent now that I had read the patch and spotted it...

Signature · 3 lines
Jesper Juhl <[email protected]>             http://www.chaosbits.net/
Plain text mails only, please      http://www.expita.com/nomime.html
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
#2 lore raw
Quoted 4 lines · Jesper Juhl

Why is this cast of 'va' needed? As far as I can see, 'va' already has the correct type of "unsigned long".
Pointless casts do more harm than good, let's remove this one :-)

Yup. Don't know what lead me to put it there; cut'n'paste, possibly. Anyway, I'll send out a fix when I get around to it.

J

#3 lore raw
In reply to Jesper Juhl
Quoted 32 lines · Jesper Juhl

On Fri, 11 Sep 2009, Ingo Molnar wrote:

[...]

Quoted 27 lines
arch/x86/xen/enlighten.c +27 -0
+static __init void xen_load_gdt_boot(const struct desc_ptr *dtr)
+{
+	unsigned long va = dtr->address;
+	unsigned int size = dtr->size + 1;
+	unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
+	unsigned long frames[pages];
+	int f;
+
+	/*
+	 * A GDT can be up to 64k in size, which corresponds to 8192
+	 * 8-byte entries, or 16 4k pages..
+	 */
+
+	BUG_ON(size > 65536);
+	BUG_ON(va & ~PAGE_MASK);
+
+	for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
+		pte_t pte;
+		unsigned long pfn, mfn;
+
+		pfn = virt_to_pfn(va);
+		mfn = pfn_to_mfn(pfn);
+
+		pte = pfn_pte(pfn, PAGE_KERNEL_RO);
+
+		if (HYPERVISOR_update_va_mapping((unsigned long)va, pte, 0))
+			BUG();

[...]

Quoted 7 lines

Why is this cast of 'va' needed? As far as I can see, 'va' already has the correct type of "unsigned long".
Pointless casts do more harm than good, let's remove this one :-)

Sorry that all I could comment on was this trivial thing, but I thought it better to comment than keep silent now that I had read the patch and spotted it...

Yes, that cast could be removed.

Btw., i'd suggest that if you have trivial review feedback please comment on the originating patches, in the original, finegrained context, not the summary pull request. (Incidentally i did that too there and the above patches did result in a few cleanups when they were submitted.)

The reason is that the originating threads all have full changelogs and have all the right people Cc:-ed in general - and by reviewing them you will also influence the patches before they are sent to Linus. The pull requests have Linus and the affected maintainers Cc:-ed mainly. So for example you did not Cc: Jeremy to the x86/fpu pull request comments you did so he had no chance to comment on them unless he happened to run across your comments on lkml.

Bug/crash reports and serious gotcha feedback can go to the pull requests too just fine - but even then, if you know what the originating commit is, try to include the people who originated the commit. (And feel free to Cc: Linus to that trivial feedback if you think it's important enough.)

Thanks,

Ingo

#4 lore raw
Quoted 3 lines · Ingo Molnar

* Jesper Juhl <[email protected]> wrote:

[...]

Quoted 25 lines
Quoted 8 lines

Why is this cast of 'va' needed? As far as I can see, 'va' already has the correct type of "unsigned long".
Pointless casts do more harm than good, let's remove this one :-)

Sorry that all I could comment on was this trivial thing, but I thought it better to comment than keep silent now that I had read the patch and spotted it...

Yes, that cast could be removed.

Btw., i'd suggest that if you have trivial review feedback please comment on the originating patches, in the original, finegrained context, not the summary pull request. (Incidentally i did that too there and the above patches did result in a few cleanups when they were submitted.)

The reason is that the originating threads all have full changelogs and have all the right people Cc:-ed in general - and by reviewing them you will also influence the patches before they are sent to Linus. The pull requests have Linus and the affected maintainers Cc:-ed mainly. So for example you did not Cc: Jeremy to the x86/fpu pull request comments you did so he had no chance to comment on them unless he happened to run across your comments on lkml.

Quoted 6 lines

Bug/crash reports and serious gotcha feedback can go to the pull requests too just fine - but even then, if you know what the originating commit is, try to include the people who originated the commit. (And feel free to Cc: Linus to that trivial feedback if you think it's important enough.)

You are making a lot of sense Ingo. I'll try to remember that.

Signature · 3 lines
Jesper Juhl <[email protected]>             http://www.chaosbits.net/
Plain text mails only, please      http://www.expita.com/nomime.html
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html