Re: [PATCH 24/25] arm64:ilp32: add vdso-ilp32 and use for signal return
Hello colleagues, After all comments, VDSO fix looks like this for me. Note I renamed Andrew's ZERO macro to DELOUSE, as there already is __SC_DELOUSE which does the same, but in C, not asm. Like Bamvor, I'm not sure how we'd apply this patch - standalone or meld to VDSO. I think, VDSO patch is too big and bad-structurized, and if I find how to refactor it, I'll incorporate this fix. Signed-off-by: Yury Norov--- arch/arm64/kernel/asm-offsets.c | 7 +++ arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S | 2 +- arch/arm64/kernel/vdso/gettimeofday.S | 20 +--- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c index e229525..fcfd087 100644 --- a/arch/arm64/kernel/asm-offsets.c +++ b/arch/arm64/kernel/asm-offsets.c @@ -101,6 +101,13 @@ int main(void) DEFINE(TSPEC_TV_SEC, offsetof(struct timespec, tv_sec)); DEFINE(TSPEC_TV_NSEC,offsetof(struct timespec, tv_nsec)); BLANK(); +#ifdef CONFIG_ARM64_ILP32 + DEFINE(COMPAT_TVAL_TV_SEC, offsetof(struct compat_timeval, tv_sec)); + DEFINE(COMPAT_TVAL_TV_USEC, offsetof(struct compat_timeval, tv_usec)); + DEFINE(COMPAT_TSPEC_TV_SEC, offsetof(struct compat_timespec, tv_sec)); + DEFINE(COMPAT_TSPEC_TV_NSEC, offsetof(struct compat_timespec, tv_nsec)); + BLANK(); +#endif DEFINE(TZ_MINWEST, offsetof(struct timezone, tz_minuteswest)); DEFINE(TZ_DSTTIME, offsetof(struct timezone, tz_dsttime)); BLANK(); diff --git a/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S index ddc63fd..d182a8d 100644 --- a/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S +++ b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S @@ -79,7 +79,7 @@ PHDRS */ VERSION { - LINUX_2.6 { + LINUX_2.6.39 { global: __kernel_rt_sigreturn; __kernel_gettimeofday; diff --git a/arch/arm64/kernel/vdso/gettimeofday.S b/arch/arm64/kernel/vdso/gettimeofday.S index efa79e8..a2d8a70 100644 --- a/arch/arm64/kernel/vdso/gettimeofday.S +++ b/arch/arm64/kernel/vdso/gettimeofday.S @@ -25,6 +25,16 @@ #define NSEC_PER_SEC_LO16 0xca00 #define NSEC_PER_SEC_HI16 0x3b9a +#ifdef __LP64__ +#define PTR_REG(n) x##n +#define OFFSET(n) n +#define DELOUSE(n) +#else +#define PTR_REG(n) w##n +#define OFFSET(n) COMPAT_##n +#define DELOUSE(n) mov w##n, w##n +#endif + vdso_data .reqx6 use_syscall.reqw7 seqcnt .reqw8 @@ -51,6 +61,8 @@ seqcnt.reqw8 /* int __kernel_gettimeofday(struct timeval *tv, struct timezone *tz); */ ENTRY(__kernel_gettimeofday) .cfi_startproc + DELOUSE(0) + DELOUSE(1) mov x2, x30 .cfi_register x30, x2 @@ -68,7 +80,7 @@ ENTRY(__kernel_gettimeofday) mov x13, #1000 lsl x13, x13, x12 udivx11, x11, x13 - stp x10, x11, [x0, #TVAL_TV_SEC] + stp PTR_REG(10), PTR_REG(11), [x0, #OFFSET(TVAL_TV_SEC)] 2: /* If tz is NULL, return 0. */ cbz x1, 3f @@ -88,6 +100,7 @@ ENDPROC(__kernel_gettimeofday) /* int __kernel_clock_gettime(clockid_t clock_id, struct timespec *tp); */ ENTRY(__kernel_clock_gettime) .cfi_startproc + DELOUSE(1) cmp w0, #CLOCK_REALTIME ccmpw0, #CLOCK_MONOTONIC, #0x4, ne b.ne2f @@ -159,7 +172,7 @@ ENTRY(__kernel_clock_gettime) 6: /* Store to the user timespec. */ lsr x11, x11, x12 - stp x10, x11, [x1, #TSPEC_TV_SEC] + stp PTR_REG(10), PTR_REG(11), [x1, #OFFSET(TSPEC_TV_SEC)] mov x0, xzr ret 7: @@ -174,6 +187,7 @@ ENDPROC(__kernel_clock_gettime) /* int __kernel_clock_getres(clockid_t clock_id, struct timespec *res); */ ENTRY(__kernel_clock_getres) .cfi_startproc + DELOUSE(1) cmp w0, #CLOCK_REALTIME ccmpw0, #CLOCK_MONOTONIC, #0x4, ne b.ne1f @@ -187,7 +201,7 @@ ENTRY(__kernel_clock_getres) ldr x2, 6f 2: cbz w1, 3f - stp xzr, x2, [x1] + stp PTR_REG(zr), PTR_REG(2), [x1] 3: /* res == NULL. */ mov w0, wzr -- 2.5.0 -- 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 24/25] arm64:ilp32: add vdso-ilp32 and use for signal return
On Wed, May 4, 2016 at 7:24 PM, Zhangjian (Bamvor)wrote: > Hi, > > > On 2016/5/5 7:23, Andrew Pinski wrote: >> >> On Wed, May 4, 2016 at 2:49 PM, Yury Norov >> wrote: >>> >>> On Tue, May 03, 2016 at 08:41:25PM +0800, Zhangjian (Bamvor) wrote: Hi, all After apply this patch with my small testcase, the vsyscall of gettimeofday in ilp32 works in both big endian and small endian. In this patch, I use the different register and offset for ilp32 and lp64. Actually, the COMPAT_TVAL_TV_SEC is same as TVAL_TV_SEC(so as to COMPAT_TSPEC_TV_SEC and TSPEC_TV_SEC). I add it to keep the logic clear. I also change the version of vdso to 4.6. It should change to 2.6.39 if glibc is not update. >>> >>> [...] >>> >>> Hi Bamvor, >>> >>> It works for me as well. Thank you. >>> I'll incorporate it in next submission. >> >> >> We should add the following so we are complaint to the ILP32 ABI >> dealing with pointers don't have to be zero extended for arguments, >> Note ZERO should most likely be ZERO_PTR or something to do that >> effect, I am not so good with names. >> #ifdef __LP64__ >> #define ZERO(n) >> #else >> #define ZERO(n) mov w##n, w##n >> #endif >> >> ... >> ENTRY(__kernel_gettimeofday) >> .cfi_startproc >> ZERO(0) >> ZERO(1) >> ... >> ENTRY(__kernel_clock_gettime) >> .cfi_startproc >> ZERO(1) >> ... >> ENTRY(__kernel_clock_getres) >> .cfi_startproc >> ZERO(1) > > Thanks. I will test and send a new version. Note there is one more patch needed to __kernel_clock_getres to store using 32bit rather than 64bit too. @@ -213,7 +213,7 @@ ENTRY(__kernel_clock_getres) ldr x2, 6f 2: cbz w1, 3f - stp xzr, x2, [x1] + stp PTR_REG(zr), PTR_REG(2), [x1] 3: /* res == NULL. */ mov w0, wzr Thanks, Andrew > > Thanks. > > Bamvor >> >> Thanks, >> Andrew Pinski >> >>> >>> Yury. > > -- 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 24/25] arm64:ilp32: add vdso-ilp32 and use for signal return
Hi, On 2016/5/5 7:23, Andrew Pinski wrote: On Wed, May 4, 2016 at 2:49 PM, Yury Norovwrote: On Tue, May 03, 2016 at 08:41:25PM +0800, Zhangjian (Bamvor) wrote: Hi, all After apply this patch with my small testcase, the vsyscall of gettimeofday in ilp32 works in both big endian and small endian. In this patch, I use the different register and offset for ilp32 and lp64. Actually, the COMPAT_TVAL_TV_SEC is same as TVAL_TV_SEC(so as to COMPAT_TSPEC_TV_SEC and TSPEC_TV_SEC). I add it to keep the logic clear. I also change the version of vdso to 4.6. It should change to 2.6.39 if glibc is not update. [...] Hi Bamvor, It works for me as well. Thank you. I'll incorporate it in next submission. We should add the following so we are complaint to the ILP32 ABI dealing with pointers don't have to be zero extended for arguments, Note ZERO should most likely be ZERO_PTR or something to do that effect, I am not so good with names. #ifdef __LP64__ #define ZERO(n) #else #define ZERO(n) mov w##n, w##n #endif ... ENTRY(__kernel_gettimeofday) .cfi_startproc ZERO(0) ZERO(1) ... ENTRY(__kernel_clock_gettime) .cfi_startproc ZERO(1) ... ENTRY(__kernel_clock_getres) .cfi_startproc ZERO(1) Thanks. I will test and send a new version. Thanks. Bamvor Thanks, Andrew Pinski Yury. -- 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 24/25] arm64:ilp32: add vdso-ilp32 and use for signal return
On Tue, May 03, 2016 at 08:41:25PM +0800, Zhangjian (Bamvor) wrote: > Hi, all > > After apply this patch with my small testcase, the vsyscall of gettimeofday in > ilp32 works in both big endian and small endian. In this patch, I use the > different register and offset for ilp32 and lp64. Actually, the > COMPAT_TVAL_TV_SEC is same as TVAL_TV_SEC(so as to COMPAT_TSPEC_TV_SEC and > TSPEC_TV_SEC). I add it to keep the logic clear. I also change the version > of vdso to 4.6. It should change to 2.6.39 if glibc is not update. > [...] Hi Bamvor, It works for me as well. Thank you. I'll incorporate it in next submission. Yury. -- 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 24/25] arm64:ilp32: add vdso-ilp32 and use for signal return
Hi, yury On 2016/4/13 23:55, Yury Norov wrote: Hi Bamvor, On Wed, Apr 13, 2016 at 05:19:28PM +0800, Zhangjian (Bamvor) wrote: Hi, Yury and Philipp There is a small fix for this patch. Othervise our tools of living patch could not work. Regards Bamvor From e05770efca9f040e0039a4a9c4e0d7d3b2bd13e8 Mon Sep 17 00:00:00 2001 From: Bamvor Jian ZhangDate: Wed, 13 Apr 2016 15:46:28 +0800 Subject: [PATCH] arm64: ilp32: do not check vdso-ilp32-offsets.h when ILP32 disabled vdso-ilp32-offsets.h is the dependency of all the arm64-obj-y. And it does not exist when CONFIG_ARM64_ILP32 is disable which lead to all the arm64-obj-y are re-built unnecessarily. Such rebuild may confuse the sofware(e.g. tools of living patch) which need to know exactly which file(s) is(are) updated. This patch fix this issue by adding the config checker. It looks reasonable and correct. I'll apply your patch in next submission (if it will be needed), otherwise I think, Arnd may apply it. Though, I don't understand much, what 'tools of living patch' means. Could you explain in details what you do, and what goes wrong? Our tools need to monitor the what *.o is changed after recompile. But without this patch, all the object in arch/arm64/kernel is recompiled. Because the vdso-ilp32-offsets.h is dependency of these files, reference this line of patch: +$(call objectify,$(arm64-obj-y)): $(obj)/vdso-ilp32/vdso-ilp32-offsets.h Regards Bamvor Nevertheless, thank you for your attention to this patchset. Yury. Signed-off-by: Bamvor Jian Zhang --- arch/arm64/kernel/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index b43ff12..0f27a10 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -60,5 +60,7 @@ $(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 +ifeq ($(CONFIG_ARM64_ILP32),y) $(call objectify,$(arm64-obj-y)): $(obj)/vdso-ilp32/vdso-ilp32-offsets.h $(obj)/vdso-ilp32/vdso-ilp32-offsets.h: $(obj)/vdso-ilp32 +endif -- 1.8.4.5 On 2016/4/6 6:08, Yury Norov wrote: From: Philipp Tomsich ILP32 VDSO exports next symbols: __kernel_rt_sigreturn; __kernel_gettimeofday; __kernel_clock_gettime; __kernel_clock_getres; What shared object to use, kernel selects depending on result of is_ilp32_compat_task() in arch/arm64/kernel/vdso.c, so it substitutes correct pages and spec. Adjusted to move the move data page before code pages in sync with commit 601255ae3c98fd3a8bb4696425e4f868b4f1 Signed-off-by: Philipp Tomsich Signed-off-by: Christoph Muellner Signed-off-by: Yury Norov --- arch/arm64/include/asm/vdso.h | 6 ++ arch/arm64/kernel/Makefile| 5 ++ arch/arm64/kernel/signal.c| 2 + 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 | 95 +++ arch/arm64/kernel/vdso.c | 61 ++--- 8 files changed, 266 insertions(+), 10 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..649a9a4 100644 --- a/arch/arm64/include/asm/vdso.h +++ b/arch/arm64/include/asm/vdso.h @@ -29,6 +29,12 @@ #include +#ifdef CONFIG_ARM64_ILP32 +#include +#else +#define vdso_offset_sigtramp_ilp32 +#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 09e4373..b43ff12 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -50,6 +50,7 @@ arm64-obj-$(CONFIG_PARAVIRT) += paravirt.o arm64-obj-$(CONFIG_RANDOMIZE_BASE)+= kaslr.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 @@ -57,3 +58,7 @@ extra-y += $(head-y) vmlinux.lds # vDSO -
Re: [PATCH 24/25] arm64:ilp32: add vdso-ilp32 and use for signal return
On Fri, Apr 29, 2016 at 07:30:19PM +0200, Arnd Bergmann wrote: > On Friday 29 April 2016 17:01:55 Catalin Marinas wrote: > > On Wed, Apr 06, 2016 at 01:08:46AM +0300, Yury Norov wrote: > > > ILP32 VDSO exports next symbols: > > > __kernel_rt_sigreturn; > > > __kernel_gettimeofday; > > > __kernel_clock_gettime; > > > __kernel_clock_getres; > > > > [...] > > > > > +$(obj)/gettimeofday-ilp32.o: $(src)/../vdso/gettimeofday.S > > > + $(call if_changed_dep,vdso-ilp32as) > > > > Are struct timeval and timespec the same between ILP32 and LP64? For > > example, __kernel_gettimeofday() assumes TVAL_TV_SEC offset defined in > > asm-offsets.c based on the LP64 timeval. > > No, ilp32 uses the generic 32-bit data structures, which have a 32-bit > time_t. I guess that means it can work for little-endian but not > big-endian, right? I don't think it works for little-endian either. The LP64 struct timeval is 16 bytes while the ILP32 one is 8 bytes. The VDSO gettimeofday is storing 16 bytes (stp x10, x11, [x0, #TVAL_TV_SEC]) -- Catalin -- 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 24/25] arm64:ilp32: add vdso-ilp32 and use for signal return
On Wed, Apr 06, 2016 at 01:08:46AM +0300, Yury Norov wrote: > ILP32 VDSO exports next symbols: > __kernel_rt_sigreturn; > __kernel_gettimeofday; > __kernel_clock_gettime; > __kernel_clock_getres; [...] > +$(obj)/gettimeofday-ilp32.o: $(src)/../vdso/gettimeofday.S > + $(call if_changed_dep,vdso-ilp32as) Are struct timeval and timespec the same between ILP32 and LP64? For example, __kernel_gettimeofday() assumes TVAL_TV_SEC offset defined in asm-offsets.c based on the LP64 timeval. > +$(obj)/sigreturn-ilp32.o: $(src)/../vdso/sigreturn.S > + $(call if_changed_dep,vdso-ilp32as) This one should be fine because ILP32 uses the same generic __NR_rt_sigreturn syscall number. -- Catalin -- 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 24/25] arm64:ilp32: add vdso-ilp32 and use for signal return
Hi Bamvor, On Wed, Apr 13, 2016 at 05:19:28PM +0800, Zhangjian (Bamvor) wrote: > Hi, Yury and Philipp > > There is a small fix for this patch. Othervise our tools of living > patch could not work. > > Regards > > Bamvor > > From e05770efca9f040e0039a4a9c4e0d7d3b2bd13e8 Mon Sep 17 00:00:00 2001 > From: Bamvor Jian Zhang> Date: Wed, 13 Apr 2016 15:46:28 +0800 > Subject: [PATCH] arm64: ilp32: do not check vdso-ilp32-offsets.h when ILP32 > disabled > > vdso-ilp32-offsets.h is the dependency of all the arm64-obj-y. And > it does not exist when CONFIG_ARM64_ILP32 is disable which lead to > all the arm64-obj-y are re-built unnecessarily. > > Such rebuild may confuse the sofware(e.g. tools of living patch) > which need to know exactly which file(s) is(are) updated. > > This patch fix this issue by adding the config checker. It looks reasonable and correct. I'll apply your patch in next submission (if it will be needed), otherwise I think, Arnd may apply it. Though, I don't understand much, what 'tools of living patch' means. Could you explain in details what you do, and what goes wrong? Nevertheless, thank you for your attention to this patchset. Yury. > > Signed-off-by: Bamvor Jian Zhang > --- > arch/arm64/kernel/Makefile | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile > index b43ff12..0f27a10 100644 > --- a/arch/arm64/kernel/Makefile > +++ b/arch/arm64/kernel/Makefile > @@ -60,5 +60,7 @@ $(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 > +ifeq ($(CONFIG_ARM64_ILP32),y) > $(call objectify,$(arm64-obj-y)): $(obj)/vdso-ilp32/vdso-ilp32-offsets.h > $(obj)/vdso-ilp32/vdso-ilp32-offsets.h: $(obj)/vdso-ilp32 > +endif > -- > 1.8.4.5 > > On 2016/4/6 6:08, Yury Norov wrote: > >From: Philipp Tomsich > > > >ILP32 VDSO exports next symbols: > > __kernel_rt_sigreturn; > > __kernel_gettimeofday; > > __kernel_clock_gettime; > > __kernel_clock_getres; > > > >What shared object to use, kernel selects depending on result of > >is_ilp32_compat_task() in arch/arm64/kernel/vdso.c, so it substitutes > >correct pages and spec. > > > >Adjusted to move the move data page before code pages in sync with > >commit 601255ae3c98fd3a8bb4696425e4f868b4f1 > > > >Signed-off-by: Philipp Tomsich > >Signed-off-by: Christoph Muellner > >Signed-off-by: Yury Norov > >--- > > arch/arm64/include/asm/vdso.h | 6 ++ > > arch/arm64/kernel/Makefile| 5 ++ > > arch/arm64/kernel/signal.c| 2 + > > 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 | 95 > > +++ > > arch/arm64/kernel/vdso.c | 61 ++--- > > 8 files changed, 266 insertions(+), 10 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..649a9a4 100644 > >--- a/arch/arm64/include/asm/vdso.h > >+++ b/arch/arm64/include/asm/vdso.h > >@@ -29,6 +29,12 @@ > > > > #include > > > >+#ifdef CONFIG_ARM64_ILP32 > >+#include > >+#else > >+#define vdso_offset_sigtramp_ilp32 > >+#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 09e4373..b43ff12 100644 > >--- a/arch/arm64/kernel/Makefile > >+++ b/arch/arm64/kernel/Makefile > >@@ -50,6 +50,7 @@ arm64-obj-$(CONFIG_PARAVIRT) += paravirt.o > > arm64-obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.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 > >@@ -57,3 +58,7 @@ extra-y+= $(head-y) > >vmlinux.lds > > # vDSO - this must be built first to generate the symbol offsets > > $(call objectify,$(arm64-obj-y)):
Re: [PATCH 24/25] arm64:ilp32: add vdso-ilp32 and use for signal return
Hi, Yury and Philipp There is a small fix for this patch. Othervise our tools of living patch could not work. Regards Bamvor From e05770efca9f040e0039a4a9c4e0d7d3b2bd13e8 Mon Sep 17 00:00:00 2001 From: Bamvor Jian ZhangDate: Wed, 13 Apr 2016 15:46:28 +0800 Subject: [PATCH] arm64: ilp32: do not check vdso-ilp32-offsets.h when ILP32 disabled vdso-ilp32-offsets.h is the dependency of all the arm64-obj-y. And it does not exist when CONFIG_ARM64_ILP32 is disable which lead to all the arm64-obj-y are re-built unnecessarily. Such rebuild may confuse the sofware(e.g. tools of living patch) which need to know exactly which file(s) is(are) updated. This patch fix this issue by adding the config checker. Signed-off-by: Bamvor Jian Zhang --- arch/arm64/kernel/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index b43ff12..0f27a10 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -60,5 +60,7 @@ $(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 +ifeq ($(CONFIG_ARM64_ILP32),y) $(call objectify,$(arm64-obj-y)): $(obj)/vdso-ilp32/vdso-ilp32-offsets.h $(obj)/vdso-ilp32/vdso-ilp32-offsets.h: $(obj)/vdso-ilp32 +endif -- 1.8.4.5 On 2016/4/6 6:08, Yury Norov wrote: From: Philipp Tomsich ILP32 VDSO exports next symbols: __kernel_rt_sigreturn; __kernel_gettimeofday; __kernel_clock_gettime; __kernel_clock_getres; What shared object to use, kernel selects depending on result of is_ilp32_compat_task() in arch/arm64/kernel/vdso.c, so it substitutes correct pages and spec. Adjusted to move the move data page before code pages in sync with commit 601255ae3c98fd3a8bb4696425e4f868b4f1 Signed-off-by: Philipp Tomsich Signed-off-by: Christoph Muellner Signed-off-by: Yury Norov --- arch/arm64/include/asm/vdso.h | 6 ++ arch/arm64/kernel/Makefile| 5 ++ arch/arm64/kernel/signal.c| 2 + 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 | 95 +++ arch/arm64/kernel/vdso.c | 61 ++--- 8 files changed, 266 insertions(+), 10 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..649a9a4 100644 --- a/arch/arm64/include/asm/vdso.h +++ b/arch/arm64/include/asm/vdso.h @@ -29,6 +29,12 @@ #include +#ifdef CONFIG_ARM64_ILP32 +#include +#else +#define vdso_offset_sigtramp_ilp32 +#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 09e4373..b43ff12 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -50,6 +50,7 @@ arm64-obj-$(CONFIG_PARAVIRT) += paravirt.o arm64-obj-$(CONFIG_RANDOMIZE_BASE)+= kaslr.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 @@ -57,3 +58,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 45bcd96..933cdcf 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -264,6 +264,8 @@ void setup_return(struct pt_regs *regs, struct k_sigaction *ka, if (ka->sa.sa_flags & SA_RESTORER) sigtramp = ka->sa.sa_restorer; + else if (is_ilp32_compat_task()) + sigtramp = VDSO_SYMBOL(current->mm->context.vdso,
[PATCH 24/25] arm64:ilp32: add vdso-ilp32 and use for signal return
From: Philipp TomsichILP32 VDSO exports next symbols: __kernel_rt_sigreturn; __kernel_gettimeofday; __kernel_clock_gettime; __kernel_clock_getres; What shared object to use, kernel selects depending on result of is_ilp32_compat_task() in arch/arm64/kernel/vdso.c, so it substitutes correct pages and spec. Adjusted to move the move data page before code pages in sync with commit 601255ae3c98fd3a8bb4696425e4f868b4f1 Signed-off-by: Philipp Tomsich Signed-off-by: Christoph Muellner Signed-off-by: Yury Norov --- arch/arm64/include/asm/vdso.h | 6 ++ arch/arm64/kernel/Makefile| 5 ++ arch/arm64/kernel/signal.c| 2 + 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 | 95 +++ arch/arm64/kernel/vdso.c | 61 ++--- 8 files changed, 266 insertions(+), 10 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..649a9a4 100644 --- a/arch/arm64/include/asm/vdso.h +++ b/arch/arm64/include/asm/vdso.h @@ -29,6 +29,12 @@ #include +#ifdef CONFIG_ARM64_ILP32 +#include +#else +#define vdso_offset_sigtramp_ilp32 +#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 09e4373..b43ff12 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -50,6 +50,7 @@ arm64-obj-$(CONFIG_PARAVIRT) += paravirt.o arm64-obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.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 @@ -57,3 +58,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 45bcd96..933cdcf 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -264,6 +264,8 @@ void setup_return(struct pt_regs *regs, struct k_sigaction *ka, if (ka->sa.sa_flags & SA_RESTORER) sigtramp = ka->sa.sa_restorer; + else if (is_ilp32_compat_task()) + sigtramp = VDSO_SYMBOL(current->mm->context.vdso, sigtramp_ilp32); else sigtramp = VDSO_SYMBOL(current->mm->context.vdso, sigtramp); diff --git a/arch/arm64/kernel/vdso-ilp32/.gitignore b/arch/arm64/kernel/vdso-ilp32/.gitignore new file mode 100644 index 000..61806c3 --- /dev/null +++ b/arch/arm64/kernel/vdso-ilp32/.gitignore @@ -0,0 +1,2 @@ +vdso-ilp32.lds +vdso-ilp32-offsets.h diff --git a/arch/arm64/kernel/vdso-ilp32/Makefile b/arch/arm64/kernel/vdso-ilp32/Makefile new file mode 100644 index 000..c8f5472 --- /dev/null +++ b/arch/arm64/kernel/vdso-ilp32/Makefile @@ -0,0 +1,72 @@ +# +# Building a vDSO image for AArch64. +# +# Author: Will Deacon +# Heavily based on the vDSO Makefiles for other archs. +# + +obj-ilp32-vdso := gettimeofday-ilp32.o note-ilp32.o sigreturn-ilp32.o + +# Build rules +targets := $(obj-ilp32-vdso) vdso-ilp32.so vdso-ilp32.so.dbg +obj-ilp32-vdso := $(addprefix $(obj)/, $(obj-ilp32-vdso)) + +ccflags-y := -shared -fno-common -fno-builtin +ccflags-y += -nostdlib -Wl,-soname=linux-ilp32-vdso.so.1 \ + $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) + +obj-y += vdso-ilp32.o +extra-y += vdso-ilp32.lds vdso-ilp32-offsets.h +CPPFLAGS_vdso-ilp32.lds += -P -C -U$(ARCH) -mabi=ilp32 + +# Force dependency (incbin is bad) +$(obj)/vdso-ilp32.o : $(obj)/vdso-ilp32.so + +# Link rule for the .so file, .lds has to be first +$(obj)/vdso-ilp32.so.dbg: $(src)/vdso-ilp32.lds $(obj-ilp32-vdso) + $(call