Commit Graph

130 Commits

Author SHA1 Message Date
Randall Spangler
b17e8d353c Add VB test error func/num
Change-Id: Ibe253963f0424935554fe91f166ef5040a723c6f

BUG=13107
TEST=make && make runtests

Review URL: http://codereview.chromium.org/6698032
2011-03-15 09:50:38 -07:00
Vadim Bendebury
2008423d5f Add function for VDAT processing.
This CL is a user space counterpart of
http://codereview.chromium.org/6690023, which provided the
ability to retrieve buffers through chromeos_acpi driver.

The buffer contents is communicated as a multi line string
with each buffer byte represented as a two symbol hex
number. `crosstool', on the other has to map the buffer
contents into a certain binary structure. This CL add
conversion of the multiline string into a binary buffer and
also adds a temp. routine to dump the buffer contents on the
screen when `crosstool' is invoked.

Change-Id: I8dd3eb935332f9bc8769c71de0db302365f12d70

BUG=chromium-os:13069, chromium-os:13091
TEST=manual

- Install the new image on a target with firmware providing
 the VDAT ACPI method.

- Run crosstool and watch for the last line:
vdat                   =  11 22 33 44 ff 1f 1c 40 ff 57 74 41 ff ff ff ff # Raw VDAT contents.
localhost tmp #

Review URL: http://codereview.chromium.org/6695012
2011-03-15 09:29:48 -07:00
Randall Spangler
227f792c1b Add check-value support and check /proc/cmdline for cros_nodebug
Change-Id: I35158810184be03f18d98893e4dd640088384579

BUG=12904
TEST=manual

crossystem fwb_tries=1
crossystem fwb_tries?1 && echo YES || echo NO --> YES
crossystem fwb_tries?0x01 && echo YES || echo NO --> YES
crossystem fwb_tries?0 && echo YES || echo NO --> NO

crossystem fwb_tries=0
crossystem fwb_tries?0 && echo YES || echo NO --> YES
crossystem fwb_tries?1 && echo YES || echo NO --> NO
crossystem fwb_tries?0x01 && echo YES || echo NO --> NO

crossystem ecfw_act --> RW (if it's not, change RW to RO in the tests below)
crossystem ecfw_act?RW && echo YES || echo NO --> YES
crossystem ecfw_act?BOB && echo YES || echo NO --> NO

For the following tests, boot Alex with dev switch on and fwb_tries=1
Expected output of `crossystem mainfw_type mainfw_act cros_debug` under each of the following scenarios:
* Neither "cros_debug" nor" cros_nodebug" in kernel command line: normal B 1
* Kernel command line changed to include "cros_nodebug": normal B 0
* Kernel command line changed to include "cros_nodebugg": normal B 1
* Kernel command line changed to include "ccros_nodebug": normal B 1

Review URL: http://codereview.chromium.org/6665005
2011-03-11 13:34:56 -08:00
Randall Spangler
196e1772ed Add cros_debug option to crossystem
Change-Id: Ie62364a87f7f144ee647054d2a9ef83522cdbe7d

BUG=12904
TEST=manual

Expected output of `crossystem mainfw_type cros_debug` under each of the following scenarios:

* Boot Alex with dev switch off: normal 0
* Boot Alex with dev switch on (and dev firmware): developer 1
* Boot Alex with dev switch on (and normal firmware): normal 1
* Boot Alex with recovery firmware: recovery 0
* Boot Alex with dev switch off, then turn the dev switch on after booting: normal 0
* Boot Cr-48 with dev switch off: normal 0
* Boot Cr-48 with dev switch on: developer 1
* Boot Cr-48 with recovery firmware: recovery 0

* Boot Alex with dev switch off and kernel command line changed to include "cros_debug": normal 1
* Boot Alex with dev switch off and kernel command line changed to include "cros_debugg": normal 0
* Boot Alex with dev switch off and kernel command line changed to include "ccros_debug": normal 0

* Boot H2O BIOS with kernel command line changed to include "cros_debug": nonchrome 1
* Boot H2O BIOS with kernel command line changed to include "cros_debugg": nonchrome 0
* Boot H2O BIOS with kernel command line changed to include "ccros_debug": nonchrome 0

Review URL: http://codereview.chromium.org/6659021
2011-03-10 11:31:06 -08:00
Randall Spangler
b416714a10 Add crossystem support for nvram_cleared and kern_nv
Fix try_b processing

And move key block flags check up in LoadFirmware(), which speeds up
boot when the dev switch is off because it doesn't do a signature
check and then throw it out.

BUG=12282
TEST=build firmware, try by hand

Review URL: http://codereview.chromium.org/6596081

Change-Id: I10474e9e0ae324906dfe02a351347d04ce847f67
2011-03-01 13:04:22 -08:00
Randall Spangler
618d17d48c Add kern_nv field to crossystem
Change-Id: Ifa5cc3bd8367a258fb720162572f450a1be99c03

BUG=none
TEST=manual

crossystem kern_nv=0x12345678
crossystem kern_nv

Review URL: http://codereview.chromium.org/6602040
2011-03-01 10:33:11 -08:00
Randall Spangler
92e378e453 rename tried_fwb constants
Change-Id: Ib8018bfe29eed50766c699d832efe4f1afcabb1a

BUG=none
TEST=make && make runtests

Review URL: http://codereview.chromium.org/6597015
2011-02-25 13:56:53 -08:00
Randall Spangler
172602829d Add NV storage fields for firmware flags
1) Did firmware attempt RW slot B before slot A?

2) Did firmware check the kernel keyblock signature, or just its hash?

Added crossystem support as well.

BUG=chrome-os-partner:1657
TEST=make && make runtests

Review URL: http://codereview.chromium.org/6597011

Change-Id: I0d743ae87cedd938ba988170793717d3fdbd8ce9
2011-02-25 12:06:26 -08:00
Randall Spangler
0f8ffb11f5 crossystem uses VbNvStorage
Change-Id: I3f158115c8514bda0b271674870d68717c4816e6

BUG=12282
TEST=manual

crossystem fwb_tries=0 && crossystem fwb_tries

This should print 0 on both BIOSes.

crossystem fwb_tries=6 && crossystem fwb_tries

This should print 1 on an older BIOS and 6 on a new BIOS (0050+)

Then reboot and run

crossystem mainfw_act

This should print 'B', since fwb_tries was non-zero.

Review URL: http://codereview.chromium.org/6576059
2011-02-25 09:50:54 -08:00
Randall Spangler
2b59a07c54 Add flashmap base address
Change-Id: If2106cbde445edc0970862a06d3837d2e466d9ef

BUG=chrome-os-partner:2487
TEST=manual

From a root shell, type: crossystem fmap_base
Should match the contents of /sys/devices/platform/chromeos_acpi/FMAP
(note that you need a new BIOS >0049 to get one that supports FMAP)

Review URL: http://codereview.chromium.org/6580037
2011-02-24 11:17:24 -08:00
Randall Spangler
b47ed5a8fb Add more properties to crossystem
crossystem now covers all data currently provided by chromeos_acpi.

Change-Id: I3364c4d65ddf63fe788d3d9c1e9d05e64be22856

BUG=chromium-os:12282
TEST=manual - test on Cr-48 and compare with ACPI values

Review URL: http://codereview.chromium.org/6557001
2011-02-23 13:05:40 -08:00
Randall Spangler
e73302caae Add support for CHNV settings to crossystem.
crossystem can now be used in place of reboot_mode.

BUG=12327
TEST=manual by comparing with the old reboot_mode utility

crossystem recovery_request=1
reboot_mode
crossystem dbg_reset=1
reboot_mode
crossystem fwb_tries=1
reboot_mode

crossystem recovery_request=0
reboot_mode
crossystem dbg_reset=0
reboot_mode
crossystem fwb_tries=0
reboot_mode

Review URL: http://codereview.chromium.org/6538066

Change-Id: Ifde661d4621129d52e757654d85e386e65f90df5
2011-02-18 14:53:01 -08:00
Randall Spangler
c80fe65f9e Fix WP polarity on Mario
Note that both the current and boot settings are incorrect as reported
by the BIOS.  This fixes both.

