[PATCH] mips: Fix o32 and n32 vDSO compilation

From: Vincenzo Frascino
Date: Mon Jun 24 2019 - 18:46:57 EST


The Unified vDSO implementation does not compile correctly for n32 and
o32 type of binaries on mips64 because the environment is not set
correctly.

Restore the correct behaviour addressing the configuration issues for
the generation of these types of binaries.

[ To be squashed with the "[PATCH v7 19/25] mips: Add support for generic
vDSO" ]

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@xxxxxxx>
---
arch/mips/vdso/Makefile | 6 ++++++
arch/mips/vdso/config-n32-o32-env.c | 17 +++++++++++++++++
2 files changed, 23 insertions(+)
create mode 100644 arch/mips/vdso/config-n32-o32-env.c

diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile
index 95df49402a53..47316964150c 100644
--- a/arch/mips/vdso/Makefile
+++ b/arch/mips/vdso/Makefile
@@ -36,6 +36,12 @@ aflags-vdso := $(ccflags-vdso) \

ifneq ($(c-gettimeofday-y),)
CFLAGS_vgettimeofday.o = -include $(c-gettimeofday-y)
+
+# config-n32-o32-env.c prepares the environment to build a 32bit vDSO
+# library on a 64bit kernel.
+# Note: Needs to be included before than the generic library.
+CFLAGS_vgettimeofday-o32.o = -include config-n32-o32-env.c -include $(c-gettimeofday-y)
+CFLAGS_vgettimeofday-n32.o = -include config-n32-o32-env.c -include $(c-gettimeofday-y)
endif

CFLAGS_REMOVE_vgettimeofday.o = -pg
diff --git a/arch/mips/vdso/config-n32-o32-env.c b/arch/mips/vdso/config-n32-o32-env.c
new file mode 100644
index 000000000000..da4994b2b3e5
--- /dev/null
+++ b/arch/mips/vdso/config-n32-o32-env.c
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Configuration file for O32 and N32 binaries.
+ * Note: To be included before lib/vdso/gettimeofday.c
+ */
+#if defined(CONFIG_MIPS32_O32) || defined(CONFIG_MIPS32_N32)
+/*
+ * In case of a 32 bit VDSO for a 64 bit kernel fake a 32 bit kernel
+ * configuration.
+ */
+#undef CONFIG_64BIT
+
+#define CONFIG_32BIT 1
+#define CONFIG_GENERIC_ATOMIC64 1
+
+#endif
+
--
2.22.0


--------------E09C3611481E52636CE747FD--