Skip to content

Commit b3c129e

Browse files
committed
Merge tag 'kvm-s390-next-6.4-1' of https://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD
Minor cleanup: - phys_to_virt conversion - Improvement of VSIE AP management
2 parents 400d213 + 8a46df7 commit b3c129e

3 files changed

Lines changed: 32 additions & 24 deletions

File tree

arch/s390/kvm/interrupt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ static inline u8 gisa_get_ipm_or_restore_iam(struct kvm_s390_gisa_interrupt *gi)
305305

306306
static inline int gisa_in_alert_list(struct kvm_s390_gisa *gisa)
307307
{
308-
return READ_ONCE(gisa->next_alert) != (u32)(u64)gisa;
308+
return READ_ONCE(gisa->next_alert) != (u32)virt_to_phys(gisa);
309309
}
310310

311311
static inline void gisa_set_ipm_gisc(struct kvm_s390_gisa *gisa, u32 gisc)
@@ -3168,7 +3168,7 @@ void kvm_s390_gisa_init(struct kvm *kvm)
31683168
hrtimer_init(&gi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
31693169
gi->timer.function = gisa_vcpu_kicker;
31703170
memset(gi->origin, 0, sizeof(struct kvm_s390_gisa));
3171-
gi->origin->next_alert = (u32)(u64)gi->origin;
3171+
gi->origin->next_alert = (u32)virt_to_phys(gi->origin);
31723172
VM_EVENT(kvm, 3, "gisa 0x%pK initialized", gi->origin);
31733173
}
31743174

arch/s390/kvm/pci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static int zpci_reset_aipb(u8 nisc)
112112
return -EINVAL;
113113

114114
aift->sbv = zpci_aif_sbv;
115-
aift->gait = (struct zpci_gaite *)zpci_aipb->aipb.gait;
115+
aift->gait = phys_to_virt(zpci_aipb->aipb.gait);
116116

117117
return 0;
118118
}

arch/s390/kvm/vsie.c

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,15 @@ static int prepare_cpuflags(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
138138
}
139139
/* Copy to APCB FORMAT1 from APCB FORMAT0 */
140140
static int setup_apcb10(struct kvm_vcpu *vcpu, struct kvm_s390_apcb1 *apcb_s,
141-
unsigned long apcb_o, struct kvm_s390_apcb1 *apcb_h)
141+
unsigned long crycb_gpa, struct kvm_s390_apcb1 *apcb_h)
142142
{
143143
struct kvm_s390_apcb0 tmp;
144+
unsigned long apcb_gpa;
144145

145-
if (read_guest_real(vcpu, apcb_o, &tmp, sizeof(struct kvm_s390_apcb0)))
146+
apcb_gpa = crycb_gpa + offsetof(struct kvm_s390_crypto_cb, apcb0);
147+
148+
if (read_guest_real(vcpu, apcb_gpa, &tmp,
149+
sizeof(struct kvm_s390_apcb0)))
146150
return -EFAULT;
147151

148152
apcb_s->apm[0] = apcb_h->apm[0] & tmp.apm[0];
@@ -157,15 +161,19 @@ static int setup_apcb10(struct kvm_vcpu *vcpu, struct kvm_s390_apcb1 *apcb_s,
157161
* setup_apcb00 - Copy to APCB FORMAT0 from APCB FORMAT0
158162
* @vcpu: pointer to the virtual CPU
159163
* @apcb_s: pointer to start of apcb in the shadow crycb
160-
* @apcb_o: pointer to start of original apcb in the guest2
164+
* @crycb_gpa: guest physical address to start of original guest crycb
161165
* @apcb_h: pointer to start of apcb in the guest1
162166
*
163167
* Returns 0 and -EFAULT on error reading guest apcb
164168
*/
165169
static int setup_apcb00(struct kvm_vcpu *vcpu, unsigned long *apcb_s,
166-
unsigned long apcb_o, unsigned long *apcb_h)
170+
unsigned long crycb_gpa, unsigned long *apcb_h)
167171
{
168-
if (read_guest_real(vcpu, apcb_o, apcb_s,
172+
unsigned long apcb_gpa;
173+
174+
apcb_gpa = crycb_gpa + offsetof(struct kvm_s390_crypto_cb, apcb0);
175+
176+
if (read_guest_real(vcpu, apcb_gpa, apcb_s,
169177
sizeof(struct kvm_s390_apcb0)))
170178
return -EFAULT;
171179

@@ -178,16 +186,20 @@ static int setup_apcb00(struct kvm_vcpu *vcpu, unsigned long *apcb_s,
178186
* setup_apcb11 - Copy the FORMAT1 APCB from the guest to the shadow CRYCB
179187
* @vcpu: pointer to the virtual CPU
180188
* @apcb_s: pointer to start of apcb in the shadow crycb
181-
* @apcb_o: pointer to start of original guest apcb
189+
* @crycb_gpa: guest physical address to start of original guest crycb
182190
* @apcb_h: pointer to start of apcb in the host
183191
*
184192
* Returns 0 and -EFAULT on error reading guest apcb
185193
*/
186194
static int setup_apcb11(struct kvm_vcpu *vcpu, unsigned long *apcb_s,
187-
unsigned long apcb_o,
195+
unsigned long crycb_gpa,
188196
unsigned long *apcb_h)
189197
{
190-
if (read_guest_real(vcpu, apcb_o, apcb_s,
198+
unsigned long apcb_gpa;
199+
200+
apcb_gpa = crycb_gpa + offsetof(struct kvm_s390_crypto_cb, apcb1);
201+
202+
if (read_guest_real(vcpu, apcb_gpa, apcb_s,
191203
sizeof(struct kvm_s390_apcb1)))
192204
return -EFAULT;
193205

@@ -200,7 +212,7 @@ static int setup_apcb11(struct kvm_vcpu *vcpu, unsigned long *apcb_s,
200212
* setup_apcb - Create a shadow copy of the apcb.
201213
* @vcpu: pointer to the virtual CPU
202214
* @crycb_s: pointer to shadow crycb
203-
* @crycb_o: pointer to original guest crycb
215+
* @crycb_gpa: guest physical address of original guest crycb
204216
* @crycb_h: pointer to the host crycb
205217
* @fmt_o: format of the original guest crycb.
206218
* @fmt_h: format of the host crycb.
@@ -211,50 +223,46 @@ static int setup_apcb11(struct kvm_vcpu *vcpu, unsigned long *apcb_s,
211223
* Return 0 or an error number if the guest and host crycb are incompatible.
212224
*/
213225
static int setup_apcb(struct kvm_vcpu *vcpu, struct kvm_s390_crypto_cb *crycb_s,
214-
const u32 crycb_o,
226+
const u32 crycb_gpa,
215227
struct kvm_s390_crypto_cb *crycb_h,
216228
int fmt_o, int fmt_h)
217229
{
218-
struct kvm_s390_crypto_cb *crycb;
219-
220-
crycb = (struct kvm_s390_crypto_cb *) (unsigned long)crycb_o;
221-
222230
switch (fmt_o) {
223231
case CRYCB_FORMAT2:
224-
if ((crycb_o & PAGE_MASK) != ((crycb_o + 256) & PAGE_MASK))
232+
if ((crycb_gpa & PAGE_MASK) != ((crycb_gpa + 256) & PAGE_MASK))
225233
return -EACCES;
226234
if (fmt_h != CRYCB_FORMAT2)
227235
return -EINVAL;
228236
return setup_apcb11(vcpu, (unsigned long *)&crycb_s->apcb1,
229-
(unsigned long) &crycb->apcb1,
237+
crycb_gpa,
230238
(unsigned long *)&crycb_h->apcb1);
231239
case CRYCB_FORMAT1:
232240
switch (fmt_h) {
233241
case CRYCB_FORMAT2:
234242
return setup_apcb10(vcpu, &crycb_s->apcb1,
235-
(unsigned long) &crycb->apcb0,
243+
crycb_gpa,
236244
&crycb_h->apcb1);
237245
case CRYCB_FORMAT1:
238246
return setup_apcb00(vcpu,
239247
(unsigned long *) &crycb_s->apcb0,
240-
(unsigned long) &crycb->apcb0,
248+
crycb_gpa,
241249
(unsigned long *) &crycb_h->apcb0);
242250
}
243251
break;
244252
case CRYCB_FORMAT0:
245-
if ((crycb_o & PAGE_MASK) != ((crycb_o + 32) & PAGE_MASK))
253+
if ((crycb_gpa & PAGE_MASK) != ((crycb_gpa + 32) & PAGE_MASK))
246254
return -EACCES;
247255

248256
switch (fmt_h) {
249257
case CRYCB_FORMAT2:
250258
return setup_apcb10(vcpu, &crycb_s->apcb1,
251-
(unsigned long) &crycb->apcb0,
259+
crycb_gpa,
252260
&crycb_h->apcb1);
253261
case CRYCB_FORMAT1:
254262
case CRYCB_FORMAT0:
255263
return setup_apcb00(vcpu,
256264
(unsigned long *) &crycb_s->apcb0,
257-
(unsigned long) &crycb->apcb0,
265+
crycb_gpa,
258266
(unsigned long *) &crycb_h->apcb0);
259267
}
260268
}

0 commit comments

Comments
 (0)