mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Paul Menzel <pmenzel@molgen.mpg.de>
Cc: "Rajneesh Bhardwaj" <irenic.rajneesh@gmail.com>,
	"Xi Pardee" <xi.pardee@linux.intel.com>,
	"Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Rajneesh Bhardwaj" <rajneesh.bhardwaj@linux.intel.com>,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] platform/x86/intel/pmc: Do not decode the summary rows in ltr_show
Date: Wed, 25 Nov 2026 12:21:14 +0200	[thread overview]
Message-ID: <awa2msC9gJdMsyu3@ashevche-desk.local> (raw)
In-Reply-To: <1834d646-431b-4422-9909-d24ac8ce57a3@molgen.mpg.de>

On Wed, Nov 25, 2026 at 12:19:45AM +0100, Paul Menzel wrote:
> Am 23.11.26 um 09:26 schrieb Andy Shevchenko:
> > On Sat, Nov 21, 2026 at 10:06:11AM +0100, Paul Menzel wrote:
> > > On an Intel Tiger Lake laptop Dell XPS 13 9310, the first read of

...

> > > +/*
> > > + * Every ltr_show map ends with CURRENT_PLATFORM and AGGREGATED_SYSTEM. Unlike
> > > + * the per-IP rows, these PMC registers do not hold an LTR message payload as
> > > + * defined by PCIe; on Tiger Lake, for example, AGGREGATED_SYSTEM has the
> > > + * reserved bits 14:13 set and reads 0x7fffdff. Do not decode them.
> > > + */
> > > +static bool pmc_core_ltr_is_summary(const struct pmc_bit_map *map,
> > > +				    unsigned int index)
> > > +{
> > > +	return !map[index + 1].name || !map[index + 2].name;
> > 
> > How do we know that the index is not out-of-boundary?

(My point was that you are iterating up to the record which has
map[index].name == NULL, but when iterating the previous one,
map[index + 2] is out of boundary.)

> The maps end with a { } sentinel, and the caller runs only for an index with
> map[index].name set, so map[index + 1] is the sentinel at the latest.
> map[index + 2] is only read if map[index + 1].name is set, so it is the
> sentinel at the latest, too. But indeed, it is not obvious when reading the
> code, so v2 counts the rows of the map once before the loop and checks
> `index + 2 >= num_rows` instead; the helper is gone.

So it heavily relies on a side-effect of || operation. This is fragile
approach.

> > > +}

-- 
With Best Regards,
Andy Shevchenko



      reply	other threads:[~2026-11-25 10:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21  9:06 Paul Menzel
2026-11-21  9:06 ` [PATCH 2/2] platform/x86/intel/pmc: Fix Tiger Lake LTR ignore maximum to 22 Paul Menzel
2026-11-23  8:26 ` [PATCH 1/2] platform/x86/intel/pmc: Do not decode the summary rows in ltr_show Andy Shevchenko
2026-11-24 23:19   ` Paul Menzel
2026-11-25 10:21     ` Andy Shevchenko [this message]

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=awa2msC9gJdMsyu3@ashevche-desk.local \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=hansg@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=irenic.rajneesh@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=pmenzel@molgen.mpg.de \
    --cc=rajneesh.bhardwaj@linux.intel.com \
    --cc=xi.pardee@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

all inboxes | Powered by JetHome®