aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/asm-offsets.c
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2011-06-28 20:20:58 -0400
committerAvi Kivity <avi@redhat.com>2011-07-12 06:16:53 -0400
commit3c42bf8a717cb636e0ed2ed77194669e2ac3ed56 (patch)
tree4f543088e6a64ce7f1a771c1618668ff27752ecc /arch/powerpc/kernel/asm-offsets.c
parent923c53caea446d246949c94703be83e68f251af7 (diff)
KVM: PPC: Split host-state fields out of kvmppc_book3s_shadow_vcpu
There are several fields in struct kvmppc_book3s_shadow_vcpu that temporarily store bits of host state while a guest is running, rather than anything relating to the particular guest or vcpu. This splits them out into a new kvmppc_host_state structure and modifies the definitions in asm-offsets.c to suit. On 32-bit, we have a kvmppc_host_state structure inside the kvmppc_book3s_shadow_vcpu since the assembly code needs to be able to get to them both with one pointer. On 64-bit they are separate fields in the PACA. This means that on 64-bit we don't need to copy the kvmppc_host_state in and out on vcpu load/unload, and in future will mean that the book3s_hv code doesn't need a shadow_vcpu struct in the PACA at all. That does mean that we have to be careful not to rely on any values persisting in the hstate field of the paca across any point where we could block or get preempted. Signed-off-by: Paul Mackerras <paulus@samba.org> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc/kernel/asm-offsets.c')
-rw-r--r--arch/powerpc/kernel/asm-offsets.c94
1 files changed, 47 insertions, 47 deletions
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index faf846131f45..dabfb7346f36 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -198,11 +198,6 @@ int main(void)
198 DEFINE(PACA_USER_TIME, offsetof(struct paca_struct, user_time)); 198 DEFINE(PACA_USER_TIME, offsetof(struct paca_struct, user_time));
199 DEFINE(PACA_SYSTEM_TIME, offsetof(struct paca_struct, system_time)); 199 DEFINE(PACA_SYSTEM_TIME, offsetof(struct paca_struct, system_time));
200 DEFINE(PACA_TRAP_SAVE, offsetof(struct paca_struct, trap_save)); 200 DEFINE(PACA_TRAP_SAVE, offsetof(struct paca_struct, trap_save));
201#ifdef CONFIG_KVM_BOOK3S_64_HANDLER
202 DEFINE(PACA_KVM_SVCPU, offsetof(struct paca_struct, shadow_vcpu));
203 DEFINE(SVCPU_SLB, offsetof(struct kvmppc_book3s_shadow_vcpu, slb));
204 DEFINE(SVCPU_SLB_MAX, offsetof(struct kvmppc_book3s_shadow_vcpu, slb_max));
205#endif
206#endif /* CONFIG_PPC64 */ 201#endif /* CONFIG_PPC64 */
207 202
208 /* RTAS */ 203 /* RTAS */
@@ -416,49 +411,54 @@ int main(void)
416 DEFINE(VCPU_HIGHMEM_HANDLER, offsetof(struct kvm_vcpu, arch.highmem_handler)); 411 DEFINE(VCPU_HIGHMEM_HANDLER, offsetof(struct kvm_vcpu, arch.highmem_handler));
417 DEFINE(VCPU_RMCALL, offsetof(struct kvm_vcpu, arch.rmcall)); 412 DEFINE(VCPU_RMCALL, offsetof(struct kvm_vcpu, arch.rmcall));
418 DEFINE(VCPU_HFLAGS, offsetof(struct kvm_vcpu, arch.hflags)); 413 DEFINE(VCPU_HFLAGS, offsetof(struct kvm_vcpu, arch.hflags));
419 DEFINE(VCPU_SVCPU, offsetof(struct kvmppc_vcpu_book3s, shadow_vcpu) - 414
420 offsetof(struct kvmppc_vcpu_book3s, vcpu)); 415#ifdef CONFIG_PPC_BOOK3S_64
421 DEFINE(SVCPU_CR, offsetof(struct kvmppc_book3s_shadow_vcpu, cr)); 416# define SVCPU_FIELD(x, f) DEFINE(x, offsetof(struct paca_struct, shadow_vcpu.f))
422 DEFINE(SVCPU_XER, offsetof(struct kvmppc_book3s_shadow_vcpu, xer)); 417# define HSTATE_FIELD(x, f) DEFINE(x, offsetof(struct paca_struct, kvm_hstate.f))
423 DEFINE(SVCPU_CTR, offsetof(struct kvmppc_book3s_shadow_vcpu, ctr)); 418#else /* 32-bit */
424 DEFINE(SVCPU_LR, offsetof(struct kvmppc_book3s_shadow_vcpu, lr)); 419# define SVCPU_FIELD(x, f) DEFINE(x, offsetof(struct kvmppc_book3s_shadow_vcpu, f))
425 DEFINE(SVCPU_PC, offsetof(struct kvmppc_book3s_shadow_vcpu, pc)); 420# define HSTATE_FIELD(x, f) DEFINE(x, offsetof(struct kvmppc_book3s_shadow_vcpu, hstate.f))
426 DEFINE(SVCPU_R0, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[0])); 421#endif
427 DEFINE(SVCPU_R1, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[1])); 422
428 DEFINE(SVCPU_R2, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[2])); 423 SVCPU_FIELD(SVCPU_CR, cr);
429 DEFINE(SVCPU_R3, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[3])); 424 SVCPU_FIELD(SVCPU_XER, xer);
430 DEFINE(SVCPU_R4, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[4])); 425 SVCPU_FIELD(SVCPU_CTR, ctr);
431 DEFINE(SVCPU_R5, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[5])); 426 SVCPU_FIELD(SVCPU_LR, lr);
432 DEFINE(SVCPU_R6, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[6])); 427 SVCPU_FIELD(SVCPU_PC, pc);
433 DEFINE(SVCPU_R7, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[7])); 428 SVCPU_FIELD(SVCPU_R0, gpr[0]);
434 DEFINE(SVCPU_R8, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[8])); 429 SVCPU_FIELD(SVCPU_R1, gpr[1]);
435 DEFINE(SVCPU_R9, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[9])); 430 SVCPU_FIELD(SVCPU_R2, gpr[2]);
436 DEFINE(SVCPU_R10, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[10])); 431 SVCPU_FIELD(SVCPU_R3, gpr[3]);
437 DEFINE(SVCPU_R11, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[11])); 432 SVCPU_FIELD(SVCPU_R4, gpr[4]);
438 DEFINE(SVCPU_R12, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[12])); 433 SVCPU_FIELD(SVCPU_R5, gpr[5]);
439 DEFINE(SVCPU_R13, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[13])); 434 SVCPU_FIELD(SVCPU_R6, gpr[6]);
440 DEFINE(SVCPU_HOST_R1, offsetof(struct kvmppc_book3s_shadow_vcpu, host_r1)); 435 SVCPU_FIELD(SVCPU_R7, gpr[7]);
441 DEFINE(SVCPU_HOST_R2, offsetof(struct kvmppc_book3s_shadow_vcpu, host_r2)); 436 SVCPU_FIELD(SVCPU_R8, gpr[8]);
442 DEFINE(SVCPU_VMHANDLER, offsetof(struct kvmppc_book3s_shadow_vcpu, 437 SVCPU_FIELD(SVCPU_R9, gpr[9]);
443 vmhandler)); 438 SVCPU_FIELD(SVCPU_R10, gpr[10]);
444 DEFINE(SVCPU_SCRATCH0, offsetof(struct kvmppc_book3s_shadow_vcpu, 439 SVCPU_FIELD(SVCPU_R11, gpr[11]);
445 scratch0)); 440 SVCPU_FIELD(SVCPU_R12, gpr[12]);
446 DEFINE(SVCPU_SCRATCH1, offsetof(struct kvmppc_book3s_shadow_vcpu, 441 SVCPU_FIELD(SVCPU_R13, gpr[13]);
447 scratch1)); 442 SVCPU_FIELD(SVCPU_FAULT_DSISR, fault_dsisr);
448 DEFINE(SVCPU_IN_GUEST, offsetof(struct kvmppc_book3s_shadow_vcpu, 443 SVCPU_FIELD(SVCPU_FAULT_DAR, fault_dar);
449 in_guest)); 444 SVCPU_FIELD(SVCPU_LAST_INST, last_inst);
450 DEFINE(SVCPU_FAULT_DSISR, offsetof(struct kvmppc_book3s_shadow_vcpu, 445 SVCPU_FIELD(SVCPU_SHADOW_SRR1, shadow_srr1);
451 fault_dsisr));
452 DEFINE(SVCPU_FAULT_DAR, offsetof(struct kvmppc_book3s_shadow_vcpu,
453 fault_dar));
454 DEFINE(SVCPU_LAST_INST, offsetof(struct kvmppc_book3s_shadow_vcpu,
455 last_inst));
456 DEFINE(SVCPU_SHADOW_SRR1, offsetof(struct kvmppc_book3s_shadow_vcpu,
457 shadow_srr1));
458#ifdef CONFIG_PPC_BOOK3S_32 446#ifdef CONFIG_PPC_BOOK3S_32
459 DEFINE(SVCPU_SR, offsetof(struct kvmppc_book3s_shadow_vcpu, sr)); 447 SVCPU_FIELD(SVCPU_SR, sr);
460#endif 448#endif
461#else 449#ifdef CONFIG_PPC64
450 SVCPU_FIELD(SVCPU_SLB, slb);
451 SVCPU_FIELD(SVCPU_SLB_MAX, slb_max);
452#endif
453
454 HSTATE_FIELD(HSTATE_HOST_R1, host_r1);
455 HSTATE_FIELD(HSTATE_HOST_R2, host_r2);
456 HSTATE_FIELD(HSTATE_VMHANDLER, vmhandler);
457 HSTATE_FIELD(HSTATE_SCRATCH0, scratch0);
458 HSTATE_FIELD(HSTATE_SCRATCH1, scratch1);
459 HSTATE_FIELD(HSTATE_IN_GUEST, in_guest);
460
461#else /* CONFIG_PPC_BOOK3S */
462 DEFINE(VCPU_CR, offsetof(struct kvm_vcpu, arch.cr)); 462 DEFINE(VCPU_CR, offsetof(struct kvm_vcpu, arch.cr));
463 DEFINE(VCPU_XER, offsetof(struct kvm_vcpu, arch.xer)); 463 DEFINE(VCPU_XER, offsetof(struct kvm_vcpu, arch.xer));
464 DEFINE(VCPU_LR, offsetof(struct kvm_vcpu, arch.lr)); 464 DEFINE(VCPU_LR, offsetof(struct kvm_vcpu, arch.lr));
@@ -468,7 +468,7 @@ int main(void)
468 DEFINE(VCPU_FAULT_DEAR, offsetof(struct kvm_vcpu, arch.fault_dear)); 468 DEFINE(VCPU_FAULT_DEAR, offsetof(struct kvm_vcpu, arch.fault_dear));
469 DEFINE(VCPU_FAULT_ESR, offsetof(struct kvm_vcpu, arch.fault_esr)); 469 DEFINE(VCPU_FAULT_ESR, offsetof(struct kvm_vcpu, arch.fault_esr));
470#endif /* CONFIG_PPC_BOOK3S */ 470#endif /* CONFIG_PPC_BOOK3S */
471#endif 471#endif /* CONFIG_KVM */
472 472
473#ifdef CONFIG_KVM_GUEST 473#ifdef CONFIG_KVM_GUEST
474 DEFINE(KVM_MAGIC_SCRATCH1, offsetof(struct kvm_vcpu_arch_shared, 474 DEFINE(KVM_MAGIC_SCRATCH1, offsetof(struct kvm_vcpu_arch_shared,