@@ -430,7 +430,9 @@ typedef struct {
430
430
struct thread_struct {
431
431
/* Cached TLS descriptors: */
432
432
struct desc_struct tls_array [GDT_ENTRY_TLS_ENTRIES ];
433
+ #ifdef CONFIG_X86_32
433
434
unsigned long sp0 ;
435
+ #endif
434
436
unsigned long sp ;
435
437
#ifdef CONFIG_X86_32
436
438
unsigned long sysenter_cs ;
@@ -797,6 +799,13 @@ static inline void spin_lock_prefetch(const void *x)
797
799
798
800
#define task_top_of_stack (task ) ((unsigned long)(task_pt_regs(task) + 1))
799
801
802
+ #define task_pt_regs (task ) \
803
+ ({ \
804
+ unsigned long __ptr = (unsigned long)task_stack_page(task); \
805
+ __ptr += THREAD_SIZE - TOP_OF_KERNEL_STACK_PADDING; \
806
+ ((struct pt_regs *)__ptr) - 1; \
807
+ })
808
+
800
809
#ifdef CONFIG_X86_32
801
810
/*
802
811
* User space process size: 3GB (default).
@@ -816,23 +825,6 @@ static inline void spin_lock_prefetch(const void *x)
816
825
.addr_limit = KERNEL_DS, \
817
826
}
818
827
819
- /*
820
- * TOP_OF_KERNEL_STACK_PADDING reserves 8 bytes on top of the ring0 stack.
821
- * This is necessary to guarantee that the entire "struct pt_regs"
822
- * is accessible even if the CPU haven't stored the SS/ESP registers
823
- * on the stack (interrupt gate does not save these registers
824
- * when switching to the same priv ring).
825
- * Therefore beware: accessing the ss/esp fields of the
826
- * "struct pt_regs" is possible, but they may contain the
827
- * completely wrong values.
828
- */
829
- #define task_pt_regs (task ) \
830
- ({ \
831
- unsigned long __ptr = (unsigned long)task_stack_page(task); \
832
- __ptr += THREAD_SIZE - TOP_OF_KERNEL_STACK_PADDING; \
833
- ((struct pt_regs *)__ptr) - 1; \
834
- })
835
-
836
828
#define KSTK_ESP (task ) (task_pt_regs(task)->sp)
837
829
838
830
#else
@@ -866,11 +858,9 @@ static inline void spin_lock_prefetch(const void *x)
866
858
#define STACK_TOP_MAX TASK_SIZE_MAX
867
859
868
860
#define INIT_THREAD { \
869
- .sp0 = TOP_OF_INIT_STACK, \
870
861
.addr_limit = KERNEL_DS, \
871
862
}
872
863
873
- #define task_pt_regs (tsk ) ((struct pt_regs *)(tsk)->thread.sp0 - 1)
874
864
extern unsigned long KSTK_ESP (struct task_struct * task );
875
865
876
866
#endif /* CONFIG_X86_64 */
0 commit comments