selftests/mm: Fixed incorrect buffer->mirror size in hmm2 double_map test
PATCH 1/1 selftests/mm: Fixed incorrect buffer->mirror size in hmm2 double_map test
The hmm2 double_map test was failing due to an incorrect buffer->mirror size. The buffer->mirror size was 6, while buffer->ptr size was 6 * PAGE_SIZE. The test failed because the kernel's copy_to_user function was attempting to copy a 6 * PAGE_SIZE buffer to buffer->mirror. Since the size of buffer->mirror was incorrect, copy_to_user failed.
This patch corrects the buffer->mirror size to 6 * PAGE_SIZE.
Test Result without this patch
==============================
# RUN hmm2.hmm2_device_private.double_map ...
# hmm-tests.c:1680:double_map:Expected ret (-14) == 0 (0) # double_map: Test terminated by assertion
# FAIL hmm2.hmm2_device_private.double_map
not ok 53 hmm2.hmm2_device_private.double_map
Test Result with this patch
===========================
# RUN hmm2.hmm2_device_private.double_map ...
# OK hmm2.hmm2_device_private.double_map
ok 53 hmm2.hmm2_device_private.double_map
--- tools/testing/selftests/mm/hmm-tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/mm/hmm-tests.c +1 -1
@@ -1657,7 +1657,7 @@ TEST_F(hmm2, double_map) buffer->fd =-1 ; buffer->size = size; - buffer->mirror =malloc (npages); + buffer->mirror =malloc (size);ASSERT_NE (buffer->mirror,NULL );/* Reserve a range of addresses. */
Signature · 1 line
2.43.5
Quoted 17 lines · Donet Tom
The hmm2
double_maptest was failing due to an incorrectbuffer->mirrorsize. Thebuffer->mirrorsize was 6, whilebuffer->ptrsize was 6 *PAGE_SIZE. The test failed because the kernel'scopy_to_userfunction was attempting to copy a 6 *PAGE_SIZEbuffer tobuffer->mirror. Since the size ofbuffer->mirrorwas incorrect,copy_to_userfailed.This patch corrects the
buffer->mirrorsize to 6 *PAGE_SIZE.Test Result without this patch
==============================
# RUN hmm2.hmm2_device_private.double_map ...
# hmm-tests.c:1680:double_map:Expected ret (-14) == 0 (0) #double_map: Test terminated by assertion
# FAIL hmm2.hmm2_device_private.double_map
not ok 53 hmm2.hmm2_device_private.double_map
Quoted 7 lines
Test Result with this patch
===========================
# RUN hmm2.hmm2_device_private.double_map ...
# OK hmm2.hmm2_device_private.double_map
ok 53 hmm2.hmm2_device_private.double_mapSigned-off-by Donet Tom <[email protected]>
Please add Fixes-by tag. Other than this, LGTM
Quoted 17 lines
--- tools/testing/selftests/mm/hmm-tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/mm/hmm-tests.c +1
-1@@ -1657,7 +1657,7 @@ TEST_F(hmm2, double_map) buffer->fd =-1 ; buffer->size = size; - buffer->mirror =malloc (npages); + buffer->mirror =malloc (size);ASSERT_NE (buffer->mirror,NULL );/* Reserve a range of addresses. */
Signature · 2 lines
BR, Muhammad Usama Anjum
Quoted 18 lines · Muhammad Usama Anjum
Quoted 17 lines · Donet Tom
The hmm2
double_maptest was failing due to an incorrectbuffer->mirrorsize. Thebuffer->mirrorsize was 6, whilebuffer->ptrsize was 6 *PAGE_SIZE. The test failed because the kernel'scopy_to_userfunction was attempting to copy a 6 *PAGE_SIZEbuffer tobuffer->mirror. Since the size ofbuffer->mirrorwas incorrect,copy_to_userfailed.This patch corrects the
buffer->mirrorsize to 6 *PAGE_SIZE.Test Result without this patch
==============================
# RUN hmm2.hmm2_device_private.double_map ...
# hmm-tests.c:1680:double_map:Expected ret (-14) == 0 (0) #double_map: Test terminated by assertion
# FAIL hmm2.hmm2_device_private.double_map
not ok 53 hmm2.hmm2_device_private.double_map
Quoted 8 lines
Quoted 7 lines
Test Result with this patch
===========================
# RUN hmm2.hmm2_device_private.double_map ...
# OK hmm2.hmm2_device_private.double_map
ok 53 hmm2.hmm2_device_private.double_mapSigned-off-by Donet Tom <[email protected]>Please add Fixes-by tag. Other than this, LGTM
I have added the Fixes-by tag here. Please let me know if you would prefer that I send a V2 with this tag.
Quoted 2 lines
Reviewed-by Muhammad Usama Anjum <[email protected]>
Thank you
Donet
Quoted 18 lines
Quoted 18 lines
--- tools/testing/selftests/mm/hmm-tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/mm/hmm-tests.c +1
-1@@ -1657,7 +1657,7 @@ TEST_F(hmm2, double_map) buffer->fd =-1 ; buffer->size = size; - buffer->mirror =malloc (npages); + buffer->mirror =malloc (size);ASSERT_NE (buffer->mirror,NULL );/* Reserve a range of addresses. */
Andrew Morton
maintainerQuoted 6 lines · On Fri, 27 Sep 2024 16:21:30 +0530 Donet Tom <[email protected]> wrote:
Quoted 6 lines
Quoted 6 lines
Test Result with this patch
===========================
# RUN hmm2.hmm2_device_private.double_map ...
# OK hmm2.hmm2_device_private.double_map
ok 53 hmm2.hmm2_device_private.double_map
Quoted 7 lines
Quoted 2 lines
Quoted 1 line
Signed-off-by Donet Tom <[email protected]>Please add Fixes-by tag. Other than this, LGTM
Fixes-by Donet Tom <[email protected]>I have added the Fixes-by tag here. Please let me know if you would prefer that I send a V2 with this tag.
"Fixes:". I added