Re: [PATCH v3] efifb: avoid reconfiguration of BAR that covers the framebuffer

2017-04-28 Thread Yinghai Lu
On Thu, Apr 27, 2017 at 6:55 AM, Ard Biesheuvel wrote: > On 23 April 2017 at 02:45, Yinghai Lu wrote: >> >> looks like those two lines are reversed. you should use: >> pcibios_resource_survey_bus(bus); >> pci_assign_unassi

Re: [PATCH v3] efifb: avoid reconfiguration of BAR that covers the framebuffer

2017-04-22 Thread Yinghai Lu
On Mon, Apr 10, 2017 at 06:29:27PM +0100, Ard Biesheuvel wrote: > /* > @@ -208,8 +208,8 @@ struct pci_bus *pci_acpi_scan_root(struct > acpi_pci_root *root) > if (!bus) > return NULL; > > - pci_bus_size_bridges(bus); > - pci_bus_assign_resources(bus); > +

[PATCH 31/42] x86, efi: Copy SETUP_EFI data and access directly

2015-07-07 Thread Yinghai Lu
The copy will be in __initdata, and it is small. We can use pointer to access the setup_data instead of using early_memmap everywhere. Cc: Matt Fleming Cc: linux-efi@vger.kernel.org Signed-off-by: Yinghai Lu --- arch/x86/include/asm/efi.h | 2 +- arch/x86/platform/efi/efi.c| 13

Re: [PATCH v5 03/19] x86, boot: Simplify run_size calculation

2015-03-23 Thread Yinghai Lu
On Sun, Mar 22, 2015 at 8:25 PM, Baoquan He wrote: > > This may not be correct. In commit e602336 > runsize = offset(.bss) + size(.bss) + size(.brk), why this formula comes > out can be checked from discussion between Kees and Junjie: > https://lkml.org/lkml/2014/10/30/612 > > And in my one kernel

[PATCH v5 03/19] x86, boot: Simplify run_size calculation

2015-03-18 Thread Yinghai Lu
size. Fixes: e6023367d779 ("x86, kaslr: Prevent .bss from overlaping initrd") Cc: Junjie Mao Cc: Kees Cook Cc: Josh Triplett Cc: Matt Fleming Cc: Andrew Morton Signed-off-by: Yinghai Lu --- arch/x86/boot/Makefile| 11 +-- arch/x86/boot/compressed/Makefile | 12 +++

[PATCH v5 12/19] x86, kaslr: Fix a bug that relocation can not be handled when kernel is loaded above 2G

2015-03-18 Thread Yinghai Lu
From: Baoquan He When process 32 bit relocation tables a local variable extended is defined to calculate the physical address of relocs entry. However it's type is int which is enough for i386, for x86_64 not enough. That's why relocation can only be handled when kernel is loaded below 2G, otherw

[PATCH v5 08/19] x86, kaslr: Get correct max_addr for relocs pointer

2015-03-18 Thread Yinghai Lu
according to ELF headers. The valid range should be VO [_text, __bss_start) loaded physical addresses. In the patch, add export for __bss_start to voffset.h and use it to get max_addr. Signed-off-by: Yinghai Lu --- arch/x86/boot/compressed/Makefile | 2 +- arch/x86/boot/compressed/misc.c | 2

[PATCH v5 05/19] x86, kaslr: Use output_run_size

2015-03-18 Thread Yinghai Lu
Now we are using output_size as parameter, actually we are passing max(output_len, run_size). Change it to output_run_size to make it less confusing. Cc: Kees Cook Signed-off-by: Yinghai Lu --- arch/x86/boot/compressed/aslr.c | 10 +- arch/x86/boot/compressed/misc.c | 6 -- arch

[PATCH v5 10/19] x86, 64bit: Set ident_mapping for kaslr

2015-03-18 Thread Yinghai Lu
. So 19 pages could make both paths happy. Cc: Kees Cook Cc: Jiri Kosina Cc: Borislav Petkov Cc: Matt Fleming Signed-off-by: Yinghai Lu --- arch/x86/boot/compressed/Makefile | 3 ++ arch/x86/boot/compressed/aslr.c | 14 ++ arch/x86/boot/compressed/head_64.S | 4 +- arch/x86/boot

[PATCH v5 11/19] x86, boot: Add checking for memcpy

2015-03-18 Thread Yinghai Lu
act. Signed-off-by: Yinghai Lu --- arch/x86/boot/compressed/misc.c | 14 +++--- arch/x86/boot/compressed/misc.h | 2 ++ arch/x86/boot/compressed/string.c | 28 ++-- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/arch/x86/boot/compressed/misc.

[PATCH v5 06/19] x86, kaslr: Consolidate mem_avoid array filling

2015-03-18 Thread Yinghai Lu
o put boot_params into the mem_avoid too. As with 64bit bootloader could put it anywhere. After those changes, we have all range needed to be avoided in mem_avoid array. Cc: Kees Cook Signed-off-by: Yinghai Lu --- arch/x86/boot/compressed/aslr.c | 29 + 1 file change

[PATCH v5 09/19] x86, boot: Split kernel_ident_mapping_init to another file

2015-03-18 Thread Yinghai Lu
We need to include that in boot::decompress_kernel stage to set new ident mapping. Also add checking for __pa/__va macro definition, as we need to override them in boot::decompress_kernel stage. Reviewed-by: Kees Cook Signed-off-by: Yinghai Lu --- arch/x86/include/asm/page.h | 5 +++ arch

[PATCH v5 14/19] x86, kaslr: Add two functions which will be used later

2015-03-18 Thread Yinghai Lu
From: Baoquan He Add two functions mem_min_overlap() and store_slot_info() which will be used later. Given a memory region mem_min_overlap will iterate all avoid region to find the first one which overlap with it. store_slot_info() calculates the slot info of passed in region and store it into

[PATCH v5 17/19] x86, kaslr: Add support of kernel physical address randomization above 4G

2015-03-18 Thread Yinghai Lu
From: Baoquan He In kaslr implementation mechanism, mainly process_e820_entry and slots_fetch_random do the job. process_e820_entry is responsible for storing the slot information. slots_fetch_random takes care of fetching slot information. In this patch, for adding support of kernel physical add

[PATCH v5 07/19] x86, boot: Move z_extract_offset calculation to header.S

2015-03-18 Thread Yinghai Lu
-0x13fa01cc7], output: [0x13e00-0x13f9ef81f], heap: [0x13fa0b680-0x13fa1367f] after patch: kernel: [13e00,13fa15fff] input: [0x13f3253b4-0x13f9f9cc7], output: [0x13e00-0x13f9ef81f], heap: [0x13fa03680-0x13fa0b67f] Signed-off-by: Yinghai Lu --- arch/x86/boot/Makefile | 2

[PATCH v5 02/19] x86, kaslr: Propagate base load address calculation v2

2015-03-18 Thread Yinghai Lu
d to make use of this flag. [ Always dump correct kaslr status when panicking from Boris] -v2: fold in fix for using physical address as value -- Yinghai split struct kaslr_setup_data definition to another file -- Yinghai use real_mode directly instead of passing it around -- Yinghai

[PATCH v5 16/19] x86, kaslr: Randomize physical and virtual address of kernel separately

2015-03-18 Thread Yinghai Lu
From: Baoquan He On x86_64, in old kaslr implementaion only physical address of kernel loading is randomized. Then calculate the delta of physical address where vmlinux was linked to load and where it is finally loaded. If delta is not equal to 0, namely there's a new physical address where kerne

[PATCH v5 01/19] x86, boot: Make data from decompress_kernel stage live longer

2015-03-18 Thread Yinghai Lu
g Cc: "H. Peter Anvin" Cc: Matt Fleming Cc: Kees Cook Signed-off-by: Yinghai Lu --- arch/x86/boot/Makefile | 2 +- arch/x86/boot/compressed/head_32.S | 11 +-- arch/x86/boot/compressed/head_64.S | 8 ++-- arch/x86/boot/compressed/mkpiggy.c

[PATCH v5 13/19] x86, kaslr: Introduce struct slot_area to manage randomization slot info

2015-03-18 Thread Yinghai Lu
From: Baoquan He Kernel is expected to be randomly reloaded anywhere in the whole physical memory area, it could be near 64T at most. In this case there could be about 4*1024*1024 randomization slots. Hence the old slot array will cost too much memory and also not efficient to store the slot info

[PATCH v5 15/19] x86, kaslr: Introduce fetch_random_virt_offset to randomize the kernel text mapping address

2015-03-18 Thread Yinghai Lu
From: Baoquan He Kaslr extended kernel text mapping region size from 512M to 1G, namely CONFIG_RANDOMIZE_BASE_MAX_OFFSET. This means kernel text can be mapped to below region: [__START_KERNEL_map + LOAD_PHYSICAL_ADDR, __START_KERNEL_map + 1G] Introduce a function find_random_virt_offset() to ge

[PATCH v5 04/19] x86, kaslr: Kill not used run_size related code.

2015-03-18 Thread Yinghai Lu
e Mao Signed-off-by: Yinghai Lu --- arch/x86/boot/compressed/Makefile | 4 +--- arch/x86/boot/compressed/head_32.S | 3 +-- arch/x86/boot/compressed/head_64.S | 3 --- arch/x86/boot/compressed/misc.c| 6 ++ arch/x86/boot/compressed/mkpiggy.c | 9 ++-- arch/x86/tools/calc

[PATCH v5 19/19] x86, kaslr: Allow random address could be below loaded address

2015-03-18 Thread Yinghai Lu
: [0x70c0-0x70e4e9bf] [0.00] .init: [0x70e5-0x7120bfff] [0.00].bss: [0x71219000-0x7234efff] [0.00].brk: [0x7234f000-0x72374fff] Signed-off-by: Yinghai Lu --- arch/x86/boot/compressed/aslr.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions

[PATCH v5 18/19] x86, kaslr: Remove useless codes

2015-03-18 Thread Yinghai Lu
From: Baoquan He Several auxiliary functions and slots[] are not needed any more since struct slot_area is used to store the slot info of kaslr now. Hence remove them in this patch. Signed-off-by: Baoquan He --- arch/x86/boot/compressed/aslr.c | 24 1 file changed, 24

[PATCH v5 00/19] x86, boot: kaslr cleanup and 64bit kaslr support

2015-03-18 Thread Yinghai Lu
ysical and virtual address of kernel separately x86, kaslr: Add support of kernel physical address randomization above 4G x86, kaslr: Remove useless codes Jiri Kosina (1): x86, kaslr: Propagate base load address calculation v2 Yinghai Lu (11): x86, boot: Make data from decompress_kernel

Re: [PATCH] Revert "x86/mm/ASLR: Propagate base load address calculation"

2015-03-16 Thread Yinghai Lu
On Mon, Mar 16, 2015 at 6:56 AM, Jiri Kosina wrote: > On Mon, 16 Mar 2015, Borislav Petkov wrote: >> From: Borislav Petkov >> Date: Mon, 16 Mar 2015 10:57:56 +0100 >> Subject: [PATCH] Revert "x86/mm/ASLR: Propagate base load address >> calculation" >> >> This reverts commit f47233c2d34f243ecdaac

Re: [PATCH v3 1/7] x86, kaslr: Use init_size instead of run_size

2015-03-13 Thread Yinghai Lu
On Fri, Mar 13, 2015 at 5:27 AM, Ingo Molnar wrote: > > * Yinghai Lu wrote: > >> commit e6023367d779 ("x86, kaslr: Prevent .bss from overlaping initrd") >> introduced one run_size for kaslr. >> We should use real runtime size (include copy/decompress) aka i

[PATCH] x86, boot: Move z_extract_offset calculation to header.S

2015-03-12 Thread Yinghai Lu
bb3b4-0x13fe4c346], output: [0x13e00-0x13fe69fff], heap: [0x13fe57080-0x13fe5f07f] Signed-off-by: Yinghai Lu --- Please apply after patcheset: [PATCH v3 0/7] x86, boot: clean up kaslr --- arch/x86/boot/Makefile |2 +- arch/x86/boot/compressed/misc.c|5 + arch/x86

Re: [PATCH v3 3/7] x86, boot: Don't overlap VO with ZO data

2015-03-12 Thread Yinghai Lu
On Tue, Mar 10, 2015 at 8:48 AM, Borislav Petkov wrote: > On Tue, Mar 10, 2015 at 08:42:40AM -0700, Yinghai Lu wrote: >> In arch/x86/boot/header.S, we already use VO and ZO. >> So please keep on using them, and don't introduce "kernel proper" etc. > > So you&

Re: [PATCH v3 3/7] x86, boot: Don't overlap VO with ZO data

2015-03-10 Thread Yinghai Lu
On Tue, Mar 10, 2015 at 8:21 AM, Borislav Petkov wrote: > On Tue, Mar 10, 2015 at 08:17:01AM -0700, Yinghai Lu wrote: >> Make it not confusing. >> >> ZO: arch/x86/boot/compressed/vmlinux >> VO: vmlinux >> >> setup + ZO ==> bzImage. >> >> compr

Re: [PATCH v3 3/7] x86, boot: Don't overlap VO with ZO data

2015-03-10 Thread Yinghai Lu
On Tue, Mar 10, 2015 at 8:10 AM, Borislav Petkov wrote: > On Tue, Mar 10, 2015 at 08:05:52AM -0700, Yinghai Lu wrote: >> We need to keep VO and ZO here... > > Why? Make it not confusing. ZO: arch/x86/boot/compressed/vmlinux VO: vmlinux setup + ZO ==> bzImage. compres

Re: [PATCH v3 2/7] x86, boot: Move ZO to end of buffer

2015-03-10 Thread Yinghai Lu
On Tue, Mar 10, 2015 at 1:00 AM, Borislav Petkov wrote: > Final patch: > > --- > From: Yinghai Lu > Date: Sat, 7 Mar 2015 14:07:16 -0800 > Subject: [PATCH] x86/setup: Move compressed kernel to the end of the buffer setup should only about arch/x86/boot/setup.ld related.

Re: [PATCH v3 3/7] x86, boot: Don't overlap VO with ZO data

2015-03-10 Thread Yinghai Lu
On Tue, Mar 10, 2015 at 2:34 AM, Borislav Petkov wrote: > Final patch: > > --- > From: Yinghai Lu > Date: Sat, 7 Mar 2015 14:07:17 -0800 > Subject: [PATCH] x86/setup: Don't overlap vmlinux's brk with compressed > kernel's data We need to keep VO and

Re: [PATCH v3 7/7] x86, kaslr, 64bit: Set new or extra ident_mapping

2015-03-09 Thread Yinghai Lu
On Mon, Mar 9, 2015 at 6:14 PM, Yinghai Lu wrote: >>> >>> +#include "misc_pgt.c" >> >> Shouldn't this just be a normal built .o file that is linked together >> in the Makefile, specifically tracking CONFIG_RANDOMIZE_BASE as aslr.o >>

Re: [PATCH v3 7/7] x86, kaslr, 64bit: Set new or extra ident_mapping

2015-03-09 Thread Yinghai Lu
On Mon, Mar 9, 2015 at 6:09 PM, Kees Cook wrote: > On Sat, Mar 7, 2015 at 2:07 PM, Yinghai Lu wrote: >> First, aslr will support to put random VO above 4G, so we must set ident >> mapping for the range even we come from startup_32 path. >> >> Second, when boot from 6

Re: [PATCH v3 5/7] x86, kaslr: Consolidate mem_avoid array filling

2015-03-09 Thread Yinghai Lu
On Mon, Mar 9, 2015 at 6:00 PM, Kees Cook wrote: > On Sat, Mar 7, 2015 at 2:07 PM, Yinghai Lu wrote: > > This may be a stupid question, but are boot_params being used outside > of the compressed loader? If so, it might make sense to split that > change into a separate patch to g

Re: [PATCH v3 2/7] x86, boot: Move ZO to end of buffer

2015-03-09 Thread Yinghai Lu
On Mon, Mar 9, 2015 at 5:54 PM, Kees Cook wrote: > On Sat, Mar 7, 2015 at 2:07 PM, Yinghai Lu wrote: >> Boris found data from boot stage can not be used kernel stage. > > "... be used during kernel stage." > > Also, can you give a specific example of this

Re: [PATCH v3 0/7] x86, boot: clean up kasl

2015-03-09 Thread Yinghai Lu
On Mon, Mar 9, 2015 at 5:39 PM, Kees Cook wrote: > On Sat, Mar 7, 2015 at 2:07 PM, Yinghai Lu wrote: >> First 3 patches make ZO (arch/x86/boot/compressed/vmlinux) data region is not >> overwritten by VO (vmlinux) after decompress. So could pass data from ZO to >> VO. >

Re: [PATCH v3 1/7] x86, kaslr: Use init_size instead of run_size

2015-03-09 Thread Yinghai Lu
On Mon, Mar 9, 2015 at 1:18 PM, Borislav Petkov wrote: > On Mon, Mar 09, 2015 at 01:06:00PM -0700, Yinghai Lu wrote: >> Yes. Just to emphasize that " We need to make sure [z_extra_offset, >> init_size) will fit ZO" > > So you want to say: > > "We need

Re: [PATCH v3 1/7] x86, kaslr: Use init_size instead of run_size

2015-03-09 Thread Yinghai Lu
On Mon, Mar 9, 2015 at 1:00 PM, Borislav Petkov wrote: > On Mon, Mar 09, 2015 at 12:35:25PM -0700, Yinghai Lu wrote: >> Can you put back: >> " >> So need to make sure [z_extra_offset, init_size) will fit ZO, that means >> init_size need to be adjusted according to

Re: [PATCH v3 1/7] x86, kaslr: Use init_size instead of run_size

2015-03-09 Thread Yinghai Lu
On Mon, Mar 9, 2015 at 5:49 AM, Borislav Petkov wrote: > I ended up committing this. Anything I've missed? > > --- > From: Yinghai Lu > Date: Sat, 7 Mar 2015 14:07:15 -0800 > Subject: [PATCH] x86/setup: Use init_size instead of run_size > > Commit > > e602

Re: [PATCH v3 1/8] x86: Kill E820_RESERVED_KERN

2015-03-07 Thread Yinghai Lu
On Sat, Mar 7, 2015 at 5:59 PM, David Rientjes wrote: > > Hmm, although the bug is reported for a 3.12 kernel, I assume this is for > stable 3.10+? If so, it should apply fine with the exception of removing > e820_reserve_setup_data() from setup_arch() rather than > memblock_x86_reserve_range_set

[PATCH v3 8/8] x86, boot, PCI: Export SETUP_PCI data via sysfs

2015-03-07 Thread Yinghai Lu
So we could let kexec-tools to rebuild SETUP_PCI and pass it to second kernel if needed. Now kexec-tools already build SETUP_EFI and SETUP_E820EXT. Cc: Bjorn Helgaas Cc: linux-...@vger.kernel.org Signed-off-by: Yinghai Lu --- arch/x86/pci/common.c | 175

[PATCH v3 3/8] x86, of: Let add_dtb reserve setup_data locally

2015-03-07 Thread Yinghai Lu
We will not reserve setup_data in generic code. Every handler need to reserve and copy setup_data locally. Current dtd handling already have code for copying, just add reserve code. Also simplify code a bit by storing real dtb size. Cc: Rob Herring Cc: David Vrabel Signed-off-by: Yinghai Lu

[PATCH v3 5/8] x86: Kill not used setup_data handling code

2015-03-07 Thread Yinghai Lu
Cc: Matt Fleming Signed-off-by: Yinghai Lu --- arch/x86/kernel/kdebugfs.c | 142 - arch/x86/kernel/setup.c| 17 -- 2 files changed, 159 deletions(-) diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c index dc1404b..c8ca86c

[PATCH v3 2/8] x86, efi: Copy SETUP_EFI data and access directly

2015-03-07 Thread Yinghai Lu
The copy will be in __initdata, and it is small. We can use pointer to access the setup_data instead of using early_memmap everywhere. Cc: Matt Fleming Cc: linux-efi@vger.kernel.org Signed-off-by: Yinghai Lu --- arch/x86/include/asm/efi.h | 2 +- arch/x86/platform/efi/efi.c| 13

[PATCH v3 4/8] x86, boot: Add add_pci handler for SETUP_PCI

2015-03-07 Thread Yinghai Lu
Let it reserve setup_data, and keep it's own list. Also clear the hdr.setup_data, as all handler now handle or reserve setup_data locally already. Cc: Bjorn Helgaas Cc: Matt Fleming Cc: linux-...@vger.kernel.org Signed-off-by: Yinghai Lu --- arch/x86/include/asm/pci.h | 2 ++ arc

[PATCH v3 1/8] x86: Kill E820_RESERVED_KERN

2015-03-07 Thread Yinghai Lu
/show_bug.cgi?id=913885 Reported-by: "Lee, Chun-Yi" Tested-by: "Lee, Chun-Yi" Cc: "Lee, Chun-Yi" Signed-off-by: Yinghai Lu Cc: sta...@vger.kernel.org --- arch/x86/include/uapi/asm/e820.h | 9 - arch/x86/kernel/e820.c | 6 ++ arch/x8

[PATCH v3 7/8] x86, boot, PCI: Copy SETUP_PCI rom to kernel space

2015-03-07 Thread Yinghai Lu
As EFI stub code could put them high when on 32bit or with exactmap= on 64bit conf. Check if the range is mapped, otherwise allocate new one and have the rom data copied. So we could access them directly. Signed-off-by: Yinghai Lu --- arch/x86/pci/common.c | 47

[PATCH v3 6/8] x86, boot, PCI: Convert SETUP_PCI data to list

2015-03-07 Thread Yinghai Lu
So we could avoid ioremap every time later. Cc: Bjorn Helgaas Cc: linux-...@vger.kernel.org Signed-off-by: Yinghai Lu --- arch/x86/include/asm/pci.h | 2 ++ arch/x86/kernel/setup.c| 1 + arch/x86/pci/common.c | 77 +- 3 files changed, 65

[PATCH v3 0/8] x86, boot: clean up setup_data handling

2015-03-07 Thread Yinghai Lu
Yinghai Lu -v3: separated with kasl patches, and fix early_ioremap return checking. Yinghai Lu (8): x86: Kill E820_RESERVED_KERN x86, efi: Copy SETUP_EFI data and access directly x86, of: Let add_dtb reserve setup_data locally x86, boot: Add add_pci handler for SETUP_PCI x86: Kill not

[PATCH v3 2/8] x86, efi: Copy SETUP_EFI data and access directly

2015-03-07 Thread Yinghai Lu
The copy will be in __initdata, and it is small. We can use pointer to access the setup_data instead of using early_memmap everywhere. Cc: Matt Fleming Cc: linux-efi@vger.kernel.org Signed-off-by: Yinghai Lu --- arch/x86/include/asm/efi.h | 2 +- arch/x86/platform/efi/efi.c| 13

[PATCH v3 1/8] x86: Kill E820_RESERVED_KERN

2015-03-07 Thread Yinghai Lu
/show_bug.cgi?id=913885 Reported-by: "Lee, Chun-Yi" Tested-by: "Lee, Chun-Yi" Cc: "Lee, Chun-Yi" Signed-off-by: Yinghai Lu Cc: sta...@vger.kernel.org --- arch/x86/include/uapi/asm/e820.h | 9 - arch/x86/kernel/e820.c | 6 ++ arch/x8

[PATCH v3 0/8] x86, boot: clean up setup_data handling

2015-03-07 Thread Yinghai Lu
Yinghai Lu -v3: separated with kasl patches, and fix early_ioremap return checking. Yinghai Lu (8): x86: Kill E820_RESERVED_KERN x86, efi: Copy SETUP_EFI data and access directly x86, of: Let add_dtb reserve setup_data locally x86, boot: Add add_pci handler for SETUP_PCI x86: Kill not

[PATCH v3 7/7] x86, kaslr, 64bit: Set new or extra ident_mapping

2015-03-07 Thread Yinghai Lu
v Cc: Matt Fleming Signed-off-by: Yinghai Lu --- arch/x86/boot/compressed/aslr.c | 21 arch/x86/boot/compressed/head_64.S | 4 +- arch/x86/boot/compressed/misc_pgt.c | 98 + arch/x86/include/asm/boot.h | 19 +++ 4 files changed, 140 inser

[PATCH v3 4/7] x86, kaslr: Access the correct kaslr_enabled variable

2015-03-07 Thread Yinghai Lu
: Jiri Kosina Signed-off-by: Yinghai Lu --- arch/x86/kernel/setup.c | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 98dc931..912f124 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -429

[PATCH v3 3/7] x86, boot: Don't overlap VO with ZO data

2015-03-07 Thread Yinghai Lu
dress calculation") Cc: "H. Peter Anvin" Cc: Matt Fleming Cc: Kees Cook Signed-off-by: Yinghai Lu --- arch/x86/boot/Makefile | 2 +- arch/x86/boot/compressed/vmlinux.lds.S | 1 + arch/x86/boot/header.S | 7 +-- 3 files changed, 7 insertions(+), 3 deleti

[PATCH v3 6/7] x86, boot: Split kernel_ident_mapping_init to another file

2015-03-07 Thread Yinghai Lu
We need to include that in boot::decompress_kernel stage to set new ident mapping. Also add checking for __pa/__va macro definition, as we need to override them in boot::decompress_kernel stage. Signed-off-by: Yinghai Lu --- arch/x86/include/asm/page.h | 5 +++ arch/x86/mm/ident_map.c

[PATCH v3 2/7] x86, boot: Move ZO to end of buffer

2015-03-07 Thread Yinghai Lu
eming Cc: Kees Cook Signed-off-by: Yinghai Lu --- arch/x86/boot/compressed/head_32.S | 11 +-- arch/x86/boot/compressed/head_64.S | 8 ++-- arch/x86/boot/compressed/mkpiggy.c | 7 ++- arch/x86/boot/compressed/vmlinux.lds.S | 1 + arch/x86/boot/header.S

[PATCH v3 1/7] x86, kaslr: Use init_size instead of run_size

2015-03-07 Thread Yinghai Lu
rton Cc: Ard Biesheuvel Cc: Junjie Mao Signed-off-by: Yinghai Lu --- arch/x86/boot/compressed/Makefile | 4 +--- arch/x86/boot/compressed/head_32.S | 5 ++--- arch/x86/boot/compressed/head_64.S | 5 + arch/x86/boot/compressed/misc.c| 15 +++--- arch/x86/boot/compressed/mkp

[PATCH v3 0/7] x86, boot: clean up kasl

2015-03-07 Thread Yinghai Lu
hanks Yinghai Lu Yinghai Lu (7): x86, kaslr: Use init_size instead of run_size x86, boot: Move ZO to end of buffer x86, boot: Don't overlap VO with ZO data x86, kaslr: Access the correct kaslr_enabled variable x86, kaslr: Consolidate mem_avoid array filling x86, b

[PATCH v3 5/7] x86, kaslr: Consolidate mem_avoid array filling

2015-03-07 Thread Yinghai Lu
ferring to init_size, as we pass init_size instead. Cc: Kees Cook Signed-off-by: Yinghai Lu --- arch/x86/boot/compressed/aslr.c | 29 ++--- arch/x86/boot/compressed/misc.h | 4 ++-- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/arch/x86/boot/compressed/aslr.c

Re: [PATCH v2 04/15] x86, kaslr: get kaslr_enabled back correctly

2015-03-07 Thread Yinghai Lu
On Sat, Mar 7, 2015 at 1:05 PM, Borislav Petkov wrote: > On Fri, Mar 06, 2015 at 11:53:22AM -0800, Yinghai Lu wrote: > --- > Commit > > f47233c2d34f ("x86/mm/ASLR: Propagate base load address calculation") > > started passing KASLR status to kernel proper, but

Re: [PATCH v2 01/15] x86, kaslr: Use init_size instead of run_size

2015-03-06 Thread Yinghai Lu
On Fri, Mar 6, 2015 at 11:56 AM, Kees Cook wrote: > On Fri, Mar 6, 2015 at 11:28 AM, Yinghai Lu wrote: > Okay, I've proven this to myself now. :) I think it would be valuable > to call out that brk and bss are included in the _end calculation. For > others: ... > So, _en

Re: [PATCH v2 04/15] x86, kaslr: get kaslr_enabled back correctly

2015-03-06 Thread Yinghai Lu
On Fri, Mar 6, 2015 at 11:50 AM, Yinghai Lu wrote: > On Fri, Mar 6, 2015 at 5:33 AM, Borislav Petkov wrote: > >> >> "However, the setup_data linked list and thus the element which contains >> kaslr_enabled is chained together using physical addresses. At the >

Re: [PATCH v2 04/15] x86, kaslr: get kaslr_enabled back correctly

2015-03-06 Thread Yinghai Lu
On Fri, Mar 6, 2015 at 5:33 AM, Borislav Petkov wrote: > > "However, the setup_data linked list and thus the element which contains > kaslr_enabled is chained together using physical addresses. At the > time when we access it in the kernel proper, we're already running > with paging enabled and t

Re: [PATCH v2 01/15] x86, kaslr: Use init_size instead of run_size

2015-03-06 Thread Yinghai Lu
On Fri, Mar 6, 2015 at 10:55 AM, Kees Cook wrote: > On Fri, Mar 6, 2015 at 10:44 AM, Yinghai Lu wrote: > > I don't see how bss and brk are related to these sizes. Can you > explain how bss, brk, and initrd factor into these sizes? Those were > what run_size was created t

Re: [PATCH v2 01/15] x86, kaslr: Use init_size instead of run_size

2015-03-06 Thread Yinghai Lu
On Fri, Mar 6, 2015 at 5:55 AM, Borislav Petkov wrote: > On Wed, Mar 04, 2015 at 12:00:34AM -0800, Yinghai Lu wrote: >> commit e6023367d779 ("x86, kaslr: Prevent .bss from overlaping initrd") >> >> introduced one run_size for kaslr. >> >> We do not

Re: [PATCH v2 04/15] x86, kaslr: get kaslr_enabled back correctly

2015-03-06 Thread Yinghai Lu
On Fri, Mar 6, 2015 at 5:33 AM, Borislav Petkov wrote: > Please use checkpatch before submitting patches: > > WARNING: please, no spaces at the start of a line > #71: FILE: arch/x86/kernel/setup.c:433: > +unsigned char *data;$ > > WARNING: please, no spaces at the start of a line > #72: FILE:

Re: [PATCH v2 04/15] x86, kaslr: get kaslr_enabled back correctly

2015-03-04 Thread Yinghai Lu
On Wed, Mar 4, 2015 at 6:58 PM, joeyli wrote: > > After 84c91b7ae merged to v3.17 kernel, hibernate code checks the e280 regions > should not be changed when doing hibernate resume. Without your patch 8, > the hibernate resume checking will randomly fail on the machines that reserved > setup_data

Re: [PATCH v2 04/15] x86, kaslr: get kaslr_enabled back correctly

2015-03-04 Thread Yinghai Lu
3c2d34f ("x86/mm/ASLR: Propagate base load address calculation") Cc: Matt Fleming Cc: Borislav Petkov Cc: Kees Cook Cc: Jiri Kosina Acked-by: Jiri Kosina Signed-off-by: Yinghai Lu --- arch/x86/kernel/setup.c | 13 - 1 file changed, 12 insertions(+), 1 deletion(-)

Re: [PATCH v2 04/15] x86, kaslr: get kaslr_enabled back correctly

2015-03-04 Thread Yinghai Lu
On Wed, Mar 4, 2015 at 10:06 AM, Yinghai Lu wrote: > On Wed, Mar 4, 2015 at 2:16 AM, Borislav Petkov wrote: >> On Wed, Mar 04, 2015 at 12:00:37AM -0800, Yinghai Lu wrote: >>> commit f47233c2d34f ("x86/mm/ASLR: Propagate base load address calculation") >&

Re: [PATCH v2 04/15] x86, kaslr: get kaslr_enabled back correctly

2015-03-04 Thread Yinghai Lu
On Wed, Mar 4, 2015 at 7:54 AM, Jiri Kosina wrote: > > Also this 15-patch series needs to be separated into two patchsets. The > whole series is not appropriate for -rc3, but this particular one at least > is a regression fix that has to go in. The first 4 should go v4.0. could leave others to

Re: [PATCH v2 04/15] x86, kaslr: get kaslr_enabled back correctly

2015-03-04 Thread Yinghai Lu
On Wed, Mar 4, 2015 at 2:16 AM, Borislav Petkov wrote: > On Wed, Mar 04, 2015 at 12:00:37AM -0800, Yinghai Lu wrote: >> commit f47233c2d34f ("x86/mm/ASLR: Propagate base load address calculation") >> is using address as value for kaslr_enabled. >> >> That will

[PATCH v2 07/15] x86, kaslr, 64bit: set new or extra ident_mapping

2015-03-04 Thread Yinghai Lu
cross 512G boundary, will need 1+(2+2)*4 pages with 2M mapping. Cc: Kees Cook Cc: Jiri Kosina Cc: Borislav Petkov Cc: Matt Fleming Signed-off-by: Yinghai Lu --- arch/x86/boot/compressed/aslr.c | 28 +++ arch/x86/boot/compressed/head_64.S | 4 +- arch/x86/boot/compressed

[PATCH v2 00/15] x86, boot: clean up kasl and setup_data handling

2015-03-04 Thread Yinghai Lu
abled accessing... 6. export SETUP_PCI via sysfs. Yinghai Lu (15): x86, kaslr: Use init_size instead of run_size x86, boot: move ZO to end of buffer x86, boot: keep data from ZO boot stage to VO kernel stage. x86, kaslr: get kaslr_enabled back correctly x86, kaslr: consolidate the mem_avoid fi

[PATCH v2 06/15] x86, boot: split kernel_ident_mapping_init into another file

2015-03-04 Thread Yinghai Lu
We need to include that in boot::decompress_kernel stage to set new mapping. Signed-off-by: Yinghai Lu --- arch/x86/include/asm/page.h | 5 +++ arch/x86/mm/ident_map.c | 74 + arch/x86/mm/init_64.c | 74

[PATCH v2 04/15] x86, kaslr: get kaslr_enabled back correctly

2015-03-04 Thread Yinghai Lu
uot;x86/mm/ASLR: Propagate base load address calculation") Cc: Matt Fleming Cc: Borislav Petkov Cc: Kees Cook Cc: Jiri Kosina Acked-by: Jiri Kosina Signed-off-by: Yinghai Lu --- arch/x86/kernel/setup.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/kerne

[PATCH v2 03/15] x86, boot: keep data from ZO boot stage to VO kernel stage.

2015-03-04 Thread Yinghai Lu
/compressed/vmlinux. -v2: add init_size in arch/x86/boot/header.S instead of BRK. -v3: split code that move Zo to end of buffer to another patch. Fixes: f47233c2d34f ("x86/mm/ASLR: Propagate base load address calculation") Cc: "H. Peter Anvin" Cc: Matt Fleming Cc: Kees Cook Signe

[PATCH v2 01/15] x86, kaslr: Use init_size instead of run_size

2015-03-04 Thread Yinghai Lu
il. Fixes: e6023367d779 ("x86, kaslr: Prevent .bss from overlaping initrd") Cc: "H. Peter Anvin" Cc: Josh Triplett Cc: Matt Fleming Cc: Kees Cook Cc: Andrew Morton Cc: Ard Biesheuvel Cc: Junjie Mao Signed-off-by: Yinghai Lu --- arch/x86/boot/compressed/Makefile | 4

[PATCH v2 02/15] x86, boot: move ZO to end of buffer

2015-03-04 Thread Yinghai Lu
compressed kernel close the end of buffer instead of middle of the buffer. Fixes: f47233c2d34f ("x86/mm/ASLR: Propagate base load address calculation") Cc: "H. Peter Anvin" Cc: Matt Fleming Cc: Kees Cook Signed-off-by: Yinghai Lu --- arch/x86/boot/compressed/head_32.S | 11 ++

[PATCH v2 15/15] x86, pci: export SETUP_PCI data via sysfs

2015-03-04 Thread Yinghai Lu
So we could let kexec-tools to rebuild SETUP_PCI and pass it to second kernel. Now kexec-tools already build SETUP_EFI and SETUP_E820EXT. Cc: Bjorn Helgaas Cc: linux-...@vger.kernel.org Signed-off-by: Yinghai Lu --- arch/x86/pci/common.c | 175

[PATCH v2 09/15] x86, efi: copy SETUP_EFI data and access directly

2015-03-04 Thread Yinghai Lu
the copy will be in __initdata, and it is small. We can use pointer to access the setup_data instead of keeping on early_memmap and early_memunmap everywhere. Cc: Matt Fleming Cc: linux-efi@vger.kernel.org Signed-off-by: Yinghai Lu --- arch/x86/include/asm/efi.h | 2 +- arch/x86/platform

[PATCH v2 11/15] x86, boot: Add add_pci handler for SETUP_PCI

2015-03-04 Thread Yinghai Lu
Let it reserve setup_data, and keep it's own list. Also clear the hdr.setup_data, as all handler will handle or reserve setup_data locally already. Cc: Bjorn Helgaas Cc: Matt Fleming Cc: linux-...@vger.kernel.org Signed-off-by: Yinghai Lu --- arch/x86/include/asm/pci.h | 2 ++ arc

[PATCH v2 12/15] x86: kill not used setup_data handling code

2015-03-04 Thread Yinghai Lu
Cc: Matt Fleming Signed-off-by: Yinghai Lu --- arch/x86/kernel/kdebugfs.c | 142 - arch/x86/kernel/setup.c| 17 -- 2 files changed, 159 deletions(-) diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c index dc1404b..c8ca86c

[PATCH v2 13/15] x86, pci: convert SETUP_PCI data to list

2015-03-04 Thread Yinghai Lu
So we could avoid ioremap every time later. Cc: Bjorn Helgaas Cc: linux-...@vger.kernel.org Signed-off-by: Yinghai Lu --- arch/x86/include/asm/pci.h | 2 ++ arch/x86/kernel/setup.c| 1 + arch/x86/pci/common.c | 77 +- 3 files changed, 65

[PATCH v2 08/15] x86: Kill E820_RESERVED_KERN

2015-03-04 Thread Yinghai Lu
un-Yi" Tested-by: "Lee, Chun-Yi" Cc: "Lee, Chun-Yi" Signed-off-by: Yinghai Lu Cc: sta...@vger.kernel.org --- arch/x86/include/uapi/asm/e820.h | 9 - arch/x86/kernel/e820.c | 6 ++ arch/x86/kernel/setup.c | 26 -

[PATCH v2 14/15] x86, boot: copy rom to kernel space

2015-03-04 Thread Yinghai Lu
As EFI stub code could put them high when on 32bit or with exactmap= on 64bit conf. Check is the range is mapped, otherwise allocate new one and have the rom data copied. So we could really avoid ioremap. Signed-off-by: Yinghai Lu --- arch/x86/pci/common.c | 47

[PATCH v2 10/15] x86, of: let add_dtb reserve by itself

2015-03-04 Thread Yinghai Lu
We will not reserve setup_data in general code. Every handler need to reserve and copy. Current dtd handling already have code copying, just add reserve code ... also simplify code a bit with storing real dtb size. Cc: Rob Herring Cc: David Vrabel Signed-off-by: Yinghai Lu --- arch/x86

[PATCH v2 05/15] x86, kaslr: consolidate the mem_avoid filling

2015-03-04 Thread Yinghai Lu
pass that instead already. Cc: Kees Cook Signed-off-by: Yinghai Lu --- arch/x86/boot/compressed/aslr.c | 29 ++--- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/arch/x86/boot/compressed/aslr.c b/arch/x86/boot/compressed/aslr.c index 7083c16..e8486a5 10

Re: [PATCH 1/8] x86, kaslr: get kaslr_enabled back correctly

2015-03-02 Thread Yinghai Lu
: Kees Cook Cc: Andrew Morton Cc: Ard Biesheuvel Cc: Junjie Mao Signed-off-by: Yinghai Lu --- arch/x86/boot/compressed/Makefile |4 --- arch/x86/boot/compressed/head_32.S |5 +--- arch/x86/boot/compressed/head_64.S |5 arch/x86/boot/compressed/misc.c| 15 ++--- a

Re: [PATCH 1/8] x86, kaslr: get kaslr_enabled back correctly

2015-03-02 Thread Yinghai Lu
On Mon, Mar 2, 2015 at 6:53 AM, Borislav Petkov wrote: > Well, it seems to work here but it still doesn't look reliable enough to > me. And this addon_zo thing of arbitrary 256K is strange. Thanks for check that out. That is not arbitrary number. Need to make that bigger than _end - _rodata > o

Re: [PATCH 1/8] x86, kaslr: get kaslr_enabled back correctly

2015-03-02 Thread Yinghai Lu
On Mon, Mar 2, 2015 at 12:56 AM, Borislav Petkov wrote: > On Sun, Mar 01, 2015 at 12:41:10PM -0800, Yinghai Lu wrote: >> Does not look safe yet... > > Why? We can not assume that range is safe to use. Please check attach one that should fix the problem really. Thanks Yinghai

Re: [PATCH 1/8] x86, kaslr: get kaslr_enabled back correctly

2015-03-01 Thread Yinghai Lu
On Sun, Mar 1, 2015 at 12:29 PM, Borislav Petkov wrote: > On Sun, Mar 01, 2015 at 12:24:08PM -0800, Yinghai Lu wrote: >> static allocation in misc.c can not be used to kernel/head_64.S stage safely. > > Correct. One possibility that works is sticking it right below >

Re: [PATCH 1/8] x86, kaslr: get kaslr_enabled back correctly

2015-03-01 Thread Yinghai Lu
On Sun, Mar 1, 2015 at 11:49 AM, Borislav Petkov wrote: > On Sun, Mar 01, 2015 at 11:27:48AM -0800, Yinghai Lu wrote: >> other 7 should also address the problem in >>http://lkml.kernel.org/r/1424929021.10337.24.ca...@intel.com > > No, they don't: > > [

Re: [PATCH 1/8] x86, kaslr: get kaslr_enabled back correctly

2015-03-01 Thread Yinghai Lu
On Sun, Mar 1, 2015 at 7:23 AM, Ingo Molnar wrote: > > I think that's a different bug. > > parse_kaslr_setup() is simply bogus, it does: > > kaslr_enabled = (bool)(pa_data + sizeof(struct setup_data)); > > which makes no sense whatsoever: it randomly enables (or disables, > depending on th

Re: [PATCH 1/8] x86, kaslr: get kaslr_enabled back correctly

2015-02-28 Thread Yinghai Lu
On Sat, Feb 28, 2015 at 6:17 PM, Yinghai Lu wrote: > We should access variable with referrence instead of using physical > address as value. > > Cc: Matt Fleming > Cc: Borislav Petkov > Signed-off-by: Yinghai Lu > --- > arch/x86/kernel/setup.c | 8 +++- > 1

[PATCH 2/8] x86: Kill E820_RESERVED_KERN

2015-02-28 Thread Yinghai Lu
un-Yi" Tested-by: "Lee, Chun-Yi" Cc: "Lee, Chun-Yi" Signed-off-by: Yinghai Lu Cc: sta...@vger.kernel.org --- arch/x86/include/uapi/asm/e820.h | 9 - arch/x86/kernel/e820.c | 6 ++ arch/x86/kernel/setup.c | 26 -

[PATCH 1/8] x86, kaslr: get kaslr_enabled back correctly

2015-02-28 Thread Yinghai Lu
We should access variable with referrence instead of using physical address as value. Cc: Matt Fleming Cc: Borislav Petkov Signed-off-by: Yinghai Lu --- arch/x86/kernel/setup.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel

[PATCH 5/8] x86, boot: Add add_pci handler for SETUP_PCI

2015-02-28 Thread Yinghai Lu
Let it reserve setup_data, and keep it's own list. Also clear the hdr.setup_data, as all handler will handle or reserve setup_data locally already. Cc: Bjorn Helgaas Cc: Matt Fleming Cc: linux-...@vger.kernel.org Signed-off-by: Yinghai Lu --- arch/x86/include/asm/pci.h | 2 ++ arc

[PATCH 3/8] x86, efi: copy SETUP_EFI data and access directly

2015-02-28 Thread Yinghai Lu
the copy will be in __initdata, and it is small. We can use pointer to access the setup_data instead of keeping on early_memmap and early_memunmap everywhere. Cc: Matt Fleming Cc: linux-efi@vger.kernel.org Signed-off-by: Yinghai Lu --- arch/x86/include/asm/efi.h | 2 +- arch/x86/platform

  1   2   >