public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Janosch Frank <frankja@linux.ibm.com>
To: Claudio Imbrenda <imbrenda@linux.ibm.com>, kvm@vger.kernel.org
Cc: david@redhat.com, thuth@redhat.com, cohuck@redhat.com,
	pmorel@linux.ibm.com, borntraeger@de.ibm.com
Subject: Re: [kvm-unit-tests PATCH v2 1/2] s390x: introduce leave_pstate to leave userspace
Date: Tue, 23 Feb 2021 17:19:21 +0100	[thread overview]
Message-ID: <6eb8c9eb-d5af-2790-1855-8b85693ef3e8@linux.ibm.com> (raw)
In-Reply-To: <20210223142429.256420-2-imbrenda@linux.ibm.com>

On 2/23/21 3:24 PM, Claudio Imbrenda wrote:
> In most testcases, we enter problem state (userspace) just to test if a
> privileged instruction causes a fault. In some cases, though, we need
> to test if an instruction works properly in userspace. This means that
> we do not expect a fault, and we need an orderly way to leave problem
> state afterwards.
> 
> This patch introduces a simple system based on the SVC instruction.
> 
> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> Acked-by: David Hildenbrand <david@redhat.com>
> Reviewed-by: Cornelia Huck <cohuck@redhat.com>

Reviewed-by: Janosch Frank <frankja@linux.ibm.com>

> ---
>  lib/s390x/asm/arch_def.h |  7 +++++++
>  lib/s390x/interrupt.c    | 12 ++++++++++--
>  2 files changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h
> index 9c4e330a..4cf8eb11 100644
> --- a/lib/s390x/asm/arch_def.h
> +++ b/lib/s390x/asm/arch_def.h
> @@ -173,6 +173,8 @@ struct cpuid {
>  	uint64_t reserved : 15;
>  };
>  
> +#define SVC_LEAVE_PSTATE 1
> +
>  static inline unsigned short stap(void)
>  {
>  	unsigned short cpu_address;
> @@ -276,6 +278,11 @@ static inline void enter_pstate(void)
>  	load_psw_mask(mask);
>  }
>  
> +static inline void leave_pstate(void)
> +{
> +	asm volatile("	svc %0\n" : : "i" (SVC_LEAVE_PSTATE));
> +}

When we add other svc calls then we should create a svc(int code)
function and call it here.

> +
>  static inline int stsi(void *addr, int fc, int sel1, int sel2)
>  {
>  	register int r0 asm("0") = (fc << 28) | sel1;
> diff --git a/lib/s390x/interrupt.c b/lib/s390x/interrupt.c
> index 1ce36073..d0567845 100644
> --- a/lib/s390x/interrupt.c
> +++ b/lib/s390x/interrupt.c
> @@ -188,6 +188,14 @@ int unregister_io_int_func(void (*f)(void))
>  
>  void handle_svc_int(void)
>  {
> -	report_abort("Unexpected supervisor call interrupt: on cpu %d at %#lx",
> -		     stap(), lc->svc_old_psw.addr);
> +	uint16_t code = lc->svc_int_code;
> +
> +	switch (code) {
> +	case SVC_LEAVE_PSTATE:
> +		lc->svc_old_psw.mask &= ~PSW_MASK_PSTATE;
> +		break;
> +	default:
> +		report_abort("Unexpected supervisor call interrupt: code %#x on cpu %d at %#lx",
> +			      code, stap(), lc->svc_old_psw.addr);
> +	}
>  }
> 


  reply	other threads:[~2021-02-23 16:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-23 14:24 [kvm-unit-tests PATCH v2 0/2] s390x: mvpg test Claudio Imbrenda
2021-02-23 14:24 ` [kvm-unit-tests PATCH v2 1/2] s390x: introduce leave_pstate to leave userspace Claudio Imbrenda
2021-02-23 16:19   ` Janosch Frank [this message]
2021-02-23 14:24 ` [kvm-unit-tests PATCH v2 2/2] s390x: mvpg: simple test Claudio Imbrenda
2021-02-26  9:24   ` Janosch Frank
2021-02-26 10:14     ` Claudio Imbrenda

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=6eb8c9eb-d5af-2790-1855-8b85693ef3e8@linux.ibm.com \
    --to=frankja@linux.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=pmorel@linux.ibm.com \
    --cc=thuth@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox