Skip to contentSkip to conversation

s390x: snippets: c: Load initial cr0

PATCH In review Janosch Frank 2 participants 2 messages Mar 31, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390x: snippets: c: Load initial cr0

As soon as we use C we need to set the AFP bit in cr0 so we can use all fprs.

---
 s390x/snippets/c/cstart.S | 6 ++++++
 1 file changed, 6 insertions(+)
s390x/snippets/c/cstart.S +6 -0
index aaa5380c..a7d4cd42 100644
@@ -12,6 +12,8 @@
 .section .init
 	.globl start
 start:
+	larl	%r1, initial_cr0
+	lctlg	%c0, %c0, 0(%r1)
 	/* XOR all registers with themselves to clear them fully. */
 	.irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
 	xgr \i,\i
@@ -34,3 +36,7 @@ exit:
 	/* For now let's only use cpu 0 in snippets so this will always work. */
 	xgr	%r0, %r0
 	sigp    %r2, %r0, SIGP_STOP
+
+initial_cr0:
+	/* enable AFP-register control, so FP regs (+BFP instr) can be used */
+	.quad	0x0000000000040000
Signature · 1 line
2.32.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · On Thu, 31 Mar 2022 12:55:15 +0000 Janosch Frank <[email protected]> wrote:

As soon as we use C we need to set the AFP bit in cr0 so we can use all fprs.

seems like a good idea

Quoted 1 line
Quoted 25 lines
---
 s390x/snippets/c/cstart.S | 6 ++++++
 1 file changed, 6 insertions(+)
s390x/snippets/c/cstart.S +6 -0
index aaa5380c..a7d4cd42 100644
@@ -12,6 +12,8 @@
 .section .init
 	.globl start
 start:
+	larl	%r1, initial_cr0
+	lctlg	%c0, %c0, 0(%r1)
 	/* XOR all registers with themselves to clear them fully. */
 	.irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
 	xgr \i,\i
@@ -34,3 +36,7 @@ exit:
 	/* For now let's only use cpu 0 in snippets so this will always work. */
 	xgr	%r0, %r0
 	sigp    %r2, %r0, SIGP_STOP
+
+initial_cr0:
+	/* enable AFP-register control, so FP regs (+BFP instr) can be used */
+	.quad	0x0000000000040000