1 // SPDX-License-Identifier: GPL-2.0-only
4 * Privileged (non-hypervisor) host registers to save.
6 struct p9_host_os_sprs {
28 static inline bool nesting_enabled(struct kvm *kvm)
30 return kvm->arch.nested_enable && kvm_is_radix(kvm);
33 bool load_vcpu_state(struct kvm_vcpu *vcpu,
34 struct p9_host_os_sprs *host_os_sprs);
35 void store_vcpu_state(struct kvm_vcpu *vcpu);
36 void save_p9_host_os_sprs(struct p9_host_os_sprs *host_os_sprs);
37 void restore_p9_host_os_sprs(struct kvm_vcpu *vcpu,
38 struct p9_host_os_sprs *host_os_sprs);
39 void switch_pmu_to_guest(struct kvm_vcpu *vcpu,
40 struct p9_host_os_sprs *host_os_sprs);
41 void switch_pmu_to_host(struct kvm_vcpu *vcpu,
42 struct p9_host_os_sprs *host_os_sprs);
44 #ifdef CONFIG_KVM_BOOK3S_HV_P9_TIMING
45 void accumulate_time(struct kvm_vcpu *vcpu, struct kvmhv_tb_accumulator *next);
46 #define start_timing(vcpu, next) accumulate_time(vcpu, next)
47 #define end_timing(vcpu) accumulate_time(vcpu, NULL)
49 #define accumulate_time(vcpu, next) do {} while (0)
50 #define start_timing(vcpu, next) do {} while (0)
51 #define end_timing(vcpu) do {} while (0)
54 #define KVMPPC_BOOK3S_HV_VCPU_ACCESSOR_SET(reg, size) \
55 static inline void kvmppc_set_##reg ##_hv(struct kvm_vcpu *vcpu, u##size val) \
57 vcpu->arch.reg = val; \
60 #define KVMPPC_BOOK3S_HV_VCPU_ACCESSOR_GET(reg, size) \
61 static inline u##size kvmppc_get_##reg ##_hv(struct kvm_vcpu *vcpu) \
63 return vcpu->arch.reg; \
66 #define KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(reg, size) \
67 KVMPPC_BOOK3S_HV_VCPU_ACCESSOR_SET(reg, size) \
68 KVMPPC_BOOK3S_HV_VCPU_ACCESSOR_GET(reg, size) \
70 #define KVMPPC_BOOK3S_HV_VCPU_ARRAY_ACCESSOR_SET(reg, size) \
71 static inline void kvmppc_set_##reg ##_hv(struct kvm_vcpu *vcpu, int i, u##size val) \
73 vcpu->arch.reg[i] = val; \
76 #define KVMPPC_BOOK3S_HV_VCPU_ARRAY_ACCESSOR_GET(reg, size) \
77 static inline u##size kvmppc_get_##reg ##_hv(struct kvm_vcpu *vcpu, int i) \
79 return vcpu->arch.reg[i]; \
82 #define KVMPPC_BOOK3S_HV_VCPU_ARRAY_ACCESSOR(reg, size) \
83 KVMPPC_BOOK3S_HV_VCPU_ARRAY_ACCESSOR_SET(reg, size) \
84 KVMPPC_BOOK3S_HV_VCPU_ARRAY_ACCESSOR_GET(reg, size) \
86 KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(mmcra, 64)
87 KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(hfscr, 64)
88 KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(fscr, 64)
89 KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dscr, 64)
90 KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(purr, 64)
91 KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(spurr, 64)
92 KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(amr, 64)
93 KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(uamor, 64)
94 KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(siar, 64)
95 KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(sdar, 64)
96 KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(iamr, 64)
97 KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dawr0, 64)
98 KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dawr1, 64)
99 KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dawrx0, 64)
100 KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dawrx1, 64)
101 KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(ciabr, 64)
102 KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(wort, 64)
103 KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(ppr, 64)
104 KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(ctrl, 64)
106 KVMPPC_BOOK3S_HV_VCPU_ARRAY_ACCESSOR(mmcr, 64)
107 KVMPPC_BOOK3S_HV_VCPU_ARRAY_ACCESSOR(sier, 64)
108 KVMPPC_BOOK3S_HV_VCPU_ARRAY_ACCESSOR(pmc, 32)
110 KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(pspb, 32)