[PATCH v9 3/8] x86/boot: Add efi_get_rsdp_addr() to dig out RSDP from EFI table

2018-10-17 Thread Chao Fan
There is a bug that kaslr may randomly choose some positions which are located in movable memory regions. This will break memory hotplug feature and make the movable memory chosen by KASLR can't be removed. So dig SRAT table from ACPI tables to get memory information. Imitate the ACPI code of pars

[PATCH v9 2/8] x86/boot: Copy kstrtoull() to compressed period

2018-10-17 Thread Chao Fan
Copy kstrtoull() to 'compressed' directory so that we can use it to change the address in cmdline from string to unsigned long long. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/misc.c | 88 + arch/x86/boot/compressed/misc.h | 4 ++ 2 files changed, 92 in

[PATCH v9 8/8] x86/boot/KASLR: Limit kaslr to choosing the immovable memory

2018-10-17 Thread Chao Fan
If CONFIG_MEMORY_HOTREMOVE enabled and the amount of immovable memory regions is not zero. Calculate the intersection between memory regions from e820/efi memory table and immovable memory regions. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 72 +++-

[PATCH v9 6/8] x86/boot: Dig out SRAT table from RSDP and find immovable memory

2018-10-17 Thread Chao Fan
Dig out SRAT table from RSDP, and then walk all memory to find the immovable memory regions, and fill in the immovable_mem[]. So that we can use it to select memory for KASLR. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/Makefile | 4 + arch/x86/boot/compressed/acpitb.c | 129 +

[PATCH v9 7/8] x86/boot/KASLR: Walk srat tables to filter immovable memory

2018-10-17 Thread Chao Fan
If CONFIG_MEMORY_HOTREMOVE enabled, walk through the acpi srat memory tables and store those immovable memory regions so that kaslr can get where to choose for randomization. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 5 + 1 file changed, 5 insertions(+) diff --git a/arc

[PATCH v9 5/8] x86/boot: Add get_acpi_rsdp() to parse RSDP in cmdlien from kexec

2018-10-17 Thread Chao Fan
If KEXEC write the RSDP pointer to cmdline, parse the cmdline and use it. Imitate from early_param of "acpi_rsdp". Signed-off-by: Chao Fan --- arch/x86/boot/compressed/acpitb.c | 23 +++ 1 file changed, 23 insertions(+) diff --git a/arch/x86/boot/compressed/acpitb.c b/arch/

[PATCH v9 4/8] x86/boot: Add bios_get_rsdp_addr() to search RSDP in memory

2018-10-17 Thread Chao Fan
Imitate acpi_find_root_pointer() and acpi_tb_scan_memory_for_rsdp() to search RSDP table pointer in memory. This function only works when RSDP not found in EFI table. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/acpitb.c | 106 ++ 1 file changed, 106 insertion

[PATCH v9 0/8] x86/boot/KASLR: Parse ACPI table and limit kaslr in immovable memory

2018-10-17 Thread Chao Fan
***Background: People reported that kaslr may randomly chooses some positions which are located in movable memory regions. This will break memory hotplug feature and make the movable memory chosen by KASLR can't be removed. ***Solutions: There should be a method to limit kaslr to choosing immovabl

[PATCH v9 1/8] x86/boot: Introduce cmdline_find_option_arg()to detect if option=arg in cmdline

2018-10-17 Thread Chao Fan
Introduce a new function cmdline_find_option_arg() to detect whether option is in command line and the value is arg. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/cmdline.c | 15 +++ arch/x86/boot/compressed/misc.h| 1 + 2 files changed, 16 insertions(+) diff --git a/arc

Re: [PATCH v9 0/8] x86/boot/KASLR: Parse ACPI table and limit kaslr in immovable memory

