linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Yangyu Chen <cyy@cyyself.name>
To: charlie@rivosinc.com
Cc: alexghiti@rivosinc.com, anup@brainfault.org,
	aou@eecs.berkeley.edu, conor@kernel.org, jrtc27@jrtc27.com,
	konstantin@linuxfoundation.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-mm@kvack.org, linux-riscv@lists.infradead.org,
	mick@ics.forth.gr, palmer@rivosinc.com, paul.walmsley@sifive.com,
	rdunlap@infradead.org
Subject: Re: [PATCH v10 0/4] RISC-V: mm: Make SV48 the default address space
Date: Sun, 14 Jan 2024 01:26:57 +0800	[thread overview]
Message-ID: <tencent_F9568C6D8872E30EDFAF20ADF686A31D6E06@qq.com> (raw)
In-Reply-To: <20230809232218.849726-1-charlie@rivosinc.com>

Hi, Charlie

Although this patchset has been merged I still have some questions about
this patchset. Because it breaks regular mmap if address >= 38 bits on
sv48 / sv57 capable systems like qemu. For example, If a userspace program
wants to mmap an anonymous page to addr=(1<<45) on an sv48 capable system,
it will fail and kernel will mmaped to another sv39 address since it does
not meet the requirement to use sv48 as you wrote:

>	else if ((((_addr) >= VA_USER_SV48)) && (VA_BITS >= VA_BITS_SV48)) \
>		mmap_end = VA_USER_SV48;			\
>	else							\
>		mmap_end = VA_USER_SV39;			\

Then, How can a userspace program create a mmap with a hint if the address
>= (1<<38) after your patch without MAP_FIXED? The only way to do this is
to pass a hint >= (1<<47) on mmap syscall then kernel will return a random
address in sv48 address space but the hint address gets lost. I think this
violate the principle of mmap syscall as kernel should take the hint and
attempt to create the mapping there.

I don't think patching in this way is right. However, if we only revert
this patch, some programs relying on mmap to return address with effective
bits <= 48 will still be an issue and it might expand to other ISAs if
they implement larger virtual address space like RISC-V sv57. A better way
to solve this might be adding a MAP_48BIT flag to mmap like MAP_32BIT has
been introduced for decades.

Thanks,
Yangyu Chen


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

  parent reply	other threads:[~2024-01-13 17:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-09 23:22 [PATCH v10 0/4] RISC-V: mm: Make SV48 the default address space Charlie Jenkins
2023-08-09 23:22 ` [PATCH v10 1/4] RISC-V: mm: Restrict address space for sv39,sv48,sv57 Charlie Jenkins
2023-08-09 23:22 ` [PATCH v10 2/4] RISC-V: mm: Add tests for RISC-V mm Charlie Jenkins
2023-08-09 23:22 ` [PATCH v10 3/4] RISC-V: mm: Update pgtable comment documentation Charlie Jenkins
2023-08-09 23:22 ` [PATCH v10 4/4] RISC-V: mm: Document mmap changes Charlie Jenkins
2023-08-30 13:20 ` [PATCH v10 0/4] RISC-V: mm: Make SV48 the default address space patchwork-bot+linux-riscv
2024-01-13 17:26 ` Yangyu Chen [this message]
2024-01-20  1:34   ` Charlie Jenkins
2024-01-20  6:13     ` Yangyu Chen
2024-01-20  6:49       ` Charlie Jenkins
2024-01-20  7:09         ` Yangyu Chen
2024-01-22 19:56           ` Charlie Jenkins

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=tencent_F9568C6D8872E30EDFAF20ADF686A31D6E06@qq.com \
    --to=cyy@cyyself.name \
    --cc=alexghiti@rivosinc.com \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=charlie@rivosinc.com \
    --cc=conor@kernel.org \
    --cc=jrtc27@jrtc27.com \
    --cc=konstantin@linuxfoundation.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=mick@ics.forth.gr \
    --cc=palmer@rivosinc.com \
    --cc=paul.walmsley@sifive.com \
    --cc=rdunlap@infradead.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 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).