From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chao Peng Subject: Re: [PATCH v6 2/3] x86: add domctl cmd to set/get CDP code/data CBM Date: Sat, 10 Oct 2015 14:11:53 +0800 Message-ID: <20151010061153.GD18953@pengc-linux.bj.intel.com> References: <1444274637-6104-1-git-send-email-he.chen@linux.intel.com> <1444274637-6104-3-git-send-email-he.chen@linux.intel.com> Reply-To: Chao Peng Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZknSI-0003M4-Oj for xen-devel@lists.xenproject.org; Sat, 10 Oct 2015 06:16:30 +0000 Content-Disposition: inline In-Reply-To: <1444274637-6104-3-git-send-email-he.chen@linux.intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: He Chen Cc: wei.liu2@citrix.com, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, jbeulich@suse.com, xen-devel@lists.xenproject.org, keir@xen.org List-Id: xen-devel@lists.xenproject.org On Thu, Oct 08, 2015 at 11:23:56AM +0800, He Chen wrote: > CDP extends CAT and provides the capacity to control L3 code & data > cache. With CDP, one COS corresponds to two CMBs(code & data). cbm_type > is added to distinguish different CBM operations. Besides, new domctl > cmds are introdunced to support set/get CDP CBM. Some CAT functions to > operation CBMs are extended to support CDP. > > Signed-off-by: He Chen > Reviewed-by: Andrew Cooper > --- > Changes in v6: > * remove variable need_write and restruct code in psr_set_l3_cbm > * remove redundant type == PSR_CBM_TYPE_L3 in psr_get_l3_cbm Looks good to me. Just several coding style issues. With that fixed: Reviewed-by: Chao Peng > +static int find_cos(struct psr_cat_cbm *map, unsigned int cos_max, > + uint64_t cbm_code, uint64_t cbm_data, bool_t cdp_enabled) > +{ > + unsigned int cos; > + > + for ( cos = 0; cos <= cos_max; cos++ ) > + { > + if( map[cos].ref && ^ space > + ((!cdp_enabled && map[cos].cbm == cbm_code) || > + (cdp_enabled && map[cos].code == cbm_code && > + map[cos].data == cbm_data))) ^space > + return cos; > + } > + > + return -ENOENT; > +} > @@ -371,53 +450,71 @@ int psr_set_l3_cbm(struct domain *d, unsigned int socket, uint64_t cbm) > if ( !psr_check_cbm(info->cbm_len, cbm) ) > return -EINVAL; > > + if ( !cdp_enabled && (type == PSR_CBM_TYPE_L3_CODE || > + type == PSR_CBM_TYPE_L3_DATA) ) > + return -ENXIO; > + > + cos_max = info->cos_max; > old_cos = d->arch.psr_cos_ids[socket]; > map = info->cos_to_cbm; > > - spin_lock(&info->cbm_lock); > - > - for ( cos = 0; cos <= info->cos_max; cos++ ) > + switch( type ) ^ space > + > + /* We try to avoid writing MSR. */ > + if ( (cdp_enabled && > + (map[cos].code != cbm_code || map[cos].data != cbm_data)) || > + (!cdp_enabled && map[cos].cbm != cbm_code)) ^ space > + {