2019-07-12 10:18:35

by Naohiro Aota

[permalink] [raw]
Subject: [PATCH v2 1/2] x86/vdso: fix flip/flop vdso build bug

Two consecutive "make" on an already compiled kernel tree will show
different behavior:

$ make
CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
DESCEND objtool
CHK include/generated/compile.h
VDSOCHK arch/x86/entry/vdso/vdso64.so.dbg
VDSOCHK arch/x86/entry/vdso/vdso32.so.dbg
Kernel: arch/x86/boot/bzImage is ready (#3)
Building modules, stage 2.
MODPOST 12 modules

$ make
make
CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
DESCEND objtool
CHK include/generated/compile.h
VDSO arch/x86/entry/vdso/vdso64.so.dbg
OBJCOPY arch/x86/entry/vdso/vdso64.so
VDSO2C arch/x86/entry/vdso/vdso-image-64.c
CC arch/x86/entry/vdso/vdso-image-64.o
VDSO arch/x86/entry/vdso/vdso32.so.dbg
OBJCOPY arch/x86/entry/vdso/vdso32.so
VDSO2C arch/x86/entry/vdso/vdso-image-32.c
CC arch/x86/entry/vdso/vdso-image-32.o
AR arch/x86/entry/vdso/built-in.a
AR arch/x86/entry/built-in.a
AR arch/x86/built-in.a
GEN .version
CHK include/generated/compile.h
UPD include/generated/compile.h
CC init/version.o
AR init/built-in.a
LD vmlinux.o
<snip>

This is causing "LD vmlinux" once every two times even without any
modifications. This is the same bug fixed in commit 92a4728608a8
("x86/boot: Fix if_changed build flip/flop bug"). We cannot use two
"if_changed" in one target. Fix this build bug by merging two commands into
one function.

Cc: Masahiro Yamada <[email protected]>
Fixes: 7ac870747988 ("x86/vdso: Switch to generic vDSO implementation")
Signed-off-by: Naohiro Aota <[email protected]>
---
arch/x86/entry/vdso/Makefile | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index 39106111be86..34773395139a 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -56,8 +56,7 @@ VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -soname linux-vdso.so.1 --no-undefined \
-z max-page-size=4096

$(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) FORCE
- $(call if_changed,vdso)
- $(call if_changed,vdso_check)
+ $(call if_changed,vdso_and_check)

HOST_EXTRACFLAGS += -I$(srctree)/tools/include -I$(srctree)/include/uapi -I$(srctree)/arch/$(SUBARCH)/include/uapi
hostprogs-y += vdso2c
@@ -127,8 +126,7 @@ $(obj)/%.so: $(obj)/%.so.dbg FORCE
$(call if_changed,objcopy)

$(obj)/vdsox32.so.dbg: $(obj)/vdsox32.lds $(vobjx32s) FORCE
- $(call if_changed,vdso)
- $(call if_changed,vdso_check)
+ $(call if_changed,vdso_and_check)

CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds)
VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -soname linux-gate.so.1
@@ -167,8 +165,7 @@ $(obj)/vdso32.so.dbg: FORCE \
$(obj)/vdso32/note.o \
$(obj)/vdso32/system_call.o \
$(obj)/vdso32/sigreturn.o
- $(call if_changed,vdso)
- $(call if_changed,vdso_check)
+ $(call if_changed,vdso_and_check)

#
# The DSO images are built using a special linker script.
@@ -184,6 +181,9 @@ VDSO_LDFLAGS = -shared $(call ld-option, --hash-style=both) \
-Bsymbolic
GCOV_PROFILE := n

+quiet_cmd_vdso_and_check = VDSO $@
+ cmd_vdso_and_check = $(cmd_vdso); $(cmd_vdso_check)
+
#
# Install the unstripped copies of vdso*.so. If our toolchain supports
# build-id, install .build-id links as well.
--
2.22.0


2019-07-12 12:11:52

by Vincenzo Frascino

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] x86/vdso: fix flip/flop vdso build bug

Hi Naohiro,

I was working on a similar patch set, but I just noticed you posted this one.
Thanks for that.

In reply to your series I am adding similar fix for arm64 compat.

