[PATCH v13 1/6] x86/boot: Introduce kstrtoull() to boot directory instead of simple_strtoull()

2018-12-11 Thread Chao Fan
Introduce kstrtoull() from lib/kstrtox.c to boot directory so that code in boot/ can use kstrtoull() and the old simple_strtoull() can be replaced. Signed-off-by: Chao Fan --- arch/x86/boot/string.c | 137 + arch/x86/boot/string.h | 2 + 2 files changed

[PATCH v13 6/6] x86/boot/KASLR: Limit KASLR to extracting kernel in immovable memory

2018-12-11 Thread Chao Fan
CONFIG_EARLY_PARSE_RSDP is enabled, walk through SRAT to get the information of immovable memory so that KASLR knows where should be chosen for randomization. Rename process_mem_region() as __process_mem_region() and name new function as process_mem_region(). Signed-off-by: Chao Fan --- arch/x86/boot

[PATCH v13 5/6] x86/boot: Parse SRAT from RSDP and store immovable memory

2018-12-11 Thread Chao Fan
SRAT should be parsed by RSDP to fix the conflict between KASLR and memory-hotremove, then find the immovable memory regions and store them in an array called immovable_mem[]. With immovable_mem[], KASLR can avoid to extract kernel to specific regions. Signed-off-by: Chao Fan --- arch/x86/boot

[PATCH v13 0/6] x86/boot/KASLR: Parse ACPI table and limit KASLR to choosing immovable memory

2018-12-11 Thread Chao Fan
ARSE_RSDP' to make code easy to read - Put strtoull() to misc.c Follow Masa's suggestion: - Remove the detection for 'movable_node' - Change the code logical about cmdline_find_option() v12->v13: Follow Boris' suggestion: - Copy kstrtoull() to boot/string.c Follow

[PATCH v13 2/6] x86/boot: Introduce get_acpi_rsdp() to parse RSDP in cmdline from KEXEC

2018-12-11 Thread Chao Fan
Y_HOTREMOVE' is needed, introduce 'CONFIG_EARLY_PARSE_RSDP' to make ifdeffery clear. Signed-off-by: Chao Fan --- arch/x86/Kconfig| 10 ++ arch/x86/boot/compressed/acpi.c | 30 ++ arch/x86/boot/compressed/misc.h | 6 ++ 3 files change

[PATCH v13 3/6] x86/boot: Introduce efi_get_rsdp_addr() to find RSDP from EFI table

2018-12-11 Thread Chao Fan
. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/acpi.c | 79 + 1 file changed, 79 insertions(+) diff --git a/arch/x86/boot/compressed/acpi.c b/arch/x86/boot/compressed/acpi.c index cad15686f82c..c96008712ec9 100644 --- a/arch/x86/boot/compressed/acpi.c

[PATCH v13 4/6] x86/boot: Introduce bios_get_rsdp_addr() to search RSDP in memory

2018-12-11 Thread Chao Fan
BIOS, there is no variable who can point to RSDP directly, so scan memory for the RSDP and verify RSDP by signature and checksum. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/acpi.c | 85 + 1 file changed, 85 insertions(+) diff --git a/arch/x86/boot

Re: [PATCH v12 1/5] x86/boot: Add get_acpi_rsdp() to parse RSDP in cmdline from KEXEC

2018-12-06 Thread Chao Fan
t; I remember I just muted it with below code, please check commit >> d52e7d5a95. >> >> +#define _LINUX_EXPORT_H >> +#define EXPORT_SYMBOL(sym) > >I made below change, it passed. My another question is why you need >include "lib/kstrtox.c" into misc.c. Does it make sense if you plan to >use it to replace simple_strtoull() in arch/x86/boot/string.c ? > >diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c >index e51713fe3add..777e807756e8 100644 >--- a/arch/x86/boot/compressed/misc.c >+++ b/arch/x86/boot/compressed/misc.c >@@ -13,6 +13,8 @@ > */ > > #define BOOT_CTYPE_H >+#define __DISABLE_EXPORTS >+ > #include "misc.h" > #include "error.h" > #include "pgtable.h" > >I just tried to include it into boot/string.c, there's no any problem. Thanks for your help, I think it's better to include it into boot/string.c. Thanks, Chao Fan > >Thanks >Baoquan > >

Re: [PATCH v12 1/5] x86/boot: Add get_acpi_rsdp() to parse RSDP in cmdline from KEXEC

2018-12-06 Thread Chao Fan
wonder if there are some options I miss or some problems. The patch is below. Thanks, Chao Fan diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c index c4428a176973..62ffe0437c8e 100644 --- a/arch/x86/boot/string.c +++ b/arch/x86/boot/string.c @@ -13,6 +13,9 @@ */ #include

Re: [PATCH v12 1/5] x86/boot: Add get_acpi_rsdp() to parse RSDP in cmdline from KEXEC

2018-12-05 Thread Chao Fan
On Wed, Dec 05, 2018 at 03:58:14PM +0100, Borislav Petkov wrote: >On Thu, Nov 29, 2018 at 04:16:27PM +0800, Chao Fan wrote: >> To fix the conflict between KASLR and memory-hotremove, memory >> information in SRAT table is necessary. >> >> ACPI SRAT (System/Static Resour

Re: [PATCH v12 1/5] x86/boot: Add get_acpi_rsdp() to parse RSDP in cmdline from KEXEC

2018-12-04 Thread Chao Fan
On Tue, Dec 04, 2018 at 07:34:00PM +0100, Borislav Petkov wrote: >On Fri, Nov 30, 2018 at 10:29:14AM +0800, Chao Fan wrote: >> Oh, thanks, will change it >> char val[19]; > >And make that 19 a define. I will do that. Thanks, Chao Fan > >-- >Regards/Gruss, >

Re: [PATCH v12 1/5] x86/boot: Add get_acpi_rsdp() to parse RSDP in cmdline from KEXEC

2018-12-04 Thread Chao Fan
On Tue, Dec 04, 2018 at 07:42:20PM +0100, Borislav Petkov wrote: >On Sat, Dec 01, 2018 at 02:05:39PM +0800, Chao Fan wrote: >> >I built your whole patchset and got the error. >> >The error depends on CONFIG_MODVERSIONS. >> >If CONFIG_MODVERSIONS=y, you will get t

Re: [PATCH v12 4/5] x86/boot: Parse SRAT table from RSDP and store immovable memory

2018-12-02 Thread Chao Fan
On Fri, Nov 30, 2018 at 09:54:33AM -0500, Masayoshi Mizuma wrote: >On Fri, Nov 30, 2018 at 09:24:54AM +0800, Chao Fan wrote: >> >> /* acpitb.c */ >> >> +#ifdef CONFIG_RANDOMIZE_BASE >> >> +/* Store the amount of immovable memory regions */ >

Re: [PATCH v12 1/5] x86/boot: Add get_acpi_rsdp() to parse RSDP in cmdline from KEXEC

2018-11-30 Thread Chao Fan
On Fri, Nov 30, 2018 at 12:35:16PM -0500, Masayoshi Mizuma wrote: >On Fri, Nov 30, 2018 at 10:43:47AM +0800, Chao Fan wrote: >... >> >]$ make arch/x86/boot/compressed/misc.o >> > CALLscripts/checksyscalls.sh >> > DESCEND objtool >> > CC arch

Re: [PATCH v12 0/5] x86/boot/KASLR: Parse ACPI table and limit KASLR to choosing immovable memory

2018-11-29 Thread Chao Fan
On Fri, Nov 30, 2018 at 09:15:13AM +0800, Chao Fan wrote: >On Thu, Nov 29, 2018 at 12:32:46PM -0500, Masayoshi Mizuma wrote: >>Hi Chao, >> >>Thank you for your continued working. > >Thanks for your test. > >> >>Could you please build your patches before

Re: [PATCH v12 1/5] x86/boot: Add get_acpi_rsdp() to parse RSDP in cmdline from KEXEC

2018-11-29 Thread Chao Fan
x86/boot/compressed/misc.o] >Error 1 >make: *** [Makefile:1715: arch/x86/boot/compressed/misc.o] Error 2 >]$ Hi Masa, So many thanks for your test. Could you give me more details about this error? More error message. Just on the first commit or the whole PATCHSET? Cause I didn't get er

Re: [PATCH v12 1/5] x86/boot: Add get_acpi_rsdp() to parse RSDP in cmdline from KEXEC

