Commit Graph

230 Commits

Author SHA1 Message Date
Nicolas Boichat
83bd850f3f vboot_reference: Add support for 2048-bit exponent 3 keys
This also adds the required tests (keys, testcases).

BRANCH=none
BUG=chromium:684354
TEST=make runtests

Change-Id: I5e148f8792ea325f813d76089271f3c4bcc2935d
Reviewed-on: https://chromium-review.googlesource.com/438951
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-02-18 00:39:28 -08:00
Nicolas Boichat
8c53e881f8 host_key2: Add VB2_SIG_ALG_COUNT to count the number of valid signatures
More reliable than simply assuming that VB2_SIG_RSA8192 is the last
signature.

BRANCH=none
BUG=chromium:684354
TEST=rm tests/testkeys/key_*; make genkeys -j
TEST=make runtests -j

Change-Id: I755b3afb50313fcdf292fb3cd5b0dfe09f8593e3
Reviewed-on: https://chromium-review.googlesource.com/438948
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-02-15 10:47:29 -08:00
Nicolas Boichat
0bde10afbf signature_digest/SignatureDigest: convert vb2_crypto to hash algorithm
We were passing the wrong value to PrependDigestInfo. Let's also refactor
the function a little bit.

BRANCH=none
BUG=chromium:689371
TEST=make gentestcases; git status => no change

Change-Id: I0244c3f3de05b33b7ddd21e93a266faf34f2c239
Reviewed-on: https://chromium-review.googlesource.com/439086
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-02-11 02:42:01 -08:00
Randall Spangler
a609478d1a 2lib: add VB2_DEBUG_RAW() to print without function name
Currently, VB2_DEBUG() will print the function name as a prefix to the
debug output.  Add VB2_DEBUG_RAW() to print without that, so that it's
possible to print little bits of debug output.  Use this in ec_sync to
hex dump the hashes.

And then clean up all of the debug calls which explicitly did things like:
    VB2_DEBUG("%s: foo", __func__);
to just:
    VB2_DEBUG("foo");
so they don't double-print the function name

BUG=chromium:683391
BRANCH=none
TEST=build_packages --board=reef chromeos-firmware &&
     DEBUG=1 make -j runtests
CQ-DEPEND=CL:430978,CL:431111

Change-Id: I0c35519d2e670d55d65d01eaa60d61f3e3edf419
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/431171
Reviewed-by: Julius Werner <jwerner@chromium.org>
2017-01-20 22:40:31 -08:00
Randall Spangler
21015898b3 firmware: replace VBDEBUG(()) macro with VB2_DEBUG()
The original VBDEBUG macro used doubly-nested parens to work with
MSVC, which didn't support varargs in macros.  We now only use more
modern compilers, so replace it with the VB2_DEBUG macro and get rid
of the ugly and fragile double parens.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; build_packages --board=reef chromeos-firmware

Change-Id: Ifc0cb0733b14daaa1fde095fab7da4215a538c77
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/425133
Reviewed-by: Shelley Chen <shchen@chromium.org>
2017-01-12 15:56:27 -08:00
Aaron Durbin
8bb1c3b852 crossystem: add phase_enforcement field
Provide 'phase_enforcement' field that indicates if a
system should have its full security features enabled while
in the factory. The backend implementation currently is only
for x86 using chromeos_acpi.

