Commit 1f09c3ed authored by Paul Mackerras's avatar Paul Mackerras Committed by Alexander Graf

KVM: PPC: Book3S HV: Minor cleanups

* Remove unused kvmppc_vcore::n_busy field.
* Remove setting of RMOR, since it was only used on PPC970 and the
  PPC970 KVM support has been removed.
* Don't use r1 or r2 in setting the runlatch since they are
  conventionally reserved for other things; use r0 instead.
* Streamline the code a little and remove the ext_interrupt_to_host
  label.
* Add some comments about register usage.
* hcall_try_real_mode doesn't need to be global, and can't be
  called from C code anyway.
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
Signed-off-by: default avatarAlexander Graf <agraf@suse.de>
parent d911f0be
...@@ -227,7 +227,6 @@ struct kvm_arch { ...@@ -227,7 +227,6 @@ struct kvm_arch {
unsigned long host_sdr1; unsigned long host_sdr1;
int tlbie_lock; int tlbie_lock;
unsigned long lpcr; unsigned long lpcr;
unsigned long rmor;
unsigned long vrma_slb_v; unsigned long vrma_slb_v;
int hpte_setup_done; int hpte_setup_done;
u32 hpt_order; u32 hpt_order;
...@@ -271,7 +270,6 @@ struct kvm_arch { ...@@ -271,7 +270,6 @@ struct kvm_arch {
*/ */
struct kvmppc_vcore { struct kvmppc_vcore {
int n_runnable; int n_runnable;
int n_busy;
int num_threads; int num_threads;
int entry_exit_count; int entry_exit_count;
int n_woken; int n_woken;
......
...@@ -505,7 +505,6 @@ int main(void) ...@@ -505,7 +505,6 @@ int main(void)
DEFINE(KVM_NEED_FLUSH, offsetof(struct kvm, arch.need_tlb_flush.bits)); DEFINE(KVM_NEED_FLUSH, offsetof(struct kvm, arch.need_tlb_flush.bits));
DEFINE(KVM_ENABLED_HCALLS, offsetof(struct kvm, arch.enabled_hcalls)); DEFINE(KVM_ENABLED_HCALLS, offsetof(struct kvm, arch.enabled_hcalls));
DEFINE(KVM_LPCR, offsetof(struct kvm, arch.lpcr)); DEFINE(KVM_LPCR, offsetof(struct kvm, arch.lpcr));
DEFINE(KVM_RMOR, offsetof(struct kvm, arch.rmor));
DEFINE(KVM_VRMA_SLB_V, offsetof(struct kvm, arch.vrma_slb_v)); DEFINE(KVM_VRMA_SLB_V, offsetof(struct kvm, arch.vrma_slb_v));
DEFINE(VCPU_DSISR, offsetof(struct kvm_vcpu, arch.shregs.dsisr)); DEFINE(VCPU_DSISR, offsetof(struct kvm_vcpu, arch.shregs.dsisr));
DEFINE(VCPU_DAR, offsetof(struct kvm_vcpu, arch.shregs.dar)); DEFINE(VCPU_DAR, offsetof(struct kvm_vcpu, arch.shregs.dar));
......
...@@ -245,9 +245,9 @@ kvm_novcpu_exit: ...@@ -245,9 +245,9 @@ kvm_novcpu_exit:
kvm_start_guest: kvm_start_guest:
/* Set runlatch bit the minute you wake up from nap */ /* Set runlatch bit the minute you wake up from nap */
mfspr r1, SPRN_CTRLF mfspr r0, SPRN_CTRLF
ori r1, r1, 1 ori r0, r0, 1
mtspr SPRN_CTRLT, r1 mtspr SPRN_CTRLT, r0
ld r2,PACATOC(r13) ld r2,PACATOC(r13)
...@@ -493,11 +493,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) ...@@ -493,11 +493,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
cmpwi r0,0 cmpwi r0,0
beq 20b beq 20b
/* Set LPCR and RMOR. */ /* Set LPCR. */
10: ld r8,VCORE_LPCR(r5) 10: ld r8,VCORE_LPCR(r5)
mtspr SPRN_LPCR,r8 mtspr SPRN_LPCR,r8
ld r8,KVM_RMOR(r9)
mtspr SPRN_RMOR,r8
isync isync
/* Check if HDEC expires soon */ /* Check if HDEC expires soon */
...@@ -1075,7 +1073,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR) ...@@ -1075,7 +1073,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
bne 2f bne 2f
mfspr r3,SPRN_HDEC mfspr r3,SPRN_HDEC
cmpwi r3,0 cmpwi r3,0
bge ignore_hdec mr r4,r9
bge fast_guest_return
2: 2:
/* See if this is an hcall we can handle in real mode */ /* See if this is an hcall we can handle in real mode */
cmpwi r12,BOOK3S_INTERRUPT_SYSCALL cmpwi r12,BOOK3S_INTERRUPT_SYSCALL
...@@ -1083,26 +1082,21 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR) ...@@ -1083,26 +1082,21 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
/* External interrupt ? */ /* External interrupt ? */
cmpwi r12, BOOK3S_INTERRUPT_EXTERNAL cmpwi r12, BOOK3S_INTERRUPT_EXTERNAL
bne+ ext_interrupt_to_host bne+ guest_exit_cont
/* External interrupt, first check for host_ipi. If this is /* External interrupt, first check for host_ipi. If this is
* set, we know the host wants us out so let's do it now * set, we know the host wants us out so let's do it now
*/ */
bl kvmppc_read_intr bl kvmppc_read_intr
cmpdi r3, 0 cmpdi r3, 0
bgt ext_interrupt_to_host bgt guest_exit_cont
/* Check if any CPU is heading out to the host, if so head out too */ /* Check if any CPU is heading out to the host, if so head out too */
ld r5, HSTATE_KVM_VCORE(r13) ld r5, HSTATE_KVM_VCORE(r13)
lwz r0, VCORE_ENTRY_EXIT(r5) lwz r0, VCORE_ENTRY_EXIT(r5)
cmpwi r0, 0x100 cmpwi r0, 0x100
bge ext_interrupt_to_host
/* Return to guest after delivering any pending interrupt */
mr r4, r9 mr r4, r9
b deliver_guest_interrupt blt deliver_guest_interrupt
ext_interrupt_to_host:
guest_exit_cont: /* r9 = vcpu, r12 = trap, r13 = paca */ guest_exit_cont: /* r9 = vcpu, r12 = trap, r13 = paca */
/* Save more register state */ /* Save more register state */
...@@ -1763,8 +1757,10 @@ kvmppc_hisi: ...@@ -1763,8 +1757,10 @@ kvmppc_hisi:
* Returns to the guest if we handle it, or continues on up to * Returns to the guest if we handle it, or continues on up to
* the kernel if we can't (i.e. if we don't have a handler for * the kernel if we can't (i.e. if we don't have a handler for
* it, or if the handler returns H_TOO_HARD). * it, or if the handler returns H_TOO_HARD).
*
* r5 - r8 contain hcall args,
* r9 = vcpu, r10 = pc, r11 = msr, r12 = trap, r13 = paca
*/ */
.globl hcall_try_real_mode
hcall_try_real_mode: hcall_try_real_mode:
ld r3,VCPU_GPR(R3)(r9) ld r3,VCPU_GPR(R3)(r9)
andi. r0,r11,MSR_PR andi. r0,r11,MSR_PR
...@@ -2024,10 +2020,6 @@ hcall_real_table: ...@@ -2024,10 +2020,6 @@ hcall_real_table:
.globl hcall_real_table_end .globl hcall_real_table_end
hcall_real_table_end: hcall_real_table_end:
ignore_hdec:
mr r4,r9
b fast_guest_return
_GLOBAL(kvmppc_h_set_xdabr) _GLOBAL(kvmppc_h_set_xdabr)
andi. r0, r5, DABRX_USER | DABRX_KERNEL andi. r0, r5, DABRX_USER | DABRX_KERNEL
beq 6f beq 6f
...@@ -2066,7 +2058,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) ...@@ -2066,7 +2058,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
li r3, 0 li r3, 0
blr blr
_GLOBAL(kvmppc_h_cede) _GLOBAL(kvmppc_h_cede) /* r3 = vcpu pointer, r11 = msr, r13 = paca */
ori r11,r11,MSR_EE ori r11,r11,MSR_EE
std r11,VCPU_MSR(r3) std r11,VCPU_MSR(r3)
li r0,1 li r0,1
...@@ -2148,9 +2140,9 @@ _GLOBAL(kvmppc_h_cede) ...@@ -2148,9 +2140,9 @@ _GLOBAL(kvmppc_h_cede)
* runlatch bit before napping. * runlatch bit before napping.
*/ */
kvm_do_nap: kvm_do_nap:
mfspr r2, SPRN_CTRLF mfspr r0, SPRN_CTRLF
clrrdi r2, r2, 1 clrrdi r0, r0, 1
mtspr SPRN_CTRLT, r2 mtspr SPRN_CTRLT, r0
li r0,1 li r0,1
stb r0,HSTATE_HWTHREAD_REQ(r13) stb r0,HSTATE_HWTHREAD_REQ(r13)
...@@ -2282,13 +2274,14 @@ machine_check_realmode: ...@@ -2282,13 +2274,14 @@ machine_check_realmode:
/* /*
* Check the reason we woke from nap, and take appropriate action. * Check the reason we woke from nap, and take appropriate action.
* Returns: * Returns (in r3):
* 0 if nothing needs to be done * 0 if nothing needs to be done
* 1 if something happened that needs to be handled by the host * 1 if something happened that needs to be handled by the host
* -1 if there was a guest wakeup (IPI) * -1 if there was a guest wakeup (IPI)
* *
* Also sets r12 to the interrupt vector for any interrupt that needs * Also sets r12 to the interrupt vector for any interrupt that needs
* to be handled now by the host (0x500 for external interrupt), or zero. * to be handled now by the host (0x500 for external interrupt), or zero.
* Modifies r0, r6, r7, r8.
*/ */
kvmppc_check_wake_reason: kvmppc_check_wake_reason:
mfspr r6, SPRN_SRR1 mfspr r6, SPRN_SRR1
...@@ -2324,6 +2317,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) ...@@ -2324,6 +2317,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
* 0 if no interrupt is pending * 0 if no interrupt is pending
* 1 if an interrupt is pending that needs to be handled by the host * 1 if an interrupt is pending that needs to be handled by the host
* -1 if there was a guest wakeup IPI (which has now been cleared) * -1 if there was a guest wakeup IPI (which has now been cleared)
* Modifies r0, r6, r7, r8, returns value in r3.
*/ */
kvmppc_read_intr: kvmppc_read_intr:
/* see if a host IPI is pending */ /* see if a host IPI is pending */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment