Re: KASLR causes intermittent boot failures on some systems

2017-04-08 Thread Baoquan He
Hi Dan, Thanks! On 04/08/17 at 12:02am, Dan Williams wrote: > > I got below problem when configure ndctl, didn't find a package named > > libkmod: > > > > ~ > > configure: error: Package requirements (libkmod) were not met: > > > > No package 'libkmod' found > > kmod-devel provides that

Re: [PATCH 2/4] KASLR: Parse all memmap entries in cmdline

2017-04-18 Thread Baoquan He
Hi Kees, Thanks for your reviewing! On 04/18/17 at 01:22pm, Kees Cook wrote: > > static int > > parse_memmap(char *p, unsigned long long *start, unsigned long long *size) > > @@ -142,40 +112,33 @@ parse_memmap(char *p, unsigned long long *start, > > unsigned long long *size) > >

Re: [PATCH 0/4] Handle memmap and mem kernel options in boot stage kaslr

2017-04-18 Thread Baoquan He
On 04/18/17 at 11:47am, Ingo Molnar wrote: > > * Baoquan He <b...@redhat.com> wrote: > > > People reported kernel panic occurs during system boots up with mem boot > > option. > > After checking code, several problems are found about memmap= and

Re: [PATCH 3/4] KASLR: Handle memory limit specified by memmap and mem option

2017-04-18 Thread Baoquan He
On 04/18/17 at 01:36pm, Kees Cook wrote: > On Mon, Apr 17, 2017 at 6:34 AM, Baoquan He <b...@redhat.com> wrote: > > Option mem= will limit the max address system can use. Any memory > > region above the limit will be removed. And memmap=nn[KMG] which > > has no of

Re: [PATCH 3/4] KASLR: Handle memory limit specified by memmap and mem option

2017-04-18 Thread Baoquan He
On 04/19/17 at 08:50am, Baoquan He wrote: > On 04/18/17 at 01:36pm, Kees Cook wrote: > > On Mon, Apr 17, 2017 at 6:34 AM, Baoquan He <b...@redhat.com> wrote: > > > @@ -432,7 +455,8 @@ static void process_e820_entry(struct e820entry > > > *entry, > > >

Re: [PATCH 2/4] KASLR: Parse all memmap entries in cmdline

2017-04-18 Thread Baoquan He
On 04/18/17 at 04:32pm, Kees Cook wrote: > On Tue, Apr 18, 2017 at 3:52 PM, Baoquan He <b...@redhat.com> wrote: > > On 04/18/17 at 01:22pm, Kees Cook wrote: > >> > +#define COMMAND_LINE_SIZE 256 > >> > +static int handle_mem_memmap(void) >

Re: [PATCH 3/4] KASLR: Handle memory limit specified by memmap and mem option

2017-04-18 Thread Baoquan He
On 04/18/17 at 01:36pm, Kees Cook wrote: > On Mon, Apr 17, 2017 at 6:34 AM, Baoquan He <b...@redhat.com> wrote: > > @@ -432,7 +455,8 @@ static void process_e820_entry(struct e820entry *entry, > > { > > struct mem_vector region, overlap; > >

Re: [PATCH 0/4] Handle memmap and mem kernel options in boot stage kaslr

2017-04-18 Thread Baoquan He
On 04/18/17 at 02:51pm, Ingo Molnar wrote: > > > I ported this series to tip:x86/boot (please post future versions against > > > that), > > > and beyond a trivial conflict with e820entry => e820_entry, it fails to > > > build on > > > 32-bit allmodconfig: > > > > > > ld: -r and -shared may

Re: KASLR causes intermittent boot failures on some systems

2017-04-24 Thread Baoquan He
On 04/24/17 at 01:52pm, Dan Williams wrote: > On Mon, Apr 24, 2017 at 1:37 PM, Thomas Garnier <thgar...@google.com> wrote: > > ) > > > > On Thu, Apr 20, 2017 at 6:26 AM, Baoquan He <b...@redhat.com> wrote: > >> On 04/19/17 at 07:27am, Thomas Garnier wr

Re: KASLR causes intermittent boot failures on some systems

2017-04-24 Thread Baoquan He
On 04/24/17 at 05:41pm, Thomas Garnier wrote: > On Mon, Apr 24, 2017 at 4:07 PM, Baoquan He <b...@redhat.com> wrote: > > Yeah, according to my debugging tracking, it goes as Dan said. And the > > is_ram is REGION_DISJOINT. And till arch_add_memory, the parameters > >

Re: KASLR causes intermittent boot failures on some systems

2017-04-24 Thread Baoquan He
On 04/24/17 at 04:18pm, Dan Williams wrote: > On Mon, Apr 24, 2017 at 4:07 PM, Baoquan He <b...@redhat.com> wrote: > > On 04/24/17 at 01:52pm, Dan Williams wrote: > [..] > >> When using the memmap= parameter we're using this call by default: > >> > >>

Re: [PATCH v8 02/13] iommu/amd: add several helper functions

2017-07-31 Thread Baoquan He
Hi Joerg, On 07/27/17 at 05:06pm, Joerg Roedel wrote: > On Fri, Jul 21, 2017 at 04:59:00PM +0800, Baoquan He wrote: > > Move single iommu enabling codes into a wrapper function > > early_enable_iommu(). > > This can make later kdump change easier.

Re: [PATCH v8 10/13] iommu/amd: Allocate memory below 4G for dev table if translation pre-enabled

2017-07-31 Thread Baoquan He
Hi Joerg, On 07/28/17 at 05:06pm, Baoquan He wrote: > Hi Joerg, > > On 07/27/17 at 05:55pm, Joerg Roedel wrote: > > On Fri, Jul 21, 2017 at 04:59:08PM +0800, Baoquan He wrote: > > > AMD pointed out it's unsafe to update the device-table while iommu > > > is

Re: [PATCH v8 10/13] iommu/amd: Allocate memory below 4G for dev table if translation pre-enabled

2017-07-31 Thread Baoquan He
On 07/31/17 at 12:21pm, Joerg Roedel wrote: > Hi Baoquan, > > On Mon, Jul 31, 2017 at 06:15:30PM +0800, Baoquan He wrote: > > I plan to add GFP_DMA32 when allocate amd_iommu_dev_table in > > early_amd_iommu_init() as below. Then in kdump kernel we don't need to

Re: [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

2017-07-28 Thread Baoquan He
On 07/28/17 at 11:55am, Ingo Molnar wrote: > > * Matt Fleming <m...@codeblueprint.co.uk> wrote: > > > On Fri, 21 Jul, at 09:19:56PM, Baoquan He wrote: > > > > > > There are places where the efi map is getting and used like this. E.g > > > in efi_

Re: [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

2017-07-28 Thread Baoquan He
Hi Matt, On 07/28/17 at 11:55am, Ingo Molnar wrote: > > * Matt Fleming <m...@codeblueprint.co.uk> wrote: > > > On Fri, 21 Jul, at 09:19:56PM, Baoquan He wrote: > > > > > > There are places where the efi map is getting and used like this. E.g > >

Re: [PATCH v8 10/13] iommu/amd: Allocate memory below 4G for dev table if translation pre-enabled

2017-07-28 Thread Baoquan He
On 07/28/17 at 01:18pm, Joerg Roedel wrote: > On Fri, Jul 28, 2017 at 07:15:53PM +0800, Baoquan He wrote: > > On 07/28/17 at 01:14pm, Joerg Roedel wrote: > > > Yes, exactly, the first device table also needs to be allocated with > > > GFP_DMA32 so that it ends

Re: [PATCH v8 10/13] iommu/amd: Allocate memory below 4G for dev table if translation pre-enabled

2017-07-28 Thread Baoquan He
On 07/28/17 at 01:14pm, Joerg Roedel wrote: > On Fri, Jul 28, 2017 at 05:06:19PM +0800, Baoquan He wrote: > > Do you mean the allocation of amd_iommu_dev_table in > > early_amd_iommu_init() also need be addressed for 1st kernel? Seems we > > don't make sure that for 1s

Re: [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

2017-07-28 Thread Baoquan He
On 07/28/17 at 06:18pm, Baoquan He wrote: > On 07/28/17 at 11:55am, Ingo Molnar wrote: > > > > * Matt Fleming <m...@codeblueprint.co.uk> wrote: > > > > > On Fri, 21 Jul, at 09:19:56PM, Baoquan He wrote: > > > > > > > > There are

Re: [PATCH] x86/boot/KASLR: Extend movable_node option for KASLR

2017-08-03 Thread Baoquan He
On 08/04/17 at 10:42am, Dou Liyang wrote: > Hi Baoquan, > > At 08/04/2017 10:00 AM, Baoquan He wrote: > > On 08/04/17 at 09:37am, Dou Liyang wrote: > > > Hi Chao,Baoquan > > > > > > At 08/04/2017 07:49 AM, Baoquan He wrote: > > > > On 08/0

Re: [PATCH] x86/boot/KASLR: Extend movable_node option for KASLR

2017-08-03 Thread Baoquan He
On 08/04/17 at 09:37am, Dou Liyang wrote: > Hi Chao,Baoquan > > At 08/04/2017 07:49 AM, Baoquan He wrote: > > On 08/03/17 at 08:24pm, Chao Fan wrote: > > > It's almost another "mem=". > > > > No, it is different. > > See Documenta

Re: [PATCH] x86/boot/KASLR: Extend movable_node option for KASLR

2017-08-03 Thread Baoquan He
On 08/03/17 at 08:24pm, Chao Fan wrote: > It's almost another "mem=". Then why not using 'mem=' directly? > > On Thu, Aug 03, 2017 at 08:17:21PM +0800, Dou Liyang wrote: > >movable_node is a boot-time switch to make hot-pluggable memory > >NUMA nodes to be movable. This option is based on an

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

2017-08-04 Thread Baoquan He
issue fix according to Kees's comment. This is based on tip/x86/boot, patch 1,2,3/4 in v5 post has been put into tip/x86/boot now. Baoquan He (2): efi: Introduce efi_memdesc_ptr to get pointer to memmap descriptor x86/boot/KASLR: Restrict kernel to be randomized in mirror regions arch

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

2017-08-04 Thread Baoquan He
memory map. Signed-off-by: Baoquan He <b...@redhat.com> --- arch/x86/boot/compressed/kaslr.c | 68 ++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index 99c719

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

2017-08-04 Thread Baoquan He
Sorry, NACK this series, there's error to hang system. Before I just halt system intentionally with error() to check the efi memmap printing, didn't notice this. Checking the cause. On 08/04/17 at 03:26pm, Baoquan He wrote: > Patch 1/2 is newly added to add efi_memdesc_ptr helper to w

[PATCH v8 1/2] efi: Introduce efi_memdesc_ptr to get pointer to memmap descriptor

2017-08-04 Thread Baoquan He
usage and struct efi_info for x86 ARCH only. Introduce efi_memdesc_ptr to get pointer to a map descriptor, and replace several places of open code with it. Suggested-by: Ingo Molnar <mi...@kernel.org> Signed-off-by: Baoquan He <b...@redhat.com> --- arch/x86/boot/compre

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

2017-08-04 Thread Baoquan He
On 08/04/17 at 05:59pm, Chao Fan wrote: > On Fri, Aug 04, 2017 at 05:22:41PM +0800, Baoquan He wrote: > >On 08/04/17 at 03:52pm, Baoquan He wrote: > >> Sorry, NACK this series, there's error to hang system. Before I just > >> halt system intentionally with error() to ch

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

2017-08-04 Thread Baoquan He
On 08/04/17 at 03:52pm, Baoquan He wrote: > Sorry, NACK this series, there's error to hang system. Before I just > halt system intentionally with error() to check the efi memmap printing, > didn't notice this. Checking the cause. I rebuilt the code or change the one of the replacement b

Re: [PATCH v10 00/12] Fix the on-flight DMA issue on system with amd iommu

2017-08-15 Thread Baoquan He
On 08/15/17 at 06:18pm, Joerg Roedel wrote: > On Wed, Aug 09, 2017 at 04:33:32PM +0800, Baoquan He wrote: > > Baoquan He (12): > > iommu/amd: Detect pre enabled translation > > iommu/amd: add several helper functions > > Revert "iommu/amd: Suppress IO_PAGE_FAU

Re: [PATCH v9 1/2] efi: Introduce efi_early_memdesc_ptr to get pointer to memmap descriptor

2017-08-16 Thread Baoquan He
On 08/16/17 at 12:37pm, Matt Fleming wrote: > On Mon, 14 Aug, at 10:54:23PM, Baoquan He wrote: > > The existing map iteration helper for_each_efi_memory_desc_in_map can > > only be used after OS initializes EFI to fill data of struct efi_memory_map. > > Should th

[PATCH v10 1/2] efi: Introduce efi_early_memdesc_ptr to get pointer to memmap descriptor

2017-08-16 Thread Baoquan He
independent usage and struct efi_info for x86 arch only. Introduce efi_early_memdesc_ptr to get pointer to a map descriptor, and replace several places of open code with it. Signed-off-by: Baoquan He <b...@redhat.com> --- v9->v10: Use the 'EFI subsystem' instead of EFI since EFI usua

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

2017-08-14 Thread Baoquan He
memory map. Signed-off-by: Baoquan He <b...@redhat.com> --- arch/x86/boot/compressed/kaslr.c | 68 ++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index 99c719

[PATCH v9 1/2] efi: Introduce efi_early_memdesc_ptr to get pointer to memmap descriptor

2017-08-14 Thread Baoquan He
usage and struct efi_info for x86 arch only. Introduce efi_early_memdesc_ptr to get pointer to a map descriptor, and replace several places of open code with it. Suggested-by: Ingo Molnar <mi...@kernel.org> Signed-off-by: Baoquan He <b...@redhat.com> --- arch/x86/boot/compre

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

2017-08-14 Thread Baoquan He
ng to Kees's comment. This is based on tip/x86/boot, patch 1,2,3/4 in v5 post has been put into tip/x86/boot now. Baoquan He (2): efi: Introduce efi_early_memdesc_ptr to get pointer to memmap descriptor x86/boot/KASLR: Restrict kernel to be randomized in mirror regions arch/x86/boo

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

2017-08-17 Thread Baoquan He
On 08/14/17 at 10:54pm, Baoquan He wrote: > Currently KASLR will parse all e820 entries of RAM type and add all > candidate position into slots array. Then we will choose one slot > randomly as the new position which kernel will be decompressed into > and run at. > > On syste

[PATCH v5 4/4] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

2017-07-13 Thread Baoquan He
found, still process e820 memory map. Signed-off-by: Baoquan He <b...@redhat.com> --- arch/x86/boot/compressed/kaslr.c | 68 ++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/k

[PATCH v5 3/4] x86/boot/KASLR: Rename process_e820_entry() into process_mem_region()

2017-07-13 Thread Baoquan He
Now process_e820_entry() is not limited to e820 entry processing, rename it to process_mem_region(). And adjust the code comment accordingly. Signed-off-by: Baoquan He <b...@redhat.com> Acked-by: Kees Cook <keesc...@chromium.org> --- arch/x86/boot/compressed/kaslr.c | 6 +++--- 1 fil

[PATCH v5 2/4] x86/boot/KASLR: Switch to pass struct mem_vector to process_e820_entry()

2017-07-13 Thread Baoquan He
This makes process_e820_entry() be able to process any kind of memory region. Signed-off-by: Baoquan He <b...@redhat.com> Acked-by: Kees Cook <keesc...@chromium.org> --- arch/x86/boot/compressed/kaslr.c | 25 ++--- 1 file changed, 14 insertions(+), 11 deletions(-)

[PATCH v5 1/4] x86/boot/KASLR: Wrap e820 entries walking code into new function process_e820_entries()

2017-07-13 Thread Baoquan He
The original function process_e820_entry() only takes care of each e820 entry passed. And move the E820_TYPE_RAM checking logic into process_e820_entries(). And remove the redundent local variable 'addr' definition in find_random_phys_addr(). Signed-off-by: Baoquan He <b...@redhat.com>

[PATCH v5 0/4] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

2017-07-13 Thread Baoquan He
rding to kbuild report and Chao Fan's comment. Baoquan He (4): x86/boot/KASLR: Wrap e820 entries walking code into new function process_e820_entries() x86/boot/KASLR: Switch to pass struct mem_vector to process_e820_entry() x86/boot/KASLR: Rename process_e820_entry() into process_mem_reg

[PATCH v4 0/4] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

2017-07-09 Thread Baoquan He
port and Chao Fan's comment. Baoquan He (4): x86/boot/KASLR: Wrap e820 entries walking code into new function process_e820_entries() x86/boot/KASLR: Switch to pass struct mem_vector to process_e820_entry() x86/boot/KASLR: Rename process_e820_entry() into process_mem_region() x86/b

[PATCH v4 2/4] x86/boot/KASLR: Switch to pass struct mem_vector to process_e820_entry()

2017-07-09 Thread Baoquan He
This makes process_e820_entry() be able to process any kind of memory region. Signed-off-by: Baoquan He <b...@redhat.com> --- arch/x86/boot/compressed/kaslr.c | 25 ++--- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr.c

[PATCH v4 1/4] x86/boot/KASLR: Wrap e820 entries walking code into new function process_e820_entries()

2017-07-09 Thread Baoquan He
The original function process_e820_entry() only takes care of each e820 entry passed. And move the E820_TYPE_RAM checking logic into process_e820_entries(). And remove the redundent local variable 'addr' definition in find_random_phys_addr(). Signed-off-by: Baoquan He <b...@redhat.

[PATCH v4 4/4] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

2017-07-09 Thread Baoquan He
found, still process e820 memory map. Signed-off-by: Baoquan He <b...@redhat.com> --- arch/x86/boot/compressed/kaslr.c | 60 ++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/k

[PATCH v4 3/4] x86/boot/KASLR: Rename process_e820_entry() into process_mem_region()

2017-07-09 Thread Baoquan He
Now process_e820_entry() is not limited to e820 entry processing, rename it to process_mem_region(). And adjust the code comment accordingly. Signed-off-by: Baoquan He <b...@redhat.com> --- arch/x86/boot/compressed/kaslr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff

Re: [PATCH] x86/boot/KASLR: exclude EFI_BOOT_SERVICES_{CODE|DATA} from KASLR's choice

2017-07-09 Thread Baoquan He
On 07/09/17 at 06:44pm, Baoquan He wrote: > On 07/07/17 at 11:56am, Matt Fleming wrote: > > On Fri, 07 Jul, at 11:07:59AM, Baoquan He wrote: > > > On 07/06/17 at 03:57pm, Matt Fleming wrote: > > > > On Thu, 06 Jul, at 08:31:07AM, Naoya Horiguchi wrote: > > &g

Re: [PATCH v4 4/4] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

2017-07-09 Thread Baoquan He
On 07/09/17 at 07:11am, Kees Cook wrote: > On Sun, Jul 9, 2017 at 5:37 AM, Baoquan He <b...@redhat.com> wrote: > > Kernel text may be located in non-mirror regions (movable zone) when both > > address range mirroring feature and KASLR are enabled. > > > > Th

Re: [PATCH] x86/boot/KASLR: exclude EFI_BOOT_SERVICES_{CODE|DATA} from KASLR's choice

2017-07-09 Thread Baoquan He
On 07/07/17 at 11:56am, Matt Fleming wrote: > On Fri, 07 Jul, at 11:07:59AM, Baoquan He wrote: > > On 07/06/17 at 03:57pm, Matt Fleming wrote: > > > On Thu, 06 Jul, at 08:31:07AM, Naoya Horiguchi wrote: > > > > + for (i = 0; i < nr_desc; i++) { > > >

Re: [PATCH v4 4/4] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

2017-07-10 Thread Baoquan He
Hi Kees, Do you think the patch as below is OK to you? Thanks! >From 1cec45dc65090f6d17bf3499b8904efc1822082e Mon Sep 17 00:00:00 2001 From: Baoquan He <b...@redhat.com> Date: Fri, 7 Jul 2017 17:25:41 +0800 Subject: [PATCH v5 4/4] x86/boot/KASLR: Restrict kernel to be randomized i

Re: [PATCH v4 4/4] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

2017-07-09 Thread Baoquan He
On 07/09/17 at 07:11am, Kees Cook wrote: > On Sun, Jul 9, 2017 at 5:37 AM, Baoquan He <b...@redhat.com> wrote: > > Signed-off-by: Baoquan He <b...@redhat.com> > > +/* Marks if efi mirror regions have been found and handled. */ > > +static bool efi_mirror_foun

Re: [PATCH v5 4/4] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

2017-07-17 Thread Baoquan He
On 07/17/17 at 04:13pm, Kees Cook wrote: > > +#ifdef CONFIG_EFI > > +/* > > + * Returns true if mirror region found (and must have been processed > > + * for slots adding) > > + */ > > +static bool process_efi_entries(unsigned long minimum, > > + unsigned long

[PATCH v6 4/4] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

2017-07-18 Thread Baoquan He
found, still process e820 memory map. Signed-off-by: Baoquan He <b...@redhat.com> Reviewed-by: Kees Cook <keesc...@chromium.org> --- v5->v6: Code style clean up according to Kees's comment. arch/x86/boot/compressed/kaslr.c | 68 ++-- 1 f

[PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

2017-07-20 Thread Baoquan He
found, still process e820 memory map. Signed-off-by: Baoquan He <b...@redhat.com> Reviewed-by: Kees Cook <keesc...@chromium.org> --- v5->v6: Code style issue fix according to Kees's comment. This is based on tip/x86/boot, patch 1,2,3/4 in v5 post has been put into tip/x86/boot

Re: [PATCH] iommu/amd: Suppress IO_PAGE_FAULTs in kdump kernel

2017-07-20 Thread Baoquan He
Hi Joerg, On 06/26/17 at 12:07pm, Joerg Roedel wrote: > Hi Baoquan, > > On Fri, Jun 23, 2017 at 07:43:10PM +0800, Baoquan He wrote: > > Do you think whether it's necessary to continue my kdump fix of amd iommu > > patchset? Seems my last post was in Jan this year. I know

[PATCH v8 07/13] iommu/amd: Do sanity check for irq remap of old dev table entry

2017-07-21 Thread Baoquan He
Firstly split the dev table entry copy into address translation part and irq remapping part. Because these two parts could be enabled independently. Secondly check if IntCtl and IntTabLen are 10b and 1000b if they are set. Signed-off-by: Baoquan He <b...@redhat.com> --- drivers

[PATCH v8 03/13] Revert "iommu/amd: Suppress IO_PAGE_FAULTs in kdump kernel"

2017-07-21 Thread Baoquan He
This reverts commit 54bd63570484167cb13edf81e31fff107b879981. We still need the IO_PAGE_FAULT message to warn error after the issue of on-flight dma in kdump kernel is fixed. Signed-off-by: Baoquan He <b...@redhat.com> --- drivers/iommu/amd_iommu.c | 3 +-- drivers/iommu/amd_iommu_

[PATCH v8 04/13] iommu/amd: Define bit fields for DTE particularly

2017-07-21 Thread Baoquan He
In AMD-Vi spec several bits of IO PTE fields and DTE fields are similar so that both of them can share the same MACRO definition. However defining them respectively can make code more read-able. Do it now. Signed-off-by: Baoquan He <b...@redhat.com> --- drivers/iommu/amd_iommu.c

[PATCH v8 00/13] Fix the on-flight DMA issue on system with amd iommu

2017-07-21 Thread Baoquan He
nymore. Below is link of v5 post. https://lists.linuxfoundation.org/pipermail/iommu/2016-September/018527.html Baoquan He (12): iommu/amd: Detect pre enabled translation iommu/amd: add several helper functions Revert "iommu/amd: Suppress IO_PAGE_FAULTs in kdump kernel" i

[PATCH v8 09/13] iommu/amd: Use is_attach_deferred call-back

2017-07-21 Thread Baoquan He
Implement call-back is_attach_deferred and use it to defer the domain attach from iommu driver init to device driver init when iommu is pre-enabled in kdump kernel. Signed-off-by: Baoquan He <b...@redhat.com> --- drivers/iommu/amd_iommu.c | 23 ++- 1 file chang

[PATCH v8 10/13] iommu/amd: Allocate memory below 4G for dev table if translation pre-enabled

2017-07-21 Thread Baoquan He
this is to allocate the device-table below 4GB if translation is pre-enabled in kdump kernel. If allocation failed, still use the old one. Signed-off-by: Baoquan He <b...@redhat.com> --- drivers/iommu/amd_iommu_init.c | 12 1 file changed, 12 insertions(+) diff --git a/drivers

[PATCH v8 11/13] iommu/amd: Don't copy GCR3 table root pointer

2017-07-21 Thread Baoquan He
are recoverable for the device and we should not allow the device to change old-kernels data when we don't have to. Signed-off-by: Baoquan He <b...@redhat.com> --- drivers/iommu/amd_iommu.c | 28 +++- drivers/iommu/amd_iommu_init.c | 11 +++ drivers

[PATCH v8 13/13] iommu/amd: Disable iommu only if amd_iommu=off is specified

2017-07-21 Thread Baoquan He
From: root <r...@amd-dinar-02.lab.bos.redhat.com> It's ok to disable iommu in normal kernel. While there's no need to disable it in kdump kernel after the on-flight dma issue has heen fixed. Signed-off-by: Baoquan He <b...@redhat.com> --- drivers/iommu/amd_iommu_init.c | 3 ++- 1

[PATCH v8 08/13] iommu: Add is_attach_deferred call-back to iommu-ops

2017-07-21 Thread Baoquan He
This new call-back will be used to check if the domain attach need be deferred for now. If yes, the domain attach/detach will return directly. Signed-off-by: Baoquan He <b...@redhat.com> --- drivers/iommu/iommu.c | 8 include/linux/iommu.h | 1 + 2 files changed, 9 insertions(+)

[PATCH v8 12/13] iommu/amd: Clear out the GV flag when handle deferred domain attach

2017-07-21 Thread Baoquan He
When handle deferred domain attach, we need check if the domain is v2. If not, should try to clear out the GV flag which could be copied from the old device table entry. Signed-off-by: Baoquan He <b...@redhat.com> --- drivers/iommu/amd_iommu.c | 18 +- 1 file chang

[PATCH v8 06/13] iommu/amd: copy old trans table from old kernel

2017-07-21 Thread Baoquan He
, and detect and enable guest vapic. - Flush all caches Signed-off-by: Baoquan He <b...@redhat.com> --- drivers/iommu/amd_iommu_init.c | 51 -- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/amd_iommu_init.c b/drivers

[PATCH v8 05/13] iommu/amd: Add function copy_dev_tables()

2017-07-21 Thread Baoquan He
, it can be reused in copy_dev_tables(). Signed-off-by: Baoquan He <b...@redhat.com> --- drivers/iommu/amd_iommu.c | 2 +- drivers/iommu/amd_iommu_init.c | 55 + drivers/iommu/amd_iommu_types.h | 1 + 3 files changed, 57 insertions(+), 1 de

[PATCH v8 01/13] iommu/amd: Detect pre enabled translation

2017-07-21 Thread Baoquan He
Add functions to check whether translation is already enabled in IOMMU. Signed-off-by: Baoquan He <b...@redhat.com> --- drivers/iommu/amd_iommu_init.c | 24 drivers/iommu/amd_iommu_proto.h | 1 + drivers/iommu/amd_iommu_types.h | 4 3 files changed, 29 inse

[PATCH v8 02/13] iommu/amd: add several helper functions

2017-07-21 Thread Baoquan He
Move single iommu enabling codes into a wrapper function early_enable_iommu(). This can make later kdump change easier. And also add iommu_disable_command_buffer and iommu_disable_event_buffer for later usage. Signed-off-by: Baoquan He <b...@redhat.com> --- drivers/iommu/amd_iommu_init.

Re: [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

2017-07-21 Thread Baoquan He
On 07/21/17 at 12:33pm, Ingo Molnar wrote: > > * Baoquan He <b...@redhat.com> wrote: > > > Kernel text may be located in non-mirror regions (movable zone) when both > > address range mirroring feature and KASLR are enabled. > > > > The address range mirror

Re: [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

2017-07-21 Thread Baoquan He
On 07/21/17 at 12:37pm, Ingo Molnar wrote: > > * Baoquan He <b...@redhat.com> wrote: > > > +/* > > + * Returns true if mirror region found (and must have been processed > > + * for slots adding) > > + */ > > +static b

Re: [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

2017-07-21 Thread Baoquan He
On 07/21/17 at 07:37pm, Ingo Molnar wrote: > > * Baoquan He <b...@redhat.com> wrote: > > > > > +static inline bool process_efi_entries(unsigned long minimum, > > > > + unsigned long image_size) > > > > &

Re: [PATCH v8 11/13] iommu/amd: Don't copy GCR3 table root pointer

2017-07-23 Thread Baoquan He
the system] > > url: > https://github.com/0day-ci/linux/commits/Baoquan-He/Fix-the-on-flight-DMA-issue-on-system-with-amd-iommu/20170724-060048 > base: https://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git next > config: x86_64-randconfig-x005-201730 (attached as .confi

Re: [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

2017-07-24 Thread Baoquan He
On 07/24/17 at 02:34pm, Matt Fleming wrote: > On Fri, 21 Jul, at 09:19:56PM, Baoquan He wrote: > > > > There are places where the efi map is getting and used like this. E.g > > in efi_high_alloc() of drivers/firmware/efi/libstub/efi-stub-helper.c. > > EF

Re: [PATCH v8 06/13] iommu/amd: copy old trans table from old kernel

2017-07-28 Thread Baoquan He
On 07/27/17 at 05:38pm, Joerg Roedel wrote: > On Fri, Jul 21, 2017 at 04:59:04PM +0800, Baoquan He wrote: > > @@ -2128,9 +2131,43 @@ static void early_enable_iommu(struct amd_iommu > > *iommu) > > static void early_enable_iommus(void) > > { > > stru

Re: [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

2017-07-28 Thread Baoquan He
Hi Ingo, On 07/24/17 at 02:34pm, Matt Fleming wrote: > On Fri, 21 Jul, at 09:19:56PM, Baoquan He wrote: > > > > There are places where the efi map is getting and used like this. E.g > > in efi_high_alloc() of drivers/firmware/efi/libstub/efi-stub-helper.c. > > EF

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

2017-07-28 Thread Baoquan He
Hi Ingo, On 07/28/17 at 08:46am, Ingo Molnar wrote: > > > + pmap = e->efi_memmap; > > +#else > > + pmap = (e->efi_memmap | ((__u64)e->efi_memmap_hi << 32)); > > +#endif > > + > > + nr_desc = e->efi_memmap_size / e->efi_memdesc_size; > > + for (i = 0; i < nr_desc; i++) { > > +

Re: [PATCH v8 10/13] iommu/amd: Allocate memory below 4G for dev table if translation pre-enabled

2017-07-28 Thread Baoquan He
Hi Joerg, On 07/27/17 at 05:55pm, Joerg Roedel wrote: > On Fri, Jul 21, 2017 at 04:59:08PM +0800, Baoquan He wrote: > > AMD pointed out it's unsafe to update the device-table while iommu > > is enabled. It turns out that device-table pointer update is split > > up

Re: [PATCH v8 13/13] iommu/amd: Disable iommu only if amd_iommu=off is specified

2017-07-28 Thread Baoquan He
On 07/27/17 at 05:58pm, Joerg Roedel wrote: > On Fri, Jul 21, 2017 at 04:59:11PM +0800, Baoquan He wrote: > > From: root <r...@amd-dinar-02.lab.bos.redhat.com> > > You probaly need to reset the author on this one. Oops, sorry. I made this patch on a testing machine. Wil

Re: [PATCH v8 11/13] iommu/amd: Don't copy GCR3 table root pointer

2017-07-28 Thread Baoquan He
On 07/27/17 at 05:57pm, Joerg Roedel wrote: > On Fri, Jul 21, 2017 at 04:59:09PM +0800, Baoquan He wrote: > > When iommu is pre_enabled in kdump kernel, if a device is set up with > > guest translations (DTE.GV=1), then don't copy GCR3 table root pointer > > but move the de

[PATCH v7] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

2017-07-25 Thread Baoquan He
memory map. Signed-off-by: Baoquan He <b...@redhat.com> --- v6->v7: Ingo pointed out several incorrect line break issues and unclear description of patch log. Correct them and rewrite patch log. And also rewrite the EFI warning message that if EFI memmap is above 4G in 32bit sys

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

2017-07-04 Thread Baoquan He
Fan's comment. Test: Chao has tested the v1 (RFC patchset) 100 times. And he said in the 100 times, 50 times are with this patchset applied, 50 times are without it. The test result showed the v1 patchset works very well. Baoquan He (2): x86/boot/KASLR: Adapt process_e820_entry for any type of

[PATCH v2 1/2] x86/boot/KASLR: Adapt process_e820_entry for any type of memory entry

2017-07-04 Thread Baoquan He
code into process_e820_entry. Signed-off-by: Baoquan He <b...@redhat.com> --- arch/x86/boot/compressed/kaslr.c | 60 ++-- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c

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

2017-07-04 Thread Baoquan He
found, still process e820 memory map. Signed-off-by: Baoquan He <b...@redhat.com> --- arch/x86/boot/compressed/kaslr.c | 52 +++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c

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

2017-07-04 Thread Baoquan He
On 07/04/17 at 04:00pm, Thomas Gleixner wrote: > On Tue, 4 Jul 2017, Baoquan He wrote: > > +/* Marks if efi mirror regions have been found and handled. */ > > +static bool efi_mirror_found; > > + > > +static void process_efi_entry(unsigned long minimum, un

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

2017-07-04 Thread Baoquan He
On 07/04/17 at 05:46pm, Thomas Gleixner wrote: > On Tue, 4 Jul 2017, Matt Fleming wrote: > > On Tue, 04 Jul, at 04:46:58PM, Thomas Gleixner wrote: > > > On Tue, 4 Jul 2017, Baoquan He wrote: > > > > > > > In fact I just referred to code in setup_arch()

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

2017-07-05 Thread Baoquan He
times, 50 times are with this patchset applied, 50 times are without it. The test result showed the v1 patchset works very well. Baoquan He (2): x86/boot/KASLR: Adapt process_e820_entry for any type of memory entry x86/boot/KASLR: Restrict kernel to be randomized in mirror regions arch/x86/boot/compress

[PATCH v3 1/2] x86/boot/KASLR: Adapt process_e820_entry for any type of memory entry

2017-07-05 Thread Baoquan He
code into process_e820_entry. Signed-off-by: Baoquan He <b...@redhat.com> --- arch/x86/boot/compressed/kaslr.c | 60 ++-- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c

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

2017-07-05 Thread Baoquan He
found, still process e820 memory map. Signed-off-by: Baoquan He <b...@redhat.com> --- arch/x86/boot/compressed/kaslr.c | 52 +++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c

Re: [PATCH] x86/boot/KASLR: exclude EFI_BOOT_SERVICES_{CODE|DATA} from KASLR's choice

2017-07-06 Thread Baoquan He
Hi Naoya Horiguchi, Thanks for making this! On 07/06/17 at 08:31am, Naoya Horiguchi wrote: > Hi Baoquan, everyone, > > I'm also interested in KASLR/EFI related issue (but not the same issue > with yours, so I separated the thread.) > > This patch is based on Baoquan's recent patches[1], adding

Re: [PATCH] x86/boot/KASLR: Skip relocation handling in no kaslr case

2017-07-06 Thread Baoquan He
On 07/05/17 at 12:06pm, Kees Cook wrote: > On Tue, Jun 27, 2017 at 4:24 PM, Baoquan He <b...@redhat.com> wrote: > > Below code was added to fix the kexec/kdump kernel with kaslr disabled, > > at that time kernel kaslr physical address and virtual address > > rand

Re: [PATCH] x86/boot/KASLR: Skip relocation handling in no kaslr case

2017-07-06 Thread Baoquan He
On 07/06/17 at 09:28pm, Baoquan He wrote: > > > Do you mean the handling in boot/compressed/head_64.S? Whatever it does, > > > it's only for physical address. The virtual address mapping is not > > > touched. Here virt_addr respresents the offset betwe

Re: [PATCH v2 1/2] x86/boot/KASLR: Adapt process_e820_entry for any type of memory entry

2017-07-05 Thread Baoquan He
On 07/05/17 at 03:06pm, Kees Cook wrote: > On Tue, Jul 4, 2017 at 1:04 AM, Baoquan He <b...@redhat.com> wrote: > > Now function process_e820_entry is only used to process e820 memory > > entries. Adapt it for any type of memory entry, not just for e820. > > Later we

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

2017-07-05 Thread Baoquan He
On 07/05/17 at 03:08pm, Kees Cook wrote: > On Wed, Jul 5, 2017 at 1:06 AM, Baoquan He <b...@redhat.com> wrote: > > Kernel text may be located in non-mirror regions (movable zone) when both > > address range mirroring feature and KASLR are enabled. > > > > Th

Re: [PATCH] x86/boot/KASLR: Skip relocation handling in no kaslr case

2017-06-27 Thread Baoquan He
On 06/28/17 at 07:24am, Baoquan He wrote: > Hi Kees, > > On 06/27/17 at 03:42pm, Kees Cook wrote: > > On Sat, Jun 24, 2017 at 7:25 AM, Baoquan He <b...@redhat.com> wrote: > > > Kdump kernel will reset to firmware after crash is trigered when > > > crashker

Re: [PATCH] x86/boot/KASLR: Skip relocation handling in no kaslr case

2017-06-27 Thread Baoquan He
Hi Kees, On 06/27/17 at 03:42pm, Kees Cook wrote: > On Sat, Jun 24, 2017 at 7:25 AM, Baoquan He <b...@redhat.com> wrote: > > Kdump kernel will reset to firmware after crash is trigered when > > crashkernel=xxM,high is added to kernel command line. Kexec has the > >

Re: [PATCH] x86/boot/KASLR: exclude EFI_BOOT_SERVICES_{CODE|DATA} from KASLR's choice

2017-07-06 Thread Baoquan He
On 07/06/17 at 03:57pm, Matt Fleming wrote: > On Thu, 06 Jul, at 08:31:07AM, Naoya Horiguchi wrote: > > + for (i = 0; i < nr_desc; i++) { > > + md = (efi_memory_desc_t *)(pmap + (i * e->efi_memdesc_size)); > > + > > + /* > > +* EFI_BOOT_SERVICES_{CODE|DATA} are

[PATCH v3 3/3] Documentation/kernel-parameters.txt: Update 'memmap=' option description

2017-04-26 Thread Baoquan He
passed to the kernel. Clarify all this. Signed-off-by: Baoquan He <b...@redhat.com> Cc: Jonathan Corbet <cor...@lwn.net> Cc: "Rafael J. Wysocki" <rafael.j.wyso...@intel.com> Cc: Andrew Morton <a...@linux-foundation.org> Cc: Greg Kroah-Hartman <gre...@lin

[PATCH v3 1/3] KASLR: Parse all memmap entries in cmdline

2017-04-26 Thread Baoquan He
only find the last entry if multiple memmap entries are provided. This is not correct. In this patch, the whole cmdline will be scanned to search each memmap, all of them will be parsed and handled. Signed-off-by: Baoquan He <b...@redhat.com> Cc: "H. Peter Anvin" <h...@zyto

[PATCH v3 0/3] Handle memmap and mem kernel options in boot stage kaslr

2017-04-26 Thread Baoquan He
/decompress/mm.h. Baoquan He (3): KASLR: Parse all memmap entries in cmdline KASLR: Handle memory limit specified by memmap and mem option Documentation/kernel-parameters.txt: Update 'memmap=' option description Documentation/admin-guide/kernel-parameters.txt | 9 ++ arch/x86/boot/comp

[PATCH v3 2/3] KASLR: Handle memory limit specified by memmap and mem option

2017-04-26 Thread Baoquan He
. This patch implements that. Signed-off-by: Baoquan He <b...@redhat.com> Acked-by: Kees Cook <keesc...@chromium.org> Cc: "H. Peter Anvin" <h...@zytor.com> Cc: Thomas Gleixner <t...@linutronix.de> Cc: Ingo Molnar <mi...@redhat.com> Cc: x...@kernel.org Cc: Kees

<    3   4   5   6   7   8   9   10   11   12   >