powerpc.c (2743103f91e20d4c4d4f1a8d00821289c4c6ff62) powerpc.c (5deb8e7ad8ac7e3fcdfa042acff617f461b361c2)
1/*
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.
5 *
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

--- 111 unchanged lines hidden (view full) ---

120 }
121
122 /* return to host */
123 local_irq_enable();
124 return r;
125}
126EXPORT_SYMBOL_GPL(kvmppc_prepare_to_enter);
127
1/*
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.
5 *
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

--- 111 unchanged lines hidden (view full) ---

120 }
121
122 /* return to host */
123 local_irq_enable();
124 return r;
125}
126EXPORT_SYMBOL_GPL(kvmppc_prepare_to_enter);
127
128#if defined(CONFIG_PPC_BOOK3S_64) && defined(CONFIG_KVM_BOOK3S_PR_POSSIBLE)
129static void kvmppc_swab_shared(struct kvm_vcpu *vcpu)
130{
131 struct kvm_vcpu_arch_shared *shared = vcpu->arch.shared;
132 int i;
133
134 shared->sprg0 = swab64(shared->sprg0);
135 shared->sprg1 = swab64(shared->sprg1);
136 shared->sprg2 = swab64(shared->sprg2);
137 shared->sprg3 = swab64(shared->sprg3);
138 shared->srr0 = swab64(shared->srr0);
139 shared->srr1 = swab64(shared->srr1);
140 shared->dar = swab64(shared->dar);
141 shared->msr = swab64(shared->msr);
142 shared->dsisr = swab32(shared->dsisr);
143 shared->int_pending = swab32(shared->int_pending);
144 for (i = 0; i < ARRAY_SIZE(shared->sr); i++)
145 shared->sr[i] = swab32(shared->sr[i]);
146}
147#endif
148
128int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
129{
130 int nr = kvmppc_get_gpr(vcpu, 11);
131 int r;
132 unsigned long __maybe_unused param1 = kvmppc_get_gpr(vcpu, 3);
133 unsigned long __maybe_unused param2 = kvmppc_get_gpr(vcpu, 4);
134 unsigned long __maybe_unused param3 = kvmppc_get_gpr(vcpu, 5);
135 unsigned long __maybe_unused param4 = kvmppc_get_gpr(vcpu, 6);
136 unsigned long r2 = 0;
137
149int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
150{
151 int nr = kvmppc_get_gpr(vcpu, 11);
152 int r;
153 unsigned long __maybe_unused param1 = kvmppc_get_gpr(vcpu, 3);
154 unsigned long __maybe_unused param2 = kvmppc_get_gpr(vcpu, 4);
155 unsigned long __maybe_unused param3 = kvmppc_get_gpr(vcpu, 5);
156 unsigned long __maybe_unused param4 = kvmppc_get_gpr(vcpu, 6);
157 unsigned long r2 = 0;
158
138 if (!(vcpu->arch.shared->msr & MSR_SF)) {
159 if (!(kvmppc_get_msr(vcpu) & MSR_SF)) {
139 /* 32 bit mode */
140 param1 &= 0xffffffff;
141 param2 &= 0xffffffff;
142 param3 &= 0xffffffff;
143 param4 &= 0xffffffff;
144 }
145
146 switch (nr) {
147 case KVM_HCALL_TOKEN(KVM_HC_PPC_MAP_MAGIC_PAGE):
148 {
160 /* 32 bit mode */
161 param1 &= 0xffffffff;
162 param2 &= 0xffffffff;
163 param3 &= 0xffffffff;
164 param4 &= 0xffffffff;
165 }
166
167 switch (nr) {
168 case KVM_HCALL_TOKEN(KVM_HC_PPC_MAP_MAGIC_PAGE):
169 {
170#if defined(CONFIG_PPC_BOOK3S_64) && defined(CONFIG_KVM_BOOK3S_PR_POSSIBLE)
171 /* Book3S can be little endian, find it out here */
172 int shared_big_endian = true;
173 if (vcpu->arch.intr_msr & MSR_LE)
174 shared_big_endian = false;
175 if (shared_big_endian != vcpu->arch.shared_big_endian)
176 kvmppc_swab_shared(vcpu);
177 vcpu->arch.shared_big_endian = shared_big_endian;
178#endif
179
149 vcpu->arch.magic_page_pa = param1;
150 vcpu->arch.magic_page_ea = param2;
151
152 r2 = KVM_MAGIC_FEAT_SR | KVM_MAGIC_FEAT_MAS0_TO_SPRG7;
153
154 r = EV_SUCCESS;
155 break;
156 }

--- 1008 unchanged lines hidden ---
180 vcpu->arch.magic_page_pa = param1;
181 vcpu->arch.magic_page_ea = param2;
182
183 r2 = KVM_MAGIC_FEAT_SR | KVM_MAGIC_FEAT_MAS0_TO_SPRG7;
184
185 r = EV_SUCCESS;
186 break;
187 }

--- 1008 unchanged lines hidden ---