Commit 5cfade5f authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Palmer Dabbelt

riscv: turn mm_segment_t into a struct

This matches what other heavily used architectures do, and will allow us
to easily use <asm-generic/uaccess.h> for the nommu case.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarPalmer Dabbelt <palmer@sifive.com>
parent df720961
...@@ -28,7 +28,9 @@ ...@@ -28,7 +28,9 @@
#include <asm/processor.h> #include <asm/processor.h>
#include <asm/csr.h> #include <asm/csr.h>
typedef unsigned long mm_segment_t; typedef struct {
unsigned long seg;
} mm_segment_t;
/* /*
* low level task data that entry.S needs immediate access to * low level task data that entry.S needs immediate access to
......
...@@ -39,8 +39,10 @@ ...@@ -39,8 +39,10 @@
* For historical reasons, these macros are grossly misnamed. * For historical reasons, these macros are grossly misnamed.
*/ */
#define KERNEL_DS (~0UL) #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
#define USER_DS (TASK_SIZE)
#define KERNEL_DS MAKE_MM_SEG(~0UL)
#define USER_DS MAKE_MM_SEG(TASK_SIZE)
#define get_fs() (current_thread_info()->addr_limit) #define get_fs() (current_thread_info()->addr_limit)
...@@ -49,9 +51,9 @@ static inline void set_fs(mm_segment_t fs) ...@@ -49,9 +51,9 @@ static inline void set_fs(mm_segment_t fs)
current_thread_info()->addr_limit = fs; current_thread_info()->addr_limit = fs;
} }
#define segment_eq(a, b) ((a) == (b)) #define segment_eq(a, b) ((a).seg == (b).seg)
#define user_addr_max() (get_fs()) #define user_addr_max() (get_fs().seg)
/** /**
...@@ -83,7 +85,7 @@ static inline int __access_ok(unsigned long addr, unsigned long size) ...@@ -83,7 +85,7 @@ static inline int __access_ok(unsigned long addr, unsigned long size)
{ {
const mm_segment_t fs = get_fs(); const mm_segment_t fs = get_fs();
return (size <= fs) && (addr <= (fs - size)); return size <= fs.seg && addr <= fs.seg - size;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment