Commit Graph

1007 Commits

Author SHA1 Message Date
Jason Zhu 78263d89a3 rsa: support write public hash in spl
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: I4120d0cad1cb24b45c3b281649e1eba520a11ee2
2020-12-10 15:59:22 +08:00
Joseph Chen b6ea0cb4ad lib: rsa-sign: add rockchip rsa key hash
SPL requires key hash to verify and flash it to OTP/EFUSE.

- hash@c:  n, e, c
- hash@np: n, e, np

/ {
    signature {
        key-dev {
            required = "conf";
            algo = "sha256,rsa2048";
            rsa,np = <...>;
            rsa,c = <...>;
            rsa,modulus = <...>;
            rsa,exponent-BN = <...>;
            ...
            key-name-hint = "dev";
            hash@np {
                algo = "sha256";
                value = <0x0934bc4d 0xfbc31ffe 0x9224d6c2 0x1a3aa280 0x881d881e 0xe2006246 0x01b9e724 0x35c03428>;
            };
            hash@c {
                algo = "sha256";
                value = <0x08962385 0x34585e06 0x0b73a496 0x374b148d 0xa2700a75 0x4aae08ad 0xb2a324a3 0x95ee6b52>;
            };
        };
    };
    ...
};

But after processed by scripts/fit.sh, only one of "hash@c" and "hash@np" would be left.

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: Id9454100f9fdb06b30f9a4b2a7bdd180f117cb68
2020-12-10 15:40:26 +08:00
Joseph Chen 5b0bc49177 lib: avb: support crypto sha256/512
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: Ifbcc1940d9b494fc488c0b9e95f88d7c98604f62
2020-12-05 20:07:07 +08:00
Joseph Chen 2c655b73ba lib: sysmem: update help of "sysmem_search" command
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: Ie747d258fa00301c488f5747cf729c242e4d6033
2020-11-12 13:12:09 +00:00
Joseph Chen ae205b953a lib: avb: independent on optee client
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I1bab69baf97b5174024db25278cf30efafd3e34e
2020-11-09 17:20:45 +08:00
Jason Zhu 08f7f19a21 lib: avb: separate the ab from the avb lib
Open CONFIG_AVB_LIBAVB_USER & CONFIG_ANDROID_AB &
CONFIG_AVB_LIBAVB_AB to enable ab.

Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: I1611907b3cb82f72d5e706ed966ee98c7569d230
2020-11-03 18:20:02 +08:00
Joseph Chen 507e69009b lib: rsa-verify: require np/c factor if using hardware decrypt
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I2c5a68e86a04f4c65719521ac9aac62297432beb
2020-10-30 18:13:59 +08:00
Jason Zhu 16a623134f lib: avb: update ops functions
1.read_from_partition: support read vbmeta from the partition tail.
2.validate_public_key_for_partition: support this function

Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: I5372848a9339b10f5b1a66e92f5217a0a3122392
2020-10-26 16:39:25 +08:00
Elon Zhang 7dbcb7a21d lib: optee_client: add README
Add README file to record some important information of optee_client.

Signed-off-by: Elon Zhang <zhangzj@rock-chips.com>
Change-Id: I66788f021d38c4617c87b46b6e3640ed7dd9e22f
2020-08-19 17:51:06 +08:00
Elon Zhang 396e3049bd rochchip: board: only map op-tee share memory as dcache enabled
The cache fixup is for the data coherence when communication
between U-Boot and OP-TEE. And data abort exception appeares on
OP-TEE V1 32bit platform due to unknown reason.
So only the share memory need be mapped as dcache enabled.

Signed-off-by: Elon Zhang <zhangzj@rock-chips.com>
Change-Id: I92b62ef5fbdf47adc0328a14034a5861e8e77fed
2020-08-14 15:39:42 +08:00
Elon Zhang 7a349fdcbd lib: optee_client: add optee initialize flag
Add optee initialize flag to reduce redundant calling.

Signed-off-by: Elon Zhang <zhangzj@rock-chips.com>
Change-Id: Ib3e883c48d5c85c446f3e9e991cd4cfcd1cede90
2020-08-04 14:38:23 +08:00
Hisping Lin 74eb602743 lib: optee_client: update to new optee msg for optee v1 platform
optee v1 smc message is deprecated and update to new optee msg,
api revision smc call is add in init func to check capcibility.

Change-Id: Ia54a1257050b5e3776a00b6b76ca608c939bb401
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
Signed-off-by: Elon Zhang <zhangzj@rock-chips.com>
2020-08-04 14:38:23 +08:00
Joseph Chen 7c3a07ede8 lib: lz4_wrapper: fix data-abort due to odd address access
We don't clearly know why there is odd address, maybe the
compression itself does.

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: Iabf2c09839485a0b12301ea003f945e1de414d83
2020-07-24 18:02:27 +08:00
Joseph Chen f7a20b1263 lib: gunzip: add hw gunzip support
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I52b6d090fdc7d535a4b0804826f5669c068464dc
2020-07-24 18:02:27 +08:00
Philippe Reynes 85289e9d5d UPSTREAM: rsa: add support of padding pss
We add the support of the padding pss for rsa signature.
This new padding is often recommended instead of pkcs-1.5.

Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
(cherry picked from commit 061daa0b61f0fbeb214c566f3adb23da05545320)

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I28e5722504bfd0428cd119b2aaae60682a720648
2020-07-15 10:33:36 +08:00
Philippe Reynes 219050bf6a UPSTREAM: rsa: add a structure for the padding
The rsa signature use a padding algorithm. By default, we use the
padding pkcs-1.5. In order to add some new padding algorithm, we
add a padding framework to manage several padding algorithm.
The choice of the padding is done in the file .its.

Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
(cherry picked from commit 20031567e12bb312bff95b70767f6275e20f0346)

Conflicts:
	common/image-fit.c
	lib/rsa/rsa-sign.c
	lib/rsa/rsa-verify.c

Change-Id: Ie522fec1ea69e6b86ebde0f7dad91a45670da66b
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2020-07-15 10:33:36 +08:00
Philippe Reynes 624f7c0791 UPSTREAM: rsa: use new openssl API to create signature
Previous implementation of the rsa signature was using
the openssl API EVP_Sign*, but the new openssl API
EVP_DigestSign* is more flexible. So we move to this
new API.

Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
(cherry picked from commit 3b5d6979fcb80ffae3b140be6edc04cbde1a0b72)

Conflicts:
	lib/rsa/rsa-sign.c

Change-Id: I6016a13904024a63d6fb8110cef37e57a164eed9
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2020-07-15 10:33:36 +08:00
Joseph Chen 1a768a2938 lib: rsa: checksum: clean up hash calculate
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I9a8d30923c8744e4af9612b0edeaed10410b0b32
2020-07-07 14:36:20 +08:00
Joseph Chen 0fb9327257 lib: rsa: verify: rename hw_crypto_rsa() => rsa_mod_exp_hw()
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I7164a2001f386b18a0e502be4735be45ed9907f1
2020-07-07 14:36:20 +08:00
Hisping Lin df538e29bd lib: optee_client v2: support RKFS version 2
1.use get_rkss_version function to get rkss version,
  if security partition have data with rkss version 1, then
  we choice rkss version 1, if security partition is empty,
  then we choice rkss version 2
2.rkss version 2 support dual backup mechanism,
  security partition total use 1M
3.rkss version 2 R&W 256k data one time

Change-Id: I2f17b22d6a442df84be0d94a808b03465dc6fefe
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
2020-06-24 11:45:46 +08:00
Hisping Lin d079c1a5ed lib: optee_client v1: support RKFS version 2
1.use get_rkss_version function to get rkss version,
  if security partition have data with rkss version 1, then
  we choice rkss version 1, if security partition is empty,
  then we choice rkss version 2
2.rkss version 2 support dual backup mechanism,
  security partition total use 1M
3.rkss version 2 R&W 256k data one time

Change-Id: I4103b6600666dffccf473ec4ed8854776a46da31
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
2020-06-24 11:45:46 +08:00
Hisping Lin 020c79da1e lib: optee_client: communicate with optee os v2 32 bits
Change-Id: Ic352f86e73631b64110b9d0d1742dc6b98e97d59
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
2020-05-28 19:13:38 +08:00
Hisping Lin 4770b276c4 lib: optee_client: free section in write and truncate func
Change-Id: Ifd7b53d4c2d1e08591192aa44f04af2b1ff07e5b
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
2020-05-28 19:13:38 +08:00
Jason Zhu e663d2b596 lib: hang: reset the device if hang in spl
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: Ica9426db31809dc316ef0cad3e4b2c0ff7985632
2020-04-21 20:04:22 +08:00
Joseph Chen e7be2a072c Kconfig: disable CLI for verified-boot
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I09acae3dda1a886629d0f9901b4c95059cdd8b42
2020-04-10 14:17:32 +08:00
Joseph Chen e1aab64013 lib: efi: fix compile error
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I2a1ee3b81eb20038f6723a205a871d43d8cb71a2
2020-04-09 18:26:22 +08:00
Joseph Chen 242e56fad2 lib: rsa: fix compile warning
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I75acadbb4fe6873c7306bd953234c1fb4ef5b0d9
2020-04-01 17:30:41 +08:00
Joseph Chen d46373c14f lib: rsa: generate data to be signed
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I125f61051c9c9604903603ef06cd7f368b48f3d8
2020-03-31 18:20:47 +08:00
Joseph Chen 37526a5172 common: support disable CLI for verified-boot
Not allow any interactive from CLI.

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I207da3f2c54df1a81100c404f045023ac763da73
2020-03-28 18:21:16 +08:00
Joseph Chen 008ec9b4bc lib: rsa: add hardware crypto for FIT image checksum and rsa
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I526dd1b9a2a7e0050786f6006fd166f3dfb3a5c4
2020-03-24 21:00:32 +08:00
Joseph Chen a8f564c371 lib: rsa: workaround fdt64_to_cpu() align issue
It seems fdt64_to_cpu() input param address must be 8-bytes
align, otherwise it brings a data-abort.

No root cause was found, let's workaround it.

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: Ic9f47d657b89b458bbd9ee52f0f931a689aec321
2020-03-13 11:23:53 +08:00
Joseph Chen 3fbeaf462e lib: Makefile: compile rsa/ depends on $(SPL_TPL_)
Fix compile error.

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: Ib6a159cd4fe5fe8387c9abb8369326a4411245b2
2020-03-13 11:23:53 +08:00
Joseph Chen 2fe84ae1c5 bidram: rename "dump_bidram" to "bidram_dump"
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I77601a95daec90b396620ee1f3a3a6e455dcc914
2020-02-28 11:37:13 +08:00
Joseph Chen 68cca28cd2 sysmem: add cmd "sysmem_search" to find available region
If the user can't make sure where the region is available
and safe for use, this command handles it.

Rename commands with prefix: sysmem_xxx.

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I37ea76bf33a3fcb8c16baeecae3980d746775ec7
2020-02-28 11:36:49 +08:00
Joseph Chen 90fca8097f sysmem: fix invisiable region boundary
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I1677891796646cf3e1db3aef836921051386a0e0
2020-02-28 11:22:04 +08:00
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 64c9242ba7 sysmem: add FIT image memory block
The same feature with AVB memory block.

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I1aff5ef703d16852b4bc0a0887b037476464034c
2020-01-16 11:14:13 +08:00
Rob Clark 2f0750eb18 UPSTREAM: efi_loader: refactor boot device and loaded_image handling
Get rid of the hacky fake boot-device and duplicate device-path
constructing (which needs to match what efi_disk and efi_net do).
Instead convert over to use efi_device_path helpers to construct
device-paths, and use that to look up the actual boot device.

Also, extract out a helper to plug things in properly to the
loaded_image.  In a following patch we'll want to re-use this in
efi_load_image() to handle the case of loading an image from a
file_path.

Signed-off-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
(cherry picked from commit 95c5553ea268144056c4bafc318b9e8b5c096a6c)

Change-Id: Iaa6a9865f2cbd15d6537d200bd86662fa4baf5a0
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2020-01-06 11:45:12 +08:00
Rob Clark a0955e7ebd UPSTREAM: efi_loader: use proper device-paths for partitions
Also, create disk objects for the disk itself, in addition to the
partitions.  (UEFI terminology is a bit confusing, a "disk" object is
really a partition.)  This helps grub properly identify the boot device
since it is trying to match up partition "disk" object with it's parent
device.

Now instead of seeing devices like:

  /File(sdhci@07864000.blk)/EndEntire
  /File(usb_mass_storage.lun0)/EndEntire

You see:

  /ACPI(133741d0,0)/UnknownMessaging(1d)/EndEntire
  /ACPI(133741d0,0)/UnknownMessaging(1d)/HD(0,800,64000,dd904a8c00000000,1,1)/EndEntire
  /ACPI(133741d0,0)/UnknownMessaging(1d)/HD(1,64800,200000,dd904a8c00000000,1,1)/EndEntire
  /ACPI(133741d0,0)/UnknownMessaging(1d)/HD(2,264800,19a000,dd904a8c00000000,1,1)/EndEntire
  /ACPI(133741d0,0)/USB(0,0)/USB(0,0)/USB(0,0)/EndEntire
  /ACPI(133741d0,0)/USB(0,0)/USB(0,0)/USB(0,0)/HD(0,800,60000,38ca680200000000,1,1)/EndEntire
  /ACPI(133741d0,0)/USB(0,0)/USB(0,0)/USB(0,0)/HD(1,61000,155000,38ca680200000000,1,1)/EndEntire
  /ACPI(133741d0,0)/USB(0,0)/USB(0,0)/USB(0,0)/HD(2,20fa800,1bbf8800,38ca680200000000,1,1)/EndEntire
  /ACPI(133741d0,0)/USB(0,0)/USB(0,0)/USB(0,0)/HD(3,1b6800,1f44000,38ca680200000000,1,1)/EndEntire

