2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License, version 2, as
4 * published by the Free Software Foundation.
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 * Copyright SUSE Linux Products GmbH 2009
17 * Authors: Alexander Graf <agraf@suse.de>
20 #ifdef __LITTLE_ENDIAN__
21 #error Need to fix SLB shadow accesses in little endian mode
24 #define SHADOW_SLB_ESID(num) (SLBSHADOW_SAVEAREA + (num * 0x10))
25 #define SHADOW_SLB_VSID(num) (SLBSHADOW_SAVEAREA + (num * 0x10) + 0x8)
26 #define UNBOLT_SLB_ENTRY(num) \
27 ld r9, SHADOW_SLB_ESID(num)(r12); \
28 /* Invalid? Skip. */; \
29 rldicl. r0, r9, 37, 63; \
30 beq slb_entry_skip_ ## num; \
31 xoris r9, r9, SLB_ESID_V@h; \
32 std r9, SHADOW_SLB_ESID(num)(r12); \
33 slb_entry_skip_ ## num:
35 #define REBOLT_SLB_ENTRY(num) \
36 ld r10, SHADOW_SLB_ESID(num)(r11); \
38 beq slb_exit_skip_ ## num; \
39 oris r10, r10, SLB_ESID_V@h; \
40 ld r9, SHADOW_SLB_VSID(num)(r11); \
42 std r10, SHADOW_SLB_ESID(num)(r11); \
43 slb_exit_skip_ ## num:
45 /******************************************************************************
49 *****************************************************************************/
51 .macro LOAD_GUEST_SEGMENTS
60 * all other volatile GPRS = free except R4, R6
61 * SVCPU[CR] = guest CR
62 * SVCPU[XER] = guest XER
63 * SVCPU[CTR] = guest CTR
64 * SVCPU[LR] = guest LR
67 /* Remove LPAR shadow entries */
69 #if SLB_NUM_BOLTED == 3
71 ld r12, PACA_SLBSHADOWPTR(r13)
73 /* Remove bolted entries */
79 #error unknown number of bolted entries
88 /* Fill SLB with our shadow */
90 lbz r12, SVCPU_SLB_MAX(r3)
92 addi r12, r12, SVCPU_SLB
95 /* for (r11 = kvm_slb; r11 < kvm_slb + kvm_slb_size; r11+=slb_entry) */
103 rldicl. r0, r10, 37, 63
104 beq slb_loop_enter_skip
118 /******************************************************************************
122 *****************************************************************************/
124 .macro LOAD_HOST_SEGMENTS
126 /* Register usage at this point:
130 * R12 = exit handler id
131 * R13 = shadow vcpu - SHADOW_VCPU_OFF [=PACA on PPC64]
133 * SVCPU[CR] = guest CR
134 * SVCPU[XER] = guest XER
135 * SVCPU[CTR] = guest CTR
136 * SVCPU[LR] = guest LR
140 /* Restore bolted entries from the shadow and fix it along the way */
142 /* We don't store anything in entry 0, so we don't need to take care of it */
146 #if SLB_NUM_BOLTED == 3
148 ld r11, PACA_SLBSHADOWPTR(r13)
155 #error unknown number of bolted entries