From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Zachary Amsden <zach@vmware.com>
Cc: Andrew Morton <akpm@osdl.org>, Zachary Amsden <zamsden@gmail.com>,
Andi Kleen <ak@muc.de>, Petr Vandrovec <petr@vmware.com>,
Chris Wright <chrisw@sous-sol.org>,
Virtualization Mailing List <virtualization@lists.osdl.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Ingo Molnar <mingo@elte.hu>
Subject: Re: [RFC, PATCH 5/5] Paravirt_ops export.patch
Date: Mon, 23 Apr 2007 14:29:17 -0700 [thread overview]
Message-ID: <462D252D.5090008@goop.org> (raw)
In-Reply-To: <462D1CBC.6050405@vmware.com>
Zachary Amsden wrote:
> There are two specific examples, both of which are real BUGs. If
> there is not enough space to do generic patching to a direct function
> call, then it is a bug, since there would not have even been enough
> space to do an indirect call in the first place. Obviously, with the
> i386 ISA, this is impossible as long as there was an indirect in the
> first place. But an attempt to place native "cli" inline with no
> padding, to use as a patch point, would fire this BUG and rightly so.
Well, the BUG is if the patch-size is smaller than sizeof(indirect
call). Or more generally, if the patch site contains bogus crud. But I
don't think checking for that in the patcher makes a great deal of sense.
> The second BUG I added is also justified. If the patch point has a
> smaller than normal clobber list, then the original indirect call is
> incorrect unless the code has taken care to save and restore clobbered
> registers around the patch point. That is the case today, but there
> is nothing validating that in the patching code.
Well, yes, it assumes that the original unpatched code is OK, and makes
sure that it remains correct after patching. The patcher could
disassemble the unpatched sequence to make sure its consistent with the
site and clobbers, but that seems like overkill.
Currently the invariants on pv_ops patch sites are initially:
1. the sequence is always at least an indirect call to an
implementation of the operations, and
2. it will always have appropriate register save/restores which allow
a call to C code to work at that site
As a result, it is always OK to execute without doing any patching.
The callsite clobbers may be smaller than those needed for a naked C
call, but that means the site will have push/pops around the indirect
call. This gives the patcher more space to work with if it wants to
inline something; if it just wants to generate a call to C code, it must
also generate its own register saves.
The indirect->direct call converter does check the clobbers, and makes
sure that inserting a naked direct call is OK.
> We could make the patching code more intelligent and have it emit the
> proper push / pop sequence around the call, but it is difficult to do
> and does not work for more than 3 argument function calls. Or we
> could record the EIP of the call instruction in the patch information,
> allowing the patcher to either overwrite the whole thing, or do
> indirect / direct conversion.
Could do. It would be useful to know how many args the function has,
and then the indirect->direct converter could generate the appropriate
push/pops for itself. We're currently using 16 bits for the clobbers
field, which is overkill, we could use one byte as the arg count. Just
an "args on stack" flag would be sufficient.
> Yes, we still do late paravirtualization. My point is that because of
> that, you can't just link once and be done with it - you must relink
> the paravirt-ops later, which is more complex than a one time
> pre-execution link.
It's semantically no different from updating the paravirt_ops structure
followed by patching. If the kernel comes up with all the sites
prelinked to the native versions, then its the same as booting on the
current kernel, with paravirt_ops initialized to the native versions.
J
next prev parent reply other threads:[~2007-04-23 21:29 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-20 1:53 [RFC, PATCH 5/5] Paravirt_ops export.patch Zachary Amsden
2007-04-20 5:10 ` Jeremy Fitzhardinge
2007-04-22 14:28 ` Eric W. Biederman
2007-04-22 16:20 ` Jeremy Fitzhardinge
2007-04-22 16:59 ` Zachary Amsden
2007-04-22 17:31 ` Jeremy Fitzhardinge
2007-04-23 20:53 ` Zachary Amsden
2007-04-23 21:14 ` Eric W. Biederman
2007-04-23 21:40 ` Zachary Amsden
2007-04-23 21:29 ` Jeremy Fitzhardinge [this message]
2007-04-23 21:54 ` Zachary Amsden
2007-04-23 22:15 ` Jeremy Fitzhardinge
2007-04-23 22:24 ` Zachary Amsden
2007-04-23 22:29 ` Andi Kleen
2007-04-22 23:57 ` Rusty Russell
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=462D252D.5090008@goop.org \
--to=jeremy@goop.org \
--cc=ak@muc.de \
--cc=akpm@osdl.org \
--cc=chrisw@sous-sol.org \
--cc=ebiederm@xmission.com \
--cc=mingo@elte.hu \
--cc=petr@vmware.com \
--cc=virtualization@lists.osdl.org \
--cc=zach@vmware.com \
--cc=zamsden@gmail.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;
as well as URLs for NNTP newsgroup(s).