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>] [day] [month] [year] [list]
Date:   Fri, 10 Nov 2017 15:36:03 -0800
From:   Megha Dey <megha.dey@...el.com>
To:     Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc:     x86@...nel.org, linux-kernel@...r.kernel.org,
        linux-doc@...r.kernel.org, tglx@...utronix.de, mingo@...hat.com,
        hpa@...or.com, andriy.shevchenko@...ux.intel.com,
        kstewart@...uxfoundation.org, yu-cheng.yu@...el.com,
        len.brown@...el.com, gregkh@...uxfoundation.org,
        peterz@...radead.org, acme@...nel.org, jolsa@...hat.com,
        namhyung@...nel.org, vikas.shivappa@...ux.intel.com,
        pombredanne@...b.com, me@...ehuey.com, bp@...e.de,
        grzegorz.andrejczuk@...el.com, tony.luck@...el.com, corbet@....net,
        ravi.v.shankar@...el.com
Subject: Re: [PATCH V0 2/3] perf/x86/intel/bm.c: Add Intel Branch Monitoring
 support

On Mon, 2017-11-06 at 13:49 +0200, Alexander Shishkin wrote:
> On Fri, Nov 03, 2017 at 11:00:05AM -0700, Megha Dey wrote:
> > +static int intel_bm_event_init(struct perf_event *event)
> > +{
> 
> ...
> 
> > +	/*
> > +	 * Find a hardware counter for the target task
> > +	 */
> > +	for (i = 0; i < bm_num_counters; i++) {
> > +		if ((bm_counter_owner[i] == NULL) ||
> > +			(bm_counter_owner[i]->state == PERF_EVENT_STATE_DEAD)) {
> > +			counter_to_use = i;
> > +			bm_counter_owner[i] = event;
> > +			break;
> 
> How are two concurrent perf_event_open()s not going to race here?
> Also, I'm not sure what's the value of looking at the ->state here.
> Shouldn't the ->destroy() method clear the corresponding array slot?

Yes you are right. I will add a locking mechanism here to prevent racing
and remove the ->state in the next version.
> 
> > +		}
> > +	}
> 
> ...
> 
> > +	wrmsrl(BR_DETECT_COUNTER_CONFIG_BASE + counter_to_use,
> > +						event->hw.bm_counter_conf);
> > +	wrmsrl(BR_DETECT_STATUS_MSR, 0);
> 
> These wrmsrs will happen on whatever CPU perf_event_open() is called on,
> as opposed to the CPU where the event will be scheduled. You probably want
> to keep the MSR accesses in the start()/stop() callbacks.

Agreed, don't think we need this code here. We are writing to the MSRs
in start() anyways.
> 
> Regards,
> --
> Alex
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