1 /* SPDX-License-Identifier: GPL-2.0-only */
4 * Copyright SUSE Linux Products GmbH 2009
6 * Authors: Alexander Graf <agraf@suse.de>
9 /******************************************************************************
13 *****************************************************************************/
15 .macro LOAD_GUEST_SEGMENTS
23 * all other volatile GPRS = free except R4, R6
24 * SVCPU[CR] = guest CR
25 * SVCPU[XER] = guest XER
26 * SVCPU[CTR] = guest CTR
27 * SVCPU[LR] = guest LR
30 #define XCHG_SR(n) lwz r9, (SVCPU_SR+(n*4))(r3); \
52 #define KVM_KILL_BAT(n, reg) \
53 mtspr SPRN_IBAT##n##U,reg; \
54 mtspr SPRN_IBAT##n##L,reg; \
55 mtspr SPRN_DBAT##n##U,reg; \
56 mtspr SPRN_DBAT##n##L,reg; \
66 /******************************************************************************
70 *****************************************************************************/
72 .macro LOAD_HOST_SEGMENTS
74 /* Register usage at this point:
78 * R12 = exit handler id
79 * R13 = shadow vcpu - SHADOW_VCPU_OFF
81 * SVCPU[CR] = guest CR
82 * SVCPU[XER] = guest XER
83 * SVCPU[CTR] = guest CTR
84 * SVCPU[LR] = guest LR
90 /* We only overwrite the upper part, so we only restoree
92 #define KVM_LOAD_BAT(n, reg, RA, RB) \
93 lwz RA,(n*16)+0(reg); \
94 lwz RB,(n*16)+4(reg); \
95 mtspr SPRN_IBAT##n##U,RA; \
96 mtspr SPRN_IBAT##n##L,RB; \
97 lwz RA,(n*16)+8(reg); \
98 lwz RB,(n*16)+12(reg); \
99 mtspr SPRN_DBAT##n##U,RA; \
100 mtspr SPRN_DBAT##n##L,RB; \
105 KVM_LOAD_BAT(0, r9, r10, r11)
106 KVM_LOAD_BAT(1, r9, r10, r11)
107 KVM_LOAD_BAT(2, r9, r10, r11)
108 KVM_LOAD_BAT(3, r9, r10, r11)
110 /* Restore Segment Registers */
116 LOAD_REG_IMMEDIATE(r3, 0x20000000 | (0x111 * 0xc))
119 addi r3, r3, 0x111 /* increment VSID */
120 addis r4, r4, 0x1000 /* address of next segment */
125 /* 'current->mm' needs to be in r4 */
129 /* This only clobbers r0, r3, r4 and r5 */
130 bl switch_mmu_context