From: Anthony Liguori <aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: kvm-devel <kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Cc: virtualization <virtualization-qjLDD68F18O7TbgM5vRIOg@public.gmane.org>
Subject: [PATCH 3/3] Eliminate read_cr3 on TLB flush
Date: Wed, 30 May 2007 09:53:41 -0500 [thread overview]
Message-ID: <465D8FF5.6040804@us.ibm.com> (raw)
In-Reply-To: <465D8F03.7000201-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 26 bytes --]
Regards,
Anthony Liguori
[-- Attachment #2: paravirt-no-read-cr3-flush.diff --]
[-- Type: text/x-patch, Size: 1619 bytes --]
Subject: [PATCH][PARAVIRT] Eliminate unnecessary CR3 read in TLB flush
This patch eliminates the CR3 read (which would cause a VM exit) in the TLB
flush path. The patch is based on Ingo Molnar's paravirt series.
Signed-off-by: Anthony Liguori <aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Index: kvm/arch/i386/kernel/kvm.c
===================================================================
--- kvm.orig/arch/i386/kernel/kvm.c 2007-05-30 09:13:48.000000000 -0500
+++ kvm/arch/i386/kernel/kvm.c 2007-05-30 09:14:24.000000000 -0500
@@ -24,11 +24,35 @@
#include <linux/kernel.h>
#include <linux/kvm_para.h>
#include <linux/cpu.h>
+#include <linux/mm.h>
+#include <asm/processor.h>
+#include <asm/tlbflush.h>
static DEFINE_PER_CPU(struct kvm_vcpu_para_state, para_state);
extern unsigned char hypercall_addr[4];
/*
+ * Avoid the VM exit upon cr3 load by using the cached
+ * ->active_mm->pgd value:
+ */
+static void kvm_flush_tlb_user(void)
+{
+ write_cr3(__pa(current->active_mm->pgd));
+}
+
+/*
+ * Avoid VM exit for cr3 read by calling into kvm_flush_tlb_user
+ */
+static fastcall void kvm_flush_tlb_kernel(void)
+{
+ unsigned long orig_cr4 = read_cr4();
+
+ write_cr4(orig_cr4 & ~X86_CR4_PGE);
+ kvm_flush_tlb_user();
+ write_cr4(orig_cr4);
+}
+
+/*
* No need for any "IO delay" on KVM
*/
static void kvm_io_delay(void)
@@ -38,6 +62,8 @@
static void kvm_guest_setup(void)
{
paravirt_ops.name = "KVM";
+ paravirt_ops.flush_tlb_user = kvm_flush_tlb_user;
+ paravirt_ops.flush_tlb_kernel = kvm_flush_tlb_kernel;
paravirt_ops.io_delay = kvm_io_delay;
paravirt_ops.paravirt_enabled = 1;
}
[-- Attachment #3: Type: text/plain, Size: 286 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
[-- Attachment #4: Type: text/plain, Size: 186 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel
next prev parent reply other threads:[~2007-05-30 14:53 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-30 14:49 [PATCH 0/3] KVM paravirt_ops implementation Anthony Liguori
2007-05-30 14:52 ` [PATCH 1/3] KVM paravirt_ops infrastructure Anthony Liguori
2007-05-30 16:42 ` [kvm-devel] " Nakajima, Jun
[not found] ` <97D612E30E1F88419025B06CB4CF1BE10259AAD7-1a9uaKK1+wJcIJlls4ac1rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-05-30 18:11 ` Anthony Liguori
[not found] ` <465DBE3A.6030908-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-05-30 19:04 ` Nakajima, Jun
[not found] ` <97D612E30E1F88419025B06CB4CF1BE10259AD83-1a9uaKK1+wJcIJlls4ac1rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-05-31 17:31 ` Anthony Liguori
[not found] ` <465F0688.1050702-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-05-31 18:47 ` Nakajima, Jun
2007-05-31 1:02 ` Rusty Russell
2007-05-31 1:15 ` [kvm-devel] " Anthony Liguori
[not found] ` <1180573347.30202.135.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-05-31 7:48 ` Avi Kivity
2007-05-31 9:58 ` Andi Kleen
[not found] ` <200705311158.28632.ak-l3A5Bk7waGM@public.gmane.org>
2007-05-31 10:11 ` Ingo Molnar
[not found] ` <20070531101116.GA10872-X9Un+BFzKDI@public.gmane.org>
2007-05-31 10:40 ` Andi Kleen
[not found] ` <200705311240.19794.ak-l3A5Bk7waGM@public.gmane.org>
2007-05-31 11:12 ` Rusty Russell
2007-05-31 17:28 ` [kvm-devel] " Anthony Liguori
2007-05-31 17:29 ` Anthony Liguori
2007-05-30 14:53 ` [PATCH 2/3][PARAVIRT] Make IO delay a NOP Anthony Liguori
[not found] ` <465D8F03.7000201-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-05-30 14:53 ` Anthony Liguori [this message]
[not found] ` <465D8FF5.6040804-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-05-30 15:01 ` [PATCH 3/3] Eliminate read_cr3 on TLB flush Andi Kleen
2007-05-30 15:32 ` Anthony Liguori
2007-05-30 15:38 ` Jeremy Fitzhardinge
2007-05-30 17:11 ` [kvm-devel] " Nakajima, Jun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=465D8FF5.6040804@us.ibm.com \
--to=aliguori-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=virtualization-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).