Re: [PATCH v2 15/18] sparc64: remove CONFIG_SET_FS support

2022-02-16 Thread Arnd Bergmann
On Wed, Feb 16, 2022 at 7:41 PM Sam Ravnborg  wrote:
> On Wed, Feb 16, 2022 at 07:34:59PM +0100, Sam Ravnborg wrote:

> >
> > I think you somehow missed the Kconfig change, and also the related
> > sparc32 change which continue to have set_fs() after this patch.

Right, thanks for pointing out the issue.

> I now notice the sparc32 bits are in the last patch.
> To avoid breaking bisect-ability on sparc64 I think you need to merge
> the sparc32 changes with this patch, unless the sparc64 changes can
> coexist with CONFIG_SET_FS continue to be set.

I originally had them in the reverse order and broke bisectability during my
rebase. The end result is still fine, but now I need to move the 'select
SET_FS' from CONFIG_SPARC to CONFIG_SPARC32 in this patch
and then remove it again from there in the last step.

I've done that in my local copy now.

 Arnd

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v2 15/18] sparc64: remove CONFIG_SET_FS support

2022-02-16 Thread Sam Ravnborg
Hi Arnd,

On Wed, Feb 16, 2022 at 07:34:59PM +0100, Sam Ravnborg wrote:
> Hi Arnd.
> 
> On Wed, Feb 16, 2022 at 02:13:29PM +0100, Arnd Bergmann wrote:
> > From: Arnd Bergmann 
> > 
> > sparc64 uses address space identifiers to differentiate between kernel
> > and user space, using ASI_P for kernel threads but ASI_AIUS for normal
> > user space, with the option of changing between them.
> > 
> > As nothing really changes the ASI any more, just hardcode ASI_AIUS
> > everywhere. Kernel threads are not allowed to access __user pointers
> > anyway.
> > 
> > Signed-off-by: Arnd Bergmann 
> > ---
> >  arch/sparc/include/asm/processor_64.h   |  4 
> >  arch/sparc/include/asm/switch_to_64.h   |  4 +---
> >  arch/sparc/include/asm/thread_info_64.h |  4 +---
> >  arch/sparc/include/asm/uaccess_64.h | 20 +---
> >  arch/sparc/kernel/process_64.c  | 12 
> >  arch/sparc/kernel/traps_64.c|  2 --
> >  arch/sparc/lib/NGmemcpy.S   |  3 +--
> >  arch/sparc/mm/init_64.c |  7 ---
> >  8 files changed, 8 insertions(+), 48 deletions(-)
> 
> I think you somehow missed the Kconfig change, and also the related
> sparc32 change which continue to have set_fs() after this patch.
I now notice the sparc32 bits are in the last patch.
To avoid breaking bisect-ability on sparc64 I think you need to merge
the sparc32 changes with this patch, unless the sparc64 changes can
coexist with CONFIG_SET_FS continue to be set.

Sam

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v2 15/18] sparc64: remove CONFIG_SET_FS support

2022-02-16 Thread Sam Ravnborg
Hi Arnd.

On Wed, Feb 16, 2022 at 02:13:29PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann 
> 
> sparc64 uses address space identifiers to differentiate between kernel
> and user space, using ASI_P for kernel threads but ASI_AIUS for normal
> user space, with the option of changing between them.
> 
> As nothing really changes the ASI any more, just hardcode ASI_AIUS
> everywhere. Kernel threads are not allowed to access __user pointers
> anyway.
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  arch/sparc/include/asm/processor_64.h   |  4 
>  arch/sparc/include/asm/switch_to_64.h   |  4 +---
>  arch/sparc/include/asm/thread_info_64.h |  4 +---
>  arch/sparc/include/asm/uaccess_64.h | 20 +---
>  arch/sparc/kernel/process_64.c  | 12 
>  arch/sparc/kernel/traps_64.c|  2 --
>  arch/sparc/lib/NGmemcpy.S   |  3 +--
>  arch/sparc/mm/init_64.c |  7 ---
>  8 files changed, 8 insertions(+), 48 deletions(-)

I think you somehow missed the Kconfig change, and also the related
sparc32 change which continue to have set_fs() after this patch.


I did not manage to review the patch - as I am too unfamiliar with the
code paths and the set_fs() removal changes.

Sam

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH v2 15/18] sparc64: remove CONFIG_SET_FS support

2022-02-16 Thread Arnd Bergmann
From: Arnd Bergmann 

sparc64 uses address space identifiers to differentiate between kernel
and user space, using ASI_P for kernel threads but ASI_AIUS for normal
user space, with the option of changing between them.

As nothing really changes the ASI any more, just hardcode ASI_AIUS
everywhere. Kernel threads are not allowed to access __user pointers
anyway.

