After choosing memstart_addr to be the highest multiple of
ARM64_MEMSTART_ALIGN less than or equal to the first usable physical memory
address, we clip the memblocks to the maximum size of the linear region.
Since the kernel may be high up in memory, we take care not to clip the
kernel itself, which means we have to clip some memory from the bottom if
this occurs, to ensure that the distance between the first and the last
usable physical memory address can be covered by the linear region.
However, we fail to update memstart_addr if this clipping from the bottom
occurs, which means that we may still end up with virtual addresses that
wrap into the userland range. So increment memstart_addr as appropriate to
prevent this from happening.
Signed-off-by: Ard Biesheuvel <redacted>
---
arch/arm64/mm/init.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
This reverts commit 36e5cd6b897e, which was needed in v4.5 and before to
ensure the correct alignment of the base of the vmemmap region. However,
since commit a7f8de168ace ("arm64: allow kernel Image to be loaded anywhere
in physical memory"), the alignment of memstart_addr itself can be freely
chosen, which means we can choose it such that additional rounding in the
definition of vmemmap is no longer necessary.
So redefine ARM64_MEMSTART_ALIGN in terms of the minimal alignment required
by sparsemem, and drop the redundant rounding in the definition of vmemmap.
Note that the net result of this change is that we align memstart_addr to
1 GB in all cases, since sparsemem is mandatory on arm64.
Signed-off-by: Ard Biesheuvel <redacted>
---
arch/arm64/include/asm/kernel-pgtable.h | 17 +++++++++++++++--
arch/arm64/include/asm/pgtable.h | 5 ++---
2 files changed, 17 insertions(+), 5 deletions(-)
On 21 March 2016 at 18:38, Ard Biesheuvel [off-list ref] wrote:
This reverts commit 36e5cd6b897e, which was needed in v4.5 and before to
ensure the correct alignment of the base of the vmemmap region. However,
since commit a7f8de168ace ("arm64: allow kernel Image to be loaded anywhere
in physical memory"), the alignment of memstart_addr itself can be freely
chosen, which means we can choose it such that additional rounding in the
definition of vmemmap is no longer necessary.
So redefine ARM64_MEMSTART_ALIGN in terms of the minimal alignment required
by sparsemem, and drop the redundant rounding in the definition of vmemmap.
Note that the net result of this change is that we align memstart_addr to
1 GB in all cases, since sparsemem is mandatory on arm64.
This is not actually true, since the 1 GB alignment on 64k pages is
only used for sparsemem-vmemmap. Also, this patch is no longer a
straight revert of the late fix we sent for v4.5, so perhaps it is
more appropriate to split off the updated definition of
ARM64_MEMSTART_ALIGN, so that we can put the straight revert on top of
that?