Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(999)

Issue 3975001: Dynamic code modification support for x64 NaCl modules... (Closed)

Created:
10 years, 2 months ago by petr
Modified:
9 years, 4 months ago
Reviewers:
bsy, Mark Seaborn, Karl
CC:
native-client-reviews_googlegroups.com
Visibility:
Public.

Description

Dynamic code modification support for x64 NaCl modules 1) enables validation of modified code 2) enables thread-safe copying of code modification 3) added tests to exercise dynamic code modification BUG=none TEST=./tests/dynamic_code_loading/dynamic_modify_test.c

Patch Set 1 #

Total comments: 12

Patch Set 2 : '' #

Patch Set 3 : '' #

Total comments: 3

Patch Set 4 : '' #

Total comments: 2

Patch Set 5 : '' #

Patch Set 6 : '' #

Patch Set 7 : '' #

Patch Set 8 : '' #

Patch Set 9 : '' #

Patch Set 10 : '' #

Total comments: 34

Patch Set 11 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+635 lines, -94 lines) Patch
M src/trusted/service_runtime/sel_validate_image.c View 1 2 3 4 5 6 7 8 9 10 3 chunks +32 lines, -17 lines 0 comments Download
M src/trusted/validator_x86/nccopycode.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +8 lines, -0 lines 0 comments Download
M src/trusted/validator_x86/nccopycode.c View 1 2 3 4 5 6 7 8 9 10 5 chunks +73 lines, -11 lines 0 comments Download
M src/trusted/validator_x86/ncvalidate_iter.h View 1 2 3 4 5 6 7 8 9 10 2 chunks +37 lines, -0 lines 0 comments Download
M src/trusted/validator_x86/ncvalidate_iter.c View 1 2 3 4 5 6 7 8 9 10 3 chunks +190 lines, -1 line 0 comments Download
M tests/dynamic_code_loading/dynamic_load_test.c View 5 6 7 8 9 10 10 chunks +34 lines, -18 lines 0 comments Download
M tests/dynamic_code_loading/dynamic_modify_test.c View 5 6 7 8 9 10 13 chunks +75 lines, -16 lines 0 comments Download
M tests/dynamic_code_loading/nacl.scons View 5 6 7 8 9 10 2 chunks +14 lines, -14 lines 0 comments Download
M tests/dynamic_code_loading/templates.h View 5 6 7 8 9 10 1 chunk +8 lines, -0 lines 0 comments Download
M tests/dynamic_code_loading/templates_arm.S View 5 6 7 8 9 10 1 chunk +20 lines, -0 lines 0 comments Download
M tests/dynamic_code_loading/templates_x86.S View 5 6 7 8 9 10 3 chunks +142 lines, -17 lines 0 comments Download
M tests/inbrowser_test_runner/nacl.scons View 10 1 chunk +1 line, -0 lines 0 comments Download
M tests/inbrowser_test_runner/test_runner.html View 10 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 22 (0 generated)
petr
10 years, 2 months ago (2010-10-20 20:37:53 UTC) #1
petr
http://codereview.chromium.org/3975001/diff/1/5 File src/trusted/validator_x86/ncvalidate_iter.c (right): http://codereview.chromium.org/3975001/diff/1/5#newcode486 src/trusted/validator_x86/ncvalidate_iter.c:486: if (memcmp(&istate_old->num_prefix_bytes, This may be a hack, let me ...
10 years, 2 months ago (2010-10-20 20:43:01 UTC) #2
bsy
the hack is an ugly one. please don't do that. http://codereview.chromium.org/3975001/diff/1/5 File src/trusted/validator_x86/ncvalidate_iter.c (right): http://codereview.chromium.org/3975001/diff/1/5#newcode477 ...
10 years, 2 months ago (2010-10-20 21:18:28 UTC) #3
Karl
http://codereview.chromium.org/3975001/diff/1/3 File src/trusted/validator_x86/nccopycode.c (right): http://codereview.chromium.org/3975001/diff/1/3#newcode246 src/trusted/validator_x86/nccopycode.c:246: #if NACL_TARGET_SUBARCH == 64 Why are you not conditionalizing ...
10 years, 2 months ago (2010-10-21 17:38:32 UTC) #4
petr
http://codereview.chromium.org/3975001/diff/1/3 File src/trusted/validator_x86/nccopycode.c (right): http://codereview.chromium.org/3975001/diff/1/3#newcode246 src/trusted/validator_x86/nccopycode.c:246: #if NACL_TARGET_SUBARCH == 64 On 2010/10/21 17:38:32, Karl wrote: ...
10 years, 2 months ago (2010-10-21 19:36:28 UTC) #5
petr
10 years, 2 months ago (2010-10-21 19:36:37 UTC) #6
Mark Seaborn
On 2010/10/21 19:36:37, petr wrote: > Denamic code modification support for x64 NaCl modules "denamic" ...
10 years, 2 months ago (2010-10-22 13:07:50 UTC) #7
Karl
LGTM. Note: Before checking in, fix the description to fix the spelling of dynamic.
10 years, 2 months ago (2010-10-22 16:28:45 UTC) #8
petr
10 years, 2 months ago (2010-10-22 18:57:52 UTC) #9
bsy
nits. i prefer syscalls to never CHECK-crash the service runtime if at all possible -- ...
10 years, 2 months ago (2010-10-23 02:29:53 UTC) #10
petr
http://codereview.chromium.org/3975001/diff/19001/11003 File src/trusted/validator_x86/nccopycode.c (right): http://codereview.chromium.org/3975001/diff/19001/11003#newcode267 src/trusted/validator_x86/nccopycode.c:267: CHECK(istate_old->length == istate_new->length && This condition is if-checked in ...
10 years, 2 months ago (2010-10-25 17:01:23 UTC) #11
petr
Bennet: plase, take another look
10 years, 1 month ago (2010-10-27 19:52:42 UTC) #12
bsy
this code looks pretty good, but we should have tests to prevent regressions. please add ...
10 years, 1 month ago (2010-11-01 23:50:50 UTC) #13
petr
10 years, 1 month ago (2010-11-04 05:09:40 UTC) #14
petr
Bennet, can you have another look please. dynamic_load_test.c runs as a small tests and inside ...
10 years, 1 month ago (2010-11-05 00:13:50 UTC) #15
Mark Seaborn
On 2010/11/05 00:13:50, petr wrote: > dynamic_load_test.c runs as a small tests and inside browser, ...
10 years, 1 month ago (2010-11-10 10:12:10 UTC) #16
Mark Seaborn
bsy wrote: > i have no idea why dynamic load test needs to run inside ...
10 years, 1 month ago (2010-11-10 11:03:42 UTC) #17
petr
10 years, 1 month ago (2010-11-11 07:37:16 UTC) #18
petr
enable dynalic_modify_test to run in a browser Bennet, Mark, please have another look
10 years, 1 month ago (2010-11-11 07:42:59 UTC) #19
bsy
mostly nits. kschimpf: plz comment on ncvalidate_iter.c http://codereview.chromium.org/3975001/diff/93001/src/trusted/validator_x86/nccopycode.c File src/trusted/validator_x86/nccopycode.c (right): http://codereview.chromium.org/3975001/diff/93001/src/trusted/validator_x86/nccopycode.c#newcode269 src/trusted/validator_x86/nccopycode.c:269: NaClLog(LOG_INFO, if ...
10 years, 1 month ago (2010-11-11 21:27:21 UTC) #20
Karl
Minor nit, agreeing with Bennet. Consider making a separate message function, with 2 instruction arguments, ...
10 years, 1 month ago (2010-11-11 22:45:41 UTC) #21
petr
10 years, 1 month ago (2010-11-12 18:11:06 UTC) #22
please have another look

http://codereview.chromium.org/3975001/diff/93001/src/trusted/validator_x86/n...
File src/trusted/validator_x86/nccopycode.c (right):

http://codereview.chromium.org/3975001/diff/93001/src/trusted/validator_x86/n...
src/trusted/validator_x86/nccopycode.c:269: NaClLog(LOG_INFO,
This can occur if you run sel_ldr with -c. We should not change this to
LOG_FATAL as then the execution will abort at this point but LOG_ERROR looks OK.

On 2010/11/11 21:27:21, bsy wrote:
> if i understand what you said earlier, this should never occur if the
validation
> phase passed.  given that, i think this should be a higher severity level than
> LOG_INFO -- a LOG_ERROR (or even a LOG_FATAL) would be appropriate.  (yeah, i
> know, i asked for an error return earlier.)

http://codereview.chromium.org/3975001/diff/93001/src/trusted/validator_x86/n...
File src/trusted/validator_x86/ncvalidate_iter.c (right):

http://codereview.chromium.org/3975001/diff/93001/src/trusted/validator_x86/n...
src/trusted/validator_x86/ncvalidate_iter.c:244: /* TODO(karl): empty fmt
strings not allowed */
I rolled back the check below, so it is valid 
On 2010/11/11 21:27:21, bsy wrote:
> is this TODO still valid, given the check below?

http://codereview.chromium.org/3975001/diff/93001/src/trusted/validator_x86/n...
src/trusted/validator_x86/ncvalidate_iter.c:249: if (format != NULL) {
I use this to print two instructions in a row, see the uses below. So, my uses
are the only that give format = NULL.
I will adopt Karl's suggestion and create a separate message function

On 2010/11/11 21:27:21, bsy wrote:
> when do we get NULL format strings?  this sounds like an internal error in the
> validator.  kschimpf: opinions?

http://codereview.chromium.org/3975001/diff/93001/src/trusted/validator_x86/n...
src/trusted/validator_x86/ncvalidate_iter.c:571:
NaClValidatorInstMessage(LOG_ERROR, state, istate_old, NULL);
Yes, they are
On 2010/11/11 21:27:21, bsy wrote:
> are these two lines the only places where the format string might be NULL?

http://codereview.chromium.org/3975001/diff/93001/src/trusted/validator_x86/n...
src/trusted/validator_x86/ncvalidate_iter.c:571:
NaClValidatorInstMessage(LOG_ERROR, state, istate_old, NULL);
Yes, I will do this

On 2010/11/11 22:45:41, Karl wrote:
> On 2010/11/11 21:27:21, bsy wrote:
> > are these two lines the only places where the format string might be NULL?
> 
> I think that you may just want to add a new "message" function
> NaClValidatorInstsMessage(....) that gets two instructions, and prints them
with
> a message.

http://codereview.chromium.org/3975001/diff/93001/src/trusted/validator_x86/n...
File src/trusted/validator_x86/ncvalidate_iter.h (right):

http://codereview.chromium.org/3975001/diff/93001/src/trusted/validator_x86/n...
src/trusted/validator_x86/ncvalidate_iter.h:198: /* Validate a segment for
dynamic code replacement
On 2010/11/11 21:27:21, bsy wrote:
> /*
>  * comment text starts on this line, not above.
>  * more comments.
>  */

Done.

http://codereview.chromium.org/3975001/diff/93001/tests/dynamic_code_loading/...
File tests/dynamic_code_loading/dynamic_load_test.c (right):

http://codereview.chromium.org/3975001/diff/93001/tests/dynamic_code_loading/...
tests/dynamic_code_loading/dynamic_load_test.c:21: #define BUF_SIZE 64
on X86-64 we operate with code samples that do not fit in 32-byte buffers
On 2010/11/11 21:27:21, bsy wrote:
> why should code buffers be 64 bytes on x86-64 cpus?  a comment please.

http://codereview.chromium.org/3975001/diff/93001/tests/dynamic_code_loading/...
tests/dynamic_code_loading/dynamic_load_test.c:102: assert(dest_size % 32 == 0);
On 2010/11/11 21:27:21, bsy wrote:
> is this 32 (always) correct?  should it be 16 or 32, depending on bundle size?

Done.

http://codereview.chromium.org/3975001/diff/93001/tests/dynamic_code_loading/...
tests/dynamic_code_loading/dynamic_load_test.c:172: uint8_t buf[32];
On 2010/11/11 21:27:21, bsy wrote:
> should this be BUF_SIZE?  if not, a comment would be nice.

Done.

http://codereview.chromium.org/3975001/diff/93001/tests/dynamic_code_loading/...
tests/dynamic_code_loading/dynamic_load_test.c:207: uint8_t nops[32];
On 2010/11/11 21:27:21, bsy wrote:
> should this be BUF_SIZE too?  if not, a comment would be nice.

Done.

http://codereview.chromium.org/3975001/diff/93001/tests/dynamic_code_loading/...
tests/dynamic_code_loading/dynamic_load_test.c:212: rc =
nacl_load_code(load_area + 1, nops, 32);
we are testing that the size of a segment is bundle aligned so

s/32/NACL_BUNDLE_SIZE/
On 2010/11/11 21:27:21, bsy wrote:
> NACL_ARRAY_SIZE(nops) or sizeof nops instead of 32?

http://codereview.chromium.org/3975001/diff/93001/tests/dynamic_code_loading/...
tests/dynamic_code_loading/dynamic_load_test.c:214: rc =
nacl_load_code(load_area + 4, nops, 32);
ditto
On 2010/11/11 21:27:21, bsy wrote:
> ditto

http://codereview.chromium.org/3975001/diff/93001/tests/dynamic_code_loading/...
tests/dynamic_code_loading/dynamic_load_test.c:218: rc =
nacl_load_code(load_area, nops + 1, 31);
ditto
On 2010/11/11 21:27:21, bsy wrote:
> NACL_ARRAY_SIZE(nops) - 1 instead of 31?

http://codereview.chromium.org/3975001/diff/93001/tests/dynamic_code_loading/...
tests/dynamic_code_loading/dynamic_load_test.c:220: rc =
nacl_load_code(load_area, nops + 4, 28);
ditto
On 2010/11/11 21:27:21, bsy wrote:
> similar to above

http://codereview.chromium.org/3975001/diff/93001/tests/dynamic_code_loading/...
tests/dynamic_code_loading/dynamic_load_test.c:224: rc =
nacl_load_code(load_area, nops, 32);
probably, it is just an additional check (maybe redundant)
s/32/NACL_BUNDLE_SIZE/ 
On 2010/11/11 21:27:21, bsy wrote:
> !!

http://codereview.chromium.org/3975001/diff/93001/tests/dynamic_code_loading/...
tests/dynamic_code_loading/dynamic_load_test.c:249: rc = nacl_load_code(data,
data, 32);
s/32/NACL_BUNDLE_SIZE/
On 2010/11/11 21:27:21, bsy wrote:
> !!

http://codereview.chromium.org/3975001/diff/93001/tests/dynamic_code_loading/...
tests/dynamic_code_loading/dynamic_load_test.c:307: uint8_t data[32];
On 2010/11/11 21:27:21, bsy wrote:
> !!

Done.

Powered by Google App Engine
This is Rietveld 408576698