From: Wang ShaoBo bobo.shaobowang@huawei.com
hulk inclusion category: feature bugzilla: 34278 CVE: NA
-------------------------------------------------
This prepares for simultaneously monitoring LxDATA and LxCODE when cdp is open, under our implementation, LxDATA and LxCODE is allocated closid and closid+1, so we should keep two monitor once time for each.
Why there needs one monitors for each closid when cdp is open, but not switch one between the two LxDATA and LxCODE is because this monitor kept by target closid maybe busy for a long time, it would cause inaccuracy if we force switching.
Signed-off-by: Wang ShaoBo bobo.shaobowang@huawei.com Reviewed-by: Xiongfeng Wang wangxiongfeng2@huawei.com Reviewed-by: Cheng Jian cj.chengjian@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com Signed-off-by: Cheng Jian cj.chengjian@huawei.com --- arch/arm64/kernel/mpam/mpam_mon.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/kernel/mpam/mpam_mon.c b/arch/arm64/kernel/mpam/mpam_mon.c index f952e9aa20c2..297169b41ea3 100644 --- a/arch/arm64/kernel/mpam/mpam_mon.c +++ b/arch/arm64/kernel/mpam/mpam_mon.c @@ -93,20 +93,28 @@ void mon_init(void)
int alloc_mon(void) { - u32 mon = ffs(mon_free_map); + u32 mon = 0; + u32 times, flag;
+ hw_alloc_times_validate(mon, times, flag); + + mon = ffs(mon_free_map); if (mon == 0) return -ENOSPC;
mon--; - mon_free_map &= ~(1 << mon); + mon_free_map &= ~(GENMASK(mon, mon + times - 1));
return mon; }
void free_mon(u32 mon) { - mon_free_map |= 1 << mon; + u32 times, flag; + + hw_alloc_times_validate(mon, times, flag); + + mon_free_map |= GENMASK(mon, mon + times - 1); }
/*