linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/3] RISC-V: build: Disable LTO for the vDSO
@ 2021-07-19 20:53 Wende Tan
  2021-07-19 21:19 ` Nick Desaulniers
  0 siblings, 1 reply; 3+ messages in thread
From: Wende Tan @ 2021-07-19 20:53 UTC (permalink / raw)
  To: palmer, paul.walmsley, aou, linux-riscv; +Cc: Wende Tan, clang-built-linux

Disable LTO for the vDSO as done for x86 [1] and arm64 [2].  This also
disables CFI for it [3].

[1] https://patchwork.kernel.org/project/linux-kbuild/patch/20201009161338.657380-28-samitolvanen@google.com/
[2] https://patchwork.kernel.org/project/kernel-hardening/patch/20201211184633.3213045-15-samitolvanen@google.com/
[3] https://lore.kernel.org/bpf/CABCJKucpFHC-9rvT7uNF+E-Jh20fz69zdO49_4p8G_Sb634qmw@mail.gmail.com/

Signed-off-by: Wende Tan <twd2.me@gmail.com>
---
 arch/riscv/kernel/vdso/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
index 24d936c147cd..4535a77792be 100644
--- a/arch/riscv/kernel/vdso/Makefile
+++ b/arch/riscv/kernel/vdso/Makefile
@@ -30,7 +30,7 @@ obj-y += vdso.o vdso-syms.o
 CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
 
 # Disable -pg to prevent insert call site
-CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os
+CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os $(CC_FLAGS_LTO)
 
 # Disable profiling and instrumentation for VDSO code
 GCOV_PROFILE := n
-- 
2.25.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/3] RISC-V: build: Disable LTO for the vDSO
  2021-07-19 20:53 [PATCH 2/3] RISC-V: build: Disable LTO for the vDSO Wende Tan
@ 2021-07-19 21:19 ` Nick Desaulniers
  2021-07-20  9:47   ` twd2
  0 siblings, 1 reply; 3+ messages in thread
From: Nick Desaulniers @ 2021-07-19 21:19 UTC (permalink / raw)
  To: Wende Tan
  Cc: palmer, paul.walmsley, aou, linux-riscv, clang-built-linux, Kees Cook

On Mon, Jul 19, 2021 at 1:53 PM Wende Tan <twd2.me@gmail.com> wrote:
>
> Disable LTO for the vDSO as done for x86 [1] and arm64 [2].  This also
> disables CFI for it [3].
>
> [1] https://patchwork.kernel.org/project/linux-kbuild/patch/20201009161338.657380-28-samitolvanen@google.com/
> [2] https://patchwork.kernel.org/project/kernel-hardening/patch/20201211184633.3213045-15-samitolvanen@google.com/
> [3] https://lore.kernel.org/bpf/CABCJKucpFHC-9rvT7uNF+E-Jh20fz69zdO49_4p8G_Sb634qmw@mail.gmail.com/

It might be nicer to use the typical form for commits:
commit <12 char sha> ("<oneline>")
rather than a mix of patchwork and lore links.

Do you have a list of diagnostics produced when building this object
file with LTO enabled?

>
> Signed-off-by: Wende Tan <twd2.me@gmail.com>
> ---
>  arch/riscv/kernel/vdso/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
> index 24d936c147cd..4535a77792be 100644
> --- a/arch/riscv/kernel/vdso/Makefile
> +++ b/arch/riscv/kernel/vdso/Makefile
> @@ -30,7 +30,7 @@ obj-y += vdso.o vdso-syms.o
>  CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
>
>  # Disable -pg to prevent insert call site
> -CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os
> +CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os $(CC_FLAGS_LTO)
>
>  # Disable profiling and instrumentation for VDSO code
>  GCOV_PROFILE := n
> --
> 2.25.1


-- 
Thanks,
~Nick Desaulniers

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/3] RISC-V: build: Disable LTO for the vDSO
  2021-07-19 21:19 ` Nick Desaulniers
@ 2021-07-20  9:47   ` twd2
  0 siblings, 0 replies; 3+ messages in thread
From: twd2 @ 2021-07-20  9:47 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: palmer, paul.walmsley, aou, linux-riscv, clang-built-linux, Kees Cook

On 2021/7/20 5:19, Nick Desaulniers wrote:
> On Mon, Jul 19, 2021 at 1:53 PM Wende Tan <twd2.me@gmail.com> wrote:
>> Disable LTO for the vDSO as done for x86 [1] and arm64 [2].  This also
>> disables CFI for it [3].
>>
>> [1] https://patchwork.kernel.org/project/linux-kbuild/patch/20201009161338.657380-28-samitolvanen@google.com/
>> [2] https://patchwork.kernel.org/project/kernel-hardening/patch/20201211184633.3213045-15-samitolvanen@google.com/
>> [3] https://lore.kernel.org/bpf/CABCJKucpFHC-9rvT7uNF+E-Jh20fz69zdO49_4p8G_Sb634qmw@mail.gmail.com/
> It might be nicer to use the typical form for commits:
> commit <12 char sha> ("<oneline>")
> rather than a mix of patchwork and lore links.

commit 004d53f8c96f ("arm64: vdso: disable LTO")
commit e242db40be27 ("x86, vdso: disable LTO only for vDSO")

I can put these into the next version.

> Do you have a list of diagnostics produced when building this object
> file with LTO enabled?
Oh, this object can be built with LTO with no issue, but x86 and arm64
seem to disable LTO for it due to no noticeable benefit for the small
amount of C code.
>> Signed-off-by: Wende Tan <twd2.me@gmail.com>
>> ---
>>  arch/riscv/kernel/vdso/Makefile | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
>> index 24d936c147cd..4535a77792be 100644
>> --- a/arch/riscv/kernel/vdso/Makefile
>> +++ b/arch/riscv/kernel/vdso/Makefile
>> @@ -30,7 +30,7 @@ obj-y += vdso.o vdso-syms.o
>>  CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
>>
>>  # Disable -pg to prevent insert call site
>> -CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os
>> +CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os $(CC_FLAGS_LTO)
>>
>>  # Disable profiling and instrumentation for VDSO code
>>  GCOV_PROFILE := n
>> --
>> 2.25.1

Thanks.
Wende


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-20  9:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-19 20:53 [PATCH 2/3] RISC-V: build: Disable LTO for the vDSO Wende Tan
2021-07-19 21:19 ` Nick Desaulniers
2021-07-20  9:47   ` twd2

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).