diff options
| author | David Gibson <david@gibson.dropbear.id.au> | 2005-10-21 01:45:50 -0400 |
|---|---|---|
| committer | Paul Mackerras <paulus@samba.org> | 2005-10-21 08:47:23 -0400 |
| commit | 6cb7bfebb145af5ea1d052512a2ae7ff07a47202 (patch) | |
| tree | 677ce52e6ad423f8a652ec3e16f98c3ad33fcc54 /include | |
| parent | b0faa28493f97b55b36ff5b1a2b8c81bf253a460 (diff) | |
[PATCH] powerpc: Merge thread_info.h
Merge ppc32 and ppc64 versions of thread_info.h. They were pretty
similar already, the chief changes are:
- Instead of inline asm to implement current_thread_info(),
which needs to be different for ppc32 and ppc64, we use C with an
asm("r1") register variable. gcc turns it into the same asm as we
used to have for both platforms.
- We replace ppc32's 'local_flags' with the ppc64
'syscall_noerror' field. The noerror flag was in fact the only thing
in the local_flags field anyway, so the ppc64 approach is simpler, and
means we only need a load-immediate/store instead of load/mask/store
when clearing the flag.
- In readiness for 64k pages, when THREAD_SIZE will be less
than a page, ppc64 used kmalloc() rather than get_free_pages() to
allocate the kernel stack. With this patch we do the same for ppc32,
since there's no strong reason not to.
- For ppc64, we no longer export THREAD_SHIFT and THREAD_SIZE
via asm-offsets, thread_info.h can now be safely included in asm, as
on ppc32.
Built and booted on G4 Powerbook (ARCH=ppc and ARCH=powerpc) and
Power5 (ARCH=ppc64 and ARCH=powerpc).
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/asm-powerpc/thread_info.h (renamed from include/asm-ppc64/thread_info.h) | 34 | ||||
| -rw-r--r-- | include/asm-ppc/ptrace.h | 2 | ||||
| -rw-r--r-- | include/asm-ppc/thread_info.h | 107 |
3 files changed, 23 insertions, 120 deletions
diff --git a/include/asm-ppc64/thread_info.h b/include/asm-powerpc/thread_info.h index 71244d8a427d..0b4c24551c21 100644 --- a/include/asm-ppc64/thread_info.h +++ b/include/asm-powerpc/thread_info.h | |||
| @@ -1,15 +1,25 @@ | |||
| 1 | /* thread_info.h: PPC low-level thread information | 1 | /* thread_info.h: PowerPC low-level thread information |
| 2 | * adapted from the i386 version by Paul Mackerras | 2 | * adapted from the i386 version by Paul Mackerras |
| 3 | * | 3 | * |
| 4 | * Copyright (C) 2002 David Howells (dhowells@redhat.com) | 4 | * Copyright (C) 2002 David Howells (dhowells@redhat.com) |
| 5 | * - Incorporating suggestions made by Linus Torvalds and Dave Miller | 5 | * - Incorporating suggestions made by Linus Torvalds and Dave Miller |
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | #ifndef _ASM_THREAD_INFO_H | 8 | #ifndef _ASM_POWERPC_THREAD_INFO_H |
| 9 | #define _ASM_THREAD_INFO_H | 9 | #define _ASM_POWERPC_THREAD_INFO_H |
| 10 | 10 | ||
| 11 | #ifdef __KERNEL__ | 11 | #ifdef __KERNEL__ |
| 12 | 12 | ||
| 13 | /* We have 8k stacks on ppc32 and 16k on ppc64 */ | ||
| 14 | |||
| 15 | #ifdef CONFIG_PPC64 | ||
| 16 | #define THREAD_SHIFT 14 | ||
| 17 | #else | ||
| 18 | #define THREAD_SHIFT 13 | ||
| 19 | #endif | ||
| 20 | |||
| 21 | #define THREAD_SIZE (1 << THREAD_SHIFT) | ||
| 22 | |||
| 13 | #ifndef __ASSEMBLY__ | 23 | #ifndef __ASSEMBLY__ |
| 14 | #include <linux/config.h> | 24 | #include <linux/config.h> |
| 15 | #include <linux/cache.h> | 25 | #include <linux/cache.h> |
| @@ -24,7 +34,8 @@ struct thread_info { | |||
| 24 | struct task_struct *task; /* main task structure */ | 34 | struct task_struct *task; /* main task structure */ |
| 25 | struct exec_domain *exec_domain; /* execution domain */ | 35 | struct exec_domain *exec_domain; /* execution domain */ |
| 26 | int cpu; /* cpu we're on */ | 36 | int cpu; /* cpu we're on */ |
| 27 | int preempt_count; /* 0 => preemptable, <0 => BUG */ | 37 | int preempt_count; /* 0 => preemptable, |
| 38 | <0 => BUG */ | ||
| 28 | struct restart_block restart_block; | 39 | struct restart_block restart_block; |
| 29 | /* set by force_successful_syscall_return */ | 40 | /* set by force_successful_syscall_return */ |
| 30 | unsigned char syscall_noerror; | 41 | unsigned char syscall_noerror; |
| @@ -54,9 +65,6 @@ struct thread_info { | |||
| 54 | 65 | ||
| 55 | /* thread information allocation */ | 66 | /* thread information allocation */ |
| 56 | 67 | ||
| 57 | #define THREAD_SHIFT 14 | ||
| 58 | #define THREAD_ORDER (THREAD_SHIFT - PAGE_SHIFT) | ||
| 59 | #define THREAD_SIZE (1 << THREAD_SHIFT) | ||
| 60 | #ifdef CONFIG_DEBUG_STACK_USAGE | 68 | #ifdef CONFIG_DEBUG_STACK_USAGE |
| 61 | #define alloc_thread_info(tsk) \ | 69 | #define alloc_thread_info(tsk) \ |
| 62 | ({ \ | 70 | ({ \ |
| @@ -68,7 +76,7 @@ struct thread_info { | |||
| 68 | ret; \ | 76 | ret; \ |
| 69 | }) | 77 | }) |
| 70 | #else | 78 | #else |
| 71 | #define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL) | 79 | #define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL) |
| 72 | #endif | 80 | #endif |
| 73 | #define free_thread_info(ti) kfree(ti) | 81 | #define free_thread_info(ti) kfree(ti) |
| 74 | #define get_thread_info(ti) get_task_struct((ti)->task) | 82 | #define get_thread_info(ti) get_task_struct((ti)->task) |
| @@ -77,9 +85,11 @@ struct thread_info { | |||
| 77 | /* how to get the thread information struct from C */ | 85 | /* how to get the thread information struct from C */ |
| 78 | static inline struct thread_info *current_thread_info(void) | 86 | static inline struct thread_info *current_thread_info(void) |
| 79 | { | 87 | { |
| 80 | struct thread_info *ti; | 88 | register unsigned long sp asm("r1"); |
| 81 | __asm__("clrrdi %0,1,%1" : "=r"(ti) : "i" (THREAD_SHIFT)); | 89 | |
| 82 | return ti; | 90 | /* gcc4, at least, is smart enough to turn this into a single |
| 91 | * rlwinm for ppc32 and clrrdi for ppc64 */ | ||
| 92 | return (struct thread_info *)(sp & ~(THREAD_SIZE-1)); | ||
| 83 | } | 93 | } |
| 84 | 94 | ||
| 85 | #endif /* __ASSEMBLY__ */ | 95 | #endif /* __ASSEMBLY__ */ |
| @@ -122,4 +132,4 @@ static inline struct thread_info *current_thread_info(void) | |||
| 122 | 132 | ||
| 123 | #endif /* __KERNEL__ */ | 133 | #endif /* __KERNEL__ */ |
| 124 | 134 | ||
| 125 | #endif /* _ASM_THREAD_INFO_H */ | 135 | #endif /* _ASM_POWERPC_THREAD_INFO_H */ |
diff --git a/include/asm-ppc/ptrace.h b/include/asm-ppc/ptrace.h index 7043c164b537..c34fb4e37a97 100644 --- a/include/asm-ppc/ptrace.h +++ b/include/asm-ppc/ptrace.h | |||
| @@ -57,7 +57,7 @@ extern unsigned long profile_pc(struct pt_regs *regs); | |||
| 57 | 57 | ||
| 58 | #define force_successful_syscall_return() \ | 58 | #define force_successful_syscall_return() \ |
| 59 | do { \ | 59 | do { \ |
| 60 | current_thread_info()->local_flags |= _TIFL_FORCE_NOERROR; \ | 60 | current_thread_info()->syscall_noerror = 1; \ |
| 61 | } while(0) | 61 | } while(0) |
| 62 | 62 | ||
| 63 | /* | 63 | /* |
diff --git a/include/asm-ppc/thread_info.h b/include/asm-ppc/thread_info.h deleted file mode 100644 index 27903db42efc..000000000000 --- a/include/asm-ppc/thread_info.h +++ /dev/null | |||
| @@ -1,107 +0,0 @@ | |||
| 1 | /* thread_info.h: PPC low-level thread information | ||
| 2 | * adapted from the i386 version by Paul Mackerras | ||
| 3 | * | ||
| 4 | * Copyright (C) 2002 David Howells (dhowells@redhat.com) | ||
| 5 | * - Incorporating suggestions made by Linus Torvalds and Dave Miller | ||
| 6 | */ | ||
| 7 | |||
| 8 | #ifndef _ASM_THREAD_INFO_H | ||
| 9 | #define _ASM_THREAD_INFO_H | ||
| 10 | |||
| 11 | #ifdef __KERNEL__ | ||
| 12 | #ifndef __ASSEMBLY__ | ||
| 13 | /* | ||
| 14 | * low level task data. | ||
| 15 | * If you change this, change the TI_* offsets below to match. | ||
| 16 | */ | ||
| 17 | struct thread_info { | ||
| 18 | struct task_struct *task; /* main task structure */ | ||
| 19 | struct exec_domain *exec_domain; /* execution domain */ | ||
| 20 | unsigned long flags; /* low level flags */ | ||
| 21 | unsigned long local_flags; /* non-racy flags */ | ||
| 22 | int cpu; /* cpu we're on */ | ||
| 23 | int preempt_count; /* 0 => preemptable, | ||
| 24 | <0 => BUG */ | ||
| 25 | struct restart_block restart_block; | ||
| 26 | }; | ||
| 27 | |||
| 28 | #define INIT_THREAD_INFO(tsk) \ | ||
| 29 | { \ | ||
| 30 | .task = &tsk, \ | ||
| 31 | .exec_domain = &default_exec_domain, \ | ||
| 32 | .flags = 0, \ | ||
| 33 | .local_flags = 0, \ | ||
| 34 | .cpu = 0, \ | ||
| 35 | .preempt_count = 1, \ | ||
| 36 | .restart_block = { \ | ||
| 37 | .fn = do_no_restart_syscall, \ | ||
| 38 | }, \ | ||
| 39 | } | ||
| 40 | |||
| 41 | #define init_thread_info (init_thread_union.thread_info) | ||
| 42 | #define init_stack (init_thread_union.stack) | ||
| 43 | |||
| 44 | /* | ||
| 45 | * macros/functions for gaining access to the thread information structure | ||
| 46 | */ | ||
| 47 | |||
| 48 | /* how to get the thread information struct from C */ | ||
| 49 | static inline struct thread_info *current_thread_info(void) | ||
| 50 | { | ||
| 51 | struct thread_info *ti; | ||
| 52 | __asm__("rlwinm %0,1,0,0,18" : "=r"(ti)); | ||
| 53 | return ti; | ||
| 54 | } | ||
| 55 | |||
| 56 | /* thread information allocation */ | ||
| 57 | #define alloc_thread_info(tsk) ((struct thread_info *) \ | ||
| 58 | __get_free_pages(GFP_KERNEL, 1)) | ||
| 59 | #define free_thread_info(ti) free_pages((unsigned long) (ti), 1) | ||
| 60 | #define get_thread_info(ti) get_task_struct((ti)->task) | ||
| 61 | #define put_thread_info(ti) put_task_struct((ti)->task) | ||
| 62 | #endif /* __ASSEMBLY__ */ | ||
| 63 | |||
| 64 | /* | ||
| 65 | * Size of kernel stack for each process. | ||
| 66 | */ | ||
| 67 | #define THREAD_SIZE 8192 /* 2 pages */ | ||
| 68 | |||
| 69 | #define PREEMPT_ACTIVE 0x10000000 | ||
| 70 | |||
| 71 | /* | ||
| 72 | * thread information flag bit numbers | ||
| 73 | */ | ||
| 74 | #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ | ||
| 75 | #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ | ||
| 76 | #define TIF_SIGPENDING 2 /* | ||
