Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp148312lqg; Wed, 10 Apr 2024 20:00:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWlFfQZ8oZFAGZAWKokgSg+PPyrE9HjbHcf3NodFdPnF3PLQ2NUipskAYOtq+oJx7c/BhSVFJoaOxLooI6pSRvO0RvEV2qEpKBMFE1/RQ== X-Google-Smtp-Source: AGHT+IEuKuxzd+Vh4tN6sdlLRmp+Cf++pr9PzxHzaqVkyKz6pe2dTnKIujQ7uwRP/VvrAzK0aq3e X-Received: by 2002:a05:6102:6d1:b0:47a:2a2b:1df5 with SMTP id m17-20020a05610206d100b0047a2a2b1df5mr3380252vsg.14.1712804430174; Wed, 10 Apr 2024 20:00:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712804430; cv=pass; d=google.com; s=arc-20160816; b=M7CmqLm65cidjSN1/NcE/veoqzwnc7K9d7excYQFMDbITlaYgB3YQto2VqSRVTLZJp wg+IzrO17M2yy+0YV2/c6bi6WOzKaHv7Yh6E65AiVirhQlHFFyzA6/E4QqBQtss6u7kK 1t/46SKeDw5T1Jl6sXMxpGnTtJtaNx3AvIL2bTZMcX2vNW2tXT5W5GhCQ8Z9ua/lGRgc md0MlqaKxJhZyF2MypIZcDnZuZSheRKfUVRZAXetUAyoluJnxbRJ43wMRHtfVqloVZxL 51pfxeuWkTmbkHFREl3p1IO/ipHYFU8YpONbbvy2NJbUDAu+znyX6KYeE/qlClaL2FDl QwXg== 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=Y4wj321PmFw8tgoIMLkPsG2xOqL3bzYbWYNMgBXLB3E=; fh=f3/3BbZ3MBzfqpHaAMiZ5353WiZNd6NJX+DCNLWJOnA=; b=cuP5Ly7n9Ga+dyLvnOR1s7gcK2SyXFDN9a345KJOTLfKYJ1TOuXwHC2hwNMVDTbSrp Y04Bm0XzaOvo08FDtwxcr5IX8YAqczfKqPxYF4oogdSbSkAFbgyFRJacsVUTqWQGHnqU a01fAJP77YGhJJ51X0j7tKFoPP2cattqjx/gpLOyu68PrmVkBF11iFGLKI9gM6UmMJdM +NTfG+cYPBX+YHWHqHTX7whirc0nMiyQwwVMtWtAo8areEDOUxHhptHfM9GAtT40UyYD 90rdeFByITdttem2eufk2grPb7EjoHu2nPI033uiKOy8EWpdmItlxWaxyOep53pCUVzC ODTA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=c1siPBkK; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-139679-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139679-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id o8-20020a056214108800b006993d99e330si596677qvr.14.2024.04.10.20.00.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 20:00:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139679-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=c1siPBkK; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-139679-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139679-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id CFCC11C23714 for ; Thu, 11 Apr 2024 03:00:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F54E13C820; Thu, 11 Apr 2024 02:59:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="c1siPBkK" 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 8C02713BAFE; Thu, 11 Apr 2024 02:59:09 +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=1712804351; cv=none; b=heUJNPW0CWemCvmMrn7Cy8xVQCMoqgEDh4vEQ26LEoojLIwslmpclGLwuT8R0smMsZUZ8+9+QyTVK2jhHjWmm3OjCeuU4X4F55sLYmscuQoa9959sNZ2mGpD1jzYgLtPAc+kfguyOzj7rsQdGtqi1TrHvKPUr0GOIcmwIdDOUTI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712804351; c=relaxed/simple; bh=eM4WasRih/4X/yvMkpDWf9CwRC6cUMzwOjwfJBps6bE=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=B8l9NpoCObnnJxZVMfjD2G076eTKVuPv2p740jAwZIcCz9biHWIDhHdHcqQGuW72ARrWEG2YNKhTH2irYGIwJsptK8FDjgNtixM6c4ASQ8+x7Y8+LaJSEl3vi7vjF3cyf3SyfXLJMDNrCT/+nIwUC9BHr+iP2oeHMEAY7EUmJGU= 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=c1siPBkK; 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=1712804350; x=1744340350; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=eM4WasRih/4X/yvMkpDWf9CwRC6cUMzwOjwfJBps6bE=; b=c1siPBkKQAvjIwIbNvWQ06m415OJjFD3BWSvZyzylBRRDBkWVXWsaW+F iNYE8dUa4LcWpPn53lJO86tEfIwQBkVqUZIK593IqlXr//QkfNwUsyz8R YGpBirEfYrqioPyOPvinoX/5yUOWd5hQJ8bM2EGfUn1FjmBKtJXE+8rBo 36gUeOL6lyeJbBWIGmRCriNsvc9OXfRxGz9WCSNoLrkTFQJRhrwxZlhLj L+So/6fuCgO9f8vJ69u/1yDuwyPGnzdzbySUve6GLJczuoUWMKVPKdzeC 9DIrvGmfQ5jjsngr03nVxIlgIgt7yo50YDWMtcvIFiNZeJSXOiLDxqH6c g==; X-CSE-ConnectionGUID: GVjimXfrQveqO8xlASAqdg== X-CSE-MsgGUID: ymVeCykJRFyezCxjp5qzzg== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="8054676" X-IronPort-AV: E=Sophos;i="6.07,192,1708416000"; d="scan'208";a="8054676" 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: N53n9HacTmGdeqK+lJGpUg== X-CSE-MsgGUID: d5rzbgEJR1WpBb6UUOptzQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,192,1708416000"; d="scan'208";a="51730486" 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 7/9] tools/arch/x86/intel_sdsi: Fix meter_certificate decoding Date: Wed, 10 Apr 2024 19:58:54 -0700 Message-Id: <20240411025856.2782476-8-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-Transfer-Encoding: 8bit Fix errors in the calculation of the start position of the counters and in the display loop. While here, use a #define for the bundle count and size. Fixes: 7fdc03a7370f ("tools/arch/x86: intel_sdsi: Add support for reading meter certificates") Signed-off-by: David E. Box Reviewed-by: Kuppuswamy Sathyanarayanan --- V4 - Use suggested struct bundle_encoding_counter cast V3 - Use macros for bundle size and count V2 - Split of V1 patch 7 tools/arch/x86/intel_sdsi/intel_sdsi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/arch/x86/intel_sdsi/intel_sdsi.c b/tools/arch/x86/intel_sdsi/intel_sdsi.c index ae29214da102..ba2a6b6645ae 100644 --- a/tools/arch/x86/intel_sdsi/intel_sdsi.c +++ b/tools/arch/x86/intel_sdsi/intel_sdsi.c @@ -394,7 +394,7 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s) printf("MMRC encoding: %.4s\n", name); printf("MMRC counter: %d\n", mc->mmrc_counter); - if (mc->bundle_length % 8) { + if (mc->bundle_length % METER_BUNDLE_SIZE) { fprintf(stderr, "Invalid bundle length\n"); return -1; } @@ -405,15 +405,16 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s) return -1; } - bec = (void *)(mc) + sizeof(mc); + bec = (struct bundle_encoding_counter *)(mc + 1); printf("Number of Feature Counters: %ld\n", BUNDLE_COUNT(mc->bundle_length)); - while (count++ < mc->bundle_length / 8) { + while (count < BUNDLE_COUNT(mc->bundle_length)) { char feature[5]; feature[4] = '\0'; get_feature(bec[count].encoding, feature); printf(" %s: %d\n", feature, bec[count].counter); + ++count; } return 0; -- 2.34.1