From: Amanieu d'Antras <amanieu@gmail.com> Cc: Amanieu d'Antras <amanieu@gmail.com>, Ryan Houdek <Houdek.Ryan@fex-emu.org>, Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Steven Price <steven.price@arm.com>, Arnd Bergmann <arnd@kernel.org>, David Laight <David.Laight@aculab.com>, Mark Brown <broonie@kernel.org>, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RESEND PATCH v4 6/8] arm64: Add a compat syscall flag to thread_info Date: Tue, 18 May 2021 10:06:56 +0100 [thread overview] Message-ID: <20210518090658.9519-7-amanieu@gmail.com> (raw) In-Reply-To: <20210518090658.9519-1-amanieu@gmail.com> This flag is used by in_compat_syscall to handle compat syscalls coming from 64-bit tasks. Signed-off-by: Amanieu d'Antras <amanieu@gmail.com> Co-developed-by: Ryan Houdek <Houdek.Ryan@fex-emu.org> Signed-off-by: Ryan Houdek <Houdek.Ryan@fex-emu.org> --- arch/arm64/include/asm/compat.h | 4 ++-- arch/arm64/include/asm/elf.h | 13 ++++++++++++- arch/arm64/include/asm/thread_info.h | 6 ++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h index a2f5001f7793..124f4487dfee 100644 --- a/arch/arm64/include/asm/compat.h +++ b/arch/arm64/include/asm/compat.h @@ -190,13 +190,13 @@ static inline bool is_compat_thread(struct thread_info *thread) static inline bool in_compat_syscall(void) { - return is_compat_task(); + return current_thread_info()->use_compat_syscall; } #define in_compat_syscall in_compat_syscall /* override the generic impl */ static inline bool thread_in_compat_syscall(struct thread_info *thread) { - return is_compat_thread(thread); + return thread->use_compat_syscall; } #else /* !CONFIG_COMPAT */ diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index e21964898d06..49a9a9db612c 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -158,10 +158,20 @@ typedef struct user_fpsimd_state elf_fpregset_t; */ #define ELF_PLAT_INIT(_r, load_addr) (_r)->regs[0] = 0 +#ifdef CONFIG_COMPAT +#define CLEAR_COMPAT_SYSCALL() \ +({ \ + current_thread_info()->use_compat_syscall = false; \ +}) +#else +#define CLEAR_COMPAT_SYSCALL() ((void)0) +#endif + #define SET_PERSONALITY(ex) \ ({ \ clear_thread_flag(TIF_32BIT); \ current->personality &= ~READ_IMPLIES_EXEC; \ + CLEAR_COMPAT_SYSCALL(); \ }) /* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */ @@ -228,7 +238,8 @@ typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG]; #define COMPAT_SET_PERSONALITY(ex) \ ({ \ set_thread_flag(TIF_32BIT); \ - }) + current_thread_info()->use_compat_syscall = true; \ +}) #ifdef CONFIG_COMPAT_VDSO #define COMPAT_ARCH_DLINFO \ do { \ diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h index 6623c99f0984..02310b45900d 100644 --- a/arch/arm64/include/asm/thread_info.h +++ b/arch/arm64/include/asm/thread_info.h @@ -42,6 +42,12 @@ struct thread_info { void *scs_base; void *scs_sp; #endif +#ifdef CONFIG_COMPAT + /* + * compat task or inside a compat syscall from a 64-bit task + */ + bool use_compat_syscall; +#endif }; #define thread_saved_pc(tsk) \ -- 2.31.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-05-18 9:12 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-18 9:06 [RESEND PATCH v4 0/8] arm64: Allow 64-bit tasks to invoke compat syscalls Amanieu d'Antras 2021-05-18 9:06 ` [RESEND PATCH v4 1/8] mm: Add arch_get_mmap_base_topdown macro Amanieu d'Antras 2021-05-18 9:06 ` [RESEND PATCH v4 2/8] hugetlbfs: Use arch_get_mmap_* macros Amanieu d'Antras 2021-05-18 9:06 ` [RESEND PATCH v4 3/8] mm: Support mmap_compat_base with the generic layout Amanieu d'Antras 2021-05-18 9:06 ` [RESEND PATCH v4 4/8] arm64: Separate in_compat_syscall from is_compat_task Amanieu d'Antras 2021-05-18 9:06 ` [RESEND PATCH v4 5/8] arm64: mm: Use HAVE_ARCH_COMPAT_MMAP_BASES Amanieu d'Antras 2021-05-18 9:06 ` Amanieu d'Antras [this message] 2021-05-18 9:06 ` [RESEND PATCH v4 7/8] arm64: Forbid calling compat sigreturn from 64-bit tasks Amanieu d'Antras 2021-05-18 9:06 ` [RESEND PATCH v4 8/8] arm64: Allow 64-bit tasks to invoke compat syscalls Amanieu d'Antras 2021-05-18 13:02 ` Arnd Bergmann 2021-05-18 20:26 ` David Laight 2021-05-18 22:41 ` Ryan Houdek 2021-05-18 23:51 ` Amanieu d'Antras 2021-05-19 15:30 ` Steven Price 2021-05-19 16:14 ` Amanieu d'Antras 2021-05-21 8:51 ` Steven Price 2021-05-21 19:18 ` Amanieu d'Antras 2021-05-24 11:20 ` Steven Price 2021-05-24 12:38 ` David Laight 2021-05-18 23:52 ` Ryan Houdek
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210518090658.9519-7-amanieu@gmail.com \ --to=amanieu@gmail.com \ --cc=David.Laight@aculab.com \ --cc=Houdek.Ryan@fex-emu.org \ --cc=arnd@kernel.org \ --cc=broonie@kernel.org \ --cc=catalin.marinas@arm.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mark.rutland@arm.com \ --cc=steven.price@arm.com \ --cc=will@kernel.org \ --subject='Re: [RESEND PATCH v4 6/8] arm64: Add a compat syscall flag to thread_info' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).