book3s.c (2122ff5eab8faec853e43f6de886e8dc8f31e317) book3s.c (49f6be8ea1bd74713c1a48e42db06a3808dfa2cd)
1/*
2 * Copyright (C) 2009. SUSE Linux Products GmbH. All rights reserved.
3 *
4 * Authors:
5 * Alexander Graf <agraf@suse.de>
6 * Kevin Wolf <mail@kevin-wolf.de>
7 *
8 * Description:

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

1288 kfree(vcpu_book3s->shadow_vcpu);
1289 vfree(vcpu_book3s);
1290}
1291
1292extern int __kvmppc_vcpu_entry(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu);
1293int __kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
1294{
1295 int ret;
1/*
2 * Copyright (C) 2009. SUSE Linux Products GmbH. All rights reserved.
3 *
4 * Authors:
5 * Alexander Graf <agraf@suse.de>
6 * Kevin Wolf <mail@kevin-wolf.de>
7 *
8 * Description:

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

1288 kfree(vcpu_book3s->shadow_vcpu);
1289 vfree(vcpu_book3s);
1290}
1291
1292extern int __kvmppc_vcpu_entry(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu);
1293int __kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
1294{
1295 int ret;
1296 struct thread_struct ext_bkp;
1296 double fpr[32][TS_FPRWIDTH];
1297 unsigned int fpscr;
1298 int fpexc_mode;
1297#ifdef CONFIG_ALTIVEC
1299#ifdef CONFIG_ALTIVEC
1298 bool save_vec = current->thread.used_vr;
1300 vector128 vr[32];
1301 vector128 vscr;
1302 unsigned long uninitialized_var(vrsave);
1303 int used_vr;
1299#endif
1300#ifdef CONFIG_VSX
1304#endif
1305#ifdef CONFIG_VSX
1301 bool save_vsx = current->thread.used_vsr;
1306 int used_vsr;
1302#endif
1303 ulong ext_msr;
1304
1305 /* No need to go into the guest when all we do is going out */
1306 if (signal_pending(current)) {
1307 kvm_run->exit_reason = KVM_EXIT_INTR;
1308 return -EINTR;
1309 }
1310
1311 /* Save FPU state in stack */
1312 if (current->thread.regs->msr & MSR_FP)
1313 giveup_fpu(current);
1307#endif
1308 ulong ext_msr;
1309
1310 /* No need to go into the guest when all we do is going out */
1311 if (signal_pending(current)) {
1312 kvm_run->exit_reason = KVM_EXIT_INTR;
1313 return -EINTR;
1314 }
1315
1316 /* Save FPU state in stack */
1317 if (current->thread.regs->msr & MSR_FP)
1318 giveup_fpu(current);
1314 memcpy(ext_bkp.fpr, current->thread.fpr, sizeof(current->thread.fpr));
1315 ext_bkp.fpscr = current->thread.fpscr;
1316 ext_bkp.fpexc_mode = current->thread.fpexc_mode;
1319 memcpy(fpr, current->thread.fpr, sizeof(current->thread.fpr));
1320 fpscr = current->thread.fpscr.val;
1321 fpexc_mode = current->thread.fpexc_mode;
1317
1318#ifdef CONFIG_ALTIVEC
1319 /* Save Altivec state in stack */
1322
1323#ifdef CONFIG_ALTIVEC
1324 /* Save Altivec state in stack */
1320 if (save_vec) {
1325 used_vr = current->thread.used_vr;
1326 if (used_vr) {
1321 if (current->thread.regs->msr & MSR_VEC)
1322 giveup_altivec(current);
1327 if (current->thread.regs->msr & MSR_VEC)
1328 giveup_altivec(current);
1323 memcpy(ext_bkp.vr, current->thread.vr, sizeof(ext_bkp.vr));
1324 ext_bkp.vscr = current->thread.vscr;
1325 ext_bkp.vrsave = current->thread.vrsave;
1329 memcpy(vr, current->thread.vr, sizeof(current->thread.vr));
1330 vscr = current->thread.vscr;
1331 vrsave = current->thread.vrsave;
1326 }
1332 }
1327 ext_bkp.used_vr = current->thread.used_vr;
1328#endif
1329
1330#ifdef CONFIG_VSX
1331 /* Save VSX state in stack */
1333#endif
1334
1335#ifdef CONFIG_VSX
1336 /* Save VSX state in stack */
1332 if (save_vsx && (current->thread.regs->msr & MSR_VSX))
1337 used_vsr = current->thread.used_vsr;
1338 if (used_vsr && (current->thread.regs->msr & MSR_VSX))
1333 __giveup_vsx(current);
1339 __giveup_vsx(current);
1334 ext_bkp.used_vsr = current->thread.used_vsr;
1335#endif
1336
1337 /* Remember the MSR with disabled extensions */
1338 ext_msr = current->thread.regs->msr;
1339
1340 /* XXX we get called with irq disabled - change that! */
1341 local_irq_enable();
1342

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

