Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp148182lqg; Wed, 10 Apr 2024 20:00:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWTvtLo30o7XhEyyaUUzsSvXTd4Jtx1vtkhnlcrplrq2+EiOrglW02WqE4PjFr0e+EiRrOiVW7RQ0LyRAQptmuQFLfG6d1Mdje2wthk6A== X-Google-Smtp-Source: AGHT+IH6H6LBOYj7e+MYpbQxZ3qHZeBOHZiW2zqrbJULS3e30nHUoni4Oq7RYuRNF+jt6bkXM3jj X-Received: by 2002:a17:906:509:b0:a4e:679b:8437 with SMTP id j9-20020a170906050900b00a4e679b8437mr2046806eja.59.1712804413157; Wed, 10 Apr 2024 20:00:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712804413; cv=pass; d=google.com; s=arc-20160816; b=0NhEZTUOFvaRXAAH4OFmOcnZN1snmxMG/969NcJOfHllQMvW8ipLzt6wy3gtrVTkuC tI9ls4NH10igIR4XrD/hZm3I1EfDkbLpBw7Ux8R87IS4jtxSwGN4OGd75FGokPNFZ72M gXbVlm3CQeky/e4uOGBWoIdzb40vkRqJCcrqi6ZiK2IPXglqLatXz02txpYbYjtAlj42 yA6QDTAc8f2Lxk0CTMyW0DMWHwRVxFkwpUkwtF+411WZ8+jJtGADm+RO/yeJCB4EILsl oLxY3fvh+EDspWkRB5+WsaWuYbBzsvMLYH2REDGYP6O0AMxiA4UAVJMNi8O6HEFG80+I v8Nw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=wP/L5xfsWybwNo3FnDBwo6l5YVIeeg6CBrkWiv/TK+I=; fh=f3/3BbZ3MBzfqpHaAMiZ5353WiZNd6NJX+DCNLWJOnA=; b=0/A70hPs9/zLxDA+8UOsktdTmGOwEBwD2v98gbeu7skV8JI/+dnWZEKnIEau5jq/cm UHlcaBCc/WIZdSTyBQ1CtgjQBuRfD7AG9CPMM/aVPLkVA8R2056oSxaQof4ppk4uLtmx DUt8JyZc/8rBVwKZwZU+Ys3gFEnADnX7QBJhHO4DS3bgp+7y2TUMJHDrBSpxdz3wSdyP wmTIzTi2CCZz6QdY1INQsVtsvNIHeTRPZg9eDkqGEP3moNsza8vxVs0p3zihguzLRbul exkU6lkk6R5AMmW1O3q/tQl6kPtwXeqJ87v9DcxJTOvyu8H3cjCeKkzQ5Zj+NKrPzADt zKgA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=glQ2q8SP; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-139678-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139678-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cf8-20020a170906b2c800b00a51a488909bsi279057ejb.567.2024.04.10.20.00.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 20:00:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139678-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=glQ2q8SP; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-139678-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139678-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E09041F2520F for ; Thu, 11 Apr 2024 03:00:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5851F13C666; Thu, 11 Apr 2024 02:59:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="glQ2q8SP" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A93A813BAD9; Thu, 11 Apr 2024 02:59:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712804350; cv=none; b=tT/w2pccb95IcTh0uO6rTwtDQqWYBIhL213llr/y14GdnhjFoE24nw/UsY/hSrCEVmoJ0JkkTjwx33Yipu+t619bJghoYfG6SDHUfAnpTKpGVM/Czs4Xz5G27Zfp7cFcyP61lndlxpmLvYlf6aoX7rJTqXHWFgY1HJMJWVAxnWY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712804350; c=relaxed/simple; bh=O4XNoax5yGBMi63llRvcorZdxNz6JIEktGe62dOVXIs=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=V8ohQ3dcufJ69H8rdX5rt9hG9IRR13hW2ArFp3xtXJ/AxmcbtE+4+/2et/SEpfy9L5iLPo8TkWa6KjMei2Ydgd4EcPA1304U5/drtxTo1S+tGD/aoDFV5mgo3bjOo98RhV19dyAN3tlQOQTbO4SlWz1Y7RuWpVGfAU4wKnz2KKo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=glQ2q8SP; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712804349; x=1744340349; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=O4XNoax5yGBMi63llRvcorZdxNz6JIEktGe62dOVXIs=; b=glQ2q8SP52CrNax5ck7wOhWMUIj5+q3LJCxXOq6lxBhPRkPOcn5uz7+W axChXb6o4GPqTEmcfqO00T7elAZl0if5/4Awhq4OdYSsLoFf4tMZdsEjS IxE5k9i3qN52ovYmWTlrVeyGhem8UEcj4Bt2FKMJfDK2Le0QAuIPSz9e0 jLikenLemDO4bR2g9QGaGexqd+bN7k5APcuro+7sBdY4wCNwTWyJ09hAZ rsPY8TjNLFv4mWlHCHiCqWpTNsFbrwT7XVRQWrAOWA0Rpq/rEveEhFM+E mlR6b+JzwEa61WN9oeEh/Ur5u0OadrvoXJHxwfgRsyLJeqzJ06iNT4OK6 g==; X-CSE-ConnectionGUID: tsMgawe0TqSxFVS4j7lK4g== X-CSE-MsgGUID: acR5lcApQhOdBdCyzFB8gg== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="8054674" X-IronPort-AV: E=Sophos;i="6.07,192,1708416000"; d="scan'208";a="8054674" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2024 19:59:04 -0700 X-CSE-ConnectionGUID: lx39kQUASTakcBY6nfuv2g== X-CSE-MsgGUID: Ip0NM+y8RumzZZ3UjHymRQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,192,1708416000"; d="scan'208";a="51730484" Received: from karczmac-mobl.amr.corp.intel.com (HELO debox1-desk4.lan) ([10.255.229.250]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2024 19:59:04 -0700 From: "David E. Box" To: david.e.box@linux.intel.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, sathyanarayanan.kuppuswamy@linux.intel.com Subject: [PATCH V4 6/9] tools/arch/x86/intel_sdsi: Fix meter_show display Date: Wed, 10 Apr 2024 19:58:53 -0700 Message-Id: <20240411025856.2782476-7-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411025856.2782476-1-david.e.box@linux.intel.com> References: <20240411025856.2782476-1-david.e.box@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes sdsi_meter_cert_show() to correctly decode and display the meter certificate output. Adds and displays a missing version field, displays the ASCII name of the signature, and fixes the print alignment. Fixes: 7fdc03a7370f ("tools/arch/x86: intel_sdsi: Add support for reading meter certificates") Signed-off-by: David E. Box Reviewed-by: Kuppuswamy Sathyanarayanan Reviewed-by: Ilpo Järvinen --- V4 - no changes V3 - Change patch subject and changelog to clarify changes. - Use new BUNDLE_COUNT #def V2 - Split of V1 patch 7 tools/arch/x86/intel_sdsi/intel_sdsi.c | 29 +++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/tools/arch/x86/intel_sdsi/intel_sdsi.c b/tools/arch/x86/intel_sdsi/intel_sdsi.c index 7eaffcbff788..ae29214da102 100644 --- a/tools/arch/x86/intel_sdsi/intel_sdsi.c +++ b/tools/arch/x86/intel_sdsi/intel_sdsi.c @@ -153,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; }; @@ -338,6 +339,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) @@ -379,12 +381,19 @@ 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; @@ -398,7 +407,7 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s) bec = (void *)(mc) + sizeof(mc); - printf("Number of Feature Counters: %d\n", mc->bundle_length / 8); + printf("Number of Feature Counters: %ld\n", BUNDLE_COUNT(mc->bundle_length)); while (count++ < mc->bundle_length / 8) { char feature[5]; -- 2.34.1