From: Marco <cavenati.marco@gmail.com>
To: Dave Hansen <dave.hansen@intel.com>
Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
namhyung@kernel.org, mark.rutland@arm.com,
alexander.shishkin@linux.intel.com, jolsa@kernel.org,
irogers@google.com, adrian.hunter@intel.com,
kan.liang@linux.intel.com, tglx@linutronix.de, bp@alien8.de,
dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com
Subject: Re: [PATCH] perf/x86/intel/pt: Update topa_entry base len to support 52-bit physical addresses
Date: Wed, 19 Jun 2024 11:42:53 +0200 [thread overview]
Message-ID: <D68A619B-B9EB-4E68-82DC-9CA68BD082FC@gmail.com> (raw)
In-Reply-To: <efc3a224-27b3-4259-a9a3-0296ccbf3e8d@intel.com>
Hi Dave,
> On 18 Jun 2024, at 19:59, Dave Hansen <dave.hansen@intel.com> wrote:
>
> On 6/18/24 04:06, Marco Cavenati wrote:
>> Increase topa_entry base to 40 bits to accommodate page addresses in
>> systems with 52-bit physical addresses.
>> The Base Physical Address field (base) has a length of MAXPHYADDR - 12 as
>> stated in Intel's SDM chapter 33.2.7.2.
>> The maximum MAXPHYADDR is 52 as stated in SDM 4.1.4.
>> Therefore, the maximum base bit length is 40.
>
> This makes it sound like it's _adding_ support for larger physical
> addresses. It really was a bug from day one. MAXPHYADDR has been
> defined to be "at most 52" for a long, long time. I think it was well
> before 5-level paging came on the scene and actual MAXPHYADDR=52 systems
> came along.
Thank you for pointing this out, I wasn't sure about the history of
MAXPHYADDR.
> It probably needs to say something more along the lines of:
>
> topa_entry->base needs to store a pfn. It obviously needs to be
> large enough to store the largest possible x86 pfn which is
> MAXPHYADDR-PAGE_SIZE (52-12). So it is 4 bits too small.
>
> This isn't the only bug in the area:
>
>> static void *pt_buffer_region(struct pt_buffer *buf)
>> {
>> return phys_to_virt(TOPA_ENTRY(buf->cur, buf->cur_idx)->base << TOPA_SHIFT);
>> }
>
> At this point, ->base is still a 40-bit (or 36-bit before this patch)
> type. If it has anything in the high 12 bits, a <<TOPA_SHIFT will just
> lose those bits.
>
> But maybe I'm reading it wrong. If I'm right, this malfunctions at pfns
> over 36-12=24 bits, or 64GB of RAM. Is it possible nobody has ever
> allocated a 'struct pt_buffer' over 64GB? Or is this somehow tolerant
> of reading garbage?
I might be wrong but I don't think this is the case, integral promotion
should make this work fine with no truncation.
Regards,
Marco
next prev parent reply other threads:[~2024-06-19 9:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-18 11:06 [PATCH] perf/x86/intel/pt: Update topa_entry base len to support 52-bit physical addresses Marco Cavenati
2024-06-18 17:37 ` Adrian Hunter
2024-06-18 17:59 ` Dave Hansen
2024-06-19 9:42 ` Marco [this message]
2024-06-19 10:00 ` Adrian Hunter
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=D68A619B-B9EB-4E68-82DC-9CA68BD082FC@gmail.com \
--to=cavenati.marco@gmail.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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