Re: [PATCH v8 0/2] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

2017-08-04 Thread Chao Fan
lly weird. And Chao also is helping Maybe a little later, cause from tommorow, I will be on vacation for 9 days. Thanks, Chao Fan >to try on his side. > >> >> On 08/04/17 at 03:26pm, Baoquan He wrote: >> > Patch 1/2 is newly added to add efi_memdesc_ptr helper to

Re: [PATCH v8 0/2] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

2017-08-04 Thread Chao Fan
ally weird. And Chao also is helping >to try on his side. Hi Bao, After testing for 10 times, no problem happened. Maybe you did something wrong in the first time. Thanks, Chao Fan > >> >> On 08/04/17 at 03:26pm, Baoquan He wrote: >> > Patch 1/2 is newly added to add

[PATCH v6 1/3] x86/boot: Add acpitb.c to parse acpi tables

2018-09-10 Thread Chao Fan
x27;t influence the initialization of ACPI after start_kernel(). Signed-off-by: Chao Fan Cc: "Rafael J. Wysocki" Cc: Len Brown Cc: Ard Biesheuvel Cc: linux-efi@vger.kernel.org Cc: linux-a...@vger.kernel.org --- arch/x86/boot/compressed/Makefile | 4 + arch/x86/boot/compressed

Re: [PATCH v6 1/3] x86/boot: Add acpitb.c to parse acpi tables

2018-09-10 Thread Chao Fan
On Mon, Sep 10, 2018 at 10:13:49PM +0200, Rafael J. Wysocki wrote: >On Mon, Sep 10, 2018 at 2:41 PM Chao Fan wrote: >> >> Imitate the ACPI code of parsing ACPI tables to dig and read ACPI >> tables. > >Why? Sorry for that, I have sent the cover letter to you. > &g

Re: [PATCH v6 1/3] x86/boot: Add acpitb.c to parse acpi tables

2018-09-11 Thread Chao Fan
On Tue, Sep 11, 2018 at 09:41:36AM +0200, Rafael J. Wysocki wrote: >On Tue, Sep 11, 2018 at 3:28 AM Chao Fan wrote: >> >> On Mon, Sep 10, 2018 at 10:13:49PM +0200, Rafael J. Wysocki wrote: >> >On Mon, Sep 10, 2018 at 2:41 PM Chao Fan wrote: >> >> >>

Re: [RFC PATCH] x86/boot: get_acpi_srat_table() can be static

2018-09-11 Thread Chao Fan
> >-struct acpi_table_header *get_acpi_srat_table(void) >+static struct acpi_table_header *get_acpi_srat_table(void) Good catch, will add it. Thanks, Chao Fan > { > char *args = (char *)get_cmd_line_ptr(); > acpi_physical_address acpi_table; > >

[PATCH v7 1/3] x86/boot: Add acpitb.c to parse acpi tables

2018-09-13 Thread Chao Fan
luence the initialization of ACPI after start_kernel(). Since use physical address directely, so acpi_os_map_memory() and acpi_os_unmap_memory() are not needed. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/Makefile | 4 + arch/x86/boot/compressed/acpitb.c | 401 ++ arc

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

2018-09-13 Thread Chao Fan
meter v5->v6: Follow Baoquan He's suggestion: - Change some log. - Add the check for acpi_rsdp - Change some code logical to make code clear v6->v7: Follow Rafael's suggestion: - Add more comments and patch log. Follow test robot's suggestion: - Add "static" tag for f

[PATCH v7 2/3] x86/boot/KASLR: Walk srat tables to filter immovable memory

2018-09-13 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

[PATCH v7 3/3] x86/boot/KASLR: Limit kaslr to choosing the immovable memory

2018-09-13 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 | 71

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

2018-09-24 Thread Chao Fan
On Sat, Sep 22, 2018 at 08:48:53AM -0700, Kees Cook wrote: >On Thu, Sep 13, 2018 at 3:46 AM, Chao Fan wrote: >> +#ifdef CONFIG_MEMORY_HOTREMOVE >> + /* >> +* If immovable memory found, filter the intersection between >> +* immovable memor

Re: [PATCH v7 1/3] x86/boot: Add acpitb.c to parse acpi tables

2018-09-24 Thread Chao Fan
On Sat, Sep 22, 2018 at 08:45:12AM -0700, Kees Cook wrote: >On Thu, Sep 13, 2018 at 3:46 AM, Chao Fan wrote: >> There is a bug that kaslr may randomly chooses some positions >> which are located in movable memory regions. This will break memory >> hotplug feature and ma

[PATCH v8 3/3] x86/boot/KASLR: Limit kaslr to choosing the immovable memory

2018-10-10 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 v8 1/3] x86/boot: Add acpitb.c to parse acpi tables

