Skip to content

Commit d6c19bd

Browse files
hramrachmpe
authored andcommitted
powerpc/perf: consolidate read_user_stack_32
There are two almost identical copies for 32bit and 64bit. The function is used only in 32bit code which will be split out in next patch so consolidate to one function. Signed-off-by: Michal Suchanek <[email protected]> Reviewed-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/0c21c919ed1296420199c78f7c3cfd29d3c7e909.1584699455.git.msuchanek@suse.de
1 parent 3dd4eb8 commit d6c19bd

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

arch/powerpc/perf/callchain.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,6 @@ static int read_user_stack_64(unsigned long __user *ptr, unsigned long *ret)
161161
return read_user_stack_slow(ptr, ret, 8);
162162
}
163163

164-
static int read_user_stack_32(unsigned int __user *ptr, unsigned int *ret)
165-
{
166-
if ((unsigned long)ptr > TASK_SIZE - sizeof(unsigned int) ||
167-
((unsigned long)ptr & 3))
168-
return -EFAULT;
169-
170-
if (!probe_user_read(ret, ptr, sizeof(*ret)))
171-
return 0;
172-
173-
return read_user_stack_slow(ptr, ret, 4);
174-
}
175-
176164
static inline int valid_user_sp(unsigned long sp, int is_64)
177165
{
178166
if (!sp || (sp & 7) || sp > (is_64 ? TASK_SIZE : 0x100000000UL) - 32)
@@ -277,19 +265,9 @@ static void perf_callchain_user_64(struct perf_callchain_entry_ctx *entry,
277265
}
278266

279267
#else /* CONFIG_PPC64 */
280-
/*
281-
* On 32-bit we just access the address and let hash_page create a
282-
* HPTE if necessary, so there is no need to fall back to reading
283-
* the page tables. Since this is called at interrupt level,
284-
* do_page_fault() won't treat a DSI as a page fault.
285-
*/
286-
static int read_user_stack_32(unsigned int __user *ptr, unsigned int *ret)
268+
static int read_user_stack_slow(void __user *ptr, void *buf, int nb)
287269
{
288-
if ((unsigned long)ptr > TASK_SIZE - sizeof(unsigned int) ||
289-
((unsigned long)ptr & 3))
290-
return -EFAULT;
291-
292-
return probe_user_read(ret, ptr, sizeof(*ret));
270+
return 0;
293271
}
294272

295273
static inline void perf_callchain_user_64(struct perf_callchain_entry_ctx *entry,
@@ -312,6 +290,28 @@ static inline int valid_user_sp(unsigned long sp, int is_64)
312290

313291
#endif /* CONFIG_PPC64 */
314292

293+
/*
294+
* On 32-bit we just access the address and let hash_page create a
295+
* HPTE if necessary, so there is no need to fall back to reading
296+
* the page tables. Since this is called at interrupt level,
297+
* do_page_fault() won't treat a DSI as a page fault.
298+
*/
299+
static int read_user_stack_32(unsigned int __user *ptr, unsigned int *ret)
300+
{
301+
int rc;
302+
303+
if ((unsigned long)ptr > TASK_SIZE - sizeof(unsigned int) ||
304+
((unsigned long)ptr & 3))
305+
return -EFAULT;
306+
307+
rc = probe_user_read(ret, ptr, sizeof(*ret));
308+
309+
if (IS_ENABLED(CONFIG_PPC64) && rc)
310+
return read_user_stack_slow(ptr, ret, 4);
311+
312+
return rc;
313+
}
314+
315315
/*
316316
* Layout for non-RT signal frames
317317
*/

0 commit comments

Comments
 (0)