x86: refactor psr: CDP: implement set value callback function.
authorYi Sun <yi.y.sun@linux.intel.com>
Tue, 1 Aug 2017 09:05:00 +0000 (11:05 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 3 Aug 2017 10:36:25 +0000 (12:36 +0200)
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 <yi.y.sun@linux.intel.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/psr.c

index b86271c5ccb09a44888ab3cacf0e8f3afcb6625c..108064245085957e51d70416a5e0a8e3f96f9983 100644 (file)
@@ -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[],