aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/kvm.c
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2010-08-05 09:44:41 -0400
committerAvi Kivity <avi@redhat.com>2010-10-24 04:52:14 -0400
commitdf08bd10266ce6132278f6b4ddc4bb0a12330b56 (patch)
treec0edb224d7b9fa46d18b66e6fcb622005f6e91c3 /arch/powerpc/kernel/kvm.c
parent9ee18b1e08e6a5648aeaaf998eabc72b5304cc17 (diff)
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: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc/kernel/kvm.c')
-rw-r--r--arch/powerpc/kernel/kvm.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/arch/powerpc/kernel/kvm.c b/arch/powerpc/kernel/kvm.c
index 10b681c092ed..48a033865410 100644
--- a/arch/powerpc/kernel/kvm.c
+++ b/arch/powerpc/kernel/kvm.c
@@ -158,6 +158,7 @@ static u32 *kvm_alloc(int len)
158 158
159extern u32 kvm_emulate_mtmsrd_branch_offs; 159extern u32 kvm_emulate_mtmsrd_branch_offs;
160extern u32 kvm_emulate_mtmsrd_reg_offs; 160extern u32 kvm_emulate_mtmsrd_reg_offs;
161extern u32 kvm_emulate_mtmsrd_orig_ins_offs;
161extern u32 kvm_emulate_mtmsrd_len; 162extern u32 kvm_emulate_mtmsrd_len;
162extern u32 kvm_emulate_mtmsrd[]; 163extern u32 kvm_emulate_mtmsrd[];
163 164
@@ -186,7 +187,21 @@ static void kvm_patch_ins_mtmsrd(u32 *inst, u32 rt)
186 /* Modify the chunk to fit the invocation */ 187 /* Modify the chunk to fit the invocation */
187 memcpy(p, kvm_emulate_mtmsrd, kvm_emulate_mtmsrd_len * 4); 188 memcpy(p, kvm_emulate_mtmsrd, kvm_emulate_mtmsrd_len * 4);
188 p[kvm_emulate_mtmsrd_branch_offs] |= distance_end & KVM_INST_B_MASK; 189 p[kvm_emulate_mtmsrd_branch_offs] |= distance_end & KVM_INST_B_MASK;
189 p[kvm_emulate_mtmsrd_reg_offs] |= rt; 190 switch (get_rt(rt)) {
191 case 30:
192 kvm_patch_ins_ll(&p[kvm_emulate_mtmsrd_reg_offs],
193 magic_var(scratch2), KVM_RT_30);
194 break;
195 case 31:
196 kvm_patch_ins_ll(&p[kvm_emulate_mtmsrd_reg_offs],
197 magic_var(scratch1), KVM_RT_30);
198 break;
199 default:
200 p[kvm_emulate_mtmsrd_reg_offs] |= rt;
201 break;
202 }
203
204 p[kvm_emulate_mtmsrd_orig_ins_offs] = *inst;
190 flush_icache_range((ulong)p, (ulong)p + kvm_emulate_mtmsrd_len * 4); 205 flush_icache_range((ulong)p, (ulong)p + kvm_emulate_mtmsrd_len * 4);
191 206
192 /* Patch the invocation */ 207 /* Patch the invocation */
@@ -423,9 +438,7 @@ static void kvm_check_ins(u32 *inst, u32 features)
423 438
424 /* Rewrites */ 439 /* Rewrites */
425 case KVM_INST_MTMSRD_L1: 440 case KVM_INST_MTMSRD_L1:
426 /* We use r30 and r31 during the hook */ 441 kvm_patch_ins_mtmsrd(inst, inst_rt);
427 if (get_rt(inst_rt) < 30)
428 kvm_patch_ins_mtmsrd(inst, inst_rt);
429 break; 442 break;
430 case KVM_INST_MTMSR: 443 case KVM_INST_MTMSR:
431 case KVM_INST_MTMSRD_L0: 444 case KVM_INST_MTMSRD_L0: