From 42778d9f5f82ee51eb3aef8eca610081a4c4cee0 Mon Sep 17 00:00:00 2001 From: Xie XiuQi Date: Sun, 28 Apr 2019 22:18:15 +0800 Subject: [PATCH] arm64/mpam: get num_partids from system regs instead of hard code hulk inclusion category: bugfix bugzilla: 14212 CVE: NA Previously hard coded for num of partids, now get them through the system registers. Signed-off-by: Xie XiuQi Reviewed-by: Hanjun Guo Signed-off-by: Yang Yingliang --- arch/arm64/kernel/mpam.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/mpam.c b/arch/arm64/kernel/mpam.c index dae2303b2449..44ba7ea4fda3 100644 --- a/arch/arm64/kernel/mpam.c +++ b/arch/arm64/kernel/mpam.c @@ -322,9 +322,17 @@ static int closid_free_map; void closid_init(void) { - int resctrl_min_closid = 32; + struct resctrl_resource *r; + struct raw_resctrl_resource *rr; + int num_closid = INT_MAX; - closid_free_map = BIT_MASK(resctrl_min_closid) - 1; + for_each_resctrl_resource(r) { + if (r->alloc_enabled) { + rr = r->res; + num_closid = min(num_closid, rr->num_partid); + } + } + closid_free_map = BIT_MASK(num_closid) - 1; /* CLOSID 0 is always reserved for the default group */ closid_free_map &= ~1; -- GitLab