Re: [Xen-devel] [PATCH v1 01/27] x86/crypto: Adapt assembly for PIE support

2017-10-20 Thread Thomas Garnier
On Fri, Oct 20, 2017 at 1:28 AM, Ard Biesheuvel wrote: > On 20 October 2017 at 09:24, Ingo Molnar wrote: >> >> * Thomas Garnier wrote: >> >>> Change the assembly code to use only relative references of symbols for the >>> kernel to be PIE compatible. >&

Re: [Xen-devel] [PATCH v1 06/27] x86/entry/64: Adapt assembly for PIE support

2017-10-20 Thread Thomas Garnier
On Fri, Oct 20, 2017 at 1:26 AM, Ingo Molnar wrote: > > * Thomas Garnier wrote: > >> Change the assembly code to use only relative references of symbols for the >> kernel to be PIE compatible. >> >> Position Independent Executable (PIE) support will allow to ex

Re: [Xen-devel] [PATCH v1 00/27] x86: PIE support and option to extend KASLR randomization

2017-10-18 Thread Thomas Garnier
On Thu, Oct 12, 2017 at 9:28 AM, Tom Lendacky wrote: > On 10/12/2017 10:34 AM, Thomas Garnier wrote: >> >> On Wed, Oct 11, 2017 at 2:34 PM, Tom Lendacky >> wrote: >>> >>> On 10/11/2017 3:30 PM, Thomas Garnier wrote: >>>> >>&g

Re: [Xen-devel] [PATCH v1 15/27] compiler: Option to default to hidden symbols

2017-10-18 Thread Thomas Garnier
On Thu, Oct 12, 2017 at 1:02 PM, Luis R. Rodriguez wrote: > On Wed, Oct 11, 2017 at 01:30:15PM -0700, Thomas Garnier wrote: >> Provide an option to default visibility to hidden except for key >> symbols. This option is disabled by default and will be used by x86_64 >> PIE sup

Re: [Xen-devel] [PATCH v1 00/27] x86: PIE support and option to extend KASLR randomization

2017-10-12 Thread Thomas Garnier
On Wed, Oct 11, 2017 at 2:34 PM, Tom Lendacky wrote: > On 10/11/2017 3:30 PM, Thomas Garnier wrote: >> Changes: >> - patch v1: >> - Simplify ftrace implementation. >> - Use gcc mstack-protector-guard-reg=%gs with PIE when possible. >> - rfc v3: >

[Xen-devel] [PATCH v1 23/27] x86/modules: Adapt module loading for PIE support

2017-10-11 Thread Thomas Garnier
Adapt module loading to support PIE relocations. Generate dynamic GOT if a symbol requires it but no entry exist in the kernel GOT. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier

[Xen-devel] [PATCH v1 19/27] x86: Support global stack cookie

2017-10-11 Thread Thomas Garnier
. Signed-off-by: Thomas Garnier --- arch/x86/Kconfig | 11 +++ arch/x86/Makefile | 9 + arch/x86/entry/entry_32.S | 3 ++- arch/x86/entry/entry_64.S | 3 ++- arch/x86/include/asm/processor.h | 3 ++- arch

[Xen-devel] [PATCH v1 17/27] xen: Adapt assembly for PIE support

2017-10-11 Thread Thomas Garnier
. Signed-off-by: Thomas Garnier --- arch/x86/tools/relocs.c | 16 +++- arch/x86/xen/xen-head.S | 9 + arch/x86/xen/xen-pvh.S | 13 + 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c index 5d3eb2760198

[Xen-devel] [PATCH v1 25/27] x86/pie: Add option to build the kernel as PIE

2017-10-11 Thread Thomas Garnier
significant change (avg -0.239%) - PIE enabled: average +0.07% System Time: - PIE disabled: no significant change (avg -0.277%) - PIE enabled: average +0.7% [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82303 Signed-off-by: Thomas Garnier merge PIE --- arch/x86/Kconfig | 7 +++ arch

[Xen-devel] [PATCH v1 27/27] x86/kaslr: Add option to extend KASLR range from 1GB to 3GB

2017-10-11 Thread Thomas Garnier
three PUD pages. The relocation table uses 64-bit integers generated with the updated relocation tool with the large-reloc option. Signed-off-by: Thomas Garnier --- arch/x86/Kconfig | 21 + arch/x86/boot/compressed/Makefile| 5 + arch/x86/boot

[Xen-devel] [PATCH v1 26/27] x86/relocs: Add option to generate 64-bit relocations

2017-10-11 Thread Thomas Garnier
top 2G and 32-bit integers are not enough. Signed-off-by: Thomas Garnier --- arch/x86/tools/relocs.c| 60 +- arch/x86/tools/relocs.h| 4 +-- arch/x86/tools/relocs_common.c | 15 +++ 3 files changed, 60 insertions(+), 19 deletions

[Xen-devel] [PATCH v1 22/27] x86/modules: Add option to start module section after kernel

2017-10-11 Thread Thomas Garnier
randomization range. Signed-off-by: Thomas Garnier --- Documentation/x86/x86_64/mm.txt | 3 +++ arch/x86/Kconfig| 4 arch/x86/include/asm/pgtable_64_types.h | 6 +- arch/x86/kernel/head64.c| 5 - arch/x86/mm/dump_pagetables.c | 4

[Xen-devel] [PATCH v1 07/27] x86: pm-trace - Adapt assembly for PIE support

2017-10-11 Thread Thomas Garnier
Change assembly to use the new _ASM_GET_PTR macro instead of _ASM_MOV for the assembly to be PIE compatible. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/include/asm/pm

[Xen-devel] [PATCH v1 11/27] x86/power/64: Adapt assembly for PIE support

2017-10-11 Thread Thomas Garnier
Change the assembly code to use only relative references of symbols for the kernel to be PIE compatible. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/power

[Xen-devel] [PATCH v1 21/27] x86/mm/dump_pagetables: Fix address markers index on x86_64

2017-10-11 Thread Thomas Garnier
The address_markers_idx enum is not aligned with the table when EFI is enabled. Add an EFI_VA_END_NR entry in this case. Signed-off-by: Thomas Garnier --- arch/x86/mm/dump_pagetables.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86/mm/dump_pagetables.c b

[Xen-devel] [PATCH v1 02/27] x86: Use symbol name on bug table for PIE support

2017-10-11 Thread Thomas Garnier
Replace the %c constraint with %P. The %c is incompatible with PIE because it implies an immediate value whereas %P reference a symbol. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier

[Xen-devel] [PATCH v1 05/27] x86: relocate_kernel - Adapt assembly for PIE support

2017-10-11 Thread Thomas Garnier
Change the assembly code to use only relative references of symbols for the kernel to be PIE compatible. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/kernel

[Xen-devel] [PATCH v1 10/27] x86/boot/64: Adapt assembly for PIE support

2017-10-11 Thread Thomas Garnier
as expected. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/kernel/head_64.S | 26 -- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a

[Xen-devel] [PATCH v1 24/27] x86/mm: Make the x86 GOT read-only

2017-10-11 Thread Thomas Garnier
The GOT is changed during early boot when relocations are applied. Make it read-only directly. This table exists only for PIE binary. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier

[Xen-devel] [PATCH v1 20/27] x86/ftrace: Adapt function tracing for PIE support

2017-10-11 Thread Thomas Garnier
5-bytes as before. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/include/asm/ftrace.h | 6 -- arch/x86/include/asm/sections.h | 4 arch/x86/kernel/ftrace.c

[Xen-devel] [PATCH v1 06/27] x86/entry/64: Adapt assembly for PIE support

2017-10-11 Thread Thomas Garnier
Change the assembly code to use only relative references of symbols for the kernel to be PIE compatible. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/entry/entry_64.S

[Xen-devel] [PATCH v1 14/27] x86/percpu: Adapt percpu for PIE support

2017-10-11 Thread Thomas Garnier
Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/entry/entry_64.S | 4 ++-- arch/x86/include/asm/percpu.h | 25 +++-- arch/x86/kernel/cpu/common.c | 4 +++- arch/x86/kernel

[Xen-devel] [PATCH v1 18/27] kvm: Adapt assembly for PIE support

2017-10-11 Thread Thomas Garnier
randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/include/asm/kvm_host.h | 6 -- arch/x86/kernel/kvm.c | 6 -- arch/x86/kvm/svm.c | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm

[Xen-devel] [PATCH v1 13/27] x86/boot/64: Use _text in a global for PIE support

2017-10-11 Thread Thomas Garnier
memory limit. Signed-off-by: Thomas Garnier --- arch/x86/kernel/head64.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index bab4fa579450..675f1dba3b21 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel

[Xen-devel] [PATCH v1 16/27] x86/relocs: Handle PIE relocations

2017-10-11 Thread Thomas Garnier
Change the relocation tool to correctly handle relocations generated by -fPIE option: - Add relocation for each entry of the .got section given the linker does not generate R_X86_64_GLOB_DAT on a simple link. - Ignore R_X86_64_GOTPCREL and R_X86_64_PLT32. Signed-off-by: Thomas Garnier

[Xen-devel] [PATCH v1 15/27] compiler: Option to default to hidden symbols

2017-10-11 Thread Thomas Garnier
/end of sections). In this case, older versions of GCC will remove the comparison if the symbols are hidden. This issue exists at least on gcc 4.9 and before. Signed-off-by: Thomas Garnier --- arch/x86/boot/boot.h | 2 +- arch/x86/include/asm/setup.h | 2 +- arch/x86

