diff mbox series

[kvm-unit-tests,v1,3/4] s390x: save/restore cr0 in IRQ handlers

Message ID 20180824115059.1517-4-david@redhat.com (mailing list archive)
State New, archived
Headers show
Series s390x: simple DXC test | expand

Commit Message

David Hildenbrand Aug. 24, 2018, 11:50 a.m. UTC
We want to check for certain conditions (e.g. no AFP enabled), but still
have it correctly set up (AFP enabled) in the IRQ handles. So let's
save + restore.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 lib/s390x/asm-offsets.c  | 1 +
 lib/s390x/asm/arch_def.h | 4 +++-
 s390x/cstart64.S         | 7 +++++++
 3 files changed, 11 insertions(+), 1 deletion(-)

Comments

Thomas Huth Aug. 27, 2018, 9:54 a.m. UTC | #1
On 2018-08-24 13:50, David Hildenbrand wrote:
> We want to check for certain conditions (e.g. no AFP enabled), but still
> have it correctly set up (AFP enabled) in the IRQ handles. So let's
> save + restore.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>  lib/s390x/asm-offsets.c  | 1 +
>  lib/s390x/asm/arch_def.h | 4 +++-
>  s390x/cstart64.S         | 7 +++++++
>  3 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/s390x/asm-offsets.c b/lib/s390x/asm-offsets.c
> index f1012c6..6e2d259 100644
> --- a/lib/s390x/asm-offsets.c
> +++ b/lib/s390x/asm-offsets.c
> @@ -57,6 +57,7 @@ int main(void)
>  	OFFSET(GEN_LC_SW_INT_GRS, lowcore, sw_int_grs);
>  	OFFSET(GEN_LC_SW_INT_FPRS, lowcore, sw_int_fprs);
>  	OFFSET(GEN_LC_SW_INT_FPC, lowcore, sw_int_fpc);
> +	OFFSET(GEN_LC_SW_INT_CR0, lowcore, sw_int_cr0);
>  	OFFSET(GEN_LC_MCCK_EXT_SA_ADDR, lowcore, mcck_ext_sa_addr);
>  	OFFSET(GEN_LC_FPRS_SA, lowcore, fprs_sa);
>  	OFFSET(GEN_LC_GRS_SA, lowcore, grs_sa);
> diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h
> index 99abe18..d2cd727 100644
> --- a/lib/s390x/asm/arch_def.h
> +++ b/lib/s390x/asm/arch_def.h
> @@ -71,7 +71,9 @@ struct lowcore {
>  	uint64_t	sw_int_grs[16];			/* 0x0200 */
>  	uint64_t	sw_int_fprs[16];		/* 0x0280 */
>  	uint32_t	sw_int_fpc;			/* 0x0300 */
> -	uint8_t		pad_0x0304[0x11b0 - 0x0304];	/* 0x0304 */
> +	uint8_t		pad_0x0304[0x0308 - 0x0304];	/* 0x0304 */
> +	uint64_t	sw_int_cr0;			/* 0x0308 */
> +	uint8_t		pad_0x0310[0x11b0 - 0x0310];	/* 0x0310 */
>  	uint64_t	mcck_ext_sa_addr;		/* 0x11b0 */
>  	uint8_t		pad_0x11b8[0x1200 - 0x11b8];	/* 0x11b8 */
>  	uint64_t	fprs_sa[16];			/* 0x1200 */
> diff --git a/s390x/cstart64.S b/s390x/cstart64.S
> index 02a4f77..465cfee 100644
> --- a/s390x/cstart64.S
> +++ b/s390x/cstart64.S
> @@ -57,6 +57,11 @@ init_psw_cont:
>  	.macro SAVE_REGS
>  	/* save grs 0-15 */
>  	stmg	%r0, %r15, GEN_LC_SW_INT_GRS
> +	/* save cr0 */
> +	stctg	%c0, %c0, GEN_LC_SW_INT_CR0
> +	/* load initital cr0 again */
> +	larl	%r1, initital_cr0
> +	lctlg	%c0, %c0, 0(%r1)
>  	/* save fprs 0-15 + fpc */
>  	la	%r1, GEN_LC_SW_INT_FPRS
>  	std	%f0, 0(%r1)
> @@ -98,6 +103,8 @@ init_psw_cont:
>  	ld	%f14, 112(%r1)
>  	ld	%f15, 120(%r1)
>  	lfpc	GEN_LC_SW_INT_FPC
> +	/* restore cr0 */
> +	lctlg	%c0, %c0, GEN_LC_SW_INT_CR0
>  	/* restore grs 0-15 */
>  	lmg	%r0, %r15, GEN_LC_SW_INT_GRS
>  	.endm
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>
Janosch Frank Aug. 27, 2018, 2:45 p.m. UTC | #2
On 24.08.2018 13:50, David Hildenbrand wrote:
> We want to check for certain conditions (e.g. no AFP enabled), but still
> have it correctly set up (AFP enabled) in the IRQ handles. So let's
> save + restore.

s/handles/handlers/

While you're at it, do you also want to fix initital_psw and name it
initial_psw in an extra patch?


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

> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>  lib/s390x/asm-offsets.c  | 1 +
>  lib/s390x/asm/arch_def.h | 4 +++-
>  s390x/cstart64.S         | 7 +++++++
>  3 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/s390x/asm-offsets.c b/lib/s390x/asm-offsets.c
> index f1012c6..6e2d259 100644
> --- a/lib/s390x/asm-offsets.c
> +++ b/lib/s390x/asm-offsets.c
> @@ -57,6 +57,7 @@ int main(void)
>  	OFFSET(GEN_LC_SW_INT_GRS, lowcore, sw_int_grs);
>  	OFFSET(GEN_LC_SW_INT_FPRS, lowcore, sw_int_fprs);
>  	OFFSET(GEN_LC_SW_INT_FPC, lowcore, sw_int_fpc);
> +	OFFSET(GEN_LC_SW_INT_CR0, lowcore, sw_int_cr0);
>  	OFFSET(GEN_LC_MCCK_EXT_SA_ADDR, lowcore, mcck_ext_sa_addr);
>  	OFFSET(GEN_LC_FPRS_SA, lowcore, fprs_sa);
>  	OFFSET(GEN_LC_GRS_SA, lowcore, grs_sa);
> diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h
> index 99abe18..d2cd727 100644
> --- a/lib/s390x/asm/arch_def.h
> +++ b/lib/s390x/asm/arch_def.h
> @@ -71,7 +71,9 @@ struct lowcore {
>  	uint64_t	sw_int_grs[16];			/* 0x0200 */
>  	uint64_t	sw_int_fprs[16];		/* 0x0280 */
>  	uint32_t	sw_int_fpc;			/* 0x0300 */
> -	uint8_t		pad_0x0304[0x11b0 - 0x0304];	/* 0x0304 */
> +	uint8_t		pad_0x0304[0x0308 - 0x0304];	/* 0x0304 */
> +	uint64_t	sw_int_cr0;			/* 0x0308 */
> +	uint8_t		pad_0x0310[0x11b0 - 0x0310];	/* 0x0310 */
>  	uint64_t	mcck_ext_sa_addr;		/* 0x11b0 */
>  	uint8_t		pad_0x11b8[0x1200 - 0x11b8];	/* 0x11b8 */
>  	uint64_t	fprs_sa[16];			/* 0x1200 */
> diff --git a/s390x/cstart64.S b/s390x/cstart64.S
> index 02a4f77..465cfee 100644
> --- a/s390x/cstart64.S
> +++ b/s390x/cstart64.S
> @@ -57,6 +57,11 @@ init_psw_cont:
>  	.macro SAVE_REGS
>  	/* save grs 0-15 */
>  	stmg	%r0, %r15, GEN_LC_SW_INT_GRS
> +	/* save cr0 */
> +	stctg	%c0, %c0, GEN_LC_SW_INT_CR0
> +	/* load initital cr0 again */
> +	larl	%r1, initital_cr0




> +	lctlg	%c0, %c0, 0(%r1)
>  	/* save fprs 0-15 + fpc */
>  	la	%r1, GEN_LC_SW_INT_FPRS
>  	std	%f0, 0(%r1)
> @@ -98,6 +103,8 @@ init_psw_cont:
>  	ld	%f14, 112(%r1)
>  	ld	%f15, 120(%r1)
>  	lfpc	GEN_LC_SW_INT_FPC
> +	/* restore cr0 */
> +	lctlg	%c0, %c0, GEN_LC_SW_INT_CR0
>  	/* restore grs 0-15 */
>  	lmg	%r0, %r15, GEN_LC_SW_INT_GRS
>  	.endm
>
David Hildenbrand Aug. 27, 2018, 4:35 p.m. UTC | #3
On 27.08.2018 16:45, Janosch Frank wrote:
> On 24.08.2018 13:50, David Hildenbrand wrote:
>> We want to check for certain conditions (e.g. no AFP enabled), but still
>> have it correctly set up (AFP enabled) in the IRQ handles. So let's
>> save + restore.
> 
> s/handles/handlers/
> 
> While you're at it, do you also want to fix initital_psw and name it
> initial_psw in an extra patch?
> 

Yes, indeed I will.

Thanks!
diff mbox series

Patch

diff --git a/lib/s390x/asm-offsets.c b/lib/s390x/asm-offsets.c
index f1012c6..6e2d259 100644
--- a/lib/s390x/asm-offsets.c
+++ b/lib/s390x/asm-offsets.c
@@ -57,6 +57,7 @@  int main(void)
 	OFFSET(GEN_LC_SW_INT_GRS, lowcore, sw_int_grs);
 	OFFSET(GEN_LC_SW_INT_FPRS, lowcore, sw_int_fprs);
 	OFFSET(GEN_LC_SW_INT_FPC, lowcore, sw_int_fpc);
+	OFFSET(GEN_LC_SW_INT_CR0, lowcore, sw_int_cr0);
 	OFFSET(GEN_LC_MCCK_EXT_SA_ADDR, lowcore, mcck_ext_sa_addr);
 	OFFSET(GEN_LC_FPRS_SA, lowcore, fprs_sa);
 	OFFSET(GEN_LC_GRS_SA, lowcore, grs_sa);
diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h
index 99abe18..d2cd727 100644
--- a/lib/s390x/asm/arch_def.h
+++ b/lib/s390x/asm/arch_def.h
@@ -71,7 +71,9 @@  struct lowcore {
 	uint64_t	sw_int_grs[16];			/* 0x0200 */
 	uint64_t	sw_int_fprs[16];		/* 0x0280 */
 	uint32_t	sw_int_fpc;			/* 0x0300 */
-	uint8_t		pad_0x0304[0x11b0 - 0x0304];	/* 0x0304 */
+	uint8_t		pad_0x0304[0x0308 - 0x0304];	/* 0x0304 */
+	uint64_t	sw_int_cr0;			/* 0x0308 */
+	uint8_t		pad_0x0310[0x11b0 - 0x0310];	/* 0x0310 */
 	uint64_t	mcck_ext_sa_addr;		/* 0x11b0 */
 	uint8_t		pad_0x11b8[0x1200 - 0x11b8];	/* 0x11b8 */
 	uint64_t	fprs_sa[16];			/* 0x1200 */
diff --git a/s390x/cstart64.S b/s390x/cstart64.S
index 02a4f77..465cfee 100644
--- a/s390x/cstart64.S
+++ b/s390x/cstart64.S
@@ -57,6 +57,11 @@  init_psw_cont:
 	.macro SAVE_REGS
 	/* save grs 0-15 */
 	stmg	%r0, %r15, GEN_LC_SW_INT_GRS
+	/* save cr0 */
+	stctg	%c0, %c0, GEN_LC_SW_INT_CR0
+	/* load initital cr0 again */
+	larl	%r1, initital_cr0
+	lctlg	%c0, %c0, 0(%r1)
 	/* save fprs 0-15 + fpc */
 	la	%r1, GEN_LC_SW_INT_FPRS
 	std	%f0, 0(%r1)
@@ -98,6 +103,8 @@  init_psw_cont:
 	ld	%f14, 112(%r1)
 	ld	%f15, 120(%r1)
 	lfpc	GEN_LC_SW_INT_FPC
+	/* restore cr0 */
+	lctlg	%c0, %c0, GEN_LC_SW_INT_CR0
 	/* restore grs 0-15 */
 	lmg	%r0, %r15, GEN_LC_SW_INT_GRS
 	.endm