Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(7694)

Issue 6405056: i#751: giant CL for x86_to_x64 translation.

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 9 months ago by yangt
Modified:
5 months, 2 weeks ago
CC:
dynamorio-devs_googlegroups.com
Visibility:
Public.

Description

Reviewer: bruening@google.com i#751: giant CL for x86_to_x64 translation. i#751: giant CL for x86_to_x64 translation. Add 'x86_to_x64' option for the 32-to-64 translation. Invariant: dcontext->x86_mode always reflects the x86 mode of the application's code. When x86_to_x64 option is enabled, full_decode is assumed. Besides, instr_create() always creates 64-bit instructions, instr_create_nbyte_nop() always creates raw nops, get_shared_gencode() always returns the 64-bit version, and far ibl always updates dcontext->x86_mode and always uses 64-bit ibl. Some assertions are relaxed to allow 32-bit dcontext and 64-bit fragment. The translate_x86_to_x64() function emulates known invalid/non-encodable 32-bit instructions in 64-bit. It also sets raw bits invalid for all instructions to enforce re-encoding. The translator uses %r8. Export reg_is_16bit(), opnd_is_reg_16bit(), get_call_return_address(), and insert_push_retaddr() for convenience. Add stats 'num_32bit_instrs_translated' that counts the number of 32-bit instructions translated to 64-bit. Add win32.x86_to_x64 into the test suite.

Patch Set 1 #

Total comments: 52

Patch Set 2 : i#751: revision based on the comments. #

Total comments: 20

Patch Set 3 : i#751: target 2nd-round review comments. #

Total comments: 4

Patch Set 4 : i#751: wrap is_wow64_process with IF_WINDOWS_ELSE and pass it to Derek. #

Total comments: 67

Patch Set 5 : i#751: giant CL for x86_to_x64 translation. #

Total comments: 16
Unified diffs Side-by-side diffs Delta from patch set Stats (+873 lines, -45 lines) Patch
M trunk/core/CMakeLists.txt View 1 2 3 4 1 chunk +4 lines, -0 lines 0 comments Download
M trunk/core/dispatch.c View 1 chunk +3 lines, -1 line 0 comments Download
M trunk/core/lib/statsx.h View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
M trunk/core/monitor.c View 1 chunk +3 lines, -1 line 0 comments Download
M trunk/core/optionsx.h View 1 2 3 4 1 chunk +2 lines, -0 lines 2 comments Download
M trunk/core/x86/arch.h View 1 2 3 4 2 chunks +20 lines, -0 lines 4 comments Download
M trunk/core/x86/arch.c View 1 2 3 4 1 chunk +1 line, -0 lines 2 comments Download
M trunk/core/x86/arch_exports.h View 1 2 3 4 1 chunk +1 line, -0 lines 2 comments Download
M trunk/core/x86/decode.h View 1 2 3 4 1 chunk +4 lines, -1 line 2 comments Download
M trunk/core/x86/emit_utils.c View 1 2 3 4 3 chunks +42 lines, -11 lines 2 comments Download
M trunk/core/x86/instr.c View 1 2 3 4 3 chunks +7 lines, -4 lines 0 comments Download
M trunk/core/x86/interp.c View 1 2 3 4 4 chunks +7 lines, -4 lines 0 comments Download
M trunk/core/x86/mangle.c View 1 2 3 4 8 chunks +22 lines, -15 lines 0 comments Download
A trunk/core/x86/x86_to_x64.c View 1 2 3 4 1 chunk +552 lines, -0 lines 2 comments Download
M trunk/suite/tests/CMakeLists.txt View 1 2 3 4 2 chunks +7 lines, -2 lines 0 comments Download
M trunk/suite/tests/win32/mixedmode.c View 1 2 3 4 6 chunks +188 lines, -5 lines 0 comments Download
M trunk/suite/tests/win32/mixedmode.templatex View 1 2 3 4 1 chunk +9 lines, -1 line 0 comments Download

Messages

Total messages: 20
yangt
11 years, 9 months ago (2012-07-17 22:38:20 UTC) #1
Reid Kleckner (google)
These are my comments. The plan we discussed in person was for me to one ...
11 years, 9 months ago (2012-07-18 16:45:45 UTC) #2
bruening
On Wed, Jul 18, 2012 at 12:45 PM, <rnk@google.com> wrote: > The plan we discussed ...
11 years, 9 months ago (2012-07-18 16:48:07 UTC) #3
bruening
started review (with the test) before your plan to ask me to review a later ...
11 years, 9 months ago (2012-07-18 16:50:15 UTC) #4
Reid Kleckner (google)
On Wed, Jul 18, 2012 at 12:48 PM, Derek Bruening <bruening@google.com>wrote: > On Wed, Jul ...
11 years, 9 months ago (2012-07-18 16:50:58 UTC) #5
yangt
Oops I'm sorry I misunderstood your intention and made this confusion. I'll take a look ...
11 years, 9 months ago (2012-07-18 17:46:40 UTC) #6
yangt
http://codereview.appspot.com/6405056/diff/1/trunk/core/x86/arch.h File trunk/core/x86/arch.h (right): http://codereview.appspot.com/6405056/diff/1/trunk/core/x86/arch.h#newcode693 trunk/core/x86/arch.h:693: if (DYNAMO_OPTION(x86_to_x64)) On 2012/07/18 16:45:45, Reid Kleckner (google) wrote: ...
11 years, 9 months ago (2012-07-19 20:23:11 UTC) #7
yangt
11 years, 9 months ago (2012-07-19 20:23:38 UTC) #8
Reid Kleckner (google)
Pretty good. Let's do one more iteration, and then I think it'll be ready for ...
11 years, 9 months ago (2012-07-20 15:23:47 UTC) #9
yangt
11 years, 9 months ago (2012-07-20 18:43:23 UTC) #10
yangt
http://codereview.appspot.com/6405056/diff/8002/trunk/core/x86/arch.h File trunk/core/x86/arch.h (right): http://codereview.appspot.com/6405056/diff/8002/trunk/core/x86/arch.h#newcode941 trunk/core/x86/arch.h:941: #ifdef X64 On 2012/07/20 15:23:47, Reid Kleckner (google) wrote: ...
11 years, 9 months ago (2012-07-20 18:43:41 UTC) #11
Reid Kleckner (google)
LGTM, but let Derek should take a look. You missed my two reply comments on ...
11 years, 9 months ago (2012-07-20 19:05:06 UTC) #12
yangt
11 years, 9 months ago (2012-07-20 19:25:17 UTC) #13
yangt
http://codereview.appspot.com/6405056/diff/11004/trunk/core/x86/mangle.c File trunk/core/x86/mangle.c (right): http://codereview.appspot.com/6405056/diff/11004/trunk/core/x86/mangle.c#newcode3851 trunk/core/x86/mangle.c:3851: if (is_wow64_process(NT_CURRENT_PROCESS) && instr_get_x86_mode(instr) && On 2012/07/20 19:05:06, Reid ...
11 years, 9 months ago (2012-07-20 19:25:26 UTC) #14
yangt
The current code translates "push esp" incorrectly. See inline comments. http://codereview.appspot.com/6405056/diff/14004/trunk/core/x86/x86_to_x64.c File trunk/core/x86/x86_to_x64.c (right): http://codereview.appspot.com/6405056/diff/14004/trunk/core/x86/x86_to_x64.c#newcode112 ...
11 years, 9 months ago (2012-07-30 15:01:16 UTC) #15
bruening
main concern is that in some places you assume that absolutely everything will be translated. ...
11 years, 9 months ago (2012-07-31 03:21:05 UTC) #16
yangt
11 years, 9 months ago (2012-08-02 19:04:34 UTC) #17
yangt
http://codereview.appspot.com/6405056/diff/14004/trunk/core/CMakeLists.txt File trunk/core/CMakeLists.txt (right): http://codereview.appspot.com/6405056/diff/14004/trunk/core/CMakeLists.txt#newcode122 trunk/core/CMakeLists.txt:122: list(APPEND ARCH_SRCS x86/x86_to_x64.c) On 2012/07/31 03:21:05, bruening wrote: > ...
11 years, 9 months ago (2012-08-02 19:04:59 UTC) #18
bruening
LGTM http://codereview.appspot.com/6405056/diff/18004/trunk/core/optionsx.h File trunk/core/optionsx.h (right): http://codereview.appspot.com/6405056/diff/18004/trunk/core/optionsx.h#newcode508 trunk/core/optionsx.h:508: OPTION_DEFAULT(bool, x86_to_x64, false, "translate x86 code to x64.") ...
11 years, 8 months ago (2012-08-06 16:58:46 UTC) #19
yangt
11 years, 8 months ago (2012-08-06 18:28:46 UTC) #20
http://codereview.appspot.com/6405056/diff/18004/trunk/core/optionsx.h
File trunk/core/optionsx.h (right):

http://codereview.appspot.com/6405056/diff/18004/trunk/core/optionsx.h#newcod...
trunk/core/optionsx.h:508: OPTION_DEFAULT(bool, x86_to_x64, false, "translate
x86 code to x64.")
On 2012/08/06 16:58:46, bruening wrote:
> can you expand the string: explain it's when on a 64-bit kernel

Done.

http://codereview.appspot.com/6405056/diff/18004/trunk/core/x86/arch.c
File trunk/core/x86/arch.c (right):

http://codereview.appspot.com/6405056/diff/18004/trunk/core/x86/arch.c#newcod...
trunk/core/x86/arch.c:2335: * - x86_to_x64: fault translation has not been
tested
On 2012/08/06 16:58:46, bruening wrote:
> add i#

Done.

http://codereview.appspot.com/6405056/diff/18004/trunk/core/x86/arch.h
File trunk/core/x86/arch.h (right):

http://codereview.appspot.com/6405056/diff/18004/trunk/core/x86/arch.h#newcod...
trunk/core/x86/arch.h:706: * This may not work if we have 32-bit fragments, in
which case we may
On 2012/08/06 16:58:46, bruening wrote:
> may not?  it definitely won't work

Done.

http://codereview.appspot.com/6405056/diff/18004/trunk/core/x86/arch.h#newcod...
trunk/core/x86/arch.h:707: * refer to X64_CACHE_MODE_DC().
On 2012/08/06 16:58:46, bruening wrote:
> why not just add this to the code?  if not, this comment should be prefixed
with
> "FIXME i#nnnn:" b/c it's a correctness issue

Done.

http://codereview.appspot.com/6405056/diff/18004/trunk/core/x86/arch_exports.h
File trunk/core/x86/arch_exports.h (right):

http://codereview.appspot.com/6405056/diff/18004/trunk/core/x86/arch_exports....
trunk/core/x86/arch_exports.h:1391: * In x86_to_x64, sets to the mode of code
cache instead.
On 2012/08/06 16:58:46, bruening wrote:
> this is an externally-visible comment (see the double star?  that's a doxygen
> comment).  users don't know what "In x86_to_x64" means, nor "mode of code
> cache".  we could go update bt.dox and the runtime option list in the .dox
files
> to explain it, but maybe x86_to_x64 is not ready for prime-time yet.  I would
> suggest keeping it un-documented for now.  thus, make this a separate, normal
> comment.
> 
> minor: comment could be clearer if expanded a little.  something like: "For
> -x86_to_x64, sets the mode of the instr to the code cache mode instead of the
> app mode."

Done.

http://codereview.appspot.com/6405056/diff/18004/trunk/core/x86/decode.h
File trunk/core/x86/decode.h (right):

http://codereview.appspot.com/6405056/diff/18004/trunk/core/x86/decode.h#newc...
trunk/core/x86/decode.h:637: * Later, if needed, we can introduce a new field in
dcontext_t.
On 2012/08/06 16:58:46, bruening wrote:
> add a xref to the i# for this

Done.

http://codereview.appspot.com/6405056/diff/18004/trunk/core/x86/emit_utils.c
File trunk/core/x86/emit_utils.c (right):

http://codereview.appspot.com/6405056/diff/18004/trunk/core/x86/emit_utils.c#...
trunk/core/x86/emit_utils.c:5989: * NOTE: this may not work if we have 32-bit
fragments.
On 2012/08/06 16:58:46, bruening wrote:
> not "may", it won't work.  should have "FIXME i#".  the "may" part is whether
> there are 32-bit fragments.  if they're there, it won't work.

Done.

http://codereview.appspot.com/6405056/diff/18004/trunk/core/x86/x86_to_x64.c
File trunk/core/x86/x86_to_x64.c (right):

http://codereview.appspot.com/6405056/diff/18004/trunk/core/x86/x86_to_x64.c#...
trunk/core/x86/x86_to_x64.c:152: replace(dcontext, ilist, instr,
On 2012/08/06 16:58:46, bruening wrote:
> ok so with this order you don't need next_instr.

Any problem?
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b