[PATCH v3 0/6] arm64: Clean up and simplify PA space size handling

Ard Biesheuvel posted 6 patches 1 year ago
arch/arm64/Kconfig                     | 37 ++------------------
arch/arm64/include/asm/assembler.h     | 14 +++-----
arch/arm64/include/asm/cpufeature.h    |  3 +-
arch/arm64/include/asm/kvm_pgtable.h   |  3 +-
arch/arm64/include/asm/pgtable-hwdef.h | 12 +------
arch/arm64/include/asm/pgtable-prot.h  |  7 ++++
arch/arm64/include/asm/pgtable.h       | 11 +-----
arch/arm64/include/asm/sparsemem.h     |  5 ++-
arch/arm64/include/asm/sysreg.h        |  6 ----
arch/arm64/kernel/cpufeature.c         |  2 +-
arch/arm64/kernel/pi/idreg-override.c  |  9 +++++
arch/arm64/kernel/pi/map_kernel.c      |  6 ++++
arch/arm64/kvm/arm.c                   |  8 ++---
arch/arm64/kvm/hyp/pgtable.c           | 33 ++++++-----------
arch/arm64/mm/init.c                   |  7 +++-
arch/arm64/mm/pgd.c                    |  9 ++---
arch/arm64/mm/proc.S                   |  2 --
scripts/gdb/linux/constants.py.in      |  1 -
tools/arch/arm64/include/asm/sysreg.h  |  6 ----
19 files changed, 64 insertions(+), 117 deletions(-)
[PATCH v3 0/6] arm64: Clean up and simplify PA space size handling
Posted by Ard Biesheuvel 1 year ago
From: Ard Biesheuvel <ardb@kernel.org>

This series addresses a number of buglets related to how we handle the
size of the physical address space when building LPA2 capable kernels:

- reject 52-bit physical addressess in the mapping routines when LPA2 is
  configured but not available at runtime
- ensure that TCR.IPS is not set to 52-bits if LPA2 is not supported
- ensure that TCR_EL2.PS and DS match the host, regardless of whether
  LPA2 is available at stage 2
- don't rely on kvm_get_parange() and invalid physical addresses as
  control flags in the pKVM page donation APIs

Finally, the configurable 48-bit physical address space limit is dropped
entirely, as it doesn't buy us a lot now that all the PARange and {I}PS
handling is done at runtime.

Changes since v2:
- add a definition of MAX_POSSIBLE_PHYSMEM_BITS to fix a build error in
  zsmalloc (#1)
- rename 'owner_update' to 'annotation' (#4)

Changes since v1:
- rebase onto v6.13-rc1
- add Anshuman's ack to patch #1
- incorporate Anshuman's feedback on patches #1 and #2
- tweak owner_update logic in patch #4

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Quentin Perret <qperret@google.com>

Ard Biesheuvel (6):
  arm64/mm: Reduce PA space to 48 bits when LPA2 is not enabled
  arm64/mm: Override PARange for !LPA2 and use it consistently
  arm64/kvm: Configure HYP TCR.PS/DS based on host stage1
  arm64/kvm: Avoid invalid physical addresses to signal owner updates
  arm64: Kconfig: force ARM64_PAN=y when enabling TTBR0 sw PAN
  arm64/mm: Drop configurable 48-bit physical address space limit

 arch/arm64/Kconfig                     | 37 ++------------------
 arch/arm64/include/asm/assembler.h     | 14 +++-----
 arch/arm64/include/asm/cpufeature.h    |  3 +-
 arch/arm64/include/asm/kvm_pgtable.h   |  3 +-
 arch/arm64/include/asm/pgtable-hwdef.h | 12 +------
 arch/arm64/include/asm/pgtable-prot.h  |  7 ++++
 arch/arm64/include/asm/pgtable.h       | 11 +-----
 arch/arm64/include/asm/sparsemem.h     |  5 ++-
 arch/arm64/include/asm/sysreg.h        |  6 ----
 arch/arm64/kernel/cpufeature.c         |  2 +-
 arch/arm64/kernel/pi/idreg-override.c  |  9 +++++
 arch/arm64/kernel/pi/map_kernel.c      |  6 ++++
 arch/arm64/kvm/arm.c                   |  8 ++---
 arch/arm64/kvm/hyp/pgtable.c           | 33 ++++++-----------
 arch/arm64/mm/init.c                   |  7 +++-
 arch/arm64/mm/pgd.c                    |  9 ++---
 arch/arm64/mm/proc.S                   |  2 --
 scripts/gdb/linux/constants.py.in      |  1 -
 tools/arch/arm64/include/asm/sysreg.h  |  6 ----
 19 files changed, 64 insertions(+), 117 deletions(-)

-- 
2.47.1.613.gc27f4b7a9f-goog
Re: [PATCH v3 0/6] arm64: Clean up and simplify PA space size handling
Posted by Will Deacon 11 months, 4 weeks ago
On Thu, 12 Dec 2024 09:18:42 +0100, Ard Biesheuvel wrote:
> This series addresses a number of buglets related to how we handle the
> size of the physical address space when building LPA2 capable kernels:
> 
> - reject 52-bit physical addressess in the mapping routines when LPA2 is
>   configured but not available at runtime
> - ensure that TCR.IPS is not set to 52-bits if LPA2 is not supported
> - ensure that TCR_EL2.PS and DS match the host, regardless of whether
>   LPA2 is available at stage 2
> - don't rely on kvm_get_parange() and invalid physical addresses as
>   control flags in the pKVM page donation APIs
> 
> [...]

Applied to arm64 (for-next/mm), thanks!

[1/6] arm64/mm: Reduce PA space to 48 bits when LPA2 is not enabled
      https://git.kernel.org/arm64/c/bf74bb73cd87
[2/6] arm64/mm: Override PARange for !LPA2 and use it consistently
      https://git.kernel.org/arm64/c/62cffa496aac
[3/6] arm64/kvm: Configure HYP TCR.PS/DS based on host stage1
      https://git.kernel.org/arm64/c/f0da16992aef
[4/6] arm64/kvm: Avoid invalid physical addresses to signal owner updates
      https://git.kernel.org/arm64/c/9d86c3c97434
[5/6] arm64: Kconfig: force ARM64_PAN=y when enabling TTBR0 sw PAN
      https://git.kernel.org/arm64/c/92b6919d7fb2
[6/6] arm64/mm: Drop configurable 48-bit physical address space limit
      https://git.kernel.org/arm64/c/32d053d6f5e9

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
Re: [PATCH v3 0/6] arm64: Clean up and simplify PA space size handling
Posted by Marc Zyngier 11 months, 4 weeks ago
On Thu, 12 Dec 2024 08:18:42 +0000,
Ard Biesheuvel <ardb+git@google.com> wrote:
> 
> From: Ard Biesheuvel <ardb@kernel.org>
> 
> This series addresses a number of buglets related to how we handle the
> size of the physical address space when building LPA2 capable kernels:
> 
> - reject 52-bit physical addressess in the mapping routines when LPA2 is
>   configured but not available at runtime
> - ensure that TCR.IPS is not set to 52-bits if LPA2 is not supported
> - ensure that TCR_EL2.PS and DS match the host, regardless of whether
>   LPA2 is available at stage 2
> - don't rely on kvm_get_parange() and invalid physical addresses as
>   control flags in the pKVM page donation APIs
> 
> Finally, the configurable 48-bit physical address space limit is dropped
> entirely, as it doesn't buy us a lot now that all the PARange and {I}PS
> handling is done at runtime.

Acked-by: Marc Zyngier <maz@kernel.org>

	M.

-- 
Without deviation from the norm, progress is not possible.