Skip to contentSkip to conversation

x86/asm for 2.6.36

GIT PULL H. Peter Anvin 4 participants 5 messages Aug 5, 2010 – Aug 6, 2010

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

Hi Linus,

The following changes since commit cdd854bc42b5e6c79bbbc40c6600d995ffe6e747:

Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc (2010-08-05 09:03:46 -0700)

are available in the git repository at:

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

Brian Gerst (5):
x86: Remove redundant K6 MSRs
x86: Use symbolic MSR names
x86-64: Simplify loading initial_gs
x86-64, asm: Directly access per-cpu IST
x86-32, asm: Directly access per-cpu GDT

H. Peter Anvin (7):
x86: Add memory modify constraints to xchg() and cmpxchg() Merge remote branch 'origin/x86/urgent' into x86/asm x86, asm: Clean up and simplify set_64bit()
x86, asm: Clean up and simplify <asm/cmpxchg.h> x86, asm: Move cmpxchg emulation code to arch/x86/lib x86, asm: Merge cmpxchg_486_u64() and cmpxchg8b_emu() um, x86: Cast to (u64 *) inside set_64bit()

 arch/um/include/asm/pgtable-3level.h   |    4 +-
 arch/x86/include/asm/cmpxchg_32.h      |  198 ++++++++++++++-----------------
 arch/x86/include/asm/cmpxchg_64.h      |   83 +++++++++-----
 arch/x86/include/asm/msr-index.h       |    2 -
 arch/x86/kernel/acpi/realmode/wakeup.S |    2 +-
 arch/x86/kernel/cpu/Makefile           |    2 +-
 arch/x86/kernel/entry_32.S             |   11 +-
 arch/x86/kernel/entry_64.S             |    6 +-
 arch/x86/kernel/head_64.S              |    5 +-
 arch/x86/kernel/verify_cpu_64.S        |    3 +-
 arch/x86/kvm/svm.c                     |    6 +-
 arch/x86/kvm/vmx.c                     |    8 +-
 arch/x86/kvm/x86.c                     |    2 +-
 arch/x86/lib/Makefile                  |    1 +
 arch/x86/{kernel/cpu => lib}/cmpxchg.c |   18 ---
 15 files changed, 166 insertions(+), 185 deletions(-)
 rename arch/x86/{kernel/cpu => lib}/cmpxchg.c (75%)
arch/um/include/asm/pgtable-3level.h +2 -2
index 084de4a..0032f92 100644
@@ -60,7 +60,7 @@
 	set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
 
 #ifdef CONFIG_64BIT
-#define set_pud(pudptr, pudval) set_64bit((phys_t *) (pudptr), pud_val(pudval))
+#define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
 #else
 #define set_pud(pudptr, pudval) (*(pudptr) = (pudval))
 #endif
@@ -73,7 +73,7 @@ static inline int pgd_newpage(pgd_t pgd)
 static inline void pgd_mkuptodate(pgd_t pgd) { pgd_val(pgd) &= ~_PAGE_NEWPAGE; }
 
 #ifdef CONFIG_64BIT
-#define set_pmd(pmdptr, pmdval) set_64bit((phys_t *) (pmdptr), pmd_val(pmdval))
+#define set_pmd(pmdptr, pmdval) set_64bit((u64 *) (pmdptr), pmd_val(pmdval))
 #else
 #define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval))
 #endif
arch/x86/include/asm/cmpxchg_32.h +89 -109

270 lines not on this page · raw message

arch/x86/include/asm/cmpxchg_64.h +52 -31

132 lines not on this page · raw message

arch/x86/include/asm/msr-index.h +0 -2
index 509a421..b27d160 100644
@@ -161,8 +161,6 @@
 #define MSR_K7_FID_VID_STATUS		0xc0010042
 
 /* K6 MSRs */
-#define MSR_K6_EFER			0xc0000080
-#define MSR_K6_STAR			0xc0000081
 #define MSR_K6_WHCR			0xc0000082
 #define MSR_K6_UWCCR			0xc0000085
 #define MSR_K6_EPMR			0xc0000086
arch/x86/kernel/acpi/realmode/wakeup.S +1 -1
index 580b4e2..28595d6 100644
@@ -104,7 +104,7 @@ _start:
 	movl	%eax, %ecx
 	orl	%edx, %ecx
 	jz	1f
