[avb] Check partition before allocating 64KB memory for VBMeta

This cl is an optimization for load_and_verify_vbmeta(). When
we want to load the VBMeta from the partition `vbmeta` and we
are the main VBMeta, prior to this cl, we first allocated 64KB
memory and then tried to read the partition `vbmeta`.

This cl added a check before this action. After this cl, we
first try to read 1 byte from the partition, if this fails
because no such partition exists, we fallback directly on
the `boot` partition. With this approach, we avoid allocating
the big chunk of memory on heap for VBMeta when the partition
doesn't exist.

This unblocks the cl aosp/2388176 where we don't have the
`vbmeta` partition and also cannot afford allocating the 64KB
memory in pVM firmware.

Bug: 256148034
Test: atest libavb_host_unittest libpvmfw_avb.integration_test
Change-Id: Ia242ddedc8bb5e8a4277a9a766d563d8ae8cdd60
1 file changed