2018-10-10 Thread Chao Fan
luence the initialization of ACPI after start_kernel(). Since use physical address directely, so acpi_os_map_memory() and acpi_os_unmap_memory() are not needed. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/Makefile | 2 + arch/x86/boot/compressed/acpitb.c | 405 ++ arc

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

2018-10-10 Thread Chao Fan
function v7-v8: Follow Kees Cook's suggestion: - Use mem_overlaps() to check memory region. - Use #ifdef in the definition of function. Any comments will be welcome. Chao Fan (3): x86/boot: Add acpitb.c to parse acpi tables x86/boot/KASLR: Walk srat tables to filter immovable memory

[PATCH v8 2/3] x86/boot/KASLR: Walk srat tables to filter immovable memory

2018-10-10 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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch

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

2018-10-10 Thread Chao Fan
t;which memory region is movable or immovable, and movable region can be >hot removed. But if kernel is randomized into movable memory, it can't >be hot removed any more, this is a regression after KASLR introduced. >So this is a different issue than Masa's. Yes, they are two issue

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

2018-10-10 Thread Chao Fan
On Wed, Oct 10, 2018 at 07:16:16PM +0200, Borislav Petkov wrote: >On Wed, Oct 10, 2018 at 04:41:16PM +0800, 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

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

2018-10-10 Thread Chao Fan
the code from Chao's patch, but not the variable. Means we need >go through the SRAT accessing again in arch/x86/mm/kaslr.c and fill >immovable_mem[num_immovable_mem] for mm/kaslr.c usage, if we decide to >do like that. Reading three times is redundant, but reading two times is needed. Becasue the ACPI code run very stable, but we need more information before that. As for Masa's issue, I am wondering whether we can tranfer the information or only the address of SRAT table from compressed period to the period after start_kernel(). Thanks, Chao Fan > >Thanks >Baoquan > >

Re: [PATCH v8 1/3] x86/boot: Add acpitb.c to parse acpi tables

2018-10-11 Thread Chao Fan
On Thu, Oct 11, 2018 at 12:57:08PM +0200, Borislav Petkov wrote: >On Wed, Oct 10, 2018 at 04:41:17PM +0800, Chao Fan wrote: >> There is a bug that kaslr may randomly chooses some positions >> which are located in movable memory regions. This will break memory >> hotplug

Re: [PATCH v8 1/3] x86/boot: Add acpitb.c to parse acpi tables

2018-10-12 Thread Chao Fan
On Thu, Oct 11, 2018 at 12:57:08PM +0200, Borislav Petkov wrote: >On Wed, Oct 10, 2018 at 04:41:17PM +0800, Chao Fan wrote: [...] >> + * If ACPI20 table not found, but ACPI table found, >> + * use the ACPI table and return true. >> + * If n

Re: [PATCH v8 1/3] x86/boot: Add acpitb.c to parse acpi tables

2018-10-12 Thread Chao Fan
On Fri, Oct 12, 2018 at 11:46:55AM +0200, Borislav Petkov wrote: >On Fri, Oct 12, 2018 at 05:36:38PM +0800, Chao Fan wrote: >> Prefer to compile out entire functions, rather than portions of functions or >> portions of expressions. Rather than putting an ifdef in an expression, &

Re: [PATCH v8 1/3] x86/boot: Add acpitb.c to parse acpi tables

2018-10-15 Thread Chao Fan
On Mon, Oct 15, 2018 at 04:26:09PM -0400, Masayoshi Mizuma wrote: >Hi Chao, > >Let me add some suggestions. Thanks for your review and suggestion. I will change them in next version. Thanks, Chao Fan > >On Wed, Oct 10, 2018 at 04:41:17PM +0800, Chao Fan wrote: >> There is

Re: [PATCH v8 1/3] x86/boot: Add acpitb.c to parse acpi tables

2018-10-15 Thread Chao Fan
On Thu, Oct 11, 2018 at 12:57:08PM +0200, Borislav Petkov wrote: >On Wed, Oct 10, 2018 at 04:41:17PM +0800, Chao Fan wrote: [...] >> +#ifdef CONFIG_KEXEC >> +static bool get_acpi_rsdp(acpi_physical_address *rsdp_addr) >> +{ >> +char *args = (char *)get_cmd_lin

Re: [PATCH v8 1/3] x86/boot: Add acpitb.c to parse acpi tables

2018-10-16 Thread Chao Fan
On Tue, Oct 16, 2018 at 02:40:36PM +0200, Borislav Petkov wrote: >On Tue, Oct 16, 2018 at 10:48:44AM +0800, Chao Fan wrote: >> Sorry for disturbing you again, I want to make sure this detail with you. >> You mean that I need splite this as a function and put it to >> cmdline

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

2018-10-17 Thread Chao Fan
abler, based on efi_init(). Signed-off-by: Chao Fan --- arch/x86/boot/compressed/acpitb.c | 96 +++ 1 file changed, 96 insertions(+) create mode 100644 arch/x86/boot/compressed/acpitb.c diff --git a/arch/x86/boot/compressed/acpitb.c b/arch/x86/boot/compressed/acpitb.c new

