* [PATCH v3] KVM: PPC: Avoid patching paravirt template code
@ 2011-12-02 6:22 Liu Yu
2011-12-19 13:46 ` Alexander Graf
0 siblings, 1 reply; 3+ messages in thread
From: Liu Yu @ 2011-12-02 6:22 UTC (permalink / raw)
To: kvm-ppc
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>
---
v2:
exclude the entire template region in the main loop
v3:
make the boundary test more safe
arch/powerpc/kernel/kvm.c | 11 ++++++++++-
arch/powerpc/kernel/kvm_emul.S | 6 ++++++
2 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/arch/powerpc/kernel/kvm.c b/arch/powerpc/kernel/kvm.c
index 3953fbd..55e999d 100644
--- a/arch/powerpc/kernel/kvm.c
+++ b/arch/powerpc/kernel/kvm.c
@@ -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();
diff --git a/arch/powerpc/kernel/kvm_emul.S b/arch/powerpc/kernel/kvm_emul.S
index 801058d..e291cf3 100644
--- a/arch/powerpc/kernel/kvm_emul.S
+++ b/arch/powerpc/kernel/kvm_emul.S
@@ -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:
--
1.6.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3] KVM: PPC: Avoid patching paravirt template code
2011-12-02 6:22 [PATCH v3] KVM: PPC: Avoid patching paravirt template code Liu Yu
@ 2011-12-19 13:46 ` Alexander Graf
0 siblings, 0 replies; 3+ messages in thread
From: Alexander Graf @ 2011-12-19 13:46 UTC (permalink / raw)
To: Liu Yu; +Cc: kvm-ppc, kvm list
On 02.12.2011, at 07:22, Liu Yu wrote:
> 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>
Thanks, applied to kvm-ppc-next. Please CC kvm@vger for KVM related patches in the future.
Alex
> ---
> v2:
> exclude the entire template region in the main loop
>
> v3:
> make the boundary test more safe
>
> arch/powerpc/kernel/kvm.c | 11 ++++++++++-
> arch/powerpc/kernel/kvm_emul.S | 6 ++++++
> 2 files changed, 16 insertions(+), 1 deletions(-)
>
> diff --git a/arch/powerpc/kernel/kvm.c b/arch/powerpc/kernel/kvm.c
> index 3953fbd..55e999d 100644
> --- a/arch/powerpc/kernel/kvm.c
> +++ b/arch/powerpc/kernel/kvm.c
> @@ -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();
>
> diff --git a/arch/powerpc/kernel/kvm_emul.S b/arch/powerpc/kernel/kvm_emul.S
> index 801058d..e291cf3 100644
> --- a/arch/powerpc/kernel/kvm_emul.S
> +++ b/arch/powerpc/kernel/kvm_emul.S
> @@ -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:
> --
> 1.6.4
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] KVM: PPC: Avoid patching paravirt template code
@ 2011-12-19 13:46 ` Alexander Graf
0 siblings, 0 replies; 3+ messages in thread
From: Alexander Graf @ 2011-12-19 13:46 UTC (permalink / raw)
To: Liu Yu; +Cc: kvm-ppc, kvm list
On 02.12.2011, at 07:22, Liu Yu wrote:
> 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>
Thanks, applied to kvm-ppc-next. Please CC kvm@vger for KVM related patches in the future.
Alex
> ---
> v2:
> exclude the entire template region in the main loop
>
> v3:
> make the boundary test more safe
>
> arch/powerpc/kernel/kvm.c | 11 ++++++++++-
> arch/powerpc/kernel/kvm_emul.S | 6 ++++++
> 2 files changed, 16 insertions(+), 1 deletions(-)
>
> diff --git a/arch/powerpc/kernel/kvm.c b/arch/powerpc/kernel/kvm.c
> index 3953fbd..55e999d 100644
> --- a/arch/powerpc/kernel/kvm.c
> +++ b/arch/powerpc/kernel/kvm.c
> @@ -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();
>
> diff --git a/arch/powerpc/kernel/kvm_emul.S b/arch/powerpc/kernel/kvm_emul.S
> index 801058d..e291cf3 100644
> --- a/arch/powerpc/kernel/kvm_emul.S
> +++ b/arch/powerpc/kernel/kvm_emul.S
> @@ -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:
> --
> 1.6.4
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-12-19 13:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-02 6:22 [PATCH v3] KVM: PPC: Avoid patching paravirt template code Liu Yu
2011-12-19 13:46 ` Alexander Graf
2011-12-19 13:46 ` Alexander Graf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.