All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Jonathan Albrecht <jonathan.albrecht@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org
Cc: ruixin.bao@ibm.com, qemu-s390x@nongnu.org,
	Laurent Vivier <laurent@vivier.eu>,
	jonathan.albrecht@ibm.com
Subject: Re: [PATCH RFC 1/1] linux-user/s390x: save/restore condition code state during signal handling
Date: Fri, 11 Jun 2021 08:18:15 -0700	[thread overview]
Message-ID: <7d3fcf31-bcf6-193d-4700-5cc3cf0fe90f@linaro.org> (raw)
In-Reply-To: <20210610185823.14817-2-jonathan.albrecht@linux.vnet.ibm.com>

On 6/10/21 11:58 AM, Jonathan Albrecht wrote:
> @@ -65,6 +65,10 @@ typedef struct {
>       uint8_t callee_used_stack[__SIGNAL_FRAMESIZE];
>       target_sigcontext sc;
>       target_sigregs sregs;
> +    uint32_t scc_op;
> +    uint64_t scc_src;
> +    uint64_t scc_dst;
> +    uint64_t scc_vr;
>       int signo;

Nope.  The layout of the stack frame is fixed by the kernel. Moreover, all of 
these variables are internal to qemu; you should only be exposing architectural 
state.

The bug is in save_sigregs:

>     __put_user(env->psw.mask, &sregs->regs.psw.mask);

This should use get_psw_mask(), currently declared in target/s390x/internal.h 
instead of cpu.h.

and correspondingly, in restore_sigregs:

>     __get_user(env->psw.mask, &sc->regs.psw.mask);
>     __get_user(env->psw.addr, &sc->regs.psw.addr);

this should use load_psw, and in addition it should not be allowing completely 
arbitrary changes to psw.mask.  From the kernel:

>         /* Use regs->psw.mask instead of PSW_USER_BITS to preserve PER bit. */
>         regs->psw.mask = (regs->psw.mask & ~(PSW_MASK_USER | PSW_MASK_RI)) |
>                 (user_sregs.regs.psw.mask & (PSW_MASK_USER | PSW_MASK_RI));
>         /* Check for invalid user address space control. */
>         if ((regs->psw.mask & PSW_MASK_ASC) == PSW_ASC_HOME)
>                 regs->psw.mask = PSW_ASC_PRIMARY |
>                         (regs->psw.mask & ~PSW_MASK_ASC);
>         /* Check for invalid amode */
>         if (regs->psw.mask & PSW_MASK_EA)
>                 regs->psw.mask |= PSW_MASK_BA;



r~


      reply	other threads:[~2021-06-11 15:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-10 18:58 [PATCH RFC 0/1] linux-user/s390x: save/restore condition code state during signal handling Jonathan Albrecht
2021-06-10 18:58 ` [PATCH RFC 1/1] " Jonathan Albrecht
2021-06-11 15:18   ` Richard Henderson [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=7d3fcf31-bcf6-193d-4700-5cc3cf0fe90f@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=jonathan.albrecht@ibm.com \
    --cc=jonathan.albrecht@linux.vnet.ibm.com \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=ruixin.bao@ibm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.