From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Alejandro Zeise <alejandro.zeise@seagate.com>,
qemu-arm@nongnu.org, John Wang <wangzq.jn@gmail.com>
Cc: qemu-devel@nongnu.org, clg@kaod.org, peter.maydell@linaro.org,
berrange@redhat.com
Subject: Re: [PATCH v2 2/2] hw/misc/aspeed_hace: Fix SG Accumulative hashing
Date: Tue, 30 Jul 2024 09:03:00 +0200 [thread overview]
Message-ID: <d5baccc9-183f-4ce8-9f1e-d7fae5d59870@linaro.org> (raw)
In-Reply-To: <20240729190035.3419649-3-alejandro.zeise@seagate.com>
Hi Alejandro,
On 29/7/24 21:00, Alejandro Zeise wrote:
> Make the Aspeed HACE module use the new qcrypto accumulative hashing functions
> when in scatter-gather accumulative mode. A hash context will maintain a
> "running-hash" as each scatter-gather chunk is received.
>
> Previously each scatter-gather "chunk" was cached
> so the hash could be computed once the final chunk was received.
> However, the cache was a shallow copy, so once the guest overwrote the
> memory provided to HACE the final hash would not be correct.
>
> Possibly related to: https://gitlab.com/qemu-project/qemu/-/issues/1121
Likely, Cc'ing John.
Reported-by: John Wang <wangzq.jn@gmail.com>
> Buglink: https://github.com/openbmc/qemu/issues/36
>
> Signed-off-by: Alejandro Zeise <alejandro.zeise@seagate.com>
> ---
> hw/misc/aspeed_hace.c | 91 ++++++++++++++++++-----------------
> include/hw/misc/aspeed_hace.h | 4 ++
> 2 files changed, 51 insertions(+), 44 deletions(-)
> @@ -252,20 +228,42 @@ static void do_hash_operation(AspeedHACEState *s, int algo, bool sg_mode,
> - if (niov) {
> - i = niov;
> - }
> + if (acc_mode) {
> + if (s->qcrypto_hash_context == NULL &&
> + qcrypto_hash_accumulate_new_ctx(algo, &s->qcrypto_hash_context, NULL)) {
> + qemu_log_mask(LOG_GUEST_ERROR,
> + "%s: qcrypto failed to create hash context\n",
> + __func__);
> + return;
> + }
Using a instance_init() handler, ...
> @@ -397,6 +395,11 @@ static void aspeed_hace_reset(DeviceState *dev)
> {
> struct AspeedHACEState *s = ASPEED_HACE(dev);
>
> + if (s->qcrypto_hash_context != NULL) {
> + qcrypto_hash_accumulate_free_ctx(s->qcrypto_hash_context, NULL);
> + s->qcrypto_hash_context = NULL;
> + }
... and instance_finalize() could simplify a bit.
Regards,
Phil.
next prev parent reply other threads:[~2024-07-30 7:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-29 19:00 [PATCH v2 0/2] hw/misc/aspeed_hace: Fix SG Accumulative Hash Calculations Alejandro Zeise
2024-07-29 19:00 ` [PATCH v2 1/2] crypto: add support for accumulative hashing Alejandro Zeise
2024-07-30 15:58 ` Cédric Le Goater
2024-07-30 16:34 ` Daniel P. Berrangé
2024-07-30 16:26 ` Daniel P. Berrangé
2024-07-29 19:00 ` [PATCH v2 2/2] hw/misc/aspeed_hace: Fix SG Accumulative hashing Alejandro Zeise
2024-07-30 7:03 ` Philippe Mathieu-Daudé [this message]
2024-07-30 10:54 ` Cédric Le Goater
2024-07-30 16:01 ` Alejandro Zeise
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=d5baccc9-183f-4ce8-9f1e-d7fae5d59870@linaro.org \
--to=philmd@linaro.org \
--cc=alejandro.zeise@seagate.com \
--cc=berrange@redhat.com \
--cc=clg@kaod.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=wangzq.jn@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).