Re: [PATCH 08/19] arm64: introduce is_a32_task and is_a32_thread (for AArch32 compat)

2016-06-21 Thread Arnd Bergmann
On Tuesday, June 21, 2016 1:34:59 PM CEST Andreas Schwab wrote:
> "Zhangjian (Bamvor)"  writes:
> 
> >> @@ -78,9 +79,9 @@
> >>
> >>   #ifdef CONFIG_COMPAT
> >>   #define TASK_SIZE_32   UL(0x1)
> >> -#define TASK_SIZE   (test_thread_flag(TIF_32BIT) ? \
> >> +#define TASK_SIZE   (is_compat_task() ? \
> >>  TASK_SIZE_32 : TASK_SIZE_64)
> >> -#define TASK_SIZE_OF(tsk)   (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
> >> +#define TASK_SIZE_OF(tsk)   (is_compat_thread(tsk) ? \
> > It should be
> > +#define TASK_SIZE_OF(tsk)  (is_compat_thread(task_thread_info(tsk)) ? \
> > is_compat_thread takes "struct thread_info *thread" while TASK_SIZE_OF takes
> > "struct task_struct *tsk"tsk.
> 
> If that doesn't throw an error does that mean that TASK_SIZE_OF is
> unused?

I think that is correct. On some architectures, TASK_SIZE (which is used)
is defined as TASK_SIZE_OF(current), but the definition above doesn't
do that and there are no other users.

Arnd

--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 08/19] arm64: introduce is_a32_task and is_a32_thread (for AArch32 compat)

2016-06-21 Thread Andreas Schwab
"Zhangjian (Bamvor)"  writes:

>> @@ -78,9 +79,9 @@
>>
>>   #ifdef CONFIG_COMPAT
>>   #define TASK_SIZE_32   UL(0x1)
>> -#define TASK_SIZE   (test_thread_flag(TIF_32BIT) ? \
>> +#define TASK_SIZE   (is_compat_task() ? \
>>  TASK_SIZE_32 : TASK_SIZE_64)
>> -#define TASK_SIZE_OF(tsk)   (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
>> +#define TASK_SIZE_OF(tsk)   (is_compat_thread(tsk) ? \
> It should be
> +#define TASK_SIZE_OF(tsk)  (is_compat_thread(task_thread_info(tsk)) ? \
> is_compat_thread takes "struct thread_info *thread" while TASK_SIZE_OF takes
> "struct task_struct *tsk"tsk.

If that doesn't throw an error does that mean that TASK_SIZE_OF is
unused?

Andreas.

-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 08/19] arm64: introduce is_a32_task and is_a32_thread (for AArch32 compat)

2016-06-21 Thread Zhangjian (Bamvor)

Hi,

On 2016/6/18 7:54, Yury Norov wrote:

Based on patch of Andrew Pinski.

This patch introduces is_a32_compat_task and is_a32_thread so it is
easier to say this is a a32 specific thread or a generic compat thread/task.
Corresponding functions are located in  to avoid mess in
headers.

Some files include both  and ,
and this is wrong because  has  already
included. It was fixed too.

Signed-off-by: Yury Norov 
Signed-off-by: Philipp Tomsich 
Signed-off-by: Christoph Muellner 
Signed-off-by: Andrew Pinski 
Reviewed-by: David Daney 
---
  arch/arm64/include/asm/compat.h  | 19 ++-
  arch/arm64/include/asm/elf.h | 10 +++---
  arch/arm64/include/asm/ftrace.h  |  2 +-
  arch/arm64/include/asm/is_compat.h   | 64 
  arch/arm64/include/asm/memory.h  |  5 +--
  arch/arm64/include/asm/processor.h   |  5 +--
  arch/arm64/include/asm/syscall.h |  2 +-
  arch/arm64/include/asm/thread_info.h |  2 +-
  arch/arm64/kernel/hw_breakpoint.c| 10 +++---
  arch/arm64/kernel/perf_regs.c|  2 +-
  arch/arm64/kernel/process.c  |  7 ++--
  arch/arm64/kernel/ptrace.c   | 11 +++
  arch/arm64/kernel/signal.c   |  4 +--
  arch/arm64/kernel/traps.c|  3 +-
  14 files changed, 98 insertions(+), 48 deletions(-)
  create mode 100644 arch/arm64/include/asm/is_compat.h

diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
index eb8432b..df2f72d 100644
--- a/arch/arm64/include/asm/compat.h
+++ b/arch/arm64/include/asm/compat.h
@@ -24,6 +24,8 @@
  #include 
  #include 

+#include 
+
  #define COMPAT_USER_HZ100
  #ifdef __AARCH64EB__
  #define COMPAT_UTS_MACHINE"armv8b\0\0"
@@ -298,23 +300,6 @@ struct compat_shmid64_ds {
compat_ulong_t __unused5;
  };

-static inline int is_compat_task(void)
-{
-   return test_thread_flag(TIF_32BIT);
-}
-
-static inline int is_compat_thread(struct thread_info *thread)
-{
-   return test_ti_thread_flag(thread, TIF_32BIT);
-}
-
-#else /* !CONFIG_COMPAT */
-
-static inline int is_compat_thread(struct thread_info *thread)
-{
-   return 0;
-}
-
  #endif /* CONFIG_COMPAT */
  #endif /* __KERNEL__ */
  #endif /* __ASM_COMPAT_H */
diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index 579b6e6..bef2d90 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -16,6 +16,10 @@
  #ifndef __ASM_ELF_H
  #define __ASM_ELF_H

+#ifndef __ASSEMBLY__
+#include 
+#endif
+
  #include 

  /*
@@ -152,13 +156,9 @@ extern int arch_setup_additional_pages(struct linux_binprm 
*bprm,
   int uses_interp);

  /* 1GB of VA */
-#ifdef CONFIG_COMPAT
-#define STACK_RND_MASK (test_thread_flag(TIF_32BIT) ? \
+#define STACK_RND_MASK (is_compat_task() ? \
0x7ff >> (PAGE_SHIFT - 12) : \
0x3 >> (PAGE_SHIFT - 12))
-#else
-#define STACK_RND_MASK (0x3 >> (PAGE_SHIFT - 12))
-#endif

  #ifdef __AARCH64EB__
  #define COMPAT_ELF_PLATFORM   ("v8b")
diff --git a/arch/arm64/include/asm/ftrace.h b/arch/arm64/include/asm/ftrace.h
index caa955f..0feb28a 100644
--- a/arch/arm64/include/asm/ftrace.h
+++ b/arch/arm64/include/asm/ftrace.h
@@ -54,7 +54,7 @@ static inline unsigned long ftrace_call_adjust(unsigned long 
addr)
  #define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS
  static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
  {
-   return is_compat_task();
+   return is_a32_compat_task();
  }
  #endif /* ifndef __ASSEMBLY__ */

diff --git a/arch/arm64/include/asm/is_compat.h 
b/arch/arm64/include/asm/is_compat.h
new file mode 100644
index 000..8dba5ca
--- /dev/null
+++ b/arch/arm64/include/asm/is_compat.h
@@ -0,0 +1,64 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see .
+ */
+
+#ifndef __ASM_IS_COMPAT_H
+#define __ASM_IS_COMPAT_H
+#ifndef __ASSEMBLY__
+
+#include 
+
+#ifdef CONFIG_AARCH32_EL0
+
+static inline int is_a32_compat_task(void)
+{
+   return test_thread_flag(TIF_32BIT);
+}
+
+static inline int is_a32_compat_thread(struct thread_info *thread)
+{
+   return test_ti_thread_flag(thread, TIF_32BIT);
+}
+