KVM: ppc: turn tlb_xlate() into a per-core hook (and give it a better name)
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
Родитель
58a96214a3
Коммит
be8d1cae07
|
@ -59,6 +59,8 @@ extern void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 gvaddr, gpa_t gpaddr,
|
||||||
extern void kvmppc_mmu_priv_switch(struct kvm_vcpu *vcpu, int usermode);
|
extern void kvmppc_mmu_priv_switch(struct kvm_vcpu *vcpu, int usermode);
|
||||||
extern void kvmppc_mmu_switch_pid(struct kvm_vcpu *vcpu, u32 pid);
|
extern void kvmppc_mmu_switch_pid(struct kvm_vcpu *vcpu, u32 pid);
|
||||||
extern void kvmppc_mmu_destroy(struct kvm_vcpu *vcpu);
|
extern void kvmppc_mmu_destroy(struct kvm_vcpu *vcpu);
|
||||||
|
extern gpa_t kvmppc_mmu_xlate(struct kvm_vcpu *vcpu, unsigned int gtlb_index,
|
||||||
|
gva_t eaddr);
|
||||||
|
|
||||||
extern struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm,
|
extern struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm,
|
||||||
unsigned int id);
|
unsigned int id);
|
||||||
|
|
|
@ -149,8 +149,6 @@ int kvmppc_core_vcpu_setup(struct kvm_vcpu *vcpu)
|
||||||
int kvmppc_core_vcpu_translate(struct kvm_vcpu *vcpu,
|
int kvmppc_core_vcpu_translate(struct kvm_vcpu *vcpu,
|
||||||
struct kvm_translation *tr)
|
struct kvm_translation *tr)
|
||||||
{
|
{
|
||||||
struct kvmppc_vcpu_44x *vcpu_44x = to_44x(vcpu);
|
|
||||||
struct kvmppc_44x_tlbe *gtlbe;
|
|
||||||
int index;
|
int index;
|
||||||
gva_t eaddr;
|
gva_t eaddr;
|
||||||
u8 pid;
|
u8 pid;
|
||||||
|
@ -166,9 +164,7 @@ int kvmppc_core_vcpu_translate(struct kvm_vcpu *vcpu,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtlbe = &vcpu_44x->guest_tlb[index];
|
tr->physical_address = kvmppc_mmu_xlate(vcpu, index, eaddr);
|
||||||
|
|
||||||
tr->physical_address = tlb_xlate(gtlbe, eaddr);
|
|
||||||
/* XXX what does "writeable" and "usermode" even mean? */
|
/* XXX what does "writeable" and "usermode" even mean? */
|
||||||
tr->valid = 1;
|
tr->valid = 1;
|
||||||
|
|
||||||
|
|
|
@ -208,6 +208,16 @@ int kvmppc_44x_tlb_index(struct kvm_vcpu *vcpu, gva_t eaddr, unsigned int pid,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gpa_t kvmppc_mmu_xlate(struct kvm_vcpu *vcpu, unsigned int gtlb_index,
|
||||||
|
gva_t eaddr)
|
||||||
|
{
|
||||||
|
struct kvmppc_vcpu_44x *vcpu_44x = to_44x(vcpu);
|
||||||
|
struct kvmppc_44x_tlbe *gtlbe = &vcpu_44x->guest_tlb[gtlb_index];
|
||||||
|
unsigned int pgmask = get_tlb_bytes(gtlbe) - 1;
|
||||||
|
|
||||||
|
return get_tlb_raddr(gtlbe) | (eaddr & pgmask);
|
||||||
|
}
|
||||||
|
|
||||||
int kvmppc_44x_itlb_index(struct kvm_vcpu *vcpu, gva_t eaddr)
|
int kvmppc_44x_itlb_index(struct kvm_vcpu *vcpu, gva_t eaddr)
|
||||||
{
|
{
|
||||||
unsigned int as = !!(vcpu->arch.msr & MSR_IS);
|
unsigned int as = !!(vcpu->arch.msr & MSR_IS);
|
||||||
|
|
|
@ -85,11 +85,4 @@ static inline unsigned int get_mmucr_sts(const struct kvm_vcpu *vcpu)
|
||||||
return (vcpu->arch.mmucr >> 16) & 0x1;
|
return (vcpu->arch.mmucr >> 16) & 0x1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline gpa_t tlb_xlate(struct kvmppc_44x_tlbe *tlbe, gva_t eaddr)
|
|
||||||
{
|
|
||||||
unsigned int pgmask = get_tlb_bytes(tlbe) - 1;
|
|
||||||
|
|
||||||
return get_tlb_raddr(tlbe) | (eaddr & pgmask);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* __KVM_POWERPC_TLB_H__ */
|
#endif /* __KVM_POWERPC_TLB_H__ */
|
||||||
|
|
|
@ -286,8 +286,6 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
|
||||||
|
|
||||||
/* XXX move to a 440-specific file. */
|
/* XXX move to a 440-specific file. */
|
||||||
case BOOKE_INTERRUPT_DTLB_MISS: {
|
case BOOKE_INTERRUPT_DTLB_MISS: {
|
||||||
struct kvmppc_vcpu_44x *vcpu_44x = to_44x(vcpu);
|
|
||||||
struct kvmppc_44x_tlbe *gtlbe;
|
|
||||||
unsigned long eaddr = vcpu->arch.fault_dear;
|
unsigned long eaddr = vcpu->arch.fault_dear;
|
||||||
int gtlb_index;
|
int gtlb_index;
|
||||||
gpa_t gpaddr;
|
gpa_t gpaddr;
|
||||||
|
@ -305,8 +303,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtlbe = &vcpu_44x->guest_tlb[gtlb_index];
|
gpaddr = kvmppc_mmu_xlate(vcpu, gtlb_index, eaddr);
|
||||||
gpaddr = tlb_xlate(gtlbe, eaddr);
|
|
||||||
gfn = gpaddr >> PAGE_SHIFT;
|
gfn = gpaddr >> PAGE_SHIFT;
|
||||||
|
|
||||||
if (kvm_is_visible_gfn(vcpu->kvm, gfn)) {
|
if (kvm_is_visible_gfn(vcpu->kvm, gfn)) {
|
||||||
|
@ -332,8 +329,6 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
|
||||||
|
|
||||||
/* XXX move to a 440-specific file. */
|
/* XXX move to a 440-specific file. */
|
||||||
case BOOKE_INTERRUPT_ITLB_MISS: {
|
case BOOKE_INTERRUPT_ITLB_MISS: {
|
||||||
struct kvmppc_vcpu_44x *vcpu_44x = to_44x(vcpu);
|
|
||||||
struct kvmppc_44x_tlbe *gtlbe;
|
|
||||||
unsigned long eaddr = vcpu->arch.pc;
|
unsigned long eaddr = vcpu->arch.pc;
|
||||||
gpa_t gpaddr;
|
gpa_t gpaddr;
|
||||||
gfn_t gfn;
|
gfn_t gfn;
|
||||||
|
@ -352,8 +347,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
|
||||||
|
|
||||||
kvmppc_account_exit(vcpu, ITLB_VIRT_MISS_EXITS);
|
kvmppc_account_exit(vcpu, ITLB_VIRT_MISS_EXITS);
|
||||||
|
|
||||||
gtlbe = &vcpu_44x->guest_tlb[gtlb_index];
|
gpaddr = kvmppc_mmu_xlate(vcpu, gtlb_index, eaddr);
|
||||||
gpaddr = tlb_xlate(gtlbe, eaddr);
|
|
||||||
gfn = gpaddr >> PAGE_SHIFT;
|
gfn = gpaddr >> PAGE_SHIFT;
|
||||||
|
|
||||||
if (kvm_is_visible_gfn(vcpu->kvm, gfn)) {
|
if (kvm_is_visible_gfn(vcpu->kvm, gfn)) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче