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 * Copyright 2011 Paul Mackerras, IBM Corp. <paulus@au1.ibm.com>
13 * Derived from book3s_rmhandlers.S and other files, which are:
15 * Copyright SUSE Linux Products GmbH 2009
17 * Authors: Alexander Graf <agraf@suse.de>
20 #include <asm/ppc_asm.h>
21 #include <asm/kvm_asm.h>
25 #include <asm/ptrace.h>
26 #include <asm/hvcall.h>
27 #include <asm/asm-offsets.h>
28 #include <asm/exception-64s.h>
29 #include <asm/kvm_book3s_asm.h>
30 #include <asm/mmu-hash64.h>
32 /*****************************************************************************
34 * Real Mode handlers that need to be in the linear mapping *
36 ****************************************************************************/
38 .globl kvmppc_skip_interrupt
39 kvmppc_skip_interrupt:
47 .globl kvmppc_skip_Hinterrupt
48 kvmppc_skip_Hinterrupt:
57 * Call kvmppc_hv_entry in real mode.
58 * Must be called with interrupts hard-disabled.
62 * LR = return address to continue at after eventually re-enabling MMU
64 _GLOBAL(kvmppc_hv_entry_trampoline)
66 LOAD_REG_ADDR(r5, kvmppc_hv_entry)
71 mtmsrd r0,1 /* clear RI in MSR */
76 /******************************************************************************
80 *****************************************************************************/
83 * We come in here when wakened from nap mode on a secondary hw thread.
84 * Relocation is off and most register values are lost.
85 * r13 points to the PACA.
87 .globl kvm_start_guest
89 ld r1,PACAEMERGSP(r13)
90 subi r1,r1,STACK_FRAME_OVERHEAD
93 li r0,KVM_HWTHREAD_IN_KVM
94 stb r0,HSTATE_HWTHREAD_STATE(r13)
96 /* NV GPR values from power7_idle() will no longer be valid */
98 stb r0,PACA_NAPSTATELOST(r13)
100 /* were we napping due to cede? */
101 lbz r0,HSTATE_NAPPING(r13)
106 * We weren't napping due to cede, so this must be a secondary
107 * thread being woken up to run a guest, or being woken up due
108 * to a stray IPI. (Or due to some machine check or hypervisor
109 * maintenance interrupt while the core is in KVM.)
112 /* Check the wake reason in SRR1 to see why we got here */
114 rlwinm r3,r3,44-31,0x7 /* extract wake reason field */
115 cmpwi r3,4 /* was it an external interrupt? */
117 ld r5,HSTATE_XICS_PHYS(r13)
118 li r7,XICS_XIRR /* if it was an external interrupt, */
119 lwzcix r8,r5,r7 /* get and ack the interrupt */
121 clrldi. r9,r8,40 /* get interrupt source ID. */
122 beq 28f /* none there? */
123 cmpwi r9,XICS_IPI /* was it an IPI? */
127 stbcix r0,r5,r6 /* clear IPI */
128 stwcix r8,r5,r7 /* EOI the interrupt */
129 sync /* order loading of vcpu after that */
131 /* get vcpu pointer, NULL if we have no vcpu to run */
132 ld r4,HSTATE_KVM_VCPU(r13)
134 /* if we have no vcpu to run, go back to sleep */
138 27: /* XXX should handle hypervisor maintenance interrupts etc. here */
140 28: /* SRR1 said external but ICP said nope?? */
142 29: /* External non-IPI interrupt to offline secondary thread? help?? */
143 stw r8,HSTATE_SAVED_XIRR(r13)
146 .global kvmppc_hv_entry
155 * all other volatile GPRS = free
158 std r0, HSTATE_VMHANDLER(r13)
160 /* Set partition DABR */
161 /* Do this before re-enabling PMU to avoid P7 DABR corruption bug */
168 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
170 /* Load guest PMU registers */
171 /* R4 is live here (vcpu pointer) */
173 sldi r3, r3, 31 /* MMCR0_FC (freeze counters) bit */
174 mtspr SPRN_MMCR0, r3 /* freeze all counters, disable ints */
176 lwz r3, VCPU_PMC(r4) /* always load up guest PMU registers */
177 lwz r5, VCPU_PMC + 4(r4) /* to prevent information leak */
178 lwz r6, VCPU_PMC + 8(r4)
179 lwz r7, VCPU_PMC + 12(r4)
180 lwz r8, VCPU_PMC + 16(r4)
181 lwz r9, VCPU_PMC + 20(r4)
183 lwz r10, VCPU_PMC + 24(r4)
184 lwz r11, VCPU_PMC + 28(r4)
185 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201)
195 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201)
197 ld r5, VCPU_MMCR + 8(r4)
198 ld r6, VCPU_MMCR + 16(r4)
204 /* Load up FP, VMX and VSX registers */
207 ld r14, VCPU_GPR(R14)(r4)
208 ld r15, VCPU_GPR(R15)(r4)
209 ld r16, VCPU_GPR(R16)(r4)
210 ld r17, VCPU_GPR(R17)(r4)
211 ld r18, VCPU_GPR(R18)(r4)
212 ld r19, VCPU_GPR(R19)(r4)
213 ld r20, VCPU_GPR(R20)(r4)
214 ld r21, VCPU_GPR(R21)(r4)
215 ld r22, VCPU_GPR(R22)(r4)
216 ld r23, VCPU_GPR(R23)(r4)
217 ld r24, VCPU_GPR(R24)(r4)
218 ld r25, VCPU_GPR(R25)(r4)
219 ld r26, VCPU_GPR(R26)(r4)
220 ld r27, VCPU_GPR(R27)(r4)
221 ld r28, VCPU_GPR(R28)(r4)
222 ld r29, VCPU_GPR(R29)(r4)
223 ld r30, VCPU_GPR(R30)(r4)
224 ld r31, VCPU_GPR(R31)(r4)
227 /* Switch DSCR to guest value */
230 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
233 * Set the decrementer to the guest decrementer.
235 ld r8,VCPU_DEC_EXPIRES(r4)
241 ld r5, VCPU_SPRG0(r4)
242 ld r6, VCPU_SPRG1(r4)
243 ld r7, VCPU_SPRG2(r4)
244 ld r8, VCPU_SPRG3(r4)
250 /* Save R1 in the PACA */
251 std r1, HSTATE_HOST_R1(r13)
253 /* Increment yield count if they have a VPA */
257 lwz r5, LPPACA_YIELDCOUNT(r3)
259 stw r5, LPPACA_YIELDCOUNT(r3)
261 stb r6, VCPU_VPA_DIRTY(r4)
263 /* Load up DAR and DSISR */
265 lwz r6, VCPU_DSISR(r4)
270 /* Restore AMR and UAMOR, set AMOR to all 1s */
277 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
287 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201)
289 * POWER7 host -> guest partition switch code.
290 * We don't have to lock against concurrent tlbies,
291 * but we do have to coordinate across hardware threads.
293 /* Increment entry count iff exit count is zero. */
294 ld r5,HSTATE_KVM_VCORE(r13)
295 addi r9,r5,VCORE_ENTRY_EXIT
297 cmpwi r3,0x100 /* any threads starting to exit? */
298 bge secondary_too_late /* if so we're too late to the party */
303 /* Primary thread switches to guest partition. */
304 ld r9,VCPU_KVM(r4) /* pointer to struct kvm */
310 li r0,LPID_RSVD /* switch to reserved LPID */
313 mtspr SPRN_SDR1,r6 /* switch to partition page table */
317 /* See if we need to flush the TLB */
318 lhz r6,PACAPACAINDEX(r13) /* test_bit(cpu, need_tlb_flush) */
319 clrldi r7,r6,64-6 /* extract bit number (6 bits) */
320 srdi r6,r6,6 /* doubleword number */
321 sldi r6,r6,3 /* address offset */
323 addi r6,r6,KVM_NEED_FLUSH /* dword in kvm->arch.need_tlb_flush */
329 23: ldarx r7,0,r6 /* if set, clear the bit */
333 li r6,128 /* and flush the TLB */
335 li r7,0x800 /* IS field = 0b10 */
343 stb r0,VCORE_IN_GUEST(r5) /* signal secondaries to continue */
346 /* Secondary threads wait for primary to have done partition switch */
347 20: lbz r0,VCORE_IN_GUEST(r5)
351 /* Set LPCR and RMOR. */
352 10: ld r8,KVM_LPCR(r9)
358 /* Check if HDEC expires soon */
361 li r12,BOOK3S_INTERRUPT_HV_DECREMENTER
365 /* Save purr/spurr */
368 std r5,HSTATE_PURR(r13)
369 std r6,HSTATE_SPURR(r13)
377 * PPC970 host -> guest partition switch code.
378 * We have to lock against concurrent tlbies,
379 * using native_tlbie_lock to lock against host tlbies
380 * and kvm->arch.tlbie_lock to lock against guest tlbies.
381 * We also have to invalidate the TLB since its
382 * entries aren't tagged with the LPID.
384 30: ld r9,VCPU_KVM(r4) /* pointer to struct kvm */
386 /* first take native_tlbie_lock */
389 .tc native_tlbie_lock[TC],native_tlbie_lock
391 ld r3,toc_tlbie_lock@toc(2)
392 lwz r8,PACA_LOCK_TOKEN(r13)
400 ld r7,KVM_LPCR(r9) /* use kvm->arch.lpcr to store HID4 */
402 rotldi r0,r0,HID4_LPID5_SH /* all lpid bits in HID4 = 1 */
406 mtspr SPRN_HID4,r0 /* switch to reserved LPID */
409 stw r0,0(r3) /* drop native_tlbie_lock */
411 /* invalidate the whole TLB */
420 /* Take the guest's tlbie_lock */
421 addi r3,r9,KVM_TLBIE_LOCK
429 mtspr SPRN_SDR1,r6 /* switch to partition page table */
431 /* Set up HID4 with the guest's LPID etc. */
436 /* drop the guest's tlbie_lock */
440 /* Check if HDEC expires soon */
443 li r12,BOOK3S_INTERRUPT_HV_DECREMENTER
447 /* Enable HDEC interrupts */
450 rldimi r0,r3, HID0_HDICE_SH, 64-HID0_HDICE_SH-1
460 /* Load up guest SLB entries */
461 31: lwz r5,VCPU_SLB_MAX(r4)
466 1: ld r8,VCPU_SLB_E(r6)
469 addi r6,r6,VCPU_SLB_SIZE
473 /* Restore state of CTRL run bit; assume 1 on entry */
489 kvmppc_cede_reentry: /* r4 = vcpu, r13 = paca */
493 /* r11 = vcpu->arch.msr & ~MSR_HV */
494 rldicl r11, r11, 63 - MSR_HV_LG, 1
495 rotldi r11, r11, 1 + MSR_HV_LG
498 /* Check if we can deliver an external or decrementer interrupt now */
499 ld r0,VCPU_PENDING_EXC(r4)
500 lis r8,(1 << BOOK3S_IRQPRIO_EXTERNAL_LEVEL)@h
510 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
512 li r0,BOOK3S_INTERRUPT_EXTERNAL
516 li r11,(MSR_ME << 1) | 1 /* synthesize MSR_SF | MSR_ME */
522 li r0,BOOK3S_INTERRUPT_DECREMENTER
525 /* Move SRR0 and SRR1 into the respective regs */
526 5: mtspr SPRN_SRR0, r6
531 stb r0,VCPU_CEDED(r4) /* cancel cede */
535 /* Activate guest mode, so faults get handled by KVM */
536 li r9, KVM_GUEST_MODE_GUEST
537 stb r9, HSTATE_IN_GUEST(r13)
544 END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
551 ld r0, VCPU_GPR(R0)(r4)
552 ld r1, VCPU_GPR(R1)(r4)
553 ld r2, VCPU_GPR(R2)(r4)
554 ld r3, VCPU_GPR(R3)(r4)
555 ld r5, VCPU_GPR(R5)(r4)
556 ld r6, VCPU_GPR(R6)(r4)
557 ld r7, VCPU_GPR(R7)(r4)
558 ld r8, VCPU_GPR(R8)(r4)
559 ld r9, VCPU_GPR(R9)(r4)
560 ld r10, VCPU_GPR(R10)(r4)
561 ld r11, VCPU_GPR(R11)(r4)
562 ld r12, VCPU_GPR(R12)(r4)
563 ld r13, VCPU_GPR(R13)(r4)
565 ld r4, VCPU_GPR(R4)(r4)
570 /******************************************************************************
574 *****************************************************************************/
577 * We come here from the first-level interrupt handlers.
579 .globl kvmppc_interrupt
583 * R12 = interrupt vector
585 * guest CR, R12 saved in shadow VCPU SCRATCH1/0
586 * guest R13 saved in SPRN_SCRATCH0
588 /* abuse host_r2 as third scratch area; we get r2 from PACATOC(r13) */
589 std r9, HSTATE_HOST_R2(r13)
590 ld r9, HSTATE_KVM_VCPU(r13)
594 std r0, VCPU_GPR(R0)(r9)
595 std r1, VCPU_GPR(R1)(r9)
596 std r2, VCPU_GPR(R2)(r9)
597 std r3, VCPU_GPR(R3)(r9)
598 std r4, VCPU_GPR(R4)(r9)
599 std r5, VCPU_GPR(R5)(r9)
600 std r6, VCPU_GPR(R6)(r9)
601 std r7, VCPU_GPR(R7)(r9)
602 std r8, VCPU_GPR(R8)(r9)
603 ld r0, HSTATE_HOST_R2(r13)
604 std r0, VCPU_GPR(R9)(r9)
605 std r10, VCPU_GPR(R10)(r9)
606 std r11, VCPU_GPR(R11)(r9)
607 ld r3, HSTATE_SCRATCH0(r13)
608 lwz r4, HSTATE_SCRATCH1(r13)
609 std r3, VCPU_GPR(R12)(r9)
612 ld r3, HSTATE_CFAR(r13)
613 std r3, VCPU_CFAR(r9)
614 END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
616 /* Restore R1/R2 so we can handle faults */
617 ld r1, HSTATE_HOST_R1(r13)
622 std r10, VCPU_SRR0(r9)
623 std r11, VCPU_SRR1(r9)
624 andi. r0, r12, 2 /* need to read HSRR0/1? */
626 mfspr r10, SPRN_HSRR0
627 mfspr r11, SPRN_HSRR1
629 1: std r10, VCPU_PC(r9)
630 std r11, VCPU_MSR(r9)
634 std r3, VCPU_GPR(R13)(r9)
637 /* Unset guest mode */
638 li r0, KVM_GUEST_MODE_NONE
639 stb r0, HSTATE_IN_GUEST(r13)
641 stw r12,VCPU_TRAP(r9)
643 /* Save HEIR (HV emulation assist reg) in last_inst
644 if this is an HEI (HV emulation interrupt, e40) */
645 li r3,KVM_INST_FETCH_FAILED
647 cmpwi r12,BOOK3S_INTERRUPT_H_EMUL_ASSIST
650 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
651 11: stw r3,VCPU_LAST_INST(r9)
653 /* these are volatile across C function calls */
660 /* If this is a page table miss then see if it's theirs or ours */
661 cmpwi r12, BOOK3S_INTERRUPT_H_DATA_STORAGE
663 cmpwi r12, BOOK3S_INTERRUPT_H_INST_STORAGE
665 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
667 /* See if this is a leftover HDEC interrupt */
668 cmpwi r12,BOOK3S_INTERRUPT_HV_DECREMENTER
674 /* See if this is an hcall we can handle in real mode */
675 cmpwi r12,BOOK3S_INTERRUPT_SYSCALL
676 beq hcall_try_real_mode
678 /* Only handle external interrupts here on arch 206 and later */
680 b ext_interrupt_to_host
681 END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_206)
683 /* External interrupt ? */
684 cmpwi r12, BOOK3S_INTERRUPT_EXTERNAL
685 bne+ ext_interrupt_to_host
687 /* External interrupt, first check for host_ipi. If this is
688 * set, we know the host wants us out so let's do it now
691 lbz r0, HSTATE_HOST_IPI(r13)
693 bne ext_interrupt_to_host
695 /* Now read the interrupt from the ICP */
696 ld r5, HSTATE_XICS_PHYS(r13)
699 beq- ext_interrupt_to_host
701 rlwinm. r0, r3, 0, 0xffffff
703 beq 3f /* if nothing pending in the ICP */
705 /* We found something in the ICP...
707 * If it's not an IPI, stash it in the PACA and return to
708 * the host, we don't (yet) handle directing real external
709 * interrupts directly to the guest
712 bne ext_stash_for_host
714 /* It's an IPI, clear the MFRR and EOI it */
717 stbcix r0, r5, r6 /* clear the IPI */
718 stwcix r3, r5, r7 /* EOI it */
721 /* We need to re-check host IPI now in case it got set in the
722 * meantime. If it's clear, we bounce the interrupt to the
725 lbz r0, HSTATE_HOST_IPI(r13)
729 /* Allright, looks like an IPI for the guest, we need to set MER */
731 /* Check if any CPU is heading out to the host, if so head out too */
732 ld r5, HSTATE_KVM_VCORE(r13)
733 lwz r0, VCORE_ENTRY_EXIT(r5)
735 bge ext_interrupt_to_host
737 /* See if there is a pending interrupt for the guest */
739 ld r0, VCPU_PENDING_EXC(r9)
740 /* Insert EXTERNAL_LEVEL bit into LPCR at the MER bit position */
741 rldicl. r0, r0, 64 - BOOK3S_IRQPRIO_EXTERNAL_LEVEL, 63
742 rldimi r8, r0, LPCR_MER_SH, 63 - LPCR_MER_SH
745 /* And if the guest EE is set, we can deliver immediately, else
746 * we return to the guest with MER set
748 andi. r0, r11, MSR_EE
752 li r10, BOOK3S_INTERRUPT_EXTERNAL
753 li r11, (MSR_ME << 1) | 1 /* synthesize MSR_SF | MSR_ME */
759 /* We raced with the host, we need to resend that IPI, bummer */
760 1: li r0, IPI_PRIORITY
761 stbcix r0, r5, r6 /* set the IPI */
763 b ext_interrupt_to_host
766 /* It's not an IPI and it's for the host, stash it in the PACA
767 * before exit, it will be picked up by the host ICP driver
769 stw r3, HSTATE_SAVED_XIRR(r13)
770 ext_interrupt_to_host:
772 guest_exit_cont: /* r9 = vcpu, r12 = trap, r13 = paca */
778 std r5,VCPU_DEC_EXPIRES(r9)
780 /* Save more register state */
784 stw r7, VCPU_DSISR(r9)
786 /* don't overwrite fault_dar/fault_dsisr if HDSI */
787 cmpwi r12,BOOK3S_INTERRUPT_H_DATA_STORAGE
789 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
790 std r6, VCPU_FAULT_DAR(r9)
791 stw r7, VCPU_FAULT_DSISR(r9)
793 /* See if it is a machine check */
794 cmpwi r12, BOOK3S_INTERRUPT_MACHINE_CHECK
795 beq machine_check_realmode
798 /* Save guest CTRL register, set runlatch to 1 */
799 6: mfspr r6,SPRN_CTRLF
806 /* Read the guest SLB and save it away */
807 lwz r0,VCPU_SLB_NR(r9) /* number of entries in SLB */
813 andis. r0,r8,SLB_ESID_V@h
815 add r8,r8,r6 /* put index in */
817 std r8,VCPU_SLB_E(r7)
818 std r3,VCPU_SLB_V(r7)
819 addi r7,r7,VCPU_SLB_SIZE
823 stw r5,VCPU_SLB_MAX(r9)
826 * Save the guest PURR/SPURR
834 std r6,VCPU_SPURR(r9)
839 * Restore host PURR/SPURR and add guest times
840 * so that the time in the guest gets accounted.
842 ld r3,HSTATE_PURR(r13)
843 ld r4,HSTATE_SPURR(r13)
848 END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_201)
856 hdec_soon: /* r9 = vcpu, r12 = trap, r13 = paca */
859 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201)
861 * POWER7 guest -> host partition switch code.
862 * We don't have to lock against tlbies but we do
863 * have to coordinate the hardware threads.
865 /* Increment the threads-exiting-guest count in the 0xff00
866 bits of vcore->entry_exit_count */
868 ld r5,HSTATE_KVM_VCORE(r13)
869 addi r6,r5,VCORE_ENTRY_EXIT
877 * At this point we have an interrupt that we have to pass
878 * up to the kernel or qemu; we can't handle it in real mode.
879 * Thus we have to do a partition switch, so we have to
880 * collect the other threads, if we are the first thread
881 * to take an interrupt. To do this, we set the HDEC to 0,
882 * which causes an HDEC interrupt in all threads within 2ns
883 * because the HDEC register is shared between all 4 threads.
884 * However, we don't need to bother if this is an HDEC
885 * interrupt, since the other threads will already be on their
886 * way here in that case.
888 cmpwi r3,0x100 /* Are we the first here? */
890 cmpwi r3,1 /* Are any other threads in the guest? */
892 cmpwi r12,BOOK3S_INTERRUPT_HV_DECREMENTER
898 * Send an IPI to any napping threads, since an HDEC interrupt
899 * doesn't wake CPUs up from nap.
901 lwz r3,VCORE_NAPPING_THREADS(r5)
905 andc. r3,r3,r0 /* no sense IPI'ing ourselves */
907 mulli r4,r4,PACA_SIZE /* get paca for thread 0 */
911 ld r8,HSTATE_XICS_PHYS(r6) /* get thread's XICS reg addr */
914 stbcix r0,r7,r8 /* trigger the IPI */
919 /* Secondary threads wait for primary to do partition switch */
920 43: ld r4,VCPU_KVM(r9) /* pointer to struct kvm */
921 ld r5,HSTATE_KVM_VCORE(r13)
926 13: lbz r3,VCORE_IN_GUEST(r5)
932 /* Primary thread waits for all the secondaries to exit guest */
933 15: lwz r3,VCORE_ENTRY_EXIT(r5)
940 /* Primary thread switches back to host partition */
941 ld r6,KVM_HOST_SDR1(r4)
942 lwz r7,KVM_HOST_LPID(r4)
943 li r8,LPID_RSVD /* switch to reserved LPID */
946 mtspr SPRN_SDR1,r6 /* switch to partition page table */
950 stb r0,VCORE_IN_GUEST(r5)
951 lis r8,0x7fff /* MAX_INT@h */
954 16: ld r8,KVM_HOST_LPCR(r4)
960 * PPC970 guest -> host partition switch code.
961 * We have to lock against concurrent tlbies, and
962 * we have to flush the whole TLB.
964 32: ld r4,VCPU_KVM(r9) /* pointer to struct kvm */
966 /* Take the guest's tlbie_lock */
967 lwz r8,PACA_LOCK_TOKEN(r13)
968 addi r3,r4,KVM_TLBIE_LOCK
976 ld r7,KVM_HOST_LPCR(r4) /* use kvm->arch.host_lpcr for HID4 */
978 rotldi r0,r0,HID4_LPID5_SH /* all lpid bits in HID4 = 1 */
982 mtspr SPRN_HID4,r0 /* switch to reserved LPID */
985 stw r0,0(r3) /* drop guest tlbie_lock */
987 /* invalidate the whole TLB */
996 /* take native_tlbie_lock */
997 ld r3,toc_tlbie_lock@toc(2)
1005 ld r6,KVM_HOST_SDR1(r4)
1006 mtspr SPRN_SDR1,r6 /* switch to host page table */
1008 /* Set up host HID4 value */
1013 stw r0,0(r3) /* drop native_tlbie_lock */
1015 lis r8,0x7fff /* MAX_INT@h */
1018 /* Disable HDEC interrupts */
1021 rldimi r0,r3, HID0_HDICE_SH, 64-HID0_HDICE_SH-1
1031 /* load host SLB entries */
1032 33: ld r8,PACA_SLBSHADOWPTR(r13)
1034 .rept SLB_NUM_BOLTED
1035 ld r5,SLBSHADOW_SAVEAREA(r8)
1036 ld r6,SLBSHADOW_SAVEAREA+8(r8)
1037 andis. r7,r5,SLB_ESID_V@h
1043 /* Save and reset AMR and UAMOR before turning on the MMU */
1048 std r6,VCPU_UAMOR(r9)
1051 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
1053 /* Switch DSCR back to host value */
1056 ld r7, HSTATE_DSCR(r13)
1057 std r8, VCPU_DSCR(r9)
1059 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
1061 /* Save non-volatile GPRs */
1062 std r14, VCPU_GPR(R14)(r9)
1063 std r15, VCPU_GPR(R15)(r9)
1064 std r16, VCPU_GPR(R16)(r9)
1065 std r17, VCPU_GPR(R17)(r9)
1066 std r18, VCPU_GPR(R18)(r9)
1067 std r19, VCPU_GPR(R19)(r9)
1068 std r20, VCPU_GPR(R20)(r9)
1069 std r21, VCPU_GPR(R21)(r9)
1070 std r22, VCPU_GPR(R22)(r9)
1071 std r23, VCPU_GPR(R23)(r9)
1072 std r24, VCPU_GPR(R24)(r9)
1073 std r25, VCPU_GPR(R25)(r9)
1074 std r26, VCPU_GPR(R26)(r9)
1075 std r27, VCPU_GPR(R27)(r9)
1076 std r28, VCPU_GPR(R28)(r9)
1077 std r29, VCPU_GPR(R29)(r9)
1078 std r30, VCPU_GPR(R30)(r9)
1079 std r31, VCPU_GPR(R31)(r9)
1082 mfspr r3, SPRN_SPRG0
1083 mfspr r4, SPRN_SPRG1
1084 mfspr r5, SPRN_SPRG2
1085 mfspr r6, SPRN_SPRG3
1086 std r3, VCPU_SPRG0(r9)
1087 std r4, VCPU_SPRG1(r9)
1088 std r5, VCPU_SPRG2(r9)
1089 std r6, VCPU_SPRG3(r9)
1095 /* Increment yield count if they have a VPA */
1096 ld r8, VCPU_VPA(r9) /* do they have a VPA? */
1099 lwz r3, LPPACA_YIELDCOUNT(r8)
1101 stw r3, LPPACA_YIELDCOUNT(r8)
1103 stb r3, VCPU_VPA_DIRTY(r9)
1105 /* Save PMU registers if requested */
1106 /* r8 and cr0.eq are live here */
1108 sldi r3, r3, 31 /* MMCR0_FC (freeze counters) bit */
1109 mfspr r4, SPRN_MMCR0 /* save MMCR0 */
1110 mtspr SPRN_MMCR0, r3 /* freeze all counters, disable ints */
1111 mfspr r6, SPRN_MMCRA
1113 /* On P7, clear MMCRA in order to disable SDAR updates */
1115 mtspr SPRN_MMCRA, r7
1116 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
1118 beq 21f /* if no VPA, save PMU stuff anyway */
1119 lbz r7, LPPACA_PMCINUSE(r8)
1120 cmpwi r7, 0 /* did they ask for PMU stuff to be saved? */
1122 std r3, VCPU_MMCR(r9) /* if not, set saved MMCR0 to FC */
1124 21: mfspr r5, SPRN_MMCR1
1125 std r4, VCPU_MMCR(r9)
1126 std r5, VCPU_MMCR + 8(r9)
1127 std r6, VCPU_MMCR + 16(r9)
1135 mfspr r10, SPRN_PMC7
1136 mfspr r11, SPRN_PMC8
1137 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201)
1138 stw r3, VCPU_PMC(r9)
1139 stw r4, VCPU_PMC + 4(r9)
1140 stw r5, VCPU_PMC + 8(r9)
1141 stw r6, VCPU_PMC + 12(r9)
1142 stw r7, VCPU_PMC + 16(r9)
1143 stw r8, VCPU_PMC + 20(r9)
1145 stw r10, VCPU_PMC + 24(r9)
1146 stw r11, VCPU_PMC + 28(r9)
1147 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201)
1150 /* Secondary threads go off to take a nap on POWER7 */
1152 lwz r0,VCPU_PTID(r9)
1155 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
1157 /* Restore host DABR and DABRX */
1158 ld r5,HSTATE_DABR(r13)
1164 ld r3,PACA_SPRG3(r13)
1168 * Reload DEC. HDEC interrupts were disabled when
1169 * we reloaded the host's LPCR value.
1171 ld r3, HSTATE_DECEXP(r13)
1176 /* Reload the host's PMU registers */
1177 ld r3, PACALPPACAPTR(r13) /* is the host using the PMU? */
1178 lbz r4, LPPACA_PMCINUSE(r3)
1180 beq 23f /* skip if not */
1181 lwz r3, HSTATE_PMC(r13)
1182 lwz r4, HSTATE_PMC + 4(r13)
1183 lwz r5, HSTATE_PMC + 8(r13)
1184 lwz r6, HSTATE_PMC + 12(r13)
1185 lwz r8, HSTATE_PMC + 16(r13)
1186 lwz r9, HSTATE_PMC + 20(r13)
1188 lwz r10, HSTATE_PMC + 24(r13)
1189 lwz r11, HSTATE_PMC + 28(r13)
1190 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201)
1198 mtspr SPRN_PMC7, r10
1199 mtspr SPRN_PMC8, r11
1200 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201)
1201 ld r3, HSTATE_MMCR(r13)
1202 ld r4, HSTATE_MMCR + 8(r13)
1203 ld r5, HSTATE_MMCR + 16(r13)
1204 mtspr SPRN_MMCR1, r4
1205 mtspr SPRN_MMCRA, r5
1206 mtspr SPRN_MMCR0, r3
1210 * For external and machine check interrupts, we need
1211 * to call the Linux handler to process the interrupt.
1212 * We do that by jumping to absolute address 0x500 for
1213 * external interrupts, or the machine_check_fwnmi label
1214 * for machine checks (since firmware might have patched
1215 * the vector area at 0x200). The [h]rfid at the end of the
1216 * handler will return to the book3s_hv_interrupts.S code.
1217 * For other interrupts we do the rfid to get back
1218 * to the book3s_hv_interrupts.S code here.
1220 ld r8, HSTATE_VMHANDLER(r13)
1221 ld r7, HSTATE_HOST_MSR(r13)
1223 cmpwi cr1, r12, BOOK3S_INTERRUPT_MACHINE_CHECK
1224 cmpwi r12, BOOK3S_INTERRUPT_EXTERNAL
1227 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
1229 /* RFI into the highmem handler, or branch to interrupt handler */
1233 mtmsrd r6, 1 /* Clear RI in MSR */
1236 beqa 0x500 /* external interrupt (PPC970) */
1237 beq cr1, 13f /* machine check */
1240 /* On POWER7, we have external interrupts set to use HSRR0/1 */
1241 11: mtspr SPRN_HSRR0, r8
1242 mtspr SPRN_HSRR1, r7
1245 13: b machine_check_fwnmi
1248 * Check whether an HDSI is an HPTE not found fault or something else.
1249 * If it is an HPTE not found fault that is due to the guest accessing
1250 * a page that they have mapped but which we have paged out, then
1251 * we continue on with the guest exit path. In all other cases,
1252 * reflect the HDSI to the guest as a DSI.
1256 mfspr r6, SPRN_HDSISR
1257 /* HPTE not found fault or protection fault? */
1258 andis. r0, r6, (DSISR_NOHPTE | DSISR_PROTFAULT)@h
1259 beq 1f /* if not, send it to the guest */
1260 andi. r0, r11, MSR_DR /* data relocation enabled? */
1263 PPC_SLBFEE_DOT(R5, R0) /* if so, look up SLB */
1264 bne 1f /* if no SLB entry found */
1265 4: std r4, VCPU_FAULT_DAR(r9)
1266 stw r6, VCPU_FAULT_DSISR(r9)
1268 /* Search the hash table. */
1269 mr r3, r9 /* vcpu pointer */
1270 li r7, 1 /* data fault */
1271 bl .kvmppc_hpte_hv_fault
1272 ld r9, HSTATE_KVM_VCPU(r13)
1274 ld r11, VCPU_MSR(r9)
1275 li r12, BOOK3S_INTERRUPT_H_DATA_STORAGE
1276 cmpdi r3, 0 /* retry the instruction */
1278 cmpdi r3, -1 /* handle in kernel mode */
1280 cmpdi r3, -2 /* MMIO emulation; need instr word */
1283 /* Synthesize a DSI for the guest */
1284 ld r4, VCPU_FAULT_DAR(r9)
1286 1: mtspr SPRN_DAR, r4
1287 mtspr SPRN_DSISR, r6
1288 mtspr SPRN_SRR0, r10
1289 mtspr SPRN_SRR1, r11
1290 li r10, BOOK3S_INTERRUPT_DATA_STORAGE
1291 li r11, (MSR_ME << 1) | 1 /* synthesize MSR_SF | MSR_ME */
1293 fast_interrupt_c_return:
1294 6: ld r7, VCPU_CTR(r9)
1295 lwz r8, VCPU_XER(r9)
1301 3: ld r5, VCPU_KVM(r9) /* not relocated, use VRMA */
1302 ld r5, KVM_VRMA_SLB_V(r5)
1305 /* If this is for emulated MMIO, load the instruction word */
1306 2: li r8, KVM_INST_FETCH_FAILED /* In case lwz faults */
1308 /* Set guest mode to 'jump over instruction' so if lwz faults
1309 * we'll just continue at the next IP. */
1310 li r0, KVM_GUEST_MODE_SKIP
1311 stb r0, HSTATE_IN_GUEST(r13)
1313 /* Do the access with MSR:DR enabled */
1315 ori r4, r3, MSR_DR /* Enable paging for data */
1320 /* Store the result */
1321 stw r8, VCPU_LAST_INST(r9)
1323 /* Unset guest mode. */
1324 li r0, KVM_GUEST_MODE_NONE
1325 stb r0, HSTATE_IN_GUEST(r13)
1329 * Similarly for an HISI, reflect it to the guest as an ISI unless
1330 * it is an HPTE not found fault for a page that we have paged out.
1333 andis. r0, r11, SRR1_ISI_NOPT@h
1335 andi. r0, r11, MSR_IR /* instruction relocation enabled? */
1338 PPC_SLBFEE_DOT(R5, R0) /* if so, look up SLB */
1339 bne 1f /* if no SLB entry found */
1341 /* Search the hash table. */
1342 mr r3, r9 /* vcpu pointer */
1345 li r7, 0 /* instruction fault */
1346 bl .kvmppc_hpte_hv_fault
1347 ld r9, HSTATE_KVM_VCPU(r13)
1349 ld r11, VCPU_MSR(r9)
1350 li r12, BOOK3S_INTERRUPT_H_INST_STORAGE
1351 cmpdi r3, 0 /* retry the instruction */
1352 beq fast_interrupt_c_return
1353 cmpdi r3, -1 /* handle in kernel mode */
1356 /* Synthesize an ISI for the guest */
1358 1: mtspr SPRN_SRR0, r10
1359 mtspr SPRN_SRR1, r11
1360 li r10, BOOK3S_INTERRUPT_INST_STORAGE
1361 li r11, (MSR_ME << 1) | 1 /* synthesize MSR_SF | MSR_ME */
1363 b fast_interrupt_c_return
1365 3: ld r6, VCPU_KVM(r9) /* not relocated, use VRMA */
1366 ld r5, KVM_VRMA_SLB_V(r6)
1370 * Try to handle an hcall in real mode.
1371 * Returns to the guest if we handle it, or continues on up to
1372 * the kernel if we can't (i.e. if we don't have a handler for
1373 * it, or if the handler returns H_TOO_HARD).
1375 .globl hcall_try_real_mode
1376 hcall_try_real_mode:
1377 ld r3,VCPU_GPR(R3)(r9)
1381 cmpldi r3,hcall_real_table_end - hcall_real_table
1383 LOAD_REG_ADDR(r4, hcall_real_table)
1389 mr r3,r9 /* get vcpu pointer */
1390 ld r4,VCPU_GPR(R4)(r9)
1393 beq hcall_real_fallback
1394 ld r4,HSTATE_KVM_VCPU(r13)
1395 std r3,VCPU_GPR(R3)(r4)
1400 /* We've attempted a real mode hcall, but it's punted it back
1401 * to userspace. We need to restore some clobbered volatiles
1402 * before resuming the pass-it-to-qemu path */
1403 hcall_real_fallback:
1404 li r12,BOOK3S_INTERRUPT_SYSCALL
1405 ld r9, HSTATE_KVM_VCPU(r13)
1409 .globl hcall_real_table
1411 .long 0 /* 0 - unused */
1412 .long .kvmppc_h_remove - hcall_real_table
1413 .long .kvmppc_h_enter - hcall_real_table
1414 .long .kvmppc_h_read - hcall_real_table
1415 .long 0 /* 0x10 - H_CLEAR_MOD */
1416 .long 0 /* 0x14 - H_CLEAR_REF */
1417 .long .kvmppc_h_protect - hcall_real_table
1418 .long 0 /* 0x1c - H_GET_TCE */
1419 .long .kvmppc_h_put_tce - hcall_real_table
1420 .long 0 /* 0x24 - H_SET_SPRG0 */
1421 .long .kvmppc_h_set_dabr - hcall_real_table
1436 #ifdef CONFIG_KVM_XICS
1437 .long .kvmppc_rm_h_eoi - hcall_real_table
1438 .long .kvmppc_rm_h_cppr - hcall_real_table
1439 .long .kvmppc_rm_h_ipi - hcall_real_table
1440 .long 0 /* 0x70 - H_IPOLL */
1441 .long .kvmppc_rm_h_xirr - hcall_real_table
1443 .long 0 /* 0x64 - H_EOI */
1444 .long 0 /* 0x68 - H_CPPR */
1445 .long 0 /* 0x6c - H_IPI */
1446 .long 0 /* 0x70 - H_IPOLL */
1447 .long 0 /* 0x74 - H_XIRR */
1475 .long .kvmppc_h_cede - hcall_real_table
1492 .long .kvmppc_h_bulk_remove - hcall_real_table
1493 hcall_real_table_end:
1499 _GLOBAL(kvmppc_h_set_dabr)
1500 std r4,VCPU_DABR(r3)
1501 /* Work around P7 bug where DABR can get corrupted on mtspr */
1502 1: mtspr SPRN_DABR,r4
1510 _GLOBAL(kvmppc_h_cede)
1512 std r11,VCPU_MSR(r3)
1514 stb r0,VCPU_CEDED(r3)
1515 sync /* order setting ceded vs. testing prodded */
1516 lbz r5,VCPU_PRODDED(r3)
1518 bne kvm_cede_prodded
1519 li r0,0 /* set trap to 0 to say hcall is handled */
1520 stw r0,VCPU_TRAP(r3)
1522 std r0,VCPU_GPR(R3)(r3)
1524 b kvm_cede_exit /* just send it up to host on 970 */
1525 END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_206)
1528 * Set our bit in the bitmask of napping threads unless all the
1529 * other threads are already napping, in which case we send this
1532 ld r5,HSTATE_KVM_VCORE(r13)
1533 lwz r6,VCPU_PTID(r3)
1534 lwz r8,VCORE_ENTRY_EXIT(r5)
1538 addi r6,r5,VCORE_NAPPING_THREADS
1547 stb r0,HSTATE_NAPPING(r13)
1548 /* order napping_threads update vs testing entry_exit_count */
1551 lwz r7,VCORE_ENTRY_EXIT(r5)
1553 bge 33f /* another thread already exiting */
1556 * Although not specifically required by the architecture, POWER7
1557 * preserves the following registers in nap mode, even if an SMT mode
1558 * switch occurs: SLB entries, PURR, SPURR, AMOR, UAMOR, AMR, SPRG0-3,
1559 * DAR, DSISR, DABR, DABRX, DSCR, PMCx, MMCRx, SIAR, SDAR.
1561 /* Save non-volatile GPRs */
1562 std r14, VCPU_GPR(R14)(r3)
1563 std r15, VCPU_GPR(R15)(r3)
1564 std r16, VCPU_GPR(R16)(r3)
1565 std r17, VCPU_GPR(R17)(r3)
1566 std r18, VCPU_GPR(R18)(r3)
1567 std r19, VCPU_GPR(R19)(r3)
1568 std r20, VCPU_GPR(R20)(r3)
1569 std r21, VCPU_GPR(R21)(r3)
1570 std r22, VCPU_GPR(R22)(r3)
1571 std r23, VCPU_GPR(R23)(r3)
1572 std r24, VCPU_GPR(R24)(r3)
1573 std r25, VCPU_GPR(R25)(r3)
1574 std r26, VCPU_GPR(R26)(r3)
1575 std r27, VCPU_GPR(R27)(r3)
1576 std r28, VCPU_GPR(R28)(r3)
1577 std r29, VCPU_GPR(R29)(r3)
1578 std r30, VCPU_GPR(R30)(r3)
1579 std r31, VCPU_GPR(R31)(r3)
1585 * Take a nap until a decrementer or external interrupt occurs,
1586 * with PECE1 (wake on decr) and PECE0 (wake on external) set in LPCR
1589 stb r0,HSTATE_HWTHREAD_REQ(r13)
1591 ori r5,r5,LPCR_PECE0 | LPCR_PECE1
1595 std r0, HSTATE_SCRATCH0(r13)
1597 ld r0, HSTATE_SCRATCH0(r13)
1604 /* get vcpu pointer */
1605 ld r4, HSTATE_KVM_VCPU(r13)
1607 /* Woken by external or decrementer interrupt */
1608 ld r1, HSTATE_HOST_R1(r13)
1610 /* load up FP state */
1614 ld r14, VCPU_GPR(R14)(r4)
1615 ld r15, VCPU_GPR(R15)(r4)
1616 ld r16, VCPU_GPR(R16)(r4)
1617 ld r17, VCPU_GPR(R17)(r4)
1618 ld r18, VCPU_GPR(R18)(r4)
1619 ld r19, VCPU_GPR(R19)(r4)
1620 ld r20, VCPU_GPR(R20)(r4)
1621 ld r21, VCPU_GPR(R21)(r4)
1622 ld r22, VCPU_GPR(R22)(r4)
1623 ld r23, VCPU_GPR(R23)(r4)
1624 ld r24, VCPU_GPR(R24)(r4)
1625 ld r25, VCPU_GPR(R25)(r4)
1626 ld r26, VCPU_GPR(R26)(r4)
1627 ld r27, VCPU_GPR(R27)(r4)
1628 ld r28, VCPU_GPR(R28)(r4)
1629 ld r29, VCPU_GPR(R29)(r4)
1630 ld r30, VCPU_GPR(R30)(r4)
1631 ld r31, VCPU_GPR(R31)(r4)
1633 /* clear our bit in vcore->napping_threads */
1634 33: ld r5,HSTATE_KVM_VCORE(r13)
1635 lwz r3,VCPU_PTID(r4)
1638 addi r6,r5,VCORE_NAPPING_THREADS
1644 stb r0,HSTATE_NAPPING(r13)
1646 /* Check the wake reason in SRR1 to see why we got here */
1648 rlwinm r3, r3, 44-31, 0x7 /* extract wake reason field */
1649 cmpwi r3, 4 /* was it an external interrupt? */
1650 li r12, BOOK3S_INTERRUPT_EXTERNAL
1653 ld r11, VCPU_MSR(r9)
1654 beq do_ext_interrupt /* if so */
1656 /* see if any other thread is already exiting */
1657 lwz r0,VCORE_ENTRY_EXIT(r5)
1659 blt kvmppc_cede_reentry /* if not go back to guest */
1661 /* some threads are exiting, so go to the guest exit path */
1662 b hcall_real_fallback
1664 /* cede when already previously prodded case */
1667 stb r0,VCPU_PRODDED(r3)
1668 sync /* order testing prodded vs. clearing ceded */
1669 stb r0,VCPU_CEDED(r3)
1673 /* we've ceded but we want to give control to the host */
1675 b hcall_real_fallback
1677 /* Try to handle a machine check in real mode */
1678 machine_check_realmode:
1679 mr r3, r9 /* get vcpu pointer */
1680 bl .kvmppc_realmode_machine_check
1682 cmpdi r3, 0 /* continue exiting from guest? */
1683 ld r9, HSTATE_KVM_VCPU(r13)
1684 li r12, BOOK3S_INTERRUPT_MACHINE_CHECK
1686 /* If not, deliver a machine check. SRR0/1 are already set */
1687 li r10, BOOK3S_INTERRUPT_MACHINE_CHECK
1688 li r11, (MSR_ME << 1) | 1 /* synthesize MSR_SF | MSR_ME */
1690 b fast_interrupt_c_return
1693 ld r5,HSTATE_KVM_VCORE(r13)
1695 13: lbz r3,VCORE_IN_GUEST(r5)
1699 ld r11,PACA_SLBSHADOWPTR(r13)
1701 .rept SLB_NUM_BOLTED
1702 ld r5,SLBSHADOW_SAVEAREA(r11)
1703 ld r6,SLBSHADOW_SAVEAREA+8(r11)
1704 andis. r7,r5,SLB_ESID_V@h
1711 /* Clear our vcpu pointer so we don't come back in early */
1713 std r0, HSTATE_KVM_VCPU(r13)
1715 /* Clear any pending IPI - assume we're a secondary thread */
1716 ld r5, HSTATE_XICS_PHYS(r13)
1718 lwzcix r3, r5, r7 /* ack any pending interrupt */
1719 rlwinm. r0, r3, 0, 0xffffff /* any pending? */
1724 stbcix r0, r5, r6 /* clear the IPI */
1725 stwcix r3, r5, r7 /* EOI it */
1728 /* increment the nap count and then go to nap mode */
1729 ld r4, HSTATE_KVM_VCORE(r13)
1730 addi r4, r4, VCORE_NAP_COUNT
1731 lwsync /* make previous updates visible */
1738 li r0, KVM_HWTHREAD_IN_NAP
1739 stb r0, HSTATE_HWTHREAD_STATE(r13)
1743 rlwimi r4, r3, 0, LPCR_PECE0 | LPCR_PECE1
1746 std r0, HSTATE_SCRATCH0(r13)
1748 ld r0, HSTATE_SCRATCH0(r13)
1755 * Save away FP, VMX and VSX registers.
1758 _GLOBAL(kvmppc_save_fp)
1761 #ifdef CONFIG_ALTIVEC
1763 oris r8,r8,MSR_VEC@h
1764 END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
1768 oris r8,r8,MSR_VSX@h
1769 END_FTR_SECTION_IFSET(CPU_FTR_VSX)
1777 li r6,reg*16+VCPU_VSRS
1785 stfd reg,reg*8+VCPU_FPRS(r3)
1789 ALT_FTR_SECTION_END_IFSET(CPU_FTR_VSX)
1792 stfd fr0,VCPU_FPSCR(r3)
1794 #ifdef CONFIG_ALTIVEC
1798 li r6,reg*16+VCPU_VRS
1805 END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
1807 mfspr r6,SPRN_VRSAVE
1808 stw r6,VCPU_VRSAVE(r3)
1814 * Load up FP, VMX and VSX registers
1817 .globl kvmppc_load_fp
1821 #ifdef CONFIG_ALTIVEC
1823 oris r8,r8,MSR_VEC@h
1824 END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
1828 oris r8,r8,MSR_VSX@h
1829 END_FTR_SECTION_IFSET(CPU_FTR_VSX)
1833 lfd fr0,VCPU_FPSCR(r4)
1839 li r7,reg*16+VCPU_VSRS
1847 lfd reg,reg*8+VCPU_FPRS(r4)
1851 ALT_FTR_SECTION_END_IFSET(CPU_FTR_VSX)
1854 #ifdef CONFIG_ALTIVEC
1861 li r7,reg*16+VCPU_VRS
1865 END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
1867 lwz r7,VCPU_VRSAVE(r4)
1868 mtspr SPRN_VRSAVE,r7