Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2299595rbb; Tue, 27 Feb 2024 18:31:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWaQWvsfFaOXYTlAReGDDr+ExeCXRycpVi3/0KK6vAl6fyB6toeIJrW5g5URYFw5VVj5eL6/YZDjXviaAEZkpWiV2ZyNRv/L6Lk202Tug== X-Google-Smtp-Source: AGHT+IGV200AZbnDLJTvAiItLpXA9b9tYAEoS0np1v2VC1y0pTYMGdF75imt5DqfoompRPw54PGd X-Received: by 2002:a17:906:fb91:b0:a43:ffe4:bc49 with SMTP id lr17-20020a170906fb9100b00a43ffe4bc49mr139813ejb.28.1709087498301; Tue, 27 Feb 2024 18:31:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709087498; cv=pass; d=google.com; s=arc-20160816; b=AhltN5VnJ6pOerBMVd0v0EXOY2DWGQfI5ZrCGcc1w+2mwucQufE8NC8unwLiaTaXap Wa8POoxf+LwYM01LYWTK1GBZY8ozBg67EaqXJxZeKufAZk79upjocQGtjyW+TQ2wEn35 gI9f7CBPtec0bI+h/W5r85bZSjOwuj9rUhXC+jjNGV9yUYwvd0yCY20ye+z9enXrUBIm qOc158bDvx6VdglHAjwpCt4tJYlGqhL0DYNar0gsp2mnAoM0QlSd/PRQBVMpTTyJ+0U2 AeRScE/XR+3XNQNWmsnzQPNUyBpaRjaxPlBngecgt7WDl7Q0sSYZoVdCfOYBqMbZkAY2 4Inw== 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=b2VW/9Qts1z4Zjhi2OYorq6Yxrdwao3zPoNBUU//oVg=; fh=x4bFVqj5qD52f35ITnpIMR9XPjt+nAjpv5WW2CLFX0Q=; b=ZLpv+nqoqotiMqrSbfzjdiBZFj+9Gvmu1VkbJ/kMtrKEDd6IO67gOI1A7ikOP1nfZp +YdViy0l6CK3HBkkyLovEOtfxmRu+nQCHrpaHYqvnezBBJpjwmNBbIwCX8dF9iZ8uuks m6XS87mz5D3RHO+S0fMXBpdP25XrgN9hon/8V7Tn0OQpyNCZ+LkzveXkjdQW5fSW18Mh aWPiDjWzMzb6BHUosMDZ9n02X3sfCnJnyqNhh+Q39ImFF6kddPaKUbyd/4/6mbE9bYZH Fh9vD9/z6HYtPJBINm8CwBbWu6DO947MENu/K9eDI4McGKxsOrqvgWgfZWg+T0ize7z8 Iv5A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WnzX7nR4; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84249-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84249-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 x23-20020a170906299700b00a4160485d26si1269042eje.1041.2024.02.27.18.31.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 18:31:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84249-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=WnzX7nR4; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84249-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84249-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 D57511F252A8 for ; Wed, 28 Feb 2024 00:01:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D24EB32C6C; Wed, 28 Feb 2024 00:00:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WnzX7nR4" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (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 F3CDD79ED; Wed, 28 Feb 2024 00:00:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078422; cv=none; b=PQkSNA13/uN46Q1CUxPuvPki8t58TWq8c5pquhjSATWCjKFxRn1+Wc9ipvUR9gWb+duIKsDXxLRhi2NjGklMj1kEh42faudjVg4v+Agn7IY5DFSKEAB0w7rYzThrEgHWewrUgwpVFmriYwmPFphFpNGy+ZshjYmr3fNfOspRFsQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078422; c=relaxed/simple; bh=+Z7En2HDO6d1w36dnpCFtmIvi6nCJV8wICBRrJL4X00=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tg1kJfx10ot3u34FTyO3lHrsDEZEV2KdRLYjmhZaVgQ1Ohq+n0wPqw7gDEdsE5tTV/yHPDxw8MeahW717p9NVq/axQEYHGuIVKKrR8WdsBqtPpBDVmvl3qJLdwFYHw/NVJL3dHls5AloLz3630obkPFdzAduEj4iLERXC2FT820= 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=WnzX7nR4; arc=none smtp.client-ip=198.175.65.13 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=1709078421; x=1740614421; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=+Z7En2HDO6d1w36dnpCFtmIvi6nCJV8wICBRrJL4X00=; b=WnzX7nR4+nbl8VnWWTRNIvZ4BHSSxR53I/wpeNrT0IZ/4Zq1h7DPE2cL K2tGY/5I/xOSMVAP1C/yKI2Yy81Jih0sqJPIz7M9GTS9PHL7N2NFAIHm2 txioPC+7rLf8N7il5ma8Abc2G/lAaZOjOS+ebxwdYlNujT4xMwJgZA+ki LSja9S5ZspMZ3f97D0rZ0MFgjZbh9vWgqBkrIf+BDhytVh3xNq0mBuplk kq6sxgFtK7Emak0am1bagX6UCBvvFGDy5REmjsYoI2OvQByUlDxahvKna 7JIIauKckHcKr67Qki688M0gnvycJ23Q2Es7COtjGbpylEzfpZTMqxhkg Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="14604939" X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="14604939" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 16:00:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="7176941" Received: from linux.intel.com ([10.54.29.200]) by orviesa010.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 16:00:18 -0800 Received: from debox1-desk4.lan (unknown [10.251.6.149]) by linux.intel.com (Postfix) with ESMTP id 406A6580B9A; Tue, 27 Feb 2024 16:00:17 -0800 (PST) From: "David E. Box" To: david.e.box@linux.intel.com, rajvi.jingar@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com Subject: [PATCH V2 5/9] tools/arch/x86/intel_sdsi: Fix maximum meter bundle length Date: Tue, 27 Feb 2024 16:00:12 -0800 Message-Id: <20240228000016.1685518-6-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228000016.1685518-1-david.e.box@linux.intel.com> References: <20240228000016.1685518-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 The maximum number of bundles in the meter certificate was set to 8 which is much less than the maximum. Instead, since the bundles appear at the end of the file, set it based on the remaining file size from the bundle start position. Fixes: aad129780bae ("platform/x86/intel/sdsi: Add support for reading the current meter state") Signed-off-by: David E. Box --- V2 - Split of V1 patch 7 tools/arch/x86/intel_sdsi/intel_sdsi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/arch/x86/intel_sdsi/intel_sdsi.c b/tools/arch/x86/intel_sdsi/intel_sdsi.c index 2cd92761f171..a02850a710ee 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) @@ -167,6 +166,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; @@ -387,7 +389,7 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s) } 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; } -- 2.34.1