Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc
Browse files Browse the repository at this point in the history
Pull sparc changes from David S. Miller:
 "This has the generic strncpy_from_user() implementation architectures
  can now use, which we've been developing on linux-arch over the past
  few days.

  For good measure I ran both a 32-bit and a 64-bit glibc testsuite run,
  and the latter of which pointed out an adjustment I needed to make to
  sparc's user_addr_max() definition.  Linus, you were right, STACK_TOP
  was not the right thing to use, even on sparc itself :-)

  From Sam Ravnborg, we have a conversion of sparc32 over to the common
  alloc_thread_info_node(), since the aspect which originally blocked
  our doing so (sun4c) has been removed."

Fix up trivial arch/sparc/Kconfig and lib/Makefile conflicts.

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc:
  sparc: Fix user_addr_max() definition.
  lib: Sparc's strncpy_from_user is generic enough, move under lib/
  kernel: Move REPEAT_BYTE definition into linux/kernel.h
  sparc: Increase portability of strncpy_from_user() implementation.
  sparc: Optimize strncpy_from_user() zero byte search.
  sparc: Add full proper error handling to strncpy_from_user().
  sparc32: use the common implementation of alloc_thread_info_node()
  • Loading branch information
torvalds committed May 24, 2012
2 parents 9978306 + c538983 commit ce00417
Show file tree
Hide file tree
Showing 18 changed files with 170 additions and 238 deletions.
2 changes: 1 addition & 1 deletion arch/sparc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ config SPARC
select GENERIC_SMP_IDLE_THREAD
select GENERIC_CMOS_UPDATE
select GENERIC_CLOCKEVENTS
select GENERIC_STRNCPY_FROM_USER

config SPARC32
def_bool !64BIT
select GENERIC_ATOMIC64
select CLZ_TAB
select ARCH_THREAD_INFO_ALLOCATOR
select ARCH_USES_GETTIMEOFFSET

config SPARC64
Expand Down
4 changes: 3 additions & 1 deletion arch/sparc/include/asm/processor_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
#define TASK_SIZE_OF(tsk) \
(test_tsk_thread_flag(tsk,TIF_32BIT) ? \
(1UL << 32UL) : ((unsigned long)-VPTE_SIZE))
#define TASK_SIZE TASK_SIZE_OF(current)
#define TASK_SIZE \
(test_thread_flag(TIF_32BIT) ? \
(1UL << 32UL) : ((unsigned long)-VPTE_SIZE))
#ifdef __KERNEL__

#define STACK_TOP32 ((1UL << 32UL) - PAGE_SIZE)
Expand Down
11 changes: 2 additions & 9 deletions arch/sparc/include/asm/thread_info_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
/*
* thread information allocation
*/
#define THREAD_INFO_ORDER 1

struct thread_info * alloc_thread_info_node(struct task_struct *tsk, int node);
void free_thread_info(struct thread_info *);
#define THREAD_SIZE_ORDER 1

#endif /* __ASSEMBLY__ */

/*
* Size of kernel stack for each process.
* Observe the order of get_free_pages() in alloc_thread_info_node().
* The sun4 has 8K stack too, because it's short on memory, and 16K is a waste.
*/
/* Size of kernel stack for each process */
#define THREAD_SIZE (2 * PAGE_SIZE)

/*
Expand Down
6 changes: 6 additions & 0 deletions arch/sparc/include/asm/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@
#else
#include <asm/uaccess_32.h>
#endif

#define user_addr_max() \
(segment_eq(get_fs(), USER_DS) ? TASK_SIZE : ~0UL)

extern long strncpy_from_user(char *dest, const char __user *src, long count);

#endif
10 changes: 0 additions & 10 deletions arch/sparc/include/asm/uaccess_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,16 +304,6 @@ static inline unsigned long clear_user(void __user *addr, unsigned long n)
return n;
}

extern long __strncpy_from_user(char *dest, const char __user *src, long count);

static inline long strncpy_from_user(char *dest, const char __user *src, long count)
{
if (__access_ok((unsigned long) src, count))
return __strncpy_from_user(dest, src, count);
else
return -EFAULT;
}

extern long __strlen_user(const char __user *);
extern long __strnlen_user(const char __user *, long len);

Expand Down
4 changes: 0 additions & 4 deletions arch/sparc/include/asm/uaccess_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,6 @@ extern unsigned long __must_check __clear_user(void __user *, unsigned long);

#define clear_user __clear_user

extern long __must_check __strncpy_from_user(char *dest, const char __user *src, long count);

#define strncpy_from_user __strncpy_from_user

extern long __strlen_user(const char __user *);
extern long __strnlen_user(const char __user *, long len);

Expand Down
2 changes: 1 addition & 1 deletion arch/sparc/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ lib-y += strlen.o
lib-y += checksum_$(BITS).o
lib-$(CONFIG_SPARC32) += blockops.o
lib-y += memscan_$(BITS).o memcmp.o strncmp_$(BITS).o
lib-y += strncpy_from_user_$(BITS).o strlen_user_$(BITS).o
lib-y += strlen_user_$(BITS).o
lib-$(CONFIG_SPARC32) += divdi3.o udivdi3.o
lib-$(CONFIG_SPARC32) += copy_user.o locks.o
lib-$(CONFIG_SPARC64) += atomic_64.o
Expand Down
3 changes: 0 additions & 3 deletions arch/sparc/lib/ksyms.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ EXPORT_SYMBOL(memset);
EXPORT_SYMBOL(memmove);
EXPORT_SYMBOL(__bzero);

/* Moving data to/from/in userspace. */
EXPORT_SYMBOL(__strncpy_from_user);

