History log of /external/tpm2/generator/structure_generator.py
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
69289285089a481cf80d1de423811fb0d903c9f6 22-Oct-2015 Vadim Bendebury <vbendeb@chromium.org> generator: fix the basic types' marshaling error return values, again

The code erroneously puts sizeof(type) as a return value in case there
is not enough room in the buffer to marshal the value.

This value is used to calculate total marshaled size, so in case there
was nothing added to the buffer the return value should be zero.

BUG=chrome-os-partner:43025
TEST=rebuilt sources and ran the tests, all tests pass.

Change-Id: I53935ca6732886d97f1c4aae2988102a62431b26
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/308231
Reviewed-by: Utkarsh Sanghi <usanghi@chromium.org>
/external/tpm2/generator/structure_generator.py
04c96e887ad2fc78ed66ce5f300c8313ae689b2e 22-Oct-2015 Vadim Bendebury <vbendeb@chromium.org> generator: fix the basic types' marshaling error return values

The code erroneously puts sizeof(type) as a return value in case there
is not enough room in the buffer to marshal the value, it should be
TPM_RC_INSUFFICIENT.

BUG=chrome-os-partner:43025
TEST=rebuilt sources and ran the tests, all tests pass.

Change-Id: I7a55f025777ccd3f64c18ee0418ff23b23f5944b
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/307938
Reviewed-by: Utkarsh Sanghi <usanghi@chromium.org>
/external/tpm2/generator/structure_generator.py
b8c5ecc6967ef4f63f4fca949db819be74dc2b4b 05-Oct-2015 Vadim Bendebury <vbendeb@chromium.org> generator: fix TPM2B_xxxx marshaling

The library code does not care to properly set up size fields of some
TPM2B_xxx objects generated while processing TPM commands. This
objects have their size field decorated with a trailing equal sign in
the description in Part 2.

This patch modifies the parser to issue additional code to calculate
the payload size when marshaling those structures.

BUG=chrome-os-partner:44608
TEST=This change fixes 176 tests listed in https://goo.gl/KwVOv3

Change-Id: I14a5fbc5f5c266a6e3d7bd00ac60a134739e7363
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/305498
Reviewed-by: Darren Krahn <dkrahn@chromium.org>
/external/tpm2/generator/structure_generator.py
f5af8595c277e36541c688f7803e106cebb65fd2 15-Oct-2015 Vadim Bendebury <vbendeb@chromium.org> generator: avoid nested invocations for marshaling/unmarshaling

A lot of TPM objects are in fact simple integers one, two or four
bytes in size. The TPM2 library spec defines some fairly long type
chains which in the end of the day are just simple integers. The
currently generated marshaling/unmarshaling code follows these chains
causing multiple nested invocations, which is both a waste of time and
stack space.

This patch modifies generated code to shortcut to the lowest base type
when marshaling/unmarshaling integer base objects.

BUG=none
TEST=the generated code passes the same set of tests as before this
change.

Change-Id: I2c5028cd32f5d74f6fa6ab9919d5c6e0c5b9fea4
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/305599
Reviewed-by: Darren Krahn <dkrahn@chromium.org>
/external/tpm2/generator/structure_generator.py
907fc8fb669416cb96d603d9d81dacc9ea537170 06-Oct-2015 Vadim Bendebury <vbendeb@chromium.org> generator: do not check parameter values when unmarshaling

The specification defines different return error values for various
command parameter errors. While the first three fields of the header
need to be checked and rejected by the unmarshaling code, the errors
in the command code and algorithm ID parameters need to be processed
by the respective commands, generated error values are sometimes
command specific.

This patch modifies the scripts to generate the code where
unmarshsling errors in certain fields are ignored, so that the command
processing can take place and return the proper return value.

BUG=chrome-os-partner:44608
TEST=this change fixes two tests listed in https://goo.gl/ziOdWS

Change-Id: I47128165dc516a2d9dcad752f73f8f2f9d5335c8
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/305496
Reviewed-by: Utkarsh Sanghi <usanghi@chromium.org>
/external/tpm2/generator/structure_generator.py
1f2ef97bdde4318c3cc254bbafdab65bfc729911 08-Oct-2015 Vadim Bendebury <vbendeb@chromium.org> generator: do not define local variables in the switch block

The gcc seems to be broken when generating code with automatic
variables declared in the beginning of the switch {} block. This
results in stack corruption and all accompanying mess. This patch
makes sure that the variables, when required, are defined in the
beginning of the function instead.

BUG=chrome-os-partner:44608
TEST=no more code dumps are thrown when running the tests.

Change-Id: Ib6a5682d73cefbc280690a9f0aeb96f9b96aa31e
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/305384
Reviewed-by: Utkarsh Sanghi <usanghi@chromium.org>
/external/tpm2/generator/structure_generator.py
595736f2120e594839d6e73cb8245d8d7e5c2360 18-Sep-2015 Vadim Bendebury <vbendeb@chromium.org> generator: modify the scripts to process HTML sources

The scripts scraping TPM2 specification are being changed to use the
specification directly (in HTML forms). The existing modules
(command_generator and structure_generator) are being modified to
provide the 'back end processing' for the data retrieved by the new
scraper (extract_structures and tpm_table).

The test is modified to still pass, test_structure_generator.html is
the source of test data.

README includes instructions how to re-generate the source code.

BUG=chromium:501639
TEST=new code generation works fine, the test also passes:
$ ./generator/structure_generator_test.py
.......
----------------------------------------------------------------------
Ran 7 tests in 0.007s

OK

Change-Id: I2a0e925475d4cd2b57528bfe1b162245fc6e0f43
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/300662
/external/tpm2/generator/structure_generator.py
b85286c8c88af688bd3f1f31a269dfae51f57689 15-Sep-2015 Vadim Bendebury <vbendeb@chromium.org> generator: make pylint happy again

There have been a few pylint violations in the generator code, this
patch fixes them.

