aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
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
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')
-rw-r--r--arch/powerpc/kernel/kvm.c21
-rw-r--r--arch/powerpc/kernel/kvm_emul.S8
2 files changed, 24 insertions, 5 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:
diff --git a/arch/powerpc/kernel/kvm_emul.S b/arch/powerpc/kernel/kvm_emul.S
index 65305325250b..f2b1b2523e61 100644
--- a/arch/powerpc/kernel/kvm_emul.S
+++ b/arch/powerpc/kernel/kvm_emul.S
@@ -78,7 +78,8 @@ kvm_emulate_mtmsrd:
78 78
79 /* OR the register's (MSR_EE|MSR_RI) on MSR */ 79 /* OR the register's (MSR_EE|MSR_RI) on MSR */
80kvm_emulate_mtmsrd_reg: 80kvm_emulate_mtmsrd_reg:
81 andi. r30, r0, (MSR_EE|MSR_RI) 81 ori r30, r0, 0
82 andi. r30, r30, (MSR_EE|MSR_RI)
82 or r31, r31, r30 83 or r31, r31, r30
83 84
84 /* Put MSR back into magic page */ 85 /* Put MSR back into magic page */
@@ -96,6 +97,7 @@ kvm_emulate_mtmsrd_reg:
96 SCRATCH_RESTORE 97 SCRATCH_RESTORE
97 98
98 /* Nag hypervisor */ 99 /* Nag hypervisor */
100kvm_emulate_mtmsrd_orig_ins:
99 tlbsync 101 tlbsync
100 102
101 b kvm_emulate_mtmsrd_branch 103 b kvm_emulate_mtmsrd_branch
@@ -117,6 +119,10 @@ kvm_emulate_mtmsrd_branch_offs:
117kvm_emulate_mtmsrd_reg_offs: 119kvm_emulate_mtmsrd_reg_offs:
118 .long (kvm_emulate_mtmsrd_reg - kvm_emulate_mtmsrd) / 4 120 .long (kvm_emulate_mtmsrd_reg - kvm_emulate_mtmsrd) / 4
119 121
122.global kvm_emulate_mtmsrd_orig_ins_offs
123kvm_emulate_mtmsrd_orig_ins_offs:
124 .long (kvm_emulate_mtmsrd_orig_ins - kvm_emulate_mtmsrd) / 4
125
120.global kvm_emulate_mtmsrd_len 126.global kvm_emulate_mtmsrd_len
121kvm_emulate_mtmsrd_len: 127kvm_emulate_mtmsrd_len:
122 .long (kvm_emulate_mtmsrd_end - kvm_emulate_mtmsrd) / 4 128 .long (kvm_emulate_mtmsrd_end - kvm_emulate_mtmsrd) / 4