History log of /external/vboot_reference/cgpt/cgpt_common.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
05987b159acb9737707b9ef92b818ac434ef8c3d 06-Feb-2015 David Riley <davidriley@chromium.org> Changes to compile signing tools on darwin

The following works from a Mac with these changes:
make Q= ARCH=arm HAVE_MACOS=1 `pwd`/build/futility/futility

Only vbutil_keyblock and vbutil_kernel have been exercised.

BUG=none
TEST='make Q= ARCH=arm HAVE_MACOS=1 `pwd`/build/futility/futility'
BRANCH=none

Signed-off-by: David Riley <davidriley@chromium.org>

Change-Id: Ie69cfee0c650d4ff96be6322083a2fea1543ee39
Reviewed-on: https://chromium-review.googlesource.com/246773
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: David Riley <davidriley@chromium.org>
Commit-Queue: David Riley <davidriley@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
3200401242aec1521e7c4a8b1906366fcabfb1a2 12-Dec-2014 Nam T. Nguyen <namnguyen@chromium.org> cgpt: Support non-standard (smaller) entries table

The standard says that entries table must be at least 16384 bytes. On
some of our devices, the NOR section is only 8 KiB and used to store
both primary and secondary tables. On this device, we can only store 24
entries.

Therefore, this CL adds support for non-standard entry table. It adjusts
the MIN_NUMBER_OF_ENTRIES to 16, and replaces GPT_ENTRIES_SECTORS with
CalculateEntriesSectors.

BUG=chromium:441812
BRANCH=none
TEST=unittest

Change-Id: I6b85b35ce5612c7abb22142f8252bd0d45b676c5
Reviewed-on: https://chromium-review.googlesource.com/234996
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Nam Nguyen <namnguyen@chromium.org>
Tested-by: Nam Nguyen <namnguyen@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
b3d38f5c620da89662deb1a08971c5025d6c1132 09-Dec-2014 Dan Ehrenberg <dehrenberg@chromium.org> vboot: GPT interface cleanup

- Rename drive_sectors to streaming_drive_sectors, to contrast with
gpt_drive_sectors
- Replace stored_on_device field with flags field for future
extensibility

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

Change-Id: I785a3b735b8eb96f647a334659329db3ee43eb80
Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/234283
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
8577b5360ca4c9514d9091ed9aded2bb3193f1f0 25-Nov-2014 Nam T. Nguyen <namnguyen@chromium.org> vboot: Remove FTS code

flash_ts driver (from Android) was pulled to support Sonic. But now we
go a different route, this CL is to drop the FTS code.

BUG=chromium:436597
BRANCH=none
TEST=unittest

Change-Id: I86d6273f9f5f642b504ccb6a76e005cda12d0e78
Reviewed-on: https://chromium-review.googlesource.com/231896
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Nam Nguyen <namnguyen@chromium.org>
Tested-by: Nam Nguyen <namnguyen@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
ab899591808dd3e5f955ab7693b54a83389cd35f 14-Nov-2014 Nam T. Nguyen <namnguyen@chromium.org> vboot: cgpt: Treat drive_path as the GPT storage

Previously, "cgpt" called out to "flashrom" directly to read and write
NOR area. This CL removes that dependency and always treats "drive_path"
as the storage of GPT structs. This makes it consistent that whatever
device that cgpt reads from or writes to is always the device that
stores GPT structs. We only need to pass in the size of the drive that
contains the partitions, but we do not need to access to that drive.

More information is in the bug.

BUG=chromium:432611
BRANCH=none
TEST=unittest
CQ-DEPEND=CL:228942

Change-Id: Id0139adf70463cec4f2924de8b9a4725dbec822b
Reviewed-on: https://chromium-review.googlesource.com/229736
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Nam Nguyen <namnguyen@chromium.org>
Tested-by: Nam Nguyen <namnguyen@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
a524a3a51591618c1395cb9e1238ee72b3f5e767 07-Nov-2014 Dan Ehrenberg <dehrenberg@chromium.org> vboot: cgpt: fix my_lba of the secondary GPT

Previously, my_lba of the secondary GPT was recorded as if that
GPT was written at the end of the device. This patch tweaks
my_lba to report where it is in the random-access GPT address space,
namely at the end of that space.

TEST=Compiled it into the firmware and observed the firmware to update
the my_lba field of the secondary GPT.
BRANCH=none
BUG=chromium:425677

Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org>

Change-Id: I88791fb2cff1086351ca8a3adeef675c4a88cc9a
Reviewed-on: https://chromium-review.googlesource.com/228942
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Daniel Ehrenberg <dehrenberg@chromium.org>
Tested-by: Daniel Ehrenberg <dehrenberg@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
6ee52d9a929d00e871e7316240b54f381146fbc6 24-Oct-2014 Nam T. Nguyen <namnguyen@chromium.org> vboot: cgpt: Support writing GPT structs to NOR flash

This CL allows the GPT headers and partition entry arrays to be stored
in a NOR flash device. Instead of treating both the NOR and NAND devices
as one (in a sandwich way), this CL writes and reads the GPT structs
independently of the actual device that houses the partitions.
Therefore, the first usable LBA of the partitions will be at 0, and the
last usable LBA is at the end of the NAND.

+------------------------+
| NOR houses GPT structs |
+------------------------+
|
0 | Index into
v v
+------------------------+
| NAND houses partitions |
+------------------------+

Note that the "my_lba", "alternate_lba", "entries_lba" in the GPT headers
are no longer meaningful.

Consumers of cgptlib will have to set "stored_on_device" to either
GPT_STORED_ON_DEVICE or GPT_STORED_OFF_DEVICE, and "gpt_drive_sectors"
to the number of 512-byte sectors available to store GPT structs.

The NOR read and write operations are done by "flashrom".

BUG=chromium:425677
BRANCH=none
TEST=unittest
TEST=build with DEBUG, cgpt create/add/show on a stumpy-moblab

Change-Id: I083b3c94da3b0bb3da1a7b10c6969774080a2afd
Reviewed-on: https://chromium-review.googlesource.com/226800
Reviewed-by: Nam Nguyen <namnguyen@chromium.org>
Commit-Queue: Nam Nguyen <namnguyen@chromium.org>
Tested-by: Nam Nguyen <namnguyen@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
d92856ddfa4f58efbaf17427eda8da5dcdbdc8e2 17-Oct-2014 Nam T. Nguyen <namnguyen@chromium.org> cgpt: Validate GPT headers before loading them

This CL validates the GPT headers before continue loading its fields.

BRANCH=none
BUG=chromium:422469
TEST=unittest
TEST=cpgt show on a random file. There should be some warnings.
TEST=boot from SD/USB on a device. cgpt show that boot device. It should
not fail.

Change-Id: I1e5e986cc46620643ec8ec6914fa696a3d04d23a
Reviewed-on: https://chromium-review.googlesource.com/223800
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Nam Nguyen <namnguyen@chromium.org>
Tested-by: Nam Nguyen <namnguyen@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
88458d9b5281aca162821a369707781ac9abb44e 28-Aug-2014 Nam T. Nguyen <namnguyen@chromium.org> vboot_reference: Rename *_SECTOR to *_SECTORS

This CL renames GPT_PMBR_SECTOR to GPT_PMBR_SECTORS and GPT_HEADER_SECTOR to
GPT_HEADER_SECTORS to better indicate that these are constants for sizes, not
location.

BRANCH=None
BUG=None
TEST=unittest

Change-Id: I26ed6d45d77dcb1eb714135edbb9e4124b54e953
Reviewed-on: https://chromium-review.googlesource.com/214830
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Nam Nguyen <namnguyen@chromium.org>
Commit-Queue: Nam Nguyen <namnguyen@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
a2d72f70c18905aba25eb0971f6f601dd1fa5a60 23-Aug-2014 Nam T. Nguyen <namnguyen@chromium.org> vboot: cgpt: Refer to partition entries by entries_lba.

This CL accesses the partition entry array through its header's
entries_lba value.

Previously, we assume the primary entry array lies on third sector, and
the secondary array lies (1 + 32) sectors from disk end. This assumption
was fine, even Wikipedia assumed the same.

But in order for us to support writing boot code to the third sector (as
required by some Freescale board), the primary entry array must be moved
to another location. Therefore, we must use "entries_lba" to locate the
arrays from now on.

BRANCH=none
BUG=chromium:406432
TEST=unittest
TEST=`cgpt create -p` and then `cgpt show`. Make sure the table
header and entries are properly moved.

Change-Id: Ia9008b0bb204f290b1f6240df562ce7d3a9bbff2
Reviewed-on: https://chromium-review.googlesource.com/213861
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Nam Nguyen <namnguyen@chromium.org>
Tested-by: Nam Nguyen <namnguyen@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
18e03706df6ab4256a89f4e578ecf0f165641c8a 24-Jun-2014 Bill Richardson <wfrichar@chromium.org> Clean up exported Mtd* functions

