On 4/6/26 7:46 PM, Mike Rapoport wrote:
> From: "Mike Rapoport (Microsoft)" <[email protected]>
> 
> Access of poisoned memory causes SIGBUS, which terminates the
> hugetlb-read-hwpoison test prematurely.
> 
> Add a dummy SIGBUS handler to allow the test to continue regardless of
> SIGBUS.
> 
> Signed-off-by: Mike Rapoport (Microsoft) <[email protected]>
> ---

I have tested this patch and it behaves as intended.

Before applying the patch, the HWPOISON test terminated with a Bus error
when accessing poisoned memory. After applying the patch, the test
catches SIGBUS, reports it and continues execution without terminating
prematurely.

Tested-by: Sarthak Sharma <[email protected]>

>  tools/testing/selftests/mm/hugetlb-read-hwpoison.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/tools/testing/selftests/mm/hugetlb-read-hwpoison.c 
> b/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
> index 46230462ad48..6bbf15f78061 100644
> --- a/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
> +++ b/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
> @@ -10,6 +10,7 @@
>  #include <sys/statfs.h>
>  #include <errno.h>
>  #include <stdbool.h>
> +#include <signal.h>
>  
>  #include "kselftest.h"
>  
> @@ -261,6 +262,11 @@ static int create_hugetlbfs_file(struct statfs 
> *file_stat)
>       return -1;
>  }
>  
> +static void sigbus_handler(int sig)
> +{
> +     printf(PREFIX "received SIGBUS\n");
> +}
> +
>  int main(void)
>  {
>       int fd;
> @@ -273,6 +279,7 @@ int main(void)
>       };
>       size_t i;
>  
> +     signal(SIGBUS, sigbus_handler);
>       for (i = 0; i < ARRAY_SIZE(wr_chunk_sizes); ++i) {
>               printf("Write/read chunk size=0x%lx\n",
>                      wr_chunk_sizes[i]);


Reply via email to