Skip to content

Commit 5cc91e0

Browse files
author
Russell King
committed
Merge branch 'for-rmk/cacheflush-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/will/linux into devel-stable
2 parents cdf0bfb + 97c72d8 commit 5cc91e0

4 files changed

Lines changed: 65 additions & 19 deletions

File tree

‎arch/arm/include/asm/cacheflush.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,7 @@ extern void flush_cache_page(struct vm_area_struct *vma, unsigned long user_addr
268268
* Harvard caches are synchronised for the user space address range.
269269
* This is used for the ARM private sys_cacheflush system call.
270270
*/
271-
#define flush_cache_user_range(start,end) \
272-
__cpuc_coherent_user_range((start) & PAGE_MASK, PAGE_ALIGN(end))
271+
#define flush_cache_user_range(s,e) __cpuc_coherent_user_range(s,e)
273272

274273
/*
275274
* Perform necessary cache operations to ensure that data previously

‎arch/arm/include/asm/thread_info.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ struct cpu_context_save {
4343
__u32 extra[2]; /* Xscale 'acc' register, etc */
4444
};
4545

46+
struct arm_restart_block {
47+
union {
48+
/* For user cache flushing */
49+
struct {
50+
unsigned long start;
51+
unsigned long end;
52+
} cache;
53+
};
54+
};
55+
4656
/*
4757
* low level task data that entry.S needs immediate access to.
4858
* __switch_to() assumes cpu_context follows immediately after cpu_domain.
@@ -68,6 +78,7 @@ struct thread_info {
6878
unsigned long thumbee_state; /* ThumbEE Handler Base register */
6979
#endif
7080
struct restart_block restart_block;
81+
struct arm_restart_block arm_restart_block;
7182
};
7283

7384
#define INIT_THREAD_INFO(tsk) \

‎arch/arm/kernel/entry-common.S‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,10 +442,10 @@ local_restart:
442442
ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine
443443

444444
add r1, sp, #S_OFF
445-
2: mov why, #0 @ no longer a real syscall
446445
cmp scno, #(__ARM_NR_BASE - __NR_SYSCALL_BASE)
447446
eor r0, scno, #__NR_SYSCALL_BASE @ put OS number back
448-
bcs arm_syscall
447+
bcs arm_syscall
448+
2: mov why, #0 @ no longer a real syscall
449449
b sys_ni_syscall @ not private func
450450

451451
#if defined(CONFIG_OABI_COMPAT) || !defined(CONFIG_AEABI)

‎arch/arm/kernel/traps.c‎

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -497,28 +497,64 @@ static int bad_syscall(int n, struct pt_regs *regs)
497497
return regs->ARM_r0;
498498
}
499499

500+
static long do_cache_op_restart(struct restart_block *);
501+
500502
static inline int
501-
do_cache_op(unsigned long start, unsigned long end, int flags)
503+
__do_cache_op(unsigned long start, unsigned long end)
502504
{
503-
struct mm_struct *mm = current->active_mm;
504-
struct vm_area_struct *vma;
505+
int ret;
506+
unsigned long chunk = PAGE_SIZE;
507+
508+
do {
509+
if (signal_pending(current)) {
510+
struct thread_info *ti = current_thread_info();
511+
512+
ti->restart_block = (struct restart_block) {
513+
.fn = do_cache_op_restart,
514+
};
515+
516+
ti->arm_restart_block = (struct arm_restart_block) {
517+
{
518+
.cache = {
519+
.start = start,
520+
.end = end,
521+
},
522+
},
523+
};
524+
525+
return -ERESTART_RESTARTBLOCK;
526+
}
527+
528+
ret = flush_cache_user_range(start, start + chunk);
529+
if (ret)
530+
return ret;
505531

532+
cond_resched();
533+
start += chunk;
534+
} while (start < end);
535+
536+
return 0;
537+
}
538+
539+
static long do_cache_op_restart(struct restart_block *unused)
540+
{
541+
struct arm_restart_block *restart_block;
542+
543+
restart_block = &current_thread_info()->arm_restart_block;
544+
return __do_cache_op(restart_block->cache.start,
545+
restart_block->cache.end);
546+
}
547+
548+
static inline int
549+
do_cache_op(unsigned long start, unsigned long end, int flags)
550+
{
506551
if (end < start || flags)
507552
return -EINVAL;
508553

509-
down_read(&mm->mmap_sem);
510-
vma = find_vma(mm, start);
511-
if (vma && vma->vm_start < end) {
512-
if (start < vma->vm_start)
513-
start = vma->vm_start;
514-
if (end > vma->vm_end)
515-
end = vma->vm_end;
554+
if (!access_ok(VERIFY_READ, start, end - start))
555+
return -EFAULT;
516556

517-
up_read(&mm->mmap_sem);
518-
return flush_cache_user_range(start, end);
519-
}
520-
up_read(&mm->mmap_sem);
521-
return -EINVAL;
557+
return __do_cache_op(start, end);
522558
}
523559

524560
/*

0 commit comments

Comments
 (0)