public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Janosch Frank <frankja@linux.ibm.com>
To: Thomas Huth <thuth@redhat.com>, kvm@vger.kernel.org
Cc: david@redhat.com, borntraeger@de.ibm.com, imbrenda@linux.ibm.com,
	cohuck@redhat.com, linux-s390@vger.kernel.org
Subject: Re: [kvm-unit-tests PATCH v3 5/8] s390x: sie: Add SIE to lib
Date: Thu, 17 Dec 2020 16:45:21 +0100	[thread overview]
Message-ID: <365acc5e-0f57-ed9e-cee3-b321827fd2b6@linux.ibm.com> (raw)
In-Reply-To: <0bb4934a-23b6-bf4f-2742-3892c17c81d0@redhat.com>

On 12/17/20 10:37 AM, Thomas Huth wrote:
> On 11/12/2020 11.00, Janosch Frank wrote:
>> This commit adds the definition of the SIE control block struct and
>> the assembly to execute SIE and save/restore guest registers.
>>
>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>> ---
>>  lib/s390x/asm-offsets.c  |  13 +++
>>  lib/s390x/asm/arch_def.h |   7 ++
>>  lib/s390x/interrupt.c    |   7 ++
>>  lib/s390x/sie.h          | 197 +++++++++++++++++++++++++++++++++++++++
>>  s390x/asm/lib.S          |  56 +++++++++++
>>  5 files changed, 280 insertions(+)
>>  create mode 100644 lib/s390x/sie.h
>>
>> diff --git a/lib/s390x/asm-offsets.c b/lib/s390x/asm-offsets.c
>> index ee94ed3..35697de 100644
>> --- a/lib/s390x/asm-offsets.c
>> +++ b/lib/s390x/asm-offsets.c
>> @@ -8,6 +8,7 @@
>>  #include <libcflat.h>
>>  #include <kbuild.h>
>>  #include <asm/arch_def.h>
>> +#include <sie.h>
>>  
>>  int main(void)
>>  {
>> @@ -69,6 +70,18 @@ int main(void)
>>  	OFFSET(GEN_LC_ARS_SA, lowcore, ars_sa);
>>  	OFFSET(GEN_LC_CRS_SA, lowcore, crs_sa);
>>  	OFFSET(GEN_LC_PGM_INT_TDB, lowcore, pgm_int_tdb);
>> +	OFFSET(__SF_GPRS, stack_frame, gprs);
>> +	OFFSET(__SF_SIE_CONTROL, stack_frame, empty1[0]);
>> +	OFFSET(__SF_SIE_SAVEAREA, stack_frame, empty1[1]);
>> +	OFFSET(__SF_SIE_REASON, stack_frame, empty1[2]);
>> +	OFFSET(__SF_SIE_FLAGS, stack_frame, empty1[3]);
>> +	OFFSET(SIE_SAVEAREA_HOST_GRS, vm_save_area, host.grs[0]);
>> +	OFFSET(SIE_SAVEAREA_HOST_FPRS, vm_save_area, host.fprs[0]);
>> +	OFFSET(SIE_SAVEAREA_HOST_FPC, vm_save_area, host.fpc);
>> +	OFFSET(SIE_SAVEAREA_GUEST_GRS, vm_save_area, guest.grs[0]);
>> +	OFFSET(SIE_SAVEAREA_GUEST_FPRS, vm_save_area, guest.fprs[0]);
>> +	OFFSET(SIE_SAVEAREA_GUEST_FPC, vm_save_area, guest.fpc);
>> +
>>  
>>  	return 0;
>>  }
>> diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h
>> index f3ab830..5a13cf2 100644
>> --- a/lib/s390x/asm/arch_def.h
>> +++ b/lib/s390x/asm/arch_def.h
>> @@ -8,6 +8,13 @@
>>  #ifndef _ASM_S390X_ARCH_DEF_H_
>>  #define _ASM_S390X_ARCH_DEF_H_
>>  
>> +struct stack_frame {
>> +	unsigned long back_chain;
>> +	unsigned long empty1[5];
>> +	unsigned long gprs[10];
>> +	unsigned int  empty2[8];
> 
> I think you can drop empty2 ?

Since I don't need to allocate it I could also remove the gprs. We only
use empty1 right now as far as I know.

> 
>> +};
>> +
>>  struct psw {
>>  	uint64_t	mask;
>>  	uint64_t	addr;
>> diff --git a/lib/s390x/interrupt.c b/lib/s390x/interrupt.c
>> index bac8862..3858096 100644
>> --- a/lib/s390x/interrupt.c
>> +++ b/lib/s390x/interrupt.c
>> @@ -11,6 +11,7 @@
>>  #include <asm/barrier.h>
>>  #include <sclp.h>
>>  #include <interrupt.h>
>> +#include <sie.h>
>>  
>>  static bool pgm_int_expected;
>>  static bool ext_int_expected;
>> @@ -57,6 +58,12 @@ void register_pgm_cleanup_func(void (*f)(void))
>>  
>>  static void fixup_pgm_int(void)
>>  {
>> +	/* If we have an error on SIE we directly move to sie_exit */
>> +	if (lc->pgm_old_psw.addr >= (uint64_t)&sie_entry &&
>> +	    lc->pgm_old_psw.addr <= (uint64_t)&sie_entry + 10) {
> 
> Can you please explain that "magic" number 10 in the comment?

I think using sie_exit would make more sense than explaining that
sie_entry + 10 bytes is the location of sie_exit.


> 
>> +		lc->pgm_old_psw.addr = (uint64_t)&sie_exit;
>> +	}
>> +
>>  	switch (lc->pgm_int_code) {
>>  	case PGM_INT_CODE_PRIVILEGED_OPERATION:
>>  		/* Normal operation is in supervisor state, so this exception
>> diff --git a/lib/s390x/sie.h b/lib/s390x/sie.h
>> new file mode 100644
>> index 0000000..b00bdf4
>> --- /dev/null
>> +++ b/lib/s390x/sie.h
> [...]
>> +extern u64 sie_entry;
>> +extern u64 sie_exit;
> 
> Maybe better:
> 
> extern uint16_t sie_entry[];
> extern uint16_t sie_exit[];
> 
> ?
> 
> Or even:
> 
> extern void sie_entry();
> extern void sie_exit();

Definitely better since I don't return values in sie_exit anymore (I
used to before).

> 
> ?
> 
>  Thomas
> 

  reply	other threads:[~2020-12-17 15:46 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11 10:00 [kvm-unit-tests PATCH v3 0/8] s390x: Add SIE library and simple test Janosch Frank
2020-12-11 10:00 ` [kvm-unit-tests PATCH v3 1/8] s390x: Add test_bit to library Janosch Frank
2020-12-11 10:00 ` [kvm-unit-tests PATCH v3 2/8] s390x: Consolidate sclp read info Janosch Frank
2020-12-11 12:06   ` Thomas Huth
2020-12-17 11:47   ` Claudio Imbrenda
2020-12-17 14:48     ` Janosch Frank
2020-12-11 10:00 ` [kvm-unit-tests PATCH v3 3/8] s390x: SCLP feature checking Janosch Frank
2020-12-17 12:18   ` Claudio Imbrenda
2020-12-17 15:21     ` Janosch Frank
2020-12-17 15:24       ` Thomas Huth
2020-12-11 10:00 ` [kvm-unit-tests PATCH v3 4/8] s390x: Split assembly and move to s390x/asm/ Janosch Frank
2020-12-11 12:18   ` Thomas Huth
2020-12-14 10:34     ` Janosch Frank
2020-12-17 12:54   ` Claudio Imbrenda
2020-12-17 13:14   ` Claudio Imbrenda
2020-12-17 15:22     ` Janosch Frank
2020-12-11 10:00 ` [kvm-unit-tests PATCH v3 5/8] s390x: sie: Add SIE to lib Janosch Frank
2020-12-17  9:37   ` Thomas Huth
2020-12-17 15:45     ` Janosch Frank [this message]
2020-12-17 14:42   ` Claudio Imbrenda
2020-12-11 10:00 ` [kvm-unit-tests PATCH v3 6/8] s390x: sie: Add first SIE test Janosch Frank
2020-12-17  9:41   ` Thomas Huth
2020-12-17 14:48   ` Claudio Imbrenda
2020-12-18 11:17   ` Cornelia Huck
2020-12-11 10:00 ` [kvm-unit-tests PATCH v3 7/8] s390x: Add diag318 intercept test Janosch Frank
2020-12-17  9:53   ` Thomas Huth
2020-12-17  9:59     ` Christian Borntraeger
2020-12-17 10:34       ` Thomas Huth
2020-12-17 14:31         ` Janosch Frank
2020-12-17 15:31           ` Janosch Frank
2020-12-17 15:36             ` Thomas Huth
2020-12-17 14:58   ` Claudio Imbrenda
2020-12-17 15:25     ` Janosch Frank
2020-12-11 10:00 ` [kvm-unit-tests PATCH v3 8/8] s390x: Fix sclp.h style issues Janosch Frank
2020-12-17 14:55   ` 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=365acc5e-0f57-ed9e-cee3-b321827fd2b6@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=linux-s390@vger.kernel.org \
    --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