[Xen-devel] [PATCH v1 01/27] x86/crypto: Adapt assembly for PIE support

2017-10-11 Thread Thomas Garnier
Change the assembly code to use only relative references of symbols for the kernel to be PIE compatible. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/crypto/aes-x86_64

[Xen-devel] [PATCH v1 09/27] x86/acpi: Adapt assembly for PIE support

2017-10-11 Thread Thomas Garnier
Change the assembly code to use only relative references of symbols for the kernel to be PIE compatible. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/kernel/acpi

[Xen-devel] [PATCH v1 08/27] x86/CPU: Adapt assembly for PIE support

2017-10-11 Thread Thomas Garnier
the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/include/asm/processor.h | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index b446c5a082ad..b09bd50b0

[Xen-devel] [PATCH v1 12/27] x86/paravirt: Adapt assembly for PIE support

2017-10-11 Thread Thomas Garnier
if PIE is enabled, switch the paravirt assembly constraints to be compatible. The %c/i constrains generate smaller code so is kept by default. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas

[Xen-devel] [PATCH v1 04/27] x86: Add macro to get symbol address for PIE support

2017-10-11 Thread Thomas Garnier
Add a new _ASM_GET_PTR macro to fetch a symbol address. It will be used to replace "_ASM_MOV $, %dst" code construct that are not compatible with PIE. Signed-off-by: Thomas Garnier --- arch/x86/include/asm/asm.h | 13 + 1 file changed, 13 insertions(+) diff --git a/arch/x

[Xen-devel] [PATCH v1 03/27] x86: Use symbol name in jump table for PIE support

2017-10-11 Thread Thomas Garnier
Replace the %c constraint with %P. The %c is incompatible with PIE because it implies an immediate value whereas %P reference a symbol. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier

[Xen-devel] [PATCH v1 00/27] x86: PIE support and option to extend KASLR randomization

2017-10-11 Thread Thomas Garnier
Changes: - patch v1: - Simplify ftrace implementation. - Use gcc mstack-protector-guard-reg=%gs with PIE when possible. - rfc v3: - Use --emit-relocs instead of -pie to reduce dynamic relocation space on mapped memory. It also simplifies the relocation process. - Move the start t

Re: [Xen-devel] [RFC v3 20/27] x86/ftrace: Adapt function tracing for PIE support

2017-10-05 Thread Thomas Garnier
On Thu, Oct 5, 2017 at 9:11 AM, Steven Rostedt wrote: > On Thu, 5 Oct 2017 09:01:14 -0700 > Thomas Garnier wrote: > >> On Thu, Oct 5, 2017 at 6:06 AM, Steven Rostedt wrote: >> > On Wed, 4 Oct 2017 14:19:56 -0700 >> > Thomas Garnier wrote: >> > >&g

Re: [Xen-devel] [RFC v3 20/27] x86/ftrace: Adapt function tracing for PIE support

2017-10-05 Thread Thomas Garnier
On Thu, Oct 5, 2017 at 6:06 AM, Steven Rostedt wrote: > On Wed, 4 Oct 2017 14:19:56 -0700 > Thomas Garnier wrote: > >> When using -fPIE/PIC with function tracing, the compiler generates a >> call through the GOT (call *__fentry__@GOTPCREL). This instruction >> takes

[Xen-devel] [RFC v3 22/27] x86/modules: Add option to start module section after kernel

2017-10-04 Thread Thomas Garnier
randomization range. Signed-off-by: Thomas Garnier --- Documentation/x86/x86_64/mm.txt | 3 +++ arch/x86/Kconfig| 4 arch/x86/include/asm/pgtable_64_types.h | 6 +- arch/x86/kernel/head64.c| 5 - arch/x86/mm/dump_pagetables.c | 4

[Xen-devel] [RFC v3 19/27] x86: Support global stack cookie

2017-10-04 Thread Thomas Garnier
. Signed-off-by: Thomas Garnier --- arch/x86/Kconfig | 4 arch/x86/Makefile | 9 + arch/x86/entry/entry_32.S | 3 ++- arch/x86/entry/entry_64.S | 3 ++- arch/x86/include/asm/processor.h | 3 ++- arch/x86

