Skip to content

Commit bb1656a

Browse files
dcpleungcfriedt
authored andcommitted
tests: mem_protect/userspace: _k_neg_eagain maybe in pinned sect
If pinned section is enabled, _k_neg_eagain should be in pinned rodata section. So add the check if pinned section is enabled. Signed-off-by: Daniel Leung <[email protected]>
1 parent 46ae0a5 commit bb1656a

File tree

1 file changed

+14
-2
lines changed
  • tests/kernel/mem_protect/userspace/src

1 file changed

+14
-2
lines changed

tests/kernel/mem_protect/userspace/src/main.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,24 @@ extern int _k_neg_eagain;
288288
*/
289289
static void test_write_kernro(void)
290290
{
291+
bool in_rodata;
292+
291293
/* Try to write to kernel RO. */
292294
const char *const ptr = (const char *const)&_k_neg_eagain;
293295

294-
zassert_true(ptr < _image_rodata_end &&
295-
ptr >= _image_rodata_start,
296+
in_rodata = ptr < _image_rodata_end &&
297+
ptr >= _image_rodata_start;
298+
299+
#ifdef CONFIG_LINKER_USE_PINNED_SECTION
300+
if (!in_rodata) {
301+
in_rodata = ptr < lnkr_pinned_rodata_end &&
302+
ptr >= lnkr_pinned_rodata_start;
303+
}
304+
#endif
305+
306+
zassert_true(in_rodata,
296307
"_k_neg_eagain is not in rodata");
308+
297309
set_fault(K_ERR_CPU_EXCEPTION);
298310

299311
_k_neg_eagain = -EINVAL;

0 commit comments

Comments
 (0)