On 12/07/2019 11:15, Naohiro Aota wrote:
> Two consecutive "make" on an already compiled kernel tree will show
> different behavior:
>
> $ make
> CALL scripts/checksyscalls.sh
> CALL scripts/atomic/check-atomics.sh
> DESCEND objtool
> CHK include/generated/compile.h
> VDSOCHK arch/x86/entry/vdso/vdso64.so.dbg
> VDSOCHK arch/x86/entry/vdso/vdso32.so.dbg
> Kernel: arch/x86/boot/bzImage is ready (#3)
> Building modules, stage 2.
> MODPOST 12 modules
>
> $ make
> make
> CALL scripts/checksyscalls.sh
> CALL scripts/atomic/check-atomics.sh
> DESCEND objtool
> CHK include/generated/compile.h
> VDSO arch/x86/entry/vdso/vdso64.so.dbg
> OBJCOPY arch/x86/entry/vdso/vdso64.so
> VDSO2C arch/x86/entry/vdso/vdso-image-64.c
> CC arch/x86/entry/vdso/vdso-image-64.o
> VDSO arch/x86/entry/vdso/vdso32.so.dbg
> OBJCOPY arch/x86/entry/vdso/vdso32.so
> VDSO2C arch/x86/entry/vdso/vdso-image-32.c
> CC arch/x86/entry/vdso/vdso-image-32.o
> AR arch/x86/entry/vdso/built-in.a
> AR arch/x86/entry/built-in.a
> AR arch/x86/built-in.a
> GEN .version
> CHK include/generated/compile.h
> UPD include/generated/compile.h
> CC init/version.o
> AR init/built-in.a
> LD vmlinux.o
> <snip>
>
> This is causing "LD vmlinux" once every two times even without any
> modifications. This is the same bug fixed in commit 92a4728608a8
> ("x86/boot: Fix if_changed build flip/flop bug"). We cannot use two
> "if_changed" in one target. Fix this build bug by merging two commands into
> one function.
>
> Cc: Masahiro Yamada <[email protected]>
> Fixes: 7ac870747988 ("x86/vdso: Switch to generic vDSO implementation")
> Signed-off-by: Naohiro Aota <[email protected]>

Reviewed-by: Vincenzo Frascino <[email protected]>
Tested-by: Vincenzo Frascino <[email protected]>

> ---
> arch/x86/entry/vdso/Makefile | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
> index 39106111be86..34773395139a 100644
> --- a/arch/x86/entry/vdso/Makefile
> +++ b/arch/x86/entry/vdso/Makefile
> @@ -56,8 +56,7 @@ VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -soname linux-vdso.so.1 --no-undefined \
> -z max-page-size=4096
>
> $(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) FORCE
> - $(call if_changed,vdso)
> - $(call if_changed,vdso_check)
> + $(call if_changed,vdso_and_check)
>
> HOST_EXTRACFLAGS += -I$(srctree)/tools/include -I$(srctree)/include/uapi -I$(srctree)/arch/$(SUBARCH)/include/uapi
> hostprogs-y += vdso2c
> @@ -127,8 +126,7 @@ $(obj)/%.so: $(obj)/%.so.dbg FORCE
> $(call if_changed,objcopy)
>
> $(obj)/vdsox32.so.dbg: $(obj)/vdsox32.lds $(vobjx32s) FORCE
> - $(call if_changed,vdso)
> - $(call if_changed,vdso_check)
> + $(call if_changed,vdso_and_check)
>
> CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds)
> VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -soname linux-gate.so.1
> @@ -167,8 +165,7 @@ $(obj)/vdso32.so.dbg: FORCE \
> $(obj)/vdso32/note.o \
> $(obj)/vdso32/system_call.o \
> $(obj)/vdso32/sigreturn.o
> - $(call if_changed,vdso)
> - $(call if_changed,vdso_check)
> + $(call if_changed,vdso_and_check)
>
> #
> # The DSO images are built using a special linker script.
> @@ -184,6 +181,9 @@ VDSO_LDFLAGS = -shared $(call ld-option, --hash-style=both) \
> -Bsymbolic
> GCOV_PROFILE := n
>
> +quiet_cmd_vdso_and_check = VDSO $@
> + cmd_vdso_and_check = $(cmd_vdso); $(cmd_vdso_check)
> +
> #
> # Install the unstripped copies of vdso*.so. If our toolchain supports
> # build-id, install .build-id links as well.
>

--
Regards,
Vincenzo

2019-07-12 14:57:38

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] x86/vdso: fix flip/flop vdso build bug

On Fri, Jul 12, 2019 at 7:16 PM Naohiro Aota <[email protected]> wrote:
>
> Two consecutive "make" on an already compiled kernel tree will show
> different behavior:
>
> $ make
> CALL scripts/checksyscalls.sh
> CALL scripts/atomic/check-atomics.sh
> DESCEND objtool
> CHK include/generated/compile.h
> VDSOCHK arch/x86/entry/vdso/vdso64.so.dbg
> VDSOCHK arch/x86/entry/vdso/vdso32.so.dbg
> Kernel: arch/x86/boot/bzImage is ready (#3)
> Building modules, stage 2.
> MODPOST 12 modules
>
> $ make
> make
> CALL scripts/checksyscalls.sh
> CALL scripts/atomic/check-atomics.sh
> DESCEND objtool
> CHK include/generated/compile.h
> VDSO arch/x86/entry/vdso/vdso64.so.dbg
> OBJCOPY arch/x86/entry/vdso/vdso64.so
> VDSO2C arch/x86/entry/vdso/vdso-image-64.c
> CC arch/x86/entry/vdso/vdso-image-64.o
> VDSO arch/x86/entry/vdso/vdso32.so.dbg
> OBJCOPY arch/x86/entry/vdso/vdso32.so
> VDSO2C arch/x86/entry/vdso/vdso-image-32.c
> CC arch/x86/entry/vdso/vdso-image-32.o
> AR arch/x86/entry/vdso/built-in.a
> AR arch/x86/entry/built-in.a
> AR arch/x86/built-in.a
> GEN .version
> CHK include/generated/compile.h
> UPD include/generated/compile.h
> CC init/version.o
> AR init/built-in.a
> LD vmlinux.o
> <snip>
>
> This is causing "LD vmlinux" once every two times even without any
> modifications. This is the same bug fixed in commit 92a4728608a8
> ("x86/boot: Fix if_changed build flip/flop bug"). We cannot use two
> "if_changed" in one target. Fix this build bug by merging two commands into
> one function.
>
> Cc: Masahiro Yamada <[email protected]>
> Fixes: 7ac870747988 ("x86/vdso: Switch to generic vDSO implementation")
> Signed-off-by: Naohiro Aota <[email protected]>
> ---

Reviewed-by: Masahiro Yamada <[email protected]>


--
Best Regards
Masahiro Yamada

Subject: [tip:x86/urgent] x86/vdso: Fix flip/flop vdso build bug

Commit-ID: e9a1379f9219be439f47a0f063431a92dc529eda
Gitweb: https://git.kernel.org/tip/e9a1379f9219be439f47a0f063431a92dc529eda
Author: Naohiro Aota <[email protected]>
AuthorDate: Fri, 12 Jul 2019 19:15:55 +0900
Committer: Thomas Gleixner <[email protected]>
CommitDate: Fri, 12 Jul 2019 17:35:07 +0200

x86/vdso: Fix flip/flop vdso build bug

Two consecutive "make" on an already compiled kernel tree will show
different behavior:

$ make
CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
DESCEND objtool
CHK include/generated/compile.h
VDSOCHK arch/x86/entry/vdso/vdso64.so.dbg
VDSOCHK arch/x86/entry/vdso/vdso32.so.dbg
Kernel: arch/x86/boot/bzImage is ready (#3)
Building modules, stage 2.
MODPOST 12 modules

$ make
make
CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
DESCEND objtool
CHK include/generated/compile.h
VDSO arch/x86/entry/vdso/vdso64.so.dbg
OBJCOPY arch/x86/entry/vdso/vdso64.so
VDSO2C arch/x86/entry/vdso/vdso-image-64.c
CC arch/x86/entry/vdso/vdso-image-64.o
VDSO arch/x86/entry/vdso/vdso32.so.dbg
OBJCOPY arch/x86/entry/vdso/vdso32.so
VDSO2C arch/x86/entry/vdso/vdso-image-32.c
CC arch/x86/entry/vdso/vdso-image-32.o
AR arch/x86/entry/vdso/built-in.a
AR arch/x86/entry/built-in.a
AR arch/x86/built-in.a
GEN .version
CHK include/generated/compile.h
UPD include/generated/compile.h
CC init/version.o
AR init/built-in.a
LD vmlinux.o
<snip>

This is causing "LD vmlinux" once every two times even without any
modifications. This is the same bug fixed in commit 92a4728608a8
("x86/boot: Fix if_changed build flip/flop bug"). Two "if_changed" cannot
be used in one target.

Fix this merging two commands into one function.

Fixes: 7ac870747988 ("x86/vdso: Switch to generic vDSO implementation")
Signed-off-by: Naohiro Aota <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Tested-by: Vincenzo Frascino <[email protected]>
Reviewed-by: Vincenzo Frascino <[email protected]>
Reviewed-by: Masahiro Yamada <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]

---
arch/x86/entry/vdso/Makefile | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index 39106111be86..34773395139a 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -56,8 +56,7 @@ VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -soname linux-vdso.so.1 --no-undefined \
-z max-page-size=4096

$(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) FORCE
- $(call if_changed,vdso)
- $(call if_changed,vdso_check)
+ $(call if_changed,vdso_and_check)

HOST_EXTRACFLAGS += -I$(srctree)/tools/include -I$(srctree)/include/uapi -I$(srctree)/arch/$(SUBARCH)/include/uapi
hostprogs-y += vdso2c
@@ -127,8 +126,7 @@ $(obj)/%.so: $(obj)/%.so.dbg FORCE
$(call if_changed,objcopy)

$(obj)/vdsox32.so.dbg: $(obj)/vdsox32.lds $(vobjx32s) FORCE
- $(call if_changed,vdso)
- $(call if_changed,vdso_check)
+ $(call if_changed,vdso_and_check)

CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds)
VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -soname linux-gate.so.1
@@ -167,8 +165,7 @@ $(obj)/vdso32.so.dbg: FORCE \
$(obj)/vdso32/note.o \
$(obj)/vdso32/system_call.o \
$(obj)/vdso32/sigreturn.o
- $(call if_changed,vdso)
- $(call if_changed,vdso_check)
+ $(call if_changed,vdso_and_check)

#
# The DSO images are built using a special linker script.
@@ -184,6 +181,9 @@ VDSO_LDFLAGS = -shared $(call ld-option, --hash-style=both) \
-Bsymbolic
GCOV_PROFILE := n

+quiet_cmd_vdso_and_check = VDSO $@
+ cmd_vdso_and_check = $(cmd_vdso); $(cmd_vdso_check)
+
#
# Install the unstripped copies of vdso*.so. If our toolchain supports
# build-id, install .build-id links as well.