[RFC PATCH] kaslr: get ACPI SRAT table to avoid movable memory

2017-08-18 Thread Chao Fan
KASLR should choose the memory region of immovable node to extract kernel. So get ACPI SRAT table and store the memory region of movable node which kaslr shold avoid. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 231 +++ arch/x86/boot

Re: [RFC PATCH] kaslr: get ACPI SRAT table to avoid movable memory

2017-08-18 Thread Chao Fan
a better method to handle the movable memory, please tell me. Thanks, Chao Fan On Fri, Aug 18, 2017 at 04:58:20PM +0800, Chao Fan wrote: >KASLR should choose the memory region of immovable node to extract kernel. >So get ACPI SRAT table and store the memory region of movable node which

Re: [PATCH 1/2] x86/boot/KASLR: Adapt process_e820_entry for all kinds of memory map

2017-06-20 Thread Chao Fan
andom_phys_addr(min_addr, output_size); Cause you will walk efi map firstly, and then e820 map(or not). Thanks, Chao Fan >--- > arch/x86/boot/compressed/kaslr.c | 60 ++-- > 1 file changed, 33 insertions(+), 27 deletions(-) > >diff --git a/arch/x

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

2017-06-21 Thread Chao Fan
kernel is in mirror region. If there are any problems, please let me know. Thanks, Chao Fan On Thu, Jun 15, 2017 at 03:52:47PM +0800, Baoquan He wrote: >Our customer reported that Kernel text may be located on non-mirror >region (movable zone) when both address range mirroring feature and

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

2017-06-21 Thread Chao Fan
On Thu, Jun 22, 2017 at 11:20:32AM +0800, Baoquan He wrote: >On 06/22/17 at 11:10am, Chao Fan wrote: >> Hi all, >> >> After testing this issue for 100 times in total, I think this patchset >> works well. > >Thanks for your effort, Chao! No problem, and many thank

[PATCH v2 1/4] kaslr: parse the extended movable_node=nn[KMG]@ss[KMG]

2017-11-01 Thread Chao Fan
e the regions in immovable_mem, where should be chosen by kaslr. Multiple regions can be specified, comma delimited. Considering the usage of memory, only support for 4 regions. 4 regions contains 2 nodes at least, enough for kernel to extract. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/ka

[PATCH v2 2/4] kaslr: select the memory region in immovable node to process

2017-11-01 Thread Chao Fan
, and one entry of e820 or efi may contain the memory in different nodes sometimes. It may split one node or one entry to several regions. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 60 ++-- 1 file changed, 52 insertions(+), 8 deletions(-) diff

[PATCH v2 4/4] kaslr: clean up a useless variable and some usless space

2017-11-01 Thread Chao Fan
There are two same variable "rc" in this function. One is in the circulation, the other is out of the circulation. The one out will never be used, so drop it. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) di

[PATCH v2 3/4] document: change the document for the extended movable_node

2017-11-01 Thread Chao Fan
Add the document for the change of extended movable_node=nn[KMG]@ss[KMG]. Cc: Jonathan Corbet Cc: linux-...@vger.kernel.org Signed-off-by: Chao Fan --- Documentation/admin-guide/kernel-parameters.txt | 9 + 1 file changed, 9 insertions(+) diff --git a/Documentation/admin-guide/kernel

[PATCH v2 0/4] kaslr: extend movable_node to movable_node=nn[KMG]@ss[KMG]

2017-11-01 Thread Chao Fan
memmap. PATCH 3/4 add document. PATCH 4/4 cleans up some little problems. v1->v2: Follow Dou's suggestion: - Add the parse for movable_node=nn[KMG] without @ss[KMG] - Fix the bug for more than one "movable_node=" specified - Drop useless variables and use mem_vector region direct

Re: [PATCH v2 1/4] kaslr: parse the extended movable_node=nn[KMG]@ss[KMG]

2017-11-13 Thread Chao Fan
On Mon, Nov 13, 2017 at 04:10:41PM +0800, Baoquan He wrote: >Hi Chao, Hi Baoquan, Thanks for your reply. > >Please think more on your patches, better to discuss with your >colleagues and ask them to help review before your post. > >On 11/01/17 at 07:32pm, Chao Fan wr

Re: [PATCH v2 2/4] kaslr: select the memory region in immovable node to process

2017-11-13 Thread Chao Fan
On Mon, Nov 13, 2017 at 04:31:31PM +0800, Baoquan He wrote: >On 11/01/17 at 07:32pm, Chao Fan wrote: >> Compare the region of memmap entry and immovable_mem, then choose the >> intersection to process_mem_region. >> >> Since the interrelationship between e820 or efi e

Re: [PATCH v2 4/4] kaslr: clean up a useless variable and some usless space

2017-11-13 Thread Chao Fan
On Mon, Nov 13, 2017 at 04:32:33PM +0800, Baoquan He wrote: >On 11/01/17 at 07:32pm, Chao Fan wrote: >> There are two same variable "rc" in this function. One is in the >> circulation, the other is out of the circulation. The one out will never >> be used, so drop it

Re: [PATCH v2 2/4] kaslr: select the memory region in immovable node to process

2017-11-13 Thread Chao Fan
On Mon, Nov 13, 2017 at 05:26:24PM +0800, Baoquan He wrote: >On 11/13/17 at 05:18pm, Chao Fan wrote: >> On Mon, Nov 13, 2017 at 04:31:31PM +0800, Baoquan He wrote: >> >On 11/01/17 at 07:32pm, Chao Fan wrote: >> >> Compare the region of memmap entry and

[PATCH 3/4] document: change the document for the extended movable_node

2017-10-19 Thread Chao Fan
Add the document for the change of extended movable_node=nn[KMG]@ss[KMG]. Cc: Jonathan Corbet Cc: linux-...@vger.kernel.org Signed-off-by: Chao Fan --- Documentation/admin-guide/kernel-parameters.txt | 9 + 1 file changed, 9 insertions(+) diff --git a/Documentation/admin-guide/kernel

[PATCH 0/4] kaslr: extend movable_node to movable_node=nn[KMG]@ss[KMG]

2017-10-19 Thread Chao Fan
tor, the usage of memory here is not too big. PATCH 1/4 parse the extended movable_node=nn[KMG]@ss[KMG], then store the memory regions. PATCH 2/4 selects the memory region in immovable node when process memmap. PATCH 3/4 is the change of document. PATCH 4/4 cleans up

[PATCH 4/4] kaslr: clean up a useless variable and some usless space

2017-10-19 Thread Chao Fan
There are two same variable "rc" in this function. One is in the circulation, the other is out of the circulation. The one out will never be used, so drop it. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) di

[PATCH 2/4] kaslr: select the memory region in immovable node to process

2017-10-19 Thread Chao Fan
as a region to process_mem_region. It may split one node or one entry to several regions. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 72 1 file changed, 58 insertions(+), 14 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr.c b

[PATCH 1/4] kaslr: parse the extended movable_node=nn[KMG]@ss[KMG]

2017-10-19 Thread Chao Fan
usage of memory, only support for 4 regions. 4 regions contains 2 nodes at least, and is enough for kernel to extract. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 63 +++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/arch/x86

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

