From 99a5d0fd340748ace6585f84fd88c173a31a6a84 Mon Sep 17 00:00:00 2001 From: Yi Sun Date: Tue, 1 Aug 2017 11:05:00 +0200 Subject: [PATCH] x86: refactor psr: CDP: implement set value callback function. This patch implements L3 CDP set value related callback function. With this patch, 'psr-cat-cbm-set' command can work for L3 CDP. Signed-off-by: Yi Sun Reviewed-by: Jan Beulich --- xen/arch/x86/psr.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index b86271c5cc..1080642450 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -374,6 +374,10 @@ static bool l3_cdp_get_feat_info(const struct feat_node *feat, static void l3_cdp_write_msr(unsigned int cos, uint32_t val, enum cbm_type type) { + wrmsrl(((type == PSR_CBM_TYPE_L3_DATA) ? + MSR_IA32_PSR_L3_MASK_DATA(cos) : + MSR_IA32_PSR_L3_MASK_CODE(cos)), + val); } static const struct feat_props l3_cdp_props = { @@ -829,17 +833,27 @@ static int insert_val_into_array(uint32_t val[], if ( !psr_check_cbm(feat->cbm_len, new_val) ) return -EINVAL; - /* Value setting position is same as feature array. */ + /* + * Value setting position is same as feature array. + * For CDP, user may set both DATA and CODE to same value. For such case, + * user input 'PSR_CBM_TYPE_L3' as type. The alternative type of CDP is same + * as it. So we should set new_val to both of DATA and CODE under such case. + */ for ( i = 0; i < props->cos_num; i++ ) { if ( type == props->type[i] ) { val[i] = new_val; - return 0; + ret = 0; + break; } + else if ( type == props->alt_type ) + val[i] = new_val; + else + ret = -EINVAL; } - return -EINVAL; + return ret; } static int compare_val(const uint32_t val[], -- 2.30.2