A lot of functions were added some time ago, nominally to support keeping
the firmware in an MTD device that wasn't formatted with the GPT headers.
That work was never completed, so these functions aren't used anywhere.

We may want to resurrect this work at some future point. Until then, this CL
just moves some of the functions into an "unused" file.

BUG=chromium:231567
BRANCH=ToT
TEST=manual

All tests pass, all firmware and external repos build.

Change-Id: I420dd52d1cea0418cedf2f8e834c61145915f20c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/207037
Reviewed-by: Randall Spangler <rspangler@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
782990277ac7d6730db4c43c2b5632de93396921 20-Jun-2014 Bill Richardson <wfrichar@chromium.org> Split libvboot_host.a into external and local libraries.

We've been creating and linking against a library called "libvboot_host.a"
for two different reasons. The main purpose is to build the vboot_reference
tools found in the utility/ directory. But there are some external userspace
programs that would also like to use some functions in this library.

This change establishes libvboot_host.a as the library for use by external
userspace programs only, and creates a new libvboot_util.a library that's
only used inside this source tree to build the vboot utilities.

BUG=chromium:231567
BRANCH=ToT
TEST=manual

Build and run the local tests:

make runalltests
make clean

Build Link firmware and all the utilities:

emerge-link chromeos-base/vboot_reference \
sys-boot/depthcharge \
sys-boot/coreboot \
chromeos-base/chromeos-ec \
chromeos-base/chromeos-firmware-link \
chromeos-base/chromeos-cryptohome \
chromeos-base/update_engine \
chromeos-base/chromeos-installer \
chromeos-base/chromeos-login \
chromeos-base/verity

Build Lumpy utilities, which include the 32-bit cros_installer:

emerge-lumpy chromeos-base/vboot_reference \
chromeos-base/chromeos-login \
chromeos-base/verity \
chromeos-base/update_engine \
chromeos-base/chromeos-installer \
chromeos-base/chromeos-cryptohome

Change-Id: Ie81ff1f74a6356cb8fab7d98471139d7758c4f19
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/207016
Reviewed-by: Randall Spangler <rspangler@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
4cb5497984642b8cbd592c14cb1912a787b2d4d7 20-Jun-2014 Bill Richardson <wfrichar@chromium.org> Remove cgpt app-specific symbols from libvboot_host.a

Three symbols used by the standalone cgpt executable were being referenced
in the files used to create the external libvboot_host.a needed by non-vboot
userspace applications.

This cleans things up so those symbols don't have to be explictly defined
by other repos just to link with that library.

BUG=chromium:318536
BRANCH=ToT
TEST=manual

No new functionality, just code cleanup. Tested with

make runtests runfutiltests runlongtests

Change-Id: Ibc77fb9800c89d7109ebf38d4d6729f52665722f
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/205667
Reviewed-by: Randall Spangler <rspangler@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
d41000ed64bb144704fcbf2db3db840de30d069d 19-Jul-2013 Albert Chaulk <achaulk@chromium.org> Don't always enable MTD mode unless MTD device is specified

On MTD devices, don't always enable MTD mode - the installer needs to
be able to access both the GPT disk and the MTD disk, so only
enable it if we install to /dev/fts

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

Change-Id: I7688e6bc758ef47cfb9d468c1224ef43b2043d02
Reviewed-on: https://gerrit.chromium.org/gerrit/62662
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Tested-by: Albert Chaulk <achaulk@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
4464354b7805b7d81667d79624275f525b5a8b11 09-Jul-2013 Albert Chaulk <achaulk@chromium.org> MTD: When running on the host (as during install) use the host FTS if possible.

BUG=chromium:252331
TEST='make runtests' still passes
BRANCH=none

Change-Id: I1deb70766b811b070f0f412cb5cfa583250dd687
Reviewed-on: https://gerrit.chromium.org/gerrit/61328
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Reviewed-by: Albert Chaulk <achaulk@chromium.org>
Tested-by: Albert Chaulk <achaulk@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
92f22e7c2a1ca08034ac3ad21b2af60347c1c4fb 02-Apr-2013 Albert Chaulk <achaulk@chromium.org> Bugfixes & MTD create command

