remap_file_pages: check file mapping
Change-Id: Ibf145a20181938a9825214253337a423fcd53064 Refs: #1521
This commit is contained in:
committed by
Masamichi Takagi
parent
e6e66e0392
commit
b0bd1feefb
@ -113,7 +113,7 @@ int devobj_create(int fd, size_t len, off_t off, struct memobj **objp, int *maxp
|
|||||||
__FUNCTION__, fd, len, off, result.handle, result.maxprot);
|
__FUNCTION__, fd, len, off, result.handle, result.maxprot);
|
||||||
|
|
||||||
obj->memobj.ops = &devobj_ops;
|
obj->memobj.ops = &devobj_ops;
|
||||||
obj->memobj.flags = MF_HAS_PAGER | MF_DEV_FILE;
|
obj->memobj.flags = MF_HAS_PAGER | MF_REMAP_FILE_PAGES | MF_DEV_FILE;
|
||||||
obj->memobj.size = len;
|
obj->memobj.size = len;
|
||||||
ihk_atomic_set(&obj->memobj.refcnt, 1);
|
ihk_atomic_set(&obj->memobj.refcnt, 1);
|
||||||
obj->handle = result.handle;
|
obj->handle = result.handle;
|
||||||
|
|||||||
@ -236,6 +236,7 @@ int fileobj_create(int fd, struct memobj **objp, int *maxprotp, int flags,
|
|||||||
memset(newobj, 0, sizeof(*newobj));
|
memset(newobj, 0, sizeof(*newobj));
|
||||||
newobj->memobj.ops = &fileobj_ops;
|
newobj->memobj.ops = &fileobj_ops;
|
||||||
newobj->memobj.flags = MF_HAS_PAGER | MF_REG_FILE |
|
newobj->memobj.flags = MF_HAS_PAGER | MF_REG_FILE |
|
||||||
|
MF_REMAP_FILE_PAGES |
|
||||||
((flags & MAP_PRIVATE) ? MF_PRIVATE : 0);
|
((flags & MAP_PRIVATE) ? MF_PRIVATE : 0);
|
||||||
newobj->handle = result.handle;
|
newobj->handle = result.handle;
|
||||||
|
|
||||||
|
|||||||
@ -37,6 +37,7 @@ enum {
|
|||||||
MF_SHM = 0x40000,
|
MF_SHM = 0x40000,
|
||||||
MF_HUGETLBFS = 0x100000,
|
MF_HUGETLBFS = 0x100000,
|
||||||
MF_PRIVATE = 0x200000, /* To prevent flush in clear_range_* */
|
MF_PRIVATE = 0x200000, /* To prevent flush in clear_range_* */
|
||||||
|
MF_REMAP_FILE_PAGES = 0x400000, /* remap_file_pages possible */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MEMOBJ_READY 0
|
#define MEMOBJ_READY 0
|
||||||
@ -181,4 +182,11 @@ static inline int is_freeable(struct memobj *memobj)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int is_callable_remap_file_pages(struct memobj *memobj)
|
||||||
|
{
|
||||||
|
if (!memobj || !(memobj->flags & MF_REMAP_FILE_PAGES))
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* HEADER_MEMOBJ_H */
|
#endif /* HEADER_MEMOBJ_H */
|
||||||
|
|||||||
@ -9213,7 +9213,7 @@ SYSCALL_DECLARE(remap_file_pages)
|
|||||||
if (!range || (start < range->start) || (range->end < end)
|
if (!range || (start < range->start) || (range->end < end)
|
||||||
|| (range->flag & VR_PRIVATE)
|
|| (range->flag & VR_PRIVATE)
|
||||||
|| (range->flag & (VR_REMOTE|VR_IO_NOCACHE|VR_RESERVED))
|
|| (range->flag & (VR_REMOTE|VR_IO_NOCACHE|VR_RESERVED))
|
||||||
|| !range->memobj) {
|
|| !is_callable_remap_file_pages(range->memobj)) {
|
||||||
ekprintf("sys_remap_file_pages(%#lx,%#lx,%#x,%#lx,%#x):"
|
ekprintf("sys_remap_file_pages(%#lx,%#lx,%#x,%#lx,%#x):"
|
||||||
"invalid VMR:[%#lx-%#lx) %#lx %p\n",
|
"invalid VMR:[%#lx-%#lx) %#lx %p\n",
|
||||||
start0, size, prot, pgoff, flags,
|
start0, size, prot, pgoff, flags,
|
||||||
|
|||||||
24
test/issues/1379+1521+1531/C1379.sh
Normal file
24
test/issues/1379+1521+1531/C1379.sh
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
USELTP=1
|
||||||
|
USEOSTEST=0
|
||||||
|
|
||||||
|
. ../../common.sh
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
for i in shmctl05:01 shmctl01:02 shmctl02:03 shmctl03:04 shmctl04:05 \
|
||||||
|
remap_file_pages01:06 remap_file_pages02:07; do
|
||||||
|
tp=`echo $i|sed 's/:.*//'`
|
||||||
|
id=`echo $i|sed 's/.*://'`
|
||||||
|
sudo PATH=$PATH:$LTPBIN $MCEXEC $LTPBIN/$tp 2>&1 | tee $tp.txt
|
||||||
|
ok=`grep TPASS $tp.txt | wc -l`
|
||||||
|
ng=`grep TFAIL $tp.txt | wc -l`
|
||||||
|
if [ $ok = 0 -a $ng = 0 ]; then
|
||||||
|
ok=`awk '/^passed/{print $2}' $tp.txt`
|
||||||
|
ng=`awk '/^failed/{print $2}' $tp.txt`
|
||||||
|
fi
|
||||||
|
if [ $ng = 0 ]; then
|
||||||
|
echo "*** C1379T$id: $tp PASS ($ok)"
|
||||||
|
else
|
||||||
|
echo "*** C1379T$id: $tp FAIL (ok=$ok ng=$ng)"
|
||||||
|
fi
|
||||||
|
done
|
||||||
74
test/issues/1379+1521+1531/C1379_arm64.txt
Normal file
74
test/issues/1379+1521+1531/C1379_arm64.txt
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
Script started on Tue 01 Sep 2020 07:13:12 AM JST
|
||||||
|
[shirasawa@apollo15 1379+1521+1531]$ uname -m
|
||||||
|
aarch64
|
||||||
|
[shirasawa@apollo15 1379+1521+1531]$ make test
|
||||||
|
sh ./C1379.sh
|
||||||
|
mcstop+release.sh ... done
|
||||||
|
mcreboot.sh -c 2-31 -m 2G@0,2G@1 -O ... done
|
||||||
|
tst_test.c:1096: INFO: Timeout per run is 0h 00m 20s
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:477: INFO: Minimum sampling period ended
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:301: INFO: loop = 1024, delay_bias = 0
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:290: INFO: start_a - start_b: { avg = 21ns, avg_dev = 9ns, dev_ratio = 0.45 }
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:290: INFO: end_a - start_a : { avg = 403181ns, avg_dev = 63ns, dev_ratio = 0.00 }
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:290: INFO: end_b - start_b : { avg = 2429ns, avg_dev = 24ns, dev_ratio = 0.01 }
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:290: INFO: end_a - end_b : { avg = 400772ns, avg_dev = 78ns, dev_ratio = 0.00 }
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:290: INFO: spins : { avg = 61836 , avg_dev = 15 , dev_ratio = 0.00 }
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:489: INFO: Reached deviation ratios < 0.10, introducing randomness
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:492: INFO: Delay range is [-462, 62221]
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:301: INFO: loop = 4616, delay_bias = 0
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:290: INFO: start_a - start_b: { avg = 32ns, avg_dev = 3ns, dev_ratio = 0.10 }
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:290: INFO: end_a - start_a : { avg = 402983ns, avg_dev = 38ns, dev_ratio = 0.00 }
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:290: INFO: end_b - start_b : { avg = 2998ns, avg_dev = 30ns, dev_ratio = 0.01 }
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:290: INFO: end_a - end_b : { avg = 400017ns, avg_dev = 27ns, dev_ratio = 0.00 }
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:290: INFO: spins : { avg = 61763 , avg_dev = 50 , dev_ratio = 0.00 }
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:606: INFO: Exceeded execution time, requesting exit
|
||||||
|
shmctl05.c:97: PASS: didn't crash
|
||||||
|
|
||||||
|
Summary:
|
||||||
|
passed 1
|
||||||
|
failed 0
|
||||||
|
skipped 0
|
||||||
|
warnings 0
|
||||||
|
*** C1379T01: shmctl05 PASS (1)
|
||||||
|
shmctl01 1 TPASS : pid, size, # of attaches and mode are correct - pass #1
|
||||||
|
shmctl01 2 TPASS : pid, size, # of attaches and mode are correct - pass #2
|
||||||
|
shmctl01 3 TPASS : new mode and change time are correct
|
||||||
|
shmctl01 4 TPASS : get correct shared memory limits
|
||||||
|
shmctl01 5 TPASS : get correct shared memory id
|
||||||
|
shmctl01 6 TPASS : SHM_LOCK is set
|
||||||
|
shmctl01 7 TPASS : SHM_LOCK is cleared
|
||||||
|
shmctl01 8 TPASS : shared memory appears to be removed
|
||||||
|
*** C1379T02: shmctl01 PASS (8)
|
||||||
|
shmctl02 1 TPASS : expected failure - errno = 13 : Permission denied
|
||||||
|
shmctl02 2 TPASS : expected failure - errno = 14 : Bad address
|
||||||
|
shmctl02 3 TPASS : expected failure - errno = 14 : Bad address
|
||||||
|
shmctl02 4 TPASS : expected failure - errno = 22 : Invalid argument
|
||||||
|
shmctl02 5 TPASS : expected failure - errno = 22 : Invalid argument
|
||||||
|
shmctl02 6 TCONF : shmctl02.c:138: shmctl() did not fail for non-root user.This may be okay for your distribution.
|
||||||
|
shmctl02 7 TCONF : shmctl02.c:138: shmctl() did not fail for non-root user.This may be okay for your distribution.
|
||||||
|
*** C1379T03: shmctl02 PASS (5)
|
||||||
|
shmctl03 1 TPASS : expected failure - errno = 13 : Permission denied
|
||||||
|
shmctl03 2 TPASS : expected failure - errno = 1 : Operation not permitted
|
||||||
|
shmctl03 3 TPASS : expected failure - errno = 1 : Operation not permitted
|
||||||
|
*** C1379T04: shmctl03 PASS (3)
|
||||||
|
shmctl04 1 TPASS : SHM_INFO call succeeded
|
||||||
|
*** C1379T05: shmctl04 PASS (1)
|
||||||
|
remap_file_pages01 1 TPASS : Non-Linear shm file OK
|
||||||
|
remap_file_pages01 2 TPASS : Non-Linear /tmp/ file OK
|
||||||
|
*** C1379T06: remap_file_pages01 PASS (2)
|
||||||
|
tst_test.c:1096: INFO: Timeout per run is 0h 05m 00s
|
||||||
|
remap_file_pages02.c:86: PASS: remap_file_pages(2) start is not valid MAP_SHARED mapping: EINVAL
|
||||||
|
remap_file_pages02.c:86: PASS: remap_file_pages(2) start is invalid: EINVAL
|
||||||
|
remap_file_pages02.c:86: PASS: remap_file_pages(2) size is invalid: EINVAL
|
||||||
|
remap_file_pages02.c:86: PASS: remap_file_pages(2) prot is invalid: EINVAL
|
||||||
|
|
||||||
|
Summary:
|
||||||
|
passed 4
|
||||||
|
failed 0
|
||||||
|
skipped 0
|
||||||
|
warnings 0
|
||||||
|
*** C1379T07: remap_file_pages02 PASS (4)
|
||||||
|
[shirasawa@apollo15 1379+1521+1531]$ exit
|
||||||
|
exit
|
||||||
|
|
||||||
|
Script done on Tue 01 Sep 2020 07:14:15 AM JST
|
||||||
66
test/issues/1379+1521+1531/C1379_x86_64.txt
Normal file
66
test/issues/1379+1521+1531/C1379_x86_64.txt
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
Script started on Tue Sep 1 06:30:33 2020
|
||||||
|
bash-4.2$ uname -m
|
||||||
|
x86_64
|
||||||
|
bash-4.2$ make test
|
||||||
|
sh ./C1379.sh
|
||||||
|
mcstop+release.sh ... done
|
||||||
|
mcreboot.sh -c 1-7,9-15,17-23,25-31 -m 10G@0,10G@1 -r 1-7:0+9-15:8+17-23:16+25-31:24 ... done
|
||||||
|
tst_test.c:1096: INFO: Timeout per run is 0h 00m 20s
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:477: INFO: Minimum sampling period ended
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:301: INFO: loop = 1024, delay_bias = 0
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:290: INFO: start_a - start_b: { avg = -341ns, avg_dev = 260ns, dev_ratio = 0.76 }
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:290: INFO: end_a - start_a : { avg = 61009ns, avg_dev = 434ns, dev_ratio = 0.01 }
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:290: INFO: end_b - start_b : { avg = 12223ns, avg_dev = 596ns, dev_ratio = 0.05 }
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:290: INFO: end_a - end_b : { avg = 48445ns, avg_dev = 377ns, dev_ratio = 0.01 }
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:290: INFO: spins : { avg = 18529 , avg_dev = 1533 , dev_ratio = 0.08 }
|
||||||
|
../../../../../include/tst_fuzzy_sync.h:606: INFO: Exceeded execution time, requesting exit
|
||||||
|
shmctl05.c:97: PASS: didn't crash
|
||||||
|
|
||||||
|
Summary:
|
||||||
|
passed 1
|
||||||
|
failed 0
|
||||||
|
skipped 0
|
||||||
|
warnings 0
|
||||||
|
*** C1379T01: shmctl05 PASS (1)
|
||||||
|
shmctl01 1 TPASS : pid, size, # of attaches and mode are correct - pass #1
|
||||||
|
shmctl01 2 TPASS : pid, size, # of attaches and mode are correct - pass #2
|
||||||
|
shmctl01 3 TPASS : new mode and change time are correct
|
||||||
|
shmctl01 4 TPASS : get correct shared memory limits
|
||||||
|
shmctl01 5 TPASS : get correct shared memory id
|
||||||
|
shmctl01 6 TPASS : SHM_LOCK is set
|
||||||
|
shmctl01 7 TPASS : SHM_LOCK is cleared
|
||||||
|
shmctl01 8 TPASS : shared memory appears to be removed
|
||||||
|
*** C1379T02: shmctl01 PASS (8)
|
||||||
|
shmctl02 1 TPASS : expected failure - errno = 13 : Permission denied
|
||||||
|
shmctl02 2 TPASS : expected failure - errno = 14 : Bad address
|
||||||
|
shmctl02 3 TPASS : expected failure - errno = 14 : Bad address
|
||||||
|
shmctl02 4 TPASS : expected failure - errno = 22 : Invalid argument
|
||||||
|
shmctl02 5 TPASS : expected failure - errno = 22 : Invalid argument
|
||||||
|
shmctl02 6 TCONF : shmctl02.c:138: shmctl() did not fail for non-root user.This may be okay for your distribution.
|
||||||
|
shmctl02 7 TCONF : shmctl02.c:138: shmctl() did not fail for non-root user.This may be okay for your distribution.
|
||||||
|
*** C1379T03: shmctl02 PASS (5)
|
||||||
|
shmctl03 1 TPASS : expected failure - errno = 13 : Permission denied
|
||||||
|
shmctl03 2 TPASS : expected failure - errno = 1 : Operation not permitted
|
||||||
|
shmctl03 3 TPASS : expected failure - errno = 1 : Operation not permitted
|
||||||
|
*** C1379T04: shmctl03 PASS (3)
|
||||||
|
shmctl04 1 TPASS : SHM_INFO call succeeded
|
||||||
|
*** C1379T05: shmctl04 PASS (1)
|
||||||
|
remap_file_pages01 1 TPASS : Non-Linear shm file OK
|
||||||
|
remap_file_pages01 2 TPASS : Non-Linear /tmp/ file OK
|
||||||
|
*** C1379T06: remap_file_pages01 PASS (2)
|
||||||
|
tst_test.c:1096: INFO: Timeout per run is 0h 05m 00s
|
||||||
|
remap_file_pages02.c:86: PASS: remap_file_pages(2) start is not valid MAP_SHARED mapping: EINVAL
|
||||||
|
remap_file_pages02.c:86: PASS: remap_file_pages(2) start is invalid: EINVAL
|
||||||
|
remap_file_pages02.c:86: PASS: remap_file_pages(2) size is invalid: EINVAL
|
||||||
|
remap_file_pages02.c:86: PASS: remap_file_pages(2) prot is invalid: EINVAL
|
||||||
|
|
||||||
|
Summary:
|
||||||
|
passed 4
|
||||||
|
failed 0
|
||||||
|
skipped 0
|
||||||
|
warnings 0
|
||||||
|
*** C1379T07: remap_file_pages02 PASS (4)
|
||||||
|
bash-4.2$ exit
|
||||||
|
exit
|
||||||
|
|
||||||
|
Script done on Tue Sep 1 06:31:10 2020
|
||||||
10
test/issues/1379+1521+1531/Makefile
Normal file
10
test/issues/1379+1521+1531/Makefile
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
CC = gcc
|
||||||
|
TARGET =
|
||||||
|
|
||||||
|
all:: $(TARGET)
|
||||||
|
|
||||||
|
test:: all
|
||||||
|
sh ./C1379.sh
|
||||||
|
|
||||||
|
clean::
|
||||||
|
rm -f $(TARGET) *.o
|
||||||
25
test/issues/1379+1521+1531/README
Normal file
25
test/issues/1379+1521+1531/README
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
【Issue#1379, Issue#1521, Issue#1531 動作確認】
|
||||||
|
□ テスト内容
|
||||||
|
1. Issue 指摘事項の再現確認
|
||||||
|
C1379T01 LTP shmctl05を実行し、全てのテストケースがPASSすること。
|
||||||
|
|
||||||
|
2. LTP を用いて既存処理に影響しないことを確認
|
||||||
|
shmctl, remap_file_pages処理を変更したため、それらを使用するLTPを選定した。
|
||||||
|
全てPASSすること。
|
||||||
|
C1379T02 shmctl01: shmctl の基本機能の確認
|
||||||
|
C1379T03 shmctl01: shmctl の基本機能の確認
|
||||||
|
C1379T04 shmctl01: shmctl の基本機能の確認
|
||||||
|
C1379T05 shmctl01: shmctl の基本機能の確認
|
||||||
|
C1379T06 remap_file_pages01: remap_file_pages の基本機能の確認
|
||||||
|
C1379T07 remap_file_pages02: remap_file_pages の基本機能の確認
|
||||||
|
|
||||||
|
□ 実行手順
|
||||||
|
$ make test
|
||||||
|
|
||||||
|
McKernelのインストール先や LTP の配置場所は、$HOME/.mck_test_config を
|
||||||
|
参照する。.mck_test_config は、McKernel をビルドした際に生成される
|
||||||
|
mck_test_config.sample ファイルを $HOME にコピーし、適宜編集すること。
|
||||||
|
|
||||||
|
□ 実行結果
|
||||||
|
C1379_x86_64.txt(x86_64実行結果)、C1379_arm64.txt(arm64実行結果)参照。
|
||||||
|
全ての項目が PASS していることを確認。
|
||||||
Reference in New Issue
Block a user