mbox series

[0/2] arm64: Further fixes to the linear address checking

Message ID 20210201190634.22942-1-catalin.marinas@arm.com (mailing list archive)
Headers show
Series arm64: Further fixes to the linear address checking | expand

Message

Catalin Marinas Feb. 1, 2021, 7:06 p.m. UTC
There some history to virt_addr_valid() that goes back to 5.4. It seems
to have been ok prior to this kernel, however, the VA reshuffling in
commit 14c127c957c1 ("arm64: mm: Flip kernel VA space") broke it. The
subsequent fix 68dd8ef32162 ("arm64: memory: Fix virt_addr_valid() using
__is_lm_address()") partially addressed it but it left virt_addr_valid()
returning true for user addresses (or NULL).

The recent commit 519ea6f1c82f ("arm64: Fix kernel address detection of
__is_lm_address()") fixed the NULL checking but broke the
virt_addr_valid() macro for tagged addresses.

The first patch attempts to fix virt_addr_valid() macro for tagged
addresses. The second patch replaces the bitwise operations with a
subtract. The resulting image is slightly smaller.

Catalin Marinas (2):
  arm64: Do not pass tagged addresses to __is_lm_address()
  arm64: Use simpler arithmetics for the linear map macros

 arch/arm64/include/asm/memory.h | 6 +++---
 arch/arm64/mm/physaddr.c        | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

Comments

Linus Torvalds Feb. 1, 2021, 7:33 p.m. UTC | #1
On Mon, Feb 1, 2021 at 11:06 AM Catalin Marinas <catalin.marinas@arm.com> wrote:
>
> The first patch attempts to fix virt_addr_valid() macro for tagged
> addresses. The second patch replaces the bitwise operations with a
> subtract. The resulting image is slightly smaller.

Thanks, this looks very sane to me.

           Linus
Catalin Marinas Feb. 2, 2021, 5:46 p.m. UTC | #2
On Mon, 1 Feb 2021 19:06:32 +0000, Catalin Marinas wrote:
> There some history to virt_addr_valid() that goes back to 5.4. It seems
> to have been ok prior to this kernel, however, the VA reshuffling in
> commit 14c127c957c1 ("arm64: mm: Flip kernel VA space") broke it. The
> subsequent fix 68dd8ef32162 ("arm64: memory: Fix virt_addr_valid() using
> __is_lm_address()") partially addressed it but it left virt_addr_valid()
> returning true for user addresses (or NULL).
> 
> [...]

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

[1/2] arm64: Do not pass tagged addresses to __is_lm_address()
      https://git.kernel.org/arm64/c/91cb2c8b072e
[2/2] arm64: Use simpler arithmetics for the linear map macros
      https://git.kernel.org/arm64/c/22cd5edb2d9c