2018-11-29 Thread Chao Fan
On Thu, Nov 29, 2018 at 11:20:13AM -0500, Masayoshi Mizuma wrote: >On Thu, Nov 29, 2018 at 04:16:27PM +0800, Chao Fan wrote: >> To fix the conflict between KASLR and memory-hotremove, memory >> information in SRAT table is necessary. >> >> ACPI SRAT (System/Static R

Re: [PATCH v12 4/5] x86/boot: Parse SRAT table from RSDP and store immovable memory

2018-11-29 Thread Chao Fan
On Thu, Nov 29, 2018 at 12:55:21PM -0500, Masayoshi Mizuma wrote: >On Thu, Nov 29, 2018 at 04:16:30PM +0800, Chao Fan wrote: >> To fix the conflict between KASLR and memory-hotremove, SRAT table >> should be parsed by RSDP pointer, then find the immovable >> memory regions

Re: [PATCH v12 0/5] x86/boot/KASLR: Parse ACPI table and limit KASLR to choosing immovable memory

2018-11-29 Thread Chao Fan
oblems with the method to splite patch. I will rework on it and build every commit. Thanks, Chao Fan >Your patches depend on the following kconfig, >so please build them under the config combination. > >RANDOMIZE_BASE >MEMORY_HOTREMOVE >EARLY_PARSE_RSDP >KEXEC >EFI > >T

[PATCH v12 4/5] x86/boot: Parse SRAT table from RSDP and store immovable memory

2018-11-29 Thread Chao Fan
regions. Add 'CONFIG_EARLY_PARSE_RSDP' which depends on RANDOMIZE_BASE && MEMORY_HOTREMOVE, cause only when both KASLR and memory-hotremove are enabled, RSDP needs to be parsed in compressed period. Signed-off-by: Chao Fan --- arch/x86/Kconfig | 10 +++ arch/x

[PATCH v12 1/5] x86/boot: Add get_acpi_rsdp() to parse RSDP in cmdline from KEXEC

2018-11-29 Thread Chao Fan
pointer (Root System Description Pointer). So RSDP should be found firstly. When booting form KEXEC/EFI/BIOS, the methods to find RSDP pointer are different. When booting from KEXEC, 'acpi_rsdp' may have been added to cmdline, so parse the cmdline and find the RSDP pointer. Signed-of

[PATCH v12 5/5] x86/boot/KASLR: Limit KASLR to extracting kernel in immovable memory

2018-11-29 Thread Chao Fan
CONFIG_EARLY_PARSE_RSDP is enabled, walk through the SRAT memory tables and store those immovable memory regions so that KASLR can get where to choose for randomization. Also, rename process_mem_region() as __process_mem_region() and name new function as process_mem_region(). Signed-off-by: Chao Fan

[PATCH v12 2/5] x86/boot: Add efi_get_rsdp_addr() to find RSDP from EFI table

2018-11-29 Thread Chao Fan
table and find the RSDP pointer. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/acpitb.c | 79 +++ 1 file changed, 79 insertions(+) diff --git a/arch/x86/boot/compressed/acpitb.c b/arch/x86/boot/compressed/acpitb.c index 614c45655cff..c43546648638 100644 --- a

[PATCH v12 0/5] x86/boot/KASLR: Parse ACPI table and limit KASLR to choosing immovable memory

2018-11-29 Thread Chao Fan
to read - Put strtoull() to misc.c Follow Masa's suggestion: - Remove the detection for 'movable_node' - Change the code logical about cmdline_find_option() Any comments will be welcome. Chao Fan (5): x86/boot: Add get_acpi_rsdp() to parse RSDP in cmdline from KEXEC x86/boot:

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

2018-11-29 Thread Chao Fan
directly, so scan memory for the RSDP and verify RSDP by signature and checksum. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/acpitb.c | 85 +++ 1 file changed, 85 insertions(+) diff --git a/arch/x86/boot/compressed/acpitb.c b/arch/x86/boot/compressed/acpitb.c

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

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 v6 0/3] x86/boot/KASLR: Parse ACPI table and limit kaslr in immovable memory.

2018-09-11 Thread Chao Fan
On Tue, Sep 11, 2018 at 09:28:44AM +0200, Rafael J. Wysocki wrote: >On Tue, Sep 11, 2018 at 3:13 AM Chao Fan wrote: >> >> sorry, the cover letter forwand to rafael. > >Thanks, but the relevant information still needs to go to the >changelog of the patch adding the extra

[tip:x86/boot] x86/boot/KASLR: Remove return value from handle_mem_options()

2018-09-10 Thread tip-bot for Chao Fan
Commit-ID: 44060e8a5189fd79220a94422b8249a85e91 Gitweb: https://git.kernel.org/tip/44060e8a5189fd79220a94422b8249a85e91 Author: Chao Fan AuthorDate: Tue, 7 Aug 2018 09:57:05 +0800 Committer: Ingo Molnar CommitDate: Mon, 10 Sep 2018 15:07:11 +0200 x86/boot/KASLR: Remove return

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

2018-09-10 Thread Chao Fan
sorry, the cover letter forwand to rafael. Thanks, Chao Fan On Mon, Sep 10, 2018 at 08:40:12PM +0800, Chao Fan wrote: >***Background: >People reported that kaslr may randomly chooses some positions >which are located in movable memory regions. This will break memory >hotplug feature

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

2018-09-10 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 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 v6 2/3] x86/boot/KASLR: Walk srat tables to filter immovable memory

2018-09-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 | 10 ++ 1 file changed, 10 insertions(+) diff

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

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

Re: [PATCH 0/3] x86/boot/KASLR: enhance randomness of kernel load addr when using GiB hugepage

2018-09-06 Thread Chao Fan
On Thu, Sep 06, 2018 at 01:58:08PM +0800, Pingfan Liu wrote: >On Thu, Sep 6, 2018 at 12:07 PM Chao Fan wrote: >> >> On Thu, Sep 06, 2018 at 10:36:19AM +0800, Pingfan Liu wrote: >> >> Hi Pingfan, >> >> >commit 747ff6265db4 ("x86/boot/KASLR: Skip sp

Re: [PATCH 0/3] x86/boot/KASLR: enhance randomness of kernel load addr when using GiB hugepage

2018-09-05 Thread Chao Fan
ment of randomness. Such as your example, in 4G, the probability every slot chosen is about 0.00049 in 5G, the probability every slot chosen is about 0.00039 Yes, you did improve 25% for randomness. But I wonder if it's worth to improve from 0.00049 to 0.00039. If there is something wrong in my u

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

2018-08-26 Thread Chao Fan
On Mon, Aug 27, 2018 at 02:28:54PM +0800, Chao Fan wrote: >On Mon, Aug 27, 2018 at 01:56:07PM +0800, Baoquan He wrote: >>On 08/07/18 at 02:50pm, Chao Fan wrote: [...] >> >>Is it possible to take num_immovable_mem definition out from #ifdef >>CONFIG_MEMORY_HOTREMOVE b

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

2018-08-26 Thread Chao Fan
On Mon, Aug 27, 2018 at 01:56:07PM +0800, Baoquan He wrote: >On 08/07/18 at 02:50pm, Chao Fan wrote: >> If 'CONFIG_MEMORY_HOTREMOVE' specified and the account of immovable >If CONFIG_MEMORY_HOTREMOVE is enabled, >> memory regions is not zero. Calculate the intersecti

Re: [PATCH v5 3/4] x86/boot/KASLR: Walk srat tables to filter immovable memory

2018-08-26 Thread Chao Fan
On Mon, Aug 27, 2018 at 10:13:49AM +0800, Baoquan He wrote: >On 08/07/18 at 02:49pm, Chao Fan wrote: >> If 'CONFIG_MEMORY_HOTREMOVE' specified, walk the acpi srat memory >> tables, store the immovable memory regions, so that kaslr can get >> the information abou

Re: [PATCH v5 3/4] x86/boot/KASLR: Walk srat tables to filter immovable memory

2018-08-23 Thread Chao Fan
it to a suitable place. May the position where we try to get the acpi table is better. Or just here is also OK. Thanks, Chao Fan >

Re: [PATCH v5 0/4] x86/boot/KASLR: Parse ACPI table and limit kaslr in immovable memory.

2018-08-22 Thread Chao Fan
Hi all, No reply for 2 weeks, any comments? Thanks, Chao Fan On Tue, Aug 07, 2018 at 02:49:56PM +0800, Chao Fan wrote: >***Background: >People reported that kaslr may randomly chooses some positions >which are located in movable memory regions. This will break memory >hotplug feat

[PATCH v5 4/4] x86/boot/KASLR: Limit kaslr to choosing the immovable memory

2018-08-06 Thread Chao Fan
tch_random, and name new function as process_mem_region. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 66 ++-- 1 file changed, 55 insertions(+), 11 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index 72

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

2018-08-06 Thread Chao Fan
If 'CONFIG_MEMORY_HOTREMOVE' specified, walk the acpi srat memory tables, store the immovable memory regions, so that kaslr can get the information abouth where can be selected or not. If 'CONFIG_MEMORY_HOTREMOVE' not specified, go on the old code. Signed-off-by: Chao Fan

[PATCH v5 2/4] x86/boot: Add acpitb.c to parse acpi tables

2018-08-06 Thread Chao Fan
Imitate the ACPI code to parse ACPI tables. Functions are simplified cause some operations are not needed here. And also, this method won't influence the initialization of ACPI. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/Makefile | 4 + arch/x86/boot/compressed/acpitb.c

[PATCH v5 1/4] x86/boot: Add acpitb.h to help parse acpi tables

2018-08-06 Thread Chao Fan
In order to parse ACPI tables, reuse the head file linux/acpi.h, so that the files in 'compressed' directory can read ACPI table by including this head file. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/acpitb.h | 7 +++ 1 file changed, 7 insertions(+) create mode 10064

[PATCH v5 0/4] x86/boot/KASLR: Parse ACPI table and limit kaslr in immovable memory.

2018-08-06 Thread Chao Fan
to #define CONFIG_EFI and return false in the other stub. - Simplify two functions in head file. v4->v5: Follow Dou Liyang's suggestion: - Add more comments about some functions based on kernel code. - Change some typo in comments. - Clean useless variable. - Add check for the bounda

[PATCH] x86/boot/KASLR: Change the function type to void

2018-08-06 Thread Chao Fan
Since function "handle_mem_options" is used only once: arch/x86/boot/compressed/kaslr.c:421 handle_mem_options(); The return value is useless, so change it to void. And also clean a useless variable. Suggested-by: Dou Liyang Signed-off-by: Chao Fan --- arch/x86/boot/compress

Re: [PATCH v4 2/4] x86/boot: Add acpitb.c to parse acpi tables

2018-08-02 Thread Chao Fan
On Fri, Aug 03, 2018 at 10:00:48AM +0800, Dou Liyang wrote: > > >At 07/23/2018 05:29 PM, Chao Fan wrote: >> Imitate the ACPI code to parse ACPI tables. Functions are simplified >> cause some operations are not needed here. >> And also, this method won't infl

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

2018-08-01 Thread Chao Fan
On Thu, Aug 02, 2018 at 01:46:29PM +0800, Dou Liyang wrote: >Hi Fan, > >At 07/23/2018 05:29 PM, Chao Fan wrote: >> If 'CONFIG_MEMORY_HOTREMOVE' specified and the account of immovable >> memory regions is not zero. Calculate the intersection between memory >> r

Re: [PATCH v4 3/4] x86/boot/KASLR: Walk srat tables to filter immovable memory

2018-08-01 Thread Chao Fan
On Thu, Aug 02, 2018 at 11:47:13AM +0800, Dou Liyang wrote: >Hi Fan, > >At 07/23/2018 05:29 PM, Chao Fan wrote: >> If 'CONFIG_MEMORY_HOTREMOVE' specified, walk the acpi srat memory >> tables, store the immovable memory regions, so that kaslr can get >> the inf

Re: [PATCH v4 0/4] x86/boot/KASLR: Parse ACPI table and limit kaslr in immovable memory.

2018-08-01 Thread Chao Fan
Hi, Sorry for disturbance, no reply for a week, any comments? Thanks, Chao Fan On Mon, Jul 23, 2018 at 05:29:04PM +0800, Chao Fan wrote: >***Background: >People reported that kaslr may randomly chooses some positions >which are located in movable memory regions. This will break memory

Re: [PATCH v4 1/4] x86/boot: Add acpitb.h to help parse acpi tables

2018-07-24 Thread Chao Fan
On Tue, Jul 24, 2018 at 02:02:57PM +0800, Baoquan He wrote: >Hi chao, > >On 07/23/18 at 05:29pm, Chao Fan wrote: >> In order to parse ACPI tables, reuse the head file linux/acpi.h, >> so that the files in 'compressed' directory can read ACPI table >> by includ

Re: [PATCH v4 1/4] x86/boot: Add acpitb.h to help parse acpi tables

2018-07-23 Thread Chao Fan
On Tue, Jul 24, 2018 at 02:02:57PM +0800, Baoquan He wrote: >Hi chao, > >On 07/23/18 at 05:29pm, Chao Fan wrote: >> In order to parse ACPI tables, reuse the head file linux/acpi.h, >> so that the files in 'compressed' directory can read ACPI table >> by includ

[PATCH v4 2/4] x86/boot: Add acpitb.c to parse acpi tables

2018-07-23 Thread Chao Fan
Imitate the ACPI code to parse ACPI tables. Functions are simplified cause some operations are not needed here. And also, this method won't influence the initialization of ACPI. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/Makefile | 4 + arch/x86/boot/compressed/acpitb.c

[PATCH v4 4/4] x86/boot/KASLR: Limit kaslr to choosing the immovable memory

2018-07-23 Thread Chao Fan
tch_random, and name new function as process_mem_region. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 66 ++-- 1 file changed, 55 insertions(+), 11 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index 47

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

2018-07-23 Thread Chao Fan
If 'CONFIG_MEMORY_HOTREMOVE' specified, walk the acpi srat memory tables, store the immovable memory regions, so that kaslr can get the information abouth where can be selected or not. If 'CONFIG_MEMORY_HOTREMOVE' not specified, go on the old code. Signed-off-by: Chao Fan

[PATCH v4 1/4] x86/boot: Add acpitb.h to help parse acpi tables

2018-07-23 Thread Chao Fan
In order to parse ACPI tables, reuse the head file linux/acpi.h, so that the files in 'compressed' directory can read ACPI table by including this head file. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/acpitb.h | 7 +++ 1 file changed, 7 insertions(+) create mode 10064

[PATCH v4 0/4] x86/boot/KASLR: Parse ACPI table and limit kaslr in immovable memory.

2018-07-23 Thread Chao Fan
to #define CONFIG_EFI and return false in the other stub. - Simplify two functions in head file. Any comments will be welcome. Chao Fan (4): x86/boot: Add acpitb.h to help parse acpi tables x86/boot: Add acpitb.c to parse acpi tables x86/boot/KASLR: Walk srat tables to filter immovab

Re: [PATCH v3 1/4] x86/boot: Add acpitb.h to help parse acpi tables

2018-07-20 Thread Chao Fan
On Thu, Jul 19, 2018 at 05:19:43PM +0200, Thomas Gleixner wrote: >On Tue, 17 Jul 2018, Chao Fan wrote: > >> In order to parse ACPI tables, reuse the head file linux/acpi.h, >> so that the files in 'compressed' directory can read ACPI table >> by including this hea

Re: [PATCH v3 2/4] x86/boot: Add acpitb.c to parse acpi tables

2018-07-19 Thread Chao Fan
On Thu, Jul 19, 2018 at 05:22:35PM +0200, Thomas Gleixner wrote: >On Tue, 17 Jul 2018, Chao Fan wrote: >> + >> +/* Search efi table for rsdp table. */ >> +static bool efi_get_rsdp_addr(acpi_physical_address *rsdp_addr) >> +{ >> +efi_system_table_t *systa

[PATCH v3 2/4] x86/boot: Add acpitb.c to parse acpi tables

2018-07-17 Thread Chao Fan
Imitate the ACPI code to parse ACPI tables. Functions are simplified cause some operations are not needed here. And also, this method won't influence the initialization of ACPI. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/Makefile | 4 + arch/x86/boot/compressed/acpitb.c

[PATCH v3 1/4] x86/boot: Add acpitb.h to help parse acpi tables

2018-07-17 Thread Chao Fan
In order to parse ACPI tables, reuse the head file linux/acpi.h, so that the files in 'compressed' directory can read ACPI table by including this head file. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/acpitb.h | 50 +++ 1 file changed, 50

[PATCH v3 4/4] x86/boot/KASLR: Limit kaslr to choosing the immovable memory

2018-07-17 Thread Chao Fan
tch_random, and name new function as process_mem_region. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 66 ++-- 1 file changed, 55 insertions(+), 11 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index c3

[PATCH v3 0/4] x86/boot/KASLR: Parse ACPI table and limit kaslr in immovable memory.

2018-07-17 Thread Chao Fan
->v2: - Simplify some code. Follow Baoquan He's suggestion: - Reuse the head file of acpi code. v2->v3: - Test in more conditions, so remove the 'RFC' tag. - Change some comments. Any comments will be welcome. Chao Fan (4): x86/boot: Add acpitb.h to help parse acpi

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

2018-07-17 Thread Chao Fan
If 'CONFIG_MEMORY_HOTREMOVE' specified, walk the acpi srat memory tables, store the immovable memory regions, so that kaslr can get the information abouth where can be selected or not. If 'CONFIG_MEMORY_HOTREMOVE' not specified, go on the old code. Signed-off-by: Chao Fan

Re: [RFC PATCH v2 3/4] x86/boot/KASLR: Walk srat tables to filter immovable memory

2018-07-16 Thread Chao Fan
On Mon, Jul 16, 2018 at 01:44:47PM +0200, Ingo Molnar wrote: > >* Chao Fan wrote: > >> If 'CONFIG_MEMORY_HOTREMOVE' specified, walk the acpi srat memory >> tables, store the immovable memory regions, so that kaslr can get >> the information about

[RFC PATCH v2 2/4] x86/boot: Add acpitb.c to parse acpi tables

2018-07-16 Thread Chao Fan
Imitate the ACPI code to parse ACPI tables. Functions are simplified cause some operations are not needed here. And also, this method won't influence the initialization of ACPI. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/Makefile | 4 + arch/x86/boot/compressed/acpitb.c

[RFC PATCH v2 3/4] x86/boot/KASLR: Walk srat tables to filter immovable memory

2018-07-16 Thread Chao Fan
If 'CONFIG_MEMORY_HOTREMOVE' specified, walk the acpi srat memory tables, store the immovable memory regions, so that kaslr can get the information abouth where can be selected or not. If 'CONFIG_MEMORY_HOTREMOVE' not specified, go on the old code. Signed-off-by: Chao Fan

[RFC PATCH v2 4/4] x86/boot/KASLR: Limit kaslr to choosing the immovable memory

2018-07-16 Thread Chao Fan
tch_random, and name new function as process_mem_region. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 65 ++-- 1 file changed, 54 insertions(+), 11 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index 0e

[RFC PATCH v2 1/4] x86/boot: Add acpitb.h to help parse acpi tables

2018-07-16 Thread Chao Fan
In order to parse ACPI tables, reuse the head file linux/acpi.h, so that the files in 'compressed' directory can read ACPI table by including this head file. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/acpitb.h | 49 +++ 1 file changed, 49

[RFC PATCH v2 0/4] x86/boot/KASLR: Parse ACPI table and limit kaslr in immovable memory.

2018-07-16 Thread Chao Fan
->v2: - Simplify some code. Follow Baoquan He's suggestion: - Reuse the head file of acpi code. Any comments will be welcome. Chao Fan (4): x86/boot: Add acpitb.h to help parse acpi tables x86/boot: Add acpitb.c to parse acpi tables x86/boot/KASLR: Walk srat tables to filter i

Re: Bug report about KASLR and ZONE_MOVABLE

2018-07-12 Thread Chao Fan
On Fri, Jul 13, 2018 at 07:52:40AM +0800, Baoquan He wrote: >Hi Michal, > >On 07/12/18 at 02:32pm, Michal Hocko wrote: >> On Thu 12-07-18 14:01:15, Chao Fan wrote: >> > On Thu, Jul 12, 2018 at 01:49:49PM +0800, Dou Liyang wrote: >> > >Hi Baoquan, >> &g

Re: Bug report about KASLR and ZONE_MOVABLE

2018-07-11 Thread Chao Fan
e you had a chance to fix >this in the KASLR side. > I think it's better to fix here, but not KASLR side. Cause much more code will be change if doing it in KASLR side. Since we didn't parse 'kernelcore' in compressed code, and you can see the distribution of ZONE_MOVABLE need

Re: Bug report about KASLR and ZONE_MOVABLE

2018-07-11 Thread Chao Fan
unsigned long kernel_pages; I think the logic of these two method are the same, and this method change less code. If I am wrong, please let me know. Thanks, Chao Fan > >+ /* >+ * KASLR may put kernel near

Re: Bug report about KASLR and ZONE_MOVABLE

2018-07-11 Thread Chao Fan
G of first kernel and last 11G as ZONE_MOVABLE of other 9 nodes as ZONE_MOVABLE. Thanks, Chao Fan On Wed, Jul 11, 2018 at 05:42:44PM +0800, Chao Fan wrote: >Hi all, > >I found there is a BUG about KASLR and ZONE_MOVABLE. > >When users use 'kernelcore=' parameter without

Re: Bug report about KASLR and ZONE_MOVABLE

2018-07-11 Thread Chao Fan
On Wed, Jul 11, 2018 at 05:42:44PM +0800, Chao Fan wrote: >Hi all, > >I found there is a BUG about KASLR and ZONE_MOVABLE. > >When users use 'kernelcore=' parameter without 'movable_node', >movable memory is evenly distributed to all nodes. The size of >ZON

Bug report about KASLR and ZONE_MOVABLE

2018-07-11 Thread Chao Fan
_pfns_for_nodes() of mm/page_alloc.c. If kernel is uncompressed in a tail position, then just set the memory after the kernel as ZONE_MOVABLE, at the same time, memory in other nodes will be set as ZONE_MOVABLE. If there is something wrong, pleas let me know. And any comments will be welcome. Thanks, Chao Fan

Re: [RFC PATCH 0/4] x86/boot/KASLR: Parse ACPI table and limit kaslr in immovable memory.

2018-07-02 Thread Chao Fan
On Tue, Jul 03, 2018 at 09:39:02AM +0800, Baoquan He wrote: >On 07/03/18 at 09:32am, Chao Fan wrote: >> On Mon, Jul 02, 2018 at 08:18:55PM +0800, Baoquan He wrote: >> >Hi Chao, >> > >> >On 06/12/18 at 04:10pm, Chao Fan wrote: >> >> *** Issues need

Re: [RFC PATCH 0/4] x86/boot/KASLR: Parse ACPI table and limit kaslr in immovable memory.

2018-07-02 Thread Chao Fan
On Mon, Jul 02, 2018 at 08:18:55PM +0800, Baoquan He wrote: >Hi Chao, > >On 06/12/18 at 04:10pm, Chao Fan wrote: >> *** Issues need be discussed >> There are several issues I am not quite sure, please help review and >> give suggestions: >> >> 1) In PATCH

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

2018-06-12 Thread Chao Fan
If 'CONFIG_MEMORY_HOTREMOVE' specified, walk the acpi srat memory tables, store the immovable memory regions, so that kaslr can get the information abouth where can be selected or not. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 55 ++

[RFC PATCH 1/4] x86/boot: Add acpitb.h to help parse acpi tables

2018-06-12 Thread Chao Fan
tables in 'compressed' directory. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/acpitb.h | 175 ++ 1 file changed, 175 insertions(+) create mode 100644 arch/x86/boot/compressed/acpitb.h diff --git a/arch/x86/boot/compressed/acpitb.h b/arch/x86/boot/

[RFC PATCH 2/4] x86/boot: Add acpitb.c to parse acpi tables

2018-06-12 Thread Chao Fan
To get more information about memory, acpi tables should be parsed. But can't use ACPI code directely, so imitate the ACPI code to dig the useful srat tables from ACPI tables. Only dig the useful tables, and don't influence the initialization of ACPI. Signed-off-by: Chao Fan --- arc

[RFC PATCH 4/4] x86/boot/KASLR: Limit kaslr to choosing the immovable memory

2018-06-12 Thread Chao Fan
unction as process_mem_region. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 65 ++-- 1 file changed, 54 insertions(+), 11 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index 4edff0501540..a0a07e549

[RFC PATCH 0/4] x86/boot/KASLR: Parse ACPI table and limit kaslr in immovable memory.

2018-06-12 Thread Chao Fan
e tests, so it's with RFC tag. Any comments will be welcome. Chao Fan (4): x86/boot: Add acpitb.h to help parse acpi tables x86/boot: Add acpitb.c to parse acpi tables x86/boot/KASLR: Walk srat tables to filter immovable memory x86/boot/KASLR: Limit kaslr to choosing the immovable

Re: [PATCH 1/2] x86/boot/KASLR: Add two functions for 1GB huge pages handling

2018-05-16 Thread Chao Fan
On Thu, May 17, 2018 at 12:03:43PM +0800, Baoquan He wrote: >Hi Chao, > >On 05/17/18 at 11:27am, Chao Fan wrote: >> >+/* Store the number of 1GB huge pages which user specified.*/ >> >+static unsigned long max_gb_huge_pages; >> >+ >> >+static i

Re: [PATCH 1/2] x86/boot/KASLR: Add two functions for 1GB huge pages handling

2018-05-16 Thread Chao Fan
if (size >= image_size) { >+ tmp.start = addr + i*PUD_SIZE; >+ tmp.size = size; >+ store_slot_info(&tmp, image_size); >+} I have another question not related to kaslr. Here you try to avoid the memory from addr to (addr + i * PUD_SIZE), but I wonder if after walking all memory regions, 'max_gb_huge_pages' is still more than 0, which means there isn't enough memory slots for huge page, what will happen? Thanks, Chao Fan >+} >+ > static unsigned long slots_fetch_random(void) > { > unsigned long slot; >-- >2.13.6 > > >

Re: [PATCH v9 0/5] x86/KASLR: Add parameter kaslr_boot_mem=nn[KMG]@ss[KMG]

2018-03-19 Thread Chao Fan
On Mon, Mar 19, 2018 at 03:24:46PM +0800, Baoquan He wrote: >On 03/12/18 at 08:04pm, Chao Fan wrote: >> On Mon, Mar 12, 2018 at 11:57:27AM +0100, Ingo Molnar wrote: >> > >> >* Baoquan He wrote: >> > >> >> Hi Ingo, >> >> >> >>

Re: [PATCH v9 0/5] x86/KASLR: Add parameter kaslr_boot_mem=nn[KMG]@ss[KMG]

2018-03-12 Thread Chao Fan
On Mon, Mar 12, 2018 at 11:57:27AM +0100, Ingo Molnar wrote: > >* Baoquan He wrote: > >> Hi Ingo, >> >> On 03/12/18 at 10:35am, Ingo Molnar wrote: >> > >> > * Chao Fan wrote: >> > >> > > Long time no reply, rebase

[PATCH v9 0/5] x86/KASLR: Add parameter kaslr_boot_mem=nn[KMG]@ss[KMG]

2018-02-28 Thread Chao Fan
d of extending mvoable_node - Use the clamp to calculate the memory intersecting, which makes logical more clear. - Disable memory mirror if movable_node specified v1->v2: Follow Dou Liyang's suggestion: - Add the parse for movable_node=nn[KMG] without @ss[KMG] - Fix the bug for more t

[PATCH v9 4/5] x86/KASLR: Skip memory mirror handling if movable_node specified

2018-02-28 Thread Chao Fan
In kernel code, if 'movable_node' specified, it will skip the mirror feature. So also skip mirror feature in KASLR. Signed-off-by: Chao Fan Acked-by: Baoquan He --- arch/x86/boot/compressed/kaslr.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/boot/compressed

[PATCH v9 2/5] x86/KASLR: Handle the memory regions specified in kaslr_boot_mem

2018-02-28 Thread Chao Fan
_mem_region. Signed-off-by: Chao Fan Tested-by: Luiz Capitulino Acked-by: Baoquan He --- arch/x86/boot/compressed/kaslr.c | 64 +--- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/comp

[PATCH v9 1/5] x86/KASLR: Add kaslr_boot_mem=nn[KMG]@ss[KMG]

2018-02-28 Thread Chao Fan
movable regions, this will make memory hotplug fail. With the help of 'kaslr_boot_mem=', limit kernel in those immovable regions specified. Signed-off-by: Chao Fan Tested-by: Luiz Capitulino Acked-by: Baoquan He --- arch/x86/boot/compressed/kaslr.c | 73 +

[PATCH v9 3/5] x86/KASLR: Give a warning if movable_node specified without kaslr_boot_mem=

2018-02-28 Thread Chao Fan
Since only 'movable_node' specified without 'kaslr_boot_mem=' may break memory hotplug, so reconmmend users using 'kaslr_boot_mem=' when 'movable_node' specified. Signed-off-by: Chao Fan Acked-by: Baoquan He --- arch/x86/boot/compressed/kaslr.c | 10 +

[PATCH v9 5/5] document: add document for kaslr_boot_mem

2018-02-28 Thread Chao Fan
Cc: linux-...@vger.kernel.org Cc: Jonathan Corbet Cc: Randy Dunlap Signed-off-by: Chao Fan --- Documentation/admin-guide/kernel-parameters.txt | 10 ++ 1 file changed, 10 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel

Re: [PATCH v8 0/5] x86/KASLR: Add parameter kaslr_mem=nn[KMG]@ss[KMG]

2018-01-28 Thread Chao Fan
Hi Kees, Since no reply for one week, any suggestions for this version? Thanks, Chao Fan On Tue, Jan 23, 2018 at 04:35:41PM +0800, Chao Fan wrote: >This is v8 resend. There's no code change. Just improve code comments >and document accordingly. So add Baoquan's Acked-by and L

[PATCH v8 3/5] x86/KASLR: Give a warning if movable_node specified without kaslr_mem=

2018-01-23 Thread Chao Fan
Since only 'movable_node' specified without 'kaslr_mem=' may break memory hotplug, so reconmmend users using 'kaslr_mem=' when 'movable_node' specified. Acked-by: Baoquan He Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 10 ++

[PATCH v8 1/5] x86/KASLR: Add kaslr_mem=nn[KMG]@ss[KMG]

2018-01-23 Thread Chao Fan
regions, this will make memory hotplug fail. With the help of 'kaslr_mem=', limit kernel in those immovable regions specified. Tested-by: Luiz Capitulino Acked-by: Baoquan He Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 73 ++

[PATCH v8 4/5] x86/KASLR: Skip memory mirror handling if movable_node specified

2018-01-23 Thread Chao Fan
In kernel code, if 'movable_node' specified, it will skip the mirror feature. So also skip mirror feature in KASLR. Acked-by: Baoquan He Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/boot/compressed

[PATCH v8 5/5] document: add document for kaslr_mem

2018-01-23 Thread Chao Fan
Cc: linux-...@vger.kernel.org Cc: Jonathan Corbet Cc: Randy Dunlap Signed-off-by: Chao Fan --- Documentation/admin-guide/kernel-parameters.txt | 10 ++ 1 file changed, 10 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel

[PATCH v8 2/5] x86/KASLR: Handle the memory regions specified in kaslr_mem

2018-01-23 Thread Chao Fan
on. Tested-by: Luiz Capitulino Acked-by: Baoquan He Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 64 +--- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.

<    1   2   3   4   >