1351 current->thread.regs->msr = ext_msr;
1352
1353 /* Make sure we save the guest FPU/Altivec/VSX state */
1354 kvmppc_giveup_ext(vcpu, MSR_FP);
1355 kvmppc_giveup_ext(vcpu, MSR_VEC);
1356 kvmppc_giveup_ext(vcpu, MSR_VSX);
1357
1358 /* Restore FPU state from stack */
1340#endif
1341
1342 /* Remember the MSR with disabled extensions */
1343 ext_msr = current->thread.regs->msr;
1344
1345 /* XXX we get called with irq disabled - change that! */
1346 local_irq_enable();
1347

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

1356 current->thread.regs->msr = ext_msr;
1357
1358 /* Make sure we save the guest FPU/Altivec/VSX state */
1359 kvmppc_giveup_ext(vcpu, MSR_FP);
1360 kvmppc_giveup_ext(vcpu, MSR_VEC);
1361 kvmppc_giveup_ext(vcpu, MSR_VSX);
1362
1363 /* Restore FPU state from stack */
1359 memcpy(current->thread.fpr, ext_bkp.fpr, sizeof(ext_bkp.fpr));
1360 current->thread.fpscr = ext_bkp.fpscr;
1361 current->thread.fpexc_mode = ext_bkp.fpexc_mode;
1364 memcpy(current->thread.fpr, fpr, sizeof(current->thread.fpr));
1365 current->thread.fpscr.val = fpscr;
1366 current->thread.fpexc_mode = fpexc_mode;
1362
1363#ifdef CONFIG_ALTIVEC
1364 /* Restore Altivec state from stack */
1367
1368#ifdef CONFIG_ALTIVEC
1369 /* Restore Altivec state from stack */
1365 if (save_vec && current->thread.used_vr) {
1366 memcpy(current->thread.vr, ext_bkp.vr, sizeof(ext_bkp.vr));
1367 current->thread.vscr = ext_bkp.vscr;
1368 current->thread.vrsave= ext_bkp.vrsave;
1370 if (used_vr && current->thread.used_vr) {
1371 memcpy(current->thread.vr, vr, sizeof(current->thread.vr));
1372 current->thread.vscr = vscr;
1373 current->thread.vrsave = vrsave;
1369 }
1374 }
1370 current->thread.used_vr = ext_bkp.used_vr;
1375 current->thread.used_vr = used_vr;
1371#endif
1372
1373#ifdef CONFIG_VSX
1376#endif
1377
1378#ifdef CONFIG_VSX
1374 current->thread.used_vsr = ext_bkp.used_vsr;
1379 current->thread.used_vsr = used_vsr;
1375#endif
1376
1377 return ret;
1378}
1379
1380static int kvmppc_book3s_init(void)
1381{
1382 return kvm_init(NULL, sizeof(struct kvmppc_vcpu_book3s), 0,
1383 THIS_MODULE);
1384}
1385
1386static void kvmppc_book3s_exit(void)
1387{
1388 kvm_exit();
1389}
1390
1391module_init(kvmppc_book3s_init);
1392module_exit(kvmppc_book3s_exit);
1380#endif
1381
1382 return ret;
1383}
1384
1385static int kvmppc_book3s_init(void)
1386{
1387 return kvm_init(NULL, sizeof(struct kvmppc_vcpu_book3s), 0,
1388 THIS_MODULE);
1389}
1390
1391static void kvmppc_book3s_exit(void)
1392{
1393 kvm_exit();
1394}
1395
1396module_init(kvmppc_book3s_init);
1397module_exit(kvmppc_book3s_exit);