From: Zenghui Yu <zenghui.yu@linux.dev>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: Zenghui Yu <yuzenghui@huawei.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, catalin.marinas@arm.com,
will@kernel.org, wanghaibin.wang@huawei.com
Subject: Re: [PATCH] arm64: Clear the initial ID map correctly before remapping
Date: Sun, 23 Jun 2024 22:20:29 +0800 [thread overview]
Message-ID: <19f05d6a-7b96-472a-919d-56292596e8bb@linux.dev> (raw)
In-Reply-To: <CAMj1kXEH0ohn57DUrCu6S-AJW=B9CyrpMwyabpjBpD9tD4VV=A@mail.gmail.com>
On 2024/6/21 17:52, Ard Biesheuvel wrote:
> On Fri, 21 Jun 2024 at 11:28, Zenghui Yu <yuzenghui@huawei.com> wrote:
> >
> > In the attempt to clear and recreate the initial ID map for LPA2, we
> > wrongly use 'start - end' as the map size and make the memset() almost a
> > nop.
> >
> > Fix it by passing the correct map size.
> >
> > Fixes: 9684ec186f8f ("arm64: Enable LPA2 at boot if supported by the system")
> > Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
> > ---
> >
> > Found by code inspection (don't have the appropriate HW to test it).
> >
>
> Good catch!
>
> Even though memset() takes an unsigned size_t, the zeroing path in
> arm64's memset.S does a signed compare on the provided size, and will
> zero at most 63 bytes if the size has the sign bit set. So in the end,
> it does not clear anything.
Yup! It took me a while to figure out why memset() with a VERY large
size doesn't corrupt the memory. ;-)
> Note that in this particular case, that
> doesn't actually matter - the memory is reused immediately to create
> another copy of the ID map, and any unused regions containing garbage
> will just be ignored.
Agreed. I can fold it into the commit message if Will/Catalin ask for a
respin. And it looks like an alternate "fix" would be just removing the
memset().
> Nonetheless,
>
> Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Thanks!
Zenghui
next prev parent reply other threads:[~2024-06-23 14:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-21 9:28 [PATCH] arm64: Clear the initial ID map correctly before remapping Zenghui Yu
2024-06-21 9:52 ` Ard Biesheuvel
2024-06-23 14:20 ` Zenghui Yu [this message]
2024-06-24 13:11 ` Will Deacon
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=19f05d6a-7b96-472a-919d-56292596e8bb@linux.dev \
--to=zenghui.yu@linux.dev \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wanghaibin.wang@huawei.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).