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] [day] [month] [year] [list]
Message-ID: <CA+7sy7D-ZB84xQ2pE-io1v7pmnAuWUszh1B=Zq+Ezup=sysQ2g@mail.gmail.com>
Date:   Wed, 26 Apr 2017 12:23:39 +0530
From:   "Jayachandran C." <c.jayachandran@...il.com>
To:     Will Deacon <will.deacon@....com>
Cc:     Ganapatrao Kulkarni <gpkulkarni@...il.com>,
        Mark Rutland <mark.rutland@....com>,
        "Andrew.Pinski@...iumnetworks.com" <Andrew.Pinski@...iumnetworks.com>,
        Catalin Marinas <catalin.marinas@....com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        acme@...nel.org, alexander.shishkin@...ux.intel.com,
        peterz@...radead.org, Ingo Molnar <mingo@...hat.com>,
        jnair@...iumnetworks.com,
        Ganapatrao Kulkarni <ganapatrao.kulkarni@...ium.com>,
        "linux-arm-kernel@...ts.infradead.org" 
        <linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH v2] arm64: perf: Use only exclude_kernel attribute when
 kernel is running in HYP

Hi Will,

On Tue, Apr 25, 2017 at 10:23 PM, Will Deacon <will.deacon@....com> wrote:
> On Tue, Apr 25, 2017 at 09:13:40AM +0530, Ganapatrao Kulkarni wrote:
>> On Mon, Apr 24, 2017 at 9:15 PM, Will Deacon <will.deacon@....com> wrote:
>> > On Thu, Apr 20, 2017 at 02:56:50PM +0530, Ganapatrao Kulkarni wrote:
>> >> On Thu, Apr 20, 2017 at 2:19 PM, Mark Rutland <mark.rutland@....com> wrote:
>> >> > On Wed, Apr 19, 2017 at 11:14:06PM +0530, Ganapatrao Kulkarni wrote:
>> >> >> commit d98ecda (arm64: perf: Count EL2 events if the kernel is running in HYP)
>> >> >> is returning error for perf syscall with mixed attribute set for exclude_kernel
>> >> >> and exclude_hv. This change is breaking some applications (observed with hhvm)
>> >> >> when ran on VHE enabled platforms.
>> >> >>
>> >> >> Adding fix to consider only exclude_kernel attribute when kernel is
>> >> >> running in HYP. Also adding sysfs file to notify the bhehaviour
>> >> >> of attribute exclude_hv.
>> >> >>
>> >> >> Signed-off-by: Ganapatrao Kulkarni <ganapatrao.kulkarni@...ium.com>
>> >> >> ---
>> >> >>
>> >> >> Changelog:
>> >> >>
>> >> >> V2:
>> >> >>  - Changes as per Will Deacon's suggestion.
>> >> >>
>> >> >> V1: Initial patch
>> >> >>
>> >> >>  arch/arm64/kernel/perf_event.c | 28 ++++++++++++++++++++++++----
>> >> >>  include/linux/perf/arm_pmu.h   |  1 +
>> >> >>  2 files changed, 25 insertions(+), 4 deletions(-)
>> >> >>
>> >> >> @@ -871,14 +890,13 @@ static int armv8pmu_set_event_filter(struct hw_perf_event *event,
>> >> >>
>> >> >>       if (attr->exclude_idle)
>> >> >>               return -EPERM;
>> >> >> -     if (is_kernel_in_hyp_mode() &&
>> >> >> -         attr->exclude_kernel != attr->exclude_hv)
>> >> >> -             return -EINVAL;
>> >> >> +     if (is_kernel_in_hyp_mode() && !attr->exclude_kernel)
>> >> >> +             config_base |= ARMV8_PMU_INCLUDE_EL2;
>> >> >>       if (attr->exclude_user)
>> >> >>               config_base |= ARMV8_PMU_EXCLUDE_EL0;
>> >> >>       if (!is_kernel_in_hyp_mode() && attr->exclude_kernel)
>> >> >>               config_base |= ARMV8_PMU_EXCLUDE_EL1;
>> >> >> -     if (!attr->exclude_hv)
>> >> >> +     if (!is_kernel_in_hyp_mode() && !attr->exclude_hv)
>> >> >>               config_base |= ARMV8_PMU_INCLUDE_EL2;
>> >> >
>> >> > This isn't quite what Will suggested.
>> >> >
>> >> > The idea was that userspace would read sysfs, then use that to determine
>> >> > the correct exclusion parameters [1,2]. This logic was not expected to
>> >> > change; it correctly validates whether we can provide what the user
>> >> > requests.
>> >>
>> >> OK, if you are ok with sysfs part, i can send next version with that
>> >> change only?.
>> >
>> > I think the sysfs part is still a little dodgy, since you still expose the
>> > "exclude_hv" file with a value of 0 when not running at EL2, which would
>> > imply that exclude_hv is forced to zero. I don't think that's correct.
>>
>> okay, i can make exclude_hv visible only when kernel booted in EL2.
>> is it ok to have empty directory "attr" when kernel booted to EL1?
>> attr can be place holder for any other miscellaneous attributes, that
>> can be added in future.
>
> Sounds good to me, although I'll seek comment from the other perf folks
> before merging anything with ABI implications.

Do you really think this is the solution given:
- this is an arm64 specific sysfs interface that is tied to the perf API
- the perf API documentation has to be updated for this
- All the applications that use the perf API have to be modified to
check this sysfs interface
- If the application fails to do so, a very narrow corner case
(exclude_hv != exclude_kernel and VHE enabled) fails.

Any application that really cares can already do see if exclude_hv !=
exclude_kernel case works by calling perf_open_event() with those
options and checking the return value.

Hope I am mistake here, otherwise this does not sound like a good idea.

JC.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