Skip to content

Commit

Permalink
Merge tag 'nios2-5.12-rc1' of git://git.kernel.org/pub/scm/linux/kern…
Browse files Browse the repository at this point in the history
…el/git/lftan/nios2

Pull arch/nios2 updates from Ley Foon Tan:

 - don't use _end for calculating min_low_pfn

 - fix broken sys_clone syscall

 - take mmap lock in cacheflush syscall

* tag 'nios2-5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/lftan/nios2:
  nios2: Don't use _end for calculating min_low_pfn
  nios2: fixed broken sys_clone syscall
  Take mmap lock in cacheflush syscall
  • Loading branch information
torvalds committed Feb 24, 2021
2 parents a555bdd + 7f7bc20 commit b866bc5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
3 changes: 3 additions & 0 deletions arch/nios2/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,10 @@ ENTRY(ret_from_interrupt)
*/
ENTRY(sys_clone)
SAVE_SWITCH_STACK
subi sp, sp, 4 /* make space for tls pointer */
stw r8, 0(sp) /* pass tls pointer (r8) via stack (5th argument) */
call nios2_clone
addi sp, sp, 4
RESTORE_SWITCH_STACK
ret

Expand Down
21 changes: 12 additions & 9 deletions arch/nios2/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ EXPORT_SYMBOL(memory_start);
unsigned long memory_end;
EXPORT_SYMBOL(memory_end);

unsigned long memory_size;

static struct pt_regs fake_regs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0};
Expand Down Expand Up @@ -141,16 +139,22 @@ asmlinkage void __init nios2_boot_init(unsigned r4, unsigned r5, unsigned r6,
parse_early_param();
}

static void __init find_limits(unsigned long *min, unsigned long *max_low,
unsigned long *max_high)
{
*max_low = PFN_DOWN(memblock_get_current_limit());
*min = PFN_UP(memblock_start_of_DRAM());
*max_high = PFN_DOWN(memblock_end_of_DRAM());
}

void __init setup_arch(char **cmdline_p)
{
int dram_start;

console_verbose();

dram_start = memblock_start_of_DRAM();
memory_size = memblock_phys_mem_size();
memory_start = PAGE_ALIGN((unsigned long)__pa(_end));
memory_end = (unsigned long) CONFIG_NIOS2_MEM_BASE + memory_size;
memory_start = memblock_start_of_DRAM();
memory_end = memblock_end_of_DRAM();

init_mm.start_code = (unsigned long) _stext;
init_mm.end_code = (unsigned long) _etext;
Expand All @@ -161,11 +165,10 @@ void __init setup_arch(char **cmdline_p)
/* Keep a copy of command line */
*cmdline_p = boot_command_line;

min_low_pfn = PFN_UP(memory_start);
max_low_pfn = PFN_DOWN(memory_end);
find_limits(&min_low_pfn, &max_low_pfn, &max_pfn);
max_mapnr = max_low_pfn;

memblock_reserve(dram_start, memory_start - dram_start);
memblock_reserve(__pa_symbol(_stext), _end - _stext);
#ifdef CONFIG_BLK_DEV_INITRD
if (initrd_start) {
memblock_reserve(virt_to_phys((void *)initrd_start),
Expand Down
11 changes: 9 additions & 2 deletions arch/nios2/kernel/sys_nios2.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len,
unsigned int op)
{
struct vm_area_struct *vma;
struct mm_struct *mm = current->mm;

if (len == 0)
return 0;
Expand All @@ -34,16 +35,22 @@ asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len,
if (addr + len < addr)
return -EFAULT;

if (mmap_read_lock_killable(mm))
return -EINTR;

/*
* Verify that the specified address region actually belongs
* to this process.
*/
vma = find_vma(current->mm, addr);
if (vma == NULL || addr < vma->vm_start || addr + len > vma->vm_end)
vma = find_vma(mm, addr);
if (vma == NULL || addr < vma->vm_start || addr + len > vma->vm_end) {
mmap_read_unlock(mm);
return -EFAULT;
}

flush_cache_range(vma, addr, addr + len);

mmap_read_unlock(mm);
return 0;
}

Expand Down

0 comments on commit b866bc5

Please sign in to comment.