BUG=none
TEST=the following command succeeds:
$ pylint --rcfile=../../../chromite/pylintrc generator/*py

the below command generates exactly the same set of files as before
this change:

$ ./generator/generator.py generator/structures.txt generator/commands.txt

Change-Id: I86384cdd44a20f16f7d5dc300189a50210c08efa
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/299709
Reviewed-by: Utkarsh Sanghi <usanghi@chromium.org>
/external/tpm2/generator/structure_generator.py
3cd8526c535baca0947adccb82f8ef71cb45ba4c 05-Sep-2015 Vadim Bendebury <vbendeb@chromium.org> generator: do not carry around unnecessary data

All classes derived from TPMObject in structure_generator.py have
their parsing functions both adding the new objects to the objects'
map and returning all newly created objects in a list.

Both the list and the map are carried around, but the list can be
always derived from the map when necessary.

This patch removes unnecessary list management code and derives the
list from the map where necessary.

BUG=chromium:501639
TEST=verified that running

$ generator/generator.py generator/structures.txt \
generator/commands.txt

generates exactly the same output as before this change.

Change-Id: I08cee1725175295f7af5b635f4095fab1d628aaf
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/297738
Reviewed-by: Utkarsh Sanghi <usanghi@chromium.org>
/external/tpm2/generator/structure_generator.py
e6c58e46dbe2edbbc743bc27dba92c30c546f000 08-Sep-2015 Vadim Bendebury <vbendeb@chromium.org> generator: do not interleave marshaling functions

Code generating marshaling function for class Union should not try
adding missing definitions *after* starting the current type's
marshaling code.

BUG=none
TEST=code generated after this fix successfully compiles for cr50.

Change-Id: Ic6ff99b7aeaa7c8eb04506e7292b89fba904ccc5
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/298141
Reviewed-by: Utkarsh Sanghi <usanghi@chromium.org>
/external/tpm2/generator/structure_generator.py
5aef9c6461983184408bb4ca0747c7c124b38903 11-Aug-2015 Jocelyn Bohr <bohr@chromium.org> Generator changes to correctly account for empty union case.

Previously, there was no case statement in union marshaling switch
blocks for valid selector values indicating that no
marshaling/unmarshaling should occur. This resulted in union marshaling
functions erroneously returning TPM_RC_SELECTOR. This is a patch to the
structure generator script to account for these valid selector values.

TEST=$ sudo emerge tpm2
builds libtpm2.a
$ gcc marshal_test.c -ltpm2 -lssl -lcrypto -o marshal-test
$ ./marshal-test
passes all marshal test cases
BUG=none

Change-Id: I8ab233757395b5cae04098b5894dcb6073620560
Reviewed-on: https://chromium-review.googlesource.com/292801
Tested-by: Jocelyn Bohr <bohr@chromium.org>
Reviewed-by: Darren Krahn <dkrahn@chromium.org>
Commit-Queue: Jocelyn Bohr <bohr@chromium.org>
/external/tpm2/generator/structure_generator.py
7cba233744eb02495f33aab5e5f28efbff87075d 11-Aug-2015 Jocelyn Bohr <bohr@chromium.org> Edit generator scripts to change fields named xor to xor_.

For C++ files to compile with libtpm2, fields named xor need to be
changed because xor is a keyword in C++.

TEST=./generator.py structures.txt commands.txt
generates marshaling files
BUG=none

Change-Id: I4367bdb62091552e93802c4cc76e5b8ca3605d45
Reviewed-on: https://chromium-review.googlesource.com/292439
Tested-by: Jocelyn Bohr <bohr@chromium.org>
Reviewed-by: Utkarsh Sanghi <usanghi@chromium.org>
Commit-Queue: Jocelyn Bohr <bohr@chromium.org>
/external/tpm2/generator/structure_generator.py
fb668129d13e02e4f9feec53d519df84d96bb5fd 30-Jul-2015 Jocelyn Bohr <bohr@chromium.org> Changes to structure_generator.py.

Changes to structure_generator.py to remove all instances of declarations
after statements in tpm_generated.c. Main function is also removed as
structure_generator is imported and invoked by generator.py.

TEST=Tested with updated generated file tpm_generated.c.
$ sudo emerge tpm2
builds libtpm2.a
$ gcc marshal_test.c -ltpm2 -lssl -lcrypto -o marshal-test
$ ./marshal-test
passes all test cases
BUG=chromium:501639

CQ-DEPEND=CL:290556

Change-Id: I1b91805a7d17336d14bb29daa08e04178e5e19ae
Reviewed-on: https://chromium-review.googlesource.com/289805
Reviewed-by: Jocelyn Bohr <bohr@chromium.org>
Commit-Queue: Jocelyn Bohr <bohr@chromium.org>
Tested-by: Jocelyn Bohr <bohr@chromium.org>
/external/tpm2/generator/structure_generator.py
9edfbac6a36e07e1a7ccb2260b6f65d97b45fef8 18-Jul-2015 ChromeOS Developer <bohr@chromium.org> Scripts to generate TPM structure marshaling code

- These scripts were taken from the platform2/trunks project and
modified to generate marshaling code for libtpm2.
- extract_structures.sh:
* Takes in a hand fixed, raw scrape of TPM2.0 spec part 2, and
outputs a readable file representing spec defined types.
* Input: raw_structures_fixed.txt
* Output: structures.txt
- structure_generator.py
* Takes in a structured representation of TPM2.0 spec part 2,
and outputs C code to marshal and unmarshal all TPM types.
* Input: structures.txt
* Output: tpm_generated.c, tpm_generated.h
- tpm_generated.c and tpm_generated.h are seen in CL:282042

TEST=Visually inspected output of extract_structures.sh.
$ ./structure_generator_test.py
Passes all generator unit tests
BUG=chromium:501639

Change-Id: Ib5a9e1d0e29271cd854b333e1d832bf2013c1098
Reviewed-on: https://chromium-review.googlesource.com/284875
Reviewed-by: Darren Krahn <dkrahn@chromium.org>
Commit-Queue: Jocelyn Bohr <bohr@chromium.org>
Tested-by: Jocelyn Bohr <bohr@chromium.org>
/external/tpm2/generator/structure_generator.py