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]
Message-ID: <CAP-5=fXJf+1V5RF-m3e+AhK0Qg-yaJ1_2HL0CTOvp1xkK-1fDg@mail.gmail.com>
Date:   Tue, 22 Nov 2022 12:57:05 -0800
From:   Ian Rogers <irogers@...gle.com>
To:     Christophe Leroy <christophe.leroy@...roup.eu>
Cc:     "Naveen N. Rao" <naveen.n.rao@...ux.vnet.ibm.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Ravi Bangoria <ravi.bangoria@....com>,
        "linux-perf-users@...r.kernel.org" <linux-perf-users@...r.kernel.org>,
        Disha Goel <disgoel@...ux.vnet.ibm.com>,
        "linuxppc-dev@...ts.ozlabs.org" <linuxppc-dev@...ts.ozlabs.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] perf test: Skip watchpoint tests if no watchpoints available

On Tue, Nov 22, 2022 at 11:19 AM Christophe Leroy
<christophe.leroy@...roup.eu> wrote:
>
>
>
> Le 21/11/2022 à 11:27, Naveen N. Rao a écrit :
> > On IBM Power9, perf watchpoint tests fail since no hardware breakpoints
> > are available. Detect this by checking the error returned by
> > perf_event_open() and skip the tests in that case.
> >
> > Reported-by: Disha Goel <disgoel@...ux.vnet.ibm.com>
> > Signed-off-by: Naveen N. Rao <naveen.n.rao@...ux.vnet.ibm.com>
> > ---
> >   tools/perf/tests/wp.c | 12 +++++++-----
> >   1 file changed, 7 insertions(+), 5 deletions(-)
> >
> > diff --git a/tools/perf/tests/wp.c b/tools/perf/tests/wp.c
> > index 56455da30341b4..cc8719609b19ea 100644
> > --- a/tools/perf/tests/wp.c
> > +++ b/tools/perf/tests/wp.c
> > @@ -59,8 +59,10 @@ static int __event(int wp_type, void *wp_addr, unsigned long wp_len)
> >       get__perf_event_attr(&attr, wp_type, wp_addr, wp_len);
> >       fd = sys_perf_event_open(&attr, 0, -1, -1,
> >                                perf_event_open_cloexec_flag());
> > -     if (fd < 0)
> > +     if (fd < 0) {
> > +             fd = -errno;
> >               pr_debug("failed opening event %x\n", attr.bp_type);
> > +     }
>
> Do you really need that ?
>
> Can't you directly check errno in the caller ?

errno is very easily clobbered and not clearly set on success - ie,
it'd be better not to do that.

Acked-by: Ian Rogers <irogers@...gle.com>

Thanks,
Ian

> >
> >       return fd;
> >   }
> > @@ -77,7 +79,7 @@ static int test__wp_ro(struct test_suite *test __maybe_unused,
> >
> >       fd = __event(HW_BREAKPOINT_R, (void *)&data1, sizeof(data1));
> >       if (fd < 0)
> > -             return -1;
> > +             return fd == -ENODEV ? TEST_SKIP : -1;
> >
> >       tmp = data1;
> >       WP_TEST_ASSERT_VAL(fd, "RO watchpoint", 1);
> > @@ -101,7 +103,7 @@ static int test__wp_wo(struct test_suite *test __maybe_unused,
> >
> >       fd = __event(HW_BREAKPOINT_W, (void *)&data1, sizeof(data1));
> >       if (fd < 0)
> > -             return -1;
> > +             return fd == -ENODEV ? TEST_SKIP : -1;
> >
> >       tmp = data1;
> >       WP_TEST_ASSERT_VAL(fd, "WO watchpoint", 0);
> > @@ -126,7 +128,7 @@ static int test__wp_rw(struct test_suite *test __maybe_unused,
> >       fd = __event(HW_BREAKPOINT_R | HW_BREAKPOINT_W, (void *)&data1,
> >                    sizeof(data1));
> >       if (fd < 0)
> > -             return -1;
> > +             return fd == -ENODEV ? TEST_SKIP : -1;
> >
> >       tmp = data1;
> >       WP_TEST_ASSERT_VAL(fd, "RW watchpoint", 1);
> > @@ -150,7 +152,7 @@ static int test__wp_modify(struct test_suite *test __maybe_unused, int subtest _
> >
> >       fd = __event(HW_BREAKPOINT_W, (void *)&data1, sizeof(data1));
> >       if (fd < 0)
> > -             return -1;
> > +             return fd == -ENODEV ? TEST_SKIP : -1;
> >
> >       data1 = tmp;
> >       WP_TEST_ASSERT_VAL(fd, "Modify watchpoint", 1);
> >
> > base-commit: 63a3bf5e8d9e79ce456c8f73d4395a5a51d841b1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