* [patch 0/9] x86, xsave: xsave/xrstor support
@ 2008-07-29 17:29 Suresh Siddha
2008-07-29 17:29 ` [patch 1/9] x86, xsave: xsave cpuid feature bits Suresh Siddha
` (9 more replies)
0 siblings, 10 replies; 37+ messages in thread
From: Suresh Siddha @ 2008-07-29 17:29 UTC (permalink / raw)
To: mingo, hpa, tglx, torvalds, akpm, arjan, roland, drepper, mikpe,
chrisw, andi
Cc: linux-kernel, suresh.b.siddha
This patchset adds the support for xsave/xrstor infrastructure for x86.
xsave/xrstor manages the existing and future processor extended states in x86
architecutre.
More info on xsave/xrstor can be found in the Intel SDM's located at
http://www.intel.com/products/processor/manuals/index.htm
The layout of the xsave/xrstor area extends from the 512-byte FXSAVE/FXRSTOR
layout. xsave/xrstor area layout consists of:
- fxsave/fxrstor area (512 bytes)
- xsave header area (64 bytes)
- set of save areas, each corresponding to a processor extended state
The number of save areas, the offset and the size of each save area is
enumerated by CPUID leaf function 0xd.
This patch includes the basic xsave/xrstor infrastructure(supporting FP/SSE),
which includes:
- context switch support, extending traditional lazy restore mechanism
- signal handling support, extending(using the software reserved bytes
464..511 in the current 512byte layout of fxsave frame) the memory
layout pointed out by the fpstate pointer in the sigcontext
More details in the patches to follow.
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---
^ permalink raw reply [flat|nested] 37+ messages in thread
* [patch 1/9] x86, xsave: xsave cpuid feature bits
2008-07-29 17:29 [patch 0/9] x86, xsave: xsave/xrstor support Suresh Siddha
@ 2008-07-29 17:29 ` Suresh Siddha
2008-07-29 17:29 ` [patch 2/9] x86, xsave: enable xsave/xrstor on cpus with xsave support Suresh Siddha
` (8 subsequent siblings)
9 siblings, 0 replies; 37+ messages in thread
From: Suresh Siddha @ 2008-07-29 17:29 UTC (permalink / raw)
To: mingo, hpa, tglx, torvalds, akpm, arjan, roland, drepper, mikpe,
chrisw, andi
Cc: linux-kernel, suresh.b.siddha
[-- Attachment #1: xsave_feature_bits.patch --]
[-- Type: text/plain, Size: 1793 bytes --]
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---
Index: tip-0728/arch/x86/kernel/cpu/feature_names.c
===================================================================
--- tip-0728.orig/arch/x86/kernel/cpu/feature_names.c 2008-07-28 18:19:50.000000000 -0700
+++ tip-0728/arch/x86/kernel/cpu/feature_names.c 2008-07-28 18:19:53.000000000 -0700
@@ -46,7 +46,7 @@
"pni", NULL, NULL, "monitor", "ds_cpl", "vmx", "smx", "est",
"tm2", "ssse3", "cid", NULL, NULL, "cx16", "xtpr", NULL,
NULL, NULL, "dca", "sse4_1", "sse4_2", "x2apic", NULL, "popcnt",
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, "xsave", NULL, NULL, NULL, NULL, NULL,
/* VIA/Cyrix/Centaur-defined */
NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en",
Index: tip-0728/include/asm-x86/cpufeature.h
===================================================================
--- tip-0728.orig/include/asm-x86/cpufeature.h 2008-07-28 18:19:50.000000000 -0700
+++ tip-0728/include/asm-x86/cpufeature.h 2008-07-28 18:19:53.000000000 -0700
@@ -92,6 +92,7 @@
#define X86_FEATURE_XTPR (4*32+14) /* Send Task Priority Messages */
#define X86_FEATURE_DCA (4*32+18) /* Direct Cache Access */
#define X86_FEATURE_X2APIC (4*32+21) /* x2APIC */
+#define X86_FEATURE_XSAVE (4*32+26) /* XSAVE */
/* VIA/Cyrix/Centaur-defined CPU features, CPUID level 0xC0000001, word 5 */
#define X86_FEATURE_XSTORE (5*32+ 2) /* on-CPU RNG present (xstore insn) */
@@ -191,6 +192,7 @@
#define cpu_has_arch_perfmon boot_cpu_has(X86_FEATURE_ARCH_PERFMON)
#define cpu_has_pat boot_cpu_has(X86_FEATURE_PAT)
#define cpu_has_x2apic boot_cpu_has(X86_FEATURE_X2APIC)
+#define cpu_has_xsave boot_cpu_has(X86_FEATURE_XSAVE)
#if defined(CONFIG_X86_INVLPG) || defined(CONFIG_X86_64)
# define cpu_has_invlpg 1
--
^ permalink raw reply [flat|nested] 37+ messages in thread
* [patch 2/9] x86, xsave: enable xsave/xrstor on cpus with xsave support
2008-07-29 17:29 [patch 0/9] x86, xsave: xsave/xrstor support Suresh Siddha
2008-07-29 17:29 ` [patch 1/9] x86, xsave: xsave cpuid feature bits Suresh Siddha
@ 2008-07-29 17:29 ` Suresh Siddha
2008-07-29 17:29 ` [patch 3/9] x86, xsave: context switch support using xsave/xrstor Suresh Siddha
` (7 subsequent siblings)
9 siblings, 0 replies; 37+ messages in thread
From: Suresh Siddha @ 2008-07-29 17:29 UTC (permalink / raw)
To: mingo, hpa, tglx, torvalds, akpm, arjan, roland, drepper, mikpe,
chrisw, andi
Cc: linux-kernel, suresh.b.siddha
[-- Attachment #1: xsave_enable.patch --]
[-- Type: text/plain, Size: 7702 bytes --]
Enables xsave/xrstor by turning on cr4.osxsave on cpu's which have
the xsave support. For now, features that OS supports/enabled are
FP and SSE.
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---
Index: tip-0728/arch/x86/kernel/Makefile
===================================================================
--- tip-0728.orig/arch/x86/kernel/Makefile 2008-07-29 09:55:43.000000000 -0700
+++ tip-0728/arch/x86/kernel/Makefile 2008-07-29 09:55:46.000000000 -0700
@@ -39,7 +39,7 @@
obj-$(CONFIG_X86_TRAMPOLINE) += trampoline.o
obj-y += process.o
-obj-y += i387.o
+obj-y += i387.o xsave.o
obj-y += ptrace.o
obj-y += ds.o
obj-$(CONFIG_X86_32) += tls.o
Index: tip-0728/arch/x86/kernel/cpu/common.c
===================================================================
--- tip-0728.orig/arch/x86/kernel/cpu/common.c 2008-07-29 09:55:43.000000000 -0700
+++ tip-0728/arch/x86/kernel/cpu/common.c 2008-07-29 09:55:46.000000000 -0700
@@ -712,6 +712,14 @@
current_thread_info()->status = 0;
clear_used_math();
mxcsr_feature_mask_init();
+
+ /*
+ * Boot processor to setup the FP and extended state context info.
+ */
+ if (!smp_processor_id())
+ init_thread_xstate();
+
+ xsave_init();
}
#ifdef CONFIG_HOTPLUG_CPU
Index: tip-0728/arch/x86/kernel/i387.c
===================================================================
--- tip-0728.orig/arch/x86/kernel/i387.c 2008-07-29 09:55:43.000000000 -0700
+++ tip-0728/arch/x86/kernel/i387.c 2008-07-29 09:55:46.000000000 -0700
@@ -61,6 +61,11 @@
return;
}
+ if (cpu_has_xsave) {
+ xsave_cntxt_init();
+ return;
+ }
+
if (cpu_has_fxsr)
xstate_size = sizeof(struct i387_fxsave_struct);
#ifdef CONFIG_X86_32
@@ -83,6 +88,13 @@
write_cr0(oldcr0 & ~(X86_CR0_TS|X86_CR0_EM)); /* clear TS and EM */
+ /*
+ * Boot processor to setup the FP and extended state context info.
+ */
+ if (!smp_processor_id())
+ init_thread_xstate();
+ xsave_init();
+
mxcsr_feature_mask_init();
/* clean state in init */
current_thread_info()->status = 0;
Index: tip-0728/arch/x86/kernel/traps_64.c
===================================================================
--- tip-0728.orig/arch/x86/kernel/traps_64.c 2008-07-29 09:55:43.000000000 -0700
+++ tip-0728/arch/x86/kernel/traps_64.c 2008-07-29 09:55:46.000000000 -0700
@@ -1186,10 +1186,6 @@
set_system_gate(IA32_SYSCALL_VECTOR, ia32_syscall);
#endif
/*
- * initialize the per thread extended state:
- */
- init_thread_xstate();
- /*
* Should be a barrier for any external CPU state:
*/
cpu_init();
Index: tip-0728/include/asm-x86/processor-flags.h
===================================================================
--- tip-0728.orig/include/asm-x86/processor-flags.h 2008-07-29 09:55:43.000000000 -0700
+++ tip-0728/include/asm-x86/processor-flags.h 2008-07-29 09:55:46.000000000 -0700
@@ -59,6 +59,7 @@
#define X86_CR4_OSFXSR 0x00000200 /* enable fast FPU save and restore */
#define X86_CR4_OSXMMEXCPT 0x00000400 /* enable unmasked SSE exceptions */
#define X86_CR4_VMXE 0x00002000 /* enable VMX virtualization */
+#define X86_CR4_OSXSAVE 0x00040000 /* enable xsave and xrestore */
/*
* x86-64 Task Priority Register, CR8
Index: tip-0728/arch/x86/kernel/xsave.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ tip-0728/arch/x86/kernel/xsave.c 2008-07-29 09:56:54.000000000 -0700
@@ -0,0 +1,87 @@
+/*
+ * xsave/xrstor support.
+ *
+ * Author: Suresh Siddha <suresh.b.siddha@intel.com>
+ */
+#include <linux/bootmem.h>
+#include <linux/compat.h>
+#include <asm/i387.h>
+
+/*
+ * Supported feature mask by the CPU and the kernel.
+ */
+unsigned int pcntxt_hmask, pcntxt_lmask;
+
+/*
+ * Represents init state for the supported extended state.
+ */
+struct xsave_struct *init_xstate_buf;
+
+/*
+ * Enable the extended processor state save/restore feature
+ */
+void __cpuinit xsave_init(void)
+{
+ if (!cpu_has_xsave)
+ return;
+
+ set_in_cr4(X86_CR4_OSXSAVE);
+
+ /*
+ * Enable all the features that the HW is capable of
+ * and the Linux kernel is aware of.
+ *
+ * xsetbv();
+ */
+ asm volatile(".byte 0x0f,0x01,0xd1"::"c" (0),
+ "a" (pcntxt_lmask), "d" (pcntxt_hmask));
+}
+
+/*
+ * setup the xstate image representing the init state
+ */
+void setup_xstate_init(void)
+{
+ init_xstate_buf = alloc_bootmem(xstate_size);
+ init_xstate_buf->i387.mxcsr = MXCSR_DEFAULT;
+}
+
+/*
+ * Enable and initialize the xsave feature.
+ */
+void __init xsave_cntxt_init(void)
+{
+ unsigned int eax, ebx, ecx, edx;
+
+ cpuid_count(0xd, 0, &eax, &ebx, &ecx, &edx);
+
+ pcntxt_lmask = eax;
+ pcntxt_hmask = edx;
+
+ if ((pcntxt_lmask & XSTATE_FPSSE) != XSTATE_FPSSE) {
+ printk(KERN_ERR "FP/SSE not shown under xsave features %x\n",
+ pcntxt_lmask);
+ BUG();
+ }
+
+ /*
+ * for now OS knows only about FP/SSE
+ */
+ pcntxt_lmask = pcntxt_lmask & XCNTXT_LMASK;
+ pcntxt_hmask = pcntxt_hmask & XCNTXT_HMASK;
+
+ xsave_init();
+
+ /*
+ * Recompute the context size for enabled features
+ */
+ cpuid_count(0xd, 0, &eax, &ebx, &ecx, &edx);
+
+ xstate_size = ebx;
+
+ setup_xstate_init();
+
+ printk(KERN_INFO "xsave/xrstor: enabled xstate_bv 0x%Lx, "
+ "cntxt size 0x%x\n",
+ (pcntxt_lmask | ((u64) pcntxt_hmask << 32)), xstate_size);
+}
Index: tip-0728/include/asm-x86/xsave.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ tip-0728/include/asm-x86/xsave.h 2008-07-29 09:55:46.000000000 -0700
@@ -0,0 +1,26 @@
+#ifndef __ASM_X86_XSAVE_H
+#define __ASM_X86_XSAVE_H
+
+#include <asm/processor.h>
+#include <asm/i387.h>
+
+#define XSTATE_FP 0x1
+#define XSTATE_SSE 0x2
+
+#define XSTATE_FPSSE (XSTATE_FP | XSTATE_SSE)
+
+#define FXSAVE_SIZE 512
+
+/*
+ * These are the features that the OS can handle currently.
+ */
+#define XCNTXT_LMASK (XSTATE_FP | XSTATE_SSE)
+#define XCNTXT_HMASK 0x0
+
+extern unsigned int xstate_size, pcntxt_hmask, pcntxt_lmask;
+extern struct xsave_struct *init_xstate_buf;
+
+extern void xsave_cntxt_init(void);
+extern void xsave_init(void);
+
+#endif
Index: tip-0728/arch/x86/kernel/traps_32.c
===================================================================
--- tip-0728.orig/arch/x86/kernel/traps_32.c 2008-07-29 09:55:43.000000000 -0700
+++ tip-0728/arch/x86/kernel/traps_32.c 2008-07-29 09:55:46.000000000 -0700
@@ -1240,7 +1240,6 @@
set_bit(SYSCALL_VECTOR, used_vectors);
- init_thread_xstate();
/*
* Should be a barrier for any external CPU state:
*/
Index: tip-0728/include/asm-x86/i387.h
===================================================================
--- tip-0728.orig/include/asm-x86/i387.h 2008-07-29 09:55:43.000000000 -0700
+++ tip-0728/include/asm-x86/i387.h 2008-07-29 09:55:46.000000000 -0700
@@ -18,6 +18,7 @@
#include <asm/sigcontext.h>
#include <asm/user.h>
#include <asm/uaccess.h>
+#include <asm/xsave.h>
extern void fpu_init(void);
extern void mxcsr_feature_mask_init(void);
Index: tip-0728/include/asm-x86/processor.h
===================================================================
--- tip-0728.orig/include/asm-x86/processor.h 2008-07-29 09:55:43.000000000 -0700
+++ tip-0728/include/asm-x86/processor.h 2008-07-29 09:55:46.000000000 -0700
@@ -351,6 +351,18 @@
u32 entry_eip;
};
+struct xsave_hdr_struct {
+ u64 xstate_bv;
+ u64 reserved1[2];
+ u64 reserved2[5];
+} __attribute__((packed));
+
+struct xsave_struct {
+ struct i387_fxsave_struct i387;
+ struct xsave_hdr_struct xsave_hdr;
+ /* new processor state extensions will go here */
+} __attribute__ ((packed, aligned (64)));
+
union thread_xstate {
struct i387_fsave_struct fsave;
struct i387_fxsave_struct fxsave;
--
^ permalink raw reply [flat|nested] 37+ messages in thread
* [patch 3/9] x86, xsave: context switch support using xsave/xrstor
2008-07-29 17:29 [patch 0/9] x86, xsave: xsave/xrstor support Suresh Siddha
2008-07-29 17:29 ` [patch 1/9] x86, xsave: xsave cpuid feature bits Suresh Siddha
2008-07-29 17:29 ` [patch 2/9] x86, xsave: enable xsave/xrstor on cpus with xsave support Suresh Siddha
@ 2008-07-29 17:29 ` Suresh Siddha
2008-07-29 17:29 ` [patch 4/9] x86, xsave: dynamically allocate sigframes fpstate instead of static allocation Suresh Siddha
` (6 subsequent siblings)
9 siblings, 0 replies; 37+ messages in thread
From: Suresh Siddha @ 2008-07-29 17:29 UTC (permalink / raw)
To: mingo, hpa, tglx, torvalds, akpm, arjan, roland, drepper, mikpe,
chrisw, andi
Cc: linux-kernel, suresh.b.siddha
[-- Attachment #1: xsave_in_context_switch.patch --]
[-- Type: text/plain, Size: 8740 bytes --]
Uses xsave/xrstor (instead of traditional fxsave/fxrstor) in context switch
when available.
Introduces TS_XSAVE flag, which determine the need to use xsave/xrstor
instructions during context switch instead of the legacy fxsave/fxrstor
instructions. Thread-synchronous status word is already in L1 cache during
this code patch and thus minimizes the performance penality compared to
(cpu_has_xsave) checks.
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---
Index: tip-0728/arch/x86/kernel/cpu/common.c
===================================================================
--- tip-0728.orig/arch/x86/kernel/cpu/common.c 2008-07-28 18:23:14.000000000 -0700
+++ tip-0728/arch/x86/kernel/cpu/common.c 2008-07-28 18:27:28.000000000 -0700
@@ -709,7 +709,10 @@
/*
* Force FPU initialization:
*/
- current_thread_info()->status = 0;
+ if (cpu_has_xsave)
+ current_thread_info()->status = TS_XSAVE;
+ else
+ current_thread_info()->status = 0;
clear_used_math();
mxcsr_feature_mask_init();
Index: tip-0728/arch/x86/kernel/i387.c
===================================================================
--- tip-0728.orig/arch/x86/kernel/i387.c 2008-07-28 18:23:45.000000000 -0700
+++ tip-0728/arch/x86/kernel/i387.c 2008-07-28 18:27:28.000000000 -0700
@@ -97,7 +97,10 @@
mxcsr_feature_mask_init();
/* clean state in init */
- current_thread_info()->status = 0;
+ if (cpu_has_xsave)
+ current_thread_info()->status = TS_XSAVE;
+ else
+ current_thread_info()->status = 0;
clear_used_math();
}
#endif /* CONFIG_X86_64 */
Index: tip-0728/include/asm-x86/i387.h
===================================================================
--- tip-0728.orig/include/asm-x86/i387.h 2008-07-28 18:23:14.000000000 -0700
+++ tip-0728/include/asm-x86/i387.h 2008-07-28 18:27:28.000000000 -0700
@@ -37,6 +37,8 @@
extern int restore_i387_ia32(struct _fpstate_ia32 __user *buf);
#endif
+#define X87_FSW_ES (1 << 7) /* Exception Summary */
+
#ifdef CONFIG_X86_64
/* Ignore delayed exceptions from user space */
@@ -47,7 +49,7 @@
_ASM_EXTABLE(1b, 2b));
}
-static inline int restore_fpu_checking(struct i387_fxsave_struct *fx)
+static inline int fxrstor_checking(struct i387_fxsave_struct *fx)
{
int err;
@@ -67,15 +69,31 @@
return err;
}
-#define X87_FSW_ES (1 << 7) /* Exception Summary */
+static inline int restore_fpu_checking(struct task_struct *tsk)
+{
+ if (task_thread_info(tsk)->status & TS_XSAVE)
+ return xrstor_checking(&tsk->thread.xstate->xsave);
+ else
+ return fxrstor_checking(&tsk->thread.xstate->fxsave);
+}
/* AMD CPUs don't save/restore FDP/FIP/FOP unless an exception
is pending. Clear the x87 state here by setting it to fixed
values. The kernel data segment can be sometimes 0 and sometimes
new user value. Both should be ok.
Use the PDA as safe address because it should be already in L1. */
-static inline void clear_fpu_state(struct i387_fxsave_struct *fx)
+static inline void clear_fpu_state(struct task_struct *tsk)
{
+ struct xsave_struct *xstate = &tsk->thread.xstate->xsave;
+ struct i387_fxsave_struct *fx = &tsk->thread.xstate->fxsave;
+
+ /*
+ * xsave header may indicate the init state of the FP.
+ */
+ if ((task_thread_info(tsk)->status & TS_XSAVE) &&
+ !(xstate->xsave_hdr.xstate_bv & XSTATE_FP))
+ return;
+
if (unlikely(fx->swd & X87_FSW_ES))
asm volatile("fnclex");
alternative_input(ASM_NOP8 ASM_NOP2,
@@ -108,7 +126,7 @@
return err;
}
-static inline void __save_init_fpu(struct task_struct *tsk)
+static inline void fxsave(struct task_struct *tsk)
{
/* Using "rex64; fxsave %0" is broken because, if the memory operand
uses any extended registers for addressing, a second REX prefix
@@ -133,7 +151,16 @@
: "=m" (tsk->thread.xstate->fxsave)
: "cdaSDb" (&tsk->thread.xstate->fxsave));
#endif
- clear_fpu_state(&tsk->thread.xstate->fxsave);
+}
+
+static inline void __save_init_fpu(struct task_struct *tsk)
+{
+ if (task_thread_info(tsk)->status & TS_XSAVE)
+ xsave(tsk);
+ else
+ fxsave(tsk);
+
+ clear_fpu_state(tsk);
task_thread_info(tsk)->status &= ~TS_USEDFPU;
}
@@ -148,6 +175,10 @@
static inline void restore_fpu(struct task_struct *tsk)
{
+ if (task_thread_info(tsk)->status & TS_XSAVE) {
+ xrstor_checking(&tsk->thread.xstate->xsave);
+ return;
+ }
/*
* The "nop" is needed to make the instructions the same
* length.
@@ -173,6 +204,27 @@
*/
static inline void __save_init_fpu(struct task_struct *tsk)
{
+ if (task_thread_info(tsk)->status & TS_XSAVE) {
+ struct xsave_struct *xstate = &tsk->thread.xstate->xsave;
+ struct i387_fxsave_struct *fx = &tsk->thread.xstate->fxsave;
+
+ xsave(tsk);
+
+ /*
+ * xsave header may indicate the init state of the FP.
+ */
+ if (!(xstate->xsave_hdr.xstate_bv & XSTATE_FP))
+ goto end;
+
+ if (unlikely(fx->swd & X87_FSW_ES))
+ asm volatile("fnclex");
+
+ /*
+ * we can do a simple return here or be paranoid :)
+ */
+ goto clear_state;
+ }
+
/* Use more nops than strictly needed in case the compiler
varies code */
alternative_input(
@@ -182,6 +234,7 @@
X86_FEATURE_FXSR,
[fx] "m" (tsk->thread.xstate->fxsave),
[fsw] "m" (tsk->thread.xstate->fxsave.swd) : "memory");
+clear_state:
/* AMD K7/K8 CPUs don't save/restore FDP/FIP/FOP unless an exception
is pending. Clear the x87 state here by setting it to fixed
values. safe_address is a random variable that should be in L1 */
@@ -191,6 +244,7 @@
"fildl %[addr]", /* set F?P to defined value */
X86_FEATURE_FXSAVE_LEAK,
[addr] "m" (safe_address));
+end:
task_thread_info(tsk)->status &= ~TS_USEDFPU;
}
Index: tip-0728/include/asm-x86/processor.h
===================================================================
--- tip-0728.orig/include/asm-x86/processor.h 2008-07-28 18:23:14.000000000 -0700
+++ tip-0728/include/asm-x86/processor.h 2008-07-28 18:27:28.000000000 -0700
@@ -367,6 +367,7 @@
struct i387_fsave_struct fsave;
struct i387_fxsave_struct fxsave;
struct i387_soft_struct soft;
+ struct xsave_struct xsave;
};
#ifdef CONFIG_X86_64
Index: tip-0728/include/asm-x86/thread_info.h
===================================================================
--- tip-0728.orig/include/asm-x86/thread_info.h 2008-07-28 18:20:15.000000000 -0700
+++ tip-0728/include/asm-x86/thread_info.h 2008-07-28 18:27:28.000000000 -0700
@@ -241,6 +241,7 @@
#define TS_POLLING 0x0004 /* true if in idle loop
and not sleeping */
#define TS_RESTORE_SIGMASK 0x0008 /* restore signal mask in do_signal() */
+#define TS_XSAVE 0x0010 /* Use xsave/xrstor */
#define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING)
Index: tip-0728/include/asm-x86/xsave.h
===================================================================
--- tip-0728.orig/include/asm-x86/xsave.h 2008-07-28 18:23:14.000000000 -0700
+++ tip-0728/include/asm-x86/xsave.h 2008-07-28 18:27:28.000000000 -0700
@@ -17,10 +17,43 @@
#define XCNTXT_LMASK (XSTATE_FP | XSTATE_SSE)
#define XCNTXT_HMASK 0x0
+#ifdef CONFIG_X86_64
+#define REX_PREFIX "0x48, "
+#else
+#define REX_PREFIX
+#endif
+
extern unsigned int xstate_size, pcntxt_hmask, pcntxt_lmask;
extern struct xsave_struct *init_xstate_buf;
extern void xsave_cntxt_init(void);
extern void xsave_init(void);
+extern int init_fpu(struct task_struct *child);
+
+static inline int xrstor_checking(struct xsave_struct *fx)
+{
+ int err;
+
+ asm volatile("1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n\t"
+ "2:\n"
+ ".section .fixup,\"ax\"\n"
+ "3: movl $-1,%[err]\n"
+ " jmp 2b\n"
+ ".previous\n"
+ _ASM_EXTABLE(1b, 3b)
+ : [err] "=r" (err)
+ : "D" (fx), "m" (*fx), "a" (-1), "d" (-1), "0" (0)
+ : "memory");
+
+ return err;
+}
+static inline void xsave(struct task_struct *tsk)
+{
+ /* This, however, we can work around by forcing the compiler to select
+ an addressing mode that doesn't require extended registers. */
+ __asm__ __volatile__(".byte " REX_PREFIX "0x0f,0xae,0x27"
+ ::"D" (&(tsk->thread.xstate->xsave)),
+ "a" (-1), "d"(-1) : "memory");
+}
#endif
Index: tip-0728/arch/x86/kernel/traps_64.c
===================================================================
--- tip-0728.orig/arch/x86/kernel/traps_64.c 2008-07-28 18:23:14.000000000 -0700
+++ tip-0728/arch/x86/kernel/traps_64.c 2008-07-28 18:27:28.000000000 -0700
@@ -1147,7 +1147,7 @@
/*
* Paranoid restore. send a SIGSEGV if we fail to restore the state.
*/
- if (unlikely(restore_fpu_checking(&me->thread.xstate->fxsave))) {
+ if (unlikely(restore_fpu_checking(me))) {
stts();
force_sig(SIGSEGV, me);
return;
--
^ permalink raw reply [flat|nested] 37+ messages in thread
* [patch 4/9] x86, xsave: dynamically allocate sigframes fpstate instead of static allocation
2008-07-29 17:29 [patch 0/9] x86, xsave: xsave/xrstor support Suresh Siddha
` (2 preceding siblings ...)
2008-07-29 17:29 ` [patch 3/9] x86, xsave: context switch support using xsave/xrstor Suresh Siddha
@ 2008-07-29 17:29 ` Suresh Siddha
2008-07-29 17:29 ` [patch 5/9] x86, xsave: reorganization of signal save/restore fpstate code layout Suresh Siddha
` (5 subsequent siblings)
9 siblings, 0 replies; 37+ messages in thread
From: Suresh Siddha @ 2008-07-29 17:29 UTC (permalink / raw)
To: mingo, hpa, tglx, torvalds, akpm, arjan, roland, drepper, mikpe,
chrisw, andi
Cc: linux-kernel, suresh.b.siddha
[-- Attachment #1: fpstate_dynamic.patch --]
[-- Type: text/plain, Size: 9554 bytes --]
dynamically allocate fpstate on the stack, instead of static allocation
in the current sigframe layout on the user stack. This will allow the
fpstate structure to grow in the future, which includes extended state
information supporting xsave/xrstor.
signal handlers will be able to access the fpstate pointer from the
sigcontext structure asusual, with no change. For the non RT sigframe's
(which are supported only for 32bit apps), current static fpstate layout
in the sigframe will be unused(so that we don't change the extramask[]
offset in the sigframe and thus prevent breaking app's which modify
extramask[]).
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---
Index: tip-0728/arch/x86/ia32/ia32_signal.c
===================================================================
--- tip-0728.orig/arch/x86/ia32/ia32_signal.c 2008-07-28 18:20:15.000000000 -0700
+++ tip-0728/arch/x86/ia32/ia32_signal.c 2008-07-28 18:35:50.000000000 -0700
@@ -179,9 +179,10 @@
u32 pretcode;
int sig;
struct sigcontext_ia32 sc;
- struct _fpstate_ia32 fpstate;
+ struct _fpstate_ia32 fpstate_unused; /* look at kernel/sigframe.h */
unsigned int extramask[_COMPAT_NSIG_WORDS-1];
char retcode[8];
+ /* fp state follows here */
};
struct rt_sigframe
@@ -192,8 +193,8 @@
u32 puc;
compat_siginfo_t info;
struct ucontext_ia32 uc;
- struct _fpstate_ia32 fpstate;
char retcode[8];
+ /* fp state follows here */
};
#define COPY(x) { \
@@ -402,7 +403,8 @@
* Determine which stack to use..
*/
static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
- size_t frame_size)
+ size_t frame_size,
+ struct _fpstate_ia32 **fpstate)
{
unsigned long sp;
@@ -421,6 +423,11 @@
ka->sa.sa_restorer)
sp = (unsigned long) ka->sa.sa_restorer;
+ if (used_math()) {
+ sp = sp - sig_xstate_ia32_size;
+ *fpstate = (struct _fpstate_ia32 *) sp;
+ }
+
sp -= frame_size;
/* Align the stack pointer according to the i386 ABI,
* i.e. so that on function entry ((sp + 4) & 15) == 0. */
@@ -434,6 +441,7 @@
struct sigframe __user *frame;
void __user *restorer;
int err = 0;
+ struct _fpstate_ia32 __user *fpstate = NULL;
/* copy_to_user optimizes that into a single 8 byte store */
static const struct {
@@ -448,7 +456,7 @@
0,
};
- frame = get_sigframe(ka, regs, sizeof(*frame));
+ frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
goto give_sigsegv;
@@ -457,8 +465,7 @@
if (err)
goto give_sigsegv;
- err |= ia32_setup_sigcontext(&frame->sc, &frame->fpstate, regs,
- set->sig[0]);
+ err |= ia32_setup_sigcontext(&frame->sc, fpstate, regs, set->sig[0]);
if (err)
goto give_sigsegv;
@@ -522,6 +529,7 @@
struct rt_sigframe __user *frame;
void __user *restorer;
int err = 0;
+ struct _fpstate_ia32 __user *fpstate = NULL;
/* __copy_to_user optimizes that into a single 8 byte store */
static const struct {
@@ -537,7 +545,7 @@
0,
};
- frame = get_sigframe(ka, regs, sizeof(*frame));
+ frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
goto give_sigsegv;
@@ -556,7 +564,7 @@
err |= __put_user(sas_ss_flags(regs->sp),
&frame->uc.uc_stack.ss_flags);
err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
- err |= ia32_setup_sigcontext(&frame->uc.uc_mcontext, &frame->fpstate,
+ err |= ia32_setup_sigcontext(&frame->uc.uc_mcontext, fpstate,
regs, set->sig[0]);
err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
if (err)
Index: tip-0728/arch/x86/kernel/sigframe.h
===================================================================
--- tip-0728.orig/arch/x86/kernel/sigframe.h 2008-07-28 18:20:15.000000000 -0700
+++ tip-0728/arch/x86/kernel/sigframe.h 2008-07-28 18:31:15.000000000 -0700
@@ -3,9 +3,18 @@
char __user *pretcode;
int sig;
struct sigcontext sc;
- struct _fpstate fpstate;
+ /*
+ * fpstate is unused. fpstate is moved/allocated after
+ * retcode[] below. This movement allows to have the FP state and the
+ * future state extensions (xsave) stay together.
+ * And at the same time retaining the unused fpstate, prevents changing
+ * the offset of extramask[] in the sigframe and thus prevent any
+ * legacy application accessing/modifying it.
+ */
+ struct _fpstate fpstate_unused;
unsigned long extramask[_NSIG_WORDS-1];
char retcode[8];
+ /* fp state follows here */
};
struct rt_sigframe {
@@ -15,13 +24,14 @@
void __user *puc;
struct siginfo info;
struct ucontext uc;
- struct _fpstate fpstate;
char retcode[8];
+ /* fp state follows here */
};
#else
struct rt_sigframe {
char __user *pretcode;
struct ucontext uc;
struct siginfo info;
+ /* fp state follows here */
};
#endif
Index: tip-0728/arch/x86/kernel/signal_32.c
===================================================================
--- tip-0728.orig/arch/x86/kernel/signal_32.c 2008-07-28 18:20:15.000000000 -0700
+++ tip-0728/arch/x86/kernel/signal_32.c 2008-07-28 18:34:54.000000000 -0700
@@ -308,7 +308,8 @@
* Determine which stack to use..
*/
static inline void __user *
-get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size)
+get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size,
+ struct _fpstate **fpstate)
{
unsigned long sp;
@@ -334,6 +335,11 @@
sp = (unsigned long) ka->sa.sa_restorer;
}
+ if (used_math()) {
+ sp = sp - sig_xstate_size;
+ *fpstate = (struct _fpstate *) sp;
+ }
+
sp -= frame_size;
/*
* Align the stack pointer according to the i386 ABI,
@@ -352,8 +358,9 @@
void __user *restorer;
int err = 0;
int usig;
+ struct _fpstate __user *fpstate = NULL;
- frame = get_sigframe(ka, regs, sizeof(*frame));
+ frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
goto give_sigsegv;
@@ -368,7 +375,7 @@
if (err)
goto give_sigsegv;
- err = setup_sigcontext(&frame->sc, &frame->fpstate, regs, set->sig[0]);
+ err = setup_sigcontext(&frame->sc, fpstate, regs, set->sig[0]);
if (err)
goto give_sigsegv;
@@ -429,8 +436,9 @@
void __user *restorer;
int err = 0;
int usig;
+ struct _fpstate __user *fpstate = NULL;
- frame = get_sigframe(ka, regs, sizeof(*frame));
+ frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
goto give_sigsegv;
@@ -455,7 +463,7 @@
err |= __put_user(sas_ss_flags(regs->sp),
&frame->uc.uc_stack.ss_flags);
err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
- err |= setup_sigcontext(&frame->uc.uc_mcontext, &frame->fpstate,
+ err |= setup_sigcontext(&frame->uc.uc_mcontext, fpstate,
regs, set->sig[0]);
err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
if (err)
Index: tip-0728/arch/x86/kernel/i387.c
===================================================================
--- tip-0728.orig/arch/x86/kernel/i387.c 2008-07-28 18:27:28.000000000 -0700
+++ tip-0728/arch/x86/kernel/i387.c 2008-07-28 18:31:15.000000000 -0700
@@ -24,6 +24,7 @@
# define save_i387_ia32 save_i387
# define restore_i387_ia32 restore_i387
# define _fpstate_ia32 _fpstate
+# define sig_xstate_ia32_size sig_xstate_size
# define user_i387_ia32_struct user_i387_struct
# define user32_fxsr_struct user_fxsr_struct
#endif
@@ -36,6 +37,7 @@
static unsigned int mxcsr_feature_mask __read_mostly = 0xffffffffu;
unsigned int xstate_size;
+unsigned int sig_xstate_ia32_size = sizeof(struct _fpstate_ia32);
static struct i387_fxsave_struct fx_scratch __cpuinitdata;
void __cpuinit mxcsr_feature_mask_init(void)
Index: tip-0728/arch/x86/kernel/signal_64.c
===================================================================
--- tip-0728.orig/arch/x86/kernel/signal_64.c 2008-07-28 18:20:15.000000000 -0700
+++ tip-0728/arch/x86/kernel/signal_64.c 2008-07-28 18:31:15.000000000 -0700
@@ -284,7 +284,7 @@
struct task_struct *me = current;
if (used_math()) {
- fp = get_stack(ka, regs, sizeof(struct _fpstate));
+ fp = get_stack(ka, regs, sig_xstate_size);
frame = (void __user *)round_down(
(unsigned long)fp - sizeof(struct rt_sigframe), 16) - 8;
Index: tip-0728/arch/x86/kernel/xsave.c
===================================================================
--- tip-0728.orig/arch/x86/kernel/xsave.c 2008-07-28 18:27:03.000000000 -0700
+++ tip-0728/arch/x86/kernel/xsave.c 2008-07-28 18:31:15.000000000 -0700
@@ -17,6 +17,10 @@
*/
struct xsave_struct *init_xstate_buf;
+#ifdef CONFIG_X86_64
+unsigned int sig_xstate_size = sizeof(struct _fpstate);
+#endif
+
/*
* Enable the extended processor state save/restore feature
*/
Index: tip-0728/include/asm-x86/i387.h
===================================================================
--- tip-0728.orig/include/asm-x86/i387.h 2008-07-28 18:27:28.000000000 -0700
+++ tip-0728/include/asm-x86/i387.h 2008-07-28 18:31:15.000000000 -0700
@@ -20,6 +20,7 @@
#include <asm/uaccess.h>
#include <asm/xsave.h>
+extern unsigned int sig_xstate_size;
extern void fpu_init(void);
extern void mxcsr_feature_mask_init(void);
extern int init_fpu(struct task_struct *child);
@@ -32,6 +33,7 @@
extern user_regset_set_fn fpregs_set, xfpregs_set, fpregs_soft_set;
#ifdef CONFIG_IA32_EMULATION
+extern unsigned int sig_xstate_ia32_size;
struct _fpstate_ia32;
extern int save_i387_ia32(struct _fpstate_ia32 __user *buf);
extern int restore_i387_ia32(struct _fpstate_ia32 __user *buf);
--
^ permalink raw reply [flat|nested] 37+ messages in thread
* [patch 5/9] x86, xsave: reorganization of signal save/restore fpstate code layout
2008-07-29 17:29 [patch 0/9] x86, xsave: xsave/xrstor support Suresh Siddha
` (3 preceding siblings ...)
2008-07-29 17:29 ` [patch 4/9] x86, xsave: dynamically allocate sigframes fpstate instead of static allocation Suresh Siddha
@ 2008-07-29 17:29 ` Suresh Siddha
2008-07-29 17:29 ` [patch 6/9] x86, xsave: xsave/xrstor specific routines Suresh Siddha
` (4 subsequent siblings)
9 siblings, 0 replies; 37+ messages in thread
From: Suresh Siddha @ 2008-07-29 17:29 UTC (permalink / raw)
To: mingo, hpa, tglx, torvalds, akpm, arjan, roland, drepper, mikpe,
chrisw, andi
Cc: linux-kernel, suresh.b.siddha
[-- Attachment #1: prepare_for_xsave_sigcontext.patch --]
[-- Type: text/plain, Size: 13597 bytes --]
move 64bit routines that saves/restores fpstate in/from user stack from
signal_64.c to xsave.c
restore_i387_xstate() now handles the condition when user passes
NULL fpstate.
Other misc changes for prepartion of xsave/xrstor sigcontext support.
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---
Index: tip-0728/arch/x86/kernel/i387.c
===================================================================
--- tip-0728.orig/arch/x86/kernel/i387.c 2008-07-28 18:31:15.000000000 -0700
+++ tip-0728/arch/x86/kernel/i387.c 2008-07-28 18:37:20.000000000 -0700
@@ -21,9 +21,10 @@
# include <asm/sigcontext32.h>
# include <asm/user32.h>
#else
-# define save_i387_ia32 save_i387
-# define restore_i387_ia32 restore_i387
+# define save_i387_xstate_ia32 save_i387_xstate
+# define restore_i387_xstate_ia32 restore_i387_xstate
# define _fpstate_ia32 _fpstate
+# define _xstate_ia32 _xstate
# define sig_xstate_ia32_size sig_xstate_size
# define user_i387_ia32_struct user_i387_struct
# define user32_fxsr_struct user_fxsr_struct
@@ -424,7 +425,6 @@
struct task_struct *tsk = current;
struct i387_fsave_struct *fp = &tsk->thread.xstate->fsave;
- unlazy_fpu(tsk);
fp->status = fp->swd;
if (__copy_to_user(buf, fp, sizeof(struct i387_fsave_struct)))
return -1;
@@ -438,8 +438,6 @@
struct user_i387_ia32_struct env;
int err = 0;
- unlazy_fpu(tsk);
-
convert_from_fxsr(&env, tsk);
if (__copy_to_user(buf, &env, sizeof(env)))
return -1;
@@ -455,10 +453,16 @@
return 1;
}
-int save_i387_ia32(struct _fpstate_ia32 __user *buf)
+int save_i387_xstate_ia32(void __user *buf)
{
+ struct _fpstate_ia32 __user *fp = (struct _fpstate_ia32 __user *) buf;
+ struct task_struct *tsk = current;
+
if (!used_math())
return 0;
+
+ if (!access_ok(VERIFY_WRITE, buf, sig_xstate_ia32_size))
+ return -EACCES;
/*
* This will cause a "finit" to be triggered by the next
* attempted FPU operation by the 'current' process.
@@ -468,13 +472,15 @@
if (!HAVE_HWFP) {
return fpregs_soft_get(current, NULL,
0, sizeof(struct user_i387_ia32_struct),
- NULL, buf) ? -1 : 1;
+ NULL, fp) ? -1 : 1;
}
+ unlazy_fpu(tsk);
+
if (cpu_has_fxsr)
- return save_i387_fxsave(buf);
+ return save_i387_fxsave(fp);
else
- return save_i387_fsave(buf);
+ return save_i387_fsave(fp);
}
static inline int restore_i387_fsave(struct _fpstate_ia32 __user *buf)
@@ -502,14 +508,26 @@
return 0;
}
-int restore_i387_ia32(struct _fpstate_ia32 __user *buf)
+int restore_i387_xstate_ia32(void __user *buf)
{
int err;
struct task_struct *tsk = current;
+ struct _fpstate_ia32 __user *fp = (struct _fpstate_ia32 __user *) buf;
if (HAVE_HWFP)
clear_fpu(tsk);
+ if (!buf) {
+ if (used_math()) {
+ clear_fpu(tsk);
+ clear_used_math();
+ }
+
+ return 0;
+ } else
+ if (!access_ok(VERIFY_READ, buf, sig_xstate_ia32_size))
+ return -EACCES;
+
if (!used_math()) {
err = init_fpu(tsk);
if (err)
@@ -518,13 +536,13 @@
if (HAVE_HWFP) {
if (cpu_has_fxsr)
- err = restore_i387_fxsave(buf);
+ err = restore_i387_fxsave(fp);
else
- err = restore_i387_fsave(buf);
+ err = restore_i387_fsave(fp);
} else {
err = fpregs_soft_set(current, NULL,
0, sizeof(struct user_i387_ia32_struct),
- NULL, buf) != 0;
+ NULL, fp) != 0;
}
set_used_math();
Index: tip-0728/arch/x86/kernel/xsave.c
===================================================================
--- tip-0728.orig/arch/x86/kernel/xsave.c 2008-07-28 18:31:15.000000000 -0700
+++ tip-0728/arch/x86/kernel/xsave.c 2008-07-28 18:37:20.000000000 -0700
@@ -12,6 +12,85 @@
*/
unsigned int pcntxt_hmask, pcntxt_lmask;
+#ifdef CONFIG_X86_64
+/*
+ * Signal frame handlers.
+ */
+
+int save_i387_xstate(void __user *buf)
+{
+ struct task_struct *tsk = current;
+ int err = 0;
+
+ if (!access_ok(VERIFY_WRITE, buf, sig_xstate_size))
+ return -EACCES;
+
+ BUILD_BUG_ON(sizeof(struct user_i387_struct) !=
+ sizeof(tsk->thread.xstate->fxsave));
+
+ if ((unsigned long)buf % 16)
+ printk("save_i387_xstate: bad fpstate %p\n", buf);
+
+ if (!used_math())
+ return 0;
+ clear_used_math(); /* trigger finit */
+ if (task_thread_info(tsk)->status & TS_USEDFPU) {
+ err = save_i387_checking((struct i387_fxsave_struct __user *)
+ buf);
+ if (err)
+ return err;
+ task_thread_info(tsk)->status &= ~TS_USEDFPU;
+ stts();
+ } else {
+ if (__copy_to_user(buf, &tsk->thread.xstate->fxsave,
+ xstate_size))
+ return -1;
+ }
+ return 1;
+}
+
+/*
+ * This restores directly out of user space. Exceptions are handled.
+ */
+int restore_i387_xstate(void __user *buf)
+{
+ struct task_struct *tsk = current;
+ int err;
+
+ if (!buf) {
+ if (used_math()) {
+ clear_fpu(tsk);
+ clear_used_math();
+ }
+
+ return 0;
+ } else
+ if (!access_ok(VERIFY_READ, buf, sig_xstate_size))
+ return -EACCES;
+
+ if (!used_math()) {
+ err = init_fpu(tsk);
+ if (err)
+ return err;
+ }
+
+ if (!(task_thread_info(current)->status & TS_USEDFPU)) {
+ clts();
+ task_thread_info(current)->status |= TS_USEDFPU;
+ }
+ err = fxrstor_checking((__force struct i387_fxsave_struct *)buf);
+ if (unlikely(err)) {
+ /*
+ * Encountered an error while doing the restore from the
+ * user buffer, clear the fpu state.
+ */
+ clear_fpu(tsk);
+ clear_used_math();
+ }
+ return err;
+}
+#endif
+
/*
* Represents init state for the supported extended state.
*/
Index: tip-0728/include/asm-x86/i387.h
===================================================================
--- tip-0728.orig/include/asm-x86/i387.h 2008-07-28 18:31:15.000000000 -0700
+++ tip-0728/include/asm-x86/i387.h 2008-07-28 18:37:20.000000000 -0700
@@ -35,8 +35,9 @@
#ifdef CONFIG_IA32_EMULATION
extern unsigned int sig_xstate_ia32_size;
struct _fpstate_ia32;
-extern int save_i387_ia32(struct _fpstate_ia32 __user *buf);
-extern int restore_i387_ia32(struct _fpstate_ia32 __user *buf);
+struct _xstate_ia32;
+extern int save_i387_xstate_ia32(void __user *buf);
+extern int restore_i387_xstate_ia32(void __user *buf);
#endif
#define X87_FSW_ES (1 << 7) /* Exception Summary */
@@ -250,13 +251,13 @@
task_thread_info(tsk)->status &= ~TS_USEDFPU;
}
+#endif /* CONFIG_X86_64 */
+
/*
* Signal frame handlers...
*/
-extern int save_i387(struct _fpstate __user *buf);
-extern int restore_i387(struct _fpstate __user *buf);
-
-#endif /* CONFIG_X86_64 */
+extern int save_i387_xstate(void __user *buf);
+extern int restore_i387_xstate(void __user *buf);
static inline void __unlazy_fpu(struct task_struct *tsk)
{
Index: tip-0728/arch/x86/ia32/ia32_signal.c
===================================================================
--- tip-0728.orig/arch/x86/ia32/ia32_signal.c 2008-07-28 18:35:50.000000000 -0700
+++ tip-0728/arch/x86/ia32/ia32_signal.c 2008-07-28 18:38:04.000000000 -0700
@@ -216,7 +216,7 @@
unsigned int *peax)
{
unsigned int tmpflags, gs, oldgs, err = 0;
- struct _fpstate_ia32 __user *buf;
+ void __user *buf;
u32 tmp;
/* Always make any pending restarted system calls return -EINTR */
@@ -260,26 +260,12 @@
err |= __get_user(tmp, &sc->fpstate);
buf = compat_ptr(tmp);
- if (buf) {
- if (!access_ok(VERIFY_READ, buf, sizeof(*buf)))
- goto badframe;
- err |= restore_i387_ia32(buf);
- } else {
- struct task_struct *me = current;
-
- if (used_math()) {
- clear_fpu(me);
- clear_used_math();
- }
- }
+ err |= restore_i387_xstate_ia32(buf);
err |= __get_user(tmp, &sc->ax);
*peax = tmp;
return err;
-
-badframe:
- return 1;
}
asmlinkage long sys32_sigreturn(struct pt_regs *regs)
@@ -351,7 +337,7 @@
*/
static int ia32_setup_sigcontext(struct sigcontext_ia32 __user *sc,
- struct _fpstate_ia32 __user *fpstate,
+ void __user *fpstate,
struct pt_regs *regs, unsigned int mask)
{
int tmp, err = 0;
@@ -382,7 +368,7 @@
err |= __put_user((u32)regs->flags, &sc->flags);
err |= __put_user((u32)regs->sp, &sc->sp_at_signal);
- tmp = save_i387_ia32(fpstate);
+ tmp = save_i387_xstate_ia32(fpstate);
if (tmp < 0)
err = -EFAULT;
else {
@@ -404,7 +390,7 @@
*/
static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
size_t frame_size,
- struct _fpstate_ia32 **fpstate)
+ void **fpstate)
{
unsigned long sp;
@@ -441,7 +427,7 @@
struct sigframe __user *frame;
void __user *restorer;
int err = 0;
- struct _fpstate_ia32 __user *fpstate = NULL;
+ void __user *fpstate = NULL;
/* copy_to_user optimizes that into a single 8 byte store */
static const struct {
@@ -529,7 +515,7 @@
struct rt_sigframe __user *frame;
void __user *restorer;
int err = 0;
- struct _fpstate_ia32 __user *fpstate = NULL;
+ void __user *fpstate = NULL;
/* __copy_to_user optimizes that into a single 8 byte store */
static const struct {
Index: tip-0728/arch/x86/kernel/signal_32.c
===================================================================
--- tip-0728.orig/arch/x86/kernel/signal_32.c 2008-07-28 18:34:54.000000000 -0700
+++ tip-0728/arch/x86/kernel/signal_32.c 2008-07-28 18:37:20.000000000 -0700
@@ -161,28 +161,14 @@
}
{
- struct _fpstate __user *buf;
+ void __user *buf;
err |= __get_user(buf, &sc->fpstate);
- if (buf) {
- if (!access_ok(VERIFY_READ, buf, sizeof(*buf)))
- goto badframe;
- err |= restore_i387(buf);
- } else {
- struct task_struct *me = current;
-
- if (used_math()) {
- clear_fpu(me);
- clear_used_math();
- }
- }
+ err |= restore_i387_xstate(buf);
}
err |= __get_user(*pax, &sc->ax);
return err;
-
-badframe:
- return 1;
}
asmlinkage unsigned long sys_sigreturn(unsigned long __unused)
@@ -264,7 +250,7 @@
* Set up a signal frame.
*/
static int
-setup_sigcontext(struct sigcontext __user *sc, struct _fpstate __user *fpstate,
+setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate,
struct pt_regs *regs, unsigned long mask)
{
int tmp, err = 0;
@@ -291,7 +277,7 @@
err |= __put_user(regs->sp, &sc->sp_at_signal);
err |= __put_user(regs->ss, (unsigned int __user *)&sc->ss);
- tmp = save_i387(fpstate);
+ tmp = save_i387_xstate(fpstate);
if (tmp < 0)
err = 1;
else
@@ -309,7 +295,7 @@
*/
static inline void __user *
get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size,
- struct _fpstate **fpstate)
+ void **fpstate)
{
unsigned long sp;
@@ -358,7 +344,7 @@
void __user *restorer;
int err = 0;
int usig;
- struct _fpstate __user *fpstate = NULL;
+ void __user *fpstate = NULL;
frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
@@ -436,7 +422,7 @@
void __user *restorer;
int err = 0;
int usig;
- struct _fpstate __user *fpstate = NULL;
+ void __user *fpstate = NULL;
frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
Index: tip-0728/arch/x86/kernel/signal_64.c
===================================================================
--- tip-0728.orig/arch/x86/kernel/signal_64.c 2008-07-28 18:31:15.000000000 -0700
+++ tip-0728/arch/x86/kernel/signal_64.c 2008-07-28 18:37:20.000000000 -0700
@@ -57,69 +57,6 @@
}
/*
- * Signal frame handlers.
- */
-
-static inline int save_i387(struct _fpstate __user *buf)
-{
- struct task_struct *tsk = current;
- int err = 0;
-
- BUILD_BUG_ON(sizeof(struct user_i387_struct) !=
- sizeof(tsk->thread.xstate->fxsave));
-
- if ((unsigned long)buf % 16)
- printk("save_i387: bad fpstate %p\n", buf);
-
- if (!used_math())
- return 0;
- clear_used_math(); /* trigger finit */
- if (task_thread_info(tsk)->status & TS_USEDFPU) {
- err = save_i387_checking((struct i387_fxsave_struct __user *)
- buf);
- if (err)
- return err;
- task_thread_info(tsk)->status &= ~TS_USEDFPU;
- stts();
- } else {
- if (__copy_to_user(buf, &tsk->thread.xstate->fxsave,
- sizeof(struct i387_fxsave_struct)))
- return -1;
- }
- return 1;
-}
-
-/*
- * This restores directly out of user space. Exceptions are handled.
- */
-static inline int restore_i387(struct _fpstate __user *buf)
-{
- struct task_struct *tsk = current;
- int err;
-
- if (!used_math()) {
- err = init_fpu(tsk);
- if (err)
- return err;
- }
-
- if (!(task_thread_info(current)->status & TS_USEDFPU)) {
- clts();
- task_thread_info(current)->status |= TS_USEDFPU;
- }
- err = restore_fpu_checking((__force struct i387_fxsave_struct *)buf);
- if (unlikely(err)) {
- /*
- * Encountered an error while doing the restore from the
- * user buffer, clear the fpu state.
- */
- clear_fpu(tsk);
- clear_used_math();
- }
- return err;
-}
-
-/*
* Do a signal return; undo the signal stack.
*/
static int
@@ -163,25 +100,11 @@
{
struct _fpstate __user * buf;
err |= __get_user(buf, &sc->fpstate);
-
- if (buf) {
- if (!access_ok(VERIFY_READ, buf, sizeof(*buf)))
- goto badframe;
- err |= restore_i387(buf);
- } else {
- struct task_struct *me = current;
- if (used_math()) {
- clear_fpu(me);
- clear_used_math();
- }
- }
+ err |= restore_i387_xstate(buf);
}
err |= __get_user(*pax, &sc->ax);
return err;
-
-badframe:
- return 1;
}
asmlinkage long sys_rt_sigreturn(struct pt_regs *regs)
@@ -279,7 +202,7 @@
sigset_t *set, struct pt_regs * regs)
{
struct rt_sigframe __user *frame;
- struct _fpstate __user *fp = NULL;
+ void __user *fp = NULL;
int err = 0;
struct task_struct *me = current;
@@ -291,7 +214,7 @@
if (!access_ok(VERIFY_WRITE, fp, sizeof(struct _fpstate)))
goto give_sigsegv;
- if (save_i387(fp) < 0)
+ if (save_i387_xstate(fp) < 0)
err |= -1;
} else
frame = get_stack(ka, regs, sizeof(struct rt_sigframe)) - 8;
--
^ permalink raw reply [flat|nested] 37+ messages in thread
* [patch 6/9] x86, xsave: xsave/xrstor specific routines
2008-07-29 17:29 [patch 0/9] x86, xsave: xsave/xrstor support Suresh Siddha
` (4 preceding siblings ...)
2008-07-29 17:29 ` [patch 5/9] x86, xsave: reorganization of signal save/restore fpstate code layout Suresh Siddha
@ 2008-07-29 17:29 ` Suresh Siddha
2008-07-29 17:29 ` [patch 7/9] x86, xsave: struct _fpstate extensions to include extended state information Suresh Siddha
` (3 subsequent siblings)
9 siblings, 0 replies; 37+ messages in thread
From: Suresh Siddha @ 2008-07-29 17:29 UTC (permalink / raw)
To: mingo, hpa, tglx, torvalds, akpm, arjan, roland, drepper, mikpe,
chrisw, andi
Cc: linux-kernel, suresh.b.siddha
[-- Attachment #1: xsave_routines.patch --]
[-- Type: text/plain, Size: 2021 bytes --]
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---
Index: tip-0728/include/asm-x86/xsave.h
===================================================================
--- tip-0728.orig/include/asm-x86/xsave.h 2008-07-28 18:19:58.000000000 -0700
+++ tip-0728/include/asm-x86/xsave.h 2008-07-28 18:20:05.000000000 -0700
@@ -48,6 +48,58 @@
return err;
}
+static inline int xsave_check(struct xsave_struct __user *buf)
+{
+ int err;
+ __asm__ __volatile__("1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
+ "2:\n"
+ ".section .fixup,\"ax\"\n"
+ "3: movl $-1,%[err]\n"
+ " jmp 2b\n"
+ ".previous\n"
+ ".section __ex_table,\"a\"\n"
+ _ASM_ALIGN "\n"
+ _ASM_PTR "1b,3b\n"
+ ".previous"
+ : [err] "=r" (err)
+ : "D" (buf), "a" (-1), "d" (-1), "0" (0)
+ : "memory");
+ if (unlikely(err) && __clear_user(buf, xstate_size))
+ err = -EFAULT;
+ /* No need to clear here because the caller clears USED_MATH */
+ return err;
+}
+
+static inline int xrestore_user(struct xsave_struct __user *buf,
+ unsigned int lmask,
+ unsigned int hmask)
+{
+ int err;
+ struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
+
+ __asm__ __volatile__("1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
+ "2:\n"
+ ".section .fixup,\"ax\"\n"
+ "3: movl $-1,%[err]\n"
+ " jmp 2b\n"
+ ".previous\n"
+ ".section __ex_table,\"a\"\n"
+ _ASM_ALIGN "\n"
+ _ASM_PTR "1b,3b\n"
+ ".previous"
+ : [err] "=r" (err)
+ : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
+ : "memory"); //memory required?
+ return err;
+}
+
+static inline void xrstor_state(struct xsave_struct *fx, int lmask, int hmask)
+{
+ asm volatile(".byte " REX_PREFIX "0x0f,0xae,0x2f\n\t"
+ :: "D" (fx), "m" (*fx), "a" (lmask), "d" (hmask)
+ : "memory");
+}
+
static inline void xsave(struct task_struct *tsk)
{
/* This, however, we can work around by forcing the compiler to select
--
^ permalink raw reply [flat|nested] 37+ messages in thread
* [patch 7/9] x86, xsave: struct _fpstate extensions to include extended state information
2008-07-29 17:29 [patch 0/9] x86, xsave: xsave/xrstor support Suresh Siddha
` (5 preceding siblings ...)
2008-07-29 17:29 ` [patch 6/9] x86, xsave: xsave/xrstor specific routines Suresh Siddha
@ 2008-07-29 17:29 ` Suresh Siddha
2008-07-29 17:29 ` [patch 8/9] x86, xsave: save/restore the extended state context in sigframe Suresh Siddha
` (2 subsequent siblings)
9 siblings, 0 replies; 37+ messages in thread
From: Suresh Siddha @ 2008-07-29 17:29 UTC (permalink / raw)
To: mingo, hpa, tglx, torvalds, akpm, arjan, roland, drepper, mikpe,
chrisw, andi
Cc: linux-kernel, suresh.b.siddha
[-- Attachment #1: sigcontext_header_extensions.patch --]
[-- Type: text/plain, Size: 5540 bytes --]
Bytes 464..511 in the current 512byte layout of fxsave/fxrstor
frame, are reserved for SW usage. On cpu's supporting xsave/xrstor, these bytes
are used to extended the fpstate pointer in the sigcontext, which now includes
the extended state information along with fpstate information.
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---
Index: tip-0728/include/asm-x86/sigcontext.h
===================================================================
--- tip-0728.orig/include/asm-x86/sigcontext.h 2008-07-28 18:42:45.000000000 -0700
+++ tip-0728/include/asm-x86/sigcontext.h 2008-07-28 18:44:20.000000000 -0700
@@ -4,6 +4,40 @@
#include <linux/compiler.h>
#include <asm/types.h>
+#define FP_XSTATE_MAGIC1 0x46505853U
+#define FP_XSTATE_MAGIC2 0x46505845U
+#define FP_XSTATE_MAGIC2_SIZE sizeof(FP_XSTATE_MAGIC2)
+
+/*
+ * bytes 464..511 in the current 512byte layout of fxsave/fxrstor frame
+ * are reserved for SW usage. On cpu's supporting xsave/xrstor, these bytes
+ * are used to extended the fpstate pointer in the sigcontext, which now
+ * includes the extended state information along with fpstate information.
+ *
+ * Presence of FP_XSTATE_MAGIC1 at the beginning of this SW reserved
+ * area and FP_XSTATE_MAGIC2 at the end of memory layout
+ * (extended_size - FP_XSTATE_MAGIC2_SIZE) indicates the presence of the
+ * extended state information in the memory layout pointed by the fpstate
+ * pointer in sigcontext.
+ */
+struct _fpx_sw_bytes {
+ __u32 magic1; /* FP_XSTATE_MAGIC1 */
+ __u32 extended_size; /* total size of the layout referred by
+ * fpstate pointer in the sigcontext.
+ */
+ __u64 xstate_bv;
+ /* feature bit mask (including fp/sse/extended
+ * state) that is present in the memory
+ * layout.
+ */
+ __u32 xstate_size; /* actual xsave state size, based on the
+ * features saved in the layout.
+ * 'extended_size' will be greater than
+ * 'xstate_size'.
+ */
+ __u32 padding[7]; /* for future use. */
+};
+
#ifdef __i386__
/*
* As documented in the iBCS2 standard..
@@ -53,7 +87,13 @@
unsigned long reserved;
struct _fpxreg _fxsr_st[8]; /* FXSR FPU reg data is ignored */
struct _xmmreg _xmm[8];
- unsigned long padding[56];
+ unsigned long padding1[44];
+
+ union {
+ unsigned long padding2[12];
+ struct _fpx_sw_bytes sw_reserved; /* represents the extended
+ * state info */
+ };
};
#define X86_FXSR_MAGIC 0x0000
@@ -79,7 +119,14 @@
unsigned long flags;
unsigned long sp_at_signal;
unsigned short ss, __ssh;
- struct _fpstate __user *fpstate;
+
+ /* fpstate is really (struct _fpstate *) or (struct _xstate *)
+ * depending on the FP_XSTATE_MAGIC1 encoded in the SW reserved
+ * bytes of (struct _fpstate) and FP_XSTATE_MAGIC2 present at the end
+ * of extended memory layout. See comments at the defintion of
+ * (struct _fpx_sw_bytes)
+ */
+ void __user *fpstate; /* zero when no FPU/extended context */
unsigned long oldmask;
unsigned long cr2;
};
@@ -130,7 +177,12 @@
__u32 mxcsr_mask;
__u32 st_space[32]; /* 8*16 bytes for each FP-reg */
__u32 xmm_space[64]; /* 16*16 bytes for each XMM-reg */
- __u32 reserved2[24];
+ __u32 reserved2[12];
+ union {
+ __u32 reserved3[12];
+ struct _fpx_sw_bytes sw_reserved; /* represents the extended
+ * state information */
+ };
};
#ifdef __KERNEL__
@@ -161,7 +213,14 @@
unsigned long trapno;
unsigned long oldmask;
unsigned long cr2;
- struct _fpstate __user *fpstate; /* zero when no FPU context */
+
+ /* fpstate is really (struct _fpstate *) or (struct _xstate *)
+ * depending on the FP_XSTATE_MAGIC1 encoded in the SW reserved
+ * bytes of (struct _fpstate) and FP_XSTATE_MAGIC2 present at the end
+ * of extended memory layout. See comments at the defintion of
+ * (struct _fpx_sw_bytes)
+ */
+ void __user *fpstate; /* zero when no FPU/extended context */
unsigned long reserved1[8];
};
#else /* __KERNEL__ */
@@ -202,4 +261,22 @@
#endif /* !__i386__ */
+struct _xsave_hdr {
+ u64 xstate_bv;
+ u64 reserved1[2];
+ u64 reserved2[5];
+};
+
+/*
+ * Extended state pointed by the fpstate pointer in the sigcontext.
+ * In addition to the fpstate, information encoded in the xstate_hdr
+ * indicates the presence of other extended state information
+ * supported by the processor and OS.
+ */
+struct _xstate {
+ struct _fpstate fpstate;
+ struct _xsave_hdr xstate_hdr;
+ /* new processor state extensions go here */
+};
+
#endif /* ASM_X86__SIGCONTEXT_H */
Index: tip-0728/include/asm-x86/sigcontext32.h
===================================================================
--- tip-0728.orig/include/asm-x86/sigcontext32.h 2008-07-28 18:42:45.000000000 -0700
+++ tip-0728/include/asm-x86/sigcontext32.h 2008-07-28 18:43:47.000000000 -0700
@@ -40,7 +40,11 @@
__u32 reserved;
struct _fpxreg _fxsr_st[8];
struct _xmmreg _xmm[8]; /* It's actually 16 */
- __u32 padding[56];
+ __u32 padding[44];
+ union {
+ __u32 padding2[12];
+ struct _fpx_sw_bytes sw_reserved;
+ };
};
struct sigcontext_ia32 {
Index: tip-0728/include/asm-x86/processor.h
===================================================================
--- tip-0728.orig/include/asm-x86/processor.h 2008-07-28 18:42:45.000000000 -0700
+++ tip-0728/include/asm-x86/processor.h 2008-07-28 18:43:47.000000000 -0700
@@ -327,7 +327,12 @@
/* 16*16 bytes for each XMM-reg = 256 bytes: */
u32 xmm_space[64];
- u32 padding[24];
+ u32 padding[12];
+
+ union {
+ u32 padding1[12];
+ u32 sw_reserved[12];
+ };
} __attribute__((aligned(16)));
--
^ permalink raw reply [flat|nested] 37+ messages in thread
* [patch 8/9] x86, xsave: save/restore the extended state context in sigframe
2008-07-29 17:29 [patch 0/9] x86, xsave: xsave/xrstor support Suresh Siddha
` (6 preceding siblings ...)
2008-07-29 17:29 ` [patch 7/9] x86, xsave: struct _fpstate extensions to include extended state information Suresh Siddha
@ 2008-07-29 17:29 ` Suresh Siddha
2008-07-29 17:29 ` [patch 9/9] x86, xsave: update xsave header bits during ptrace fpregs set Suresh Siddha
2008-07-29 23:09 ` [patch 0/9] x86, xsave: xsave/xrstor support H. Peter Anvin
9 siblings, 0 replies; 37+ messages in thread
From: Suresh Siddha @ 2008-07-29 17:29 UTC (permalink / raw)
To: mingo, hpa, tglx, torvalds, akpm, arjan, roland, drepper, mikpe,
chrisw, andi
Cc: linux-kernel, suresh.b.siddha
[-- Attachment #1: extended_fpstate_in_sigcontext.patch --]
[-- Type: text/plain, Size: 15588 bytes --]
On cpu's supporting xsave/xrstor, fpstate pointer in the sigcontext, will
include the extended state information along with fpstate information. Presence
of extended state information is indicated by the presence
of FP_XSTATE_MAGIC1 at fpstate.sw_reserved.magic1 and FP_XSTATE_MAGIC2
at fpstate + (fpstate.sw_reserved.extended_size - FP_XSTATE_MAGIC2_SIZE).
Extended feature bit mask that is saved in the memory layout is represented
by the fpstate.sw_reserved.xstate_bv
For RT signal frames, UC_FP_XSTATE in the uc_flags also indicate the
presence of extended state information in the sigcontext's fpstate
pointer.
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---
Index: tip-0728/arch/x86/kernel/xsave.c
===================================================================
--- tip-0728.orig/arch/x86/kernel/xsave.c 2008-07-28 18:50:02.000000000 -0700
+++ tip-0728/arch/x86/kernel/xsave.c 2008-07-28 18:51:24.000000000 -0700
@@ -6,12 +6,68 @@
#include <linux/bootmem.h>
#include <linux/compat.h>
#include <asm/i387.h>
+#ifdef CONFIG_IA32_EMULATION
+#include <asm/sigcontext32.h>
+#endif
/*
* Supported feature mask by the CPU and the kernel.
*/
unsigned int pcntxt_hmask, pcntxt_lmask;
+struct _fpx_sw_bytes fx_sw_reserved;
+#ifdef CONFIG_IA32_EMULATION
+struct _fpx_sw_bytes fx_sw_reserved_ia32;
+#endif
+
+/*
+ * Check for the presence of extended state information in the
+ * user fpstate pointer in the sigcontext.
+ */
+int check_for_xstate(struct i387_fxsave_struct __user *buf,
+ void __user *fpstate,
+ struct _fpx_sw_bytes *fx_sw_user)
+{
+ int min_xstate_size = sizeof(struct i387_fxsave_struct) +
+ sizeof(struct xsave_hdr_struct);
+ unsigned int magic2;
+ int err;
+
+ err = __copy_from_user(fx_sw_user, &buf->sw_reserved[0],
+ sizeof(struct _fpx_sw_bytes));
+
+ if (err)
+ return err;
+
+ /*
+ * First Magic check failed.
+ */
+ if (fx_sw_user->magic1 != FP_XSTATE_MAGIC1)
+ return -1;
+
+ /*
+ * Check for error scenarios.
+ */
+ if (fx_sw_user->xstate_size < min_xstate_size ||
+ fx_sw_user->xstate_size > xstate_size ||
+ fx_sw_user->xstate_size > fx_sw_user->extended_size)
+ return -1;
+
+ err = __get_user(magic2, (__u32 *) (((void *)fpstate) +
+ fx_sw_user->extended_size -
+ FP_XSTATE_MAGIC2_SIZE));
+ /*
+ * Check for the presence of second magic word at the end of memory
+ * layout. This detects the case where the user just copied the legacy
+ * fpstate layout with out copying the extended state information
+ * in the memory layout.
+ */
+ if (err || magic2 != FP_XSTATE_MAGIC2)
+ return -1;
+
+ return 0;
+}
+
#ifdef CONFIG_X86_64
/*
* Signal frame handlers.
@@ -28,15 +84,18 @@
BUILD_BUG_ON(sizeof(struct user_i387_struct) !=
sizeof(tsk->thread.xstate->fxsave));
- if ((unsigned long)buf % 16)
+ if ((unsigned long)buf % 64)
printk("save_i387_xstate: bad fpstate %p\n", buf);
if (!used_math())
return 0;
clear_used_math(); /* trigger finit */
if (task_thread_info(tsk)->status & TS_USEDFPU) {
- err = save_i387_checking((struct i387_fxsave_struct __user *)
- buf);
+ if (task_thread_info(tsk)->status & TS_XSAVE)
+ err = xsave_user(buf);
+ else
+ err = fxsave_user(buf);
+
if (err)
return err;
task_thread_info(tsk)->status &= ~TS_USEDFPU;
@@ -46,23 +105,77 @@
xstate_size))
return -1;
}
+
+ if (task_thread_info(tsk)->status & TS_XSAVE) {
+ struct _fpstate __user *fx = buf;
+
+ err = __copy_to_user(&fx->sw_reserved, &fx_sw_reserved,
+ sizeof(struct _fpx_sw_bytes));
+
+ err |= __put_user(FP_XSTATE_MAGIC2,
+ (__u32 __user *) (buf + sig_xstate_size
+ - FP_XSTATE_MAGIC2_SIZE));
+ }
+
return 1;
}
/*
+ * Restore the extended state if present. Otherwise, restore the FP/SSE
+ * state.
+ */
+int restore_user_xstate(void __user *buf)
+{
+ struct _fpx_sw_bytes fx_sw_user;
+ unsigned int lmask, hmask;
+ int err;
+
+ if (((unsigned long)buf % 64) ||
+ check_for_xstate(buf, buf, &fx_sw_user))
+ goto fx_only;
+
+ lmask = fx_sw_user.xstate_bv;
+ hmask = fx_sw_user.xstate_bv >> 32;
+
+ /*
+ * restore the state passed by the user.
+ */
+ err = xrestore_user(buf, lmask, hmask);
+ if (err)
+ return err;
+
+ /*
+ * init the state skipped by the user.
+ */
+ lmask = pcntxt_lmask & ~lmask;
+ hmask = pcntxt_hmask & ~hmask;
+
+ xrstor_state(init_xstate_buf, lmask, hmask);
+
+ return 0;
+
+fx_only:
+ /*
+ * couldn't find the extended state information in the
+ * memory layout. Restore just the FP/SSE and init all
+ * the other extended state.
+ */
+ xrstor_state(init_xstate_buf, pcntxt_lmask & ~XSTATE_FPSSE,
+ pcntxt_hmask);
+ return fxrstor_checking((__force struct i387_fxsave_struct *)buf);
+}
+
+/*
* This restores directly out of user space. Exceptions are handled.
*/
int restore_i387_xstate(void __user *buf)
{
struct task_struct *tsk = current;
- int err;
+ int err = 0;
if (!buf) {
- if (used_math()) {
- clear_fpu(tsk);
- clear_used_math();
- }
-
+ if (used_math())
+ goto clear;
return 0;
} else
if (!access_ok(VERIFY_READ, buf, sig_xstate_size))
@@ -78,12 +191,17 @@
clts();
task_thread_info(current)->status |= TS_USEDFPU;
}
- err = fxrstor_checking((__force struct i387_fxsave_struct *)buf);
+ if (task_thread_info(tsk)->status & TS_XSAVE)
+ err = restore_user_xstate(buf);
+ else
+ err = fxrstor_checking((__force struct i387_fxsave_struct *)
+ buf);
if (unlikely(err)) {
/*
* Encountered an error while doing the restore from the
* user buffer, clear the fpu state.
*/
+clear:
clear_fpu(tsk);
clear_used_math();
}
@@ -92,6 +210,38 @@
#endif
/*
+ * Prepare the SW reserved portion of the fxsave memory layout, indicating
+ * the presence of the extended state information in the memory layout
+ * pointed by the fpstate pointer in the sigcontext.
+ * This will be saved when ever the FP and extended state context is
+ * saved on the user stack during the signal handler delivery to the user.
+ */
+void prepare_fx_sw_frame(void)
+{
+ int size_extended = (xstate_size - sizeof(struct i387_fxsave_struct)) +
+ FP_XSTATE_MAGIC2_SIZE;
+
+ sig_xstate_size = sizeof(struct _fpstate) + size_extended;
+
+#ifdef CONFIG_IA32_EMULATION
+ sig_xstate_ia32_size = sizeof(struct _fpstate_ia32) + size_extended;
+#endif
+
+ memset(&fx_sw_reserved, 0, sizeof(fx_sw_reserved));
+
+ fx_sw_reserved.magic1 = FP_XSTATE_MAGIC1;
+ fx_sw_reserved.extended_size = sig_xstate_size;
+ fx_sw_reserved.xstate_bv = pcntxt_lmask |
+ (((u64) (pcntxt_hmask)) << 32);
+ fx_sw_reserved.xstate_size = xstate_size;
+#ifdef CONFIG_IA32_EMULATION
+ memcpy(&fx_sw_reserved_ia32, &fx_sw_reserved,
+ sizeof(struct _fpx_sw_bytes));
+ fx_sw_reserved_ia32.extended_size = sig_xstate_ia32_size;
+#endif
+}
+
+/*
* Represents init state for the supported extended state.
*/
struct xsave_struct *init_xstate_buf;
@@ -162,6 +312,8 @@
xstate_size = ebx;
+ prepare_fx_sw_frame();
+
setup_xstate_init();
printk(KERN_INFO "xsave/xrstor: enabled xstate_bv %Lx, cntxt size %x\n",
Index: tip-0728/arch/x86/kernel/i387.c
===================================================================
--- tip-0728.orig/arch/x86/kernel/i387.c 2008-07-28 18:50:02.000000000 -0700
+++ tip-0728/arch/x86/kernel/i387.c 2008-07-28 18:50:08.000000000 -0700
@@ -26,6 +26,7 @@
# define _fpstate_ia32 _fpstate
# define _xstate_ia32 _xstate
# define sig_xstate_ia32_size sig_xstate_size
+# define fx_sw_reserved_ia32 fx_sw_reserved
# define user_i387_ia32_struct user_i387_struct
# define user32_fxsr_struct user_fxsr_struct
#endif
@@ -447,12 +448,30 @@
if (err)
return -1;
- if (__copy_to_user(&buf->_fxsr_env[0], fx,
- sizeof(struct i387_fxsave_struct)))
+ if (__copy_to_user(&buf->_fxsr_env[0], fx, xstate_size))
return -1;
return 1;
}
+static int save_i387_xsave(void __user *buf)
+{
+ struct _fpstate_ia32 __user *fx = buf;
+ int err = 0;
+
+ if (save_i387_fxsave(fx) < 0)
+ return -1;
+
+ err = __copy_to_user(&fx->sw_reserved, &fx_sw_reserved_ia32,
+ sizeof(struct _fpx_sw_bytes));
+ err |= __put_user(FP_XSTATE_MAGIC2,
+ (__u32 __user *) (buf + sig_xstate_ia32_size
+ - FP_XSTATE_MAGIC2_SIZE));
+ if (err)
+ return -1;
+
+ return 1;
+}
+
int save_i387_xstate_ia32(void __user *buf)
{
struct _fpstate_ia32 __user *fp = (struct _fpstate_ia32 __user *) buf;
@@ -477,6 +496,8 @@
unlazy_fpu(tsk);
+ if (cpu_has_xsave)
+ return save_i387_xsave(fp);
if (cpu_has_fxsr)
return save_i387_fxsave(fp);
else
@@ -491,14 +512,15 @@
sizeof(struct i387_fsave_struct));
}
-static int restore_i387_fxsave(struct _fpstate_ia32 __user *buf)
+static int restore_i387_fxsave(struct _fpstate_ia32 __user *buf,
+ unsigned int size)
{
struct task_struct *tsk = current;
struct user_i387_ia32_struct env;
int err;
err = __copy_from_user(&tsk->thread.xstate->fxsave, &buf->_fxsr_env[0],
- sizeof(struct i387_fxsave_struct));
+ size);
/* mxcsr reserved bits must be masked to zero for security reasons */
tsk->thread.xstate->fxsave.mxcsr &= mxcsr_feature_mask;
if (err || __copy_from_user(&env, buf, sizeof(env)))
@@ -508,6 +530,51 @@
return 0;
}
+static int restore_i387_xsave(void __user *buf)
+{
+ struct _fpx_sw_bytes fx_sw_user;
+ struct _fpstate_ia32 __user *fx_user =
+ ((struct _fpstate_ia32 __user *) buf);
+ struct i387_fxsave_struct __user *fx =
+ (struct i387_fxsave_struct __user *) &fx_user->_fxsr_env[0];
+ struct xsave_hdr_struct *xsave_hdr =
+ ¤t->thread.xstate->xsave.xsave_hdr;
+ unsigned int lmask, hmask;
+ int err;
+
+ if (check_for_xstate(fx, buf, &fx_sw_user))
+ goto fx_only;
+
+ lmask = fx_sw_user.xstate_bv;
+ hmask = fx_sw_user.xstate_bv >> 32;
+
+ err = restore_i387_fxsave(buf, fx_sw_user.xstate_size);
+
+ xsave_hdr->xstate_bv &= (pcntxt_lmask | (((u64) pcntxt_hmask) << 32));
+ /*
+ * These bits must be zero.
+ */
+ xsave_hdr->reserved1[0] = xsave_hdr->reserved1[1] = 0;
+
+ /*
+ * Init the state that is not present in the memory layout
+ * and enabled by the OS.
+ */
+ lmask = ~(pcntxt_lmask & ~lmask);
+ hmask = ~(pcntxt_hmask & ~hmask);
+ xsave_hdr->xstate_bv &= (lmask | (((u64) hmask) << 32));
+
+ return err;
+fx_only:
+ /*
+ * Couldn't find the extended state information in the memory
+ * layout. Restore the FP/SSE and init the other extended state
+ * enabled by the OS.
+ */
+ xsave_hdr->xstate_bv = XSTATE_FPSSE;
+ return restore_i387_fxsave(buf, sizeof(struct i387_fxsave_struct));
+}
+
int restore_i387_xstate_ia32(void __user *buf)
{
int err;
@@ -535,8 +602,11 @@
}
if (HAVE_HWFP) {
- if (cpu_has_fxsr)
- err = restore_i387_fxsave(fp);
+ if (cpu_has_xsave)
+ err = restore_i387_xsave(buf);
+ else if (cpu_has_fxsr)
+ err = restore_i387_fxsave(fp, sizeof(struct
+ i387_fxsave_struct));
else
err = restore_i387_fsave(fp);
} else {
Index: tip-0728/arch/x86/kernel/signal_64.c
===================================================================
--- tip-0728.orig/arch/x86/kernel/signal_64.c 2008-07-28 18:50:02.000000000 -0700
+++ tip-0728/arch/x86/kernel/signal_64.c 2008-07-28 18:50:08.000000000 -0700
@@ -195,7 +195,7 @@
sp = current->sas_ss_sp + current->sas_ss_size;
}
- return (void __user *)round_down(sp - size, 16);
+ return (void __user *)round_down(sp - size, 64);
}
static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
@@ -229,7 +229,10 @@
}
/* Create the ucontext. */
- err |= __put_user(0, &frame->uc.uc_flags);
+ if (cpu_has_xsave)
+ err |= __put_user(UC_FP_XSTATE, &frame->uc.uc_flags);
+ else
+ err |= __put_user(0, &frame->uc.uc_flags);
err |= __put_user(0, &frame->uc.uc_link);
err |= __put_user(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
err |= __put_user(sas_ss_flags(regs->sp),
Index: tip-0728/include/asm-x86/i387.h
===================================================================
--- tip-0728.orig/include/asm-x86/i387.h 2008-07-28 18:50:02.000000000 -0700
+++ tip-0728/include/asm-x86/i387.h 2008-07-28 18:50:08.000000000 -0700
@@ -32,8 +32,10 @@
extern user_regset_get_fn fpregs_get, xfpregs_get, fpregs_soft_get;
extern user_regset_set_fn fpregs_set, xfpregs_set, fpregs_soft_set;
+extern struct _fpx_sw_bytes fx_sw_reserved;
#ifdef CONFIG_IA32_EMULATION
extern unsigned int sig_xstate_ia32_size;
+extern struct _fpx_sw_bytes fx_sw_reserved_ia32;
struct _fpstate_ia32;
struct _xstate_ia32;
extern int save_i387_xstate_ia32(void __user *buf);
@@ -105,7 +107,7 @@
X86_FEATURE_FXSAVE_LEAK);
}
-static inline int save_i387_checking(struct i387_fxsave_struct __user *fx)
+static inline int fxsave_user(struct i387_fxsave_struct __user *fx)
{
int err;
Index: tip-0728/include/asm-x86/xsave.h
===================================================================
--- tip-0728.orig/include/asm-x86/xsave.h 2008-07-28 18:50:02.000000000 -0700
+++ tip-0728/include/asm-x86/xsave.h 2008-07-28 18:50:08.000000000 -0700
@@ -29,6 +29,9 @@
extern void xsave_cntxt_init(void);
extern void xsave_init(void);
extern int init_fpu(struct task_struct *child);
+extern int check_for_xstate(struct i387_fxsave_struct __user *buf,
+ void __user *fpstate,
+ struct _fpx_sw_bytes *sw);
static inline int xrstor_checking(struct xsave_struct *fx)
{
@@ -48,7 +51,7 @@
return err;
}
-static inline int xsave_check(struct xsave_struct __user *buf)
+static inline int xsave_user(struct xsave_struct __user *buf)
{
int err;
__asm__ __volatile__("1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
Index: tip-0728/include/asm-x86/ucontext.h
===================================================================
--- tip-0728.orig/include/asm-x86/ucontext.h 2008-07-28 18:49:10.000000000 -0700
+++ tip-0728/include/asm-x86/ucontext.h 2008-07-28 18:50:08.000000000 -0700
@@ -1,6 +1,12 @@
#ifndef ASM_X86__UCONTEXT_H
#define ASM_X86__UCONTEXT_H
+#define UC_FP_XSTATE 0x1 /* indicates the presence of extended state
+ * information in the memory layout pointed
+ * by the fpstate pointer in the ucontext's
+ * sigcontext struct (uc_mcontext).
+ */
+
struct ucontext {
unsigned long uc_flags;
struct ucontext *uc_link;
Index: tip-0728/arch/x86/ia32/ia32_signal.c
===================================================================
--- tip-0728.orig/arch/x86/ia32/ia32_signal.c 2008-07-28 18:50:02.000000000 -0700
+++ tip-0728/arch/x86/ia32/ia32_signal.c 2008-07-28 18:50:08.000000000 -0700
@@ -544,7 +544,10 @@
goto give_sigsegv;
/* Create the ucontext. */
- err |= __put_user(0, &frame->uc.uc_flags);
+ if (cpu_has_xsave)
+ err |= __put_user(UC_FP_XSTATE, &frame->uc.uc_flags);
+ else
+ err |= __put_user(0, &frame->uc.uc_flags);
err |= __put_user(0, &frame->uc.uc_link);
err |= __put_user(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
err |= __put_user(sas_ss_flags(regs->sp),
Index: tip-0728/arch/x86/kernel/signal_32.c
===================================================================
--- tip-0728.orig/arch/x86/kernel/signal_32.c 2008-07-28 18:50:02.000000000 -0700
+++ tip-0728/arch/x86/kernel/signal_32.c 2008-07-28 18:50:08.000000000 -0700
@@ -443,7 +443,10 @@
goto give_sigsegv;
/* Create the ucontext. */
- err |= __put_user(0, &frame->uc.uc_flags);
+ if (cpu_has_xsave)
+ err |= __put_user(UC_FP_XSTATE, &frame->uc.uc_flags);
+ else
+ err |= __put_user(0, &frame->uc.uc_flags);
err |= __put_user(0, &frame->uc.uc_link);
err |= __put_user(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
err |= __put_user(sas_ss_flags(regs->sp),
--
^ permalink raw reply [flat|nested] 37+ messages in thread
* [patch 9/9] x86, xsave: update xsave header bits during ptrace fpregs set
2008-07-29 17:29 [patch 0/9] x86, xsave: xsave/xrstor support Suresh Siddha
` (7 preceding siblings ...)
2008-07-29 17:29 ` [patch 8/9] x86, xsave: save/restore the extended state context in sigframe Suresh Siddha
@ 2008-07-29 17:29 ` Suresh Siddha
2008-07-29 23:09 ` [patch 0/9] x86, xsave: xsave/xrstor support H. Peter Anvin
9 siblings, 0 replies; 37+ messages in thread
From: Suresh Siddha @ 2008-07-29 17:29 UTC (permalink / raw)
To: mingo, hpa, tglx, torvalds, akpm, arjan, roland, drepper, mikpe,
chrisw, andi
Cc: linux-kernel, suresh.b.siddha
[-- Attachment #1: fix_ptrace_set_fpregs.patch --]
[-- Type: text/plain, Size: 1070 bytes --]
FP/SSE bits may be zero in the xsave header(representing the init state).
Update these bits during the ptrace fpregs set operation, to indicate the
non-init state.
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---
Index: tip-0728/arch/x86/kernel/i387.c
===================================================================
--- tip-0728.orig/arch/x86/kernel/i387.c 2008-07-28 18:50:08.000000000 -0700
+++ tip-0728/arch/x86/kernel/i387.c 2008-07-28 18:51:29.000000000 -0700
@@ -214,6 +214,13 @@
*/
target->thread.xstate->fxsave.mxcsr &= mxcsr_feature_mask;
+ /*
+ * update the header bits in the xsave header, indicating the
+ * presence of FP and SSE state.
+ */
+ if (cpu_has_xsave)
+ target->thread.xstate->xsave.xsave_hdr.xstate_bv |= XSTATE_FPSSE;
+
return ret;
}
@@ -414,6 +421,12 @@
if (!ret)
convert_to_fxsr(target, &env);
+ /*
+ * update the header bit in the xsave header, indicating the
+ * presence of FP.
+ */
+ if (cpu_has_xsave)
+ target->thread.xstate->xsave.xsave_hdr.xstate_bv |= XSTATE_FP;
return ret;
}
--
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-07-29 17:29 [patch 0/9] x86, xsave: xsave/xrstor support Suresh Siddha
` (8 preceding siblings ...)
2008-07-29 17:29 ` [patch 9/9] x86, xsave: update xsave header bits during ptrace fpregs set Suresh Siddha
@ 2008-07-29 23:09 ` H. Peter Anvin
2008-07-29 23:29 ` Suresh Siddha
9 siblings, 1 reply; 37+ messages in thread
From: H. Peter Anvin @ 2008-07-29 23:09 UTC (permalink / raw)
To: Suresh Siddha
Cc: mingo, tglx, torvalds, akpm, arjan, roland, drepper, mikpe,
chrisw, andi, linux-kernel
Suresh Siddha wrote:
> This patchset adds the support for xsave/xrstor infrastructure for x86.
> xsave/xrstor manages the existing and future processor extended states in x86
> architecutre.
>
> More info on xsave/xrstor can be found in the Intel SDM's located at
> http://www.intel.com/products/processor/manuals/index.htm
>
> The layout of the xsave/xrstor area extends from the 512-byte FXSAVE/FXRSTOR
> layout. xsave/xrstor area layout consists of:
>
> - fxsave/fxrstor area (512 bytes)
> - xsave header area (64 bytes)
> - set of save areas, each corresponding to a processor extended state
>
> The number of save areas, the offset and the size of each save area is
> enumerated by CPUID leaf function 0xd.
>
> This patch includes the basic xsave/xrstor infrastructure(supporting FP/SSE),
> which includes:
> - context switch support, extending traditional lazy restore mechanism
> - signal handling support, extending(using the software reserved bytes
> 464..511 in the current 512byte layout of fxsave frame) the memory
> layout pointed out by the fpstate pointer in the sigcontext
>
> More details in the patches to follow.
>
> Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Applied as tip:x86/xsave.
I should warn I had to do quite a bit of manual fixup in order to
disentangle it from other changes in -tip, so please test it out; I
compile-tested it but for obvious reasons can't do more than that at the
moment.
-hpa
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-07-29 23:09 ` [patch 0/9] x86, xsave: xsave/xrstor support H. Peter Anvin
@ 2008-07-29 23:29 ` Suresh Siddha
2008-07-29 23:43 ` H. Peter Anvin
0 siblings, 1 reply; 37+ messages in thread
From: Suresh Siddha @ 2008-07-29 23:29 UTC (permalink / raw)
To: H. Peter Anvin
Cc: Siddha, Suresh B, mingo@elte.hu, tglx@linutronix.de,
torvalds@linux-foundation.org, akpm@linux-foundation.org,
arjan@linux.intel.com, roland@redhat.com, drepper@redhat.com,
mikpe@it.uu.se, chrisw@sous-sol.org, andi@firstfloor.org,
linux-kernel@vger.kernel.org
On Tue, Jul 29, 2008 at 04:09:12PM -0700, H. Peter Anvin wrote:
> Applied as tip:x86/xsave.
>
> I should warn I had to do quite a bit of manual fixup in order to
> disentangle it from other changes in -tip, so please test it out; I
> compile-tested it but for obvious reasons can't do more than that at the
> moment.
hpa, these patches just apply fine to tip/master. Can you please arrange
the tip/x86/xsave tree accordingly? or do I need to do something else
to smooth this process?
thanks,
suresh
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-07-29 23:29 ` Suresh Siddha
@ 2008-07-29 23:43 ` H. Peter Anvin
2008-07-30 10:03 ` Ingo Molnar
0 siblings, 1 reply; 37+ messages in thread
From: H. Peter Anvin @ 2008-07-29 23:43 UTC (permalink / raw)
To: Suresh Siddha
Cc: mingo@elte.hu, tglx@linutronix.de, torvalds@linux-foundation.org,
akpm@linux-foundation.org, arjan@linux.intel.com,
roland@redhat.com, drepper@redhat.com, mikpe@it.uu.se,
chrisw@sous-sol.org, andi@firstfloor.org,
linux-kernel@vger.kernel.org
Suresh Siddha wrote:
> On Tue, Jul 29, 2008 at 04:09:12PM -0700, H. Peter Anvin wrote:
>> Applied as tip:x86/xsave.
>>
>> I should warn I had to do quite a bit of manual fixup in order to
>> disentangle it from other changes in -tip, so please test it out; I
>> compile-tested it but for obvious reasons can't do more than that at the
>> moment.
>
> hpa, these patches just apply fine to tip/master. Can you please arrange
> the tip/x86/xsave tree accordingly? or do I need to do something else
> to smooth this process?
This is awkward, since that means this is "derived topic". Most of the
changes are orthogonal and relatively trivial to fix up at merge time,
so I would prefer to keep them separate.
-hpa
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-07-29 23:43 ` H. Peter Anvin
@ 2008-07-30 10:03 ` Ingo Molnar
2008-07-30 16:31 ` H. Peter Anvin
2008-07-30 18:25 ` Ingo Molnar
0 siblings, 2 replies; 37+ messages in thread
From: Ingo Molnar @ 2008-07-30 10:03 UTC (permalink / raw)
To: H. Peter Anvin
Cc: Suresh Siddha, tglx@linutronix.de, torvalds@linux-foundation.org,
akpm@linux-foundation.org, arjan@linux.intel.com,
roland@redhat.com, drepper@redhat.com, mikpe@it.uu.se,
chrisw@sous-sol.org, andi@firstfloor.org,
linux-kernel@vger.kernel.org
* H. Peter Anvin <hpa@zytor.com> wrote:
>> hpa, these patches just apply fine to tip/master. Can you please
>> arrange the tip/x86/xsave tree accordingly? or do I need to do
>> something else to smooth this process?
>
> This is awkward, since that means this is "derived topic". Most of
> the changes are orthogonal and relatively trivial to fix up at merge
> time, so I would prefer to keep them separate.
Well, in this case the conflicts seem to be quite heavy, so i'd suggest
to use the method we have used for x86/x2apic and for xen-64bit:
Merge the affected topics into tip/x86/core. Then merge x86/core into
x86/xsave, and put the xsave patches ontop of that base.
This way x86/xsave is a 'derived' topic and optional until it's proven,
but one that is still mergable once all the dependent topics go
upstream. We'd only have to rebase it in the (unlikely) event of there
being some major problem with any of the topics merged into x86/core.
ok?
Ingo
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-07-30 10:03 ` Ingo Molnar
@ 2008-07-30 16:31 ` H. Peter Anvin
2008-07-30 17:08 ` Suresh Siddha
2008-07-30 18:25 ` Ingo Molnar
1 sibling, 1 reply; 37+ messages in thread
From: H. Peter Anvin @ 2008-07-30 16:31 UTC (permalink / raw)
To: Ingo Molnar
Cc: Suresh Siddha, tglx@linutronix.de, torvalds@linux-foundation.org,
akpm@linux-foundation.org, arjan@linux.intel.com,
roland@redhat.com, drepper@redhat.com, mikpe@it.uu.se,
chrisw@sous-sol.org, andi@firstfloor.org,
linux-kernel@vger.kernel.org
Ingo Molnar wrote:
> * H. Peter Anvin <hpa@zytor.com> wrote:
>
>>> hpa, these patches just apply fine to tip/master. Can you please
>>> arrange the tip/x86/xsave tree accordingly? or do I need to do
>>> something else to smooth this process?
>> This is awkward, since that means this is "derived topic". Most of
>> the changes are orthogonal and relatively trivial to fix up at merge
>> time, so I would prefer to keep them separate.
>
> Well, in this case the conflicts seem to be quite heavy, so i'd suggest
> to use the method we have used for x86/x2apic and for xen-64bit:
>
> Merge the affected topics into tip/x86/core. Then merge x86/core into
> x86/xsave, and put the xsave patches ontop of that base.
>
> This way x86/xsave is a 'derived' topic and optional until it's proven,
> but one that is still mergable once all the dependent topics go
> upstream. We'd only have to rebase it in the (unlikely) event of there
> being some major problem with any of the topics merged into x86/core.
>
> ok?
It somewhat concerns me, because one of the conflicts is generated by
collision with x2apic. The rest of them I don't think are too problematic.
Most of the conflicts are of the type "orthogonal transformations to the
same chunk of code", which doesn't make them less annoying.
-hpa
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-07-30 16:31 ` H. Peter Anvin
@ 2008-07-30 17:08 ` Suresh Siddha
2008-07-30 17:14 ` H. Peter Anvin
0 siblings, 1 reply; 37+ messages in thread
From: Suresh Siddha @ 2008-07-30 17:08 UTC (permalink / raw)
To: H. Peter Anvin
Cc: Ingo Molnar, Siddha, Suresh B, tglx@linutronix.de,
torvalds@linux-foundation.org, akpm@linux-foundation.org,
arjan@linux.intel.com, roland@redhat.com, drepper@redhat.com,
mikpe@it.uu.se, chrisw@sous-sol.org, andi@firstfloor.org,
linux-kernel@vger.kernel.org
On Wed, Jul 30, 2008 at 09:31:41AM -0700, H. Peter Anvin wrote:
> Ingo Molnar wrote:
> > * H. Peter Anvin <hpa@zytor.com> wrote:
> >
> >>> hpa, these patches just apply fine to tip/master. Can you please
> >>> arrange the tip/x86/xsave tree accordingly? or do I need to do
> >>> something else to smooth this process?
> >> This is awkward, since that means this is "derived topic". Most of
> >> the changes are orthogonal and relatively trivial to fix up at merge
> >> time, so I would prefer to keep them separate.
> >
> > Well, in this case the conflicts seem to be quite heavy, so i'd suggest
> > to use the method we have used for x86/x2apic and for xen-64bit:
> >
> > Merge the affected topics into tip/x86/core. Then merge x86/core into
> > x86/xsave, and put the xsave patches ontop of that base.
> >
> > This way x86/xsave is a 'derived' topic and optional until it's proven,
> > but one that is still mergable once all the dependent topics go
> > upstream. We'd only have to rebase it in the (unlikely) event of there
> > being some major problem with any of the topics merged into x86/core.
> >
> > ok?
>
> It somewhat concerns me, because one of the conflicts is generated by
> collision with x2apic. The rest of them I don't think are too problematic.
hpa, confilicts with x2apic branch are very small and related to cpuid bits.
commit 04df16d2465cbb59b84c9c57ad865dbbeebadad8
Author: Suresh Siddha <suresh.b.siddha@intel.com>
Date: Tue Jul 29 10:29:18 2008 -0700
x86, xsave: xsave cpuid feature bits
Add xsave CPU feature bits.
and
commit 32e1d0a0651004f5fe47f85a2a5c725ad579a90c
Author: Suresh Siddha <suresh.b.siddha@intel.com>
Date: Thu Jul 10 11:16:50 2008 -0700
x64, x2apic/intr-remap: cpuid bits for x2apic feature
cpuid feature for x2apic.
Both of these patches are straight forward, simple and can be moved
to x86/core(?) now, if that helps.
thanks,
suresh
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-07-30 17:08 ` Suresh Siddha
@ 2008-07-30 17:14 ` H. Peter Anvin
0 siblings, 0 replies; 37+ messages in thread
From: H. Peter Anvin @ 2008-07-30 17:14 UTC (permalink / raw)
To: Suresh Siddha
Cc: Ingo Molnar, tglx@linutronix.de, torvalds@linux-foundation.org,
akpm@linux-foundation.org, arjan@linux.intel.com,
roland@redhat.com, drepper@redhat.com, mikpe@it.uu.se,
chrisw@sous-sol.org, andi@firstfloor.org,
linux-kernel@vger.kernel.org
Suresh Siddha wrote:
>> It somewhat concerns me, because one of the conflicts is generated by
>> collision with x2apic. The rest of them I don't think are too problematic.
>
> hpa, confilicts with x2apic branch are very small and related to cpuid bits.
>
> commit 04df16d2465cbb59b84c9c57ad865dbbeebadad8
> Author: Suresh Siddha <suresh.b.siddha@intel.com>
> Date: Tue Jul 29 10:29:18 2008 -0700
>
> x86, xsave: xsave cpuid feature bits
>
> Add xsave CPU feature bits.
>
> and
>
> commit 32e1d0a0651004f5fe47f85a2a5c725ad579a90c
> Author: Suresh Siddha <suresh.b.siddha@intel.com>
> Date: Thu Jul 10 11:16:50 2008 -0700
>
> x64, x2apic/intr-remap: cpuid bits for x2apic feature
>
> cpuid feature for x2apic.
>
> Both of these patches are straight forward, simple and can be moved
> to x86/core(?) now, if that helps.
This is true. Cherry-picking those to the x86/core branch is probably
the easiest, even if that means they're duplicated in the x2apic branch
(I presume we don't want to rebase x2apic).
-hpa
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-07-30 10:03 ` Ingo Molnar
2008-07-30 16:31 ` H. Peter Anvin
@ 2008-07-30 18:25 ` Ingo Molnar
2008-07-30 21:46 ` Suresh Siddha
2008-07-30 23:41 ` Suresh Siddha
1 sibling, 2 replies; 37+ messages in thread
From: Ingo Molnar @ 2008-07-30 18:25 UTC (permalink / raw)
To: H. Peter Anvin
Cc: Suresh Siddha, tglx@linutronix.de, torvalds@linux-foundation.org,
akpm@linux-foundation.org, arjan@linux.intel.com,
roland@redhat.com, drepper@redhat.com, mikpe@it.uu.se,
chrisw@sous-sol.org, andi@firstfloor.org,
linux-kernel@vger.kernel.org
* Ingo Molnar <mingo@elte.hu> wrote:
> Well, in this case the conflicts seem to be quite heavy, so i'd
> suggest to use the method we have used for x86/x2apic and for
> xen-64bit:
>
> Merge the affected topics into tip/x86/core. Then merge x86/core into
> x86/xsave, and put the xsave patches ontop of that base.
>
> This way x86/xsave is a 'derived' topic and optional until it's
> proven, but one that is still mergable once all the dependent topics
> go upstream. We'd only have to rebase it in the (unlikely) event of
> there being some major problem with any of the topics merged into
> x86/core.
I've restructured tip/x86/xsave to be like this, and it can now be
merged into tip/master without conficts.
I briefly merged it into tip/master to test it, but after about 10
randconfig iterations it ran into a spontaneous reboot crash. There's
nothing in the log, the box (an Athlon64 X2) just reboots spontaneously.
Removing the x86/xsave changes makes the system boot up fine.
I've pushed out the tree i tested into the tip/tmp.x86/xsave.broken
branch. The bad config is:
http://redhat.com/~mingo/misc/config-Wed_Jul_30_20_09_12_CEST_2008.bad
Two crashlogs are here:
http://redhat.com/~mingo/misc/crash-Wed_Jul_30_20_09_12_CEST_2008.log
the serial log just stops at a certain point. It's not at a specific
point, but the crash happened both times i tried to boot it.
Ingo
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-07-30 18:25 ` Ingo Molnar
@ 2008-07-30 21:46 ` Suresh Siddha
2008-07-30 23:41 ` Suresh Siddha
1 sibling, 0 replies; 37+ messages in thread
From: Suresh Siddha @ 2008-07-30 21:46 UTC (permalink / raw)
To: Ingo Molnar
Cc: H. Peter Anvin, Siddha, Suresh B, tglx@linutronix.de,
torvalds@linux-foundation.org, akpm@linux-foundation.org,
arjan@linux.intel.com, roland@redhat.com, drepper@redhat.com,
mikpe@it.uu.se, chrisw@sous-sol.org, andi@firstfloor.org,
linux-kernel@vger.kernel.org
On Wed, Jul 30, 2008 at 11:25:39AM -0700, Ingo Molnar wrote:
>
> I've restructured tip/x86/xsave to be like this, and it can now be
> merged into tip/master without conficts.
thanks.
> I briefly merged it into tip/master to test it, but after about 10
> randconfig iterations it ran into a spontaneous reboot crash. There's
> nothing in the log, the box (an Athlon64 X2) just reboots spontaneously.
> Removing the x86/xsave changes makes the system boot up fine.
I am also seeing this reboot issue and am hitting this both on tip/master
aswell as the tip/tmp.x86/xsave.broken
It seems to be timing related. Will look further.
thanks,
suresh
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-07-30 18:25 ` Ingo Molnar
2008-07-30 21:46 ` Suresh Siddha
@ 2008-07-30 23:41 ` Suresh Siddha
2008-07-31 21:29 ` Ingo Molnar
1 sibling, 1 reply; 37+ messages in thread
From: Suresh Siddha @ 2008-07-30 23:41 UTC (permalink / raw)
To: Ingo Molnar
Cc: H. Peter Anvin, Siddha, Suresh B, tglx@linutronix.de,
torvalds@linux-foundation.org, akpm@linux-foundation.org,
arjan@linux.intel.com, roland@redhat.com, drepper@redhat.com,
mikpe@it.uu.se, chrisw@sous-sol.org, andi@firstfloor.org,
linux-kernel@vger.kernel.org
On Wed, Jul 30, 2008 at 11:25:39AM -0700, Ingo Molnar wrote:
> I briefly merged it into tip/master to test it, but after about 10
> randconfig iterations it ran into a spontaneous reboot crash. There's
> nothing in the log, the box (an Athlon64 X2) just reboots spontaneously.
> Removing the x86/xsave changes makes the system boot up fine.
>
> I've pushed out the tree i tested into the tip/tmp.x86/xsave.broken
> branch. The bad config is:
>
> http://redhat.com/~mingo/misc/config-Wed_Jul_30_20_09_12_CEST_2008.bad
Ingo, 2.6.25, 2.6.26 also reboots randomly with this config on my dual-socket
system.
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-07-30 23:41 ` Suresh Siddha
@ 2008-07-31 21:29 ` Ingo Molnar
2008-07-31 21:58 ` Suresh Siddha
0 siblings, 1 reply; 37+ messages in thread
From: Ingo Molnar @ 2008-07-31 21:29 UTC (permalink / raw)
To: Suresh Siddha
Cc: H. Peter Anvin, tglx@linutronix.de, torvalds@linux-foundation.org,
akpm@linux-foundation.org, arjan@linux.intel.com,
roland@redhat.com, drepper@redhat.com, mikpe@it.uu.se,
chrisw@sous-sol.org, andi@firstfloor.org,
linux-kernel@vger.kernel.org
* Suresh Siddha <suresh.b.siddha@intel.com> wrote:
> On Wed, Jul 30, 2008 at 11:25:39AM -0700, Ingo Molnar wrote:
> > I briefly merged it into tip/master to test it, but after about 10
> > randconfig iterations it ran into a spontaneous reboot crash. There's
> > nothing in the log, the box (an Athlon64 X2) just reboots spontaneously.
> > Removing the x86/xsave changes makes the system boot up fine.
> >
> > I've pushed out the tree i tested into the tip/tmp.x86/xsave.broken
> > branch. The bad config is:
> >
> > http://redhat.com/~mingo/misc/config-Wed_Jul_30_20_09_12_CEST_2008.bad
>
> Ingo, 2.6.25, 2.6.26 also reboots randomly with this config on my
> dual-socket system.
hmmm ....
a few guesses: perhaps I2C related (the randconfig turned on I2C bits)?
Do you have any way (hw test-kit) to figure out where the reboot comes
from - is it a triple fault caused by the kernel? Or some hardware
event?
Ingo
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-07-31 21:29 ` Ingo Molnar
@ 2008-07-31 21:58 ` Suresh Siddha
2008-07-31 22:14 ` Andi Kleen
2008-07-31 22:17 ` Ingo Molnar
0 siblings, 2 replies; 37+ messages in thread
From: Suresh Siddha @ 2008-07-31 21:58 UTC (permalink / raw)
To: Ingo Molnar
Cc: Siddha, Suresh B, H. Peter Anvin, tglx@linutronix.de,
torvalds@linux-foundation.org, akpm@linux-foundation.org,
arjan@linux.intel.com, roland@redhat.com, drepper@redhat.com,
mikpe@it.uu.se, chrisw@sous-sol.org, andi@firstfloor.org,
linux-kernel@vger.kernel.org
On Thu, Jul 31, 2008 at 02:29:15PM -0700, Ingo Molnar wrote:
> > Ingo, 2.6.25, 2.6.26 also reboots randomly with this config on my
> > dual-socket system.
>
> hmmm ....
>
> a few guesses: perhaps I2C related (the randconfig turned on I2C bits)?
> Do you have any way (hw test-kit) to figure out where the reboot comes
> from - is it a triple fault caused by the kernel? Or some hardware
> event?
Doh! I knew something was wrong with your randconfig :)
#
# Watchdog Device Drivers
#
....
CONFIG_PC87413_WDT=y
CONFIG_60XX_WDT=y
# CONFIG_SBC8360_WDT is not set
CONFIG_CPU5_WDT=y
CONFIG_SMSC37B787_WDT=y
CONFIG_W83627HF_WDT=y
CONFIG_W83697HF_WDT=y
CONFIG_W83877F_WDT=y
CONFIG_W83977F_WDT=y
CONFIG_MACHZ_WDT=y
CONFIG_SBC_EPX_C3_WATCHDOG=y
Kernel was enabling watchdog, with out the userspace having the
heartbeat daemon....
randconfig is really not a good way to test! I can't even ssh to the box
with this config (something else is missing in the config!)
Anyhow, with watchdog removed, it works just fine. (both xsave and non-xsave
kernels)
thanks,
suresh
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-07-31 21:58 ` Suresh Siddha
@ 2008-07-31 22:14 ` Andi Kleen
2008-07-31 22:19 ` Suresh Siddha
2008-07-31 22:17 ` Ingo Molnar
1 sibling, 1 reply; 37+ messages in thread
From: Andi Kleen @ 2008-07-31 22:14 UTC (permalink / raw)
To: Suresh Siddha
Cc: Ingo Molnar, H. Peter Anvin, tglx@linutronix.de,
torvalds@linux-foundation.org, akpm@linux-foundation.org,
arjan@linux.intel.com, roland@redhat.com, drepper@redhat.com,
mikpe@it.uu.se, chrisw@sous-sol.org, andi@firstfloor.org,
linux-kernel@vger.kernel.org
> Kernel was enabling watchdog, with out the userspace having the
> heartbeat daemon....
Watchdog are normally only armed when someone opens the device
first.
-Andi
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-07-31 21:58 ` Suresh Siddha
2008-07-31 22:14 ` Andi Kleen
@ 2008-07-31 22:17 ` Ingo Molnar
2008-08-13 11:00 ` Ingo Molnar
1 sibling, 1 reply; 37+ messages in thread
From: Ingo Molnar @ 2008-07-31 22:17 UTC (permalink / raw)
To: Suresh Siddha
Cc: H. Peter Anvin, tglx@linutronix.de, torvalds@linux-foundation.org,
akpm@linux-foundation.org, arjan@linux.intel.com,
roland@redhat.com, drepper@redhat.com, mikpe@it.uu.se,
chrisw@sous-sol.org, andi@firstfloor.org,
linux-kernel@vger.kernel.org
* Suresh Siddha <suresh.b.siddha@intel.com> wrote:
> On Thu, Jul 31, 2008 at 02:29:15PM -0700, Ingo Molnar wrote:
> > > Ingo, 2.6.25, 2.6.26 also reboots randomly with this config on my
> > > dual-socket system.
> >
> > hmmm ....
> >
> > a few guesses: perhaps I2C related (the randconfig turned on I2C bits)?
> > Do you have any way (hw test-kit) to figure out where the reboot comes
> > from - is it a triple fault caused by the kernel? Or some hardware
> > event?
>
> Doh! I knew something was wrong with your randconfig :)
>
> #
> # Watchdog Device Drivers
> #
> ....
>
> CONFIG_PC87413_WDT=y
> CONFIG_60XX_WDT=y
> # CONFIG_SBC8360_WDT is not set
> CONFIG_CPU5_WDT=y
> CONFIG_SMSC37B787_WDT=y
> CONFIG_W83627HF_WDT=y
> CONFIG_W83697HF_WDT=y
> CONFIG_W83877F_WDT=y
> CONFIG_W83977F_WDT=y
> CONFIG_MACHZ_WDT=y
> CONFIG_SBC_EPX_C3_WATCHDOG=y
>
> Kernel was enabling watchdog, with out the userspace having the
> heartbeat daemon....
I never had function hw watchdog support on this box - so i guess the
2.6.27-rc1 kernel started supporting it - cool.
This was unfortunate timing i guess - when i removed xsave i didnt get
the reboot :-/
> randconfig is really not a good way to test! I can't even ssh to the
> box with this config (something else is missing in the config!)
it is a randconfig tailored to my testboxes, it might not work out of
box on yours :-)
randconfig is an excellent way of testing kernels, that testbox can run
strings of hundreds (sometimes thousands) of random kernels without
hitting any kernel bug. I had to resolve a large number of real kernel
bugs (and a handful of glitches like this hardware watchdog thing) to
get so far though.
> Anyhow, with watchdog removed, it works just fine. (both xsave and
> non-xsave kernels)
Great, thanks. I've re-integrated tip/x86/xsave into x86/master and have
pushed out the result.
Ingo
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-07-31 22:14 ` Andi Kleen
@ 2008-07-31 22:19 ` Suresh Siddha
2008-07-31 22:36 ` Andi Kleen
` (2 more replies)
0 siblings, 3 replies; 37+ messages in thread
From: Suresh Siddha @ 2008-07-31 22:19 UTC (permalink / raw)
To: Andi Kleen
Cc: Siddha, Suresh B, Ingo Molnar, H. Peter Anvin, tglx@linutronix.de,
torvalds@linux-foundation.org, akpm@linux-foundation.org,
arjan@linux.intel.com, roland@redhat.com, drepper@redhat.com,
mikpe@it.uu.se, chrisw@sous-sol.org, linux-kernel@vger.kernel.org
On Thu, Jul 31, 2008 at 03:14:35PM -0700, Andi Kleen wrote:
> > Kernel was enabling watchdog, with out the userspace having the
> > heartbeat daemon....
>
> Watchdog are normally only armed when someone opens the device
> first.
But thats not what I see with for ex with, w83627hf_wdt.c
Its done at the module_init time. (while I thought it should be
really done when some user level app opens the device, probably
its poorly written to take care if the kernel panics before starting userland.
but kernel can even die before the watchdog driver load aswell ;-)
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-07-31 22:19 ` Suresh Siddha
@ 2008-07-31 22:36 ` Andi Kleen
2008-07-31 22:38 ` Linus Torvalds
2008-07-31 22:48 ` Alan Cox
2 siblings, 0 replies; 37+ messages in thread
From: Andi Kleen @ 2008-07-31 22:36 UTC (permalink / raw)
To: Suresh Siddha
Cc: Andi Kleen, Ingo Molnar, H. Peter Anvin, tglx@linutronix.de,
torvalds@linux-foundation.org, akpm@linux-foundation.org,
arjan@linux.intel.com, roland@redhat.com, drepper@redhat.com,
mikpe@it.uu.se, chrisw@sous-sol.org, linux-kernel@vger.kernel.org,
wim
On Thu, Jul 31, 2008 at 03:19:24PM -0700, Suresh Siddha wrote:
> On Thu, Jul 31, 2008 at 03:14:35PM -0700, Andi Kleen wrote:
> > > Kernel was enabling watchdog, with out the userspace having the
> > > heartbeat daemon....
> >
> > Watchdog are normally only armed when someone opens the device
> > first.
>
> But thats not what I see with for ex with, w83627hf_wdt.c
>
> Its done at the module_init time. (while I thought it should be
> really done when some user level app opens the device, probably
> its poorly written to take care if the kernel panics before starting userland.
> but kernel can even die before the watchdog driver load aswell ;-)
Ok that watchdog driver is just broken then. Putting the watchdog maintainer
into cc.
-Andi
>
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-07-31 22:19 ` Suresh Siddha
2008-07-31 22:36 ` Andi Kleen
@ 2008-07-31 22:38 ` Linus Torvalds
2008-07-31 22:50 ` Ingo Molnar
2008-07-31 22:48 ` Alan Cox
2 siblings, 1 reply; 37+ messages in thread
From: Linus Torvalds @ 2008-07-31 22:38 UTC (permalink / raw)
To: Suresh Siddha, Wim Van Sebroeck, Pádraig Brady
Cc: Andi Kleen, Ingo Molnar, H. Peter Anvin, tglx@linutronix.de,
akpm@linux-foundation.org, arjan@linux.intel.com,
roland@redhat.com, drepper@redhat.com, mikpe@it.uu.se,
chrisw@sous-sol.org, linux-kernel@vger.kernel.org
On Thu, 31 Jul 2008, Suresh Siddha wrote:
> On Thu, Jul 31, 2008 at 03:14:35PM -0700, Andi Kleen wrote:
> > > Kernel was enabling watchdog, with out the userspace having the
> > > heartbeat daemon....
> >
> > Watchdog are normally only armed when someone opens the device
> > first.
>
> But thats not what I see with for ex with, w83627hf_wdt.c
>
> Its done at the module_init time. (while I thought it should be
> really done when some user level app opens the device, probably
> its poorly written to take care if the kernel panics before starting userland.
> but kernel can even die before the watchdog driver load aswell ;-)
Yeah, that's a _really_ broken watchdog timer driver. There's no way that
it's correct to start the watchdog at init time, at least when compiled
in.
It also looks to me like it's not even probing for the hardware - it's
just assuming it's there. That's scary. Am I missing something?
It really shouldn't be activated until it's opened. And it really
shouldn't just write to ports randomly without checking that they make
sense...
Linus
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-07-31 22:19 ` Suresh Siddha
2008-07-31 22:36 ` Andi Kleen
2008-07-31 22:38 ` Linus Torvalds
@ 2008-07-31 22:48 ` Alan Cox
2 siblings, 0 replies; 37+ messages in thread
From: Alan Cox @ 2008-07-31 22:48 UTC (permalink / raw)
To: Suresh Siddha
Cc: Andi Kleen, Siddha, Suresh B, Ingo Molnar, H. Peter Anvin,
tglx@linutronix.de, torvalds@linux-foundation.org,
akpm@linux-foundation.org, arjan@linux.intel.com,
roland@redhat.com, drepper@redhat.com, mikpe@it.uu.se,
chrisw@sous-sol.org, linux-kernel@vger.kernel.org
> But thats not what I see with for ex with, w83627hf_wdt.c
>
> Its done at the module_init time. (while I thought it should be
> really done when some user level app opens the device, probably
> its poorly written to take care if the kernel panics before starting userland.
> but kernel can even die before the watchdog driver load aswell ;-)
Various watchdogs fail to conform in assorted differing ways. Wim did
some patches to build a common watchdog library and I sent him a rework
of it a while ago. Once that is adopted this should all get cleaned up.
Right now Wim is a bit busy however.
Alan
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-07-31 22:38 ` Linus Torvalds
@ 2008-07-31 22:50 ` Ingo Molnar
2008-08-01 2:06 ` Rene Herman
0 siblings, 1 reply; 37+ messages in thread
From: Ingo Molnar @ 2008-07-31 22:50 UTC (permalink / raw)
To: Linus Torvalds
Cc: Suresh Siddha, Wim Van Sebroeck, Pádraig Brady, Andi Kleen,
H. Peter Anvin, tglx@linutronix.de, akpm@linux-foundation.org,
arjan@linux.intel.com, roland@redhat.com, drepper@redhat.com,
mikpe@it.uu.se, chrisw@sous-sol.org, linux-kernel@vger.kernel.org
* Linus Torvalds <torvalds@linux-foundation.org> wrote:
> > But thats not what I see with for ex with, w83627hf_wdt.c
> >
> > Its done at the module_init time. (while I thought it should be
> > really done when some user level app opens the device, probably its
> > poorly written to take care if the kernel panics before starting
> > userland. but kernel can even die before the watchdog driver load
> > aswell ;-)
>
> Yeah, that's a _really_ broken watchdog timer driver. There's no way
> that it's correct to start the watchdog at init time, at least when
> compiled in.
>
> It also looks to me like it's not even probing for the hardware - it's
> just assuming it's there. That's scary. Am I missing something?
>
> It really shouldn't be activated until it's opened. And it really
> shouldn't just write to ports randomly without checking that they make
> sense...
there are a handful of old ISA-ish drivers that can crash randconfig
kernels in various ways. [indefinite lockups, crashes, stomped-over
hardware, non-working keyboard, etc.]
I mapped most of them out via many months of trial-and-error - but it
would still be nice to have some separate config option to disable the
known ones. CONFIG_ALLOW_NON_GENERIC or something like that - which i
would unset in the randconfig runs.
( They are not CONFIG_BROKEN per se, because often it's hardware that
cannot be probed in any reliable way - the driver just assumes it's
there. )
Ingo
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-07-31 22:50 ` Ingo Molnar
@ 2008-08-01 2:06 ` Rene Herman
2008-08-01 9:51 ` Ingo Molnar
0 siblings, 1 reply; 37+ messages in thread
From: Rene Herman @ 2008-08-01 2:06 UTC (permalink / raw)
To: Ingo Molnar
Cc: Linus Torvalds, Suresh Siddha, Wim Van Sebroeck,
Pádraig Brady, Andi Kleen, H. Peter Anvin,
tglx@linutronix.de, akpm@linux-foundation.org,
arjan@linux.intel.com, roland@redhat.com, drepper@redhat.com,
mikpe@it.uu.se, chrisw@sous-sol.org, linux-kernel@vger.kernel.org
On 01-08-08 00:50, Ingo Molnar wrote:
> there are a handful of old ISA-ish drivers that can crash randconfig
> kernels in various ways. [indefinite lockups, crashes, stomped-over
> hardware, non-working keyboard, etc.]
>
> I mapped most of them out via many months of trial-and-error - but it
> would still be nice to have some separate config option to disable the
> known ones. CONFIG_ALLOW_NON_GENERIC or something like that - which i
> would unset in the randconfig runs.
>
> ( They are not CONFIG_BROKEN per se, because often it's hardware that
> cannot be probed in any reliable way - the driver just assumes it's
> there. )
If you have a list, I might be able to do something about some of them.
Rene.
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-08-01 2:06 ` Rene Herman
@ 2008-08-01 9:51 ` Ingo Molnar
2008-08-01 14:27 ` Rene Herman
0 siblings, 1 reply; 37+ messages in thread
From: Ingo Molnar @ 2008-08-01 9:51 UTC (permalink / raw)
To: Rene Herman
Cc: Linus Torvalds, Suresh Siddha, Wim Van Sebroeck,
Pádraig Brady, Andi Kleen, H. Peter Anvin,
tglx@linutronix.de, akpm@linux-foundation.org,
arjan@linux.intel.com, roland@redhat.com, drepper@redhat.com,
mikpe@it.uu.se, chrisw@sous-sol.org, linux-kernel@vger.kernel.org
* Rene Herman <rene.herman@keyaccess.nl> wrote:
> On 01-08-08 00:50, Ingo Molnar wrote:
>
>> there are a handful of old ISA-ish drivers that can crash randconfig
>> kernels in various ways. [indefinite lockups, crashes, stomped-over
>> hardware, non-working keyboard, etc.]
>>
>> I mapped most of them out via many months of trial-and-error - but it
>> would still be nice to have some separate config option to disable the
>> known ones. CONFIG_ALLOW_NON_GENERIC or something like that - which i
>> would unset in the randconfig runs.
>>
>> ( They are not CONFIG_BROKEN per se, because often it's hardware that
>> cannot be probed in any reliable way - the driver just assumes it's
>> there. )
>
> If you have a list, I might be able to do something about some of
> them.
find attached below a newer version of the original list i published
half a year ago:
http://people.redhat.com/mingo/auto-qa-patches/Kconfig-qa.patch
these are just pragmatic local hacks to get things going. (There are
more per machine quirks as well.)
i have not used a BROKEN annotation because CONFIG_BROKEN is
impractical: it just kills code altogether, indiscriminately. There's no
way for users to enable CONFIG_BROKEN in the upstream kernel - nothing
selects it and it's not an interactive option either.
So by all means if we mark a driver or a kernel feature as
CONFIG_BROKEN, it's killed altogether for all practical purposes.
What we'd need is some more gradual approach: for example a way to mark
"drivers that are not expected to boot on a whitebox PC", without
removing them altogether via a CONFIG_BROKEN dependency - often it's
hardware that cannot be probed safely.
Ingo
------------------>
Index: linux/security/smack/Kconfig
===================================================================
--- linux.orig/security/smack/Kconfig
+++ linux/security/smack/Kconfig
@@ -1,6 +1,9 @@
config SECURITY_SMACK
bool "Simplified Mandatory Access Control Kernel Support"
depends on NETLABEL && SECURITY_NETWORK
+ # breaks networking (TCP connections)
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT
default n
help
This selects the Simplified Mandatory Access Control Kernel.
Index: linux/drivers/block/Kconfig
===================================================================
--- linux.orig/drivers/block/Kconfig
+++ linux/drivers/block/Kconfig
@@ -71,6 +71,11 @@ config BLK_DEV_XD
config PARIDE
tristate "Parallel port IDE device support"
depends on PARPORT_PC
+
+ # the probe can hang during bootup on non-PARIDE boxes
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT if PARIDE = y
+
---help---
There are many external CD-ROM and disk devices that connect through
your computer's parallel port. Most of them are actually IDE devices
Index: linux/drivers/i2c/busses/Kconfig
===================================================================
--- linux.orig/drivers/i2c/busses/Kconfig
+++ linux/drivers/i2c/busses/Kconfig
@@ -610,6 +610,11 @@ config I2C_ELEKTOR
config I2C_PCA_ISA
tristate "PCA9564 on an ISA bus"
depends on ISA
+
+ # takes away IRQ10 on venus and thus breaks e1000
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT
+
select I2C_ALGOPCA
default n
help
Index: linux/drivers/ide/Kconfig
===================================================================
--- linux.orig/drivers/ide/Kconfig
+++ linux/drivers/ide/Kconfig
@@ -9,6 +9,11 @@ config HAVE_IDE
menuconfig IDE
tristate "ATA/ATAPI/MFM/RLL support"
depends on HAVE_IDE
+
+ # my test box expects /dev/sda, not /dev/hda
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT if IDE = y
+
depends on BLOCK
---help---
If you say Y here, your kernel will be able to manage low cost mass
Index: linux/drivers/isdn/icn/Kconfig
===================================================================
--- linux.orig/drivers/isdn/icn/Kconfig
+++ linux/drivers/isdn/icn/Kconfig
@@ -4,6 +4,11 @@
config ISDN_DRV_ICN
tristate "ICN 2B and 4B support"
depends on ISA
+
+ # crashed on venus, see config-Sun_May_25_11_00_41_CEST_2008.bad
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT
+
help
This enables support for two kinds of ISDN-cards made by a German
company called ICN. 2B is the standard version for a single ISDN
Index: linux/drivers/media/video/Kconfig
===================================================================
--- linux.orig/drivers/media/video/Kconfig
+++ linux/drivers/media/video/Kconfig
@@ -481,6 +481,9 @@ config VIDEO_SAA6588
config VIDEO_PMS
tristate "Mediavision Pro Movie Studio Video For Linux"
depends on ISA && VIDEO_V4L1
+ # hung on bootup on mars, see config-Wed_Jun__4_14_33_56_CEST_2008.bad
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT
help
Say Y if you have such a thing.
Index: linux/drivers/mtd/Kconfig
===================================================================
--- linux.orig/drivers/mtd/Kconfig
+++ linux/drivers/mtd/Kconfig
@@ -1,6 +1,11 @@
menuconfig MTD
tristate "Memory Technology Device (MTD) support"
depends on HAS_IOMEM
+
+ # dangerous to enable - sometimes hangs on probe
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT if MTD = y
+
help
Memory Technology Devices are flash, RAM and similar chips, often
used for solid state file systems on embedded devices. This option
Index: linux/drivers/net/appletalk/Kconfig
===================================================================
--- linux.orig/drivers/net/appletalk/Kconfig
+++ linux/drivers/net/appletalk/Kconfig
@@ -52,6 +52,11 @@ config LTPC
config COPS
tristate "COPS LocalTalk PC support"
depends on DEV_APPLETALK && (ISA || EISA)
+ #
+ # Can hang
+ #
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT if COPS = y
help
This allows you to use COPS AppleTalk cards to connect to LocalTalk
networks. You also need version 1.3.3 or later of the netatalk
Index: linux/drivers/scsi/Kconfig
===================================================================
--- linux.orig/drivers/scsi/Kconfig
+++ linux/drivers/scsi/Kconfig
@@ -1520,6 +1520,11 @@ config SCSI_NSP32
config SCSI_DEBUG
tristate "SCSI debugging host simulator"
depends on SCSI
+
+ # this creates a fake /dev/sda which confuses the bzImage bootup
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT if SCSI_DEBUG = y
+
help
This is a host adapter simulator that can simulate multiple hosts
each with multiple dummy SCSI devices (disks). It defaults to one
Index: linux/drivers/video/Kconfig
===================================================================
--- linux.orig/drivers/video/Kconfig
+++ linux/drivers/video/Kconfig
@@ -236,6 +236,11 @@ comment "Frame buffer hardware drivers"
config FB_CIRRUS
tristate "Cirrus Logic support"
+
+ # can hang on a box without this hardware
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT if FB_CIRRUS = y
+
depends on FB && (ZORRO || PCI)
select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
@@ -546,6 +551,11 @@ config FB_CT65550
config FB_ASILIANT
bool "Asiliant (Chips) 69000 display support"
+
+ # can hang on a box without this hardware
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT if FB_ASILIANT = y
+
depends on (FB = y) && PCI
select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
@@ -564,6 +574,11 @@ config FB_IMSTT
config FB_VGA16
tristate "VGA 16-color graphics support"
+
+ # can hang on a box without this hardware
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT if FB_VGA16 = y
+
depends on FB && (X86 || PPC)
select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
@@ -674,6 +689,11 @@ config FB_UVESA
config FB_VESA
bool "VESA VGA graphics support"
+
+ # can hang on a box without this hardware
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT if FB_VESA = y
+
depends on (FB = y) && X86
select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
@@ -1299,6 +1319,11 @@ config FB_MATROX_MULTIHEAD
config FB_RADEON
tristate "ATI Radeon display support"
+
+ # can hang on a box without this hardware
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT if FB_RADEON = y
+
depends on FB && PCI
select FB_BACKLIGHT if FB_RADEON_BACKLIGHT
select FB_MODE_HELPERS
@@ -1581,6 +1606,11 @@ config FB_VT8623
config FB_CYBLA
tristate "Cyberblade/i1 support"
+
+ # can hang on a box without this hardware
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT if FB_CYBLA = y
+
depends on FB && PCI && X86_32 && !64BIT
select FB_CFB_IMAGEBLIT
select VIDEO_SELECT
@@ -2006,6 +2036,11 @@ config FB_SH7760
config FB_VIRTUAL
tristate "Virtual Frame Buffer support (ONLY FOR TESTING!)"
+
+ # can hang on a box without this hardware
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT if FB_VIRTUAL = y
+
depends on FB
select FB_SYS_FILLRECT
select FB_SYS_COPYAREA
Index: linux/drivers/video/console/Kconfig
===================================================================
--- linux.orig/drivers/video/console/Kconfig
+++ linux/drivers/video/console/Kconfig
@@ -61,6 +61,11 @@ config VIDEO_SELECT
config MDA_CONSOLE
depends on !M68K && !PARISC && ISA
+
+ # can hang on a box without this hardware
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT if MDA_CONSOLE = y
+
tristate "MDA text console (dual-headed) (EXPERIMENTAL)"
---help---
Say Y here if you have an old MDA or monochrome Hercules graphics
@@ -113,6 +118,10 @@ config DUMMY_CONSOLE_ROWS
config FRAMEBUFFER_CONSOLE
tristate "Framebuffer Console support"
+
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT if FRAMEBUFFER_CONSOLE = y
+
depends on FB
select CRC32
help
Index: linux/drivers/watchdog/Kconfig
===================================================================
--- linux.orig/drivers/watchdog/Kconfig
+++ linux/drivers/watchdog/Kconfig
@@ -324,6 +324,12 @@ config SC520_WDT
config EUROTECH_WDT
tristate "Eurotech CPU-1220/1410 Watchdog Timer"
depends on X86
+
+ # this ISA driver puts itself on IRQ10 - if IRQ10 happens to
+ # trigger then that will cause a watchdog-initiated reboot
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT if EUROTECH_WDT = y
+
help
Enable support for the watchdog timer on the Eurotech CPU-1220 and
CPU-1410 cards. These are PC/104 SBCs. Spec sheets and product
@@ -830,6 +836,11 @@ config MIXCOMWD
config WDT
tristate "WDT Watchdog timer"
depends on ISA
+
+ # this ISA driver sits on IRQ11 by default - blocking forcedeth
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT if WDT = y
+
---help---
If you have a WDT500P or WDT501P watchdog board, say Y here,
otherwise N. It is not possible to probe for this board, which means
Index: linux/fs/Kconfig
===================================================================
--- linux.orig/fs/Kconfig
+++ linux/fs/Kconfig
@@ -1636,6 +1636,11 @@ config NFS_V4
config ROOT_NFS
bool "Root file system on NFS"
depends on NFS_FS=y && IP_PNP
+
+ # hangs a non-root-NFS box during bootup
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT
+
help
If you want your system to mount its root file system via NFS,
choose Y here. This is common practice for managing systems
Index: linux/security/Kconfig
===================================================================
--- linux.orig/security/Kconfig
+++ linux/security/Kconfig
@@ -85,6 +85,11 @@ config SECURITY_FILE_CAPABILITIES
config SECURITY_ROOTPLUG
bool "Root Plug Support"
depends on USB=y && SECURITY
+
+ # fails with hard-to-debug "could not find init" boot failure
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT
+
help
This is a sample LSM module that should only be used as such.
It prevents any programs running with egid == 0 if a specific
Index: linux/security/selinux/Kconfig
===================================================================
--- linux.orig/security/selinux/Kconfig
+++ linux/security/selinux/Kconfig
@@ -100,6 +100,11 @@ config SECURITY_SELINUX_CHECKREQPROT_VAL
config SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT
bool "NSA SELinux enable new secmark network controls by default"
depends on SECURITY_SELINUX
+
+ # old system booted up with this cannot ssh out
+ depends on BROKEN_BOOT_ALLOWED
+ select BROKEN_BOOT
+
default n
help
This option determines whether the new secmark-based network
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-08-01 9:51 ` Ingo Molnar
@ 2008-08-01 14:27 ` Rene Herman
2008-08-01 14:49 ` Andi Kleen
0 siblings, 1 reply; 37+ messages in thread
From: Rene Herman @ 2008-08-01 14:27 UTC (permalink / raw)
To: Ingo Molnar, Wolfram Sang
Cc: Linus Torvalds, Suresh Siddha, Wim Van Sebroeck,
Pádraig Brady, Andi Kleen, H. Peter Anvin,
tglx@linutronix.de, akpm@linux-foundation.org,
arjan@linux.intel.com, roland@redhat.com, drepper@redhat.com,
mikpe@it.uu.se, chrisw@sous-sol.org, linux-kernel@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 2756 bytes --]
On 01-08-08 11:51, Ingo Molnar wrote:
> find attached below a newer version of the original list i published
> half a year ago:
>
> http://people.redhat.com/mingo/auto-qa-patches/Kconfig-qa.patch
>
> these are just pragmatic local hacks to get things going. (There are
> more per machine quirks as well.)
>
> i have not used a BROKEN annotation because CONFIG_BROKEN is
> impractical: it just kills code altogether, indiscriminately. There's no
> way for users to enable CONFIG_BROKEN in the upstream kernel - nothing
> selects it and it's not an interactive option either.
>
> So by all means if we mark a driver or a kernel feature as
> CONFIG_BROKEN, it's killed altogether for all practical purposes.
>
> What we'd need is some more gradual approach: for example a way to mark
> "drivers that are not expected to boot on a whitebox PC", without
> removing them altogether via a CONFIG_BROKEN dependency - often it's
> hardware that cannot be probed safely.
For real ISA at the least, the best fix I feel is just not go grabbing
resources without anything (ie, ISAPnP) or anyone (ie, the user) telling
us that's where the hardware's at.
For example, for the first real ISA driver in the list:
> Index: linux/drivers/i2c/busses/Kconfig
> ===================================================================
> --- linux.orig/drivers/i2c/busses/Kconfig
> +++ linux/drivers/i2c/busses/Kconfig
> @@ -610,6 +610,11 @@ config I2C_ELEKTOR
> config I2C_PCA_ISA
> tristate "PCA9564 on an ISA bus"
> depends on ISA
> +
> + # takes away IRQ10 on venus and thus breaks e1000
> + depends on BROKEN_BOOT_ALLOWED
> + select BROKEN_BOOT
> +
The attached would be my preffered approach to this.
(to avoid an IRQ 0 discussion -- the middle hunk is unrelated, just
makes it consistent with the rest of the file)
(and this uses the isa_bus match() method as intended; the idea of the
isa_bus is to make it look at least somewhat like a sane bus such as PCI
which includes only failing a load if there's no way a later bind could
conceivably succeed. somewhat debatable merit sometimes, but such is the
device model, and it's actually fairly nice once you get used to it for
quickly switching drivers for a single piece of hardware)
A user of this hardware is a one-time
$ echo options i2c-pca-isa base=0x330 irq=10 >> /etc/modprobe.conf
away from the old behaviour. Given the hackish nature of all this kind
of hardware these days its users tend to not mind. In fact, what with
getting old hardware to play nice with modern systems, I myself at least
very much welcome having to be explicit about these things.
(and just saw the CC list on this thing while adding Wolfram. ouch. will
be dropping all from any followups...)
Rene.
[-- Attachment #2: 0001-i2c-don-t-autograb-i2c-pca-isa.patch --]
[-- Type: text/plain, Size: 1974 bytes --]
>From 58f25a608b827426bf5c110795dd7e917e9cc568 Mon Sep 17 00:00:00 2001
From: Rene Herman <rene.herman@gmail.com>
Date: Fri, 1 Aug 2008 15:35:31 +0200
Subject: [PATCH] i2c: don't autograb i2c-pca-isa
Grabbing resources without anything telling us we should can break
randconfig builds by keeping them busy. Insist that when hardware
is not capable of telling us, the user does.
Signed-off-by: Rene Herman <rene.herman@gmail.com>
---
drivers/i2c/busses/i2c-pca-isa.c | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-pca-isa.c b/drivers/i2c/busses/i2c-pca-isa.c
index a119784..2579169 100644
--- a/drivers/i2c/busses/i2c-pca-isa.c
+++ b/drivers/i2c/busses/i2c-pca-isa.c
@@ -36,8 +36,8 @@
#define DRIVER "i2c-pca-isa"
#define IO_SIZE 4
-static unsigned long base = 0x330;
-static int irq = 10;
+static unsigned long base;
+static int irq = -1;
/* Data sheet recommends 59kHz for 100kHz operation due to variation
* in the actual clock rate */
@@ -107,6 +107,19 @@ static struct i2c_adapter pca_isa_ops = {
.timeout = 100,
};
+static int __devinit pca_isa_match(struct device *dev, unsigned int id)
+{
+ int match = base != 0;
+
+ if (match) {
+ if (irq == -1)
+ dev_warn(dev, "using poling mode (specify irq)\n");
+ } else
+ dev_err(dev, "please specify base\n");
+
+ return match;
+}
+
static int __devinit pca_isa_probe(struct device *dev, unsigned int id)
{
init_waitqueue_head(&pca_wait);
@@ -153,7 +166,7 @@ static int __devexit pca_isa_remove(struct device *dev, unsigned int id)
{
i2c_del_adapter(&pca_isa_ops);
- if (irq > 0) {
+ if (irq > -1) {
disable_irq(irq);
free_irq(irq, &pca_isa_ops);
}
@@ -163,6 +176,7 @@ static int __devexit pca_isa_remove(struct device *dev, unsigned int id)
}
static struct isa_driver pca_isa_driver = {
+ .match = pca_isa_match,
.probe = pca_isa_probe,
.remove = __devexit_p(pca_isa_remove),
.driver = {
--
1.5.5
^ permalink raw reply related [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-08-01 14:27 ` Rene Herman
@ 2008-08-01 14:49 ` Andi Kleen
2008-08-01 15:19 ` Rene Herman
0 siblings, 1 reply; 37+ messages in thread
From: Andi Kleen @ 2008-08-01 14:49 UTC (permalink / raw)
To: Rene Herman
Cc: Ingo Molnar, Wolfram Sang, Linus Torvalds, Suresh Siddha,
Wim Van Sebroeck, Pádraig Brady, Andi Kleen, H. Peter Anvin,
tglx@linutronix.de, akpm@linux-foundation.org,
arjan@linux.intel.com, roland@redhat.com, drepper@redhat.com,
mikpe@it.uu.se, chrisw@sous-sol.org, linux-kernel@vger.kernel.org
On Fri, Aug 01, 2008 at 04:27:53PM +0200, Rene Herman wrote:
> On 01-08-08 11:51, Ingo Molnar wrote:
>
> >find attached below a newer version of the original list i published
> >half a year ago:
> >
> > http://people.redhat.com/mingo/auto-qa-patches/Kconfig-qa.patch
> >
> >these are just pragmatic local hacks to get things going. (There are
> >more per machine quirks as well.)
> >
> >i have not used a BROKEN annotation because CONFIG_BROKEN is
> >impractical: it just kills code altogether, indiscriminately. There's no
> >way for users to enable CONFIG_BROKEN in the upstream kernel - nothing
> >selects it and it's not an interactive option either.
> >
> >So by all means if we mark a driver or a kernel feature as
> >CONFIG_BROKEN, it's killed altogether for all practical purposes.
> >
> >What we'd need is some more gradual approach: for example a way to mark
> >"drivers that are not expected to boot on a whitebox PC", without
> >removing them altogether via a CONFIG_BROKEN dependency - often it's
> >hardware that cannot be probed safely.
>
> For real ISA at the least, the best fix I feel is just not go grabbing
> resources without anything (ie, ISAPnP) or anyone (ie, the user) telling
Really old systems don't have isapnp. Neither have smbus devices.
> us that's where the hardware's at.
That would mean the users on these systems would need to add tons
of obscure command line options.
-Andi
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-08-01 14:49 ` Andi Kleen
@ 2008-08-01 15:19 ` Rene Herman
2008-08-01 15:44 ` Andi Kleen
0 siblings, 1 reply; 37+ messages in thread
From: Rene Herman @ 2008-08-01 15:19 UTC (permalink / raw)
To: Andi Kleen
Cc: Ingo Molnar, Wolfram Sang, Linus Torvalds, Suresh Siddha,
Wim Van Sebroeck, Pádraig Brady, H. Peter Anvin,
tglx@linutronix.de, akpm@linux-foundation.org,
arjan@linux.intel.com, roland@redhat.com, drepper@redhat.com,
mikpe@it.uu.se, chrisw@sous-sol.org, linux-kernel@vger.kernel.org
On 01-08-08 16:49, Andi Kleen wrote:
>> For real ISA at the least, the best fix I feel is just not go grabbing
>> resources without anything (ie, ISAPnP) or anyone (ie, the user) telling
>
> Really old systems don't have isapnp. Neither have smbus devices.
>
>> us that's where the hardware's at.
>
> That would mean the users on these systems would need to add tons
> of obscure command line options.
No, it means users on those 1% of systems that are using drivers that
break the other 99% would have to for those one or two drivers that do.
And as said, we don't care.
Rene.
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-08-01 15:19 ` Rene Herman
@ 2008-08-01 15:44 ` Andi Kleen
2008-08-01 16:03 ` Rene Herman
0 siblings, 1 reply; 37+ messages in thread
From: Andi Kleen @ 2008-08-01 15:44 UTC (permalink / raw)
To: Rene Herman
Cc: Andi Kleen, Ingo Molnar, Wolfram Sang, Linus Torvalds,
Suresh Siddha, Wim Van Sebroeck, Pádraig Brady,
H. Peter Anvin, tglx@linutronix.de, akpm@linux-foundation.org,
arjan@linux.intel.com, roland@redhat.com, drepper@redhat.com,
mikpe@it.uu.se, chrisw@sous-sol.org, linux-kernel@vger.kernel.org
On Fri, Aug 01, 2008 at 05:19:17PM +0200, Rene Herman wrote:
> On 01-08-08 16:49, Andi Kleen wrote:
>
> >>For real ISA at the least, the best fix I feel is just not go grabbing
> >>resources without anything (ie, ISAPnP) or anyone (ie, the user) telling
> >
> >Really old systems don't have isapnp. Neither have smbus devices.
> >
> >>us that's where the hardware's at.
> >
> >That would mean the users on these systems would need to add tons
> >of obscure command line options.
>
> No, it means users on those 1% of systems that are using drivers that
> break the other 99% would have to for those one or two drivers that do.
>
> And as said, we don't care.
Not sure who "we" is in this context.
Especially dropping easy support for all smbus devices (which are often like
this) would seem quite wrong to me. And for real ISA devices there tends to
be a surprisingly large user base left for those.
The config option Ingo proposed is a good idea though.
Or they can just use 64bit which never defines CONFIG_ISA, but of course
still has to support all the similar smbus drivers.
-Andi
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-08-01 15:44 ` Andi Kleen
@ 2008-08-01 16:03 ` Rene Herman
0 siblings, 0 replies; 37+ messages in thread
From: Rene Herman @ 2008-08-01 16:03 UTC (permalink / raw)
To: Andi Kleen
Cc: Ingo Molnar, Wolfram Sang, Linus Torvalds, Suresh Siddha,
Wim Van Sebroeck, Pádraig Brady, H. Peter Anvin,
tglx@linutronix.de, akpm@linux-foundation.org,
arjan@linux.intel.com, roland@redhat.com, drepper@redhat.com,
mikpe@it.uu.se, chrisw@sous-sol.org, linux-kernel@vger.kernel.org
On 01-08-08 17:44, Andi Kleen wrote:
> On Fri, Aug 01, 2008 at 05:19:17PM +0200, Rene Herman wrote:
>> On 01-08-08 16:49, Andi Kleen wrote:
>>
>>>> For real ISA at the least, the best fix I feel is just not go grabbing
>>>> resources without anything (ie, ISAPnP) or anyone (ie, the user) telling
>>> Really old systems don't have isapnp. Neither have smbus devices.
>>>
>>>> us that's where the hardware's at.
>>> That would mean the users on these systems would need to add tons
>>> of obscure command line options.
>> No, it means users on those 1% of systems that are using drivers that
>> break the other 99% would have to for those one or two drivers that do.
>>
>> And as said, we don't care.
>
> Not sure who "we" is in this context.
We, the old crap hardware users the drivers for which break sensible
systems by default.
Really, look at the patch I posted -- it's a patch to make passing in a
base (and irq if you want one) to i2c-pca-isa needed. Right now, the
thing just grabs those resources and breaks the boot on systems that
don't have it as per Ingo's testing.
On plain technical grounds mucking with resources you don't own is bad
(on those old systems, 0x330 might even be a NE2000 which gets confused
really quickly) and even more importantly; let's take a wild guess and
assume that that specific ISA driver has, oh let's say, less than 3
users in the world all of whom wouldn't care one bit about sticking in
an options line in their modprobe.conf.
There is no reason drivers like that should be allowed to break all the
_other_ systems instead of making those users do that. Not a single one.
> Especially dropping easy support for all smbus devices (which are often like
> this) would seem quite wrong to me. And for real ISA devices there tends to
> be a surprisingly large user base left for those.
Fortunately, smbus devices tend to not grab IRQs and go poking around
the general I/O space willy-nilly (they go poking around the smbus I/O
space willy-nilly). Note again, this specific case is a _bus_ driver for
a bus on an ISA card.
Rene
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [patch 0/9] x86, xsave: xsave/xrstor support
2008-07-31 22:17 ` Ingo Molnar
@ 2008-08-13 11:00 ` Ingo Molnar
0 siblings, 0 replies; 37+ messages in thread
From: Ingo Molnar @ 2008-08-13 11:00 UTC (permalink / raw)
To: Suresh Siddha
Cc: H. Peter Anvin, tglx@linutronix.de, torvalds@linux-foundation.org,
akpm@linux-foundation.org, arjan@linux.intel.com,
roland@redhat.com, drepper@redhat.com, mikpe@it.uu.se,
chrisw@sous-sol.org, andi@firstfloor.org,
linux-kernel@vger.kernel.org
* Ingo Molnar <mingo@elte.hu> wrote:
> > Anyhow, with watchdog removed, it works just fine. (both xsave and
> > non-xsave kernels)
>
> Great, thanks. I've re-integrated tip/x86/xsave into x86/master and
> have pushed out the result.
FYI, small tip/x86/xsave build fixlet below - user-space exposed
interfaces need to use __u64 not u64.
Ingo
-------------->
>From 26d809af6397ce5c37f5c44d89734d19cce1ad25 Mon Sep 17 00:00:00 2001
From: Ingo Molnar <mingo@elte.hu>
Date: Wed, 13 Aug 2008 12:46:26 +0200
Subject: [PATCH] x86: fix xsave build error
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
fix this build failure with certain glibc versions:
In file included from /usr/include/bits/sigcontext.h:28,
from /usr/include/signal.h:333,
from Documentation/accounting/getdelays.c:24:
/home/mingo/tip/usr/include/asm/sigcontext.h:191: error: expected specifier-qualifier-list before ‘u64’
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
include/asm-x86/sigcontext.h | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/asm-x86/sigcontext.h b/include/asm-x86/sigcontext.h
index 899fe2f..ee813f4 100644
--- a/include/asm-x86/sigcontext.h
+++ b/include/asm-x86/sigcontext.h
@@ -264,9 +264,9 @@ struct sigcontext {
#endif /* !__i386__ */
struct _xsave_hdr {
- u64 xstate_bv;
- u64 reserved1[2];
- u64 reserved2[5];
+ __u64 xstate_bv;
+ __u64 reserved1[2];
+ __u64 reserved2[5];
};
/*
^ permalink raw reply related [flat|nested] 37+ messages in thread
end of thread, other threads:[~2008-08-13 11:01 UTC | newest]
Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-29 17:29 [patch 0/9] x86, xsave: xsave/xrstor support Suresh Siddha
2008-07-29 17:29 ` [patch 1/9] x86, xsave: xsave cpuid feature bits Suresh Siddha
2008-07-29 17:29 ` [patch 2/9] x86, xsave: enable xsave/xrstor on cpus with xsave support Suresh Siddha
2008-07-29 17:29 ` [patch 3/9] x86, xsave: context switch support using xsave/xrstor Suresh Siddha
2008-07-29 17:29 ` [patch 4/9] x86, xsave: dynamically allocate sigframes fpstate instead of static allocation Suresh Siddha
2008-07-29 17:29 ` [patch 5/9] x86, xsave: reorganization of signal save/restore fpstate code layout Suresh Siddha
2008-07-29 17:29 ` [patch 6/9] x86, xsave: xsave/xrstor specific routines Suresh Siddha
2008-07-29 17:29 ` [patch 7/9] x86, xsave: struct _fpstate extensions to include extended state information Suresh Siddha
2008-07-29 17:29 ` [patch 8/9] x86, xsave: save/restore the extended state context in sigframe Suresh Siddha
2008-07-29 17:29 ` [patch 9/9] x86, xsave: update xsave header bits during ptrace fpregs set Suresh Siddha
2008-07-29 23:09 ` [patch 0/9] x86, xsave: xsave/xrstor support H. Peter Anvin
2008-07-29 23:29 ` Suresh Siddha
2008-07-29 23:43 ` H. Peter Anvin
2008-07-30 10:03 ` Ingo Molnar
2008-07-30 16:31 ` H. Peter Anvin
2008-07-30 17:08 ` Suresh Siddha
2008-07-30 17:14 ` H. Peter Anvin
2008-07-30 18:25 ` Ingo Molnar
2008-07-30 21:46 ` Suresh Siddha
2008-07-30 23:41 ` Suresh Siddha
2008-07-31 21:29 ` Ingo Molnar
2008-07-31 21:58 ` Suresh Siddha
2008-07-31 22:14 ` Andi Kleen
2008-07-31 22:19 ` Suresh Siddha
2008-07-31 22:36 ` Andi Kleen
2008-07-31 22:38 ` Linus Torvalds
2008-07-31 22:50 ` Ingo Molnar
2008-08-01 2:06 ` Rene Herman
2008-08-01 9:51 ` Ingo Molnar
2008-08-01 14:27 ` Rene Herman
2008-08-01 14:49 ` Andi Kleen
2008-08-01 15:19 ` Rene Herman
2008-08-01 15:44 ` Andi Kleen
2008-08-01 16:03 ` Rene Herman
2008-07-31 22:48 ` Alan Cox
2008-07-31 22:17 ` Ingo Molnar
2008-08-13 11:00 ` Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox