lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 1 May 2022 23:07:14 -0700
From:   Namhyung Kim <namhyung@...nel.org>
To:     Ravi Bangoria <ravi.bangoria@....com>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Dmitry Monakhov <dmtrmonakhov@...dex-team.ru>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Ingo Molnar <mingo@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        Jiri Olsa <jolsa@...nel.org>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Borislav Petkov <bp@...en8.de>, dave.hansen@...ux.intel.com,
        "H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
        linux-perf-users <linux-perf-users@...r.kernel.org>,
        linux-kernel <linux-kernel@...r.kernel.org>,
        sandipan.das@....com, ananth.narayan@....com,
        Kim Phillips <kim.phillips@....com>, santosh.shukla@....com,
        Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH] perf/amd/ibs: Use interrupt regs ip for stack unwinding

Hello,

On Thu, Apr 28, 2022 at 10:15 PM Ravi Bangoria <ravi.bangoria@....com> wrote:
>
> IbsOpRip is recorded when IBS interrupt is triggered. But there is
> a skid from the time IBS interrupt gets triggered to the time the
> interrupt is presented to the core. Meanwhile processor would have
> moved ahead and thus IbsOpRip will be inconsistent with rsp and rbp
> recorded as part of the interrupt regs. This causes issues while
> unwinding stack using the ORC unwinder as it needs consistent rip,
> rsp and rbp. Fix this by using rip from interrupt regs instead of
> IbsOpRip for stack unwinding.
>
> Fixes: ee9f8fce99640 ("x86/unwind: Add the ORC unwinder")
> Reported-by: Dmitry Monakhov <dmtrmonakhov@...dex-team.ru>
> Suggested-by: Peter Zijlstra <peterz@...radead.org>
> Signed-off-by: Ravi Bangoria <ravi.bangoria@....com>

Acked-by: Namhyung Kim <namhyung@...nel.org>

Thanks,
Namhyung


> ---
>  arch/x86/events/amd/ibs.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
>
> diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
> index 9739019d4b67..171941043f53 100644
> --- a/arch/x86/events/amd/ibs.c
> +++ b/arch/x86/events/amd/ibs.c
> @@ -304,6 +304,16 @@ static int perf_ibs_init(struct perf_event *event)
>         hwc->config_base = perf_ibs->msr;
>         hwc->config = config;
>
> +       /*
> +        * rip recorded by IbsOpRip will not be consistent with rsp and rbp
> +        * recorded as part of interrupt regs. Thus we need to use rip from
> +        * interrupt regs while unwinding call stack. Setting _EARLY flag
> +        * makes sure we unwind call-stack before perf sample rip is set to
> +        * IbsOpRip.
> +        */
> +       if (event->attr.sample_type & PERF_SAMPLE_CALLCHAIN)
> +               event->attr.sample_type |= __PERF_SAMPLE_CALLCHAIN_EARLY;
> +
>         return 0;
>  }
>
> @@ -687,6 +697,14 @@ static int perf_ibs_handle_irq(struct perf_ibs *perf_ibs, struct pt_regs *iregs)
>                 data.raw = &raw;
>         }
>
> +       /*
> +        * rip recorded by IbsOpRip will not be consistent with rsp and rbp
> +        * recorded as part of interrupt regs. Thus we need to use rip from
> +        * interrupt regs while unwinding call stack.
> +        */
> +       if (event->attr.sample_type & PERF_SAMPLE_CALLCHAIN)
> +               data.callchain = perf_callchain(event, iregs);
> +
>         throttle = perf_event_overflow(event, &data, &regs);
>  out:
>         if (throttle) {
> --
> 2.27.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