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

Richard Henderson posted 33 patches 10 months, 4 weeks ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Riku Voipio <riku.voipio@iki.fi>, Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>, Stefan Berger <stefanb@linux.vnet.ibm.com>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Yanan Wang <wangyanan55@huawei.com>, Laurent Vivier <laurent@vivier.eu>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, David Hildenbrand <david@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Nicholas Piggin <npiggin@gmail.com>, Daniel Henrique Barboza <danielhb413@gmail.com>, "Cédric Le Goater" <clg@kaod.org>, "Alex Bennée" <alex.bennee@linaro.org>, Yoshinori Sato <ysato@users.sourceforge.jp>
There is a newer version of this series
[PATCH v3 25/33] tests/tcg: Extend file in linux-madvise.c
Posted by Richard Henderson 10 months, 4 weeks ago
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(+)

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);
 
-- 
2.34.1


Re: [PATCH v3 25/33] tests/tcg: Extend file in linux-madvise.c
Posted by Ilya Leoshkevich 10 months ago
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>
Re: [PATCH v3 25/33] tests/tcg: Extend file in linux-madvise.c
Posted by Richard Henderson 9 months, 3 weeks ago
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~