Commit df08bd10 authored by Alexander Graf's avatar Alexander Graf Committed by Avi Kivity

KVM: PPC: Make PV mtmsrd L=1 work with r30 and r31

We had an arbitrary limitation in mtmsrd L=1 that kept us from using r30 and
r31 as input registers. Let's get rid of that and get more potential speedups!
Signed-off-by: default avatarAlexander Graf <agraf@suse.de>
parent 9ee18b1e
...@@ -158,6 +158,7 @@ static u32 *kvm_alloc(int len) ...@@ -158,6 +158,7 @@ static u32 *kvm_alloc(int len)
extern u32 kvm_emulate_mtmsrd_branch_offs; extern u32 kvm_emulate_mtmsrd_branch_offs;
extern u32 kvm_emulate_mtmsrd_reg_offs; extern u32 kvm_emulate_mtmsrd_reg_offs;
extern u32 kvm_emulate_mtmsrd_orig_ins_offs;
extern u32 kvm_emulate_mtmsrd_len; extern u32 kvm_emulate_mtmsrd_len;
extern u32 kvm_emulate_mtmsrd[]; extern u32 kvm_emulate_mtmsrd[];
...@@ -186,7 +187,21 @@ static void kvm_patch_ins_mtmsrd(u32 *inst, u32 rt) ...@@ -186,7 +187,21 @@ static void kvm_patch_ins_mtmsrd(u32 *inst, u32 rt)
/* Modify the chunk to fit the invocation */ /* Modify the chunk to fit the invocation */
memcpy(p, kvm_emulate_mtmsrd, kvm_emulate_mtmsrd_len * 4); memcpy(p, kvm_emulate_mtmsrd, kvm_emulate_mtmsrd_len * 4);
p[kvm_emulate_mtmsrd_branch_offs] |= distance_end & KVM_INST_B_MASK; p[kvm_emulate_mtmsrd_branch_offs] |= distance_end & KVM_INST_B_MASK;
p[kvm_emulate_mtmsrd_reg_offs] |= rt; switch (get_rt(rt)) {
case 30:
kvm_patch_ins_ll(&p[kvm_emulate_mtmsrd_reg_offs],
magic_var(scratch2), KVM_RT_30);
break;
case 31:
kvm_patch_ins_ll(&p[kvm_emulate_mtmsrd_reg_offs],
magic_var(scratch1), KVM_RT_30);
break;
default:
p[kvm_emulate_mtmsrd_reg_offs] |= rt;
break;
}
p[kvm_emulate_mtmsrd_orig_ins_offs] = *inst;
flush_icache_range((ulong)p, (ulong)p + kvm_emulate_mtmsrd_len * 4); flush_icache_range((ulong)p, (ulong)p + kvm_emulate_mtmsrd_len * 4);
/* Patch the invocation */ /* Patch the invocation */
...@@ -423,9 +438,7 @@ static void kvm_check_ins(u32 *inst, u32 features) ...@@ -423,9 +438,7 @@ static void kvm_check_ins(u32 *inst, u32 features)
/* Rewrites */ /* Rewrites */
case KVM_INST_MTMSRD_L1: case KVM_INST_MTMSRD_L1:
/* We use r30 and r31 during the hook */ kvm_patch_ins_mtmsrd(inst, inst_rt);
if (get_rt(inst_rt) < 30)
kvm_patch_ins_mtmsrd(inst, inst_rt);
break; break;
case KVM_INST_MTMSR: case KVM_INST_MTMSR:
case KVM_INST_MTMSRD_L0: case KVM_INST_MTMSRD_L0:
......
...@@ -78,7 +78,8 @@ kvm_emulate_mtmsrd: ...@@ -78,7 +78,8 @@ kvm_emulate_mtmsrd:
/* OR the register's (MSR_EE|MSR_RI) on MSR */ /* OR the register's (MSR_EE|MSR_RI) on MSR */
kvm_emulate_mtmsrd_reg: kvm_emulate_mtmsrd_reg:
andi. r30, r0, (MSR_EE|MSR_RI) ori r30, r0, 0
andi. r30, r30, (MSR_EE|MSR_RI)
or r31, r31, r30 or r31, r31, r30
/* Put MSR back into magic page */ /* Put MSR back into magic page */
...@@ -96,6 +97,7 @@ kvm_emulate_mtmsrd_reg: ...@@ -96,6 +97,7 @@ kvm_emulate_mtmsrd_reg:
SCRATCH_RESTORE SCRATCH_RESTORE
/* Nag hypervisor */ /* Nag hypervisor */
kvm_emulate_mtmsrd_orig_ins:
tlbsync tlbsync
b kvm_emulate_mtmsrd_branch b kvm_emulate_mtmsrd_branch
...@@ -117,6 +119,10 @@ kvm_emulate_mtmsrd_branch_offs: ...@@ -117,6 +119,10 @@ kvm_emulate_mtmsrd_branch_offs:
kvm_emulate_mtmsrd_reg_offs: kvm_emulate_mtmsrd_reg_offs:
.long (kvm_emulate_mtmsrd_reg - kvm_emulate_mtmsrd) / 4 .long (kvm_emulate_mtmsrd_reg - kvm_emulate_mtmsrd) / 4
.global kvm_emulate_mtmsrd_orig_ins_offs
kvm_emulate_mtmsrd_orig_ins_offs:
.long (kvm_emulate_mtmsrd_orig_ins - kvm_emulate_mtmsrd) / 4
.global kvm_emulate_mtmsrd_len .global kvm_emulate_mtmsrd_len
kvm_emulate_mtmsrd_len: kvm_emulate_mtmsrd_len:
.long (kvm_emulate_mtmsrd_end - kvm_emulate_mtmsrd) / 4 .long (kvm_emulate_mtmsrd_end - kvm_emulate_mtmsrd) / 4
......
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