Skip to contentSkip to conversation

arm64: compat: Add a 32-bit vDSO

PATCH New Mark Salyzyn 1 participant 1 message Jan 26, 2018 arm64

lore
Share & tools
lore
#0 lore raw

PATCH v2 4/6 arm64: compat: Add a 32-bit vDSO

From: Kevin Brodsky <[email protected]>

Provide the files necessary for building a compat (AArch32) vDSO in kernel/vdso32.

This is mostly an adaptation of the arm vDSO. The most significant change in vgettimeofday.c is the use of the arm64 vdso_data struct, allowing the vDSO data page to be shared between the 32 and 64-bit vDSOs. Additionally, a different set of barrier macros is used (see aarch32-barrier.h), as we want to support old 32-bit compilers that may not support ARMv8 and its new barrier arguments (*ld).

In addition to the time functions, sigreturn trampolines are also provided, aiming at replacing those in the sigreturn page as the latter don't provide any unwinding information (and it's easier to have just one "user code" page). arm-specific unwinding directives are used, based on glibc's implementation. Symbol offsets are made available to the kernel using the same method as the 64-bit vDSO.

There is unfortunately an important caveat: we cannot get away with hand-coding 32-bit instructions like in kernel/kuser32.S, this time we really need a 32-bit compiler. The compat vDSO Makefile relies on CROSS_COMPILE_ARM32 to provide a 32-bit compiler, appropriate logic will be added to the arm64 Makefile later on to ensure that an attempt to build the compat vDSO is made only if this variable has been set properly.

Take an effort to recode the arm64 vdso code from assembler to C previously submitted by Andrew Pinski <[email protected]>, rework it for use in both arm and arm64, overlapping any optimizations for each architecture.

Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Cc Dave Martin <[email protected]>
Cc "Eric W. Biederman" <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc linux-kernel at vger.kernel.org

v2:
- Ensured CONFIG_64BIT is not defined, side effect is BITS_PER_LONG is correct adding confidence.

---
 arch/arm64/kernel/vdso32/.gitignore      |   2 +
 arch/arm64/kernel/vdso32/Makefile        | 172 +++++++++++++++++++++++++++++++
 arch/arm64/kernel/vdso32/compiler.h      | 122 ++++++++++++++++++++++
 arch/arm64/kernel/vdso32/datapage.h      |   1 +
 arch/arm64/kernel/vdso32/sigreturn.S     |  76 ++++++++++++++
 arch/arm64/kernel/vdso32/vdso.S          |  32 ++++++
 arch/arm64/kernel/vdso32/vdso.lds.S      |  95 +++++++++++++++++
 arch/arm64/kernel/vdso32/vgettimeofday.c |   3 +
 8 files changed, 503 insertions(+)
 create mode 100644 arch/arm64/kernel/vdso32/.gitignore
 create mode 100644 arch/arm64/kernel/vdso32/Makefile
 create mode 100644 arch/arm64/kernel/vdso32/compiler.h
 create mode 100644 arch/arm64/kernel/vdso32/datapage.h
 create mode 100644 arch/arm64/kernel/vdso32/sigreturn.S
 create mode 100644 arch/arm64/kernel/vdso32/vdso.S
 create mode 100644 arch/arm64/kernel/vdso32/vdso.lds.S
 create mode 100644 arch/arm64/kernel/vdso32/vgettimeofday.c
arch/arm64/kernel/vdso32/.gitignore new file +2 -0
new file mode 100644
index 000000000000..4fea950fa5ed
@@ -0,0 +1,2 @@
+vdso.lds
+vdso.so.raw
arch/arm64/kernel/vdso32/Makefile new file +172 -0

172 lines not on this page · raw message

arch/arm64/kernel/vdso32/compiler.h new file +122 -0

122 lines not on this page · raw message

arch/arm64/kernel/vdso32/datapage.h new file +1 -0
new file mode 100644
index 000000000000..fe3e216d94d1
@@ -0,0 +1 @@
+#include "../vdso/datapage.h"
arch/arm64/kernel/vdso32/sigreturn.S new file +76 -0

76 lines not on this page · raw message

arch/arm64/kernel/vdso32/vdso.S new file +32 -0
new file mode 100644
index 000000000000..fe19ff70eb76
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2012 ARM Limited
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Will Deacon <[email protected]>
+ */
+
+#include <linux/init.h>
+#include <linux/linkage.h>
+#include <linux/const.h>
+#include <asm/page.h>
+
+	.globl vdso32_start, vdso32_end
+	.section .rodata
+	.balign PAGE_SIZE
+vdso32_start:
+	.incbin "arch/arm64/kernel/vdso32/vdso.so"
+	.balign PAGE_SIZE
+vdso32_end:
+
+	.previous
arch/arm64/kernel/vdso32/vdso.lds.S new file +95 -0

95 lines not on this page · raw message

arch/arm64/kernel/vdso32/vgettimeofday.c new file +3 -0
new file mode 100644
index 000000000000..b73d4011993d
@@ -0,0 +1,3 @@
+#include "compiler.h"
+#include "datapage.h"
+#include "../../../../lib/vdso/vgettimeofday.c"
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog