mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: Huacai Chen <chenhuacai@loongson.cn>,
	Arnd Bergmann <arnd@arndb.de>,
	 Huacai Chen <chenhuacai@kernel.org>
Cc: loongarch@lists.linux.dev, linux-arch@vger.kernel.org,
	Xuefeng Li <lixuefeng@loongson.cn>, Guo Ren <guoren@kernel.org>,
	Xuerui Wang <kernel@xen0n.name>,
	Jiaxun Yang <jiaxun.yang@flygoat.com>,
	 linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn
Subject: Re: [PATCH] LoongArch: Set correct size for VDSO code mapping
Date: Sun, 29 Sep 2024 16:19:03 +0800	[thread overview]
Message-ID: <8fb18e4166be8ef59ed0ccb7fa2f79844220aec2.camel@xry111.site> (raw)
In-Reply-To: <20240929074944.3540514-1-chenhuacai@loongson.cn>

On Sun, 2024-09-29 at 15:49 +0800, Huacai Chen wrote:
> The current size of VDSO code mapping is hardcoded to PAGE_SIZE. This
> cannot work for 4KB page size after commit 18efd0b10e0fd77 ("LoongArch:
> vDSO: Wire up getrandom() vDSO implementation") because the code size
> increases to 8KB. Thus set the code mapping size to its real size, i.e.
> PAGE_ALIGN(vdso_end - vdso_start).

I get:

$ size vdso.so
   text	   data	    bss	    dec	   
hex	filename
   3716	    328	      0	   4044	   
fcc	vdso.so

So it "just" fits in 4 KiB, and of course it may exceed 4 KiB with a
different compiler or some kernel configuration affecting code
generation like CONFIG_INIT_STACK_ALL_ZERO or
CONFIG_ZERO_CALL_USED_REGS).

I remember I've checked `size vdso.so` before but I cannot remember why
I didn't realize a problem here.  Sorry for the stupidity.

Reviewed-by: Xi Ruoyao <xry111@xry111.site>

> 
> Fixes: 18efd0b10e0fd77 ("LoongArch: vDSO: Wire up getrandom() vDSO implementation")
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> ---
>  arch/loongarch/kernel/vdso.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/arch/loongarch/kernel/vdso.c b/arch/loongarch/kernel/vdso.c
> index f6fcc52aefae..7e0cc7f5e1ed 100644
> --- a/arch/loongarch/kernel/vdso.c
> +++ b/arch/loongarch/kernel/vdso.c
> @@ -85,7 +85,6 @@ static vm_fault_t vvar_fault(const struct vm_special_mapping *sm,
>  
>  struct loongarch_vdso_info vdso_info = {
>  	.vdso = vdso_start,
> -	.size = PAGE_SIZE,
>  	.code_mapping = {
>  		.name = "[vdso]",
>  		.pages = vdso_pages,
> @@ -103,7 +102,7 @@ static int __init init_vdso(void)
>  	unsigned long i, cpu, pfn;
>  
>  	BUG_ON(!PAGE_ALIGNED(vdso_info.vdso));
> -	BUG_ON(!PAGE_ALIGNED(vdso_info.size));
> +	vdso_info.size = PAGE_ALIGN(vdso_end - vdso_start);
>  
>  	for_each_possible_cpu(cpu)
>  		vdso_pdata[cpu].node = cpu_to_node(cpu);

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

      reply	other threads:[~2024-09-29  8:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-29  7:49 Huacai Chen
2024-09-29  8:19 ` Xi Ruoyao [this message]

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=8fb18e4166be8ef59ed0ccb7fa2f79844220aec2.camel@xry111.site \
    --to=xry111@xry111.site \
    --cc=arnd@arndb.de \
    --cc=chenhuacai@kernel.org \
    --cc=chenhuacai@loongson.cn \
    --cc=guoren@kernel.org \
    --cc=jiaxun.yang@flygoat.com \
    --cc=kernel@xen0n.name \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lixuefeng@loongson.cn \
    --cc=loongarch@lists.linux.dev \
    --cc=loongson-kernel@lists.loongnix.cn \
    /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

all inboxes | Powered by JetHome®