Change-Id: Iebd2b4ac91232444e538f6e2763a22cb227f2e4f

BUG=chrome-os-partner:2078
TEST=manual

Run crossystem on Mario and Alex with WP enabled, disabled and check
Verify true hardware WP status by doing:
   flashrom --wp-enable
   flashrom --wp-status
   flashrom --wp-disable
   flashrom --wp-status
On a system with hardware WP enabled, the disable step should fail and write
protect will still report enabled.

Review URL: http://codereview.chromium.org/6531035
2011-02-17 11:06:47 -08:00
Che-Liang Chiou
305e9e5e85 Add load_firmware_test utility program
BUG=chromium-os:1302
TEST=emerge vboot_reference &&
	(load_firmware_test firmware_image.bin | grep LOAD_FIRMWARE_SUCCESS)

Review URL: http://codereview.chromium.org/6465018

Change-Id: I85fce39aaf4abb50bd70d126ac8c7cb892a7857b
2011-02-17 17:56:16 +08:00
Randall Spangler
542186618a Initial version of crossystem.
Works for getting switch positions, hwid, fwid.

BUG=chrome-os-partner:1940
TEST=ran manually on Mario and Alex

Review URL: http://codereview.chromium.org/6413002

Change-Id: I874df3b5adf872fec2d36e574cb4b8b4a72d331c
2011-02-07 11:20:20 -08:00
Gaurav Shah
0688025c7e Fix the maximum output size in the call to the external signer.
Maximum output size is the signature size.

BUG=7676
TEST=manual

1) Verified that earlier outbufsize value was more than what the external signer would return.
2) Re-ran run_vbutil_tests.sh

Change-Id: I180cfea7625ee09a51709d8f7735884c32b8b409

Review URL: http://codereview.chromium.org/4251006
2010-11-02 20:58:26 -07:00
Gaurav Shah
068fc6f251 Add support for using external signing application and .pem private key files to vbutil_keyblock.
This allows signing using a .pem file using an external program.

It is assumed that the external program reads input from stdin, and outputs signed data on stdout. It takes one argument - the file name for the .pem private key reference. See external_rsa_signer.sh for an example external program.

Example usage:
vbutil_keyblock --pack 4096.keyblock \
                --datapubkey 4096.vbpubk \
                --signprivate_pem 4096.pem \
                --pem_algorithm 8 \
                --externalsigner "external_rsa_signer.sh"

I have tried to make the change such that it doesn't impact existing tools/interfaces (since these are used at various places). That said, I am aware of the places where we could just extend an old interface an avoid code duplication but thought I'd put that re-factoring in as a TODO for now. Let me know if you disagree and I can merge them (and changing the existing interface).

BUG=7576
TEST=Extended run_vbutil_tests.sh to test vbutil_keyblock packing using an external signer.

To test, make && make runtests (or just run tests/gen_test_keys.sh; tests/run_vbutils_tests.sh)

Review URL: http://codereview.chromium.org/4194003

Change-Id: I7cc52c8293c04ef9ba074794d046c9a4f19f6bdd
2010-10-29 10:59:50 -07:00
Bill Richardson
60bcbe3cd4 New tools to help debug vboot failures.
This adds some tools to help us figure out why a particular kernel isn't
booting. Often we suspect it's because it was signed with the wrong keys, or
has flags restricting its use to certain boot modes. This change adds some
tools to extract and display all the keys from the BIOS, and try them on the
various kernels. We also display the sha1sum of all the keys we find, to
make comparing them easier.

Change-Id: I38e447bf95cb6c3a0b87aa949611bb135f2f94b4

BUG=chromeos-partner:888
TEST=manual

To test, obtain a root shell, and run dev_debug_vboot. You should see lots
of useful information go by.

Review URL: http://codereview.chromium.org/3303018
2010-09-09 14:53:56 -07:00
Gaurav Shah
47b593d849 Add additional sanity checks to RSA verification code.
Also, make algorithm unsigned int in most places.

BUG=chrome-os-partner:701
TEST=existing RSA verification tests still pass

Review URL: http://codereview.chromium.org/3136017
2010-08-17 15:48:22 -07:00
Randall Spangler
138acfe1ba Fix KeyBlockVerify() to take an explicit param for whether to use hash only.
Fix VerifyMemberInside().

BUG=chrome-os-partner:703
TEST=make && make runtests

Review URL: http://codereview.chromium.org/3126013
2010-08-17 15:45:21 -07:00
Bill Richardson
4f36ef3360 Changes to allow user-signed kernels to be generated.
Make vbutil_keyblock handle unsigned blocks. Also enable --unpack option and
add tests for it.

Modify vbutil_kernel to allow unsigned keyblocks, correct usage message,
and fix the --debug option which was somehow disabled.

Update load_kernel_test to accept /dev/null for the public key, to test
non-signed kernel keyblocks.

Review URL: http://codereview.chromium.org/3124004
2010-08-09 17:50:14 -07:00
Gaurav Shah
8dd20941cd Zero-out allocated buffer while creating kernel preamble header.
Since the kernel vblocks are always padded out to a fixed size, the unused (padded) memory was ending up containing random bytes, leading to vbutil_kernel generating vblocks that are not bit-identical when run with the same inputs.

BUG=none
TEST=see below
1) Use vbutil_kernel with the same set of inputs to generate two alternative vblocks.
2) Compare the 2 files - they must be bitwise identical space. The padding bytes must all be set to 0.
3) Generate a new signed image using the resign_image.sh script under scripts/image_signing. This signed image should be boot and install successfully on a maching running our custom firmware using the same set of root, firmware, and kernel keys.

Review URL: http://codereview.chromium.org/3076033
2010-08-04 16:45:42 -07:00
Bill Richardson
abf0550458 Switch to using .vbprivk for signing everything now.
This makes it much simpler to keep track of what we're doing.

vbutil_key can now wrap both .keyb and .pem keys. It figures out which is
which by trying both and just using the one that works.

vbutil_keyblock and vbutil_kernel now use .vbprivk files for signing.

replace debug() with VBDEBUG(()) in host-side sources, too.

rename PrivateKeyRead to PrivateKeyReadPem

Add real PrivateKeyRead and PrivateKeyWrite for .vbprivk files.

Review URL: http://codereview.chromium.org/2871033
2010-07-01 10:22:06 -07:00
Bill Richardson
a08b5c9d03 Adding --repack and --headeronly options to vbutil_kernel
The --repack option lets us sign a previously signed kernel blob with a new
kernel data key.

The --headeronly option is so we can emit the new verification header
separately from the kernel blob.

More work to come...

Review URL: http://codereview.chromium.org/2812034
2010-06-30 21:59:43 -07:00
Randall Spangler
620c38cf34 Remove unused files, and tidy the directory structure of the remaining ones.
Review URL: http://codereview.chromium.org/2815011
2010-06-17 14:45:22 -07:00
Randall Spangler
a55e5ca76c Refactor LoadFirmware() to avoid global variables, which don't work when running out of ROM
Review URL: http://codereview.chromium.org/2848006
2010-06-15 18:45:09 -07:00
Randall Spangler
729b87258b Clean up of key block functions
No substantial new code, just making the old code consistent.

Review URL: http://codereview.chromium.org/2729021
2010-06-11 11:16:20 -07:00
Randall Spangler
6a97b3e2a1 Add vbutil_keyblock
Review URL: http://codereview.chromium.org/2748008
2010-06-10 17:55:02 -07:00
Randall Spangler
d55c645372 Utility to pack public key, version, algorithm into a single file in VbPublicKey format
Review URL: http://codereview.chromium.org/2762009
2010-06-10 12:43:51 -07:00
Randall Spangler
d183644564 Major refactoring of structures, with unit tests. This matches the doc I sent out earlier.
Firmware-side code for LoadKernel() is in place now.  LoadFirmware() replacement coming soon.

The new functions are implemented in parallel to the existing ones (i.e., everything that used to work still does).

Review URL: http://codereview.chromium.org/2745007
2010-06-10 09:59:04 -07:00