-	movl	$0xc0000080, %ecx
+	movl	$MSR_EFER, %ecx
 	wrmsr
 1:
 
arch/x86/kernel/cpu/Makefile +1 -1
index 3a785da..c47c439 100644
@@ -16,7 +16,7 @@ obj-y			:= intel_cacheinfo.o addon_cpuid_features.o
 obj-y			+= proc.o capflags.o powerflags.o common.o
 obj-y			+= vmware.o hypervisor.o sched.o mshyperv.o
 
-obj-$(CONFIG_X86_32)	+= bugs.o cmpxchg.o
+obj-$(CONFIG_X86_32)	+= bugs.o
 obj-$(CONFIG_X86_64)	+= bugs_64.o
 
 obj-$(CONFIG_CPU_SUP_INTEL)		+= intel.o
arch/x86/kernel/cpu/cmpxchg.c deleted +0 -72

72 lines not on this page · raw message

arch/x86/kernel/entry_32.S +5 -6
index cd49141..233c582 100644
@@ -611,14 +611,14 @@ ldt_ss:
  * compensating for the offset by changing to the ESPFIX segment with
  * a base address that matches for the difference.
  */
+#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
 	mov %esp, %edx			/* load kernel esp */
 	mov PT_OLDESP(%esp), %eax	/* load userspace esp */
 	mov %dx, %ax			/* eax: new kernel esp */
 	sub %eax, %edx			/* offset (low word is 0) */
-	PER_CPU(gdt_page, %ebx)
 	shr $16, %edx
-	mov %dl, GDT_ENTRY_ESPFIX_SS * 8 + 4(%ebx) /* bits 16..23 */
-	mov %dh, GDT_ENTRY_ESPFIX_SS * 8 + 7(%ebx) /* bits 24..31 */
+	mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
+	mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
 	pushl $__ESPFIX_SS
 	CFI_ADJUST_CFA_OFFSET 4
 	push %eax			/* new kernel esp */
@@ -791,9 +791,8 @@ ptregs_clone:
  * normal stack and adjusts ESP with the matching offset.
  */
 	/* fixup the stack */
-	PER_CPU(gdt_page, %ebx)
-	mov GDT_ENTRY_ESPFIX_SS * 8 + 4(%ebx), %al /* bits 16..23 */
-	mov GDT_ENTRY_ESPFIX_SS * 8 + 7(%ebx), %ah /* bits 24..31 */
+	mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
+	mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
 	shl $16, %eax
 	addl %esp, %eax			/* the adjusted stack pointer */
 	pushl $__KERNEL_DS
arch/x86/kernel/entry_64.S +3 -3
index 4db7c4d..59af275 100644
@@ -1065,6 +1065,7 @@ ENTRY(\sym)
 END(\sym)
 .endm
 
+#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
 .macro paranoidzeroentry_ist sym do_sym ist
 ENTRY(\sym)
 	INTR_FRAME
@@ -1076,10 +1077,9 @@ ENTRY(\sym)
 	TRACE_IRQS_OFF
 	movq %rsp,%rdi		/* pt_regs pointer */
 	xorl %esi,%esi		/* no error code */
-	PER_CPU(init_tss, %r12)
-	subq $EXCEPTION_STKSZ, TSS_ist + (\ist - 1) * 8(%r12)
+	subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
 	call \do_sym
-	addq $EXCEPTION_STKSZ, TSS_ist + (\ist - 1) * 8(%r12)
+	addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
 	jmp paranoid_exit	/* %ebx: no swapgs flag */
 	CFI_ENDPROC
 END(\sym)
arch/x86/kernel/head_64.S +2 -3
index 3d1e6f1..239046b 100644
@@ -234,9 +234,8 @@ ENTRY(secondary_startup_64)
 	 * init data section till per cpu areas are set up.
 	 */
 	movl	$MSR_GS_BASE,%ecx
-	movq	initial_gs(%rip),%rax
-	movq    %rax,%rdx
-	shrq	$32,%rdx
+	movl	initial_gs(%rip),%eax
+	movl	initial_gs+4(%rip),%edx
 	wrmsr	
 
 	/* esi is pointer to real mode structure with interesting info.
arch/x86/kernel/verify_cpu_64.S +2 -1
index 45b6f8a..56a8c2a 100644
@@ -31,6 +31,7 @@
  */
 
 #include <asm/cpufeature.h>
+#include <asm/msr-index.h>
 
 verify_cpu:
 	pushfl				# Save caller passed flags
