xref: /kvm-unit-tests/s390x/cpu.S (revision c679803096e43f60b7e9abb72498afaf3fdfd697)
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * s390x assembly library
4 *
5 * Copyright (c) 2019 IBM Corp.
6 *
7 * Authors:
8 *    Janosch Frank <frankja@linux.ibm.com>
9 */
10#include <asm/asm-offsets.h>
11#include <asm/sigp.h>
12
13#include "macros.S"
14
15/*
16 * load_reset calling convention:
17 * %r2 subcode (0 or 1)
18 */
19.globl diag308_load_reset
20diag308_load_reset:
21	SAVE_REGS_STACK
22	/* Backup current PSW mask, as we have to restore it on success */
23	epsw	%r0, %r1
24	st	%r0, GEN_LC_SW_INT_PSW
25	st	%r1, GEN_LC_SW_INT_PSW + 4
26	/* Load reset psw mask (short psw, 64 bit) */
27	lg	%r0, reset_psw
28	/* Load the success label address */
29	larl    %r1, 0f
30	/* Or it to the mask */
31	ogr	%r0, %r1
32	/* Store it at the reset PSW location (real 0x0) */
33	stg	%r0, 0
34	stg     %r15, GEN_LC_SW_INT_GRS + 15 * 8
35	/* Do the reset */
36	diag    %r0,%r2,0x308
37	/* Failure path */
38	xgr	%r2, %r2
39	br	%r14
40	/* Success path */
41	/* load a cr0 that has the AFP control bit which enables all FPRs */
420:	larl	%r1, initial_cr0
43	lctlg	%c0, %c0, 0(%r1)
44	lg      %r15, GEN_LC_SW_INT_GRS + 15 * 8
45	RESTORE_REGS_STACK
46	lhi	%r2, 1
47	larl	%r0, 1f
48	stg	%r0, GEN_LC_SW_INT_PSW + 8
49	lpswe	GEN_LC_SW_INT_PSW
501:	br	%r14
51
52/* Sets up general registers and cr0 when a new cpu is brought online. */
53.globl smp_cpu_setup_state
54smp_cpu_setup_state:
55	xgr	%r1, %r1
56	lmg     %r0, %r15, GEN_LC_SW_INT_GRS
57	lctlg   %c0, %c0, GEN_LC_SW_INT_CRS
58	/* We should only go once through cpu setup and not for every restart */
59	stg	%r14, GEN_LC_RESTART_NEW_PSW + 8
60	larl	%r14, 0f
61	lpswe	GEN_LC_SW_INT_PSW
62	/* If the function returns, just loop here */
630:	j	0
64
65	.align	8
66reset_psw:
67	.quad	0x0008000180000000
68