[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zb8+8qmn5SV4LKFd@MiWiFi-R3L-srv>
Date: Sun, 4 Feb 2024 15:38:26 +0800
From: Baoquan He <bhe@...hat.com>
To: "yang.zhang" <gaoshanliukou@....com>
Cc: ebiederm@...ssion.com, kexec@...ts.infradead.org,
linux-kernel@...r.kernel.org,
"yang.zhang" <yang.zhang@...intek.com>
Subject: Re: [PATCH] kexec: should use uchunk for user buffer increasing
On 01/30/24 at 06:18pm, yang.zhang wrote:
> From: "yang.zhang" <yang.zhang@...intek.com>
>
> Because of alignment requirement in kexec-tools, there is
> no problem for user buffer increasing when loading segments.
> But when coping, the step is uchunk, so we should use uchunk
> not mchunk.
In theory, ubytes is <= mbytes. So uchunk is always <= mchunk. If ubytes
is exhausted, while there's still remaining mbytes, then uchunk is 0,
there's still mchunk stepping forward. If I understand it correctly,
this is a good catch. Not sure if Eric has comment on this to confirm.
static int kimage_load_normal_segment(struct kimage *image,
struct kexec_segment *segment)
{
.....
ptr += maddr & ~PAGE_MASK;
mchunk = min_t(size_t, mbytes,
PAGE_SIZE - (maddr & ~PAGE_MASK));
uchunk = min(ubytes, mchunk);
.....}
>
> Signed-off-by: yang.zhang <yang.zhang@...intek.com>
> ---
> kernel/kexec_core.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
> index d08fc7b5db97..2b8354313c85 100644
> --- a/kernel/kexec_core.c
> +++ b/kernel/kexec_core.c
> @@ -813,9 +813,9 @@ static int kimage_load_normal_segment(struct kimage *image,
> ubytes -= uchunk;
> maddr += mchunk;
> if (image->file_mode)
> - kbuf += mchunk;
> + kbuf += uchunk;
> else
> - buf += mchunk;
> + buf += uchunk;
> mbytes -= mchunk;
>
> cond_resched();
> @@ -881,9 +881,9 @@ static int kimage_load_crash_segment(struct kimage *image,
> ubytes -= uchunk;
> maddr += mchunk;
> if (image->file_mode)
> - kbuf += mchunk;
> + kbuf += uchunk;
> else
> - buf += mchunk;
> + buf += uchunk;
> mbytes -= mchunk;
>
> cond_resched();
> --
> 2.34.1
>
>
> _______________________________________________
> kexec mailing list
> kexec@...ts.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
>
Powered by blists - more mailing lists