From: Sandipan Das <sandipan.das@amd.com>
To: Stephane Eranian <eranian@google.com>
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org,
ananth.narayan@amd.com, ravi.bangoria@amd.com
Subject: Re: [PATCH 1/2] perf/x86/utils: fix uninitialized var in get_branch_type()
Date: Thu, 29 Sep 2022 12:30:10 +0530 [thread overview]
Message-ID: <c63414d8-57e1-69d4-a180-746e415289c1@amd.com> (raw)
In-Reply-To: <20220928184043.408364-2-eranian@google.com>
On 9/29/2022 12:10 AM, Stephane Eranian wrote:
> offset is passed as a pointer and on certain call path is not set by the
> function. If the caller does not re-initialize offset between calls, value
> could be inherited between calls. Prevent this by initializing offset on each
> call.
> This impacts the code in amd_pmu_lbr_filter() which does
> for(i=0; ...) {
> ret = get_branch_type_fused(..., &offset);
> if (offset)
> lbr_entries[i].from += offset;
> }
>
> Signed-off-by: Stephane Eranian <eranian@google.com>
> ---
> arch/x86/events/utils.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/arch/x86/events/utils.c b/arch/x86/events/utils.c
> index 5f5617afde79..76b1f8bb0fd5 100644
> --- a/arch/x86/events/utils.c
> +++ b/arch/x86/events/utils.c
> @@ -94,6 +94,10 @@ static int get_branch_type(unsigned long from, unsigned long to, int abort,
> u8 buf[MAX_INSN_SIZE];
> int is64 = 0;
>
> + /* make sure we initialize offset */
> + if (offset)
> + *offset = 0;
> +
> to_plm = kernel_ip(to) ? X86_BR_KERNEL : X86_BR_USER;
> from_plm = kernel_ip(from) ? X86_BR_KERNEL : X86_BR_USER;
>
Reviewed-by: Sandipan Das <sandipan.das@amd.com>
next prev parent reply other threads:[~2022-09-29 7:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-28 18:40 [PATCH 0/2] perf/x86/amd/lbr: fix LBR filtering support Stephane Eranian
2022-09-28 18:40 ` [PATCH 1/2] perf/x86/utils: fix uninitialized var in get_branch_type() Stephane Eranian
2022-09-29 7:00 ` Sandipan Das [this message]
2022-09-30 9:31 ` [tip: perf/core] perf/x86/utils: Fix " tip-bot2 for Stephane Eranian
2022-09-28 18:40 ` [PATCH 2/2] perf/x86/amd/lbr: adjust LBR regardless of filtering Stephane Eranian
2022-09-29 7:01 ` Sandipan Das
2022-09-30 9:31 ` [tip: perf/core] perf/x86/amd/lbr: Adjust " tip-bot2 for Stephane Eranian
2022-09-29 8:14 ` [PATCH 0/2] perf/x86/amd/lbr: fix LBR filtering support Peter Zijlstra
2022-09-29 8:30 ` Sandipan Das
2022-09-29 10:19 ` Peter Zijlstra
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=c63414d8-57e1-69d4-a180-746e415289c1@amd.com \
--to=sandipan.das@amd.com \
--cc=ananth.narayan@amd.com \
--cc=eranian@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=ravi.bangoria@amd.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®