Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  *
0004  * Copyright SUSE Linux Products GmbH 2009
0005  *
0006  * Authors: Alexander Graf <agraf@suse.de>
0007  */
0008 
0009 #ifndef __ASM_KVM_BOOK3S_ASM_H__
0010 #define __ASM_KVM_BOOK3S_ASM_H__
0011 
0012 /* XICS ICP register offsets */
0013 #define XICS_XIRR       4
0014 #define XICS_MFRR       0xc
0015 #define XICS_IPI        2   /* interrupt source # for IPIs */
0016 
0017 /* Maximum number of threads per physical core */
0018 #define MAX_SMT_THREADS     8
0019 
0020 /* Maximum number of subcores per physical core */
0021 #define MAX_SUBCORES        4
0022 
0023 #ifdef __ASSEMBLY__
0024 
0025 #ifdef CONFIG_KVM_BOOK3S_HANDLER
0026 
0027 #include <asm/kvm_asm.h>
0028 
0029 .macro DO_KVM intno
0030     .if (\intno == BOOK3S_INTERRUPT_SYSTEM_RESET) || \
0031         (\intno == BOOK3S_INTERRUPT_MACHINE_CHECK) || \
0032         (\intno == BOOK3S_INTERRUPT_DATA_STORAGE) || \
0033         (\intno == BOOK3S_INTERRUPT_INST_STORAGE) || \
0034         (\intno == BOOK3S_INTERRUPT_DATA_SEGMENT) || \
0035         (\intno == BOOK3S_INTERRUPT_INST_SEGMENT) || \
0036         (\intno == BOOK3S_INTERRUPT_EXTERNAL) || \
0037         (\intno == BOOK3S_INTERRUPT_EXTERNAL_HV) || \
0038         (\intno == BOOK3S_INTERRUPT_ALIGNMENT) || \
0039         (\intno == BOOK3S_INTERRUPT_PROGRAM) || \
0040         (\intno == BOOK3S_INTERRUPT_FP_UNAVAIL) || \
0041         (\intno == BOOK3S_INTERRUPT_DECREMENTER) || \
0042         (\intno == BOOK3S_INTERRUPT_SYSCALL) || \
0043         (\intno == BOOK3S_INTERRUPT_TRACE) || \
0044         (\intno == BOOK3S_INTERRUPT_PERFMON) || \
0045         (\intno == BOOK3S_INTERRUPT_ALTIVEC) || \
0046         (\intno == BOOK3S_INTERRUPT_VSX)
0047 
0048     b   kvmppc_trampoline_\intno
0049 kvmppc_resume_\intno:
0050 
0051     .endif
0052 .endm
0053 
0054 #else
0055 
0056 .macro DO_KVM intno
0057 .endm
0058 
0059 #endif /* CONFIG_KVM_BOOK3S_HANDLER */
0060 
0061 #else  /*__ASSEMBLY__ */
0062 
0063 struct kvmppc_vcore;
0064 
0065 /* Struct used for coordinating micro-threading (split-core) mode changes */
0066 struct kvm_split_mode {
0067     unsigned long   rpr;
0068     unsigned long   pmmar;
0069     unsigned long   ldbar;
0070     u8      subcore_size;
0071     u8      do_nap;
0072     u8      napped[MAX_SMT_THREADS];
0073     struct kvmppc_vcore *vc[MAX_SUBCORES];
0074 };
0075 
0076 /*
0077  * This struct goes in the PACA on 64-bit processors.  It is used
0078  * to store host state that needs to be saved when we enter a guest
0079  * and restored when we exit, but isn't specific to any particular
0080  * guest or vcpu.  It also has some scratch fields used by the guest
0081  * exit code.
0082  */
0083 struct kvmppc_host_state {
0084     ulong host_r1;
0085     ulong host_r2;
0086     ulong host_msr;
0087     ulong vmhandler;
0088     ulong scratch0;
0089     ulong scratch1;
0090     ulong scratch2;
0091     u8 in_guest;
0092     u8 restore_hid5;
0093     u8 napping;
0094 
0095 #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
0096     u8 hwthread_req;
0097     u8 hwthread_state;
0098     u8 host_ipi;
0099     u8 ptid;        /* thread number within subcore when split */
0100     u8 fake_suspend;
0101     struct kvm_vcpu *kvm_vcpu;
0102     struct kvmppc_vcore *kvm_vcore;
0103     void __iomem *xics_phys;
0104     void __iomem *xive_tima_phys;
0105     void __iomem *xive_tima_virt;
0106     u32 saved_xirr;
0107     u64 dabr;
0108     u64 host_mmcr[10];  /* MMCR 0,1,A, SIAR, SDAR, MMCR2, SIER, MMCR3, SIER2/3 */
0109     u32 host_pmc[8];
0110     u64 host_purr;
0111     u64 host_spurr;
0112     u64 host_dscr;
0113     u64 dec_expires;
0114     struct kvm_split_mode *kvm_split_mode;
0115 #endif
0116 #ifdef CONFIG_PPC_BOOK3S_64
0117     u64 cfar;
0118     u64 ppr;
0119     u64 host_fscr;
0120 #endif
0121 };
0122 
0123 struct kvmppc_book3s_shadow_vcpu {
0124     bool in_use;
0125     ulong gpr[14];
0126     u32 cr;
0127     ulong xer;
0128     ulong ctr;
0129     ulong lr;
0130     ulong pc;
0131 
0132     ulong shadow_srr1;
0133     ulong fault_dar;
0134     u32 fault_dsisr;
0135     u32 last_inst;
0136 
0137 #ifdef CONFIG_PPC_BOOK3S_32
0138     u32     sr[16];         /* Guest SRs */
0139 
0140     struct kvmppc_host_state hstate;
0141 #endif
0142 
0143 #ifdef CONFIG_PPC_BOOK3S_64
0144     u8 slb_max;         /* highest used guest slb entry */
0145     struct  {
0146         u64     esid;
0147         u64     vsid;
0148     } slb[64];          /* guest SLB */
0149     u64 shadow_fscr;
0150 #endif
0151 };
0152 
0153 #endif /*__ASSEMBLY__ */
0154 
0155 /* Values for kvm_state */
0156 #define KVM_HWTHREAD_IN_KERNEL  0
0157 #define KVM_HWTHREAD_IN_IDLE    1
0158 #define KVM_HWTHREAD_IN_KVM 2
0159 
0160 #endif /* __ASM_KVM_BOOK3S_ASM_H__ */