[Xen-devel] [RFC v3 26/27] x86/relocs: Add option to generate 64-bit relocations

2017-10-04 Thread Thomas Garnier
top 2G and 32-bit integers are not enough. Signed-off-by: Thomas Garnier --- arch/x86/tools/relocs.c| 60 +- arch/x86/tools/relocs.h| 4 +-- arch/x86/tools/relocs_common.c | 15 +++ 3 files changed, 60 insertions(+), 19 deletions

[Xen-devel] [RFC v3 20/27] x86/ftrace: Adapt function tracing for PIE support

2017-10-04 Thread Thomas Garnier
calls on the ftrace assembly functions. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/include/asm/ftrace.h | 23 +- arch/x86/include/asm/sections.h | 4 + arch/x86

[Xen-devel] [RFC v3 24/27] x86/mm: Make the x86 GOT read-only

2017-10-04 Thread Thomas Garnier
The GOT is changed during early boot when relocations are applied. Make it read-only directly. This table exists only for PIE binary. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier

[Xen-devel] [RFC v3 23/27] x86/modules: Adapt module loading for PIE support

2017-10-04 Thread Thomas Garnier
Adapt module loading to support PIE relocations. Generate dynamic GOT if a symbol requires it but no entry exist in the kernel GOT. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier

[Xen-devel] [RFC v3 21/27] x86/mm/dump_pagetables: Fix address markers index on x86_64

2017-10-04 Thread Thomas Garnier
The address_markers_idx enum is not aligned with the table when EFI is enabled. Add an EFI_VA_END_NR entry in this case. Signed-off-by: Thomas Garnier --- arch/x86/mm/dump_pagetables.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86/mm/dump_pagetables.c b

[Xen-devel] [RFC v3 18/27] kvm: Adapt assembly for PIE support

2017-10-04 Thread Thomas Garnier
randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/include/asm/kvm_host.h | 6 -- arch/x86/kernel/kvm.c | 6 -- arch/x86/kvm/svm.c | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm

[Xen-devel] [RFC v3 16/27] x86/relocs: Handle PIE relocations

2017-10-04 Thread Thomas Garnier
Change the relocation tool to correctly handle relocations generated by -fPIE option: - Add relocation for each entry of the .got section given the linker does not generate R_X86_64_GLOB_DAT on a simple link. - Ignore R_X86_64_GOTPCREL and R_X86_64_PLT32. Signed-off-by: Thomas Garnier

[Xen-devel] [RFC v3 27/27] x86/kaslr: Add option to extend KASLR range from 1GB to 3GB

2017-10-04 Thread Thomas Garnier
three PUD pages. The relocation table uses 64-bit integers generated with the updated relocation tool with the large-reloc option. Signed-off-by: Thomas Garnier --- arch/x86/Kconfig | 21 + arch/x86/boot/compressed/Makefile| 5 + arch/x86/boot

[Xen-devel] [RFC v3 17/27] xen: Adapt assembly for PIE support

2017-10-04 Thread Thomas Garnier
. Signed-off-by: Thomas Garnier --- arch/x86/tools/relocs.c | 16 +++- arch/x86/xen/xen-head.S | 9 + arch/x86/xen/xen-pvh.S | 13 + 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c index 5d3eb2760198

[Xen-devel] [RFC v3 10/27] x86/boot/64: Adapt assembly for PIE support

2017-10-04 Thread Thomas Garnier
as expected. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/kernel/head_64.S | 26 -- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a

[Xen-devel] [RFC v3 25/27] x86/pie: Add option to build the kernel as PIE

2017-10-04 Thread Thomas Garnier
Optimal runs): Elapsed Time: - PIE disabled: no significant change (avg -0.239%) - PIE enabled: average +0.07% System Time: - PIE disabled: no significant change (avg -0.277%) - PIE enabled: average +0.7% [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82303 Signed-off-by: Thomas Garnier

[Xen-devel] [RFC v3 13/27] x86/boot/64: Use _text in a global for PIE support

2017-10-04 Thread Thomas Garnier
memory limit. Signed-off-by: Thomas Garnier --- arch/x86/kernel/head64.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index bab4fa579450..675f1dba3b21 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel

[Xen-devel] [RFC v3 04/27] x86: Add macro to get symbol address for PIE support

2017-10-04 Thread Thomas Garnier
Add a new _ASM_GET_PTR macro to fetch a symbol address. It will be used to replace "_ASM_MOV $, %dst" code construct that are not compatible with PIE. Signed-off-by: Thomas Garnier --- arch/x86/include/asm/asm.h | 13 + 1 file changed, 13 insertions(+) diff --git a/arch/x

[Xen-devel] [RFC v3 14/27] x86/percpu: Adapt percpu for PIE support

2017-10-04 Thread Thomas Garnier
Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/entry/entry_64.S | 4 ++-- arch/x86/include/asm/percpu.h | 25 +++-- arch/x86/kernel/cpu/common.c | 4 +++- arch/x86/kernel

[Xen-devel] [RFC v3 15/27] compiler: Option to default to hidden symbols

2017-10-04 Thread Thomas Garnier
/end of sections). In this case, older versions of GCC will remove the comparison if the symbols are hidden. This issue exists at least on gcc 4.9 and before. Signed-off-by: Thomas Garnier --- arch/x86/boot/boot.h | 2 +- arch/x86/include/asm/setup.h | 2 +- arch/x86

