From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org, jbe@pengutronix.de,
Roland Hieber <rhi@pengutronix.de>
Subject: Re: [PATCH 1/2] HABv4: remove useless error message
Date: Tue, 3 Dec 2019 15:47:12 +0100 [thread overview]
Message-ID: <004f884e-f8a4-0646-8571-96952468a350@pengutronix.de> (raw)
In-Reply-To: <20191203143640.cyk6gorjqkj2twtq@pengutronix.de>
[-- Attachment #1.1.1: Type: text/plain, Size: 3834 bytes --]
On 12/3/19 3:36 PM, Sascha Hauer wrote:
>> I think there is just one warning in the buffer:
>>
>>> HABv4: Status: Operation completed with warning (0x69)
>>> HABv4: Config: Secure IC (0xcc)
>>> HABv4: State: Trusted state (0x99)
>>> HABv4: ERROR: Recompile with larger event data buffer (at least 36 bytes)
>>
>> The barebox producing that output is missing both patches:
>>
>> 81e2b508e785 i.MX habv4: habv4_get_status(): display warning events, too
>> e7c33540d0c0 i.MX: HABv4: Reset index variable after error type
>>
>> The question is, do we know why we see this error message? I don't have
>> good feeling when we remove it, because it's annoying and we don't
>> understand why we see it.
>
> The message is wrong because the code is wrong. Let's see:
>
> /* Check reason for stopping */
> len = sizeof(data);
> index = 0;
> if (rvt->report_event(HAB_STATUS_ANY, index, NULL, &len) == HAB_STATUS_SUCCESS)
> pr_err("ERROR: Recompile with larger event data buffer (at least %d bytes)\n\n", len);
>
> report_event() like called above will give you the first message of any
> type (HAB_STATUS_ANY) with index 0. It will do so successfully, so it
> returns HAB_STATUS_SUCCESS.
>
> &len on entry means the length of the buffer (here sizeof(data), large
> enough). &len on exit is the length of the actual message returned. If
> &len is smaller than on entry it means the message buffer was big
> enough. If it's bigger, then we must increase the buffer size and call
> again.
>
> The message buffer is big enough, so report_event copies the buffer
> and returns 36 bytes were copied, but we answer with "Error: Recompile
> with a larger event data buffer".
I see, this means since:
| e7c33540d0c0 i.MX: HABv4: Reset index variable after error type
the check is even more broken and fires every time we have at least one
warning and/or error.
So we can either remove the check/message with a proper commit log or
change the code to semething like:
> diff --git a/drivers/hab/habv4.c b/drivers/hab/habv4.c
> index e3c1de1a4dbe..013cdea1bc43 100644
> --- a/drivers/hab/habv4.c
> +++ b/drivers/hab/habv4.c
> @@ -507,7 +507,7 @@ static int habv4_get_status(const struct habv4_rvt *rvt)
> {
> uint8_t data[256];
> uint32_t len;
> - uint32_t index = 0;
> + uint32_t index = 0, done = 0;
> enum hab_status status;
> enum hab_config config = 0x0;
> enum hab_state state = 0x0;
> @@ -542,6 +542,7 @@ static int habv4_get_status(const struct habv4_rvt *rvt)
>
> len = sizeof(data);
> index++;
> + done++;
> }
>
> len = sizeof(data);
> @@ -553,13 +554,13 @@ static int habv4_get_status(const struct habv4_rvt *rvt)
> habv4_display_event(data, len);
> len = sizeof(data);
> index++;
> + done++;
> }
>
> - /* Check reason for stopping */
> + /* Check if we've handled every event */
> len = sizeof(data);
> - index = 0;
> - if (rvt->report_event(HAB_STATUS_ANY, index, NULL, &len) == HAB_STATUS_SUCCESS)
> - pr_err("ERROR: Recompile with larger event data buffer (at least %d bytes)\n\n", len);
> + if (rvt->report_event(HAB_STATUS_ANY, done, NULL, &len) == HAB_STATUS_SUCCESS)
> + pr_err("ERROR: unhandled HAB event!\n\n", len);
>
> return -EPERM;
> }
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 149 bytes --]
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2019-12-03 14:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-02 10:24 Juergen Borleis
2019-12-02 10:24 ` [PATCH 2/2] HABv4: fix ROM code API usage Juergen Borleis
2019-12-02 13:07 ` [PATCH 1/2] HABv4: remove useless error message Roland Hieber
2019-12-02 13:24 ` Marc Kleine-Budde
2019-12-02 13:33 ` Roland Hieber
2019-12-02 13:38 ` Marc Kleine-Budde
2019-12-02 14:30 ` Juergen Borleis
2019-12-03 14:04 ` Marc Kleine-Budde
2019-12-03 14:36 ` Sascha Hauer
2019-12-03 14:47 ` Marc Kleine-Budde [this message]
2019-12-03 14:51 ` Juergen Borleis
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=004f884e-f8a4-0646-8571-96952468a350@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=jbe@pengutronix.de \
--cc=rhi@pengutronix.de \
--cc=s.hauer@pengutronix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox