All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com,
	steve.capper@arm.com, will@kernel.org
Subject: Re: [PATCH] arm64: mm: fix VA-range sanity check
Date: Thu, 15 Jun 2023 12:23:07 +0100	[thread overview]
Message-ID: <ZIr0m4MWYV3iy2ik@shell.armlinux.org.uk> (raw)
In-Reply-To: <20230615102628.1052103-1-mark.rutland@arm.com>

On Thu, Jun 15, 2023 at 11:26:28AM +0100, Mark Rutland wrote:
> Both create_mapping_noalloc() and update_mapping_prot() sanity-check the
> their 'virt' parameter, but the check itself doesn't make much sense.
> The condition used today appears to be a historical accident.
> 
> The sanity-check condition:
> 
> 	if ((virt >= PAGE_END) && (virt < VMALLOC_START)) {
> 		[ ... warning here ... ]
> 		return;
> 	}
> 
> ... can only be true for the KASAN shadow region or the module region,
> and there's no reason to exclude these specifically for creating and
> updateing mappings.
> 
> When arm64 support was first upstreamed in commit:
> 
>   c1cc1552616d0f35 ("arm64: MMU initialisation")
> 
> ... the condition was:
> 
> 	if (virt < VMALLOC_START) {
> 		[ ... warning here ... ]
> 		return;
> 	}
> 
> At the time, VMALLOC_START was the lowest kernel address, and this was
> checking whether 'virt' would be translated via TTBR1.
> 
> Subsequently in commit:
> 
>   14c127c957c1c607 ("arm64: mm: Flip kernel VA space")
> 
> ... the condition was changed to:
> 
> 	if ((virt >= VA_START) && (virt < VMALLOC_START)) {
> 		[ ... warning here ... ]
> 		return;
> 	}
> 
> This appear to have been a thinko. The commit moved the linear map to
> the bottom of the kernel address space, with VMALLOC_START being at the
> halfway point. The old condition would warn for changes to the linear
> map below this, and at the time VA_START was the end of the linear map.
> 
> Subsequently we cleaned up the naming of VA_START in commit:
> 
>   77ad4ce69321abbe ("arm64: memory: rename VA_START to PAGE_END")
> 
> ... keeping the erroneous condition as:
> 
> 	if ((virt >= PAGE_END) && (virt < VMALLOC_START)) {
> 		[ ... warning here ... ]
> 		return;
> 	}
> 
> Correct the condition to check against the start of the TTBR1 address
> space, which is currently PAGE_OFFSET. This simplifies the logic, and
> more clearly matches the "outside kernel range" message in the warning.
> 
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: Steve Capper <steve.capper@arm.com>
> Cc: Will Deacon <will@kernel.org>

This simplifies the second of the kernel text replication patches!

Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Thanks!

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-06-15 11:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-15 10:26 [PATCH] arm64: mm: fix VA-range sanity check Mark Rutland
2023-06-15 11:23 ` Russell King (Oracle) [this message]
2023-06-15 17:11 ` Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZIr0m4MWYV3iy2ik@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=steve.capper@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.