[Xen-devel] [RFC v3 08/27] x86/CPU: Adapt assembly for PIE support

2017-10-04 Thread Thomas Garnier
the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/include/asm/processor.h | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index b446c5a082ad..b09bd50b0

[Xen-devel] [RFC v3 01/27] x86/crypto: Adapt assembly for PIE support

2017-10-04 Thread Thomas Garnier
Change the assembly code to use only relative references of symbols for the kernel to be PIE compatible. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/crypto/aes-x86_64

[Xen-devel] [RFC v3 05/27] x86: relocate_kernel - Adapt assembly for PIE support

2017-10-04 Thread Thomas Garnier
Change the assembly code to use only relative references of symbols for the kernel to be PIE compatible. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/kernel

[Xen-devel] [RFC v3 02/27] x86: Use symbol name on bug table for PIE support

2017-10-04 Thread Thomas Garnier
Replace the %c constraint with %P. The %c is incompatible with PIE because it implies an immediate value whereas %P reference a symbol. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier

[Xen-devel] [RFC v3 07/27] x86: pm-trace - Adapt assembly for PIE support

2017-10-04 Thread Thomas Garnier
Change assembly to use the new _ASM_GET_PTR macro instead of _ASM_MOV for the assembly to be PIE compatible. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/include/asm/pm

[Xen-devel] [RFC v3 06/27] x86/entry/64: Adapt assembly for PIE support

2017-10-04 Thread Thomas Garnier
Change the assembly code to use only relative references of symbols for the kernel to be PIE compatible. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/entry/entry_64.S

[Xen-devel] [RFC v3 09/27] x86/acpi: Adapt assembly for PIE support

2017-10-04 Thread Thomas Garnier
Change the assembly code to use only relative references of symbols for the kernel to be PIE compatible. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/kernel/acpi

[Xen-devel] [RFC v3 11/27] x86/power/64: Adapt assembly for PIE support

2017-10-04 Thread Thomas Garnier
Change the assembly code to use only relative references of symbols for the kernel to be PIE compatible. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/power

[Xen-devel] x86: PIE support and option to extend KASLR randomization

2017-10-04 Thread Thomas Garnier
These patches make the changes necessary to build the kernel as Position Independent Executable (PIE) on x86_64. A PIE kernel can be relocated below the top 2G of the virtual address space. It allows to optionally extend the KASLR randomization range from 1G to 3G. Thanks a lot to Ard Biesheuvel &

[Xen-devel] [RFC v3 03/27] x86: Use symbol name in jump table for PIE support

2017-10-04 Thread Thomas Garnier
Replace the %c constraint with %P. The %c is incompatible with PIE because it implies an immediate value whereas %P reference a symbol. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier

[Xen-devel] [RFC v3 12/27] x86/paravirt: Adapt assembly for PIE support

2017-10-04 Thread Thomas Garnier
if PIE is enabled, switch the paravirt assembly constraints to be compatible. The %c/i constrains generate smaller code so is kept by default. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas

Re: [Xen-devel] x86: PIE support and option to extend KASLR randomization

2017-10-02 Thread Thomas Garnier
On Sat, Sep 23, 2017 at 2:43 AM, Ingo Molnar wrote: > > * Thomas Garnier wrote: > >> > 2) we first implement the additional entropy bits that Linus suggested. >> > >> > does this work for you? >> >> Sure, I can look at how feasible that is. I

Re: [Xen-devel] x86: PIE support and option to extend KASLR randomization