Signed-off-by: Arnd Bergmann 
---
 arch/sparc/include/asm/processor_64.h   |  4 
 arch/sparc/include/asm/switch_to_64.h   |  4 +---
 arch/sparc/include/asm/thread_info_64.h |  4 +---
 arch/sparc/include/asm/uaccess_64.h | 20 +---
 arch/sparc/kernel/process_64.c  | 12 
 arch/sparc/kernel/traps_64.c|  2 --
 arch/sparc/lib/NGmemcpy.S   |  3 +--
 arch/sparc/mm/init_64.c |  7 ---
 8 files changed, 8 insertions(+), 48 deletions(-)

diff --git a/arch/sparc/include/asm/processor_64.h 
b/arch/sparc/include/asm/processor_64.h
index ae851e8fce4c..89850dff6b03 100644
--- a/arch/sparc/include/asm/processor_64.h
+++ b/arch/sparc/include/asm/processor_64.h
@@ -47,10 +47,6 @@
 
 #ifndef __ASSEMBLY__
 
-typedef struct {
-   unsigned char seg;
-} mm_segment_t;
-
 /* The Sparc processor specific thread struct. */
 /* XXX This should die, everything can go into thread_info now. */
 struct thread_struct {
diff --git a/arch/sparc/include/asm/switch_to_64.h 
b/arch/sparc/include/asm/switch_to_64.h
index b1d4e2e3210f..14f3c49bfdbc 100644
--- a/arch/sparc/include/asm/switch_to_64.h
+++ b/arch/sparc/include/asm/switch_to_64.h
@@ -20,10 +20,8 @@ do { \
 */
 #define switch_to(prev, next, last)\
 do {   save_and_clear_fpu();   \
-   /* If you are tempted to conditionalize the following */\
-   /* so that ASI is only written if it changes, think again. */   \
__asm__ __volatile__("wr %%g0, %0, %%asi"   \
-   : : "r" (task_thread_info(next)->current_ds));\
+   : : "r" (ASI_AIUS));\
trap_block[current_thread_info()->cpu].thread = \
task_thread_info(next); \
__asm__ __volatile__(   \
diff --git a/arch/sparc/include/asm/thread_info_64.h 
b/arch/sparc/include/asm/thread_info_64.h
index 8047a9caab2f..1a44372e2bc0 100644
--- a/arch/sparc/include/asm/thread_info_64.h
+++ b/arch/sparc/include/asm/thread_info_64.h
@@ -46,7 +46,7 @@ struct thread_info {
struct pt_regs  *kregs;
int preempt_count;  /* 0 => preemptable, <0 => BUG 
*/
__u8new_child;
-   __u8current_ds;
+   __u8__pad;
__u16   cpu;
 
unsigned long   *utraps;
@@ -81,7 +81,6 @@ struct thread_info {
 #define TI_KREGS   0x0028
 #define TI_PRE_COUNT   0x0030
 #define TI_NEW_CHILD   0x0034
-#define TI_CURRENT_DS  0x0035
 #define TI_CPU 0x0036
 #define TI_UTRAPS  0x0038
 #define TI_REG_WINDOW  0x0040
@@ -116,7 +115,6 @@ struct thread_info {
 #define INIT_THREAD_INFO(tsk)  \
 {  \
.task   =   &tsk,   \
-   .current_ds =   ASI_P,  \
.preempt_count  =   INIT_PREEMPT_COUNT, \
.kregs  =   (struct pt_regs *)(init_stack+THREAD_SIZE)-1 \
 }
diff --git a/arch/sparc/include/asm/uaccess_64.h 
b/arch/sparc/include/asm/uaccess_64.h
index 59b9a545df23..94266a5c5b04 100644
--- a/arch/sparc/include/asm/uaccess_64.h
+++ b/arch/sparc/include/asm/uaccess_64.h
@@ -12,33 +12,15 @@
 #include 
 
 #include 
+#include 
 
 /*
  * Sparc64 is segmented, though more like the M68K than the I386.
  * We use the secondary ASI to address user memory, which references a
  * completely different VM map, thus there is zero chance of the user
  * doing something queer and tricking us into poking kernel memory.
- *
- * What is left here is basically what is needed for the other parts of
- * the kernel that expect to be able to manipulate, erum, "segments".
- * Or perhaps more properly, permissions.
- *
- * "For historical reasons, these macros are grossly misnamed." -Linus
  */
 
-#define KERNEL_DS   ((mm_segment_t) { ASI_P })
-#define USER_DS ((mm_segment_t) { ASI_AIUS })  /* har har har */
-
-#define get_fs() ((mm_segment_t){(current_thread_info()->current_ds)})
-
-#include 
-
-#define set_fs(val)
\
-do {   
\
-   current_thread_info()->current_ds = (val).seg;  
\
-   __asm__ __volatile__ ("wr %%g0, %0, %%