Fix some bugs in the cgpt implementation of the flash I/O functions & load
logic, it was validating too much at load time.

Implement the create command for MTD

BUG=chromium:221745
TEST=MTD version of run_cgpt_tests.sh passes
BRANCH=none

Original-Change-Id: I2f52637d82962f4d805aa827c5c37685f10e76ea
Reviewed-on: https://gerrit.chromium.org/gerrit/47172
Tested-by: Albert Chaulk <achaulk@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
(cherry picked from commit 931544744ba410dad267064b87d504b0b4c24772)

Change-Id: If9364155fb2c030645adc6ee6f3fbe5373bcc153
Reviewed-on: https://gerrit.chromium.org/gerrit/49793
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Reviewed-by: Albert Chaulk <achaulk@chromium.org>
Tested-by: Albert Chaulk <achaulk@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
a75071c25295e392a21b8deddccaf2f3f0d0f041 29-Mar-2013 Albert Chaulk <achaulk@chromium.org> Enables MTD mode via command line option.

Enables MTD mode with a command line option of
-N=<write page bytes>,<write pages per erase block>,
<erase block offset to fts partition>,<erase block size of fts partition>

The problem is that we need to know exactly where the fts store partition is
and what the layout of the flash chip is in order to be able to use it
properly. This will vary per-device however, so for flexibility and testing
purposes, this command line option allows specification of arbitrary layouts.

BUG=chromium:221745
BRANCH=none
TEST=verified during development via prints

Original-Change-Id: I88640e777d5ccd4ffd3b39e1f131dc1d362c6b2c
Reviewed-on: https://gerrit.chromium.org/gerrit/46920
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Reviewed-by: Albert Chaulk <achaulk@chromium.org>
Tested-by: Albert Chaulk <achaulk@chromium.org>
(cherry picked from commit 2b768f99d246823f3711bbe4cf50ea9ab4588a06)

Change-Id: I35591d4fbec13c3887beef11fdefc84fc90b8e05
Reviewed-on: https://gerrit.chromium.org/gerrit/49792
Reviewed-by: Albert Chaulk <achaulk@chromium.org>
Tested-by: Albert Chaulk <achaulk@chromium.org>
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
b334e651a597a10d562bc882613f0b482b24e3ca 28-Mar-2013 Albert Chaulk <achaulk@chromium.org> Provide MTD version of common functions

Provide an MTD implementation of several common functions in cgpt_common.c

BUG=chromium:221745
BRANCH=none
TEST=none

Original-Change-Id: Ib3248c283ca31e33a91b9ea0c14b2f72ea7c5850
Reviewed-on: https://gerrit.chromium.org/gerrit/47029
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Tested-by: Albert Chaulk <achaulk@chromium.org>
(cherry picked from commit b0bd7e4cf8dd15cc3c371dac157093c7e7c7a874)

Change-Id: I243c2bf98a88d0019c332b274868459b5f1b8ea1
Reviewed-on: https://gerrit.chromium.org/gerrit/49791
Reviewed-by: Albert Chaulk <achaulk@chromium.org>
Tested-by: Albert Chaulk <achaulk@chromium.org>
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
534723a6519267461855441279b321e6fc1e4e90 20-Mar-2013 Albert Chaulk <achaulk@chromium.org> Integrate the flash key-value store code into cgpt.

Integrates the FTS driver into cgpt. This driver is binary-format compatible
with the linux driver for interoperabiilty. The cgpt changes load & store a
hex-encoded mtd partition table in the FTS; we need some sort of encoding
because FTS only stores NUL-terminated strings.

Currently, the mtd code paths aren't executed in cgpt, only in the tests. It's
also not hooked up to the vboot code yet, we will need to do that eventually.

BUG=chromium:221745
TEST=new unit test added
BRANCH=none

Change-Id: I94eb0389d29aca0beb9d9a644465c7d86161b3c2
Original-Change-Id: I9fe2fa91b666572563426adb8fa9d426f9b60bbf
Reviewed-on: https://gerrit.chromium.org/gerrit/46796
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Reviewed-by: Albert Chaulk <achaulk@chromium.org>
Tested-by: Albert Chaulk <achaulk@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49789
/external/vboot_reference/cgpt/cgpt_common.c
fa6b35c1ffa33833b3250a6515869ccd4cb59121 26-Mar-2013 Albert Chaulk <achaulk@chromium.org> Refactor CgptAdd and CgptPrioitize to remove gpt-specific code

- Refactor cgpt_prioitize.c to completely remove gpt-specific code.
- Refactor cgpt_add.c to isolate gpt-dependence to one helper function
and the backup/restore logic
- Change several common apis to take a struct drive* rather than a GptData*,
this provides a path to cleanly implement mtd versions

BUG=chromium:221745
TEST=no functional changes, existing tests cover this
BRANCH=none

Change-Id: I27ed166aae390aa5dc83062f62939e45122edc76
Original-Change-Id: I1b0a73509efbf22411c4ae5cf044feede0a49a33
Reviewed-on: https://gerrit.chromium.org/gerrit/46548
Tested-by: Albert Chaulk <achaulk@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49788
/external/vboot_reference/cgpt/cgpt_common.c
0c3ba249abb1dc60f5ebabccf84ff13206440b83 29-Mar-2013 Bill Richardson <wfrichar@chromium.org> Massive refactoring of external header files.

This reduces the number of exported header files to the minimum needed by
the existing userspace utilities and firmware implementations.

BUG=chromium:221544
BRANCH=none
TEST=manual, trybots
CQ-DEPEND=CL:47019,CL:47022,CL:47023

sudo FEATURES=test emerge vboot_reference
FEATURES=test emerge-$BOARD \
vboot_reference \
chromeos-cryptohome \
chromeos-installer \
chromeos-u-boot \
peach-u-boot \
depthcharge

Change-Id: I2946cc2dbaf5459a6c5eca92ca57d546498e6d85
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47021
Reviewed-by: Randall Spangler <rspangler@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
3f806a2abf07d7b801852a4a6f3a9080a4b5c427 20-Mar-2013 Bill Richardson <wfrichar@chromium.org> Apply consistent naming scheme for hostlib functions.

The chromeos-installer uses several functions from the vboot_reference
userspace library, but the names of those functions are inconsistent:

IsZero
MapFile
VbGetSystemPropertyString
cgpt_add
cgpt_boot
cgpt_create
cgpt_get_boot_partition_number
cgpt_get_num_non_empty_partitions
cgpt_get_partition_details
cgpt_prioritize
cgpt_set_attributes
find_kernel_config

The Google C++ style guide says types and functions should use CamelCase,
while variables use lower_case_with_underscores.

Kernel style (which vboot_reference tries to be more-or-less compatible
with) uses lower_case_with_underscores for everything, but that really only
has to apply to firmware stuff. For userspace, we can use the Google style.

BUG=chromium:221544
BRANCH=none
TEST=buildbot
CQ-DEPEND=CL:46045

Renaming/cleanup only; no functional changes.

Change-Id: I9c82c9ff8909be88586194c8ffdb435fc771195f
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46044
/external/vboot_reference/cgpt/cgpt_common.c
57cdad33d6f07227f93bbc35f167d60e58b83d8b 16-Jan-2013 Louis Yung-Chieh Lo <yjlou@chromium.org> (modify and resend) Trigger sync right after writing.

This can trigger the sync mechanism earlier so that the kernel has enough
time to schedule a real disk sync before system reboots.

We sent this in CL 41269, however it is reverted because the sync() and
syncfs() make test cases timeout (tons of disk access). So we only sync
file itself in this CL and leave the whoe system sync outside cgpt.

BUG=chromium-os:35992
TEST=make && make runtests ; and trybot
BRANCH=none

Change-Id: I9c6b602220131f1f011e7865788a122d4c379e73
Reviewed-on: https://gerrit.chromium.org/gerrit/41345
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Commit-Queue: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
43949662d8f4738afa3c8b641e7a2d198a658138 15-Jan-2013 Bill Richardson <wfrichar@chromium.org> Revert "Trigger sync right after writing."

This reverts commit f3613b60c7374dfcf54c922d46c7da8feeb22000.

That commit attempts to solve a disk-syncing problem by forcing numerous
sync() calls inside cgpt. However, it's too much of a sledgehammer approach.

Some subset of buildbots now run a short test suite when compiling
vboot_reference. On my z620, commit f3613b60c737 increases the time to run
"make runcgpttests" from 1.6 seconds to over eight minutes.

We need a different solution to this problem.

BUG=chromium-os:35992
TEST=manual
BRANCH=none

To test:

cd vboot_reference
make && make runtests

Change-Id: I0489906103dbc93edf201570bd9158621c651d54
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/41306
Reviewed-by: Randall Spangler <rspangler@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
f3613b60c7374dfcf54c922d46c7da8feeb22000 15-Jan-2013 Louis Yung-Chieh Lo <yjlou@chromium.org> Trigger sync right after writing.

This can trigger the sync mechanism earlier so that the kernel has enough
time to schedule a real disk sync before system reboots.

BUG=chromium-os:35992
TEST=compile only
BRANCH=none

Change-Id: I505fdf45d95a52c9eca7687ecd6fb9f6be8cc5f1
Reviewed-on: https://gerrit.chromium.org/gerrit/41269
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Queue: Yung-Chieh Lo <yjlou@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
b7b865cfee68190babd971ab9a897bdabbab075f 24-Aug-2012 Stefan Reinauer <reinauer@chromium.org> Support alternative GPT header signature

In order to dual boot Windows and ChromeOS, Windows must
not find a GPT partition table on the disk. So change
ChromeOS to cope with an alternative signature "CHROMEOS"
instead of the standard "EFI PART"

BUG=chrome-os-partner:6108
TEST=rebuild chromeos, install it,
run cgpt legacy /dev/sda
dd if=/dev/sda of=/tmp/x bs=1k
hexdump -C /tmp/X
see the string CHROMEOS
BRANCH=link
Signed-off-by: Stefan Reinauer <reinauer@chromium.org>

Change-Id: Ia88eff33b9880bd73a78c1b8e026c1f8298c4557
Reviewed-on: https://gerrit.chromium.org/gerrit/31264
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Stefan Reinauer <reinauer@chromium.org>
Tested-by: Stefan Reinauer <reinauer@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
23429d3d782f7506fb4747356974294cce08ac47 30-Apr-2012 Bill Richardson <wfrichar@chromium.org> Let cgpt open devices in read-only mode when possible.

BUG=chromium-os:12430
TEST=manual

Running "make; make runtests" in src/platform/vboot_refererence will test
this change. Tests for use on a Chromebook are described in the bug report,
but will require a USB or SD card that has a physical write-protect switch.

Change-Id: I16a67bad3b59bec0981f4064f51fb1a29da65a90
Reviewed-on: https://gerrit.chromium.org/gerrit/21474
Tested-by: Bill Richardson <wfrichar@chromium.org>
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Richard Barnette <jrbarnette@chromium.org>
Reviewed-by: Che-Liang Chiou <clchiou@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
93cf15e9a1c29962d6f08be6102d2ea7876d969f 08-Jul-2011 Gabe Black <gabeblack@chromium.org> Introduce GUID type for Chrome OS read/write firmware.

This change teaches cgpt a new GUID type to be used for the Chrome OS
read/write firmware. The GUID is CAB6E88E-ABF3-4102-A07A-D4BB9BE3C1D3.

BUG=chrome-os-partner:4843
TEST=Built and installed on my host, used a separate change to repurpose
partition 11 for the R/W firmware using cgpt and the "firmware" type, inspected
the image using cgpt. Built and installed an image and used cgpt on the device
to inspect it's GPT.

Signed-off-by: Gabe Black <gabeblack@google.com>

Change-Id: I3b2801b2e1f71b3275bbddbc45fb63bde5bce5a7
Reviewed-on: http://gerrit.chromium.org/gerrit/3763
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Gabe Black <gabeblack@chromium.org>
/external/vboot_reference/cgpt/cgpt_common.c
3430b32667937a75c7a3afc83f8f7a601a8187f7 29-Nov-2010 Bill Richardson <wfrichar@chromium.org> Add 'prioritize' command to cgpt tool.

This lets us reorder the priority of all the kernel partitions with a single
command, instead of a bunch of complicated and error-prone shell script
logic.

Change-Id: I21d39763ec5a748488d5319a987bcfe7c34ce4d0

BUG=chromium-os:9167
TEST=manual

In the chroot, do this:

cd ~/trunk/src/platform/vboot_reference
make
make runtests
make clean

Everything should pass.

Review URL: http://codereview.chromium.org/5352005
/external/vboot_reference/cgpt/cgpt_common.c
500b3c2369e1a8370041ea276bc40b81c6e7a713 22-Nov-2010 Louis Yung-Chieh Lo <yjlou@chromium.org> Fix for un-initialized code point variable.

The original CL is http://codereview.chromium.org/5025003/, but it was reverted
because the compiler complains code_point variable is not initialized. This CL
just initializes it.

This CL also adds few lines of code to make code more robust.

