All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Opaniuk <igor.opaniuk@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/8] cmd: avb2.0: avb command for performing verification
Date: Tue, 15 May 2018 18:44:45 +0300	[thread overview]
Message-ID: <CAModR+UxBTHqFhvqLgMrCS8cZd0v1pZwYGsFmtQ73w-LpP0Jgw@mail.gmail.com> (raw)
In-Reply-To: <CAPnjgZ1zXj5jWZpy_hnUVN96OMCK04Yxiov_O52XPK+n7Yf7dQ@mail.gmail.com>

Hi Simon,

I've dug into DriverModel documentation and even created a PoC for
existing avb commands. The problem is that (maybe I missed out some
key concepts) I'm still
not sure if it makes sense to follow it driver mode in the context of
AVB 2.0 feature and
what kind of extra devices can be used within the same uclass in this case?
Could you please explain in detail.
Thanks

Hi Sam,
Thanks, will fix!


On 3 May 2018 at 05:31, Simon Glass <sjg@chromium.org> wrote:
> Hi Igor,
>
> On 25 April 2018 at 07:18, Igor Opaniuk <igor.opaniuk@linaro.org> wrote:
>> Enable a "avb" command to execute Android Verified
>> Boot 2.0 operations. It includes such subcommands:
>>   avb init - initialize avb2 subsystem
>>   avb read_rb - read rollback index
>>   avb write_rb - write rollback index
>>   avb is_unlocked - check device lock state
>>   avb get_uuid - read and print uuid of a partition
>>   avb read_part - read data from partition
>>   avb read_part_hex - read data from partition and output to stdout
>>   avb write_part - write data to partition
>>   avb verify - run full verification chain
>>
>> Signed-off-by: Igor Opaniuk <igor.opaniuk@linaro.org>
>> ---
>>  cmd/Kconfig  |  15 +++
>>  cmd/Makefile |   3 +
>>  cmd/avb.c    | 351 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>  3 files changed, 369 insertions(+)
>>  create mode 100644 cmd/avb.c
>>
>> diff --git a/cmd/Kconfig b/cmd/Kconfig
>> index bc1d2f3..96695ff 100644
>> --- a/cmd/Kconfig
>> +++ b/cmd/Kconfig
>> @@ -1675,6 +1675,21 @@ config CMD_TRACE
>>           for analsys (e.g. using bootchart). See doc/README.trace for full
>>           details.
>>
>> +config CMD_AVB
>> +       bool "avb - Android Verified Boot 2.0 operations"
>> +       depends on LIBAVB_AB
>> +       help
>> +         Enables a "avb" command to perform verification of partitions using
>> +         Android Verified Boot 2.0 functionality. It includes such subcommands:
>> +           avb init - initialize avb2 subsystem
>> +           avb read_rb - read rollback index
>> +           avb write_rb - write rollback index
>> +           avb is_unlocked - check device lock state
>> +           avb get_uuid - read and print uuid of a partition
>> +           avb read_part - read data from partition
>> +           avb read_part_hex - read data from partition and output to stdout
>> +           avb write_part - write data to partition
>> +           avb verify - run full verification chain
>>  endmenu
>>
>>  config CMD_UBI
>> diff --git a/cmd/Makefile b/cmd/Makefile
>> index c4269ac..bbf6c2a 100644
>> --- a/cmd/Makefile
>> +++ b/cmd/Makefile
>> @@ -151,6 +151,9 @@ obj-$(CONFIG_CMD_REGULATOR) += regulator.o
>>
>>  obj-$(CONFIG_CMD_BLOB) += blob.o
>>
>> +# Android Verified Boot 2.0
>> +obj-$(CONFIG_CMD_AVB) += avb.o
>> +
>>  obj-$(CONFIG_X86) += x86/
>>  endif # !CONFIG_SPL_BUILD
>>
>> diff --git a/cmd/avb.c b/cmd/avb.c
>> new file mode 100644
>> index 0000000..d040906
>> --- /dev/null
>> +++ b/cmd/avb.c
>> @@ -0,0 +1,351 @@
>> +
>> +/*
>> + * (C) Copyright 2018, Linaro Limited
>> + *
>> + * SPDX-License-Identifier:    GPL-2.0+
>> + */
>> +
>> +#include <avb_verify.h>
>> +#include <command.h>
>> +#include <image.h>
>> +#include <malloc.h>
>> +#include <mmc.h>
>> +
>> +#define AVB_BOOTARGS   "avb_bootargs"
>> +static struct AvbOps *avb_ops;
>> +
>> +static const char * const requested_partitions[] = {"boot",
>> +                                            "system",
>> +                                            "vendor",
>> +                                            NULL};
>> +
>> +int do_avb_init(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>> +{
>> +       unsigned long mmc_dev;
>> +
>> +       if (argc != 2)
>> +               return CMD_RET_USAGE;
>> +
>> +       mmc_dev = simple_strtoul(argv[1], NULL, 16);
>> +
>> +       if (avb_ops)
>> +               avb_ops_free(avb_ops);
>> +
>> +       avb_ops = avb_ops_alloc(mmc_dev);
>> +       if (avb_ops)
>> +               return CMD_RET_SUCCESS;
>> +
>> +       return CMD_RET_FAILURE;
>> +}
>> +
>> +int do_avb_read_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>> +{
>> +       const char *part;
>> +       s64 offset;
>> +       size_t bytes, bytes_read = 0;
>> +       void *buffer;
>> +
>> +       if (!avb_ops) {
>> +               printf("AVB 2.0 is not initialized, please run 'avb init'\n");
>> +               return CMD_RET_USAGE;
>> +       }
>> +
>> +       if (argc != 5)
>> +               return CMD_RET_USAGE;
>> +
>> +       part = argv[1];
>> +       offset = simple_strtoul(argv[2], NULL, 16);
>> +       bytes = simple_strtoul(argv[3], NULL, 16);
>> +       buffer = (void *)simple_strtoul(argv[4], NULL, 16);
>> +
>> +       if (avb_ops->read_from_partition(avb_ops, part, offset, bytes,
>> +                                        buffer, &bytes_read) ==
>> +                                        AVB_IO_RESULT_OK) {
>
> Please can you make sure this uses driver model, and put wrappers for
> these function calls in the uclass?
>
> Regards,
> Simon



-- 
Regards,
Igor Opaniuk

  reply	other threads:[~2018-05-15 15:44 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-25 13:17 [U-Boot] [PATCH 0/8] Initial integration of AVB2.0 Igor Opaniuk
2018-04-25 13:17 ` [U-Boot] [PATCH 1/8] avb2.0: add Android Verified Boot 2.0 libraries Igor Opaniuk
2018-04-25 13:17 ` [U-Boot] [PATCH 2/8] avb2.0: integrate avb 2.0 into the build system Igor Opaniuk
2018-04-25 13:18 ` [U-Boot] [PATCH 3/8] avb2.0: implement AVB ops Igor Opaniuk
2018-04-25 13:18 ` [U-Boot] [PATCH 4/8] cmd: avb2.0: avb command for performing verification Igor Opaniuk
2018-05-02 18:52   ` Sam Protsenko
2018-05-03  2:31   ` Simon Glass
2018-05-15 15:44     ` Igor Opaniuk [this message]
2018-05-15 16:26       ` Simon Glass
2018-05-15 17:31         ` Igor Opaniuk
2018-05-15 18:28           ` Simon Glass
2018-05-16  8:20             ` Igor Opaniuk
2018-05-16 15:40               ` Simon Glass
2018-04-25 13:18 ` [U-Boot] [PATCH 5/8] avb2.0: add boot states and dm-verity support Igor Opaniuk
2018-05-02 18:59   ` Sam Protsenko
2018-04-25 13:18 ` [U-Boot] [PATCH 6/8] am57xx_hs: avb2.0: add support of AVB 2.0 Igor Opaniuk
2018-05-02 19:06   ` Sam Protsenko
2018-04-25 13:18 ` [U-Boot] [PATCH 7/8] test/py: avb2.0: add tests for avb commands Igor Opaniuk
2018-04-25 13:18 ` [U-Boot] [PATCH 8/8] doc: avb2.0: add README about AVB2.0 integration Igor Opaniuk
2018-05-02 19:12   ` Sam Protsenko
2018-05-16  9:20     ` Igor Opaniuk
2018-04-26  3:05 ` [U-Boot] [PATCH 0/8] Initial integration of AVB2.0 Kever Yang
2018-04-26 13:00   ` Igor Opaniuk
2018-04-26 18:35   ` Alex Deymo
2018-04-27  9:53     ` Igor Opaniuk
2018-04-30 10:47       ` Alex Deymo
2018-05-06 11:31 ` Eugeniu Rosca
2018-05-15 15:31   ` Eugeniu Rosca
2018-05-15 16:58     ` Igor Opaniuk
2018-05-15 17:10       ` Eugeniu Rosca

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAModR+UxBTHqFhvqLgMrCS8cZd0v1pZwYGsFmtQ73w-LpP0Jgw@mail.gmail.com \
    --to=igor.opaniuk@linaro.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.