/* Networking helper routines. */
EXPORT_SYMBOL(csum_partial);

Expand Down
47 changes: 0 additions & 47 deletions arch/sparc/lib/strncpy_from_user_32.S

This file was deleted.

133 changes: 0 additions & 133 deletions arch/sparc/lib/strncpy_from_user_64.S

This file was deleted.

1 change: 1 addition & 0 deletions arch/sparc/lib/usercopy.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/bug.h>

void copy_from_user_overflow(void)
Expand Down
27 changes: 0 additions & 27 deletions arch/sparc/mm/srmmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,33 +467,6 @@ void srmmu_unmapiorange(unsigned long virt_addr, unsigned int len)
flush_tlb_all();
}

/*
* On the SRMMU we do not have the problems with limited tlb entries
* for mapping kernel pages, so we just take things from the free page
* pool. As a side effect we are putting a little too much pressure
* on the gfp() subsystem. This setup also makes the logic of the
* iommu mapping code a lot easier as we can transparently handle
* mappings on the kernel stack without any special code.
*/
struct thread_info *alloc_thread_info_node(struct task_struct *tsk, int node)
{
struct thread_info *ret;

ret = (struct thread_info *)__get_free_pages(GFP_KERNEL,
THREAD_INFO_ORDER);
#ifdef CONFIG_DEBUG_STACK_USAGE
if (ret)
memset(ret, 0, PAGE_SIZE << THREAD_INFO_ORDER);
#endif /* DEBUG_STACK_USAGE */

return ret;
}

void free_thread_info(struct thread_info *ti)
{
free_pages((unsigned long)ti, THREAD_INFO_ORDER);
}

/* tsunami.S */
extern void tsunami_flush_cache_all(void);
extern void tsunami_flush_cache_mm(struct mm_struct *mm);
Expand Down
4 changes: 2 additions & 2 deletions arch/x86/include/asm/word-at-a-time.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef _ASM_WORD_AT_A_TIME_H
#define _ASM_WORD_AT_A_TIME_H

#include <linux/kernel.h>

/*
* This is largely generic for little-endian machines, but the
* optimal byte mask counting is probably going to be something
Expand Down Expand Up @@ -35,8 +37,6 @@ static inline long count_masked_bytes(long mask)

#endif

#define REPEAT_BYTE(x) ((~0ul / 0xff) * (x))

/* Return the high bit set in the first byte that is a zero */
static inline unsigned long has_zero(unsigned long a)
{
Expand Down
1 change: 1 addition & 0 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <linux/init.h>
#include <linux/export.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/fs.h>
#include <linux/namei.h>
Expand Down
2 changes: 2 additions & 0 deletions include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

#define STACK_MAGIC 0xdeadbeef

#define REPEAT_BYTE(x) ((~0ul / 0xff) * (x))

#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
#define __ALIGN_MASK(x, mask) __ALIGN_KERNEL_MASK((x), (mask))
#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
Expand Down
3 changes: 3 additions & 0 deletions lib/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ config BITREVERSE
config RATIONAL
boolean

config GENERIC_STRNCPY_FROM_USER
bool

config GENERIC_FIND_FIRST_BIT
bool

Expand Down
2 changes: 2 additions & 0 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ obj-$(CONFIG_CLZ_TAB) += clz_tab.o

obj-$(CONFIG_DDR) += jedec_ddr_data.o

obj-$(CONFIG_GENERIC_STRNCPY_FROM_USER) += strncpy_from_user.o

hostprogs-y := gen_crc32table
clean-files := crc32table.h

Expand Down
Loading

0 comments on commit ce00417

Please sign in to comment.