KVM: PPC: Avoid patching paravirt template code
authorLiu Yu-B13201 <Yu.Liu@freescale.com>
Thu, 1 Dec 2011 20:22:53 +0000 (20:22 +0000)
committerAvi Kivity <avi@redhat.com>
Mon, 5 Mar 2012 12:52:34 +0000 (14:52 +0200)
Currently we patch the whole code include paravirt template code.
This isn't safe for scratch area and has impact to performance.

Signed-off-by: Liu Yu <yu.liu@freescale.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/powerpc/kernel/kvm.c
arch/powerpc/kernel/kvm_emul.S

index 04d4b5aa6dcae5eaac326972d9a028671f086b6e..62bdf238966985d8b98d84105b3fd4d108601194 100644 (file)
@@ -665,6 +665,9 @@ static void kvm_check_ins(u32 *inst, u32 features)
        }
 }
 
+extern u32 kvm_template_start[];
+extern u32 kvm_template_end[];
+
 static void kvm_use_magic_page(void)
 {
        u32 *p;
@@ -692,8 +695,14 @@ static void kvm_use_magic_page(void)
         */
        local_irq_disable();
 
-       for (p = start; p < end; p++)
+       for (p = start; p < end; p++) {
+               /* Avoid patching the template code */
+               if (p >= kvm_template_start && p < kvm_template_end) {
+                       p = kvm_template_end - 1;
+                       continue;
+               }
                kvm_check_ins(p, features);
+       }
 
        local_irq_enable();
 
index 801058dd74dbc8ab887fbe5a66b56ccc2008ed3a..e291cf3cf954b9c718fb240eceeed0823b6b436a 100644 (file)
@@ -66,6 +66,9 @@ kvm_hypercall_start:
           shared->critical == r1 and r2 is always != r1 */             \
        STL64(r2, KVM_MAGIC_PAGE + KVM_MAGIC_CRITICAL, 0);
 
+.global kvm_template_start
+kvm_template_start:
+
 .global kvm_emulate_mtmsrd
 kvm_emulate_mtmsrd:
 
@@ -350,3 +353,6 @@ kvm_emulate_mtsrin_orig_ins_offs:
 .global kvm_emulate_mtsrin_len
 kvm_emulate_mtsrin_len:
        .long (kvm_emulate_mtsrin_end - kvm_emulate_mtsrin) / 4
+
+.global kvm_template_end
+kvm_template_end: