Commit Graph

647 Commits

Author SHA1 Message Date
Hung-Te Lin
9ea8e0d390 firmware: Add TONORM_CONFIRM screen.
We need to alert user his change has been accepted for 5 seconds.

BUG=chrome-os-partner:11078
TEST=emerge-daisy vboot_reference-firmware vboot_reference chromeos-u-boot chromeos-boogimage

Change-Id: I6a3b13e7543479fbd6543d759093ecf501fb1d04
Reviewed-on: https://gerrit.chromium.org/gerrit/29982
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
2012-08-13 17:25:13 -07:00
Dave Parker
3985f94fae Increase max number of bitmaps to composite to 16 per screen.
This is needed to render new-style screens that use 13 bitmaps.
bmpblk version is changed from 1.2 to 2.0, due to incompatibility.

BUG=chrome-os-partner:11078
TEST=emerge-<board> vboot-reference. Run firmware with new bmpblock.

Original-Change-Id: I750da66b020fe195896df58f31fcbb2a9e33e404
Reviewed-on: https://gerrit.chromium.org/gerrit/28945
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Tested-by: Dave Parker <dparker@chromium.org>
(cherry picked from commit 0b7ee46c2eeba858ff59d534e265b445895623a2)

Change-Id: I80543c46a7c0e09169e29e32077d84c57192e431
Reviewed-on: https://gerrit.chromium.org/gerrit/29602
Reviewed-by: Dave Parker <dparker@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org>
2012-08-09 01:56:44 -07:00
Mike Frysinger
6c34ecf61b rename common.mk to build.mk
This is to avoid confusion with the canonical common.mk file that is
a CrOS build system.

BUG=chromium-os:33327
TEST=`cros_run_unit_tests --board x86-alex -p vboot_reference` still works

Change-Id: I4b6719d58a4a8ab44b62c23c0e2c45b154374958
Reviewed-on: https://gerrit.chromium.org/gerrit/29578
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
2012-08-08 11:39:45 -07:00
Randall Spangler
62fed6f191 Hash-based EC verification needs only a tiny bit of padding.c info
BUG=chrome-os-partner:11232
TEST=build u-boot and ec for link
CQ-DEPEND=29496

Change-Id: I614cfc0a45b1cf492f1cec4e085e8f3259ac6662
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29497
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-08-07 19:06:33 -07:00
Bill Richardson
f217520215 vboot: add flag to indicate that the EC is slow to program
Some EC's are slow to program their firmware. This could happen at any boot
as part of software sync. This adds the VB_INIT_FLAG_EC_SLOW_UPDATE input
flag to VbInit(), so that vboot knows to display the EC-is-being-programmed
screen when that flag is set.

BUG=chrome-os-partner:12255
TEST=none

This isn't activated yet by anything, so there's nothing to test.

Change-Id: Id4d12e463fcdee017b7c52b53a2facefc33b745f
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29370
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-08-07 09:08:50 -07:00
Randall Spangler
da8d32dc8d Crossystem should return at-boot switch positions from VbSharedData
This is more reliable than reading them through FDT/ACPI, since it reflects
the positions as shown to verified boot code.

Notes:
1. This affects ALL platforms with virtual dev switches (x86 AND arm)
2. The fix should have no effect on older platforms, but I haven't tested those.

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

1. boot in normal mode.

devsw_boot             = 0                              # Developer switch position at boot
recovery_reason        = 0                              # Recovery mode reason for current boot
recoverysw_boot        = 0                              # Recovery switch position at boot
wpsw_boot              = 1                              # Firmware write protect hardware switch position at boot

2. boot in developer mode.

localhost ~ # crossystem
devsw_boot             = 1                              # Developer switch position at boot
recovery_reason        = 0                              # Recovery mode reason for current boot
recoverysw_boot        = 0                              # Recovery switch position at boot
wpsw_boot              = 1                              # Firmware write protect hardware switch position at boot

3. boot in developer-recovery mode using keyboard combo.

devsw_boot             = 1                              # Developer switch position at boot
recovery_reason        = 2                              # Recovery mode reason for current boot
recoverysw_boot        = 1                              # Recovery switch position at boot
wpsw_boot              = 1                              # Firmware write protect hardware switch position at boot

4. disable WP and reboot.  wpsw_boot should be 0.

Change-Id: If4156b5e14c6923c5b331c7e5feaabbffe1dad37
Reviewed-on: https://gerrit.chromium.org/gerrit/29199
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
2012-08-06 13:15:43 -07:00
Vincent Palatin
63a0c47f50 cryptolib: put constant arrays in rodata segment
The SHA256 constants and some algo definitions are currently in the
.data segment, this wastes precious RAM on the EC where read-only data
are stored in flash only.

BUG=chrome-os-partner:12271
TEST=sudo emerge vboot_reference &&
emerge-daisy vboot_reference vboot_reference-firmware chromeos-ec
and manually check the content of the .data segment in the EC binary.

Change-Id: I67b8c0f2843312651e8ac287cea2f8cb5f075453
Reviewed-on: https://gerrit.chromium.org/gerrit/29273
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
2012-08-06 12:06:47 -07:00
Bill Richardson
b48cd672a7 Add WAIT screen to default bitmap
Some systems take a long time to program the EC firmware (because it's
behind a really slow I2C bus or something). This could happen at any boot as
part of software sync. If it's necessary to reprogram the EC on a slow
system, we need to display a BIOS screen to the user so he/she doesn't think
it's bricked.

This CL is just to add a new default bitmap so we'll have something to
display when we need it. Nothing actually uses it yet.

BUG=chrome-os-partner:12254
TEST=none

There should be no user-visible changes. We don't invoke this screen yet.

Change-Id: Icb922f933e2e921472dbdff7a26a3ca4d58fbba3
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29241
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
2012-08-05 22:08:33 -07:00
Bill Richardson
2934475dbc TONORM screen should display at Dev screen, not Recovery screen.
We're still working out the correct behavior for the keyboard-based
dev-mode. Before this, we rebooted into recovery mode before asking if you
wanted to return to normal mode, so if you said "no, stay in dev-mode" you'd
still be at the recovery screen.

But now the confirmation for returning to normal mode happens at the
dev-mode screen, so you never get to the recovery screen (unless normal mode
won't boot, in which case you get there automatically).

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

First, clear the GBB flags so that you can actually test the virtual dev
switch:

  /usr/share/vboot/bin/set_gbb_flags.sh 0
  reboot

It should come up in normal mode.

Activate keyboard-based dev-mode as before:
- three-finger salute
- Ctrl-D at the recovery screen
- Press ENTER when asked

Now, at the DEV screen, try to leave:
- Press SPACE. It should ask if you want to go to normal mode.
- Press ESC (no). You should be back at the DEV screen again.
- Press ENTER. It should ask if you want to go to normal mode.
- Press ESC (no). You should be back at the DEV screen again.
- Press SPACE. It should ask if you want to go to normal mode.
- Press ENTER (yes). It should reboot into normal mode.

Change-Id: I99af6e7b97fb61f943bd14c8c7166571b5ccf106
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28872
2012-08-02 15:36:42 -07:00
Kees Cook
41282f1bbb Add missing mocked TPM functions
BUG=chromium-os:33110, chromium-os:33111, chromium-os:33112
TEST=alex build, "MOCK_TPM=1 make" links
STATUS=Fixed

Change-Id: I9d71e49ec6c98e74954a17849ca82bf948d78ff2
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28982
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Reviewed-by: Taylor Hutt <thutt@chromium.org>
2012-08-02 10:02:57 -07:00
Randall Spangler
7c3a486d6d Flush keyboard at start of screens which take keyboard input
BUG=chrome-os-partner:11887
TEST=manual

Boot with dev mode on.  Boots normally.

Boot with dev mode on, hammering on ENTER key as soon as you release power.
Dev mode screen is shown.
Keep hammering.  Dev screen will stay up as long as you do this.
Wait >2 sec.
Press ENTER.  System reboots to TONORM screen.

Change-Id: I18e35b23c18a65637a84d3d1964b291e0cb5e8c5
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28995
Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org>
2012-08-01 18:01:52 -07:00
Randall Spangler
6c9f097380 Revert "Enter key at DEV screen no longer transition to TONORM screen"
This reverts commit 2b45044edf

We will instead flush the keyboard buffer at the start of screens which accept keyboard input.

Change-Id: I1f5a480c6c1eeb7432b557dd4d984c1450ac973e
Reviewed-on: https://gerrit.chromium.org/gerrit/28952
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-08-01 12:22:49 -07:00
Randall Spangler
2b45044edf Enter key at DEV screen no longer transition to TONORM screen
And space at TONORM screen no longer confirms disabling dev mode

Added Ctrl+Refresh as an alias for tonorm screen request.  U-boot will
need to be enhanced to support that.  Until then, many FAFT tests will
break.

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

1. Boot to DEV screen
2. Press Enter.  Nothing happens.
3. Press Space.  Goes to TONORM screen.
4. Press Space.  Nothing happens.
5. Press Enter.  Reboots with dev mode disabled.

Change-Id: I7f61c4001c668ac916f50f931a79a107752c83b5
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28851
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-31 16:07:33 -07:00
Bill Richardson
463eaeb308 security: Avoid integer wrap on 32-bit platforms
This could wrap before the assignment:

  uint64_t = uint32_t * int;

Instead:

  uint64_t = uint32_t;
  uint64_t *= int;

BUG=chrome-os-partner:11643
TEST=none

Nothing to test or verify. If the security guys approve, it's fixed.

Change-Id: Ib7c9774998332ac1a29c4551bc039eaa999ee681
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28841
Reviewed-by: Gaurav Shah <gauravsh@chromium.org>
2012-07-31 16:07:32 -07:00
Randall Spangler
0c32130a57 Shut down after EC software sync if lid is closed
So if the EC reboots when the lid is closed (for example, it wakes
from hibernate because the AC adapter was inserted), it won't leave
the AP powered on.

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

   Reboot EC with lid closed ('reboot hard').
   Should finish software sync and shut down.
   Reboot EC with lid open. Boots.
   Hibernate EC and wake with lid open. Boots.
   Hibernate EC and wake with power button press. Boots.
   Reboot into recovery mode. Boots. Press power button; shuts down.
   Reboot into recovery mode. Boots. Close lid; shuts down.

CQ-DEPEND=*22578

Change-Id: I09d5331222aa10b73518f9f574ec5a32d8e6ac23
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28525
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-26 16:50:10 -07:00
Randall Spangler
584e0d2070 Add more specific recovery reasons for EC software sync.
Software sync will, of course, work perfectly, so these will never be needed.

BUG=none
TEST=none (hey, it all works perfectly)

Change-Id: I0014dfb99507c5eb00de73b77edb7538b598658f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28495
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-26 16:25:35 -07:00
Randall Spangler
09d0c2e487 Handle reboots required to protect/unprotect RW firmware
Necessary for updating snow EC

BUG=chrome-os-partner:11087
TEST=force an EC update by loading a slightly old EC and then a new BIOS

Change-Id: Id00257f8a67c08077a5b396cf120a056a7601671
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28436
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-25 18:07:20 -07:00
Randall Spangler
241de33bab EC software sync now updates RW firmware if necessary.
BUG=chrome-os-partner:11087
TEST=manual

1. Update EC to a new version
2. Rebuild EC code and chromeos-bootimage
3. Update BIOS (AP) RW firmware
4. Reboot.  EC should get updated to the version in the BIOS iamge.

CQ-DEPEND=28414

Change-Id: I227d9bf7cc1f4984d6eb13b5372bcf4181ad0df5
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28415
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-25 18:07:20 -07:00
Bill Richardson
1a72ad60d7 Call VbExEcGetExpectedRW() with the correct parameters.
vboot is passing in an index but the function expects an enum.

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

Build with serial enabled, watch what happens. Before, it does this:

  ec.c: VbExEcGetExpectedRW: Unrecognized EC firmware requested.
  VbEcSoftwareSync() - VbExEcGetExpectedRW() returned 65536
  VbSetRecoveryRequest(34)

After this change, it should get a little further:

  ec.c: VbExEcGetExpectedRW: EC-RW image offset 0 size 0.
  ec.c: VbExEcGetExpectedRW: EC image has bogus size.
  VbEcSoftwareSync() - VbExEcGetExpectedRW() returned 65536
  VbSetRecoveryRequest(34)

Sigh.

Change-Id: Ideb5f9d70bc5f3f202a8e04a6ec718e1d674d526
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28341
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-07-24 18:55:36 -07:00
Randall Spangler
029ae65756 VbExEcGetExpectedRW() should take a const **
Since vboot is expected not to modify the contents of the returned pointer.

BUG=chrome-os-partner:11148
TEST=if it builds, it worked

This change MUST be submitted at the same time as u-boot
https://gerrit.chromium.org/gerrit/28146.

Change-Id: Ieeee8f456a7fbd9fe6b108a29e208058310b471b
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28145
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-23 16:12:53 -07:00
Gabe Black
b1aa7aea2d Change VbExEcGetExpectedRW so that vboot picks an ec image instead of U-Boot.
This changes the signature of the function above so that it takes an additional
parameter that specifies which EC image vboot wants. This is better than making
U-Boot decide because U-Boot doesn't really keep track of which version it is
(it peeks at internal vboot data) and vboot does.

Also, some consts were removed from the image pointer pointer. The pointer
itself will be changed in the body of the function to tell vboot where the EC
has been loaded, and the contents of the buffer will be changed because U-Boot
will have to actually load the EC there.

BUG=chrome-os-partner:11148
TEST=Built vboot_reference, vboot_reference-firmware, chromeos-u-boot, and
chromeos-bootimage for Daisy and Link and saw them complete successfully with
and without the signature for U-Boot's version of this function being updated.
That works because the function isn't actually being used yet.

Change-Id: I2814c8210eb5b3d965bb8bbf23c0f283f9e44c90
Signed-off-by: Gabe Black <gabeblack@google.com>
Reviewed-on: https://gerrit.chromium.org/gerrit/27755
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Gabe Black <gabeblack@chromium.org>
Tested-by: Gabe Black <gabeblack@chromium.org>
2012-07-19 18:45:16 -07:00
Randall Spangler
d4faa060cc Partial EC software sync implementation
Doesn't check the EC hash, but does jump to the correct image, for now
assuming the hash is good.

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

- Power+refresh.  System boots.  EC is in RO (verify via 'ectool version')
- Create a BIOS signed *without* RO-normal.
- Power+refresh.  System boots.  EC ends up in A.
- ectool eventgetb.  Event 0x2000 IS present, indicating EC has rebooted
- ectool eventclearb -1
- Power button to shut down, then power button to power back on.
- ectool eventgetb.  Event 0x2000 is NOT present.
- crossystem recovery_request=123 && reboot.  System reboots to recovery mode
  and EC is in read-only (verify via EC console 'sysinfo')
- Power off and on.  System boots.  EC ends up in A again.

Change-Id: I39682d1bf7215c62a4b20613d029e78194b98826
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27574
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-16 18:23:28 -07:00
Randall Spangler
cc36ff4073 Request EC reboot to RO via return code rather than function (vboot portion)
This gives the AP a chance to save NvStorage data first.

BUG=chrome-os-partner:11087
TEST=none yet; API isn't used yet

Change-Id: Iae7a24958fb076039795b92d9edb73d7e6ebfc6f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27525
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-16 17:49:11 -07:00
Bill Richardson
88d9375f50 Ensure that the VGA is enabled/disabled as needed.
On some systems, we require the VGA option ROM to be loaded before VbInit()
is called so we can display BIOS screens. If that hasn't happened, we
request it and reboot. Alternatively, if we don't need the option ROM
(normal mode) but we've already loaded it, we un-request it and reboot just
in case there are security vulnerabilities that might be exposed.

Not all systems need preloaded option ROMs. There is an additional input
flag that indicates whether this matters or not.

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

Using keyboard-based dev-mode, switch between normal and dev mode and back.
It should work as expected.

Change-Id: Id1d662014d47ab648c73db4b1647520801f3a0b8
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27125
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-07-11 12:09:38 -07:00
Randall Spangler
053b7b682c Stub out new vboot APIs for EC software sync
BUG=chrome-os-partner:11087
TEST=make sure it builds; APIs aren't used yet.

Change-Id: If86f3465a889b8fa87cf225d2b9876fe79311327
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26875
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-07-07 19:10:24 -07:00
Randall Spangler
b2ac7fbbbf Add EC software sync flag to VbInit()
Nothing uses this yet; this is just a placeholder so the u-boot code
which sets the flag based on the FDT can go in.

BUG=chrome-os-partner:11087
TEST=if it builds it works

Change-Id: Ie04e3330bcda5c07d34a49391627316bd6232b5a
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26874
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-07-07 19:10:24 -07:00
Che-Liang Chiou
dc6b642b47 Set/clear developer mode flag in VbInit output
This would allow caller of VbInit know if vboot is on developer mode.

Signed-off-by: Che-Liang Chiou <clchiou@chromium.org>

BUG=chrome-os-partner:10947
TEST=Snow U-Boot successfully read the correct value of the flag

Change-Id: If1d88975892045467f5ab9d00b00ed53765b83f1
Reviewed-on: https://gerrit.chromium.org/gerrit/26557
Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org>
Commit-Ready: Che-Liang Chiou <clchiou@chromium.org>
Tested-by: Che-Liang Chiou <clchiou@chromium.org>
2012-07-02 03:00:00 -07:00
Che-Liang Chiou
8d47de4750 Revert "Expose getter of virtual dev switch value"
This reverts commit 552ae43be0.

vboot should set up dev switch value in output flag of VbInit, instead
of exposing TPM getter to U-Boot.

BUG=chrome-os-partner:10947
TEST=build okay for Snow and Alex

Change-Id: Iee884dbf758fef0cacfed6bcbab373ab5ec5aa25
Reviewed-on: https://gerrit.chromium.org/gerrit/26556
Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org>
Commit-Ready: Che-Liang Chiou <clchiou@chromium.org>
Tested-by: Che-Liang Chiou <clchiou@chromium.org>
2012-07-02 02:35:55 -07:00
Che-Liang Chiou
552ae43be0 Expose getter of virtual dev switch value
Firmware needs to be able to read virtual dev switch to set up device
tree blob which is passed to kernel and eventually read by crossystem.

Signed-off-by: Che-Liang Chiou <clchiou@chromium.org>

BUG=chrome-os-partner:10947
TEST=With this change, U-Boot can read virtual dev switch.

Change-Id: Ifac2ec3d39b8e9c1100031fdef085c28bb8b37c7
Reviewed-on: https://gerrit.chromium.org/gerrit/26394
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Ready: Che-Liang Chiou <clchiou@chromium.org>
Tested-by: Che-Liang Chiou <clchiou@chromium.org>
2012-06-29 00:19:08 -07:00
Bill Richardson
17b8224ea5 Add bits to request and acknowledge Option ROM loading.
For fastest boot, we don't want to load the VGA Option ROM every time, but
only when we need it. Coreboot does that loading, but it can't always know
when it's needed (with keyboard-based dev-mode, coreboot can't tell if we're
in dev-mode or not). By the time we get to U-Boot, it's too late, so we need
two extra bits - one for vboot to tell coreboot to load the Option ROM and
another for coreboot to let vboot know it's been done.

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

The only visible change is that crossystem will now have an "oprom_needed"
flag that can be set or cleared. Nothing actually pays attention to it yet,
though.

Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Change-Id: I521a6afdfb8ea17a8148b32eeb858844c981de9c
Reviewed-on: https://gerrit.chromium.org/gerrit/26272
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-06-27 17:40:40 -07:00
Bill Richardson
592567e956 Remove VbExTrustEC() from vboot, so it can go into BIOS.
The VbExTrustEC function should be implemented in the BIOS, not the vboot
library. Also, weak references don't seem to work with our linker, so we'll
have to just require it always.

BUG=chrome-os-partner:9953
TEST=none

This must go in with a simultaneous change to U-Boot. The only test is
whether or not everything continues to compile.

Change-Id: I8a5ccb167eec3bcacbe892cf0bdcfe550a1f57d6
Reviewed-on: https://gerrit.chromium.org/gerrit/25557
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
2012-06-18 15:21:30 -07:00
Randall Spangler
acd6f4688a Add GBB flags to enable dev mode by default
And enable dev_boot_usb by default.
And disable rollback checks.

The first flag is necessary for factory to build with keyboard
controlled dev mode.  The other flags are really handy for development
on systems where you've defeated firmware WP and are installing custom
firmware.

BUG=chromium-os:31844
TEST=make && make runtests

Signed-off-by: Randall Spangler <rspangler@chromium.org>

Change-Id: I9d837fee676cb0186ea98f13005ad60a9ab86393
Reviewed-on: https://gerrit.chromium.org/gerrit/25265
Tested-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Commit-Ready: Randall Spangler <rspangler@chromium.org>
2012-06-14 18:57:52 -07:00
Kees Cook
8b6da26a6e tlcl: add GetOwner command
Since the "ownership" permament flag does not indicate if the TPM is
currently owned, the state of TPM Ownership must be read via a Capability
read of TPM_CAP_PROP_OWNER. This adds the "getownership" function.

BUG=chromium-os:22172
TEST=x86-alex build & manual test

Change-Id: I2fc9e933e891ba40190d008436b22496dced1c93
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/24784
Reviewed-by: Will Drewry <wad@chromium.org>
2012-06-13 14:22:12 -07:00
Randall Spangler
c0e3742996 Remove unused test fields from VbNvStorage
Confirmed via codesearch that these fields are not used outside of
vboot_reference itself, and the only use inside vboot_reference is one
test which checked that the test error generation itself worked.

BUG=chromium-os:31668
TEST=make && make runtests

Signed-off-by: Randall Spangler <rspangler@chromium.org>
Change-Id: Ic393e126ca2853f7aaff19ffd6fcdbdb1c47689f
Reviewed-on: https://gerrit.chromium.org/gerrit/24895
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-06-11 10:43:32 -07:00
Mike Frysinger
71b126ba46 add SetVirtualDevMode stub
Fixes build failure seen in u-boot for tegra2 seaboard:
.../vboot_fw.a(vboot_api_kernel.o): In function 'VbConfirmChangeDevMode':
(.text+0x84): undefined reference to 'SetVirtualDevMode'

BUG=None
TEST=`emerge-tegra2_seaboard chromeos-u-boot` works again

Change-Id: If374a78218fc8a7921ff8dddde163138969e0876
Reviewed-on: https://gerrit.chromium.org/gerrit/24948
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
2012-06-09 12:29:21 -07:00
Mike Frysinger
1efd9e6539 add extra param to mocked SetupTPM
Previous commit missed this file.

BUG=None
TEST=None

Change-Id: Id29e3291d4843f5ace71c2eedf7f91ee04df62d5
Reviewed-on: https://gerrit.chromium.org/gerrit/24944
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
2012-06-09 01:24:55 -07:00
Bill Richardson
ec8df1628c Support virtual dev-switch (keyboard-based dev-mode)
BUG=chrome-os-partner:9706
TEST=manual

Currently, Link is the only platform that enables this feature.

To enter dev-mode:

  Boot into recovery mode using the magic key chord. At the Insert screen,
  press Ctrl-D. You'll be asked if you want to enter developer mode. If you
  then press ENTER, it will reboot with dev-mode enabled. If you press SPACE
  or ESC, it will return to the Insert screen.

  If you enter recovery mode through any other means, or if dev-mode is
  already enabled, pressing Ctrl-D at the Insert screen will have no effect.

To return to normal mode:

  Reboot. At the Dev screen, press ENTER or SPACE. It will reboot to
  recovery mode and ask you if you want to return to normal mode. If you
  press ESC or power off, you'll still be in dev-mode. Press ENTER or SPACE,
  and it will reboot into normal mode (of course, if you've messed up your
  images while in dev-mode, you'll just come right back to recovery mode
  again).

  You can also request a direct return to normal mode by running

    crossystem disable_dev_request=1

  and rebooting.

Change-Id: I435905855a6c39932ee466cc046bdc4c4c860f98
Reviewed-on: https://gerrit.chromium.org/gerrit/24160
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
2012-06-08 22:24:05 -07:00
Bill Richardson
35d0733626 Add DISABLE_DEV_REQUEST flag to nvram.
This just creates the bit. It doesn't actually do anything yet.

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

  crossystem disable_dev_request=1
  crossystem
  crossystem disable_dev_request=0
  crossystem

Change-Id: I0e92a6b5ef5074ee5eae2d6d469c1c9826faecb3
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/23752
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-05-25 16:05:22 -07:00
Bill Richardson
6f4cc56359 Honor both fake_dev and virtual dev switch
BUG=chrome-os-partner:9706
TEST=none

No test yet. The entire boot/dev-mode/recovery flow depends on this working.
This is only part of the process, which will eventually be tested through
FAFT.

Change-Id: Iea6eaf59d4f349590cf9b920e4effb6a2641b2dc
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/23657
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-05-25 12:47:48 -07:00
Kees Cook
201fe0bb55 cryptolib: rename SHA* function to avoid openssl collision
When linking tools that need OpenSSL functions on the target, the
resolution of SHA* functions was being redirected to the firmware
cryptolib instead of the OpenSSL implementations, which was causing
OpenSSL calls to crash. This renames the internal implementations
to avoid the collision.

BUG=None
TEST=make runtests passes, mount-encrypted runs on target again.

Change-Id: Ica4fb04faf203ae3b4118c540f18d40239753810
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/23305
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-05-22 19:52:55 -07:00
Bill Richardson
b75d8adcc0 Use virtual dev-mode switch when told to.
If VbInit() is instructed to look at a virtual dev-mode switch, then it will
use value contained in the TPM's firmware space instead of a hardware GPIO
to determine if developer mode is enabled.

This change just makes it look. It doesn't provide a way to actually set
the value in the TPM. VbInit() isn't being told to look yet, either. Those
changes are coming.

BUG=chrome-os-partner:9706
TEST=none

The usual sanity-check applies:

  make
  make runtests

But to actually test that this stuff is working IRL requires special tweaks
to other components and monitoring the serial debug output from both EC and
CPU. We'll save the hands-on tests for when it's all done.

Change-Id: Ie485ad2180224e192238bf2a5dbf95bbcb9130f9
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/23067
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-05-18 18:15:58 -07:00
Bill Richardson
feac077c1d Add checksum to TPM RollbackSpace regions for FW and kernel.
BUG=chrome-os-partner:9707
TEST=manual

  make
  make runtests

You can also test it by clearing the TPM, then manually looking at the TPM
regions. In dev-mode, clear the regions and you'll see something like this:

  localhost ~ # tpmc read 1007 a
  1 0 0 0 0 0 0 0 0 0
  localhost ~ # tpmc read 1008 d
  1 4c 57 52 47 0 0 0 0 0 0 0 0
  localhost ~ #

Go back to normal mode and reboot, and you'll see something like this:

  localhost ~ # tpmc read 1007 a
  2 0 1 0 1 0 0 0 0 4f
  localhost ~ # tpmc read 1008 d
  2 4c 57 52 47 1 0 1 0 0 0 0 55
  localhost ~ #

The important things are that the first number is now 2, instead of 1, and
the last number is not zero (it's a checksum, so it'll vary depending on the
other numbers, which will themselves vary according to the firmware and
kernel versions).

Change-Id: Ia4040311c2a4b2819792549b883377c8b6b89d48
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/22856
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-05-17 09:21:50 -07:00
Bill Richardson
317e25c663 Use CHROMEOS_EC macro to cut down compiled size.
This macro is only defined by the EC firmware build process, and is used to
cut down the amount of compiled code. A future CL will refactor the library
to make this unnecessary.

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

  make
  make runtests

Change-Id: I41d0b4b282ec7147e8d6f508531af32e74f2d19e
Reviewed-on: https://gerrit.chromium.org/gerrit/22313
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
2012-05-09 20:52:01 -07:00
Bill Richardson
fe356f9d57 Fix potential memory leak in KeyBlockVerify()
BUG=none
TEST=none

Change-Id: I17f1cff7d6f750dfd862d71941c6b8cfec57b6bf
Reviewed-on: https://gerrit.chromium.org/gerrit/22312
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
2012-05-09 20:14:03 -07:00
Bill Richardson
3079538053 Separate SHA256 and SHA512 into separate files
This is just to pave the way for better use of vboot by the EC.

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

  make
  make runtests

Change-Id: I2e68371039bfc1b492245db12facf0c5ad592824
Reviewed-on: https://gerrit.chromium.org/gerrit/22301
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
2012-05-09 18:47:53 -07:00
Bill Richardson
ec15b1fce9 Protect ARRAY_SIZE macro from being #defined twice
BUG=chrome-os-partner:7459
TEST=none

Change-Id: I3664ad9db4a4e0cecd38443bf01f99531ba80972
Reviewed-on: https://gerrit.chromium.org/gerrit/22183
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-05-09 10:46:38 -07:00
Bill Richardson
2448d3b3bc Create vbutil_ec tool for signing EC firmware.
This just adds the vbutil_ec tool (and a simple test of the library
functions related to it).

BUG=chrome-os-partner:7459, chromium-os:27142
TEST=manual

  make
  make runtests

Change-Id: I2a2c4e7cfb8ac6ce2229c5de4252a5cc89321fa5
Reviewed-on: https://gerrit.chromium.org/gerrit/21868
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Stefan Reinauer <reinauer@google.com>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2012-05-04 12:16:45 -07:00
Bill Richardson
f47291926a Require -Wall -Werror for everything.
BUG=none
TEST=none

Change-Id: Ib9781238274285f73d00d8fca4ecda28fc2c6678
Reviewed-on: https://gerrit.chromium.org/gerrit/21748
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
2012-05-03 17:38:57 -07:00
Che-Liang Chiou
916cf1e977 Omit body load address check
Omit this check because this check is not really necessary and it is
dealing more harms than goods to ARM boards.

While body load address is configurable, it is not quite possible to fix
all the build scripts and runtime scripts to carry this address; so in
reality all scripts use the default body load address.

The problem is, this default address is not friendly to ARM boards, and
it virtually makes this check fails on ARM boards.

BUG=chromium-os:28077
TEST=emerge-{daisy,x86-alex} vboot_reference
TEST=load_kernel_test -b 1 chromiumos_image.bin
TEST=run verified boot on Daisy

Change-Id: I1a1cc0aedf254e2a2b680046812ab7154f26dea7
Reviewed-on: https://gerrit.chromium.org/gerrit/20947
Tested-by: Che-Liang Chiou <clchiou@chromium.org>
Reviewed-by: Gaurav Shah <gauravsh@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Ready: Che-Liang Chiou <clchiou@chromium.org>
2012-04-24 23:38:31 -07:00
Kees Cook
f9e82e9695 mount-encrypted: close TPM when spawning resizer
When the filesystem resizing process starts, it has the TPM open,
which means it can collide with tcsd after the main process exits.
Additionally, improve the debugging around TPM usage for better timing
analysis.

BUG=None
TEST=lumpy build & manual testing

Change-Id: I7028131015fb972c99e8b3d035f58346f08fbd06
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/19535
Reviewed-by: Elly Jones <ellyjones@chromium.org>
2012-04-05 13:27:17 -07:00