This is on a board with single USB disk and single sd-card.  The
UnknownMessaging(1d) node in the device-path is the MMC device,
but grub_efi_print_device_path() hasn't been updated yet for some
of the newer device-path sub-types.

This patch is inspired by a patch originally from Peter Jones, but
re-worked to use efi_device_path, so it doesn't much resemble the
original.

Signed-off-by: Rob Clark <robdclark@gmail.com>
[agraf: s/unsigned/unsigned int/]
Signed-off-by: Alexander Graf <agraf@suse.de>
(cherry picked from commit 884bcf6f65c414dce3b3d2a91e2c9eba0e5e08f8)

Change-Id: I8d891a25dd321b718b0429d8b8a895cc4490f272
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2020-01-06 11:45:12 +08:00
Rob Clark 1fa8dee876 UPSTREAM: efi_loader: add device-path utils
Helpers to construct device-paths from devices, partitions, files, and
for parsing and manipulating device-paths.

For non-legacy devices, this will use u-boot's device-model to construct
device-paths which include bus hierarchy to construct device-paths.  For
legacy devices we still fake it, but slightly more convincingly.

Signed-off-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
(cherry picked from commit b66c60dde9d48889b93694326d40f7e5208cff25)

Change-Id: I9825d4132ec08bef46a3b5b7c6946a5636d73ce9
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2020-01-06 11:45:12 +08:00
Joseph Chen 1ce69de6f2 lib: sysmem: promise sysmem_alloc_by_name() alloc cacheline align buffer
This function is called to alloc buffer for storage driver
access, make sure the address is cacheline align.

Also better for any module which calls it.

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I520d16ea28764671eb566cc96cab744ca6b13fc2
2019-12-24 21:04:55 +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 1d09cf29cd lib: bidram: add 4GB+ memory size support
- On ARMv7: LPAE seems to be not friendly that brings a lot of
  compile errors.

- On ARMv8: MMU translate table is static defined by mem_map[]
  and max 4GB as usual. It is not created dynamically according
  to real memory size, that is different from ARMv7.

- 4GB memory is enough for U-Boot on both ARMv7 an ARMv8.

Considering all that, we decide to make max 4GB size to be visiable
for U-Boot, but still pass the real available memory size to kernel
by bidram_fixup() called at late before fixup "/memory" node.

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: Idd5fa769e940b0618446909f8f9edc39f596f072
2019-12-16 21:01:54 +08:00
Joseph Chen 369e944c84 fdt/Makefile: make u-boot-dtb.bin 8-byte aligned
The dts/kern.dtb is appended after u-boot-dtb.bin for U-disk boot.

Make sure u-boot-dtb.bin is 8-byte aligned to avoid data-abort on
calling: fdt_check_header(gd->fdt_blob_kern).

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: Id5f2daf0c5446e7ea828cb970d3d4879e3acda86
2019-12-16 12:07:46 +08:00
Joseph Chen fc474da559 lib: sha256: add sha256_csum()
Change-Id: I3b053f9c07df0d124cdbde9f905e309bcd11c84e
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-11-05 12:24:10 +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
Joseph Chen 5704c899ed fdtdec: support pack "kern.dtb" to the end of u-boot.bin
- It provides a way to promise kernel dtb can be loaded successfully
  even when the image is damaged.
- This makes developers easily to add what they what just like a "U-Boot" dtb.
- The kern.dtb file is pack into the end of u-boot.bin while ./dts/kern.dtb
  is exist.

Change-Id: I93a36a9c65ea8719e5610cdcbcc7708e5337c53f
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-11-04 14:53:45 +08:00
Joseph Chen bcf005ba08 lib: sysmem: no need to increase alloc size when base is 0
Change-Id: Ia716956e1a0e980330d6a7f7eb6c89f91e133ddf
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-11-04 10:23:52 +08:00
Joseph Chen d65bf0c630 lib: sysmem: fix alloc failed at 0x0 address
The 0x0 address is usually allocated by 32-bit uncompressed kernel
and this alloc action is just a peek. Due to LMB core doesn't support
alloc at 0x0 address, we have to alloc the memblk backword a few bytes.

This patch is mainly to avoid fail message from sysmem/LMB.

Change-Id: I894ae2252a30a7690d10899484266191dfb12d15
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-10-31 16:39:43 +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