@@ -88,7 +89,7 @@ verify_cpu_sse_test:
 	je	verify_cpu_sse_ok
 	test	%di,%di
 	jz	verify_cpu_no_longmode	# only try to force SSE on AMD
-	movl	$0xc0010015,%ecx	# HWCR
+	movl	$MSR_K7_HWCR,%ecx
 	rdmsr
 	btr	$15,%eax		# enable SSE
 	wrmsr
arch/x86/kvm/svm.c +3 -3
index 56c9b6b..2636ea8 100644
@@ -131,7 +131,7 @@ static struct svm_direct_access_msrs {
 	u32 index;   /* Index of the MSR */
 	bool always; /* True if intercept is always on */
 } direct_access_msrs[] = {
-	{ .index = MSR_K6_STAR,				.always = true  },
+	{ .index = MSR_STAR,				.always = true  },
 	{ .index = MSR_IA32_SYSENTER_CS,		.always = true  },
 #ifdef CONFIG_X86_64
 	{ .index = MSR_GS_BASE,				.always = true  },
@@ -2433,7 +2433,7 @@ static int svm_get_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 *data)
 		*data = tsc_offset + native_read_tsc();
 		break;
 	}
-	case MSR_K6_STAR:
+	case MSR_STAR:
 		*data = svm->vmcb->save.star;
 		break;
 #ifdef CONFIG_X86_64
@@ -2557,7 +2557,7 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data)
 
 		break;
 	}
-	case MSR_K6_STAR:
+	case MSR_STAR:
 		svm->vmcb->save.star = data;
 		break;
 #ifdef CONFIG_X86_64
arch/x86/kvm/vmx.c +4 -4
index 27a0222..49b25ee 100644
@@ -240,14 +240,14 @@ static u64 host_efer;
 static void ept_save_pdptrs(struct kvm_vcpu *vcpu);
 
 /*
- * Keep MSR_K6_STAR at the end, as setup_msrs() will try to optimize it
+ * Keep MSR_STAR at the end, as setup_msrs() will try to optimize it
  * away by decrementing the array size.
  */
 static const u32 vmx_msr_index[] = {
 #ifdef CONFIG_X86_64
 	MSR_SYSCALL_MASK, MSR_LSTAR, MSR_CSTAR,
 #endif
-	MSR_EFER, MSR_TSC_AUX, MSR_K6_STAR,
+	MSR_EFER, MSR_TSC_AUX, MSR_STAR,
 };
 #define NR_VMX_MSR ARRAY_SIZE(vmx_msr_index)
 
@@ -1117,10 +1117,10 @@ static void setup_msrs(struct vcpu_vmx *vmx)
 		if (index >= 0 && vmx->rdtscp_enabled)
 			move_msr_up(vmx, index, save_nmsrs++);
 		/*
-		 * MSR_K6_STAR is only needed on long mode guests, and only
+		 * MSR_STAR is only needed on long mode guests, and only
 		 * if efer.sce is enabled.
 		 */
-		index = __find_msr_index(vmx, MSR_K6_STAR);
+		index = __find_msr_index(vmx, MSR_STAR);
 		if ((index >= 0) && (vmx->vcpu.arch.efer & EFER_SCE))
 			move_msr_up(vmx, index, save_nmsrs++);
 	}