Change-Id: Ib1329bcaeb4a1bd9abfe9e766b61bd0e52d2c260

BUG=chromium-os:7542
TEST=RUNTESTS=1 emerge-x86-generic vboot_reference
Manually tested the following commands (intentionally mix Chinese and ASCII):
export C=.../cgpt
export D=/tmp/hda

$C add $D -i 1 -l 批P踢T踢T許C夕C餐
$C find $D -l 批P踢T踢T許C夕C餐
$C show $D
$C add $D -i 1 -l abc012
$C add $D -i 1 -l 是否看過坊間常見的許茹芸淚海慶功宴吃蓋飯第四集
$C add $D -i 1 -l 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ # ok and truncated
$C add $D -i 1 -l `printf "\xf4\x91\x81\x81"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xf4\x8f\xbf\xbf"`
$C add $D -i 1 -l `printf "\xf4\x8f\x44\x44"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xf4\x8f\xbf"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xf0\xbf\xbf\xbf"`
$C add $D -i 1 -l `printf "\xf0\xbf\xbf\x44"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xf0\x80\x80\x80"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xf0\x80\x84\x80"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xf0\x80\x90\x80"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xf0\x88\x80\x80"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xed\x80\x80"`
$C add $D -i 1 -l `printf "\xed\xa0\x80"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xe0\xbf\xbf"`
$C add $D -i 1 -l `printf "\xe0\xbf\x44"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xe0\x80\x80"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xe0\x90\x80"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xe0\xbf"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xd0\x80"`
$C add $D -i 1 -l `printf "\xd0\x11"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xd0"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xc0\xaf"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\x80"` # (EXPECT: failed)

Review URL: http://codereview.chromium.org/5104009
/external/vboot_reference/cgpt/cgpt_common.c
e417185ff654ead6b8c1c6eafe5fc67a89a4210d 19-Nov-2010 Chris Sosa <sosa@chromium.org> Revert "The right implementation of CGPT label conversion between UTF8 and UTF16."

This reverts commit 6965cbfed3352754f0ff9a270e3b330223b7154c.

TBR=Change broke tree

Change-Id: I5323799bf0bc2f9a1f2815f0c44fc90ca9a7bd77
/external/vboot_reference/cgpt/cgpt_common.c
6965cbfed3352754f0ff9a270e3b330223b7154c 19-Nov-2010 Louis Yung-Chieh Lo <yjlou@chromium.org> The right implementation of CGPT label conversion between UTF8 and UTF16.

For security quick fix, the original UTF8/UTF16 conversion only supports
ASCII area. This CL extends the library to support multiple code units
conversion between UTF8 and UTF16. The UTF8/UTF16 encoded byte(s) would be
decoded to code point first, then be encoded to UTF16/UTF8 correspondingly.

Bill, please kindly review the UTF8/UTF16 conversion.
Peter, please kindly comment if any security concern.

Thanks.

Change-Id: I99c558ff27556e0b8635ba2b8d9925d042e75cb2

BUG=chromium-os:7542
TEST=RUNTESTS=1 emerge-x86-generic vboot_reference
Manually tested the following commands (intentionally mix Chinese and ASCII):
export C=.../cgpt
export D=/tmp/hda

$C add $D -i 1 -l 批P踢T踢T許C夕C餐
$C find $D -l 批P踢T踢T許C夕C餐
$C show $D
$C add $D -i 1 -l 批P踢T踢T許C夕C餐
$C find $D -l 批P踢T踢T許C夕C餐
$C add $D -i 1 -l abc012
$C add $D -i 1 -l 是否看過坊間常見的許茹芸淚海慶功宴吃蓋飯第四集
$C add $D -i 1 -l 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ # ok and truncated
$C add $D -i 1 -l `printf "\xf4\x91\x81\x81"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xf4\x8f\xbf\xbf"`
$C add $D -i 1 -l `printf "\xf4\x8f\x44\x44"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xf4\x8f\xbf"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xf0\xbf\xbf\xbf"`
$C add $D -i 1 -l `printf "\xf0\xbf\xbf\x44"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xf0\x80\x80\x80"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xf0\x80\x84\x80"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xf0\x80\x90\x80"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xf0\x88\x80\x80"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xed\x80\x80"`
$C add $D -i 1 -l `printf "\xed\xa0\x80"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xe0\xbf\xbf"`
$C add $D -i 1 -l `printf "\xe0\xbf\x44"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xe0\x80\x80"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xe0\x90\x80"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xe0\xbf"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xd0\x80"`
$C add $D -i 1 -l `printf "\xd0\x11"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xd0"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\xc0\xaf"` # (EXPECT: failed)
$C add $D -i 1 -l `printf "\x80"` # (EXPECT: failed)

