16 #include <linux/signal.h>
17 #include <linux/sched.h>
18 #include <linux/kernel.h>
19 #include <linux/errno.h>
20 #include <linux/string.h>
21 #include <linux/types.h>
22 #include <linux/mman.h>
25 #include <linux/hrtimer.h>
27 #include <linux/time.h>
34 #include <asm/pgtable.h>
35 #include <asm/processor.h>
36 #include <asm/cputable.h>
37 #include <asm/thread_info.h>
39 #include <asm/vdso_datapage.h>
43 #include <asm/cache.h>
44 #include <asm/compat.h>
49 #ifdef CONFIG_PPC_POWERNV
52 #if defined(CONFIG_KVM) || defined(CONFIG_KVM_GUEST)
55 #if defined(CONFIG_KVM) && defined(CONFIG_PPC_BOOK3S)
60 #if defined(CONFIG_BOOKE) || defined(CONFIG_40x)
65 #if defined(CONFIG_PPC_FSL_BOOK3E)
66 #include "../mm/mmu_decl.h"
107 #if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
117 #ifdef CONFIG_KVM_BOOK3S_32_HANDLER
120 #ifdef CONFIG_KVM_BOOKE_HV
138 DEFINE(PACA_SIZE,
sizeof(
struct paca_struct));
139 DEFINE(PACA_LOCK_TOKEN,
offsetof(
struct paca_struct, lock_token));
150 DEFINE(PACASOFTIRQEN,
offsetof(
struct paca_struct, soft_enabled));
151 DEFINE(PACAIRQHAPPENED,
offsetof(
struct paca_struct, irq_happened));
153 #ifdef CONFIG_PPC_MM_SLICES
161 #ifdef CONFIG_PPC_BOOK3E
170 DEFINE(PACA_CRIT_STACK,
offsetof(
struct paca_struct, crit_kstack));
174 #ifdef CONFIG_PPC_STD_MMU_64
178 DEFINE(PACASLBCACHEPTR,
offsetof(
struct paca_struct, slb_cache_ptr));
179 DEFINE(PACAVMALLOCSLLP,
offsetof(
struct paca_struct, vmalloc_sllp));
180 #ifdef CONFIG_PPC_MM_SLICES
189 DEFINE(PACA_SLBSHADOWPTR,
offsetof(
struct paca_struct, slb_shadow_ptr));
190 DEFINE(SLBSHADOW_STACKVSID,
192 DEFINE(SLBSHADOW_STACKESID,
202 DEFINE(PACAKEXECSTATE,
offsetof(
struct paca_struct, kexec_state));
204 DEFINE(PACA_STARTTIME_USER,
offsetof(
struct paca_struct, starttime_user));
208 DEFINE(PACA_NAPSTATELOST,
offsetof(
struct paca_struct, nap_state_lost));
225 DEFINE(HCALL_STAT_SIZE,
sizeof(
struct hcall_stats));
226 DEFINE(HCALL_STAT_CALLS,
offsetof(
struct hcall_stats, num_calls));
228 DEFINE(HCALL_STAT_PURR,
offsetof(
struct hcall_stats, purr_total));
297 #if defined(CONFIG_PPC32)
298 #if defined(CONFIG_BOOKE) || defined(CONFIG_40x)
382 DEFINE(BUG_ENTRY_SIZE,
sizeof(
struct bug_entry));
396 #ifdef CONFIG_ALTIVEC
408 #ifdef CONFIG_KVM_BOOK3S_64_HV
438 #ifdef CONFIG_KVM_BOOK3S_64_HV
453 #ifdef CONFIG_PPC_BOOK3S
489 #ifdef CONFIG_PPC_BOOK3S_64
490 #ifdef CONFIG_KVM_BOOK3S_PR
491 # define SVCPU_FIELD(x, f) DEFINE(x, offsetof(struct paca_struct, shadow_vcpu.f))
493 # define SVCPU_FIELD(x, f)
495 # define HSTATE_FIELD(x, f) DEFINE(x, offsetof(struct paca_struct, kvm_hstate.f))
497 # define SVCPU_FIELD(x, f) DEFINE(x, offsetof(struct kvmppc_book3s_shadow_vcpu, f))
498 # define HSTATE_FIELD(x, f) DEFINE(x, offsetof(struct kvmppc_book3s_shadow_vcpu, hstate.f))
501 SVCPU_FIELD(SVCPU_CR,
cr);
502 SVCPU_FIELD(SVCPU_XER,
xer);
503 SVCPU_FIELD(SVCPU_CTR,
ctr);
504 SVCPU_FIELD(SVCPU_LR,
lr);
505 SVCPU_FIELD(SVCPU_PC,
pc);
506 SVCPU_FIELD(SVCPU_R0,
gpr[0]);
507 SVCPU_FIELD(SVCPU_R1,
gpr[1]);
508 SVCPU_FIELD(SVCPU_R2,
gpr[2]);
509 SVCPU_FIELD(SVCPU_R3,
gpr[3]);
510 SVCPU_FIELD(SVCPU_R4,
gpr[4]);
511 SVCPU_FIELD(SVCPU_R5,
gpr[5]);
512 SVCPU_FIELD(SVCPU_R6,
gpr[6]);
513 SVCPU_FIELD(SVCPU_R7,
gpr[7]);
514 SVCPU_FIELD(SVCPU_R8,
gpr[8]);
515 SVCPU_FIELD(SVCPU_R9,
gpr[9]);
516 SVCPU_FIELD(SVCPU_R10,
gpr[10]);
517 SVCPU_FIELD(SVCPU_R11,
gpr[11]);
518 SVCPU_FIELD(SVCPU_R12,
gpr[12]);
519 SVCPU_FIELD(SVCPU_R13,
gpr[13]);
520 SVCPU_FIELD(SVCPU_FAULT_DSISR, fault_dsisr);
521 SVCPU_FIELD(SVCPU_FAULT_DAR, fault_dar);
522 SVCPU_FIELD(SVCPU_LAST_INST, last_inst);
523 SVCPU_FIELD(SVCPU_SHADOW_SRR1, shadow_srr1);
524 #ifdef CONFIG_PPC_BOOK3S_32
525 SVCPU_FIELD(SVCPU_SR,
sr);
528 SVCPU_FIELD(SVCPU_SLB, slb);
529 SVCPU_FIELD(SVCPU_SLB_MAX, slb_max);
532 HSTATE_FIELD(HSTATE_HOST_R1, host_r1);
533 HSTATE_FIELD(HSTATE_HOST_R2, host_r2);
534 HSTATE_FIELD(HSTATE_HOST_MSR, host_msr);
535 HSTATE_FIELD(HSTATE_VMHANDLER, vmhandler);
536 HSTATE_FIELD(HSTATE_SCRATCH0,
scratch0);
537 HSTATE_FIELD(HSTATE_SCRATCH1,
scratch1);
538 HSTATE_FIELD(HSTATE_IN_GUEST, in_guest);
539 HSTATE_FIELD(HSTATE_RESTORE_HID5, restore_hid5);
540 HSTATE_FIELD(HSTATE_NAPPING, napping);
542 #ifdef CONFIG_KVM_BOOK3S_64_HV
543 HSTATE_FIELD(HSTATE_HWTHREAD_REQ, hwthread_req);
544 HSTATE_FIELD(HSTATE_HWTHREAD_STATE, hwthread_state);
545 HSTATE_FIELD(HSTATE_KVM_VCPU,
kvm_vcpu);
546 HSTATE_FIELD(HSTATE_KVM_VCORE, kvm_vcore);
547 HSTATE_FIELD(HSTATE_XICS_PHYS, xics_phys);
548 HSTATE_FIELD(HSTATE_MMCR, host_mmcr);
549 HSTATE_FIELD(HSTATE_PMC, host_pmc);
550 HSTATE_FIELD(HSTATE_PURR, host_purr);
551 HSTATE_FIELD(HSTATE_SPURR, host_spurr);
552 HSTATE_FIELD(HSTATE_DSCR, host_dscr);
553 HSTATE_FIELD(HSTATE_DABR, dabr);
554 HSTATE_FIELD(HSTATE_DECEXP, dec_expires);
570 #ifdef CONFIG_KVM_GUEST
589 #ifdef CONFIG_PPC_FSL_BOOK3E
590 DEFINE(TLBCAM_SIZE,
sizeof(
struct tlbcam));
598 #if defined(CONFIG_KVM) && defined(CONFIG_SPE)
605 #ifdef CONFIG_KVM_BOOKE_HV
611 #ifdef CONFIG_KVM_EXIT_TIMING
613 arch.timing_exit.tv32.tbu));
615 arch.timing_exit.tv32.tbl));
617 arch.timing_last_enter.tv32.tbu));
619 arch.timing_last_enter.tv32.tbl));
622 #ifdef CONFIG_PPC_POWERNV
626 DEFINE(PACA_OPAL_MC_EVT,
offsetof(
struct paca_struct, opal_mc_evt));