[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 c

[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

[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

[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

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

2018-10-17 Thread Chao Fan
yle. - Splite PATCH 1/3 to more path. - Introduce some new function - Use existing function to rework some code Follow Masayoshi's suggetion: - Make code more readable Any comments will be welcome. Chao Fan (8): x86/boot: Introduce cmdline_find_option_arg()to detect if option=arg

[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

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 ha

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'

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 m

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 randomi

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 s

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 pos

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 >--- > arc

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;

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

2018-10-22 Thread Chao Fan
e length of memory is 8. Well the max memory address is 16, add "0x" and '\0' is 19. So I set it as 20. I am not sure whether 8 is enough for the address, if OK, 11 will be enough, or 19 is OK. If my understanding is wrong, please tell me. Thanks, Chao Fan > >Wondering why not making it 200, it's also enough to store the address. > >

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

2018-10-22 Thread Chao Fan
aps() to check memory region. - Use #ifdef in the definition of function. v8-v9: Follow Boris' suggetion: - Change code style. - Splite PATCH 1/3 to more path. - Introduce some new function - Use existing function to rework some code Follow Masayoshi's suggetion: - Make code more readab

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

2018-10-22 Thread Chao Fan
e out the immovable memory regions to avoid KASLR extracts kernel on movable memory, so slove the conflict between KASLR and movable_node feature. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/acpitb.c | 96 +++ 1 file changed, 96 insertions(+) create mode 100644

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

2018-10-22 Thread Chao Fan
w 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/arch/x86/boot/

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

2018-10-22 Thread Chao Fan
acpi_os_get_root_pointer(). Process: RSDP->RSDT/XSDT->ACPI root table->SRAT. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/Makefile | 4 + arch/x86/boot/compressed/acpitb.c | 127 ++ arch/x86/boot/compressed/kaslr.c | 4 - arch/x86/boot/compressed/misc.h | 1

[PATCH v10 7/7] x86/boot/KASLR: Limit kaslr to choosing the immovable memory

2018-10-22 Thread Chao Fan
intersection between memory regions from e820/efi memory table and immovable memory regions. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 77 +++- 1 file changed, 66 insertions(+), 11 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86

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

2018-10-22 Thread Chao Fan
e and get the memory information. So that we can figure out the immovable memory regions to avoid KASLR extracts kernel on movable memory, so slove the conflict between KASLR and movable_node feature. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/acpitb.c | 106

[PATCH v10 5/7] x86/boot: Add get_acpi_rsdp() to parse RSDP in cmdline from kexec

2018-10-22 Thread Chao Fan
Imitate setup_acpi_rsdp() for the early_param of "acpi_rsdp". KEXEC writes the RSDP pointer to cmdline for EFI booting. So if "acpi_rsdp" found in cmdline, use it directely. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/acpitb.c | 23 +++ 1 file ch

[PATCH v10 2/7] x86/boot: Copy kstrtoull() to compressed period

2018-10-22 Thread Chao Fan
kstrtoull() lives in 'uncompressed' period, used to convert a string to an unsigned long long. Copy to 'compressed' so that we can use it to convert the memory address from sting to unsigned long long in 'compressed' period. Signed-off-by: Chao Fan --- arch/x

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

2018-10-22 Thread Chao Fan
On Thu, Oct 18, 2018 at 12:21:23PM +0800, Baoquan He wrote: >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 adverb

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

2018-10-22 Thread Chao Fan
On Mon, Oct 22, 2018 at 06:24:55PM +0800, Baoquan He wrote: >On 10/22/18 at 06:13pm, Chao Fan wrote: >> >> +static bool process_mem_region(struct mem_vector *region, >> >> +unsigned long long minimum, >> >> +

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

2018-10-22 Thread Chao Fan
? >+ while (data->next) >+ data = (struct setup_data *)(unsigned long)data->next; >+ data->next = (unsigned long)kaslr_data; >+ } If my understanding is not wrong, it should be: data = (struct setup_data *)(unsigned long)params->hdr.setup_data; if (!data) params->hdr.setup_data = (unsigned long)kaslr_data; else { while (data->next) data = (struct setup_data *)(unsigned long)data->next; data->next = (unsigned long)kaslr_data; } If I misunderstand something, please tell me. Thanks, Chao Fan

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

2018-10-24 Thread Chao Fan
On Wed, Oct 24, 2018 at 03:21:36PM -0400, Masayoshi Mizuma wrote: >On Tue, Oct 23, 2018 at 10:48:02AM +0800, Chao Fan wrote: >> On Mon, Oct 22, 2018 at 11:42:05AM -0400, Masayoshi Mizuma wrote: >> >Hi Boris, >> >> Hi Mizuma-san, >> >> I have several qu

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

2018-10-31 Thread Chao Fan
Hi all, Sorry for disturbance. No reply to this version for more than one week, any comments? Thanks, Chao Fan On Mon, Oct 22, 2018 at 05:37:13PM +0800, Chao Fan wrote: >***Background: >People reported that kaslr may randomly chooses some positions >which are located in movable memor

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

2018-10-31 Thread Chao Fan
On Wed, Oct 31, 2018 at 11:05:37AM +0100, Borislav Petkov wrote: >On Wed, Oct 31, 2018 at 03:42:34PM +0800, Chao Fan wrote: >> Hi all, >> >> Sorry for disturbance. >> No reply to this version for more than one week, >> any comments? > >You do realize that we

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

2018-11-06 Thread Chao Fan
s by putting SRAT parsing everywhere :) > >arch/x86/mm/ident_map.c is a good example, it's shared between >arch/x86/boot/compressed and arch/x86/mm/init_64.c Thanks to Baoquan, I think we can try this idea. How about you, Masa? Thanks, Chao Fan > >

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

2018-11-06 Thread Chao Fan
On Tue, Nov 06, 2018 at 01:22:53PM +0100, Borislav Petkov wrote: >On Mon, Oct 22, 2018 at 05:37:14PM +0800, Chao Fan wrote: >> Now, there are cmdline_find_option() and cmdline_find_option_bool() in >> cmdline.c. Sometimes, when detecting such as whether 'acpi=off' is

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

2018-11-06 Thread Chao Fan
On Tue, Nov 06, 2018 at 08:13:03PM +0100, Borislav Petkov wrote: >On Mon, Oct 22, 2018 at 05:37:15PM +0800, Chao Fan wrote: >> kstrtoull() lives in 'uncompressed' period, used to >> convert a string to an unsigned long long. >> Copy to 'compressed' so th

[PATCH v11 2/5] x86/boot: Add bios_get_rsdp_addr() to search RSDP in memory

2018-11-12 Thread Chao Fan
e and get the memory information. And figure out the immovable memory regions to avoid KASLR extracts kernel on movable memory, slove the conflict between KASLR and movable_node feature. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/acpitb.c | 106 ++ 1 file ch

[PATCH v11 1/5] x86/boot: Add efi_get_rsdp_addr() to dig out RSDP from EFI table

2018-11-12 Thread Chao Fan
: boot_param->systab->efi_config_table->RSDP. Based on efi_init(), efi_config_init(), efi_config_parse_tables(). Signed-off-by: Chao Fan --- arch/x86/boot/compressed/acpitb.c | 96 +++ 1 file changed, 96 insertions(+) create mode 100644 arch/x86/boot/c

[PATCH v11 4/5] x86/boot: Dig out SRAT table from RSDP and find immovable memory

2018-11-12 Thread Chao Fan
confition, BIOS condition. If KEXEC add 'acpi_rsdp' to cmdline, use it. Otherwise, parse EFI table for RSDP. Then, search memory for RSDP. Imitate from ACPI code, based on acpi_os_get_root_pointer(). Process: RSDP->RSDT/XSDT->ACPI root table->SRAT. Signed-off-by: Chao Fan

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

2018-11-12 Thread Chao Fan
unction to rework some code Follow Masayoshi's suggetion: - Make code more readable v9->v10: Follow Baoquan's suggestion: - Change some log - Merge last two patch together. v10->v11: Follow Boris' suggestion: - Link kstrtoull() instead of copying it. - Drop the

[PATCH v11 5/5] x86/boot/KASLR: Walk srat tables to filter immovable memory

2018-11-12 Thread Chao Fan
ction between memory regions from e820/efi memory table and immovable memory regions. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 77 +++- 1 file changed, 66 insertions(+), 11 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compr

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

2018-11-12 Thread Chao Fan
onflict problem, set BOOT_STRING tag to expose only kstrtoull() and functions used by it. Other functions in lib/kstrtox.c will be covered. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/acpitb.c | 26 ++ arch/x86/boot/string.h| 4 lib/kstrtox.c

Re: [PATCH v11 3/5] x86/boot: Add get_acpi_rsdp() to parse RSDP in cmdlien from kexec

2018-11-12 Thread Chao Fan
() is exposed. I am not sure whether this is OK. Thanks, Chao Fan On Mon, Nov 12, 2018 at 05:46:43PM +0800, Chao Fan wrote: >Imitate setup_acpi_rsdp() for the early_param of 'acpi_rsdp'. >KEXEC writes the RSDP pointer to cmdline for EFI booting. >So if 'acpi_rsdp' found

Re: [PATCH v11 1/5] x86/boot: Add efi_get_rsdp_addr() to dig out RSDP from EFI table

2018-11-12 Thread Chao Fan
On Mon, Nov 12, 2018 at 03:54:33PM +0100, Borislav Petkov wrote: >On Mon, Nov 12, 2018 at 05:46:41PM +0800, Chao Fan wrote: >> In order to parse SRAT table and get memory information, RSDP pointer >> should be found. In kernel, there are three methods to get RSDP: >> EFI cond

Re: [PATCH v11 2/5] x86/boot: Add bios_get_rsdp_addr() to search RSDP in memory

2018-11-12 Thread Chao Fan
On Mon, Nov 12, 2018 at 04:27:44PM +0100, Borislav Petkov wrote: >On Mon, Nov 12, 2018 at 05:46:42PM +0800, Chao Fan wrote: >> Imitate ACPI code to search RSDP pointer from memory. >> Walk memory and check the signature until get the RSDP signature. >> Based on acpi_tb_scan_

Re: [PATCH v11 3/5] x86/boot: Add get_acpi_rsdp() to parse RSDP in cmdlien from kexec

2018-11-12 Thread Chao Fan
On Mon, Nov 12, 2018 at 12:43:44PM -0500, Masayoshi Mizuma wrote: >Hi Chao, > >On Mon, Nov 12, 2018 at 05:46:43PM +0800, Chao Fan wrote: >> Imitate setup_acpi_rsdp() for the early_param of 'acpi_rsdp'. >> KEXEC writes the RSDP pointer to cmdline for EFI booting

Re: [PATCH v11 4/5] x86/boot: Dig out SRAT table from RSDP and find immovable memory

2018-11-12 Thread Chao Fan
eader + sizeof(struct acpi_table_srat)); >> + >> +while (((unsigned long)table) + >> + sizeof(struct acpi_subtable_header) < table_end) { >> +if (table->type == ACPI_SRAT_TYPE_MEMORY_AFFINITY) { >> +ma =

Re: [PATCH v11 4/5] x86/boot: Dig out SRAT table from RSDP and find immovable memory

2018-11-12 Thread Chao Fan
On Mon, Nov 12, 2018 at 04:51:59PM -0500, Masayoshi Mizuma wrote: >On Mon, Nov 12, 2018 at 05:46:44PM +0800, Chao Fan wrote: >> To avoid KASLR extracting kernel on movable memory, slove the >> conflict between KASLR and movable_node feature, dig the SRAT tables >> from RSDP p

Re: [PATCH v11 3/5] x86/boot: Add get_acpi_rsdp() to parse RSDP in cmdlien from kexec

2018-11-13 Thread Chao Fan
On Tue, Nov 13, 2018 at 06:51:50PM +0100, Borislav Petkov wrote: >On Mon, Nov 12, 2018 at 05:46:43PM +0800, Chao Fan wrote: >> Imitate setup_acpi_rsdp() for the early_param of 'acpi_rsdp'. >> KEXEC writes the RSDP pointer to cmdline for EFI booting. >> So if '

Re: [PATCH v11 3/5] x86/boot: Add get_acpi_rsdp() to parse RSDP in cmdlien from kexec

2018-11-13 Thread Chao Fan
On Wed, Nov 14, 2018 at 09:54:50AM +0800, Chao Fan wrote: >On Tue, Nov 13, 2018 at 06:51:50PM +0100, Borislav Petkov wrote: >>On Mon, Nov 12, 2018 at 05:46:43PM +0800, Chao Fan wrote: >>> Imitate setup_acpi_rsdp() for the early_param of 'acpi_rsdp'. >>> KEXEC w

Re: [PATCH v11 3/5] x86/boot: Add get_acpi_rsdp() to parse RSDP in cmdlien from kexec

2018-11-13 Thread Chao Fan
((__ismask(c)&(_P|_U|_L|_D)) != 0) #define islower(c) ((__ismask(c)&(_L)) != 0) #define isprint(c) ((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0) Now I can make it. I wonder whether this is OK to cover isdigit() with 'BOOT_STRING' tag. Thanks, Chao Fan >-- >Regards/Gruss, >Boris. > >Good mailing practices for 400: avoid top-posting and trim the reply. > >

Re: [PATCH v11 3/5] x86/boot: Add get_acpi_rsdp() to parse RSDP in cmdlien from kexec

2018-11-18 Thread Chao Fan
On Wed, Nov 14, 2018 at 07:30:17PM +0100, Borislav Petkov wrote: >On Wed, Nov 14, 2018 at 02:12:16PM +0800, Chao Fan wrote: >> But isdigit() would be redefine, so: >> >> diff --git a/include/linux/ctype.h b/include/linux/ctype.h >> index 363b004426db..aba01c385232 10

Re: [PATCH v11 5/5] x86/boot/KASLR: Walk srat tables to filter immovable memory

2018-11-18 Thread Chao Fan
On Fri, Nov 16, 2018 at 02:50:39PM +0100, Borislav Petkov wrote: > Subject: Re: [PATCH v11 5/5] x86/boot/KASLR: Walk srat tables to filter > immovable memory > >s/srat/SRAT/g > >On Mon, Nov 12, 2018 at 05:46:45PM +0800, Chao Fan wrote: >> KASLR may randomly chooses

Re: [PATCH v11 4/5] x86/boot: Dig out SRAT table from RSDP and find immovable memory

2018-11-18 Thread Chao Fan
On Fri, Nov 16, 2018 at 12:16:54PM +0100, Borislav Petkov wrote: >On Mon, Nov 12, 2018 at 05:46:44PM +0800, Chao Fan wrote: >> To avoid KASLR extracting kernel on movable memory, slove the > ^ > >Please introduce a spel

Re: [PATCH v11 4/5] x86/boot: Dig out SRAT table from RSDP and find immovable memory

2018-11-19 Thread Chao Fan
Hi Boris, On Fri, Nov 16, 2018 at 12:16:54PM +0100, Borislav Petkov wrote: >On Mon, Nov 12, 2018 at 05:46:44PM +0800, Chao Fan wrote: >> To avoid KASLR extracting kernel on movable memory, slove the > ^ > >Please introd

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

2019-02-10 Thread Chao Fan
length; >+ num++; >+ } > } It looks better in another mail where you add a new function. Thanks, Chao Fan > > if (num >= MAX_NUMNODES*2) { >@@ -320,