Skip to content

Commit d1fa27c

Browse files
Wayne Renandrewboie
authored andcommitted
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 <[email protected]>
1 parent 8450d26 commit d1fa27c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

arch/arc/core/mpu/arc_mpu_v3_internal.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ int arc_core_mpu_get_max_domain_partition_regions(void)
656656
int arc_core_mpu_buffer_validate(void *addr, size_t size, int write)
657657
{
658658
int r_index;
659-
659+
int key = arch_irq_lock();
660660

661661
/*
662662
* 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)
667667
/* match and the area is in one region */
668668
if (r_index >= 0 && r_index == _mpu_probe((u32_t)addr + (size - 1))) {
669669
if (_is_user_accessible_region(r_index, write)) {
670-
return 0;
670+
r_index = 0;
671671
} else {
672-
return -EPERM;
672+
r_index = -EPERM;
673673
}
674+
} else {
675+
r_index = -EPERM;
674676
}
675677

676-
return -EPERM;
678+
arch_irq_unlock(key);
679+
680+
return r_index;
677681
}
678682
#endif /* CONFIG_USERSPACE */
679683

0 commit comments

Comments
 (0)