2017-09-22 Thread Thomas Garnier
On Thu, Sep 21, 2017 at 2:21 PM, Thomas Garnier wrote: > On Thu, Sep 21, 2017 at 9:10 AM, Ard Biesheuvel > wrote: >> >> On 21 September 2017 at 08:59, Ingo Molnar wrote: >> > >> > ( Sorry about the delay in answering this. I could blame the delay on the >

Re: [Xen-devel] x86: PIE support and option to extend KASLR randomization

2017-09-22 Thread Thomas Garnier
On Fri, Sep 22, 2017 at 11:38 AM, H. Peter Anvin wrote: > On 09/22/17 09:32, Ingo Molnar wrote: >> >> BTW., I think things improved with ORC because with ORC we have RBP as an >> extra >> register and with PIE we lose RBX - so register pressure in code generation >> is >> lower. >> > > We lose E

Re: [Xen-devel] x86: PIE support and option to extend KASLR randomization

2017-09-22 Thread Thomas Garnier
On Fri, Sep 22, 2017 at 9:32 AM, Ingo Molnar wrote: > > * Thomas Garnier wrote: > >> On Thu, Sep 21, 2017 at 8:59 AM, Ingo Molnar wrote: >> > >> > ( Sorry about the delay in answering this. I could blame the delay on the >> > merge >> > wi

Re: [Xen-devel] x86: PIE support and option to extend KASLR randomization

2017-09-22 Thread Thomas Garnier
On Thu, Sep 21, 2017 at 9:24 PM, Markus Trippelsdorf wrote: > On 2017.09.21 at 14:21 -0700, Thomas Garnier wrote: >> On Thu, Sep 21, 2017 at 9:10 AM, Ard Biesheuvel >> wrote: >> > >> > On 21 September 2017 at 08:59, Ingo Molnar wrote: >> > > >&g

Re: [Xen-devel] x86: PIE support and option to extend KASLR randomization

2017-09-21 Thread Thomas Garnier
On Thu, Sep 21, 2017 at 2:16 PM, Thomas Garnier wrote: > > On Thu, Sep 21, 2017 at 8:59 AM, Ingo Molnar wrote: > > > > ( Sorry about the delay in answering this. I could blame the delay on the > > merge > > window, but in reality I've been procrastinatin

Re: [Xen-devel] x86: PIE support and option to extend KASLR randomization

2017-09-21 Thread Thomas Garnier
g this is due to the > > permanent, > > non-trivial impact PIE has on generated C code. ) > > > > * Thomas Garnier wrote: > > > >> 1) PIE sometime needs two instructions to represent a single > >> instruction on mcmodel=kernel. > > > > Wh

Re: [Xen-devel] x86: PIE support and option to extend KASLR randomization

2017-09-21 Thread Thomas Garnier
On Thu, Sep 21, 2017 at 8:59 AM, Ingo Molnar wrote: > > ( Sorry about the delay in answering this. I could blame the delay on the > merge > window, but in reality I've been procrastinating this is due to the > permanent, > non-trivial impact PIE has on generated

Re: [Xen-devel] x86: PIE support and option to extend KASLR randomization

2017-08-29 Thread Thomas Garnier
On Fri, Aug 25, 2017 at 8:05 AM, Thomas Garnier wrote: > On Fri, Aug 25, 2017 at 1:04 AM, Ingo Molnar wrote: >> >> * Thomas Garnier wrote: >> >>> With the fix for function tracing, the hackbench results have an >>> average of +0.8 to +1.4% (f

Re: [Xen-devel] x86: PIE support and option to extend KASLR randomization

2017-08-25 Thread Thomas Garnier
On Thu, Aug 24, 2017 at 2:42 PM, Linus Torvalds wrote: > > On Thu, Aug 24, 2017 at 2:13 PM, Thomas Garnier wrote: > > > > My original performance testing was done with an Ubuntu generic > > configuration. This configuration has the CONFIG_FUNCTION_TRACER > > opti

Re: [Xen-devel] x86: PIE support and option to extend KASLR randomization

2017-08-25 Thread Thomas Garnier
On Fri, Aug 25, 2017 at 1:04 AM, Ingo Molnar wrote: > > * Thomas Garnier wrote: > >> With the fix for function tracing, the hackbench results have an >> average of +0.8 to +1.4% (from +8% to +10% before). With a default >> configuration, the numbers are closer to 0.

Re: [Xen-devel] x86: PIE support and option to extend KASLR randomization

2017-08-24 Thread Thomas Garnier
On Thu, Aug 17, 2017 at 7:10 AM, Thomas Garnier wrote: > > On Thu, Aug 17, 2017 at 1:09 AM, Ingo Molnar wrote: > > > > > > * Thomas Garnier wrote: > > > > > > > -model=small/medium assume you are on the low 32-bit. It generates > > > > &g

Re: [Xen-devel] x86: PIE support and option to extend KASLR randomization

2017-08-21 Thread Thomas Garnier
On Mon, Aug 21, 2017 at 7:31 AM, Peter Zijlstra wrote: > On Tue, Aug 15, 2017 at 07:20:38AM -0700, Thomas Garnier wrote: >> On Tue, Aug 15, 2017 at 12:56 AM, Ingo Molnar wrote: > >> > Have you considered a kernel with -mcmodel=small (or medium) instead of >> > -fp

Re: [Xen-devel] x86: PIE support and option to extend KASLR randomization

2017-08-17 Thread Thomas Garnier
On Thu, Aug 17, 2017 at 1:09 AM, Ingo Molnar wrote: > > > * Thomas Garnier wrote: > > > > > -model=small/medium assume you are on the low 32-bit. It generates > > > > instructions where the virtual addresses have the high 32-bit to be > > >

Re: [Xen-devel] x86: PIE support and option to extend KASLR randomization

2017-08-16 Thread Thomas Garnier
On Wed, Aug 16, 2017 at 8:12 AM, Ingo Molnar wrote: > > > * Thomas Garnier wrote: > > > On Tue, Aug 15, 2017 at 12:56 AM, Ingo Molnar wrote: > > > > > > * Thomas Garnier wrote: > > > > > >> > Do these changes get us closer to being a

Re: [Xen-devel] x86: PIE support and option to extend KASLR randomization

2017-08-15 Thread Thomas Garnier
On Tue, Aug 15, 2017 at 7:47 AM, Daniel Micay wrote: > On 15 August 2017 at 10:20, Thomas Garnier wrote: >> On Tue, Aug 15, 2017 at 12:56 AM, Ingo Molnar wrote: >>> >>> * Thomas Garnier wrote: >>> >>>> > Do these changes get us closer to bein

Re: [Xen-devel] x86: PIE support and option to extend KASLR randomization

2017-08-15 Thread Thomas Garnier
On Tue, Aug 15, 2017 at 12:56 AM, Ingo Molnar wrote: > > * Thomas Garnier wrote: > >> > Do these changes get us closer to being able to build the kernel as truly >> > position independent, i.e. to place it anywhere in the valid x86-64 address >> > space? Or

Re: [Xen-devel] x86: PIE support and option to extend KASLR randomization

2017-08-11 Thread Thomas Garnier
On Fri, Aug 11, 2017 at 5:41 AM, Ingo Molnar wrote: > > * Thomas Garnier wrote: > >> Changes: >> - v2: >>- Add support for global stack cookie while compiler default to fs without >> mcmodel=kernel >>- Change patch 7 to correctly jump out of

Re: [Xen-devel] [RFC v2 13/23] x86/power/64: Adapt assembly for PIE support

2017-08-11 Thread Thomas Garnier
On Fri, Aug 11, 2017 at 5:36 AM, Pavel Machek wrote: > On Thu 2017-08-10 10:26:05, Thomas Garnier wrote: >> Change the assembly code to use only relative references of symbols for the >> kernel to be PIE compatible. >> >> Position Independent Executable (PIE) support

[Xen-devel] [RFC v2 20/23] x86/pie: Add option to build the kernel as PIE for x86_64

2017-08-10 Thread Thomas Garnier
) .text sections: - PIE disabled: 9373572 bytes (+0.04% from baseline) - PIE enabled: 9499138 bytes (+1.38% from baseline) The big decrease in vmlinux file size is due to the lower number of relocations appended to the file. Signed-off-by: Thomas Garnier --- arch/x86/Kconfig | 7 +++ arch

[Xen-devel] [RFC v2 15/23] x86/boot/64: Use _text in a global for PIE support

2017-08-10 Thread Thomas Garnier
memory limit. Signed-off-by: Thomas Garnier --- arch/x86/kernel/head64.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index 925b2928f377..e71f27a20576 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel

[Xen-devel] [RFC v2 18/23] x86/relocs: Handle DYN relocations for PIE support

2017-08-10 Thread Thomas Garnier
Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/tools/relocs.c | 74 +++-- 1 file changed, 65 insertions(+), 9 deletions(-) diff --git a/arch/x86

[Xen-devel] [RFC v2 23/23] x86/kaslr: Add option to extend KASLR range from 1GB to 3GB

2017-08-10 Thread Thomas Garnier
three PUD pages. The relocation table uses 64-bit integers generated with the updated relocation tool with the large-reloc option. Signed-off-by: Thomas Garnier --- arch/x86/Kconfig | 21 + arch/x86/boot/compressed/Makefile| 5 + arch/x86/boot

[Xen-devel] [RFC v2 07/23] x86: relocate_kernel - Adapt assembly for PIE support

2017-08-10 Thread Thomas Garnier
Change the assembly code to use only relative references of symbols for the kernel to be PIE compatible. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/kernel

[Xen-devel] [RFC v2 12/23] x86/boot/64: Adapt assembly for PIE support

2017-08-10 Thread Thomas Garnier
as expected. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/kernel/head_64.S | 31 +++ 1 file changed, 23 insertions(+), 8 deletions(-) diff

[Xen-devel] [RFC v2 04/23] x86: Add macro to get symbol address for PIE support

2017-08-10 Thread Thomas Garnier
Add a new _ASM_GET_PTR macro to fetch a symbol address. It will be used to replace "_ASM_MOV $, %dst" code construct that are not compatible with PIE. Signed-off-by: Thomas Garnier --- arch/x86/include/asm/asm.h | 13 + 1 file changed, 13 insertions(+) diff --git a/arch/x

[Xen-devel] [RFC v2 09/23] x86: pm-trace - Adapt assembly for PIE support

2017-08-10 Thread Thomas Garnier
Change assembly to use the new _ASM_GET_PTR macro instead of _ASM_MOV for the assembly to be PIE compatible. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/include/asm/pm

[Xen-devel] [RFC v2 17/23] compiler: Option to default to hidden symbols

2017-08-10 Thread Thomas Garnier
Provide an option to default visibility to hidden except for key symbols. This option is disabled by default and will be used by x86_64 PIE support to remove errors between compilation units. Signed-off-by: Thomas Garnier --- arch/x86/boot/boot.h | 2 +- arch/x86/include/asm/setup.h

[Xen-devel] [RFC v2 21/23] x86/relocs: Add option to generate 64-bit relocations

2017-08-10 Thread Thomas Garnier
top 2G and 32-bit integers are not enough. Signed-off-by: Thomas Garnier --- arch/x86/tools/relocs.c| 60 +- arch/x86/tools/relocs.h| 4 +-- arch/x86/tools/relocs_common.c | 15 +++ 3 files changed, 60 insertions(+), 19 deletions

[Xen-devel] [RFC v2 19/23] x86: Support global stack cookie

2017-08-10 Thread Thomas Garnier
. Signed-off-by: Thomas Garnier --- arch/x86/Kconfig | 4 arch/x86/Makefile | 9 + arch/x86/entry/entry_32.S | 3 ++- arch/x86/entry/entry_64.S | 3 ++- arch/x86/include/asm/processor.h | 3 ++- arch/x86

[Xen-devel] [RFC v2 22/23] x86/module: Add support for mcmodel large and PLTs

2017-08-10 Thread Thomas Garnier
still expect kernel functions to be within 2G and generate relative calls. To solve this issue, the PLT arm64 code was adapted for x86_64. When a relative relocation go outside its range, a dynamic PLT entry is used to correctly jump to the destination. Signed-off-by: Thomas Garnier --- arch/x86

[Xen-devel] [RFC v2 13/23] x86/power/64: Adapt assembly for PIE support

2017-08-10 Thread Thomas Garnier
Change the assembly code to use only relative references of symbols for the kernel to be PIE compatible. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/power

[Xen-devel] [RFC v2 08/23] x86/entry/64: Adapt assembly for PIE support

2017-08-10 Thread Thomas Garnier
Change the assembly code to use only relative references of symbols for the kernel to be PIE compatible. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/entry/entry_64.S

[Xen-devel] [RFC v2 11/23] x86/acpi: Adapt assembly for PIE support

2017-08-10 Thread Thomas Garnier
Change the assembly code to use only relative references of symbols for the kernel to be PIE compatible. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/kernel/acpi

[Xen-devel] [RFC v2 14/23] x86/paravirt: Adapt assembly for PIE support

2017-08-10 Thread Thomas Garnier
if PIE is enabled, switch the paravirt assembly constraints to be compatible. The %c/i constrains generate smaller code so is kept by default. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas

[Xen-devel] [RFC v2 01/23] x86/crypto: Adapt assembly for PIE support

2017-08-10 Thread Thomas Garnier
Change the assembly code to use only relative references of symbols for the kernel to be PIE compatible. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/crypto/aes-x86_64

[Xen-devel] [RFC v2 16/23] x86/percpu: Adapt percpu for PIE support

2017-08-10 Thread Thomas Garnier
Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/entry/entry_64.S | 4 ++-- arch/x86/include/asm/percpu.h | 25 +++-- arch/x86/kernel/cpu/common.c | 4 +++- arch/x86/kernel

  1   2   >