Commit Graph

57 Commits

Author SHA1 Message Date
Joseph Chen c01d448924 sysmem: simplify the memblk name
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: Icfe908ade21d1d8f568db796298f67ba9f013da6
2020-02-28 11:22:04 +08:00
Joseph Chen 27e62cd7db lib: avb: implement get_preloaded_partition callback
It works only when verification error is allowed, it avoids
AVB workflow to load the full partition which wastes time.

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: Icbcd48b7bf97d826663523099c944e269f17b709
2019-12-20 12:39:41 +08:00
Joseph Chen eb89f0a81d lib: avb: add partition slot append interface
Dump current slot information is helpful.

Change-Id: I872c29b9a67860703951a4e88e9549be17b94eed
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-11-04 15:43:46 +08:00
Jason Zhu 69fdc5969f lib: avb: update and modify the avb library
The commit point is updated to google external/avb/
which commit point is 868db2a514bbb02e166fb55b1592b27de8c9680c.

Change-Id: I10f7c0ac356a7666b518b62e59ccb62277668578
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-09-20 08:50:37 +08:00
Jason Zhu c2bb0fd141 lib: avb: print the permanent attribute certificate is exist or not
Change-Id: I10775dd06a6fb1bfdddcfda37fe2e1178c3fde21
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-09-18 10:34:40 +08:00
Jason Zhu 3120d9d50e avb: do not use lastboot if enable CONFIG_ANDROID_AVB
The avb process have verify next level firmware to ensure its
availability. So there is no need to support lastboot in avb
process.

Change-Id: I1623a2bd93c54802ce0067cad7061ade6cc56313
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-07-09 16:38:02 +08:00
Jason Zhu 63a580aed3 lib: avb: the rsa_key.c is used when enable CONFIG_ROCKCHIP_CRYPTO_V1
Change-Id: If266df70d0969d5a3556e505f39b853cf818a338
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-07-03 09:34:10 +08:00
Jason Zhu 4a7c178034 lib: avb: change the hardware rsa verified interface
Change-Id: Id42cf3a829a35514b75f3c5990ce7e00b94f712e
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-06-24 18:31:36 +08:00
Joseph Chen 89151b4aad lib: avb: use sysmem alloc to load image
Using malloc buffer to load image makes CONFIG_SYS_MALLOC_LEN must be
large enough, sysmem alloc is a better way.

Change-Id: I24e2b86c53b8d3307c0d155fc37cb499c321e1c6
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-05-22 15:30:20 +08:00
Jason Zhu 4f2523c3a0 lib: avb: load full partition if allow verification error
Change-Id: I506676512a46ec09d6c617f555f735a24fc4a594
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-04-29 11:08:08 +08:00
Jason Zhu 813227ad54 lib: avb: add init ab metadata interface
Change-Id: Ifad6c8ca70568c2dc8eea0a4ead23e3e7a2a0e74
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-04-29 11:05:35 +08:00
Joseph Chen ee561e345b lib: avb: AVB_VBMETA_PUBLIC_KEY_VALIDATE select CONSOLE_DISABLE_CTRLC
Clean coding style by the way.

Change-Id: Ib614175e9ea7ceebc49030235b66d82adc57d3a0
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-03-20 15:08:14 +08:00
Jason Zhu 74b485fb2b fastboot: delete write perm-attr hash if use pre-loader pub_key
Since we use the pre-loader public key to verify permanent attribute, then
we do not need to write permanent attribute hash to otp & efuse.

Change-Id: Ic5e19fed2fc9405ab5bc7504dd930fd5f02d847c
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-03-08 18:12:14 +08:00
Jason Zhu 65f0143b26 lib: avb: verify the perm attr by root public key
Change-Id: I7e06152a21325ffcd785223952fe8ffaff4d5f08
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-03-08 15:32:09 +08:00
Jason Zhu 1f670f7cc9 lib: avb: get public key by atags
Change-Id: I0d77229585263e81e8be4f5c67a02080c07b0e55
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-03-08 15:32:09 +08:00
Jason Zhu 9b83ce70a9 lib: avb: add get&set perm-attr cer
Change-Id: I89d3a30f43659ae8c9d107ede5db1590b022440d
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-03-08 15:32:09 +08:00
Jason Zhu 7cca3dd4d7 lib: avb: support last boot
Change-Id: I803e3deda068be34061a302c27009db5e444f290
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-03-06 17:16:13 +08:00
Jason Zhu 4454e90b43 lib: avb: change the output memssage I/O
Since the stderr is not used in uboot, use printf to print the
message.

Change-Id: Ib522609e783acf8f407e2f9fb3805b553c543cba
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-03-06 17:16:13 +08:00
Jason Zhu ee9d343315 lib: avb: fix fail to read PIK minimum
Do not update the PIK version if it is equal to the value in the storage,
otherwise the error may occur in power failure test.

Change-Id: Ia478d9b404de3982b4de5b185e15d181b37f5fd9
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-01-16 17:59:46 +08:00
Joseph Chen b2a1587371 lib: avb: add more help info for AVB_VBMETA_PUBLIC_KEY_VALIDATE
Change-Id: I2c63850244983144a6b5ac8303f1debc7a37cb2a
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-03 09:53:29 +08:00
Joseph Chen caed6b4f82 rockchip: make avb boot flow uninterruptable
- only allow "boot_android" as bootcmd;
- enter rockusb or fastboot when boot failed;
- don't allow ctrl+c to enter hush;

Change-Id: I7a67f4b738ed78370f19fe2c8c920a5abc104b4b
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-12-12 11:00:47 +08:00
Joseph Chen a349065b9f avb: Kconfig: add config AVB_VBMETA_PUBLIC_KEY_VALIDATE
Change-Id: I2f9c74a8427874066e1bb7ac7b774a0fb3befba9
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-12-12 11:00:47 +08:00
Jason Zhu 7c1937d6d1 lib: avb: change judgement value when read from rpmb
If the item is not existent, trust will return TEE_ERROR_GENERIC
TEE_ERROR_NO_DATA and TEE_ERROR_ITEM_NOT_FOUND. We initialize
the item when return these value.

TEST: fastboot getvar at-vboot-state

ERROR: avb-perm-attr-set=0
avb-locked=
avb-unlock-disabled=

Change-Id: Ie1b4e1ce7d1dc419a0af11e5701b0130f2f7f553
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-08-17 11:41:20 +08:00
Jason Zhu 615e0cde57 lib: avb: fix bug HANG in fastboot getvar at-vboot-state
Bug: Run 'fastboot getvar at-vboot-state', then HANG
in the fastboot without any message.

Cause: The fastboot can not decide the vboot size when
the return information size of vboot state is larger
than the VBOOT_STATE_SIZE. This makes the device will not
response to console.

Solution: 1. Enlarge VBOOT_STATE_SIZE. The max size of
vboot state may be 862, so define VBOOT_STATE_SIZE
to 1000.
2. Use snprintf to get the info.

Change-Id: I2d0fda76ca9034c596993ab27a02cbf2fa550977
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-08-17 11:41:20 +08:00
Jason Zhu 8d0db1d983 lib: avb: implement the function get_random()
Use the function get_timer to get the random
seed. Then the seed is used by function srand
to initialize the random data.

Change-Id: Iaae6a17d22b8e85fb4d4b6c6247cd11003b64eea
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-06-14 11:04:46 +08:00
Jason Zhu ab608f806e lib: avb: update avb source code
according to google lib avb
commit id: 44e07124afb1f46af0d745d83481f49c482900b1

Change-Id: Ie59a7265699e3e6b1673bb64da6d1c7a1e7b6201
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-06-13 10:50:36 +08:00
Jason Zhu 57c7f8fe0d lib: avb: support generate unlock challenge
Change-Id: Ia21746ec2bc729fd92ca7ea7a3320dfcbd4dd238
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-06-13 10:50:36 +08:00
Jason Zhu 83ab7b4937 lib: avb: rk: add authenticated unlock interface
Change-Id: Ib2aa1ac07d25f14aa08fc759ec99b6ba64d6abef
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-06-13 10:50:36 +08:00
Jason Zhu c3230cf0df lib: avb: add bootloader-min-versions
The bootloader include uboot and trust. The uboot slot index
number is 0. The trust slot number index is 1.

Change-Id: Ia62edbf60486fa4128756458c6312f682a83d0f7
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-03-22 10:57:04 +08:00
Jason Zhu df50318e9d lib: avb: add slot number to avb-min-versions
Acording to google, the avb-min-versions includes the slot number
rather than the image rollback-index stored in the image.

PIK/PSK: use AVB_ATX_PSK_VERSION_LOCATION and AVB_ATX_PIK_VERSION_LOCATION
as slot number.

Change-Id: I06b8d107e27f1e0f136b5e964c1287bc13f80b7c
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-03-22 10:57:04 +08:00
Jason Zhu 82e713e13f lib: avb: support set_key_version
the lib avb use this function to set key version

Change-Id: Id0903b3326a0d6a0eadebd1ce23a19f92102908c
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-03-07 16:45:39 +08:00
Jason Zhu da980a5200 lib: avb: initialize temp_flag before next used
Change-Id: Icbc570fdb1cd1f8ff30309f5776421ee6c4a086b
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-03-05 20:41:36 +08:00
Jason Zhu 90ed034fda lib: avb: change the return value if the item is not found
Change-Id: Ie6d29a59323789c594b4c6e9167c3bbe58e25e9f
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-03-05 20:39:32 +08:00
Jason Zhu 76c40fa69f lib: avb: fix compile error in arm64
Change-Id: I7be9c7bab1721500c70cacb1774b579d2939436a
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-03-05 11:35:03 +08:00
Jason Zhu 99ff1ad0c6 lib: avb: fix compile warning
Change-Id: I0cdddc0da44a839371fd8b6d6402053e505976fd
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-02-10 10:48:41 +08:00
Jason Zhu 187a5bc522 lib: avb: declare some functions externally
1. extern load_metadata
2. extern save_metadata_if_changed

Change-Id: I3afe604c39a5f7cf31a0a28d7cc939da51295c10
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-02-10 10:48:30 +08:00
Jason Zhu 459bc93392 lib: avb: get the dev_desc by function rockchip_get_bootdev
Change-Id: I62211b54b0efc11e232d9473a9f566c9fa82b3d8
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-02-10 10:48:21 +08:00
Jason Zhu 37a7bc39c0 lib: avb: update and modify the avb library
The commit point is updated to google external/avb/
which commit point is cf8c56208d2d9643804a7f123b196c7ebc9af276.

Change-Id: I5a10a8a45d3e9e2c9d20d9b3d44946073c9a49ff
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-02-10 10:41:04 +08:00
Cody Xie 95a5167379 libavb: Fix compile warning.
Change-Id: I6a36f02348e61c166334221edc157ee8a261253a
Signed-off-by: Cody Xie <cody.xie@rock-chips.com>
(cherry picked from commit a0e0ea07af830fdf873fb874a7e76264597bca3b)
2017-11-22 10:43:28 +08:00
Jason Zhu ceecd5fea6 lib: avb: support the atx and public_key verify
1.support the permanent attribute verify
2.support the PRK, PIK, PSK certificate verify
and then get the psk public_key, compare it with
public_key in vbmeta.

If the function is required, please open the macro
AVB_VBMETA_PUBLIC_KEY_VALIDATE.

Change-Id: Ifeab776c76f97fadd980671481ce27d203516673
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2017-11-20 10:29:57 +08:00
Jason Zhu fd717dcefe lib: avb: support write efuse
Write the permanent attributes hash to efuse.

Change-Id: Id11586a66f055e7eb1a66997814f351509d49b21
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2017-11-20 10:29:57 +08:00
Jason Zhu e291f58fb4 lib: avb: modify load boot partition size
Load the boot image real size other than the
boot partition size. If not, the uboot can not
malloc a big buffer for the all boot partition.

Change-Id: Ifc8d7cc1f214b94f6018c68cb03e8e9ce89781de
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2017-11-20 10:26:13 +08:00
Jason Zhu 52b8c717cf lib: avb: close optee client
Change-Id: Iee7c991f7c06acbb064e016e11338cbf846be20d
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2017-11-14 10:55:55 +08:00
Jason Zhu fe83bbf40d lib: avb: add reed/write vbootkey hash
The android things require the soc-v key hash to be flashed
using the fastboot. So these function can be used in fastboot
to flash the key hash.

Change-Id: I6e00f2e1e371793b6f0868356ac0a51090adfe5e
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2017-11-14 10:55:55 +08:00
Jason Zhu f74d184a88 lib: avb: add a permanent attribute flag
Add a flag to indicate the permanent attributes
have been written or not.

Change-Id: Id0b22158772bdf18466205df5f08cb0ddb820fbf
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2017-11-14 10:55:55 +08:00
Jason Zhu 5b09015999 lib: avb: change the prefix of some functions to make them coincident
Change-Id: Id876e6e49fb614e43d9f15cd9d24cee29aead223
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2017-11-14 10:55:55 +08:00
Hisping Lin ae8ec5e139 lib: optee_client: change file name
change OpteeClientTest.c to OpteeClientInterface.c

Change-Id: I68b32a2a4757af655bd4eaa723067f024ff112ef
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
2017-11-14 10:55:53 +08:00
Jason Zhu e7e0443e3e avb: modify the function read_from_partition and write_to_partition
There is no need to malloc a space if offset
and num_bytes is multiple of 512 in function
read_from_partition.

The blk_dwrite in write_to_partition do not
return 1 if execute success. So do not need
to judge the return value.

Change-Id: Icd5681815640e86166d05ab3fc74f95d669621c7
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2017-11-14 10:55:53 +08:00
Jason Zhu 5170bcddec avb: provide read/write vboot state function for fastboot
Change-Id: I197868d00a24719ce504a25fb81dc1577d2a214e
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2017-11-14 10:55:52 +08:00
Jason Zhu 023e4d5516 avb: provide read-write flash_lock_state functions for fastboot
Change-Id: Id6135c58416b0b914d2de8b5d911bf9eb02c5c60
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2017-11-14 10:55:52 +08:00