From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: "David E. Box" <david.e.box@linux.intel.com>
Cc: Netdev <netdev@vger.kernel.org>,
sathyanarayanan.kuppuswamy@linux.intel.com,
LKML <linux-kernel@vger.kernel.org>,
platform-driver-x86@vger.kernel.org
Subject: Re: [PATCH 7/8] tools: Fix errors in meter_certificate display
Date: Thu, 8 Feb 2024 16:46:04 +0200 (EET) [thread overview]
Message-ID: <654cf0d5-e6c4-ac98-154a-29c0536ae2a4@linux.intel.com> (raw)
In-Reply-To: <20240201010747.471141-8-david.e.box@linux.intel.com>
On Wed, 31 Jan 2024, David E. Box wrote:
> The maximum number of bundles in the meter certificate was hardcoded to
> 8 which caused extra bundles not to display. Instead, since the bundles
> appear at the end of the file, set it to the remaining size from where
> the bundles start.
>
> Add missing 'version' field to struct meter_certificate.
>
> Fix errors in the calculation of the start position of the counters and
> in the display loop.
Why are all these bundled into a single commit? They sound like
independent changes.
--
i.
> Fixes: aad129780bae ("platform/x86/intel/sdsi: Add support for reading the current meter state")
> Signed-off-by: David E. Box <david.e.box@linux.intel.com>
> ---
> tools/arch/x86/intel_sdsi/intel_sdsi.c | 51 +++++++++++++++-----------
> 1 file changed, 30 insertions(+), 21 deletions(-)
>
> diff --git a/tools/arch/x86/intel_sdsi/intel_sdsi.c b/tools/arch/x86/intel_sdsi/intel_sdsi.c
> index 2cd92761f171..a8fb6d17405f 100644
> --- a/tools/arch/x86/intel_sdsi/intel_sdsi.c
> +++ b/tools/arch/x86/intel_sdsi/intel_sdsi.c
> @@ -43,7 +43,6 @@
> #define METER_CERT_MAX_SIZE 4096
> #define STATE_MAX_NUM_LICENSES 16
> #define STATE_MAX_NUM_IN_BUNDLE (uint32_t)8
> -#define METER_MAX_NUM_BUNDLES 8
>
> #define __round_mask(x, y) ((__typeof__(x))((y) - 1))
> #define round_up(x, y) ((((x) - 1) | __round_mask(x, y)) + 1)
> @@ -154,11 +153,12 @@ struct bundle_encoding {
> };
>
> struct meter_certificate {
> - uint32_t block_signature;
> + uint32_t signature;
> + uint32_t version;
> + uint64_t ppin;
> uint32_t counter_unit;
> - uint64_t ppin;
> uint32_t bundle_length;
> - uint32_t reserved;
> + uint64_t reserved;
> uint32_t mmrc_encoding;
> uint32_t mmrc_counter;
> };
> @@ -167,6 +167,9 @@ struct bundle_encoding_counter {
> uint32_t encoding;
> uint32_t counter;
> };
> +#define METER_MAX_NUM_BUNDLES \
> + (METER_CERT_MAX_SIZE - sizeof(struct meter_certificate) / \
> + sizeof(struct bundle_encoding_counter))
>
> struct sdsi_dev {
> struct sdsi_regs regs;
> @@ -334,6 +337,7 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s)
> uint32_t count = 0;
> FILE *cert_ptr;
> int ret, size;
> + char name[4];
>
> ret = sdsi_update_registers(s);
> if (ret)
> @@ -375,32 +379,39 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s)
> printf("\n");
> printf("Meter certificate for device %s\n", s->dev_name);
> printf("\n");
> - printf("Block Signature: 0x%x\n", mc->block_signature);
> - printf("Count Unit: %dms\n", mc->counter_unit);
> - printf("PPIN: 0x%lx\n", mc->ppin);
> - printf("Feature Bundle Length: %d\n", mc->bundle_length);
> - printf("MMRC encoding: %d\n", mc->mmrc_encoding);
> - printf("MMRC counter: %d\n", mc->mmrc_counter);
> +
> + get_feature(mc->signature, name);
> + printf("Signature: %.4s\n", name);
> +
> + printf("Version: %d\n", mc->version);
> + printf("Count Unit: %dms\n", mc->counter_unit);
> + printf("PPIN: 0x%lx\n", mc->ppin);
> + printf("Feature Bundle Length: %d\n", mc->bundle_length);
> +
> + get_feature(mc->mmrc_encoding, name);
> + printf("MMRC encoding: %.4s\n", name);
> +
> + printf("MMRC counter: %d\n", mc->mmrc_counter);
> if (mc->bundle_length % 8) {
> fprintf(stderr, "Invalid bundle length\n");
> return -1;
> }
>
> if (mc->bundle_length > METER_MAX_NUM_BUNDLES * 8) {
> - fprintf(stderr, "More than %d bundles: %d\n",
> + fprintf(stderr, "More than %ld bundles: actual %d\n",
> METER_MAX_NUM_BUNDLES, mc->bundle_length / 8);
> return -1;
> }
>
> - bec = (void *)(mc) + sizeof(mc);
> + bec = (void *)(mc) + sizeof(*mc);
>
> - printf("Number of Feature Counters: %d\n", mc->bundle_length / 8);
> - while (count++ < mc->bundle_length / 8) {
> - char feature[5];
> + printf("Number of Feature Counters: %d\n", mc->bundle_length / 8);
> + while (count < mc->bundle_length / 8) {
> + char feature[4];
>
> - feature[4] = '\0';
> get_feature(bec[count].encoding, feature);
> - printf(" %s: %d\n", feature, bec[count].counter);
> + printf(" %.4s: %d\n", feature, bec[count].counter);
> + ++count;
> }
>
> return 0;
> @@ -480,7 +491,7 @@ static int sdsi_state_cert_show(struct sdsi_dev *s)
> sizeof(*lki) + // size of the license key info
> offset; // offset to this blob content
> struct bundle_encoding *bundle = (void *)(lbc) + sizeof(*lbc);
> - char feature[5];
> + char feature[4];
> uint32_t i;
>
> printf(" Blob %d:\n", count - 1);
> @@ -493,11 +504,9 @@ static int sdsi_state_cert_show(struct sdsi_dev *s)
> printf(" Blob revision ID: %u\n", lbc->rev_id);
> printf(" Number of Features: %u\n", lbc->num_bundles);
>
> - feature[4] = '\0';
> -
> for (i = 0; i < min(lbc->num_bundles, STATE_MAX_NUM_IN_BUNDLE); i++) {
> get_feature(bundle[i].encoding, feature);
> - printf(" Feature %d: %s\n", i, feature);
> + printf(" Feature %d: %.4s\n", i, feature);
> }
>
> if (lbc->num_bundles > STATE_MAX_NUM_IN_BUNDLE)
>
next prev parent reply other threads:[~2024-02-08 14:46 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 1:07 [PATCH 0/8] Intel On Demand: Add netlink interface for SPDM attestation David E. Box
2024-02-01 1:07 ` [PATCH 1/8] platform/x86/intel/sdsi: Set message size during writes David E. Box
2024-02-01 16:49 ` Kuppuswamy Sathyanarayanan
2024-02-08 13:42 ` Ilpo Järvinen
2024-02-08 21:49 ` Kuppuswamy Sathyanarayanan
2024-02-01 1:07 ` [PATCH 2/8] platform/x86/intel/sdsi: Combine read and write mailbox flows David E. Box
2024-02-01 17:31 ` Kuppuswamy Sathyanarayanan
2024-02-01 18:11 ` David E. Box
2024-02-08 13:38 ` Ilpo Järvinen
2024-02-01 1:07 ` [PATCH 3/8] platform/x86/intel/sdsi: Add header file David E. Box
2024-02-08 13:41 ` Ilpo Järvinen
2024-02-08 21:52 ` Kuppuswamy Sathyanarayanan
2024-02-01 1:07 ` [PATCH 4/8] platform/x86/intel/sdsi: Add netlink SPDM transport David E. Box
2024-02-01 9:26 ` Jiri Pirko
2024-02-01 16:42 ` David E. Box
2024-02-01 18:00 ` Jiri Pirko
2024-02-01 1:07 ` [PATCH 5/8] platform/x86/intel/sdsi: Add in-band BIOS lock support David E. Box
2024-02-08 13:52 ` Ilpo Järvinen
2024-02-01 1:07 ` [PATCH 6/8] platform/x86/intel/sdsi: Add attribute to read the current meter state David E. Box
2024-02-08 14:43 ` Ilpo Järvinen
2024-02-01 1:07 ` [PATCH 7/8] tools: Fix errors in meter_certificate display David E. Box
2024-02-08 14:46 ` Ilpo Järvinen [this message]
2024-02-01 1:07 ` [PATCH 8/8] tools: intel_sdsi: Add current meter support David E. Box
2024-02-08 14:52 ` Ilpo Järvinen
2024-02-01 3:49 ` [PATCH 0/8] Intel On Demand: Add netlink interface for SPDM attestation Stephen Hemminger
2024-02-01 16:53 ` Kuppuswamy Sathyanarayanan
2024-02-02 1:42 ` Jakub Kicinski
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=654cf0d5-e6c4-ac98-154a-29c0536ae2a4@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=david.e.box@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=sathyanarayanan.kuppuswamy@linux.intel.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