On reef:
$ grep ^ /sys/devices/platform/chromeos_acpi/GPIO.*/*
/sys/devices/platform/chromeos_acpi/GPIO.2/GPIO.0:4
/sys/devices/platform/chromeos_acpi/GPIO.2/GPIO.1:1
/sys/devices/platform/chromeos_acpi/GPIO.2/GPIO.2:10
/sys/devices/platform/chromeos_acpi/GPIO.2/GPIO.3:INT3452:00

BUG=chrome-os-partner:59951
BRANCH=None
TEST=Tested on reef with accompanying coreboot patches and flipping
internal pulls to see the correct setting.

Change-Id: Id5401d795cff8874a038f2456121549713a11237
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/418899
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
2016-12-13 11:51:17 -08:00
Randall Spangler
6e3931d1f6 vboot: Add vb2_unpack_key_buffer
Previously, vb2_unpack_key() actually unpacked a key buffer.  Callers
that had a vb2_packed_key had to typecast it back to a uint8_t buffer to
unpack it.  Rename vb2_unpack_key() to vb2_unpack_key_buffer(), and make
vb2_unpack_key() unpack a vb2_packed_key.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge;
     emerge-samus and boot it

Change-Id: I9ee38a819c59cc58a72ead78cf5ddf3d0f301ae7
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400906
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-11-06 02:34:03 +00:00
Randall Spangler
559a110f33 vboot: use malloc and free directly
Originally, vboot1 code used VbExMalloc() and VbExFree() since it needed
to talk to EFI firmware that didn't have standard malloc() and free().
Now, coreboot and depthcharge implement them as wrappers around those
standard calls.  vboot2 code already calls them directly, so let vboot1
code do that too.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge

Change-Id: I49ad0e32e38d278dc3589bfaf494bcf0e4b0a4bd
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400905
2016-11-06 02:33:50 +00:00
Randall Spangler
13c0776aab vboot: Remove the remainder of vb1 cryptolib
At this point, all that's left are a few constants in the cryptolib
header files, and they're only used by host-side code.  So move them to
a host-side header file and get rid of cryptolib.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge

Change-Id: I2235f0e84e13fef313afe54e749b73744b157884
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400903
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-11-06 02:33:19 +00:00
Randall Spangler
46a382d613 vboot: Remove vboot1 cryptolib padding source
The old vboot1 cryptolib hard-coded many of its padding arrays in a
padding.c file.  Use the equivalent vboot2 apis instead.

This change is almost exclusively on the host and test side; the only
firmware impact is on a single line of debug output.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge

Change-Id: If689ffd92f0255847bea2424950da4547b2c0df3
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400902
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-11-06 02:33:02 +00:00
Randall Spangler
5a9f498182 host,test: Remove unneeded vb1 rsa functions
Another in a continued stream of refactoring.  This change removes more
of the vb1 rsa library code and associated tests, in favor of their vb2
equivalents.  This change touches only host-side code and its tests, not
firmware.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge

Change-Id: I1973bc2f03c60da62232e30bab0fa5fe791b6b34
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400901
2016-10-29 19:41:09 -07:00
Randall Spangler
664096bd1a vboot: use standard memcmp, memcpy, memset
Originally, we didn't trust the firmware to provide these functions from
a standard library.  Now, with coreboot, we do.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge

Change-Id: I4e624c40085f2b665275a38624340b2f6aabcf11
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/399120
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-10-23 13:33:38 -07:00
Randall Spangler
fb267154d2 Fix indentation in firmware and host libs
vboot_reference originally used 2-space indentation, rather than
kernel-style tabs.  This makes it painful to maintain given that newer
source files are kernel-style.

Re-indent the files that need it, and reflow comments.

No functionality changes.

BUG=none
BRANCH=none
TEST=make runtests

Change-Id: I7dabed41f69434b1988a52600c0cb1eac8c8d7e6
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/396488
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-10-13 17:27:07 -07:00
Randall Spangler
770202f0c7 Fix more coverity warnings
Assorted minor code issues, which we should fix so any new errors stand
out more.

BUG=chromium:643769
BRANCH=none
TEST=make runtests

Change-Id: I82ece2de948ef224115c408bdfc09445d3da119b
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/390337
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-10-01 00:04:39 -07:00
Randall Spangler
d8a9ede87c futility/host lib: Fix coverity warnings
Assorted minor code issues, which we should fix so any new errors stand
out more.

BUG=chromium:643769
BRANCH=none
TEST=make runtests

Change-Id: Ib37b45dea54bd506b519b0304300b8d192e34339
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/382319
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-09-14 13:05:02 -07:00
Mike Frysinger
6c18af5017 cgpt: add support for managing the legacy boot gpt bit
Bit 2 in the GPT partition attributes has been allocated as the legacy
bios boot (equivalent to the "active" or "boot" flag in MBR).  If we
try to boot images on newer x86 systems, syslinux dies because it can't
find any GPT partition marked bootable.

Update the various parts of cgpt add & show to manage this bit.  Now we
can run:
	cgpt add -i 12 -B 1 chromiumos_image.bin
And the EFI partition will be marked bootable.

BUG=chromium:644845
TEST=vboot_reference unittests pass
TEST=booted an amd64-generic disk image via USB on a generic laptop
BRANCH=None

Change-Id: I78e17b8df5b0c61e9e2d8a3c703e6d5ad230fe92
Reviewed-on: https://chromium-review.googlesource.com/382411
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-09-08 15:36:23 -07:00
Randall Spangler
5c537e3ea8 futility: use vboot2 functions for kernel preamble
Another in a long series of refactoring changes to replace old vboot1
code with its vboot2 equivalent.  Futility changes only; no change to
firmware.

BUG=chromium:611535
BRANCH=none
TEST=make runtests

Change-Id: I7be813b82820674e975db13d5e540e49bdea028d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/366057
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-09-06 22:02:21 -07:00
Randall Spangler
7d0cc747c7 vboot: Remove vboot1 host signature functions
These have been superseded by their vboot2 equivalents.  No firmware
changes; host-only.

BUG=chromium:611535
BRANCH=none
TEST=make runtests

Change-Id: I36b5d3357767f32489efb7e480049620dcc0fce4
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363970
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-09-06 22:02:19 -07:00
Randall Spangler
a62ffa8d61 vboot: replace CreateKernelPreamble() with vboot2 equivalent
Continued refactoring of host library to kernel style / vboot2 structs.

BUG=chromium:611535
BRANCH=none
TEST=make runtests

Change-Id: Ifed376812ed7690eea1ec0dfab958e836f7724a0
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363951
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-09-06 22:02:18 -07:00
Randall Spangler
0efc4f3ee1 futility: Fix lookup of invalid algorithm names
If given a malformed file with an invalid algorithm, futility could
dereference null when looking up the algorithm names.

BUG=chromium:643769
BRANCH=none
TEST=make runtests

Change-Id: I26d1312b8bf2eec8d806664708676daa9f36fa58
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/380522
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
2016-09-06 22:02:16 -07:00
Randall Spangler
f7559e4b46 futility: Use vboot 2.0 APIs for public keys
This replaces calls to the old vboot 1 APIs with their vboot 2.0
equivalents.

BUG=chromium:611535
BRANCH=none
TEST=make runtests

Change-Id: Ieb1a127577c6428c47ac088c3aaa0d0dad6275a8
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/356541
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-09-02 01:28:37 -07:00
Nicolas Norvez
8e917140b7 crossystem: refactor VM detection to share across architectures
If there is no HWID and mainfw_type is "nonchrome", report that the
host is a VM. If HWID is present, it's not a VM. Make the detection
architecture-independent.

BUG=chromium:632303
TEST=emerge-cyan vboot_reference and test binary on QEMU and HW
TEST=emerge-veyron_minnie vboot_reference and test binary on HW
BRANCH=none

Change-Id: I076eb9838a3b724ded0cfded9fb8d8a5392631c8
Reviewed-on: https://chromium-review.googlesource.com/368650
Commit-Ready: Nicolas Norvez <norvez@chromium.org>
Tested-by: Nicolas Norvez <norvez@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-08-15 09:25:29 -07:00
Nicolas Norvez
969ce32e40 Detect and report VM environment in crossystem
Add "inside_vm" command to crossystem.
x86: If there is no HWID and mainfw_type is "nonchrome", report that the
host is a VM. If HWID is present, it's not a VM.
ARM: Detection not implemented and so far no ARM VMs exist, always
report that the system is not a VM

BUG=chromium:632303
TEST=emerge-cyan vboot_reference and test binary on cyan QEMU and HW
BRANCH=none

Change-Id: I18f5cb24b68e51f3097d9aafd9f0db0e610d322a
Reviewed-on: https://chromium-review.googlesource.com/367240
Commit-Ready: Nicolas Norvez <norvez@chromium.org>
Tested-by: Nicolas Norvez <norvez@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-10 15:31:09 -07:00
Randall Spangler
d46461cec2 futility: Use vboot 2.0 APIs for private keys
This replaces calls to the vboot 1 host library with their vboot 2.0
equivalents.

BUG=chromium:611535
BRANCH=none
TEST=make runtests

Change-Id: Id061554fd82ea3efe35d0fe1485693b47599a863
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/356540
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-08-10 15:30:35 -07:00
Randall Spangler
939cc3a5c2 futility: Use only vboot 2.0 APIs for keyblocks
This refactors futility and the host library to use only vboot 2.0 APIs
to create and verify keyblocks.

BUG=chromium:611535
BRANCH=none
TEST=make runtests

Change-Id: Ia3cc1e24971b94f01bcb4890c8666a3af6f84841
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/356129
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-08-10 15:30:33 -07:00
Randall Spangler
814aaf09ce futility: Create signatures using vboot 2.0 APIs
Refactor futility to use only vboot 2.0 APIs to create signatures.

BUG=chromium:611535
BRANCH=none
TEST=make runtests

Change-Id: I176e7f424fa556d34d8fe691df5681f1e43210ce
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/356128
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-08-03 19:40:41 -07:00
Randall Spangler
158b29672a futility: cmd_show uses only vboot 2.0 APIs
This removes the remaining vboot 1.0 API calls from cmd_show.

BUG=chromium:611535
BRANCH=none
TEST=make runtests

Change-Id: I03c4260aa034100efbbea1005367cd85dfff273d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/350173
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-08-03 17:47:13 -07:00
Randall Spangler
98263a1b17 vboot: Upgrade VerifyFirmwarePreamble() to vboot2.0
This replaces all calls to vboot1 VerifyFirmwarePreamble() with
equivalent vb2.0 functions.  No effect on ToT firmware, which already
uses the vboot2.0 functions.

BUG=chromium:611535
BRANCH=none
TEST=make runtests

Change-Id: I5c84e9ed0e0c75e2ea8dbd9bfcde0597bc457f24
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/349322
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-07-26 19:42:38 -07:00
sselvar2
bba272a877 apollolake: Find GPIO bank offset for write protect pin
Specify function to find GPIO bank offset for write protect pin in
Broxton.

BUG=chrome-os-partner:55604
BRANCH=none
TEST=verify crossystem output with and without WP screw.

Change-Id: Ied41f31e59e0dfc699fbcd1b6bb8688f1fea549c
Signed-off-by: sselvar2 <susendra.selvaraj@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/358124
Commit-Ready: Aaron Durbin <adurbin@chromium.org>
Tested-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2016-07-26 17:32:33 -07:00
Randall Spangler
ca72512866 vboot: Disambiguate vb2.1 structs and functions
Futility needs to link against both vboot1/vboot2.0 and vboot2.1
functions.  This was easy in the past because it did (vboot1 +
vboot2.1) and there's no overlap.

In replacing vboot1 function calls and structs with vboot2.0, now there
are symbol collisions between vboot2.0 and vboot2.1.  For example, both
of them use a struct called vb2_signature, but the structs are defined
differently.  Functions which operate on those structs also overload.

Rename the vb2.1 structs to start with vb21_ instead of vb2_.  Do the
same for vb2.1 functions which operate on vb2.1 data.

BUG=chromium:611535
BRANCH=none
TEST=make runtests

Change-Id: I24defd87cbd9ef64239faf1a8e98ab2372d27539
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/347458
Reviewed-by: Daisuke Nojiri <dnojiri@google.com>
2016-07-26 17:31:54 -07:00
Randall Spangler
7c3ae42e04 vboot: Convert vboot1 SHA calls to use vboot2
This change replaces all calls to the old vboot1 SHA library with their
vboot2 equivalents.

This is the first in a long series of changes to move the core vboot kernel
verification into vb2, and the control/display loop out to depthcharge.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; build samus firmware and boot it

Change-Id: I31986eb766176c0e39a192c5ce15730471c3cf94
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/344342
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-07-22 18:40:04 -07:00
Julius Werner
8228f47dfd cgpt: Add cgpt legacy parameter to set primary GPT signature to IGNOREME
Now that we have support for the IGNOREME signature in cgpt, we need a
way to set it on an existing disk. The easiest option is to shoehorn
this into the cgpt legacy command, because that's already made to modify
GPT header signatures (really, it would be nice to rename it to cgpt
signature or something, but let's not break existing uses for now).

BRANCH=None
BUG=chrome-os-partner:52595
TEST=unit tests

Change-Id: If2835fec28a9c39373abd050e2e057f73e5ec700
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/340073
Reviewed-by: Nam Nguyen <namnguyen@google.com>
2016-04-25 15:15:32 -07:00
Hung-Te Lin
aee6bd69fe Support doing battery cut-off in firmware stage.
Add a new crossystem value "battery_cutoff_request" to indicate that
next reboot should cut-off battery and shutdown during firmware stage.

This request is primarily for factories to ship devices in an safe
state. Previously we have done same thing by running "ectool battery-cutoff"
but that creates a problem which "ectool" (and the one to request for
cut-off) must live in developer mode while  the device must be shipped
in normal mode. The mode transition was solved by setting
"disable_dev_request=1", but that flag is may get lost on x86 systems
(having NV storage in CMOS) when the battery is cut-off .

From the experience from Ryu, such settings (dev mode transition and
battery cut-off) should be done together inside firmware execution so we
can create a new flag, battery_cutoff_request, to finalize device
properly.

BRANCH=none
BUG=chromium:601705
TEST=emerge-chell depthcharge vboot_reference chromeos-bootimage
     crossystem battery_cutoff_request=1
     # Unplug AC adapter
     reboot
     # See device rebooted and then shutdown immediately.
     # Press power button and system won't boot.
     # Attach AC adapter and now system boots.
CQ-DEPEND=CL:337596,CL:338193

Change-Id: I73ccae15b337cd65786106646546c67c155b8fa6
Reviewed-on: https://chromium-review.googlesource.com/337602
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2016-04-12 05:49:26 -07:00
Duncan Laurie
eb0c8cc39b crossystem: x86: Write VbNv with mosys if using vboot2
If this is an x86 system using vboot2 then write VbNv data
to CMOS and also use mosys to write it directly to flash.

BUG=chrome-os-partner:51846
BRANCH=none
TEST=emerge-chell vboot_reference; emerge-oak vboot_reference
verify on chell that "crossystem dev_disable_request=1" is
written to both CMOS and flash.

Change-Id: Ifd5dcee4d401f8de36801c5c0a7db3255e618e28
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/336311
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2016-04-11 14:36:41 -07:00
Duncan Laurie
e98431f52b crossystem: Move mosys based VbNv functions to shared code
The code to read/write vbnv with mosys was implemented in the
ARM specific code so move it to the generic crosystem code
so it can be used on x86.

No functional changes in this commit.

BUG=chrome-os-partner:51846
BRANCH=none
TEST=emerge-chell vboot_reference; emerge-oak vboot_reference

Change-Id: I3fe18fadb924094e710427208976328caf12a009
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/336310
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2016-04-11 14:36:41 -07:00
Mary Ruthven
46d78db74a vboot2: Add try RO software sync flag
This flag will be used by the firmware updater to indicate that RO
software sync should be attempted.

BUG=chrome-os-partner:48703
BRANCH=None
TEST=make runtests

Change-Id: I42090ac47da45c724e66334648ab447ad3c21178
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/320621
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-01-06 05:22:40 -08:00
Julius Werner
bbdd62f9b0 crossystem: Remove savedmem_base and savedmem_size fields
I don't even know what this is. It seems to have marked some kind of
debug buffer provided by H2C BIOS on pre-Daisy Chromebooks and has not
been touched since it was copied in here when crossystem was first
added. I can't find any references in our codebase so I doubt anybody
would miss it. Let's remove it so the '(error)' fields returned there on
any modern Chromebook stop confusing our vendors.

BRANCH=None
BUG=chromium:551715
TEST=Built for Falco and Jerry.

Change-Id: Ie2baec536b50bb192eb4cd3e48df212cce53561a
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/311346
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Bernie Thompson <bhthompson@chromium.org>
2015-11-09 12:49:18 -08:00
Julius Werner
c62f42b5c3 crossystem: Remove platform_family field
This field doesn't seem to be used for anyone and it keeps adding work
for people trying to bring up new platforms. If we ever needed something
like this again, we'd probably prefer to have it in mosys now anyway.
Let's get rid of it.

BRANCH=None
BUG=chromium:551715
TEST=Built for Falco and Jerry.

Change-Id: I6b96e255968fdd22a345d4a75bfdc1e79d3f5896
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/311345
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Bernie Thompson <bhthompson@chromium.org>
2015-11-09 12:49:18 -08:00
Mary Ruthven
12a55f255a Add NV flag to default boot legacy OS
In developer mode, this option will make the system try to boot into
a legacy OS first after the 30 second timeout. This removes the need to
press a key during boot to try legacy mode and the need to remove the
write protect screw to boot legacy as default.

BUG=chromium:310697
BRANCH=none
TEST=make runtests

Change-Id: I9a9f64c14ad015e21d08eec36e8fc187189cd2f2
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/304077
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-10-13 14:02:26 -07:00
Randall Spangler
c8e48545d5 vboot2: Support reboot requested by secdata
When a TPM goes from the disabled state to the enabled state, it must
reboot after being enabled, before it can be initialized.  In vboot1,
TLCL was part of vboot and this was handled internally.  In vboot2, the
caller must set a context flag, so that vboot can decide whether to
allow the reboot, or whether to go directly to recovery mode.  This
check is necessary to handle the following cases:

1) The device is booting normally, but the TPM needs a reboot.  This
should simply reboot, without going to recovery mode.

2) The device is booting in recovery mode, but the TPM needs a reboot.
If this is the first time it asked us, allow the reboot.

3) The TPM asked for a reboot last time, so we did.  And it's still
asking.  Don't reboot, because that runs the risk that whatever is wrong
won't be fixed next boot either, and we'll get stuck in a reboot loop
that will prevent recovery.  Boot into recovery mode.

Add a new NvStorage bit to track whether the TPM requested a reboot on
the previous boot.  That's better than what we did in vboot1, where we
used a special recovery request.  Vboot1 couldn't track getting stuck in
a reboot loop in normal mode, only in recovery mode.  The new code can
catch both.

BUG=chrome-os-partner:45462
BRANCH=ryu
TEST=make runtests

Change-Id: I2ee54af107275ccf64a6cb41132b7a0fc02bb983
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/300572
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
2015-09-17 17:35:11 -07:00
Shelley Chen
85f646613c crossystem: Updated crossystem to accomodate Android
(resubmit)

Previously crossystem assumed that mosys was located
in /usr/sbin.  In Android mosys is currently located
in /system/bin.  Using fixed paths as opposed to
'which' to prevent attacks where attacker could insert
mosys in PATH.

difference from previous commit:
  Removed the allocation of duplicate arrays.  Kept
  with simplicity of original version, just returning
  correct constant depending on detected platform.

BUG=chromium:527484
BRANCH=none
TEST=ran crossystem, crossystem fw_try_count/
fw_try_next, crossystem fw_try_count/fw_try_next=x
on smaug and daisy.

Change-Id: I923206db1411a9a35c9c8e3f9ede5016f49b5f26
Signed-off-by: Shelley Chen <shchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/299801
Reviewed-by: danny chan <dchan@chromium.org>
2015-09-14 23:47:03 -07:00
Eric Caruso
9cd821ca51 Revert "crossystem: Updated crossystem to accomodate Android"
This reverts commit 26825b53dc.

This looks like it breaks ARM systems by causing crossystem to crash freeing stuff.

BUG=chromium:523189

Change-Id: Ic1e1594519354e7b80424f5c66dc9bdb2605ec73
Reviewed-on: https://chromium-review.googlesource.com/295215
Reviewed-by: Eric Caruso <ejcaruso@chromium.org>
Commit-Queue: Eric Caruso <ejcaruso@chromium.org>
Tested-by: Eric Caruso <ejcaruso@chromium.org>
2015-08-22 00:24:02 +00:00
Shelley Chen
26825b53dc crossystem: Updated crossystem to accomodate Android
Previously crossystem assumed that mosys was located
in /usr/sbin.  In Android mosys is currently located
in /system/bin.  Using fixed paths as opposed to
'which' to prevent attacks where attacker could insert
mosys in PATH.

BUG=none
BRANCH=none
TEST=ran crossystem, crossystem fw_try_count/
fw_try_next, crossystem fw_try_count/fw_try_next=x
on link and smaug.

Change-Id: I9604f008d457147188dc852c173d5a184163b339
Signed-off-by: Shelley Chen <shchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/292314
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-08-20 23:26:59 +00:00
Furquan Shaikh
8804be8cbe VbNvStorage: Add flags for misc settings
1. Change offset 8 to hold all misc settings (fastboot, boot_on_ac
detect) instead of only fastboot settings.
2. Add flag to hold state of boot_on_ac_detect (If set to 1, AP should
start booting as soon as AC is connected in off-state).

BUG=chrome-os-partner:41680
BRANCH=None
TEST=Compiles successfully. make runtests successful.

Change-Id: I64b3fc69bd52cbcaf5899c953ccafa2e81b5b8a5
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/289900
Trybot-Ready: Furquan Shaikh <furquan@chromium.org>
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Furquan Shaikh <furquan@chromium.org>
2015-08-01 02:51:38 +00:00
Duncan Laurie
a0206634ba crossystem: Add Skylake PCH GPIO controller ID
Add the GPIO controller ID that is used in the Skylake PCH
so it can properly export and use GPIOs that are exported
in VBNV for write protect.

BUG=chrome-os-partner:42560
BRANCH=none
TEST=verify crossystem output with and without WP enabled

Change-Id: Ic85c202bd0ca15c154c10481926ef18bafe3fac5
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/286827
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-07-21 06:07:18 +00:00
Duncan Laurie
2376954429 crossystem: Add skylake platform IDs
Add the skylake-u and skylake-y vendor/device IDs so it can be
reported by crossystem.

BUG=chrome-os-partner:42560
BRANCH=none
TEST=run "crossystem platform_family" on glados

Change-Id: I5f9b92d404166e56d77cf8b0cd627a3a0b63bedf
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/286921
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-07-21 04:50:29 +00:00
John Zhao
5f16cceb3e crossytem:Fix the write protect line gpio value
For crossystem to work correctly on Strago/Cyan,
add Braswell string and correct GPIO offset
calculations.
In Braswell, write protect line is MF_ISH_GPIO_4
as encoded as 0x10016 where the GPEAST offset
(COMMUNITY_OFFSET_GPEAT) is 0x10000

BUG=chrome-os-partner:40835
BRANCH=None
TEST=test_that -b <strago/cyan> <IP> platform_Crossystem

Change-Id: I365f3d6ca9f3ac7ef50abb9b2ba13f184d39c100
Signed-off-by: John Zhao <john.zhao@intel.com>
Signed-off-by: Arindam Roy <arindam.roy@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/274841
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Commit-Queue: Bernie Thompson <bhthompson@chromium.org>
2015-07-14 03:30:32 +00:00
David Hendricks
fbf631c845 crossystem: Add check for "mkbp" back
We may have been over-zealous earlier when trying to eliminate
references to mkbp. Since crossystem runs on all ChromeOS devices,
this re-adds "mkbp" back to mitigate the risk of encountering
problems on systems running newer versions of ChromeOS but with
older firmware.

BUG=chrome-os-partner:21097
BRANCH=none
TEST=Compiled for veyron_brain

Change-Id: Ia0086687fbc3a1195b062367ccb6ee5c41acd026
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/282602
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
2015-06-30 10:47:49 +00:00
David Hendricks
dc600e8b12 crossystem: Check for "cros-ec" instead of "mkbp" for *NvStorage
This changes the string we look for in the devicetree on ARM
platforms to look for "cros-ec" (DT uses dashes instead of
underscores) instead of "mkbp".

BUG=chrome-os-partner:21097
CQ-DEPEND=CL:273347
BRANCH=none
TEST=with depthcharge patch applied, ran crossystem on newly
booted system and saw VBNV-related variables turn out the same.

Signed-off-by: David Hendricks <dhendrix@chromium.org>
Change-Id: Iac43f5381327eb878a8d0db606b78bb7bdce816f
Reviewed-on: https://chromium-review.googlesource.com/273391
Commit-Queue: Stefan Reinauer <reinauer@chromium.org>
Tested-by: Stefan Reinauer <reinauer@chromium.org>
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
2015-06-25 02:11:47 +00:00
Furquan Shaikh
c180460feb fastboot: Add fastboot related flags to nvstorage
Use unused offset 8 for fastboot related flags.

BUG=chrome-os-partner:40196
BRANCH=None
TEST=Compiles successfully.

Change-Id: I6df0985924ba80cdcb68bb6b7658bf962f01287f
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/273180
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Furquan Shaikh <furquan@chromium.org>
Trybot-Ready: Furquan Shaikh <furquan@chromium.org>
2015-05-29 11:29:20 +00:00