From: cov@codeaurora.org (Christopher Covington)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 18/24] ARM64: Add vdso for ILP32 and use it for the signal return
Date: Wed, 10 Sep 2014 10:31:39 -0400 [thread overview]
Message-ID: <541060CB.6000402@codeaurora.org> (raw)
In-Reply-To: <1409779158-30963-19-git-send-email-apinski@cavium.com>
Hi Andrew,
On 09/03/2014 05:19 PM, Andrew Pinski wrote:
> This patch adds the VDSO for ILP32. We need to use a different
> VDSO than LP64 since ILP32 uses ELF32 while LP64 uses ELF64.
>
> After this patch, signal handling works mostly. In that signals
> go through their action and then returned correctly.
>
> Signed-off-by: Andrew Pinski <apinski@cavium.com>
> ---
> arch/arm64/include/asm/vdso.h | 4 +
> arch/arm64/kernel/Makefile | 5 +
> arch/arm64/kernel/signal.c | 4 +
> arch/arm64/kernel/vdso-ilp32/.gitignore | 2 +
> arch/arm64/kernel/vdso-ilp32/Makefile | 72 ++++++++++++++++++
> arch/arm64/kernel/vdso-ilp32/vdso-ilp32.S | 33 ++++++++
> arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S | 98 +++++++++++++++++++++++++
> arch/arm64/kernel/vdso.c | 69 ++++++++++++++---
> 8 files changed, 274 insertions(+), 13 deletions(-)
> create mode 100644 arch/arm64/kernel/vdso-ilp32/.gitignore
> create mode 100644 arch/arm64/kernel/vdso-ilp32/Makefile
> create mode 100644 arch/arm64/kernel/vdso-ilp32/vdso-ilp32.S
> create mode 100644 arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S
>
> diff --git a/arch/arm64/include/asm/vdso.h b/arch/arm64/include/asm/vdso.h
> index 839ce00..84050c6 100644
> --- a/arch/arm64/include/asm/vdso.h
> +++ b/arch/arm64/include/asm/vdso.h
> @@ -29,6 +29,10 @@
>
> #include <generated/vdso-offsets.h>
>
> +#ifdef CONFIG_ARM64_ILP32
> +#include <generated/vdso-ilp32-offsets.h>
> +#endif
> +
> #define VDSO_SYMBOL(base, name) \
> ({ \
> (void *)(vdso_offset_##name - VDSO_LBASE + (unsigned long)(base)); \
> diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
> index 6de85f5..dcb9033 100644
> --- a/arch/arm64/kernel/Makefile
> +++ b/arch/arm64/kernel/Makefile
> @@ -31,6 +31,7 @@ arm64-obj-$(CONFIG_KGDB) += kgdb.o
> arm64-obj-$(CONFIG_EFI) += efi.o efi-stub.o efi-entry.o
>
> obj-y += $(arm64-obj-y) vdso/
> +obj-$(CONFIG_ARM64_ILP32) += vdso-ilp32/
> obj-m += $(arm64-obj-m)
> head-y := head.o
> extra-y := $(head-y) vmlinux.lds
> @@ -38,3 +39,7 @@ extra-y := $(head-y) vmlinux.lds
> # vDSO - this must be built first to generate the symbol offsets
> $(call objectify,$(arm64-obj-y)): $(obj)/vdso/vdso-offsets.h
> $(obj)/vdso/vdso-offsets.h: $(obj)/vdso
> +
> +# vDSO - this must be built first to generate the symbol offsets
> +$(call objectify,$(arm64-obj-y)): $(obj)/vdso-ilp32/vdso-ilp32-offsets.h
> +$(obj)/vdso-ilp32/vdso-ilp32-offsets.h: $(obj)/vdso-ilp32
> diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
> index f47c064..5311147 100644
> --- a/arch/arm64/kernel/signal.c
> +++ b/arch/arm64/kernel/signal.c
> @@ -242,6 +242,10 @@ static void setup_return(struct pt_regs *regs, struct k_sigaction *ka,
>
> if (ka->sa.sa_flags & SA_RESTORER)
> sigtramp = ka->sa.sa_restorer;
> +#ifdef CONFIG_ARM64_ILP32
> + else if (is_ilp32_compat_task())
> + sigtramp = VDSO_SYMBOL(current->mm->context.vdso, sigtramp_ilp32);
> +#endif
> else
> sigtramp = VDSO_SYMBOL(current->mm->context.vdso, sigtramp);
In my opinion, moving the ifdef around the definition of
is_ilp32_compat_task() would make the code easier to read and maintain.
> diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
> index a777ac3..21b3726 100644
> --- a/arch/arm64/kernel/vdso.c
> +++ b/arch/arm64/kernel/vdso.c
> @@ -41,6 +41,12 @@ extern char vdso_start, vdso_end;
> static unsigned long vdso_pages;
> static struct page **vdso_pagelist;
>
> +#ifdef CONFIG_ARM64_ILP32
> +extern char vdso_ilp32_start, vdso_ilp32_end;
> +static unsigned long vdso_ilp32_pages;
> +static struct page **vdso_ilp32_pagelist;
> +#endif
> +
> /*
> * The vDSO data page.
> */
> @@ -110,24 +116,31 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp)
> }
> #endif /* CONFIG_AARCH32_EL0 */
>
> -static struct vm_special_mapping vdso_spec[2];
> +static struct vm_special_mapping vdso_spec[2][2];
>
> -static int __init vdso_init(void)
> +static inline int __init vdso_init_common(char *vdso_start, char *vdso_end,
> + unsigned long *vdso_pagesp,
> + struct page ***vdso_pagelistp,
> + bool ilp32)
> {
> int i;
> + unsigned long vdso_pages;
> + struct page **vdso_pagelist;
>
> - if (memcmp(&vdso_start, "\177ELF", 4)) {
> + if (memcmp(vdso_start, "\177ELF", 4)) {
> pr_err("vDSO is not a valid ELF object!\n");
> return -EINVAL;
> }
>
> - vdso_pages = (&vdso_end - &vdso_start) >> PAGE_SHIFT;
> + vdso_pages = (vdso_end - vdso_start) >> PAGE_SHIFT;
> + *vdso_pagesp = vdso_pages;
> pr_info("vdso: %ld pages (%ld code @ %p, %ld data @ %p)\n",
> - vdso_pages + 1, vdso_pages, &vdso_start, 1L, vdso_data);
> + vdso_pages + 1, vdso_pages, vdso_start, 1L, vdso_data);
>
> /* Allocate the vDSO pagelist, plus a page for the data. */
> vdso_pagelist = kcalloc(vdso_pages + 1, sizeof(struct page *),
> GFP_KERNEL);
> + *vdso_pagelistp = vdso_pagelist;
> if (vdso_pagelist == NULL)
> return -ENOMEM;
>
> @@ -136,33 +149,63 @@ static int __init vdso_init(void)
>
> /* Grab the vDSO code pages. */
> for (i = 0; i < vdso_pages; i++)
> - vdso_pagelist[i + 1] = virt_to_page(&vdso_start + i * PAGE_SIZE);
> + vdso_pagelist[i + 1] = virt_to_page(vdso_start + i * PAGE_SIZE);
>
> /* Populate the special mapping structures */
> - vdso_spec[0] = (struct vm_special_mapping) {
> + vdso_spec[ilp32][0] = (struct vm_special_mapping) {
> .name = "[vvar]",
> .pages = vdso_pagelist,
> };
>
> - vdso_spec[1] = (struct vm_special_mapping) {
> + vdso_spec[ilp32][1] = (struct vm_special_mapping) {
> .name = "[vdso]",
> .pages = &vdso_pagelist[1],
> };
>
> return 0;
> }
> +
> +static int __init vdso_init(void)
> +{
> + return vdso_init_common(&vdso_start, &vdso_end,
> + &vdso_pages, &vdso_pagelist, 0);
> +}
> arch_initcall(vdso_init);
>
> +#ifdef CONFIG_ARM64_ILP32
> +static int __init vdso_ilp32_init(void)
> +{
> + return vdso_init_common(&vdso_ilp32_start, &vdso_ilp32_end,
> + &vdso_ilp32_pages, &vdso_ilp32_pagelist, 1);
> +}
> +arch_initcall(vdso_ilp32_init);
> +#endif
> +
> int arch_setup_additional_pages(struct linux_binprm *bprm,
> int uses_interp)
> {
> struct mm_struct *mm = current->mm;
> unsigned long vdso_base, vdso_text_len, vdso_mapping_len;
> void *ret;
> -
> - vdso_text_len = vdso_pages << PAGE_SHIFT;
> + struct page **pagelist;
> + unsigned long pages;
> + bool ilp32;
> +
> +#ifdef CONFIG_ARM64_ILP32
> + ilp32 = is_ilp32_compat_task();
> + if (is_ilp32_compat_task()) {
> + pages = vdso_ilp32_pages;
> + pagelist = vdso_ilp32_pagelist;
> + } else
> +#endif
Same
> + {
> + ilp32 = false;
> + pages = vdso_pages;
> + pagelist = vdso_pagelist;
> + }
> + vdso_text_len = pages << PAGE_SHIFT;
> /* Be sure to map the data page */
> - vdso_mapping_len = vdso_text_len + PAGE_SIZE;
> + vdso_mapping_len = (pages + 1) << PAGE_SHIFT;
>
> down_write(&mm->mmap_sem);
> vdso_base = get_unmapped_area(NULL, 0, vdso_mapping_len, 0, 0);
> @@ -172,7 +215,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
> }
> ret = _install_special_mapping(mm, vdso_base, PAGE_SIZE,
> VM_READ|VM_MAYREAD,
> - &vdso_spec[0]);
> + &vdso_spec[ilp32][0]);
> if (IS_ERR(ret))
> goto up_fail;
>
> @@ -181,7 +224,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
> ret = _install_special_mapping(mm, vdso_base, vdso_text_len,
> VM_READ|VM_EXEC|
> VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
> - &vdso_spec[1]);
> + &vdso_spec[ilp32][1]);
> if (IS_ERR(ret))
> goto up_fail;
>
>
Regards,
Christopher
--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by the Linux Foundation.
next prev parent reply other threads:[~2014-09-10 14:31 UTC|newest]
Thread overview: 77+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-03 21:18 [PATCHv3 00/24] ILP32 support in ARM64 Andrew Pinski
2014-09-03 21:18 ` [PATCH 01/24] ARM64: Force LP64 to compile the kernel Andrew Pinski
2014-09-03 21:18 ` [PATCH 02/24] ARM64: Rename COMPAT to AARCH32_EL0 in Kconfig Andrew Pinski
2014-09-03 21:18 ` [PATCH 03/24] ARM64: Change some CONFIG_COMPAT over to use CONFIG_AARCH32_EL0 instead Andrew Pinski
2014-09-03 21:18 ` [PATCH 04/24] ARM64:ILP32: Set kernel_long to long long so we can reuse most of the same syscalls as LP64 Andrew Pinski
2014-09-03 21:18 ` [PATCH 05/24] ARM64:UAPI: Set the correct __BITS_PER_LONG for ILP32 Andrew Pinski
2014-09-03 21:19 ` [PATCH 06/24] Allow for some signal structures to be the same between a 32bit ABI and the 64bit ABI Andrew Pinski
2014-09-03 21:19 ` [PATCH 07/24] ARM64:ILP32: Use the same size and layout of the signal structures for ILP32 as for LP64 Andrew Pinski
2014-09-18 3:41 ` zhangjian
2014-09-03 21:19 ` [PATCH 08/24] Allow a 32bit ABI to use the naming of the 64bit ABI syscalls to avoid confusion of not splitting the registers Andrew Pinski
2014-09-04 10:11 ` Arnd Bergmann
2014-10-01 12:42 ` Catalin Marinas
2014-10-01 14:00 ` Arnd Bergmann
2014-10-02 11:19 ` Catalin Marinas
2014-09-03 21:19 ` [PATCH 09/24] ARM64:ILP32: Use the same syscall names as LP64 Andrew Pinski
2014-10-01 12:48 ` Catalin Marinas
2014-09-03 21:19 ` [PATCH 10/24] ARM64: Introduce is_a32_task/is_a32_thread and TIF_AARCH32 and use them in the correct locations Andrew Pinski
2014-09-03 21:19 ` [PATCH 11/24] ARM64: Add is_ilp32_compat_task and is_ilp32_compat_thread Andrew Pinski
2014-09-03 21:19 ` [PATCH 12/24] ARM64:ILP32: COMPAT_USE_64BIT_TIME is true for ILP32 tasks Andrew Pinski
2014-09-03 21:19 ` [PATCH 13/24] ARM64:ILP32: Use the non compat HWCAP for ILP32 Andrew Pinski
2014-10-01 13:12 ` Catalin Marinas
2014-09-03 21:19 ` [PATCH 14/24] ARM64:ILP32 use the standard start_thread for ILP32 so the processor state is not AARCH32 Andrew Pinski
2014-09-03 21:19 ` [PATCH 15/24] compat_binfmt_elf: coredump: Allow some core dump macros be overridden for compat Andrew Pinski
2014-09-03 21:19 ` [PATCH 16/24] ARM64:ILP32: Support core dump for ILP32 Andrew Pinski
2014-10-01 13:22 ` Catalin Marinas
2014-09-03 21:19 ` [PATCH 17/24] ARM64: Add loading of ILP32 binaries Andrew Pinski
2014-09-03 21:19 ` [PATCH 18/24] ARM64: Add vdso for ILP32 and use it for the signal return Andrew Pinski
2014-09-10 14:31 ` Christopher Covington [this message]
2014-10-01 13:59 ` Catalin Marinas
2014-10-02 13:38 ` Catalin Marinas
2014-09-03 21:19 ` [PATCH 19/24] ptrace: Allow compat to use the native siginfo Andrew Pinski
2014-10-02 14:13 ` Catalin Marinas
2014-09-03 21:19 ` [PATCH 20/24] ARM64:ILP32: The native siginfo is used instead of the compat siginfo Andrew Pinski
2014-09-03 21:19 ` [PATCH 21/24] ARM64:ILP32: Use a seperate syscall table as a few syscalls need to be using the compat syscalls Andrew Pinski
2014-10-02 15:23 ` Catalin Marinas
2014-10-02 15:46 ` Catalin Marinas
2014-09-03 21:19 ` [PATCH 22/24] ARM64:ILP32: Fix signal return for ILP32 when the user modified the signal stack Andrew Pinski
2014-09-03 21:19 ` [PATCH 23/24] ARM64: Add ARM64_ILP32 to Kconfig Andrew Pinski
2014-09-03 21:19 ` [PATCH 24/24] Add documentation about ARM64 ILP32 ABI Andrew Pinski
2014-09-04 10:01 ` Arnd Bergmann
2014-10-02 15:52 ` [PATCHv3 00/24] ILP32 support in ARM64 Catalin Marinas
2015-02-10 18:13 ` Rich Felker
2015-02-11 17:39 ` Catalin Marinas
2015-02-11 19:05 ` [musl] " Szabolcs Nagy
2015-02-11 19:22 ` H.J. Lu
2015-02-11 19:50 ` arnd at arndb.de
2015-02-11 20:12 ` Rich Felker
[not found] ` <1383502854.512344.1423688575473.JavaMail.open-xchange@oxbaltgw09.schlund.de>
2015-02-11 21:09 ` arnd at arndb.de
2015-02-11 21:37 ` Rich Felker
2015-02-16 17:20 ` Arnd Bergmann
2015-02-16 17:51 ` Rich Felker
2015-02-16 19:38 ` Arnd Bergmann
2015-02-12 8:12 ` Szabolcs Nagy
2015-02-12 17:07 ` Catalin Marinas
2015-02-11 19:21 ` Rich Felker
2015-02-12 18:17 ` Catalin Marinas
2015-02-12 18:59 ` arnd at arndb.de
2015-02-13 13:33 ` Catalin Marinas
2015-02-13 16:30 ` Rich Felker
2015-02-13 17:33 ` Catalin Marinas
2015-02-13 18:37 ` Rich Felker
2015-02-16 14:40 ` Arnd Bergmann
2015-02-16 15:38 ` Rich Felker
2015-02-16 16:54 ` Arnd Bergmann
2015-02-11 18:33 ` H.J. Lu
2015-02-11 19:02 ` Rich Felker
2015-02-11 19:16 ` H.J. Lu
2015-02-11 19:25 ` Rich Felker
2015-02-11 19:34 ` H.J. Lu
2015-02-11 19:47 ` Rich Felker
2015-02-11 19:57 ` H.J. Lu
2015-02-11 20:15 ` Andy Lutomirski
2015-02-12 15:50 ` Catalin Marinas
2015-02-12 16:13 ` Rich Felker
2015-02-12 16:30 ` H.J. Lu
2015-02-12 17:00 ` Rich Felker
2015-02-11 21:41 ` Joseph Myers
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=541060CB.6000402@codeaurora.org \
--to=cov@codeaurora.org \
--cc=linux-arm-kernel@lists.infradead.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).