[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

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

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

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

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

[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

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

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

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: 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
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-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: KASLR may break some kernel features (was Re: [PATCH v5 1/4] kaslr: add immovable_mem=nn[KMG]@ss[KMG] to specify extracting memory)

2018-01-11 Thread Chao Fan
s case, what range do we need to avoid? Only [1G, 2G]? > >Any ranges like that that need to be avoided should be known at build >time, so they should simply be added to the mem_avoid list that is >already present in the KASLR code... > Hi Kees, So this issue can be figured out in a independent patch. And does this patch have any problems? If so, please tell me, I will try my best to improve it. Thanks, Chao Fan >-Kees > >-- >Kees Cook >Pixel Security > >

Re: KASLR may break some kernel features (was Re: [PATCH v5 1/4] kaslr: add immovable_mem=nn[KMG]@ss[KMG] to specify extracting memory)

2018-01-11 Thread Chao Fan
;> >> Any ranges like that that need to be avoided should be known at build >> time, so they should simply be added to the mem_avoid list that is >> already present in the KASLR code... > >Seems KASLR doesn't have an solution which allow user to specify avoided >ran

Re: KASLR may break some kernel features (was Re: [PATCH v5 1/4] kaslr: add immovable_mem=nn[KMG]@ss[KMG] to specify extracting memory)

2018-01-12 Thread Chao Fan
On Sat, Jan 13, 2018 at 12:02:26PM +0800, Baoquan He wrote: >On 01/12/18 at 01:52pm, Luiz Capitulino wrote: >> On Fri, 12 Jan 2018 10:47:53 +0800 >> Chao Fan wrote: >> >> > On Fri, Jan 12, 2018 at 10:31:52AM +0800, Baoquan He wrote: >> > >On 01/11/18 at

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

2018-01-18 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. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 10 ++ 1 file changed, 10 i

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

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

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

2018-01-18 Thread Chao Fan
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-parameters.txt index e2de7c006a74..28a879f62560 100644 --- a

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

2018-01-18 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 5/5] document: add document for kaslr_mem

2018-01-18 Thread Chao Fan
On Fri, Jan 19, 2018 at 11:53:31AM +0800, Baoquan He wrote: >On 01/19/18 at 11:36am, Chao Fan wrote: >> Signed-off-by: Chao Fan >> --- >> Documentation/admin-guide/kernel-parameters.txt | 10 ++ >> 1 file changed, 10 insertions(+) >> >> diff -

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

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

2018-01-23 Thread Chao Fan
27;s suggestion: - Change names of several functions. - Add a new parameter "immovable_mem" instead 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 Liyan

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

Re: [PATCH v5 1/4] kaslr: add immovable_mem=nn[KMG]@ss[KMG] to specify extracting memory

2018-01-04 Thread Chao Fan
On Thu, Jan 04, 2018 at 06:30:57PM +0800, Baoquan He wrote: >On 01/04/18 at 04:02pm, Chao Fan wrote: >> In current code, kaslr may choose the memory region in movable >> nodes to extract kernel, which will make the nodes can't be hot-removed. >> To solve it, we can sp

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

Re: [PATCH v6 5/5] kaslr: add kaslr_mem=nn[KMG]!ss[KMG] to avoid memory regions

2018-01-16 Thread Chao Fan
On Tue, Jan 16, 2018 at 11:34:23AM -0500, Luiz Capitulino wrote: >On Tue, 16 Jan 2018 08:43:20 +0800 >Baoquan He wrote: > >> On 01/15/18 at 08:49pm, Chao Fan wrote: >> > Hi Luiz, >> > >> > I don't know if this patch is OK for you. >> > O

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

2018-01-17 Thread Chao Fan
regions, this will make memory hotplug fail. With the help of 'kaslr_mem=', limit kernel in those immovable regions specified. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 73 ++-- 1 file changed, 70 insertions(+), 3 deletions(-) di

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

2018-01-17 Thread Chao Fan
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-parameters.txt index e2de7c006a74..f6d5adde1a73 100644 --- a

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

2018-01-17 Thread Chao Fan
gion. 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.c index b21741135673..b200a7ceafc1 100644 --- a/arch

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

2018-01-17 Thread Chao Fan
ting, 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 than one "movable_node=" specified - Drop useless variables

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

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

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

2018-01-17 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.. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 10 ++ 1 file changed, 10 i

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

2018-01-17 Thread Chao Fan
On Wed, Jan 17, 2018 at 12:32:35PM -0500, Luiz Capitulino wrote: >On Wed, 17 Jan 2018 18:53:46 +0800 >Chao Fan wrote: > >> ***Background: >> People reported that kaslr may randomly chooses some positions >> which are located in movable memory regions. This will brea

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

2018-01-17 Thread Chao Fan
On Wed, Jan 17, 2018 at 10:03:54PM +0800, Baoquan He wrote: >On 01/17/18 at 06:53pm, Chao Fan wrote: >> In kernel code, if movable_node specified, it will skip the mirror >> feature. So we should also skip mirror feature in KASLR. >> >> Signed-off-by: Chao Fan >>

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

2018-01-17 Thread Chao Fan
On Wed, Jan 17, 2018 at 10:02:48PM +0800, Baoquan He wrote: >On 01/17/18 at 06:53pm, Chao Fan wrote: >> Since only 'movable_node' specified without 'kaslr_mem=' may break >> memory hotplug, so reconmmend users using 'kaslr_mem=' when >> '

Re: [PATCH v5 1/4] kaslr: add immovable_mem=nn[KMG]@ss[KMG] to specify extracting memory

2018-01-08 Thread Chao Fan
On Mon, Jan 08, 2018 at 09:39:54AM -0500, Luiz Capitulino wrote: >On Fri, 5 Jan 2018 10:58:11 +0800 >Chao Fan wrote: > >> On Thu, Jan 04, 2018 at 06:30:57PM +0800, Baoquan He wrote: >> >On 01/04/18 at 04:02pm, Chao Fan wrote: >> >> In current code, kaslr may

[PATCH v6 2/5] kaslr: give a warning if movable_node specified without kaslr_mem=

2018-01-15 Thread Chao Fan
Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index b071f6edd7b2..38816d3f8865 100644 --- a/arch/x86/boot/compressed/kaslr.c +++ b/arch/x86/boot

[PATCH v6 4/5] kaslr: calculate the memory region in kaslr_mem

2018-01-15 Thread Chao Fan
If there is no kaslr_mem= region specified, use region directely. Otherwise, calculate the intersecting between efi or e820 memmap entry and kaslr_mem. Rename process_mem_region to slots_count to match slots_fetch_random, and rename new function sa process_mem_region. Signed-off-by: Chao Fan

Re: [PATCH v6 5/5] kaslr: add kaslr_mem=nn[KMG]!ss[KMG] to avoid memory regions

2018-01-15 Thread Chao Fan
e too slow and is not good for the randomness. So as Kess said, I put the regions suitable for 1G huge page to mem_avoid, you can use kaslr_mem=1G!1G to solve the problem in your email. Thanks, Chao Fan On Mon, Jan 15, 2018 at 08:40:16PM +0800, Chao Fan wrote: >In current code, kaslr choose

Re: [PATCH v6 1/5] kaslr: add kaslr_mem=nn[KMG]@ss[KMG] to specify extracting memory

2018-01-15 Thread Chao Fan
On Mon, Jan 15, 2018 at 08:40:12PM +0800, Chao Fan wrote: >In current code, kaslr only has a method to avoid some memory regions, >but no method to specify the regions for kaslr to extract. So kaslr >may choose the wrong position sometimes, which will cause some other >features fail.

[PATCH v6 5/5] kaslr: add kaslr_mem=nn[KMG]!ss[KMG] to avoid memory regions

2018-01-15 Thread Chao Fan
period. It can help users to avoid more memory regions, not only the 1G huge huge page issue. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 56 +++- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr.c b

[PATCH v6 1/5] kaslr: add kaslr_mem=nn[KMG]@ss[KMG] to specify extracting memory

2018-01-15 Thread Chao Fan
t;handle_mem_filter", since it will not only handle memmap parameter now. Multiple regions can be specified, comma delimited. Considering the usage of memory, only support for 4 regions. 4 regions contains 2 nodes at least, enough for kernel to extract. Signed-off-by: Chao Fan --- ar

[PATCH v6 3/5] kaslr: disable memory mirror feature when movable_node

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

[PATCH v6 0/5] kaslr: add parameter kaslr_mem=nn[KMG][@|!ss[KMG]]

2018-01-15 Thread Chao Fan
ption for the document. v4->v5: - Change the problem reported by LKP Follow Dou's suggestion: - Also return if match "movable_node" when parsing kernel commandline in handle_mem_filter without define CONFIG_MEMORY_HOTPLUG v5->v6: - Add the last patch to save the avoid m

Re: [PATCH v6 1/5] kaslr: add kaslr_mem=nn[KMG]@ss[KMG] to specify extracting memory

2018-01-15 Thread Chao Fan
On Mon, Jan 15, 2018 at 02:40:35PM -0800, Randy Dunlap wrote: >On 01/15/2018 04:40 AM, Chao Fan wrote: >> In current code, kaslr only has a method to avoid some memory regions, >> but no method to specify the regions for kaslr to extract. So kaslr >> may choose the wrong posi

Re: [PATCH v6 5/5] kaslr: add kaslr_mem=nn[KMG]!ss[KMG] to avoid memory regions

2018-01-15 Thread Chao Fan
On Tue, Jan 16, 2018 at 08:43:20AM +0800, Baoquan He wrote: >On 01/15/18 at 08:49pm, Chao Fan wrote: >> Hi Luiz, >> >> I don't know if this patch is OK for you. >> Of coure you can only use kaslr_mem=nn@ss to solve the 1G huge page >> issue. Because we know

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

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

  1   2   3   4   >