diff mbox series

[v3,25/33] tests/tcg: Extend file in linux-madvise.c

Message ID 20240102015808.132373-26-richard.henderson@linaro.org
State Superseded
Headers show
Series linux-user: Improve host and guest page size handling | expand

Commit Message

Richard Henderson Jan. 2, 2024, 1:58 a.m. UTC
When guest page size > host page size, this test can fail
due to the SIGBUS protection hack.  Avoid this by making
sure that the file size is at least one guest page.

Visible with alpha guest on x86_64 host.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tests/tcg/multiarch/linux/linux-madvise.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Ilya Leoshkevich Jan. 30, 2024, 1:13 p.m. UTC | #1
On Tue, Jan 02, 2024 at 12:58:00PM +1100, Richard Henderson wrote:
> When guest page size > host page size, this test can fail
> due to the SIGBUS protection hack.  Avoid this by making
> sure that the file size is at least one guest page.

Maybe also mention PAGE_PASSTHROUGH?

> Visible with alpha guest on x86_64 host.

I had to apply (very hacky):

--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -803,7 +803,7 @@ int main(int argc, char **argv, char **envp)
      * The most efficient setting is to match the host.
      */
     host_page_size = qemu_real_host_page_size();
-    set_preferred_target_page_bits(ctz32(host_page_size));
+    set_preferred_target_page_bits(ctz32(host_page_size) + 1);
     finalize_target_page_bits();

in order to see this. Is there a way to set the guest page size from
the command line?

> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  tests/tcg/multiarch/linux/linux-madvise.c | 2 ++
>  1 file changed, 2 insertions(+)

Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
Richard Henderson Feb. 3, 2024, 10:58 p.m. UTC | #2
On 1/30/24 23:13, Ilya Leoshkevich wrote:
> Is there a way to set the guest page size from
> the command line?

No.  Before this patch set, guest page size was a compile-time constant.  Afterward, it 
would be possible for any TARGET_PAGE_BITS_VARY target.

I refrained from adding such a command-line switch because, other than selecting the host 
page size, it only leads to breakage.  That doesn't seem helpful, even for developers.


r~
diff mbox series

Patch

diff --git a/tests/tcg/multiarch/linux/linux-madvise.c b/tests/tcg/multiarch/linux/linux-madvise.c
index 29d0997e68..539fb3b772 100644
--- a/tests/tcg/multiarch/linux/linux-madvise.c
+++ b/tests/tcg/multiarch/linux/linux-madvise.c
@@ -42,6 +42,8 @@  static void test_file(void)
     assert(ret == 0);
     written = write(fd, &c, sizeof(c));
     assert(written == sizeof(c));
+    ret = ftruncate(fd, pagesize);
+    assert(ret == 0);
     page = mmap(NULL, pagesize, PROT_READ, MAP_PRIVATE, fd, 0);
     assert(page != MAP_FAILED);