Commit 2a2f7bdc authored by Wang ShaoBo's avatar Wang ShaoBo Committed by Zheng Zengkai
Browse files

arm64/mpam: make mbw_max/min not less than min_bw

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I61CPK


CVE: NA

--------------------------------

Do not allow min_bw below the granularity with adjusting mbw_max/min,
and with setting mbw_max/min less than min_bw, return 'Invalid argument'
directly.

Signed-off-by: default avatarWang ShaoBo <bobo.shaobowang@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
Reviewed-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 68dc7081
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -338,15 +338,11 @@ parse_bw(char *buf, struct resctrl_resource *r,
	switch (rr->ctrl_features[type].evt) {
	case QOS_MBA_MAX_EVENT_ID:
	case QOS_MBA_PBM_EVENT_ID:
		if (kstrtoul(buf, rr->ctrl_features[type].base, &data))
			return -EINVAL;
		data = (data < r->mbw.min_bw) ? r->mbw.min_bw : data;
		data = roundup(data, r->mbw.bw_gran);
		break;
	case QOS_MBA_MIN_EVENT_ID:
		if (kstrtoul(buf, rr->ctrl_features[type].base, &data))
			return -EINVAL;
		/* for mbw min feature, 0 of setting is allowed */
		if (data < r->mbw.min_bw)
			return -EINVAL;
		data = roundup(data, r->mbw.bw_gran);
		break;
	default:
+3 −0
Original line number Diff line number Diff line
@@ -419,6 +419,9 @@ static int mpam_resctrl_resource_init(struct mpam_resctrl_res *res)
		 * of 1 would appear too fine to make percentage conversions.
		 */
		r->mbw.bw_gran = GRAN_MBA_BW;
		/* do not allow mbw_max/min below mbw.bw_gran */
		if (r->mbw.min_bw < r->mbw.bw_gran)
			r->mbw.min_bw = r->mbw.bw_gran;

		/* We will only pick a class that can monitor and control */
		r->alloc_capable = true;