From: Dennis Chen <hidden> Date: 2016-06-23 11:31:35
Two major changes in this patch:
[1] Add memblock_mem_limit_mark_nomap(phys_addr_t limit) function to
mark memblock regions above the @limit as NOMAP region, which will
be used to address the observed 'mem=x' kernel parameter issue.
[2] Add 'size' and 'flag' debug output in the memblock debugfs.
The '/sys/kernel/debug/memblock/memory' output looks like before:
0: 0x0000008000000000..0x0000008001e7ffff
1: 0x0000008001e80000..0x00000083ff184fff
2: 0x00000083ff185000..0x00000083ff1c2fff
3: 0x00000083ff1c3000..0x00000083ff222fff
4: 0x00000083ff223000..0x00000083ffe42fff
5: 0x00000083ffe43000..0x00000083ffffffff
With this patch applied:
0: 0x0000008000000000..0x0000008001e7ffff 0x0000000001e80000 0x4
1: 0x0000008001e80000..0x00000083ff184fff 0x00000003fd305000 0x0
2: 0x00000083ff185000..0x00000083ff1c2fff 0x000000000003e000 0x4
3: 0x00000083ff1c3000..0x00000083ff222fff 0x0000000000060000 0x0
4: 0x00000083ff223000..0x00000083ffe42fff 0x0000000000c20000 0x4
5: 0x00000083ffe43000..0x00000083ffffffff 0x00000000001bd000 0x0
Signed-off-by: Dennis Chen <redacted>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Steve Capper <redacted>
Cc: Ard Biesheuvel <redacted>
Cc: Will Deacon <redacted>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Rafael J. Wysocki <redacted>
Cc: Matt Fleming <redacted>
Cc: linux-mm at kvack.org
Cc: linux-acpi at vger.kernel.org
Cc: linux-efi at vger.kernel.org
---
include/linux/memblock.h | 2 ++
mm/memblock.c | 50 ++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 44 insertions(+), 8 deletions(-)
@@ -814,6 +814,18 @@ int __init_memblock memblock_mark_nomap(phys_addr_t base, phys_addr_t size)}/**+*memblock_clear_nomap-ClearflagMEMBLOCK_NOMAPforaspecifiedregion.+*@base:thebasephysaddroftheregion+*@size:thesizeoftheregion+*+*Return0onsuccess,-errnoonfailure.+*/+int__init_memblockmemblock_clear_nomap(phys_addr_tbase,phys_addr_tsize)+{+returnmemblock_setclr_flag(base,size,0,MEMBLOCK_NOMAP);+}++/***__next_reserved_mem_region-nextfunctionforfor_each_reserved_region()*@idx:pointertou64loopvariable*@out_start:ptrtophys_addr_tforstartaddressoftheregion,canbe%NULL
@@ -1465,14 +1477,11 @@ phys_addr_t __init_memblock memblock_end_of_DRAM(void)return(memblock.memory.regions[idx].base+memblock.memory.regions[idx].size);}-void__initmemblock_enforce_memory_limit(phys_addr_tlimit)+staticphys_addr_t__find_max_addr(phys_addr_tlimit){phys_addr_tmax_addr=(phys_addr_t)ULLONG_MAX;structmemblock_region*r;-if(!limit)-return;-/* find out max address */for_each_memblock(memory,r){if(limit<=r->size){
@@ -1482,6 +1491,18 @@ void __init memblock_enforce_memory_limit(phys_addr_t limit)limit-=r->size;}+returnmax_addr;+}++void__initmemblock_enforce_memory_limit(phys_addr_tlimit)+{+phys_addr_tmax_addr;++if(!limit)+return;++max_addr=__find_max_addr(limit);+/* truncate both memory and reserved regions */memblock_remove_range(&memblock.memory,max_addr,(phys_addr_t)ULLONG_MAX);
From: Dennis Chen <hidden> Date: 2016-06-23 11:31:59
This is a rework patch based on [1]. According to the proposal from
Mark Rutland, when applying the system memory limit through 'mem=x'
kernel command line, don't remove the rest memory regions above the
limit from the memblock, instead marking them as MEMBLOCK_NOMAP region,
which will preserve the ability to identify regions as normal memory
while not using them for allocation and the linear map.
Without this patch, the ACPI core will map those acpi data regions(if
they are above the limit) as device type memory, which will result in
the alignment exception when ACPI core parses the AML data stream
since the parsing will produce some non-alignment accesses.
[1]:http://lists.infradead.org/pipermail/linux-arm-kernel/2016-June/438443.html
Signed-off-by: Dennis Chen <redacted>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Steve Capper <redacted>
Cc: Ard Biesheuvel <redacted>
Cc: Will Deacon <redacted>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Rafael J. Wysocki <redacted>
Cc: Matt Fleming <redacted>
Cc: linux-mm at kvack.org
Cc: linux-acpi at vger.kernel.org
Cc: linux-efi at vger.kernel.org
---
arch/arm64/mm/init.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
From: Mark Rutland <mark.rutland@arm.com> Date: 2016-06-23 12:42:36
On Thu, Jun 23, 2016 at 07:30:15PM +0800, Dennis Chen wrote:
This is a rework patch based on [1]. According to the proposal from
Mark Rutland, when applying the system memory limit through 'mem=x'
kernel command line, don't remove the rest memory regions above the
limit from the memblock, instead marking them as MEMBLOCK_NOMAP region,
which will preserve the ability to identify regions as normal memory
while not using them for allocation and the linear map.
Without this patch, the ACPI core will map those acpi data regions(if
they are above the limit) as device type memory, which will result in
the alignment exception when ACPI core parses the AML data stream
since the parsing will produce some non-alignment accesses.
[1]:http://lists.infradead.org/pipermail/linux-arm-kernel/2016-June/438443.html
Please rewrite the message to be standalone (i.e. so peopel can read
this without having to folow the link).
Explain why using mem= makes ACPI think regions should be mapped as
Device memory, the problems this causes for ACPICA, then cover why we
want to nomap the region.
quoted hunk
Signed-off-by: Dennis Chen <redacted>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Steve Capper <redacted>
Cc: Ard Biesheuvel <redacted>
Cc: Will Deacon <redacted>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Rafael J. Wysocki <redacted>
Cc: Matt Fleming <redacted>
Cc: linux-mm at kvack.org
Cc: linux-acpi at vger.kernel.org
Cc: linux-efi at vger.kernel.org
---
arch/arm64/mm/init.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
I think that the memblock_is_map_memory() check should go. Just because
a page of the kernel image is mapped doesn't mean that the rest is. That
will make this a 1-1 change.
Other than that, this looks right to me.
Thanks,
Mark.
}
if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && initrd_start) {
--
1.8.3.1
From: Dennis Chen <hidden> Date: 2016-06-24 02:32:04
On Thu, Jun 23, 2016 at 01:42:30PM +0100, Mark Rutland wrote:
On Thu, Jun 23, 2016 at 07:30:15PM +0800, Dennis Chen wrote:
quoted
This is a rework patch based on [1]. According to the proposal from
Mark Rutland, when applying the system memory limit through 'mem=x'
kernel command line, don't remove the rest memory regions above the
limit from the memblock, instead marking them as MEMBLOCK_NOMAP region,
which will preserve the ability to identify regions as normal memory
while not using them for allocation and the linear map.
Without this patch, the ACPI core will map those acpi data regions(if
they are above the limit) as device type memory, which will result in
the alignment exception when ACPI core parses the AML data stream
since the parsing will produce some non-alignment accesses.
[1]:http://lists.infradead.org/pipermail/linux-arm-kernel/2016-June/438443.html
Please rewrite the message to be standalone (i.e. so peopel can read
this without having to folow the link).
Explain why using mem= makes ACPI think regions should be mapped as
Device memory, the problems this causes for ACPICA, then cover why we
want to nomap the region.
quoted
Signed-off-by: Dennis Chen <redacted>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Steve Capper <redacted>
Cc: Ard Biesheuvel <redacted>
Cc: Will Deacon <redacted>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Rafael J. Wysocki <redacted>
Cc: Matt Fleming <redacted>
Cc: linux-mm at kvack.org
Cc: linux-acpi at vger.kernel.org
Cc: linux-efi at vger.kernel.org
---
arch/arm64/mm/init.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
I think that the memblock_is_map_memory() check should go. Just because
a page of the kernel image is mapped doesn't mean that the rest is. That
will make this a 1-1 change.
Good catch! Will be applied, thanks!
Other than that, this looks right to me.
Thanks,
Mark.
quoted
}
if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && initrd_start) {
--
1.8.3.1
From: Mark Rutland <mark.rutland@arm.com> Date: 2016-06-23 12:57:55
On Thu, Jun 23, 2016 at 07:30:14PM +0800, Dennis Chen wrote:
Two major changes in this patch:
[1] Add memblock_mem_limit_mark_nomap(phys_addr_t limit) function to
mark memblock regions above the @limit as NOMAP region, which will
be used to address the observed 'mem=x' kernel parameter issue.
[2] Add 'size' and 'flag' debug output in the memblock debugfs.
The '/sys/kernel/debug/memblock/memory' output looks like before:
0: 0x0000008000000000..0x0000008001e7ffff
1: 0x0000008001e80000..0x00000083ff184fff
2: 0x00000083ff185000..0x00000083ff1c2fff
3: 0x00000083ff1c3000..0x00000083ff222fff
4: 0x00000083ff223000..0x00000083ffe42fff
5: 0x00000083ffe43000..0x00000083ffffffff
With this patch applied:
0: 0x0000008000000000..0x0000008001e7ffff 0x0000000001e80000 0x4
1: 0x0000008001e80000..0x00000083ff184fff 0x00000003fd305000 0x0
2: 0x00000083ff185000..0x00000083ff1c2fff 0x000000000003e000 0x4
3: 0x00000083ff1c3000..0x00000083ff222fff 0x0000000000060000 0x0
4: 0x00000083ff223000..0x00000083ffe42fff 0x0000000000c20000 0x4
5: 0x00000083ffe43000..0x00000083ffffffff 0x00000000001bd000 0x0
Please explain in the commit message what the problem being solved is,
and how this solves it. e.g.
In some cases, memblock is queried to determine whether a physical
address corresponds to memory present in a system even if unused by the
OS for the linear mapping, highmem, etc. For example, the ACPI core
needs this information to determine which attributes to use when mapping
ACPI regions. Use of incorrect memory types can result in faults, data
corruption, or other issues.
Removing memory with memblock_enforce_memory_limit throws away this
information, and so a kernel booted with mem= may suffer from the issues
described above. To avoid this, we can mark regions as nomap rather than
removing them, which preserves the information we need while preventing
other use of the regions.
This patch adds new insfrastructure to mark all memblock regions in an
address range as nomap, to cater for this. Similarly we add
infrastructure to clear the flag for an address range, which makes
handling some overlap cases simpler.
Other than that, the patch itself looks fine to me.
Thanks,
Mark.
quoted hunk
Signed-off-by: Dennis Chen <redacted>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Steve Capper <redacted>
Cc: Ard Biesheuvel <redacted>
Cc: Will Deacon <redacted>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Rafael J. Wysocki <redacted>
Cc: Matt Fleming <redacted>
Cc: linux-mm at kvack.org
Cc: linux-acpi at vger.kernel.org
Cc: linux-efi at vger.kernel.org
---
include/linux/memblock.h | 2 ++
mm/memblock.c | 50 ++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 44 insertions(+), 8 deletions(-)
@@ -814,6 +814,18 @@ int __init_memblock memblock_mark_nomap(phys_addr_t base, phys_addr_t size)}/**+*memblock_clear_nomap-ClearflagMEMBLOCK_NOMAPforaspecifiedregion.+*@base:thebasephysaddroftheregion+*@size:thesizeoftheregion+*+*Return0onsuccess,-errnoonfailure.+*/+int__init_memblockmemblock_clear_nomap(phys_addr_tbase,phys_addr_tsize)+{+returnmemblock_setclr_flag(base,size,0,MEMBLOCK_NOMAP);+}++/***__next_reserved_mem_region-nextfunctionforfor_each_reserved_region()*@idx:pointertou64loopvariable*@out_start:ptrtophys_addr_tforstartaddressoftheregion,canbe%NULL
@@ -1465,14 +1477,11 @@ phys_addr_t __init_memblock memblock_end_of_DRAM(void)return(memblock.memory.regions[idx].base+memblock.memory.regions[idx].size);}-void__initmemblock_enforce_memory_limit(phys_addr_tlimit)+staticphys_addr_t__find_max_addr(phys_addr_tlimit){phys_addr_tmax_addr=(phys_addr_t)ULLONG_MAX;structmemblock_region*r;-if(!limit)-return;-/* find out max address */for_each_memblock(memory,r){if(limit<=r->size){
@@ -1482,6 +1491,18 @@ void __init memblock_enforce_memory_limit(phys_addr_t limit)limit-=r->size;}+returnmax_addr;+}++void__initmemblock_enforce_memory_limit(phys_addr_tlimit)+{+phys_addr_tmax_addr;++if(!limit)+return;++max_addr=__find_max_addr(limit);+/* truncate both memory and reserved regions */memblock_remove_range(&memblock.memory,max_addr,(phys_addr_t)ULLONG_MAX);
From: Dennis Chen <hidden> Date: 2016-06-24 02:28:45
On Thu, Jun 23, 2016 at 01:57:48PM +0100, Mark Rutland wrote:
On Thu, Jun 23, 2016 at 07:30:14PM +0800, Dennis Chen wrote:
quoted
Two major changes in this patch:
[1] Add memblock_mem_limit_mark_nomap(phys_addr_t limit) function to
mark memblock regions above the @limit as NOMAP region, which will
be used to address the observed 'mem=x' kernel parameter issue.
[2] Add 'size' and 'flag' debug output in the memblock debugfs.
The '/sys/kernel/debug/memblock/memory' output looks like before:
0: 0x0000008000000000..0x0000008001e7ffff
1: 0x0000008001e80000..0x00000083ff184fff
2: 0x00000083ff185000..0x00000083ff1c2fff
3: 0x00000083ff1c3000..0x00000083ff222fff
4: 0x00000083ff223000..0x00000083ffe42fff
5: 0x00000083ffe43000..0x00000083ffffffff
With this patch applied:
0: 0x0000008000000000..0x0000008001e7ffff 0x0000000001e80000 0x4
1: 0x0000008001e80000..0x00000083ff184fff 0x00000003fd305000 0x0
2: 0x00000083ff185000..0x00000083ff1c2fff 0x000000000003e000 0x4
3: 0x00000083ff1c3000..0x00000083ff222fff 0x0000000000060000 0x0
4: 0x00000083ff223000..0x00000083ffe42fff 0x0000000000c20000 0x4
5: 0x00000083ffe43000..0x00000083ffffffff 0x00000000001bd000 0x0
Please explain in the commit message what the problem being solved is,
and how this solves it. e.g.
In some cases, memblock is queried to determine whether a physical
address corresponds to memory present in a system even if unused by the
OS for the linear mapping, highmem, etc. For example, the ACPI core
needs this information to determine which attributes to use when mapping
ACPI regions. Use of incorrect memory types can result in faults, data
corruption, or other issues.
Removing memory with memblock_enforce_memory_limit throws away this
information, and so a kernel booted with mem= may suffer from the issues
described above. To avoid this, we can mark regions as nomap rather than
removing them, which preserves the information we need while preventing
other use of the regions.
This patch adds new insfrastructure to mark all memblock regions in an
address range as nomap, to cater for this. Similarly we add
infrastructure to clear the flag for an address range, which makes
handling some overlap cases simpler.
Other than that, the patch itself looks fine to me.
The above commit message is very clear to describe why we need to add
those new infrastructures in this patch. Thanks Mark, you're saving
my time :) I will apply it in the next version.
Thanks,
Dennis
Thanks,
Mark.
quoted
Signed-off-by: Dennis Chen <redacted>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Steve Capper <redacted>
Cc: Ard Biesheuvel <redacted>
Cc: Will Deacon <redacted>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Rafael J. Wysocki <redacted>
Cc: Matt Fleming <redacted>
Cc: linux-mm at kvack.org
Cc: linux-acpi at vger.kernel.org
Cc: linux-efi at vger.kernel.org
---
include/linux/memblock.h | 2 ++
mm/memblock.c | 50 ++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 44 insertions(+), 8 deletions(-)
@@ -814,6 +814,18 @@ int __init_memblock memblock_mark_nomap(phys_addr_t base, phys_addr_t size)}/**+*memblock_clear_nomap-ClearflagMEMBLOCK_NOMAPforaspecifiedregion.+*@base:thebasephysaddroftheregion+*@size:thesizeoftheregion+*+*Return0onsuccess,-errnoonfailure.+*/+int__init_memblockmemblock_clear_nomap(phys_addr_tbase,phys_addr_tsize)+{+returnmemblock_setclr_flag(base,size,0,MEMBLOCK_NOMAP);+}++/***__next_reserved_mem_region-nextfunctionforfor_each_reserved_region()*@idx:pointertou64loopvariable*@out_start:ptrtophys_addr_tforstartaddressoftheregion,canbe%NULL
@@ -1465,14 +1477,11 @@ phys_addr_t __init_memblock memblock_end_of_DRAM(void)return(memblock.memory.regions[idx].base+memblock.memory.regions[idx].size);}-void__initmemblock_enforce_memory_limit(phys_addr_tlimit)+staticphys_addr_t__find_max_addr(phys_addr_tlimit){phys_addr_tmax_addr=(phys_addr_t)ULLONG_MAX;structmemblock_region*r;-if(!limit)-return;-/* find out max address */for_each_memblock(memory,r){if(limit<=r->size){
@@ -1482,6 +1491,18 @@ void __init memblock_enforce_memory_limit(phys_addr_t limit)limit-=r->size;}+returnmax_addr;+}++void__initmemblock_enforce_memory_limit(phys_addr_tlimit)+{+phys_addr_tmax_addr;++if(!limit)+return;++max_addr=__find_max_addr(limit);+/* truncate both memory and reserved regions */memblock_remove_range(&memblock.memory,max_addr,(phys_addr_t)ULLONG_MAX);
WARNING: vmlinux.o(.text.unlikely+0x330c): Section mismatch in reference from the function __find_max_addr() to the variable .meminit.data:memblock
The function __find_max_addr() references
the variable __meminitdata memblock.
This is often because __find_max_addr lacks a __meminitdata
annotation or the annotation of memblock is wrong.
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/octet-stream
Size: 21054 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160623/f10dbdcd/attachment-0001.obj>