2018-10-17 Thread Baoquan He
On 10/17/18 at 06:20pm, Chao Fan wrote: > In the earliest time, I tried to dig ACPI tabls to solve this problem. > But I didn't splite the code in 'compressed/' and ACPI code, so the patch > is hard to follow so refused by community. > Somebody suggest to add a kernel parameter to specify the > imm

Re: [PATCH v9 1/8] x86/boot: Introduce cmdline_find_option_arg()to detect if option=arg in cmdline

2018-10-17 Thread Baoquan He
On 10/17/18 at 06:20pm, Chao Fan wrote: > +bool cmdline_find_option_arg(const char *option, const char *arg, int > argsize) > +{ > + char *buffer = malloc(argsize+1); > + bool find = false; > + int ret; > + > + ret = cmdline_find_option(option, buffer, argsize+1); > + if (ret =

Re: [PATCH v9 2/8] x86/boot: Copy kstrtoull() to compressed period

2018-10-17 Thread Baoquan He
On 10/17/18 at 06:20pm, Chao Fan wrote: > Copy kstrtoull() to 'compressed' directory so that > we can use it to change the address in cmdline from > string to unsigned long long. So you don't like simple_strtoull() in arch/x86/boot/string.c which has been used in boot/compressed/kaslr.c . Why? Are

Re: [PATCH v9 8/8] x86/boot/KASLR: Limit kaslr to choosing the immovable memory

2018-10-17 Thread Baoquan He
On 10/17/18 at 06:20pm, Chao Fan wrote: > If CONFIG_MEMORY_HOTREMOVE enabled and the amount of immovable > memory regions is not zero. Calculate the intersection between memory This if conditional adverbial clauses is not an complete sentence. > regions from e820/efi memory table and immovable me

Re: [PATCH v9 7/8] x86/boot/KASLR: Walk srat tables to filter immovable memory

2018-10-17 Thread Baoquan He
On 10/17/18 at 06:20pm, Chao Fan wrote: > If CONFIG_MEMORY_HOTREMOVE enabled, walk through the acpi srat memory > tables and store those immovable memory regions so that kaslr can get > where to choose for randomization. This patch only adds invocation of get_immovable_mem() inside mem_avoid_init(

Re: [PATCH v9 3/8] x86/boot: Add efi_get_rsdp_addr() to dig out RSDP from EFI table

2018-10-17 Thread Baoquan He
On 10/17/18 at 06:20pm, Chao Fan wrote: > There is a bug that kaslr may randomly choose some positions > which are located in movable memory regions. This will break memory > hotplug feature and make the movable memory chosen by KASLR can't be > removed. So dig SRAT table from ACPI tables to get me

Re: [PATCH v9 0/8] x86/boot/KASLR: Parse ACPI table and limit kaslr in immovable memory

2018-10-17 Thread Chao Fan
On Thu, Oct 18, 2018 at 11:59:58AM +0800, Baoquan He wrote: >On 10/17/18 at 06:20pm, Chao Fan wrote: >> In the earliest time, I tried to dig ACPI tabls to solve this problem. >> But I didn't splite the code in 'compressed/' and ACPI code, so the patch >> is hard to follow so refused by community. >

Re: [PATCH v9 2/8] x86/boot: Copy kstrtoull() to compressed period

2018-10-17 Thread Chao Fan
On Thu, Oct 18, 2018 at 12:03:38PM +0800, Baoquan He wrote: >On 10/17/18 at 06:20pm, Chao Fan wrote: >> Copy kstrtoull() to 'compressed' directory so that >> we can use it to change the address in cmdline from >> string to unsigned long long. > >So you don't like simple_strtoull() in arch/x86/boot/

Re: [PATCH v9 3/8] x86/boot: Add efi_get_rsdp_addr() to dig out RSDP from EFI table

2018-10-17 Thread Chao Fan
On Thu, Oct 18, 2018 at 12:35:39PM +0800, Baoquan He wrote: >On 10/17/18 at 06:20pm, Chao Fan wrote: >> There is a bug that kaslr may randomly choose some positions >> which are located in movable memory regions. This will break memory >> hotplug feature and make the movable memory chosen by KASLR

Re: [PATCH v9 3/8] x86/boot: Add efi_get_rsdp_addr() to dig out RSDP from EFI table

2018-10-17 Thread Baoquan He
On 10/18/18 at 01:54pm, Chao Fan wrote: > On Thu, Oct 18, 2018 at 12:35:39PM +0800, Baoquan He wrote: > >On 10/17/18 at 06:20pm, Chao Fan wrote: > >> There is a bug that kaslr may randomly choose some positions > >> which are located in movable memory regions. This will break memory > >> hotplug fe

Re: [PATCH v9 7/8] x86/boot/KASLR: Walk srat tables to filter immovable memory

2018-10-17 Thread Chao Fan
On Thu, Oct 18, 2018 at 12:23:20PM +0800, Baoquan He wrote: >On 10/17/18 at 06:20pm, Chao Fan wrote: >> If CONFIG_MEMORY_HOTREMOVE enabled, walk through the acpi srat memory >> tables and store those immovable memory regions so that kaslr can get >> where to choose for randomization. > >This patch

Re: [PATCH v9 2/8] x86/boot: Copy kstrtoull() to compressed period

2018-10-17 Thread Baoquan He
On 10/18/18 at 01:51pm, Chao Fan wrote: > On Thu, Oct 18, 2018 at 12:03:38PM +0800, Baoquan He wrote: > >On 10/17/18 at 06:20pm, Chao Fan wrote: > >> Copy kstrtoull() to 'compressed' directory so that > >> we can use it to change the address in cmdline from > >> string to unsigned long long. > > >

Re: [PATCH v9 2/8] x86/boot: Copy kstrtoull() to compressed period

2018-10-17 Thread Chao Fan
On Thu, Oct 18, 2018 at 02:01:28PM +0800, Baoquan He wrote: >On 10/18/18 at 01:51pm, Chao Fan wrote: >> On Thu, Oct 18, 2018 at 12:03:38PM +0800, Baoquan He wrote: >> >On 10/17/18 at 06:20pm, Chao Fan wrote: >> >> Copy kstrtoull() to 'compressed' directory so that >> >> we can use it to change the

Re: [PATCH v9 3/8] x86/boot: Add efi_get_rsdp_addr() to dig out RSDP from EFI table

2018-10-17 Thread Chao Fan
On Thu, Oct 18, 2018 at 01:56:44PM +0800, Baoquan He wrote: >On 10/18/18 at 01:54pm, Chao Fan wrote: >> On Thu, Oct 18, 2018 at 12:35:39PM +0800, Baoquan He wrote: >> >On 10/17/18 at 06:20pm, Chao Fan wrote: >> >> There is a bug that kaslr may randomly choose some positions >> >> which are located

Re: [PATCH v9 6/8] x86/boot: Dig out SRAT table from RSDP and find immovable memory

2018-10-17 Thread Chao Fan
On Wed, Oct 17, 2018 at 06:20:10PM +0800, Chao Fan wrote: >Dig out SRAT table from RSDP, and then walk all memory to find >the immovable memory regions, and fill in the immovable_mem[]. >So that we can use it to select memory for KASLR. > >Signed-off-by: Chao Fan >--- > arch/x86/boot/compressed/Ma

Re: [PATCH v9 1/8] x86/boot: Introduce cmdline_find_option_arg()to detect if option=arg in cmdline

2018-10-17 Thread Chao Fan
On Thu, Oct 18, 2018 at 12:01:20PM +0800, Baoquan He wrote: >On 10/17/18 at 06:20pm, Chao Fan wrote: >> +bool cmdline_find_option_arg(const char *option, const char *arg, int >> argsize) >> +{ >> +char *buffer = malloc(argsize+1); >> +bool find = false; >> +int ret; >> + >> +ret =