arch: arc: fix the bug where buffer validate should be atomic
reported by #22290 and similar to #22275, the access to mpu regs in buffer validate should be atomic. Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
This commit is contained in:
parent
8450d26b34
commit
d1fa27c42f
1 changed files with 8 additions and 4 deletions
|
@ -656,7 +656,7 @@ int arc_core_mpu_get_max_domain_partition_regions(void)
|
||||||
int arc_core_mpu_buffer_validate(void *addr, size_t size, int write)
|
int arc_core_mpu_buffer_validate(void *addr, size_t size, int write)
|
||||||
{
|
{
|
||||||
int r_index;
|
int r_index;
|
||||||
|
int key = arch_irq_lock();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For ARC MPU v3, overlapping is not supported.
|
* For ARC MPU v3, overlapping is not supported.
|
||||||
|
@ -667,13 +667,17 @@ int arc_core_mpu_buffer_validate(void *addr, size_t size, int write)
|
||||||
/* match and the area is in one region */
|
/* match and the area is in one region */
|
||||||
if (r_index >= 0 && r_index == _mpu_probe((u32_t)addr + (size - 1))) {
|
if (r_index >= 0 && r_index == _mpu_probe((u32_t)addr + (size - 1))) {
|
||||||
if (_is_user_accessible_region(r_index, write)) {
|
if (_is_user_accessible_region(r_index, write)) {
|
||||||
return 0;
|
r_index = 0;
|
||||||
} else {
|
} else {
|
||||||
return -EPERM;
|
r_index = -EPERM;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
r_index = -EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -EPERM;
|
arch_irq_unlock(key);
|
||||||
|
|
||||||
|
return r_index;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_USERSPACE */
|
#endif /* CONFIG_USERSPACE */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue