Commit 3ff03278 authored by Paolo Bonzini's avatar Paolo Bonzini

Merge tag 'kvm-ppc-next-5.9-1' of...

Merge tag 'kvm-ppc-next-5.9-1' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc into kvm-next-5.6

PPC KVM update for 5.9

- Improvements and bug-fixes for secure VM support, giving reduced startup
  time and memory hotplug support.
- Locking fixes in nested KVM code
- Increase number of guests supported by HV KVM to 4094
- Preliminary POWER10 support
parents 43bd9ef4 81ab595d
...@@ -895,6 +895,7 @@ Return values ...@@ -895,6 +895,7 @@ Return values
One of the following values: One of the following values:
* H_SUCCESS on success. * H_SUCCESS on success.
* H_STATE if the VM is not in a position to switch to secure.
Description Description
~~~~~~~~~~~ ~~~~~~~~~~~
...@@ -933,6 +934,8 @@ Return values ...@@ -933,6 +934,8 @@ Return values
* H_UNSUPPORTED if called from the wrong context (e.g. * H_UNSUPPORTED if called from the wrong context (e.g.
from an SVM or before an H_SVM_INIT_START from an SVM or before an H_SVM_INIT_START
hypercall). hypercall).
* H_STATE if the hypervisor could not successfully
transition the VM to Secure VM.
Description Description
~~~~~~~~~~~ ~~~~~~~~~~~
......
...@@ -23,6 +23,10 @@ int kvmppc_send_page_to_uv(struct kvm *kvm, unsigned long gfn); ...@@ -23,6 +23,10 @@ int kvmppc_send_page_to_uv(struct kvm *kvm, unsigned long gfn);
unsigned long kvmppc_h_svm_init_abort(struct kvm *kvm); unsigned long kvmppc_h_svm_init_abort(struct kvm *kvm);
void kvmppc_uvmem_drop_pages(const struct kvm_memory_slot *free, void kvmppc_uvmem_drop_pages(const struct kvm_memory_slot *free,
struct kvm *kvm, bool skip_page_out); struct kvm *kvm, bool skip_page_out);
int kvmppc_uvmem_memslot_create(struct kvm *kvm,
const struct kvm_memory_slot *new);
void kvmppc_uvmem_memslot_delete(struct kvm *kvm,
const struct kvm_memory_slot *old);
#else #else
static inline int kvmppc_uvmem_init(void) static inline int kvmppc_uvmem_init(void)
{ {
...@@ -82,5 +86,15 @@ static inline int kvmppc_send_page_to_uv(struct kvm *kvm, unsigned long gfn) ...@@ -82,5 +86,15 @@ static inline int kvmppc_send_page_to_uv(struct kvm *kvm, unsigned long gfn)
static inline void static inline void
kvmppc_uvmem_drop_pages(const struct kvm_memory_slot *free, kvmppc_uvmem_drop_pages(const struct kvm_memory_slot *free,
struct kvm *kvm, bool skip_page_out) { } struct kvm *kvm, bool skip_page_out) { }
static inline int kvmppc_uvmem_memslot_create(struct kvm *kvm,
const struct kvm_memory_slot *new)
{
return H_UNSUPPORTED;
}
static inline void kvmppc_uvmem_memslot_delete(struct kvm *kvm,
const struct kvm_memory_slot *old) { }
#endif /* CONFIG_PPC_UV */ #endif /* CONFIG_PPC_UV */
#endif /* __ASM_KVM_BOOK3S_UVMEM_H__ */ #endif /* __ASM_KVM_BOOK3S_UVMEM_H__ */
...@@ -59,7 +59,7 @@ enum xlate_readwrite { ...@@ -59,7 +59,7 @@ enum xlate_readwrite {
}; };
extern int kvmppc_vcpu_run(struct kvm_vcpu *vcpu); extern int kvmppc_vcpu_run(struct kvm_vcpu *vcpu);
extern int __kvmppc_vcpu_run(struct kvm_run *run, struct kvm_vcpu *vcpu); extern int __kvmppc_vcpu_run(struct kvm_vcpu *vcpu);
extern void kvmppc_handler_highmem(void); extern void kvmppc_handler_highmem(void);
extern void kvmppc_dump_vcpu(struct kvm_vcpu *vcpu); extern void kvmppc_dump_vcpu(struct kvm_vcpu *vcpu);
......
...@@ -474,7 +474,8 @@ ...@@ -474,7 +474,8 @@
#ifndef SPRN_LPID #ifndef SPRN_LPID
#define SPRN_LPID 0x13F /* Logical Partition Identifier */ #define SPRN_LPID 0x13F /* Logical Partition Identifier */
#endif #endif
#define LPID_RSVD 0x3ff /* Reserved LPID for partn switching */ #define LPID_RSVD_POWER7 0x3ff /* Reserved LPID for partn switching */
#define LPID_RSVD 0xfff /* Reserved LPID for partn switching */
#define SPRN_HMER 0x150 /* Hypervisor maintenance exception reg */ #define SPRN_HMER 0x150 /* Hypervisor maintenance exception reg */
#define HMER_DEBUG_TRIG (1ul << (63 - 17)) /* Debug trigger */ #define HMER_DEBUG_TRIG (1ul << (63 - 17)) /* Debug trigger */
#define SPRN_HMEER 0x151 /* Hyp maintenance exception enable reg */ #define SPRN_HMEER 0x151 /* Hyp maintenance exception enable reg */
...@@ -1362,6 +1363,7 @@ ...@@ -1362,6 +1363,7 @@
#define PVR_ARCH_206p 0x0f100003 #define PVR_ARCH_206p 0x0f100003
#define PVR_ARCH_207 0x0f000004 #define PVR_ARCH_207 0x0f000004
#define PVR_ARCH_300 0x0f000005 #define PVR_ARCH_300 0x0f000005
#define PVR_ARCH_31 0x0f000006
/* Macros for setting and retrieving special purpose registers */ /* Macros for setting and retrieving special purpose registers */
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
......
...@@ -260,11 +260,15 @@ int kvmppc_mmu_hv_init(void) ...@@ -260,11 +260,15 @@ int kvmppc_mmu_hv_init(void)
if (!mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE)) if (!mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE))
return -EINVAL; return -EINVAL;
/* POWER7 has 10-bit LPIDs (12-bit in POWER8) */
host_lpid = 0; host_lpid = 0;
if (cpu_has_feature(CPU_FTR_HVMODE)) if (cpu_has_feature(CPU_FTR_HVMODE))
host_lpid = mfspr(SPRN_LPID); host_lpid = mfspr(SPRN_LPID);
rsvd_lpid = LPID_RSVD;
/* POWER8 and above have 12-bit LPIDs (10-bit in POWER7) */
if (cpu_has_feature(CPU_FTR_ARCH_207S))
rsvd_lpid = LPID_RSVD;
else
rsvd_lpid = LPID_RSVD_POWER7;
kvmppc_init_lpid(rsvd_lpid + 1); kvmppc_init_lpid(rsvd_lpid + 1);
......
...@@ -161,7 +161,9 @@ int kvmppc_mmu_walk_radix_tree(struct kvm_vcpu *vcpu, gva_t eaddr, ...@@ -161,7 +161,9 @@ int kvmppc_mmu_walk_radix_tree(struct kvm_vcpu *vcpu, gva_t eaddr,
return -EINVAL; return -EINVAL;
/* Read the entry from guest memory */ /* Read the entry from guest memory */
addr = base + (index * sizeof(rpte)); addr = base + (index * sizeof(rpte));
vcpu->srcu_idx = srcu_read_lock(&kvm->srcu);
ret = kvm_read_guest(kvm, addr, &rpte, sizeof(rpte)); ret = kvm_read_guest(kvm, addr, &rpte, sizeof(rpte));
srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx);
if (ret) { if (ret) {
if (pte_ret_p) if (pte_ret_p)
*pte_ret_p = addr; *pte_ret_p = addr;
...@@ -237,7 +239,9 @@ int kvmppc_mmu_radix_translate_table(struct kvm_vcpu *vcpu, gva_t eaddr, ...@@ -237,7 +239,9 @@ int kvmppc_mmu_radix_translate_table(struct kvm_vcpu *vcpu, gva_t eaddr,
/* Read the table to find the root of the radix tree */ /* Read the table to find the root of the radix tree */
ptbl = (table & PRTB_MASK) + (table_index * sizeof(entry)); ptbl = (table & PRTB_MASK) + (table_index * sizeof(entry));
vcpu->srcu_idx = srcu_read_lock(&kvm->srcu);
ret = kvm_read_guest(kvm, ptbl, &entry, sizeof(entry)); ret = kvm_read_guest(kvm, ptbl, &entry, sizeof(entry));
srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx);
if (ret) if (ret)
return ret; return ret;
......
...@@ -343,13 +343,18 @@ static void kvmppc_set_pvr_hv(struct kvm_vcpu *vcpu, u32 pvr) ...@@ -343,13 +343,18 @@ static void kvmppc_set_pvr_hv(struct kvm_vcpu *vcpu, u32 pvr)
vcpu->arch.pvr = pvr; vcpu->arch.pvr = pvr;
} }
/* Dummy value used in computing PCR value below */
#define PCR_ARCH_31 (PCR_ARCH_300 << 1)
static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat) static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat)
{ {
unsigned long host_pcr_bit = 0, guest_pcr_bit = 0; unsigned long host_pcr_bit = 0, guest_pcr_bit = 0;
struct kvmppc_vcore *vc = vcpu->arch.vcore; struct kvmppc_vcore *vc = vcpu->arch.vcore;
/* We can (emulate) our own architecture version and anything older */ /* We can (emulate) our own architecture version and anything older */
if (cpu_has_feature(CPU_FTR_ARCH_300)) if (cpu_has_feature(CPU_FTR_ARCH_31))
host_pcr_bit = PCR_ARCH_31;
else if (cpu_has_feature(CPU_FTR_ARCH_300))
host_pcr_bit = PCR_ARCH_300; host_pcr_bit = PCR_ARCH_300;
else if (cpu_has_feature(CPU_FTR_ARCH_207S)) else if (cpu_has_feature(CPU_FTR_ARCH_207S))
host_pcr_bit = PCR_ARCH_207; host_pcr_bit = PCR_ARCH_207;
...@@ -375,6 +380,9 @@ static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat) ...@@ -375,6 +380,9 @@ static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat)
case PVR_ARCH_300: case PVR_ARCH_300:
guest_pcr_bit = PCR_ARCH_300; guest_pcr_bit = PCR_ARCH_300;
break; break;
case PVR_ARCH_31:
guest_pcr_bit = PCR_ARCH_31;
break;
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -2355,7 +2363,7 @@ static int kvmppc_core_vcpu_create_hv(struct kvm_vcpu *vcpu) ...@@ -2355,7 +2363,7 @@ static int kvmppc_core_vcpu_create_hv(struct kvm_vcpu *vcpu)
* to trap and then we emulate them. * to trap and then we emulate them.
*/ */
vcpu->arch.hfscr = HFSCR_TAR | HFSCR_EBB | HFSCR_PM | HFSCR_BHRB | vcpu->arch.hfscr = HFSCR_TAR | HFSCR_EBB | HFSCR_PM | HFSCR_BHRB |
HFSCR_DSCR | HFSCR_VECVSX | HFSCR_FP; HFSCR_DSCR | HFSCR_VECVSX | HFSCR_FP | HFSCR_PREFIX;
if (cpu_has_feature(CPU_FTR_HVMODE)) { if (cpu_has_feature(CPU_FTR_HVMODE)) {
vcpu->arch.hfscr &= mfspr(SPRN_HFSCR); vcpu->arch.hfscr &= mfspr(SPRN_HFSCR);
if (cpu_has_feature(CPU_FTR_P9_TM_HV_ASSIST)) if (cpu_has_feature(CPU_FTR_P9_TM_HV_ASSIST))
...@@ -4552,16 +4560,14 @@ static void kvmppc_core_commit_memory_region_hv(struct kvm *kvm, ...@@ -4552,16 +4560,14 @@ static void kvmppc_core_commit_memory_region_hv(struct kvm *kvm,
switch (change) { switch (change) {
case KVM_MR_CREATE: case KVM_MR_CREATE:
if (kvmppc_uvmem_slot_init(kvm, new)) /*
return; * @TODO kvmppc_uvmem_memslot_create() can fail and
uv_register_mem_slot(kvm->arch.lpid, * return error. Fix this.
new->base_gfn << PAGE_SHIFT, */
new->npages * PAGE_SIZE, kvmppc_uvmem_memslot_create(kvm, new);
0, new->id);
break; break;
case KVM_MR_DELETE: case KVM_MR_DELETE:
uv_unregister_mem_slot(kvm->arch.lpid, old->id); kvmppc_uvmem_memslot_delete(kvm, old);
kvmppc_uvmem_slot_free(kvm, old);
break; break;
default: default:
/* TODO: Handle KVM_MR_MOVE */ /* TODO: Handle KVM_MR_MOVE */
......
...@@ -233,20 +233,21 @@ long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu) ...@@ -233,20 +233,21 @@ long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu)
/* copy parameters in */ /* copy parameters in */
hv_ptr = kvmppc_get_gpr(vcpu, 4); hv_ptr = kvmppc_get_gpr(vcpu, 4);
regs_ptr = kvmppc_get_gpr(vcpu, 5);
vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
err = kvm_vcpu_read_guest(vcpu, hv_ptr, &l2_hv, err = kvm_vcpu_read_guest(vcpu, hv_ptr, &l2_hv,
sizeof(struct hv_guest_state)); sizeof(struct hv_guest_state)) ||
kvm_vcpu_read_guest(vcpu, regs_ptr, &l2_regs,
sizeof(struct pt_regs));
srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
if (err) if (err)
return H_PARAMETER; return H_PARAMETER;
if (kvmppc_need_byteswap(vcpu)) if (kvmppc_need_byteswap(vcpu))
byteswap_hv_regs(&l2_hv); byteswap_hv_regs(&l2_hv);
if (l2_hv.version != HV_GUEST_STATE_VERSION) if (l2_hv.version != HV_GUEST_STATE_VERSION)
return H_P2; return H_P2;
regs_ptr = kvmppc_get_gpr(vcpu, 5);
err = kvm_vcpu_read_guest(vcpu, regs_ptr, &l2_regs,
sizeof(struct pt_regs));
if (err)
return H_PARAMETER;
if (kvmppc_need_byteswap(vcpu)) if (kvmppc_need_byteswap(vcpu))
byteswap_pt_regs(&l2_regs); byteswap_pt_regs(&l2_regs);
if (l2_hv.vcpu_token >= NR_CPUS) if (l2_hv.vcpu_token >= NR_CPUS)
...@@ -323,12 +324,12 @@ long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu) ...@@ -323,12 +324,12 @@ long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu)
byteswap_hv_regs(&l2_hv); byteswap_hv_regs(&l2_hv);
byteswap_pt_regs(&l2_regs); byteswap_pt_regs(&l2_regs);
} }
vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
err = kvm_vcpu_write_guest(vcpu, hv_ptr, &l2_hv, err = kvm_vcpu_write_guest(vcpu, hv_ptr, &l2_hv,
sizeof(struct hv_guest_state)); sizeof(struct hv_guest_state)) ||
if (err) kvm_vcpu_write_guest(vcpu, regs_ptr, &l2_regs,
return H_AUTHORITY;
err = kvm_vcpu_write_guest(vcpu, regs_ptr, &l2_regs,
sizeof(struct pt_regs)); sizeof(struct pt_regs));
srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
if (err) if (err)
return H_AUTHORITY; return H_AUTHORITY;
...@@ -508,12 +509,16 @@ long kvmhv_copy_tofrom_guest_nested(struct kvm_vcpu *vcpu) ...@@ -508,12 +509,16 @@ long kvmhv_copy_tofrom_guest_nested(struct kvm_vcpu *vcpu)
goto not_found; goto not_found;
/* Write what was loaded into our buffer back to the L1 guest */ /* Write what was loaded into our buffer back to the L1 guest */
vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
rc = kvm_vcpu_write_guest(vcpu, gp_to, buf, n); rc = kvm_vcpu_write_guest(vcpu, gp_to, buf, n);
srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
if (rc) if (rc)
goto not_found; goto not_found;
} else { } else {
/* Load the data to be stored from the L1 guest into our buf */ /* Load the data to be stored from the L1 guest into our buf */
vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
rc = kvm_vcpu_read_guest(vcpu, gp_from, buf, n); rc = kvm_vcpu_read_guest(vcpu, gp_from, buf, n);
srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
if (rc) if (rc)
goto not_found; goto not_found;
...@@ -548,9 +553,12 @@ static void kvmhv_update_ptbl_cache(struct kvm_nested_guest *gp) ...@@ -548,9 +553,12 @@ static void kvmhv_update_ptbl_cache(struct kvm_nested_guest *gp)
ret = -EFAULT; ret = -EFAULT;
ptbl_addr = (kvm->arch.l1_ptcr & PRTB_MASK) + (gp->l1_lpid << 4); ptbl_addr = (kvm->arch.l1_ptcr & PRTB_MASK) + (gp->l1_lpid << 4);
if (gp->l1_lpid < (1ul << ((kvm->arch.l1_ptcr & PRTS_MASK) + 8))) if (gp->l1_lpid < (1ul << ((kvm->arch.l1_ptcr & PRTS_MASK) + 8))) {
int srcu_idx = srcu_read_lock(&kvm->srcu);
ret = kvm_read_guest(kvm, ptbl_addr, ret = kvm_read_guest(kvm, ptbl_addr,
&ptbl_entry, sizeof(ptbl_entry)); &ptbl_entry, sizeof(ptbl_entry));
srcu_read_unlock(&kvm->srcu, srcu_idx);
}
if (ret) { if (ret) {
gp->l1_gr_to_hr = 0; gp->l1_gr_to_hr = 0;
gp->process_table = 0; gp->process_table = 0;
......
This diff is collapsed.
...@@ -55,8 +55,7 @@ ...@@ -55,8 +55,7 @@
****************************************************************************/ ****************************************************************************/
/* Registers: /* Registers:
* r3: kvm_run pointer * r3: vcpu pointer
* r4: vcpu pointer
*/ */
_GLOBAL(__kvmppc_vcpu_run) _GLOBAL(__kvmppc_vcpu_run)
...@@ -68,8 +67,8 @@ kvm_start_entry: ...@@ -68,8 +67,8 @@ kvm_start_entry:
/* Save host state to the stack */ /* Save host state to the stack */
PPC_STLU r1, -SWITCH_FRAME_SIZE(r1) PPC_STLU r1, -SWITCH_FRAME_SIZE(r1)
/* Save r3 (kvm_run) and r4 (vcpu) */ /* Save r3 (vcpu) */
SAVE_2GPRS(3, r1) SAVE_GPR(3, r1)
/* Save non-volatile registers (r14 - r31) */ /* Save non-volatile registers (r14 - r31) */
SAVE_NVGPRS(r1) SAVE_NVGPRS(r1)
...@@ -82,47 +81,46 @@ kvm_start_entry: ...@@ -82,47 +81,46 @@ kvm_start_entry:
PPC_STL r0, _LINK(r1) PPC_STL r0, _LINK(r1)
/* Load non-volatile guest state from the vcpu */ /* Load non-volatile guest state from the vcpu */
VCPU_LOAD_NVGPRS(r4) VCPU_LOAD_NVGPRS(r3)
kvm_start_lightweight: kvm_start_lightweight:
/* Copy registers into shadow vcpu so we can access them in real mode */ /* Copy registers into shadow vcpu so we can access them in real mode */
mr r3, r4
bl FUNC(kvmppc_copy_to_svcpu) bl FUNC(kvmppc_copy_to_svcpu)
nop nop
REST_GPR(4, r1) REST_GPR(3, r1)
#ifdef CONFIG_PPC_BOOK3S_64 #ifdef CONFIG_PPC_BOOK3S_64
/* Get the dcbz32 flag */ /* Get the dcbz32 flag */
PPC_LL r3, VCPU_HFLAGS(r4) PPC_LL r0, VCPU_HFLAGS(r3)
rldicl r3, r3, 0, 63 /* r3 &= 1 */ rldicl r0, r0, 0, 63 /* r3 &= 1 */
stb r3, HSTATE_RESTORE_HID5(r13) stb r0, HSTATE_RESTORE_HID5(r13)
/* Load up guest SPRG3 value, since it's user readable */ /* Load up guest SPRG3 value, since it's user readable */
lwz r3, VCPU_SHAREDBE(r4) lbz r4, VCPU_SHAREDBE(r3)
cmpwi r3, 0 cmpwi r4, 0
ld r5, VCPU_SHARED(r4) ld r5, VCPU_SHARED(r3)
beq sprg3_little_endian beq sprg3_little_endian
sprg3_big_endian: sprg3_big_endian:
#ifdef __BIG_ENDIAN__ #ifdef __BIG_ENDIAN__
ld r3, VCPU_SHARED_SPRG3(r5) ld r4, VCPU_SHARED_SPRG3(r5)
#else #else
addi r5, r5, VCPU_SHARED_SPRG3 addi r5, r5, VCPU_SHARED_SPRG3
ldbrx r3, 0, r5 ldbrx r4, 0, r5
#endif #endif
b after_sprg3_load b after_sprg3_load
sprg3_little_endian: sprg3_little_endian:
#ifdef __LITTLE_ENDIAN__ #ifdef __LITTLE_ENDIAN__
ld r3, VCPU_SHARED_SPRG3(r5) ld r4, VCPU_SHARED_SPRG3(r5)
#else #else
addi r5, r5, VCPU_SHARED_SPRG3 addi r5, r5, VCPU_SHARED_SPRG3
ldbrx r3, 0, r5 ldbrx r4, 0, r5
#endif #endif
after_sprg3_load: after_sprg3_load:
mtspr SPRN_SPRG3, r3 mtspr SPRN_SPRG3, r4
#endif /* CONFIG_PPC_BOOK3S_64 */ #endif /* CONFIG_PPC_BOOK3S_64 */
PPC_LL r4, VCPU_SHADOW_MSR(r4) /* get shadow_msr */ PPC_LL r4, VCPU_SHADOW_MSR(r3) /* get shadow_msr */
/* Jump to segment patching handler and into our guest */ /* Jump to segment patching handler and into our guest */
bl FUNC(kvmppc_entry_trampoline) bl FUNC(kvmppc_entry_trampoline)
...@@ -146,7 +144,7 @@ after_sprg3_load: ...@@ -146,7 +144,7 @@ after_sprg3_load:
* *
*/ */
PPC_LL r3, GPR4(r1) /* vcpu pointer */ PPC_LL r3, GPR3(r1) /* vcpu pointer */
/* /*
* kvmppc_copy_from_svcpu can clobber volatile registers, save * kvmppc_copy_from_svcpu can clobber volatile registers, save
...@@ -169,7 +167,7 @@ after_sprg3_load: ...@@ -169,7 +167,7 @@ after_sprg3_load:
#endif /* CONFIG_PPC_BOOK3S_64 */ #endif /* CONFIG_PPC_BOOK3S_64 */
/* R7 = vcpu */ /* R7 = vcpu */
PPC_LL r7, GPR4(r1) PPC_LL r7, GPR3(r1)
PPC_STL r14, VCPU_GPR(R14)(r7) PPC_STL r14, VCPU_GPR(R14)(r7)
PPC_STL r15, VCPU_GPR(R15)(r7) PPC_STL r15, VCPU_GPR(R15)(r7)
...@@ -190,11 +188,11 @@ after_sprg3_load: ...@@ -190,11 +188,11 @@ after_sprg3_load:
PPC_STL r30, VCPU_GPR(R30)(r7) PPC_STL r30, VCPU_GPR(R30)(r7)
PPC_STL r31, VCPU_GPR(R31)(r7) PPC_STL r31, VCPU_GPR(R31)(r7)
/* Pass the exit number as 3rd argument to kvmppc_handle_exit */ /* Pass the exit number as 2nd argument to kvmppc_handle_exit */
lwz r5, VCPU_TRAP(r7) lwz r4, VCPU_TRAP(r7)
/* Restore r3 (kvm_run) and r4 (vcpu) */ /* Restore r3 (vcpu) */
REST_2GPRS(3, r1) REST_GPR(3, r1)
bl FUNC(kvmppc_handle_exit_pr) bl FUNC(kvmppc_handle_exit_pr)
/* If RESUME_GUEST, get back in the loop */ /* If RESUME_GUEST, get back in the loop */
...@@ -223,11 +221,11 @@ kvm_loop_heavyweight: ...@@ -223,11 +221,11 @@ kvm_loop_heavyweight:
PPC_LL r4, _LINK(r1) PPC_LL r4, _LINK(r1)
PPC_STL r4, (PPC_LR_STKOFF + SWITCH_FRAME_SIZE)(r1) PPC_STL r4, (PPC_LR_STKOFF + SWITCH_FRAME_SIZE)(r1)
/* Load vcpu and cpu_run */ /* Load vcpu */
REST_2GPRS(3, r1) REST_GPR(3, r1)
/* Load non-volatile guest state from the vcpu */ /* Load non-volatile guest state from the vcpu */
VCPU_LOAD_NVGPRS(r4) VCPU_LOAD_NVGPRS(r3)
/* Jump back into the beginning of this function */ /* Jump back into the beginning of this function */
b kvm_start_lightweight b kvm_start_lightweight
...@@ -235,7 +233,7 @@ kvm_loop_heavyweight: ...@@ -235,7 +233,7 @@ kvm_loop_heavyweight:
kvm_loop_lightweight: kvm_loop_lightweight:
/* We'll need the vcpu pointer */ /* We'll need the vcpu pointer */
REST_GPR(4, r1) REST_GPR(3, r1)
/* Jump back into the beginning of this function */ /* Jump back into the beginning of this function */
b kvm_start_lightweight b kvm_start_lightweight
...@@ -1151,9 +1151,9 @@ static int kvmppc_exit_pr_progint(struct kvm_vcpu *vcpu, unsigned int exit_nr) ...@@ -1151,9 +1151,9 @@ static int kvmppc_exit_pr_progint(struct kvm_vcpu *vcpu, unsigned int exit_nr)
return r; return r;
} }
int kvmppc_handle_exit_pr(struct kvm_run *run, struct kvm_vcpu *vcpu, int kvmppc_handle_exit_pr(struct kvm_vcpu *vcpu, unsigned int exit_nr)
unsigned int exit_nr)
{ {
struct kvm_run *run = vcpu->run;
int r = RESUME_HOST; int r = RESUME_HOST;
int s; int s;
...@@ -1826,12 +1826,11 @@ static void kvmppc_core_vcpu_free_pr(struct kvm_vcpu *vcpu) ...@@ -1826,12 +1826,11 @@ static void kvmppc_core_vcpu_free_pr(struct kvm_vcpu *vcpu)
static int kvmppc_vcpu_run_pr(struct kvm_vcpu *vcpu) static int kvmppc_vcpu_run_pr(struct kvm_vcpu *vcpu)
{ {
struct kvm_run *run = vcpu->run;
int ret; int ret;
/* Check if we can run the vcpu at all */ /* Check if we can run the vcpu at all */
if (!vcpu->arch.sane) { if (!vcpu->arch.sane) {
run->exit_reason = KVM_EXIT_INTERNAL_ERROR; vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
...@@ -1858,7 +1857,7 @@ static int kvmppc_vcpu_run_pr(struct kvm_vcpu *vcpu) ...@@ -1858,7 +1857,7 @@ static int kvmppc_vcpu_run_pr(struct kvm_vcpu *vcpu)
kvmppc_fix_ee_before_entry(); kvmppc_fix_ee_before_entry();
ret = __kvmppc_vcpu_run(run, vcpu); ret = __kvmppc_vcpu_run(vcpu);
kvmppc_clear_debug(vcpu); kvmppc_clear_debug(vcpu);
......
...@@ -229,7 +229,9 @@ int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu) ...@@ -229,7 +229,9 @@ int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu)
*/ */
args_phys = kvmppc_get_gpr(vcpu, 4) & KVM_PAM; args_phys = kvmppc_get_gpr(vcpu, 4) & KVM_PAM;
vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
rc = kvm_read_guest(vcpu->kvm, args_phys, &args, sizeof(args)); rc = kvm_read_guest(vcpu->kvm, args_phys, &args, sizeof(args));
srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
if (rc) if (rc)
goto fail; goto fail;
......
...@@ -731,12 +731,11 @@ int kvmppc_core_check_requests(struct kvm_vcpu *vcpu) ...@@ -731,12 +731,11 @@ int kvmppc_core_check_requests(struct kvm_vcpu *vcpu)
int kvmppc_vcpu_run(struct kvm_vcpu *vcpu) int kvmppc_vcpu_run(struct kvm_vcpu *vcpu)
{ {
struct kvm_run *run = vcpu->run;
int ret, s; int ret, s;
struct debug_reg debug; struct debug_reg debug;
if (!vcpu->arch.sane) { if (!vcpu->arch.sane) {
run->exit_reason = KVM_EXIT_INTERNAL_ERROR; vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
return -EINVAL; return -EINVAL;
} }
...@@ -778,7 +777,7 @@ int kvmppc_vcpu_run(struct kvm_vcpu *vcpu) ...@@ -778,7 +777,7 @@ int kvmppc_vcpu_run(struct kvm_vcpu *vcpu)
vcpu->arch.pgdir = vcpu->kvm->mm->pgd; vcpu->arch.pgdir = vcpu->kvm->mm->pgd;
kvmppc_fix_ee_before_entry(); kvmppc_fix_ee_before_entry();
ret = __kvmppc_vcpu_run(run, vcpu); ret = __kvmppc_vcpu_run(vcpu);
/* No need for guest_exit. It's done in handle_exit. /* No need for guest_exit. It's done in handle_exit.
We also get here with interrupts enabled. */ We also get here with interrupts enabled. */
...@@ -982,9 +981,9 @@ static int kvmppc_resume_inst_load(struct kvm_vcpu *vcpu, ...@@ -982,9 +981,9 @@ static int kvmppc_resume_inst_load(struct kvm_vcpu *vcpu,
* *
* Return value is in the form (errcode<<2 | RESUME_FLAG_HOST | RESUME_FLAG_NV) * Return value is in the form (errcode<<2 | RESUME_FLAG_HOST | RESUME_FLAG_NV)
*/ */
int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, int kvmppc_handle_exit(struct kvm_vcpu *vcpu, unsigned int exit_nr)
unsigned int exit_nr)
{ {
struct kvm_run *run = vcpu->run;
int r = RESUME_HOST; int r = RESUME_HOST;
int s; int s;
int idx; int idx;
......
...@@ -237,7 +237,7 @@ _GLOBAL(kvmppc_resume_host) ...@@ -237,7 +237,7 @@ _GLOBAL(kvmppc_resume_host)
/* Switch to kernel stack and jump to handler. */ /* Switch to kernel stack and jump to handler. */
LOAD_REG_ADDR(r3, kvmppc_handle_exit) LOAD_REG_ADDR(r3, kvmppc_handle_exit)
mtctr r3 mtctr r3
lwz r3, HOST_RUN(r1) mr r3, r4
lwz r2, HOST_R2(r1) lwz r2, HOST_R2(r1)
mr r14, r4 /* Save vcpu pointer. */ mr r14, r4 /* Save vcpu pointer. */
...@@ -337,15 +337,14 @@ heavyweight_exit: ...@@ -337,15 +337,14 @@ heavyweight_exit:
/* Registers: /* Registers:
* r3: kvm_run pointer * r3: vcpu pointer
* r4: vcpu pointer
*/ */
_GLOBAL(__kvmppc_vcpu_run) _GLOBAL(__kvmppc_vcpu_run)
stwu r1, -HOST_STACK_SIZE(r1) stwu r1, -HOST_STACK_SIZE(r1)
stw r1, VCPU_HOST_STACK(r4) /* Save stack pointer to vcpu. */ stw r1, VCPU_HOST_STACK(r3) /* Save stack pointer to vcpu. */
/* Save host state to stack. */ /* Save host state to stack. */
stw r3, HOST_RUN(r1) mr r4, r3
mflr r3 mflr r3
stw r3, HOST_STACK_LR(r1) stw r3, HOST_STACK_LR(r1)
mfcr r5 mfcr r5
......
...@@ -434,9 +434,10 @@ _GLOBAL(kvmppc_resume_host) ...@@ -434,9 +434,10 @@ _GLOBAL(kvmppc_resume_host)
#endif #endif
/* Switch to kernel stack and jump to handler. */ /* Switch to kernel stack and jump to handler. */
PPC_LL r3, HOST_RUN(r1) mr r3, r4
mr r5, r14 /* intno */ mr r5, r14 /* intno */
mr r14, r4 /* Save vcpu pointer. */ mr r14, r4 /* Save vcpu pointer. */
mr r4, r5
bl kvmppc_handle_exit bl kvmppc_handle_exit
/* Restore vcpu pointer and the nonvolatiles we used. */ /* Restore vcpu pointer and the nonvolatiles we used. */
...@@ -525,15 +526,14 @@ heavyweight_exit: ...@@ -525,15 +526,14 @@ heavyweight_exit:
blr blr
/* Registers: /* Registers:
* r3: kvm_run pointer * r3: vcpu pointer
* r4: vcpu pointer
*/ */
_GLOBAL(__kvmppc_vcpu_run) _GLOBAL(__kvmppc_vcpu_run)
stwu r1, -HOST_STACK_SIZE(r1) stwu r1, -HOST_STACK_SIZE(r1)
PPC_STL r1, VCPU_HOST_STACK(r4) /* Save stack pointer to vcpu. */ PPC_STL r1, VCPU_HOST_STACK(r3) /* Save stack pointer to vcpu. */
/* Save host state to stack. */ /* Save host state to stack. */
PPC_STL r3, HOST_RUN(r1) mr r4, r3
mflr r3 mflr r3
mfcr r5 mfcr r5
PPC_STL r3, HOST_STACK_LR(r1) PPC_STL r3, HOST_STACK_LR(r1)
......
...@@ -403,7 +403,10 @@ int kvmppc_ld(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr, ...@@ -403,7 +403,10 @@ int kvmppc_ld(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr,
return EMULATE_DONE; return EMULATE_DONE;
} }
if (kvm_read_guest(vcpu->kvm, pte.raddr, ptr, size)) vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
rc = kvm_read_guest(vcpu->kvm, pte.raddr, ptr, size);
srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
if (rc)
return EMULATE_DO_MMIO; return EMULATE_DO_MMIO;
return EMULATE_DONE; return EMULATE_DONE;
......
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