From: Chris Wright <chrisw@sous-sol.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Chris Wright <chrisw@sous-sol.org>, Andi Kleen <ak@suse.de>,
Jeremy Fitzhardinge <jeremy@goop.org>,
patches@x86-64.org, linux-kernel@vger.kernel.org,
Rusty Russell <rusty@rustcorp.com.au>,
Zach Amsden <zach@vmware.com>
Subject: [PATCH] x86: skip paravirt patching when appropriate
Date: Sat, 18 Aug 2007 15:28:21 -0700 [thread overview]
Message-ID: <20070818222821.GX3672@sequoia.sous-sol.org> (raw)
In-Reply-To: <20070818213141.GW3672@sequoia.sous-sol.org>
* Chris Wright (chrisw@sous-sol.org) wrote:
> Now that I understand the problem, I do have a very simple (slightly
> overkill) fix for paravirt patching. This can be cleaned up to avoid
> the copies when they aren't needed, but that will take a little more
> auditing of the various patchers. If you still prefer a revert I've
> got one handy, and we can re-visit this all post .23.
This one avoids the patching when necessary, but needs some validation on
VMI (and Zach's not avail today). I'll resend when I know it's working
for all paravirt patchers.
thanks,
-chris
--
Subject: [PATCH] x86: skip paravirt patching when appropriate
From: Chris Wright <chrisw@sous-sol.org>
commit d34fda4a84c18402640a1a2342d6e6d9829e6db7 was a little overkill
in the case where a paravirt patcher chooses to leave patch site
unpatched. Instead of copying original instructions to temp buffer
then back to patch site, simply skip patching those sites altogether.
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Zach Amsden <zach@vmware.com>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
---
arch/i386/kernel/alternative.c | 4 ++--
arch/i386/kernel/paravirt.c | 10 +++++-----
arch/i386/kernel/vmi.c | 4 ++--
include/asm-i386/paravirt.h | 3 +++
4 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/arch/i386/kernel/alternative.c b/arch/i386/kernel/alternative.c
index 9f4ac8b..b81d87e 100644
--- a/arch/i386/kernel/alternative.c
+++ b/arch/i386/kernel/alternative.c
@@ -366,10 +366,10 @@ void apply_paravirt(struct paravirt_patch_site *start,
unsigned int used;
BUG_ON(p->len > MAX_PATCH_LEN);
- /* prep the buffer with the original instructions */
- memcpy(insnbuf, p->instr, p->len);
used = paravirt_ops.patch(p->instrtype, p->clobbers, insnbuf,
(unsigned long)p->instr, p->len);
+ if (used == PV_NO_PATCH)
+ continue;
BUG_ON(used > p->len);
diff --git a/arch/i386/kernel/paravirt.c b/arch/i386/kernel/paravirt.c
index 739cfb2..a36ce34 100644
--- a/arch/i386/kernel/paravirt.c
+++ b/arch/i386/kernel/paravirt.c
@@ -122,7 +122,7 @@ unsigned paravirt_patch_nop(void)
unsigned paravirt_patch_ignore(unsigned len)
{
- return len;
+ return PV_NO_PATCH;
}
struct branch {
@@ -139,9 +139,9 @@ unsigned paravirt_patch_call(void *insnbuf,
unsigned long delta = (unsigned long)target - (addr+5);
if (tgt_clobbers & ~site_clobbers)
- return len; /* target would clobber too much for this site */
+ return PV_NO_PATCH; /* target would clobber too much for this site */
if (len < 5)
- return len; /* call too long for patch site */
+ return PV_NO_PATCH; /* call too long for patch site */
b->opcode = 0xe8; /* call */
b->delta = delta;
@@ -157,7 +157,7 @@ unsigned paravirt_patch_jmp(const void *target, void *insnbuf,
unsigned long delta = (unsigned long)target - (addr+5);
if (len < 5)
- return len; /* call too long for patch site */
+ return PV_NO_PATCH; /* call too long for patch site */
b->opcode = 0xe9; /* jmp */
b->delta = delta;
@@ -196,7 +196,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
unsigned insn_len = end - start;
if (insn_len > len || start == NULL)
- insn_len = len;
+ insn_len = PV_NO_PATCH;
else
memcpy(insnbuf, start, insn_len);
diff --git a/arch/i386/kernel/vmi.c b/arch/i386/kernel/vmi.c
index 18673e0..27ae004 100644
--- a/arch/i386/kernel/vmi.c
+++ b/arch/i386/kernel/vmi.c
@@ -118,7 +118,7 @@ static unsigned patch_internal(int call, unsigned len, void *insnbuf,
case VMI_RELOCATION_NONE:
/* leave native code in place */
- break;
+ return PV_NO_PATCH;
default:
BUG();
@@ -153,7 +153,7 @@ static unsigned vmi_patch(u8 type, u16 clobbers, void *insns,
default:
break;
}
- return len;
+ return PV_NO_PATCH;
}
/* CPUID has non-C semantics, and paravirt-ops API doesn't match hardware ISA */
diff --git a/include/asm-i386/paravirt.h b/include/asm-i386/paravirt.h
index 9fa3fa9..b26794f 100644
--- a/include/asm-i386/paravirt.h
+++ b/include/asm-i386/paravirt.h
@@ -252,6 +252,9 @@ extern struct paravirt_ops paravirt_ops;
#define paravirt_alt(insn_string) \
_paravirt_alt(insn_string, "%c[paravirt_typenum]", "%c[paravirt_clobber]")
+enum {
+ PV_NO_PATCH = -1
+};
unsigned paravirt_patch_nop(void);
unsigned paravirt_patch_ignore(unsigned len);
unsigned paravirt_patch_call(void *insnbuf,
next prev parent reply other threads:[~2007-08-18 22:28 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-09 12:41 [PATCH] [0/12] x86 Late merge bug fixes for 2.6.23 Andi Kleen
2007-08-09 12:41 ` [PATCH] [1/12] x86: Work around mmio config space quirk on AMD Fam10h Andi Kleen
2007-08-10 10:19 ` [patches] " Joachim Deguara
2007-08-12 9:25 ` Linus Torvalds
2007-08-12 10:03 ` Andi Kleen
2007-08-12 19:15 ` Linus Torvalds
2007-08-13 3:06 ` Dave Jones
2007-08-13 3:26 ` Linus Torvalds
2007-08-13 3:38 ` dean gaudet
2007-08-09 12:41 ` [PATCH] [2/12] x86_64: Calgary - Fix mis-handled PCI topology Andi Kleen
2007-08-09 12:41 ` [PATCH] [3/12] x86_64: Don't mark __exitcall as __cold Andi Kleen
2007-08-09 12:41 ` [PATCH] [4/12] x86_64: Disable CLFLUSH support again Andi Kleen
2007-08-09 12:54 ` [patches] " Jan Beulich
2007-08-09 13:11 ` Muli Ben-Yehuda
2007-08-09 13:12 ` Andi Kleen
2007-08-09 13:29 ` [patches] " Jan Beulich
2007-08-09 16:24 ` Muli Ben-Yehuda
2007-08-09 12:41 ` [PATCH] [5/12] x86_64: Make patching more robust, fix paravirt issue Andi Kleen
2007-08-18 0:05 ` Jeremy Fitzhardinge
2007-08-18 0:11 ` Chris Wright
2007-08-18 9:49 ` Andi Kleen
2007-08-18 20:32 ` Chris Wright
2007-08-18 20:55 ` Linus Torvalds
2007-08-18 21:31 ` Chris Wright
2007-08-18 22:28 ` Chris Wright [this message]
2007-08-19 3:08 ` [PATCH] x86: skip paravirt patching when appropriate Zachary Amsden
2007-08-19 5:55 ` Zachary Amsden
2007-08-18 21:58 ` [PATCH] [5/12] x86_64: Make patching more robust, fix paravirt issue Jeremy Fitzhardinge
2007-08-20 1:50 ` Rusty Russell
2007-08-20 2:07 ` Chris Wright
2007-08-20 6:15 ` Jeremy Fitzhardinge
2007-08-21 7:30 ` Glauber de Oliveira Costa
2007-08-21 11:23 ` Andi Kleen
2007-08-21 12:26 ` Glauber de Oliveira Costa
2007-08-09 12:41 ` [PATCH] [6/12] x86_64: Early segment setup for VT Andi Kleen
2007-10-11 21:30 ` H. Peter Anvin
2007-08-09 12:41 ` [PATCH] [7/12] x86_64: really stop MCEs during code patching Andi Kleen
2007-08-09 12:41 ` [PATCH] [8/12] x86_64: Use global flag to disable broken local apic timer on AMD CPUs Andi Kleen
2007-08-09 16:46 ` Cal Peake
2007-08-09 16:50 ` Andi Kleen
2007-08-09 12:41 ` [PATCH] [9/12] x86_64: Avoid NMI Watchdog and/or long wait in setup_APIC_timer Andi Kleen
2007-08-09 12:41 ` [PATCH] [10/12] x86_64: Add warning in Documentation that zero-page is not a stable ABI Andi Kleen
2007-08-09 12:41 ` [PATCH] [11/12] x86_64: vdso.lds in arch/x86_64/vdso/.gitignore Andi Kleen
2007-08-09 12:41 ` [PATCH] [12/12] x86_64: Fix start_kernel warning Andi Kleen
2007-08-09 13:06 ` [PATCH] [0/12] x86 Late merge bug fixes for 2.6.23 Muli Ben-Yehuda
2007-08-09 13:12 ` Andi Kleen
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=20070818222821.GX3672@sequoia.sous-sol.org \
--to=chrisw@sous-sol.org \
--cc=ak@suse.de \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@x86-64.org \
--cc=rusty@rustcorp.com.au \
--cc=torvalds@linux-foundation.org \
--cc=zach@vmware.com \
/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
all inboxes | Powered by JetHome®