Sean Christopherson <seanjc@google.com> writes:
> Expand the guest_memfd negative testcases for overflow and MAP_PRIVATE to
> verify that reads to inaccessible memory also get a SIGBUS.
>
> Opportunistically fix the write path to use the "val" instead of hardcoding
> the literal value a second time, and to use TEST_FAIL(...) instead of
> TEST_ASSERT(false, ...).
>
The change the use "val" isn't in this patch, and I think the
TEST_FAIL() change was intended for another earlier patch.
Reviewed-by: Ackerley Tng <ackerleytng@google.com>
Tested-by: Ackerley Tng <ackerleytng@google.com>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
> tools/testing/selftests/kvm/guest_memfd_test.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/testing/selftests/kvm/guest_memfd_test.c b/tools/testing/selftests/kvm/guest_memfd_test.c
> index f5372fdf096d..e7d9aeb418d3 100644
> --- a/tools/testing/selftests/kvm/guest_memfd_test.c
> +++ b/tools/testing/selftests/kvm/guest_memfd_test.c
> @@ -84,6 +84,7 @@ static void test_fault_sigbus(int fd, size_t accessible_size, size_t map_size)
> mem = kvm_mmap(map_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd);
>
> TEST_EXPECT_SIGBUS(memset(mem, val, map_size));
> + TEST_EXPECT_SIGBUS((void)READ_ONCE(mem[accessible_size]));
>
> for (i = 0; i < accessible_size; i++)
> TEST_ASSERT_EQ(READ_ONCE(mem[i]), val);
> --
> 2.51.0.618.g983fd99d29-goog