powerpc/vdso: Replace vdso_base by vdso
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Sun, 27 Sep 2020 09:16:29 +0000 (09:16 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 3 Dec 2020 14:01:16 +0000 (01:01 +1100)
All other architectures but s390 use a void pointer named 'vdso'
to reference the VDSO mapping.

In a following patch, the VDSO data page will be put in front of
text, vdso_base will then not anymore point to VDSO text.

To avoid confusion between vdso_base and VDSO text, rename vdso_base
into vdso and make it a void __user *.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/8e6cefe474aa4ceba028abb729485cd46c140990.1601197618.git.christophe.leroy@csgroup.eu
13 files changed:
arch/powerpc/include/asm/book3s/32/mmu-hash.h
arch/powerpc/include/asm/book3s/64/mmu.h
arch/powerpc/include/asm/elf.h
arch/powerpc/include/asm/mmu_context.h
arch/powerpc/include/asm/nohash/32/mmu-40x.h
arch/powerpc/include/asm/nohash/32/mmu-44x.h
arch/powerpc/include/asm/nohash/32/mmu-8xx.h
arch/powerpc/include/asm/nohash/mmu-book3e.h
arch/powerpc/kernel/signal_32.c
arch/powerpc/kernel/signal_64.c
arch/powerpc/kernel/vdso.c
arch/powerpc/perf/callchain_32.c
arch/powerpc/perf/callchain_64.c

index 2e277ca0170fbb1d344ba9018ec279fdd95a5801..3311876612365ce0556af09f1b75aad193cf46df 100644 (file)
@@ -90,7 +90,7 @@ struct hash_pte {
 
 typedef struct {
        unsigned long id;
-       unsigned long vdso_base;
+       void __user *vdso;
 } mm_context_t;
 
 void update_bats(void);
index e0b52940e43cb4f6dc2b235d8ff0e984bd306322..ad0837d8076d77604734ea920f25b70495af6eb5 100644 (file)
@@ -111,7 +111,7 @@ typedef struct {
 
        struct hash_mm_context *hash_context;
 
-       unsigned long vdso_base;
+       void __user *vdso;
        /*
         * pagetable fragment support
         */
index 53ed2ca401515a89c21e4d3121d3b9e5a63aaffe..4ecc372c408e93314cd6a9f3eab9ef46cc0bc73c 100644 (file)
@@ -169,7 +169,7 @@ do {                                                                        \
        NEW_AUX_ENT(AT_DCACHEBSIZE, dcache_bsize);                      \
        NEW_AUX_ENT(AT_ICACHEBSIZE, icache_bsize);                      \
        NEW_AUX_ENT(AT_UCACHEBSIZE, ucache_bsize);                      \
-       VDSO_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso_base);  \
+       VDSO_AUX_ENT(AT_SYSINFO_EHDR, (unsigned long)current->mm->context.vdso);\
        ARCH_DLINFO_CACHE_GEOMETRY;                                     \
 } while (0)
 
index e02aa793420b8a43c896499ac74b70d395262361..d54358cb5be1143c5bfc512312bbe8801b92f63f 100644 (file)
@@ -262,8 +262,10 @@ extern void arch_exit_mmap(struct mm_struct *mm);
 static inline void arch_unmap(struct mm_struct *mm,
                              unsigned long start, unsigned long end)
 {
-       if (start <= mm->context.vdso_base && mm->context.vdso_base < end)
-               mm->context.vdso_base = 0;
+       unsigned long vdso_base = (unsigned long)mm->context.vdso;
+
+       if (start <= vdso_base && vdso_base < end)
+               mm->context.vdso = NULL;
 }
 
 #ifdef CONFIG_PPC_MEM_KEYS
index 74f4edb5916e47e7682ed8a0fa5335bf3369a0c4..8a8f13a22cf4e4aafc3442645914da25b490f2cf 100644 (file)
@@ -57,7 +57,7 @@
 typedef struct {
        unsigned int    id;
        unsigned int    active;
-       unsigned long   vdso_base;
+       void __user     *vdso;
 } mm_context_t;
 
 #endif /* !__ASSEMBLY__ */
index 28aa3b339c5e73de1d57b66489dd8fde1f4ebddd..2d92a39d8f2e808ffd8ace7afc0dcc14e8743d6b 100644 (file)
@@ -108,7 +108,7 @@ extern unsigned int tlb_44x_index;
 typedef struct {
        unsigned int    id;
        unsigned int    active;
-       unsigned long   vdso_base;
+       void __user     *vdso;
 } mm_context_t;
 
 /* patch sites */
index 0bd1b144eb76851de95267b8737f14b6ff7359a0..478249959baae4a8d74426107e98c26a640e404d 100644 (file)
@@ -181,7 +181,7 @@ void mmu_pin_tlb(unsigned long top, bool readonly);
 typedef struct {
        unsigned int id;
        unsigned int active;
-       unsigned long vdso_base;
+       void __user *vdso;
        void *pte_frag;
 } mm_context_t;
 
index b410046643126e12ff615a9553f5efe36348dad7..e43a418d3ccd0c38b9d8e5e4209b8cd82a580808 100644 (file)
@@ -238,7 +238,7 @@ extern unsigned int tlbcam_index;
 typedef struct {
        unsigned int    id;
        unsigned int    active;
-       unsigned long   vdso_base;
+       void __user     *vdso;
 } mm_context_t;
 
 /* Page size definitions, common between 32 and 64-bit
index 123682299d4f800885c46389607f2f23e88821b6..e45aafef4c5bb8e4120724a8f86b5d0095323370 100644 (file)
@@ -801,8 +801,8 @@ int handle_rt_signal32(struct ksignal *ksig, sigset_t *oldset,
        }
 
        /* Save user registers on the stack */
-       if (vdso32_rt_sigtramp && tsk->mm->context.vdso_base) {
-               tramp = tsk->mm->context.vdso_base + vdso32_rt_sigtramp;
+       if (vdso32_rt_sigtramp && tsk->mm->context.vdso) {
+               tramp = (unsigned long)tsk->mm->context.vdso + vdso32_rt_sigtramp;
        } else {
                tramp = (unsigned long)mctx->mc_pad;
                /* Set up the sigreturn trampoline: li r0,sigret; sc */
@@ -901,8 +901,8 @@ int handle_signal32(struct ksignal *ksig, sigset_t *oldset,
        else
                unsafe_save_user_regs(regs, mctx, tm_mctx, 1, failed);
 
-       if (vdso32_sigtramp && tsk->mm->context.vdso_base) {
-               tramp = tsk->mm->context.vdso_base + vdso32_sigtramp;
+       if (vdso32_sigtramp && tsk->mm->context.vdso) {
+               tramp = (unsigned long)tsk->mm->context.vdso + vdso32_sigtramp;
        } else {
                tramp = (unsigned long)mctx->mc_pad;
                /* Set up the sigreturn trampoline: li r0,sigret; sc */
index 7df088b9ad0fce3d343b8e71244ee92133f49691..68e850bd5ef7731b33a68a9ba9dd2c229cb0ff84 100644 (file)
@@ -854,8 +854,8 @@ int handle_rt_signal64(struct ksignal *ksig, sigset_t *set,
        tsk->thread.fp_state.fpscr = 0;
 
        /* Set up to return from userspace. */
-       if (vdso64_rt_sigtramp && tsk->mm->context.vdso_base) {
-               regs->nip = tsk->mm->context.vdso_base + vdso64_rt_sigtramp;
+       if (vdso64_rt_sigtramp && tsk->mm->context.vdso) {
+               regs->nip = (unsigned long)tsk->mm->context.vdso + vdso64_rt_sigtramp;
        } else {
                err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
                if (err)
index 2b975759a04d636f14c8e88cb8a02d8e288ddc60..5214cd4909f8e1c939fecc2bfec5eb500c6062b4 100644 (file)
@@ -123,7 +123,7 @@ static int vdso_mremap(const struct vm_special_mapping *sm, struct vm_area_struc
        if (new_size != text_size + PAGE_SIZE)
                return -EINVAL;
 
-       current->mm->context.vdso_base = new_vma->vm_start;
+       current->mm->context.vdso = (void __user *)new_vma->vm_start;
 
        return 0;
 }
@@ -198,7 +198,7 @@ static int __arch_setup_additional_pages(struct linux_binprm *bprm, int uses_int
         * install_special_mapping or the perf counter mmap tracking code
         * will fail to recognise it as a vDSO.
         */
-       current->mm->context.vdso_base = vdso_base;
+       mm->context.vdso = (void __user *)vdso_base;
 
        /*
         * our vma flags don't have VM_WRITE so by default, the process isn't
@@ -221,7 +221,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
        struct mm_struct *mm = current->mm;
        int rc;
 
-       mm->context.vdso_base = 0;
+       mm->context.vdso = NULL;
 
        if (!vdso_ready)
                return 0;
@@ -231,7 +231,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
 
        rc = __arch_setup_additional_pages(bprm, uses_interp);
        if (rc)
-               mm->context.vdso_base = 0;
+               mm->context.vdso = NULL;
 
        mmap_write_unlock(mm);
        return rc;
index 64e4013d8060bf9c10327eb8504b19238b1cadfe..b32e94047fb9856080231dbaeb0356beed982048 100644 (file)
@@ -59,8 +59,8 @@ static int is_sigreturn_32_address(unsigned int nip, unsigned int fp)
 {
        if (nip == fp + offsetof(struct signal_frame_32, mctx.mc_pad))
                return 1;
-       if (vdso32_sigtramp && current->mm->context.vdso_base &&
-           nip == current->mm->context.vdso_base + vdso32_sigtramp)
+       if (vdso32_sigtramp && current->mm->context.vdso &&
+           nip == (unsigned long)current->mm->context.vdso + vdso32_sigtramp)
                return 1;
        return 0;
 }
@@ -70,8 +70,8 @@ static int is_rt_sigreturn_32_address(unsigned int nip, unsigned int fp)
        if (nip == fp + offsetof(struct rt_signal_frame_32,
                                 uc.uc_mcontext.mc_pad))
                return 1;
-       if (vdso32_rt_sigtramp && current->mm->context.vdso_base &&
-           nip == current->mm->context.vdso_base + vdso32_rt_sigtramp)
+       if (vdso32_rt_sigtramp && current->mm->context.vdso &&
+           nip == (unsigned long)current->mm->context.vdso + vdso32_rt_sigtramp)
                return 1;
        return 0;
 }
index 0777b04a0c56b1adf75da8a77f3f47ef747fdc27..6b9c06058c33dbc18d775dc5fdcfc18bb6c19a77 100644 (file)
@@ -68,8 +68,8 @@ static int is_sigreturn_64_address(unsigned long nip, unsigned long fp)
 {
        if (nip == fp + offsetof(struct signal_frame_64, tramp))
                return 1;
-       if (vdso64_rt_sigtramp && current->mm->context.vdso_base &&
-           nip == current->mm->context.vdso_base + vdso64_rt_sigtramp)
+       if (vdso64_rt_sigtramp && current->mm->context.vdso &&
+           nip == (unsigned long)current->mm->context.vdso + vdso64_rt_sigtramp)
                return 1;
        return 0;
 }