arch/x86/kvm/x86.c +1 -1
index 97aab03..25f1907 100644
@@ -733,7 +733,7 @@ static u32 msrs_to_save[] = {
 	HV_X64_MSR_GUEST_OS_ID, HV_X64_MSR_HYPERCALL,
 	HV_X64_MSR_APIC_ASSIST_PAGE,
 	MSR_IA32_SYSENTER_CS, MSR_IA32_SYSENTER_ESP, MSR_IA32_SYSENTER_EIP,
-	MSR_K6_STAR,
+	MSR_STAR,
 #ifdef CONFIG_X86_64
 	MSR_CSTAR, MSR_KERNEL_GS_BASE, MSR_SYSCALL_MASK, MSR_LSTAR,
 #endif
arch/x86/lib/Makefile +1 -0
index f871e04..e10cf07 100644
@@ -30,6 +30,7 @@ ifeq ($(CONFIG_X86_32),y)
         lib-y += checksum_32.o
         lib-y += strstr_32.o
         lib-y += semaphore_32.o string_32.o
+        lib-y += cmpxchg.o
 ifneq ($(CONFIG_X86_CMPXCHG64),y)
         lib-y += cmpxchg8b_emu.o atomic64_386_32.o
 endif
arch/x86/lib/cmpxchg.c new file +54 -0

54 lines not on this page · raw message

#1 lore raw
Quoted 5 lines · H. Peter Anvin

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

H. Peter Anvin (7):
x86, asm: Clean up and simplify set_64bit()

Hmm. This seems to cause compiler warnings for me on x86-64:

drivers/pci/intr_remapping.c: In function ‘modify_irte’:
drivers/pci/intr_remapping.c:314: warning: passing argument 1 of
‘set_64bit’ from incompatible pointer type
/home/torvalds/v2.6/linux/arch/x86/include/asm/cmpxchg_64.h:6: note:
expected ‘volatile u64 *’ but argument is of type ‘long unsigned int *’

and I'm not clear on the reason for that function prototype change.

Linus

#2 lore raw
Quoted 16 lines · Linus Torvalds
Quoted 5 lines · H. Peter Anvin

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

H. Peter Anvin (7):
x86, asm: Clean up and simplify set_64bit()

Hmm. This seems to cause compiler warnings for me on x86-64:

drivers/pci/intr_remapping.c: In function ‘modify_irte’:
drivers/pci/intr_remapping.c:314: warning: passing argument 1 of
‘set_64bit’ from incompatible pointer type
/home/torvalds/v2.6/linux/arch/x86/include/asm/cmpxchg_64.h:6: note:
expected ‘volatile u64 *’ but argument is of type ‘long unsigned int *’

Quoted 3 lines

and I'm not clear on the reason for that function prototype change.

Linus

On 64 bits the intent was to be consistent with the tightened-up 32-bit code. Perhaps that was a mistake, but it seems a lot more consistent to me to have "u64" be the type

On the 32-bit side, it's not so much a function prototype change as the previous version of the code actually explicitly cast it to an array of unsigned ints... it has the advantage that it can accept any type, but the disadvantage that is can accept *ANY* type. The problem of course is the above, since gcc will issue warnings for u64 (unsigned long long) version the otherwise-identical "unsigned long".

It's worth noting that in this particular case the code itself looks like this:

	set_64bit((unsigned long *)&irte->low, irte_modified->low);
	set_64bit((unsigned long *)&irte->high, irte_modified->high);

... where the existing cast is there because irte->low and irte->high are types __u64. In other words, with the "more logical" u64 prototype the casts should just get removed.

On the other hand I should have seen this sooner, obviously.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#3 lore raw
Quoted 10 lines · H. Peter Anvin

It's worth noting that in this particular case the code itself looks like this:

       set_64bit((unsigned long *)&irte->low, irte_modified->low); set_64bit((unsigned long *)&irte->high, irte_modified->high);

... where the existing cast is there because irte->low and irte->high are types __u64.  In other words, with the "more logical" u64 prototype the casts should just get removed.

Ok, right you are. I'll just remove the casts, since that makes the code look better. Maybe it will cause warnings on some other plaform, but I do agree that maybe the right thing to do is to just say "set_64bit() should have taken a u64 * to begin with".

Quoted 1 line

On the other hand I should have seen this sooner, obviously.

Yeah, I didn't look at the code, I just reacted to "hmm, this results in new warnings, not good".

Linus

#4 lore raw
In reply to H. Peter Anvin
Quoted 11 lines · H. Peter Anvin

It's worth noting that in this particular case the code itself looks like this:

	set_64bit((unsigned long *)&irte->low, irte_modified->low);
	set_64bit((unsigned long *)&irte->high, irte_modified->high);

... where the existing cast is there because irte->low and irte->high are types __u64. In other words, with the "more logical" u64 prototype the casts should just get removed.

Looking through the build I'm currently running, so far, it is smoking out a bunch of unnecessary casts and wrappers, for example, in kvm/mmu.c:

static void __set_spte(u64 *sptep, u64 spte)
{

#ifdef CONFIG_X86_64
	set_64bit((unsigned long *)sptep, spte);
#else
	set_64bit((unsigned long long *)sptep, spte);

#endif
}

... which just becomes the much cleaner ...

static void __set_spte(u64 *sptep, u64 spte)

{
	set_64bit(sptep, spte);
}

I'll go through all these as this build finishes and give you an updated tree to pull, ok?

-hpa