Re: [kvm-unit-tests PATCH v3 2/7] s390x: Fully commit to stack save area for exceptions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 22/02/2021 09.57, Janosch Frank wrote:
Having two sets of macros for saving registers on exceptions makes
maintaining harder. Also we have limited space in the lowcore to save
stuff and by using the stack as a save area, we can stack exceptions.

So let's use the SAVE/RESTORE_REGS_STACK as the default. When we also
move the diag308 macro over we can remove the old SAVE/RESTORE_REGS
macros.

Signed-off-by: Janosch Frank <frankja@xxxxxxxxxxxxx>
Reviewed-by: Claudio Imbrenda <imbrenda@xxxxxxxxxxxxx>
---
[...]
diff --git a/lib/s390x/asm/interrupt.h b/lib/s390x/asm/interrupt.h
index 1a2e2cd8..31e4766d 100644
--- a/lib/s390x/asm/interrupt.h
+++ b/lib/s390x/asm/interrupt.h
@@ -14,8 +14,8 @@
  #define EXT_IRQ_SERVICE_SIG	0x2401
void register_pgm_cleanup_func(void (*f)(void));
-void handle_pgm_int(void);
-void handle_ext_int(void);
+void handle_pgm_int(struct stack_frame_int *stack);
+void handle_ext_int(struct stack_frame_int *stack);
  void handle_mcck_int(void);
  void handle_io_int(void);

So handle_io_int() does not get a *stack parameter here...

  void handle_svc_int(void);
diff --git a/lib/s390x/interrupt.c b/lib/s390x/interrupt.c
index 1ce36073..a59df80e 100644
--- a/lib/s390x/interrupt.c
+++ b/lib/s390x/interrupt.c
@@ -56,7 +56,7 @@ void register_pgm_cleanup_func(void (*f)(void))
  	pgm_cleanup_func = f;
  }
-static void fixup_pgm_int(void)
+static void fixup_pgm_int(struct stack_frame_int *stack)
  {
  	/* If we have an error on SIE we directly move to sie_exit */
  	if (lc->pgm_old_psw.addr >= (uint64_t)&sie_entry &&
@@ -76,7 +76,7 @@ static void fixup_pgm_int(void)
  		/* Handling for iep.c test case. */
  		if (lc->trans_exc_id & 0x80UL && lc->trans_exc_id & 0x04UL &&
  		    !(lc->trans_exc_id & 0x08UL))
-			lc->pgm_old_psw.addr = lc->sw_int_grs[14];
+			lc->pgm_old_psw.addr = stack->grs0[12];

I'd maybe put a "/* GR14 */" comment at the end of the line, to make it more obvious which register we're aiming here at.

  		break;
  	case PGM_INT_CODE_SEGMENT_TRANSLATION:
  	case PGM_INT_CODE_PAGE_TRANSLATION:
@@ -115,7 +115,7 @@ static void fixup_pgm_int(void)
  	/* suppressed/terminated/completed point already at the next address */
  }
-void handle_pgm_int(void)
+void handle_pgm_int(struct stack_frame_int *stack)
  {
  	if (!pgm_int_expected) {
  		/* Force sclp_busy to false, otherwise we will loop forever */
@@ -130,10 +130,10 @@ void handle_pgm_int(void)
  	if (pgm_cleanup_func)
  		(*pgm_cleanup_func)();
  	else
-		fixup_pgm_int();
+		fixup_pgm_int(stack);
  }
-void handle_ext_int(void)
+void handle_ext_int(struct stack_frame_int *stack)
  {
  	if (!ext_int_expected &&
  	    lc->ext_int_code != EXT_IRQ_SERVICE_SIG) {
@@ -143,13 +143,13 @@ void handle_ext_int(void)
  	}
if (lc->ext_int_code == EXT_IRQ_SERVICE_SIG) {
-		lc->sw_int_crs[0] &= ~(1UL << 9);
+		stack->crs[0] &= ~(1UL << 9);
  		sclp_handle_ext();
  	} else {
  		ext_int_expected = false;
  	}
- if (!(lc->sw_int_crs[0] & CR0_EXTM_MASK))
+	if (!(stack->crs[0] & CR0_EXTM_MASK))
  		lc->ext_old_psw.mask &= ~PSW_MASK_EXT;
  }
diff --git a/s390x/cstart64.S b/s390x/cstart64.S
index ace0c0d9..35d20293 100644
--- a/s390x/cstart64.S
+++ b/s390x/cstart64.S
@@ -92,33 +92,36 @@ memsetxc:
.section .text
  pgm_int:
-	SAVE_REGS
+	SAVE_REGS_STACK
+	lgr     %r2, %r15
  	brasl	%r14, handle_pgm_int
-	RESTORE_REGS
+	RESTORE_REGS_STACK
  	lpswe	GEN_LC_PGM_OLD_PSW
ext_int:
-	SAVE_REGS
+	SAVE_REGS_STACK
+	lgr     %r2, %r15
  	brasl	%r14, handle_ext_int
-	RESTORE_REGS
+	RESTORE_REGS_STACK
  	lpswe	GEN_LC_EXT_OLD_PSW
mcck_int:
-	SAVE_REGS
+	SAVE_REGS_STACK
  	brasl	%r14, handle_mcck_int
-	RESTORE_REGS
+	RESTORE_REGS_STACK
  	lpswe	GEN_LC_MCCK_OLD_PSW
io_int:
  	SAVE_REGS_STACK
+	lgr     %r2, %r15

... and here you're passing the stack pointer as a parameter, though handle_io_int() does not use it... well, ok, it gets reworked again in the next patch, but maybe you could still remove the above line when picking up the patch?

Anyway:
Acked-by: Thomas Huth <thuth@xxxxxxxxxx>




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux