[PATCH v3 18/23] arm/vdso: Migrate to generic vdso_base
From: Dmitry Safonov
Date: Fri Jun 11 2021 - 14:03:53 EST
Generic way to track the landing vma area.
As a bonus, after unmapping sigpage, kernel won't try to land on its
previous position (due to UNMAPPED_VDSO_BASE check instead of
context.vdso ?= 0 check).
Signed-off-by: Dmitry Safonov <dima@xxxxxxxxxx>
---
arch/arm/Kconfig | 1 +
arch/arm/kernel/process.c | 9 +--------
arch/arm/kernel/signal.c | 6 +++++-
3 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 2df5ad505b8b..edf1cbb908a9 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -23,6 +23,7 @@ config ARM
select ARCH_HAS_SYNC_DMA_FOR_CPU if SWIOTLB
select ARCH_HAS_TEARDOWN_DMA_OPS if MMU
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
+ select ARCH_HAS_VDSO_BASE
select ARCH_HAVE_CUSTOM_GPIO_H
select ARCH_HAVE_NMI_SAFE_CMPXCHG if CPU_V7 || CPU_V7M || CPU_V6K
select ARCH_HAS_GCOV_PROFILE_ALL
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index b863c5525b5d..3a5975d1ace6 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -387,16 +387,9 @@ static unsigned long sigpage_addr(const struct mm_struct *mm,
static struct page *signal_page;
extern struct page *get_signal_page(void);
-static void sigpage_mremap(const struct vm_special_mapping *sm,
- struct vm_area_struct *new_vma)
-{
- current->mm->context.sigpage = new_vma->vm_start;
-}
-
static const struct vm_special_mapping sigpage_mapping = {
.name = "[sigpage]",
.pages = &signal_page,
- .mremap = sigpage_mremap,
};
int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
@@ -434,7 +427,7 @@ int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
goto up_fail;
}
- mm->context.sigpage = addr;
+ mm->vdso_base = (void __user *)addr;
/* Unlike the sigpage, failure to install the vdso is unlikely
* to be fatal to the process, so no error check needed
diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index a3a38d0a4c85..6c0507e84e24 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -451,13 +451,17 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
#ifdef CONFIG_MMU
if (cpsr & MODE32_BIT) {
struct mm_struct *mm = current->mm;
+ unsigned long land = (unsigned long)mm->vdso_base;
+
+ if (land == UNMAPPED_VDSO_BASE)
+ return 1;
/*
* 32-bit code can use the signal return page
* except when the MPU has protected the vectors
* page from PL0
*/
- retcode = mm->context.sigpage + signal_return_offset +
+ retcode = land + signal_return_offset +
(idx << 2) + thumb;
} else
#endif
--
2.31.1