qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Helge Deller <deller@kernel.org>,
	Laurent Vivier <laurent@vivier.eu>,
	Michael Tokarev <mjt@tls.msk.ru>,
	Richard Henderson <richard.henderson@linaro.org>,
	qemu-devel@nongnu.org, qemu-trivial@nongnu.org,
	Akihiko Odaki <akihiko.odaki@daynix.com>
Subject: Re: [PATCH] tcg/tci: Fix TCI on hppa host and update TCI test matrix
Date: Sun, 7 Jan 2024 11:54:12 +0100	[thread overview]
Message-ID: <4ca9e87d-1123-408c-ad49-71c01e332828@linaro.org> (raw)
In-Reply-To: <ZZpQZ77s2t81mXIT@p100>

Cc'ing Akihiko for commit a1eaa6281f.

On 7/1/24 08:19, Helge Deller wrote:
> Update the TCI interpreter test matrix for big-endian hosts with
> big- (hppa, hppa64) and little-endian (x86,x96-64) targets.
> I used native ppc64 and hppa hosts for those tests.
> 
> Starting TCI on a hppa host crashed immediately, because hppa is
> the only archive left where the stack grows upwards.
> Write-protecting the stack guard page at the top of the stack
> fixes the crash.
> 

Fixes: a1eaa6281f ("util: Delete checks for old host definitions")

> Signed-off-by: Helge Deller <deller@gmx.de>
> 
> diff --git a/tcg/tci/README b/tcg/tci/README
> index 4a8b5b5401..0c1e50779e 100644
> --- a/tcg/tci/README
> +++ b/tcg/tci/README
> @@ -72,16 +72,16 @@ host and target with same or different endianness.
>               | host (le)                     host (be)
>               | 32             64             32             64
>   ------------+------------------------------------------------------------
> -target (le) | s0, u0         s1, u1         s?, u?         s?, u?
> +target (le) | s0, u0         s1, u1         s2, u?         s2, u?
>   32 bit      |
>               |
> -target (le) | sc, uc         s1, u1         s?, u?         s?, u?
> +target (le) | sc, uc         s1, u1         s2, u?         s2, u?
>   64 bit      |
>               |
> -target (be) | sc, u0         sc, uc         s?, u?         s?, u?
> +target (be) | sc, u0         sc, uc         s2, u?         s2, u?
>   32 bit      |
>               |
> -target (be) | sc, uc         sc, uc         s?, u?         s?, u?
> +target (be) | sc, uc         sc, uc         s?, u?         s2, u?
>   64 bit      |
>               |
>   
> @@ -110,6 +115,10 @@ u1 = linux-user-test works
>     A cross compiled QEMU for ppc host works at least partially:
>     i386-linux-user/qemu-i386 can run a simple hello-world program
>     (tested in a ppc emulation).
> +  The big-endian tests were run on native hppa (big-endian, 32-bit) and
> +  ppc64 (big-endian, 64-bit) machines. Tested target machines were
> +  x86 and x86-64 (little-endian, debian install ISO) and 32- and 64-bit
> +  big-endian hppa (NetBSD and Debian install ISOs).
>   
>   * Some TCG opcodes are either missing in the code generator and/or
>     in the interpreter. These opcodes raise a runtime exception, so it is
> diff --git a/util/oslib-posix.c b/util/oslib-posix.c
> index e86fd64e09..e378b71641 100644
> --- a/util/oslib-posix.c
> +++ b/util/oslib-posix.c
> @@ -585,11 +585,8 @@ char *qemu_get_pid_name(pid_t pid)
>   
>   void *qemu_alloc_stack(size_t *sz)
>   {
> -    void *ptr;
> +    void *ptr, *ptr2;
>       int flags;
> -#ifdef CONFIG_DEBUG_STACK_USAGE
> -    void *ptr2;
> -#endif
>       size_t pagesz = qemu_real_host_page_size();
>   #ifdef _SC_THREAD_STACK_MIN
>       /* avoid stacks smaller than _SC_THREAD_STACK_MIN */
> @@ -619,7 +616,12 @@ void *qemu_alloc_stack(size_t *sz)
>       }
>   
>       /* Stack grows down -- guard page at the bottom. */
> -    if (mprotect(ptr, pagesz, PROT_NONE) != 0) {
> +    ptr2 = ptr;
> +#if defined(__hppa__)

Is it worth make this generic by declaring some TARGET_STACK_GROWS_UP
definition in target/foo/cpu-param.h?

> +    /* but on hppa the stack grows up, so guard the top page instead */
> +    ptr2 = ptr + *sz - pagesz;
> +#endif
> +    if (mprotect(ptr2, pagesz, PROT_NONE) != 0) {
>           perror("failed to set up stack guard page");
>           abort();
>       }
> 



  reply	other threads:[~2024-01-07 10:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-07  7:19 [PATCH] tcg/tci: Fix TCI on hppa host and update TCI test matrix Helge Deller
2024-01-07 10:54 ` Philippe Mathieu-Daudé [this message]
2024-01-08  7:24   ` Akihiko Odaki
2024-01-07 15:22 ` Peter Maydell
2024-01-07 21:40   ` Helge Deller
2024-01-08 11:50     ` Philippe Mathieu-Daudé

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=4ca9e87d-1123-408c-ad49-71c01e332828@linaro.org \
    --to=philmd@linaro.org \
    --cc=akihiko.odaki@daynix.com \
    --cc=deller@kernel.org \
    --cc=laurent@vivier.eu \
    --cc=mjt@tls.msk.ru \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=richard.henderson@linaro.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).