Review URL: http://codereview.chromium.org/5025003
/external/vboot_reference/cgpt/cgpt_common.c
2b23c021f3137427a8b3f00e7702850be6e1c242 18-Nov-2010 Louis Yung-Chieh Lo <yjlou@chromium.org> Fixing the bug of CGPT when primary entry table is invalid.

http://code.google.com/p/chromium-os/issues/detail?id=9279
This issue disclosed a bug of cgpt. The bug comes from the 'show' command always
reads the primary entry table when '-i partition' is specified. I added an
ANY_VALID constant for GetEntry to automatically select valid entry table.

Also fixed the bugs in cmd_boot.c and cmd_find.c. In cmd_add.c, stop user to
continue if any header/entry table is invalid.

Also fixed the bug that untrusted header size could cause segmentation failure.

Hungte, this is FYI. But welcome to do review.

BUG=chromium-os:9279
TEST=RUNTESTS=1 emerge-x86-generic vboot_reference
Manually tested:
cgpt show /tmp/test -i 1 -b
cgpt show /tmp/test
cgpt add /tmp/test -i 1 -l TEST
cgpt find /tmp/test -l STATE
cgpt boot /tmp/test -i 1

Change-Id: Iaba9c635754096a82b3ec74634af184362d4e264
Change-Id: I6f3e87e3998457676e3388d2a6ed36c0564796d8

Review URL: http://codereview.chromium.org/5115002
/external/vboot_reference/cgpt/cgpt_common.c
c4e92af85ac2bfd90ab82c0b13bb0041595a0aff 12-Oct-2010 Bill Richardson <wfrichar@chromium.org> Address some security concerns in the cgpt tool.

1. Check for potential integer overflow in sector_bytes * sector_count.
2. Added O_NOFOLLOW to open() call - Is this enough?
3. Passing buffer length to GuidToStr(), PMBRToStr().
4. Use unsigned int in GetEntry() to determine stride.
5. Address conversion between UTF16 and UTF8.

Note: The UTF conversion is complex and troublesome, and needs careful
consideration to get right. For now, I've just forced the interpretation of
the partition name to 7-bit ASCII. That's sufficient for the needs of Chrome
OS, and I can file a new issue to handle UTF correctly.

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

Running "make runtests" invokes the tests/run_cgpt_tests.sh script, which checks the behavior and output of the cgpt tool.

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

Change-Id: I5fd29796d8c929527e0cfbc6d5ccbcdc77502c6b
/external/vboot_reference/cgpt/cgpt_common.c
f7a45cc01d7e4056482b2cdc23080bfabbbffc76 21-Jun-2010 vbendeb <vbendeb@chromium.org> Reduce attributes size to comply with msc limitations.

It turned out that shared verified boot library fails to
work properly when compiled by msc in BIOS environment.

The culprit was identified as failing 64 bit logical
operations by preprocessor. It is probably possible to
come up with a certain compile flag set to fix the
operations, but it is not easy to modify and control the BIOS
compilation environment.

The alternative solution is to limit the size of the field
in question to 16 bits (especially since this is the only
part of the attributes field which is supposed to be
altered by firmware.

A union is being introduced in firmware/lib/cgptlib/include/gpt.h:GptEntry to allow
accessing the field both as a 64 bit entity and a top
16 bit field. All places where this field is used are
being modified appropriately.

tests/Makefile is being fixed to allow controlling test run
from the top level directory.

Tested by building everything and running tests.
All tests pass.

Review URL: http://codereview.chromium.org/2799019
/external/vboot_reference/cgpt/cgpt_common.c
f1372d9109d638fbb1a177a89ebaf64e7ee0637e 11-Jun-2010 Bill Richardson <wfrichar@chromium.org> Nearly complete rewrite of cgpt tool.

This fixes a number of bugs, adds a bunch of commands, and essentially makes
cgpt ready to use as a replacement for gpt. Still to do is to add commands
and options that will let it generated intentionally bad partitions, for use
in testing.

Review URL: http://codereview.chromium.org/2719008
/external/vboot_reference/cgpt/cgpt_common.c