mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-24 09:50:04 +00:00
userfaultfd: selftest: avoid my_bcmp false positives with powerpc
Keep a non-zero placeholder after the count, for the my_bcmp comparison of the page against the zeropage. The lockless increment between 255 to 256 against a lockless my_bcmp could otherwise return false positives on ppc32le. Signed-off-by: Andrea Arcangeli <aarcange@redhat.com> Tested-by: Michael Ellerman <mpe@ellerman.id.au> Cc: Dr. David Alan Gilbert <dgilbert@redhat.com> Cc: Shuah Khan <shuahkh@osg.samsung.com> Cc: Thierry Reding <treding@nvidia.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
56ed8f169e
commit
1f5fee2cf2
1 changed files with 10 additions and 2 deletions
|
@ -465,6 +465,14 @@ static int userfaultfd_stress(void)
|
||||||
*area_mutex(area_src, nr) = (pthread_mutex_t)
|
*area_mutex(area_src, nr) = (pthread_mutex_t)
|
||||||
PTHREAD_MUTEX_INITIALIZER;
|
PTHREAD_MUTEX_INITIALIZER;
|
||||||
count_verify[nr] = *area_count(area_src, nr) = 1;
|
count_verify[nr] = *area_count(area_src, nr) = 1;
|
||||||
|
/*
|
||||||
|
* In the transition between 255 to 256, powerpc will
|
||||||
|
* read out of order in my_bcmp and see both bytes as
|
||||||
|
* zero, so leave a placeholder below always non-zero
|
||||||
|
* after the count, to avoid my_bcmp to trigger false
|
||||||
|
* positives.
|
||||||
|
*/
|
||||||
|
*(area_count(area_src, nr) + 1) = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pipefd = malloc(sizeof(int) * nr_cpus * 2);
|
pipefd = malloc(sizeof(int) * nr_cpus * 2);
|
||||||
|
@ -610,8 +618,8 @@ int main(int argc, char **argv)
|
||||||
fprintf(stderr, "Usage: <MiB> <bounces>\n"), exit(1);
|
fprintf(stderr, "Usage: <MiB> <bounces>\n"), exit(1);
|
||||||
nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
|
nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
page_size = sysconf(_SC_PAGE_SIZE);
|
page_size = sysconf(_SC_PAGE_SIZE);
|
||||||
if ((unsigned long) area_count(NULL, 0) + sizeof(unsigned long long) >
|
if ((unsigned long) area_count(NULL, 0) + sizeof(unsigned long long) * 2
|
||||||
page_size)
|
> page_size)
|
||||||
fprintf(stderr, "Impossible to run this test\n"), exit(2);
|
fprintf(stderr, "Impossible to run this test\n"), exit(2);
|
||||||
nr_pages_per_cpu = atol(argv[1]) * 1024*1024 / page_size /
|
nr_pages_per_cpu = atol(argv[1]) * 1024*1024 / page_size /
|
||||||
nr_cpus;
|
nr_cpus;
|
||||||
|
|
Loading…
Reference in a new issue