Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2306636rbb; Tue, 27 Feb 2024 18:54:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWcsCHDnla0bG7W0j3WigMWvopp/9YmerT3XHlQG5nhJRp8b0Q/0vPq/i2ZMuYvVSZaHvmgDgH3ArrwSoXkdXAB7Kf1k+4okSOWkJjZEQ== X-Google-Smtp-Source: AGHT+IFiVEdF0sD4GrCwWCP6sfLmKUciFvwwWlDIkn46vwf1snxoQ4if73+VoJVZpDtCnDUYDGXV X-Received: by 2002:a05:6214:3007:b0:68f:5d27:4291 with SMTP id ke7-20020a056214300700b0068f5d274291mr3588430qvb.64.1709088869398; Tue, 27 Feb 2024 18:54:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709088869; cv=pass; d=google.com; s=arc-20160816; b=zTQ+zX7OUR0GemByN5W2n+ysfrD0S5TO0IZ2tYJAO/G1qeUN10sgBnjeVKrPjajWF7 7pzJ+nuCXMIJHTVOV8oQjWtc91LvKlz0om0OvpqaN9j6TQTNc8htGlSrQhA7OIq/lAk/ cJqfIC3Y2oPjYKSPIqbagJE5fJeIOpwrRsMYmrg4d4bIT0ysBIRlVzFLwRXacoCTZHuq knvcZ4TiBUxRIzOCqRKqdRK8pB8rZBj1OojtJw16Q8CJCnpgNk116D5PpWkejafCE4Su 6MyW2yC69vYLHh7hsw2MwEgjhrlYnieW2cBGxgFaPwT5w7eNsyN2SQKacZ/lbJyzXfed hdUA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=y5EvSUMgenoYj2Iozn0EnqUOzpsei+cfPHl0sSALKQ4=; fh=uWu9MeyGkywR165s6yDWPgkXRNiae1Qrt207vzeAVio=; b=08IJJeD54WAzlAzENtwIIHOLyW/g0yp09M4SrhpXQmx+AZYkt4hUzQUsndGcC0KQtm TPO55JOswpUyV3qcykLDYBC3IGuS6uQxX2ku8D9hZkZRCUeLUccYnr+5CQtAp4MAY+uV Z8ryVM+pEZJy7mw8RVjEvKX2UzZRbyHhp2P+smCyuH/Hxk+OU5Q6U1w7l1TgrRUT7/qE GwGNKHrNmTImRsJoLRzvcfFFmnUyCJMLonQEimqnplCEefWt/aaxSTo5vi8rZOwT+++R AFcdC2plPi4EswdHtcbqbvS5tkdDK7NNQc0oWf4KflMYx6mLi++nLWdTuqQWz9h1+CZJ 3Ncw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TuUZR64z; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84452-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84452-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 gu7-20020a056214260700b0068fe77ac562si10075187qvb.294.2024.02.27.18.54.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 18:54:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84452-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=TuUZR64z; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84452-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84452-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 150BC1C246D2 for ; Wed, 28 Feb 2024 02:54:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B4861CFAB; Wed, 28 Feb 2024 02:54:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="TuUZR64z" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 27C091CD0F; Wed, 28 Feb 2024 02:54:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709088861; cv=none; b=h6jdOmB6ZYeaQp2VQpW92a9zMm8C0fj5bFpyEX/aXQsRvrexAmMY1f5tvjOhPLTDk3AaoOOlQDDtq+F53DV1Z5OI/3qnOIE/C9W46cNpzGcAGbfDZenReU0lSZ3WDFB3on7DS59a5hq5nC4SUi7H95bH+trPoGhHlRywiC8Ouas= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709088861; c=relaxed/simple; bh=DcplYvg9YXEcB4+RqfeA3kQTbwDp+wkHlaKrY7RctWg=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=qzSg7xTpxI14fok0BtTJxgjZw7PJHQyPRIbvEMSYi+xY1Wx6HCyCiXRwWHFRrVbEVYU2sPowWTu/N83kPuoN3UqXYg3JnPm6kaBPT4lHGEMMa82t4+4fyWf9vSAZ/AY275tSr836X0MH9LM7WLzyEPYTcGA7+05gGGn12BQAweU= 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=TuUZR64z; arc=none smtp.client-ip=192.198.163.15 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=1709088859; x=1740624859; h=message-id:date:mime-version:subject:to:references:from: in-reply-to:content-transfer-encoding; bh=DcplYvg9YXEcB4+RqfeA3kQTbwDp+wkHlaKrY7RctWg=; b=TuUZR64z+oozVqXme4TMA2i/zanHKazWaY1+AXke3mDm0YnP15h7oiTA Fp9jujkPoXckY1MnYFvX9mSsvjYv8nPkbYx7mqNEMjnoEYZtgfyIRX+b7 EEC9AI4lmsrjBV97+H1WD91d5Hbf6bjQxL89Svc1x7ALWr3tbDKsj6bqr ruuGNaofd6KzGSM2YdFte7yzWeeSbduWi4LjCABKOX2/+SRkiXayLfU6q /W/M/omubGewkvMsdgd3OXAeNGHAkLEQwumModoBdlhR6v9FQHBzI9FCN 9YIsbyc1bAgObZDoopIPvKR7Ze+rwX9MkTctt0ob/CHIEN+A1eRgBLgq7 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="3632870" X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="3632870" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 18:54:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="44785267" Received: from dschro4x-mobl.amr.corp.intel.com (HELO [10.212.137.190]) ([10.212.137.190]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 18:54:17 -0800 Message-ID: <75594a83-0d7c-4106-8f06-d940dcff02df@linux.intel.com> Date: Tue, 27 Feb 2024 18:54:17 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH V2 5/9] tools/arch/x86/intel_sdsi: Fix maximum meter bundle length Content-Language: en-US To: "David E. Box" , rajvi.jingar@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com References: <20240228000016.1685518-1-david.e.box@linux.intel.com> <20240228000016.1685518-6-david.e.box@linux.intel.com> From: Kuppuswamy Sathyanarayanan In-Reply-To: <20240228000016.1685518-6-david.e.box@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2/27/24 4:00 PM, David E. Box wrote: > 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); I think you can avoid hardcoding here as well. sizeof(struct bundle_encoding_counter) > return -1; > } -- Sathyanarayanan Kuppuswamy Linux Kernel Developer