Revert "shmobj: Support large page"

This reverts commit 9a60997ea0.

Change-Id: Id60959b4e03451987239faa0bbc2e780b72fafaa
This commit is contained in:
Masamichi Takagi
2020-07-18 17:48:26 +09:00
committed by Masamichi Takagi
parent 40f8091fab
commit d7cf39883f
32 changed files with 75 additions and 2212 deletions

View File

@ -1,44 +0,0 @@
#/bin/sh
USELTP=1
USEOSTEST=0
. ../../common.sh
issue="1381"
tid=01
arch=`uname -p`
if [ "$arch" == "x86_64" ]; then
pgshift=21
elif [ "$arch" == "aarch64" ]; then
pgshift=29
fi
tname=`printf "C${issue}T%02d" ${tid}`
echo "*** ${tname} start *******************************"
${MCEXEC} ./C1381T01 ${pgshift}
if [ $? -eq 0 ]; then
echo "*** ${tname} PASSED ******************************"
else
echo "*** ${tname} FAILED ******************************"
fi
let tid++
echo ""
for tp in futex_wake04 shmat01 shmat02 shmat03 shmctl01 shmctl02 shmctl03 shmctl04 shmdt01 shmdt02 shmget01 shmget02 shmget03 shmget04 shmget05
do
tname=`printf "C${issue}T%02d" ${tid}`
echo "*** ${tname} start *******************************"
sudo $MCEXEC $LTPBIN/$tp 2>&1 | tee $tp.txt
ok=`grep PASS $tp.txt | wc -l`
ng=`grep FAIL $tp.txt | wc -l`
if [ $ng = 0 ]; then
echo "*** ${tname} PASSED ($ok)"
else
echo "*** ${tname} FAILED (ok=$ok ng=$ng)"
fi
let tid++
echo ""
done

View File

@ -1,106 +0,0 @@
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/mman.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define PAGES 3
#define MAP_HUGE_SHIFT 26
static unsigned long ps, hps;
void *test_mmap(unsigned long size, int pgshift)
{
int lp_flags = 0;
if (pgshift != 0) {
lp_flags = MAP_HUGETLB | (pgshift << MAP_HUGE_SHIFT);
}
return mmap(NULL, size, PROT_WRITE | PROT_READ,
MAP_ANONYMOUS | MAP_SHARED |
lp_flags,
-1, 0);
}
int main(int argc, char **argv)
{
void *addr;
int i, pgshift, err, ret = 0;
size_t size;
if (argc < 2) {
printf("error: too few arguments\n");
ret = -1;
goto out;
}
pgshift = atoi(argv[1]);
hps = (1 << pgshift);
ps = getpagesize();
printf("** Case 1: specified MAP_HUGETLB\n");
size = hps * PAGES;
addr = test_mmap(size, pgshift);
if (addr == MAP_FAILED) {
perror("mmap fail: ");
ret = -1;
}
memset(addr, 'a', size);
errno = 0;
err = munmap(addr + size - ps, ps);
if (err == -1 && errno == EINVAL) {
printf("[OK] munmap returned %d and errno: EINVAL\n", err);
}
else {
printf("[NG] munamp succceeded\n");
ret = -1;
// goto out;
}
printf("** Case 2: size is aligned on large page\n");
size = hps * PAGES;
addr = test_mmap(size, 0);
if (addr == MAP_FAILED) {
perror("mmap fail: ");
ret = -1;
}
memset(addr, 'a', size);
errno = 0;
err = munmap(addr + size - ps, ps);
if (err == -1 && errno == EINVAL) {
printf("[OK] munmap returned %d and errno: EINVAL\n", err);
}
else {
printf("[NG] munamp succceeded\n");
ret = -1;
// goto out;
}
printf("** Case 3: size is NOT aligned on large page\n");
size = hps * PAGES - ps;
addr = test_mmap(size, 0);
if (addr == MAP_FAILED) {
perror("mmap fail: ");
ret = -1;
}
memset(addr, 'a', size);
errno = 0;
err = munmap(addr + size - ps, ps);
if (err == 0 && errno == 0) {
printf("[OK] munamp succceeded\n");
}
else {
printf("[NG] munmap returned %d and errno: EINVAL\n", err);
ret = -1;
// goto out;
}
out:
return ret;
}

View File

@ -1,11 +0,0 @@
CFLAGS=-g
LDFLAGS=
TARGET= C1381T01
all: $(TARGET)
test: all
sh ./C1381.sh
clean:
rm -f $(TARGET) *.o *.txt

View File

@ -1,38 +0,0 @@
【Issue#1381 動作確認】
□ テスト内容
1. 以下のケースでMAP_SHARED指定のmmapをした領域の、
最後のスモールページ1ページ分をmunmapし、期待通りの動作となることを確認する
- MAP_HUGETLB指定 munmapが-1を返し、errnoにEINVALがセットされる
- ラージページサイズの倍数のサイズ munampが-1を返し、errnoにEINVALがセットされる
- ラージページサイズの倍数ではないサイズ munmapが成功する
2. Issueで報告された以下のLTPを実行し、症状が発生しないことを確認する
- futex_wake04
3. 以下のLTPを用いて既存のshm機能に影響が無いことを確認
- shmat01
- shmat02
- shmat03
- shmctl01
- shmctl02
- shmctl03
- shmctl04
- shmdt01
- shmdt02
- shmget01
- shmget02
- shmget03
- shmget04
- shmget05
□ 実行手順
$ make test
McKernelのインストール先や、OSTEST, LTPの配置場所は、
$HOME/.mck_test_config を参照している
.mck_test_config は、McKernelをビルドした際に生成されるmck_test_config.sample ファイルを
$HOMEにコピーし、適宜編集する
□ 実行結果
x86_64_result.log aarch64_result.log 参照。
すべての項目をPASSしていることを確認。

View File

@ -1,116 +0,0 @@
*** C1381T01 start *******************************
** Case 1: specified MAP_HUGETLB
[OK] munmap returned -1 and errno: EINVAL
** Case 2: size is aligned on large page
[OK] munmap returned -1 and errno: EINVAL
** Case 3: size is NOT aligned on large page
[OK] munamp succceeded
*** C1381T01 PASSED ******************************
*** C1381T02 start *******************************
futex_wake04 0 TINFO : Hugepagesize 536870912
futex_wake04 1 TPASS : Hi hydra, thread2 awake!
*** C1381T02 PASSED (1)
*** C1381T03 start *******************************
tst_test.c:1096: INFO: Timeout per run is 0h 05m 00s
shmat01.c:147: PASS: shmat() succeeded to attach NULL address
shmat01.c:147: PASS: shmat() succeeded to attach aligned address
shmat01.c:147: PASS: shmat() succeeded to attach unaligned address with SHM_RND
shmat01.c:147: PASS: shmat() succeeded to attach aligned address with SHM_READONLY, and got S IGSEGV on write
Summary:
passed 4
failed 0
skipped 0
warnings 0
*** C1381T03 PASSED (4)
*** C1381T04 start *******************************
tst_test.c:1096: INFO: Timeout per run is 0h 05m 00s
shmat02.c:68: PASS: shmat() failed as expected: EINVAL
shmat02.c:68: PASS: shmat() failed as expected: EINVAL
shmat02.c:68: PASS: shmat() failed as expected: EACCES
Summary:
passed 3
failed 0
skipped 0
warnings 0
*** C1381T04 PASSED (3)
*** C1381T05 start *******************************
tst_test.c:1096: INFO: Timeout per run is 0h 05m 00s
shmat03.c:75: INFO: Attempting to attach shared memory to null page
shmat03.c:91: INFO: Mapped shared memory to 0x1000001e0000
shmat03.c:98: PASS: The kernel assigned a different VM address
shmat03.c:101: INFO: Touching shared memory to see if anything strange happens
Summary:
passed 1
failed 0
skipped 0
warnings 0
*** C1381T05 PASSED (1)
*** C1381T06 start *******************************
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
*** C1381T06 PASSED (8)
*** C1381T07 start *******************************
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.
*** C1381T07 PASSED (5)
*** C1381T08 start *******************************
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
*** C1381T08 PASSED (3)
*** C1381T09 start *******************************
shmctl04 1 TPASS : SHM_INFO call succeeded
*** C1381T09 PASSED (1)
*** C1381T10 start *******************************
shmdt01 1 TPASS : shared memory detached correctly
*** C1381T10 PASSED (1)
*** C1381T11 start *******************************
shmdt02 1 TPASS : expected failure - errno = 22 : Invalid argument
*** C1381T11 PASSED (1)
*** C1381T12 start *******************************
shmget01 1 TPASS : size, pid & mode are correct
*** C1381T12 PASSED (1)
*** C1381T13 start *******************************
shmget02 1 TPASS : expected failure - errno = 22 : Invalid argument
shmget02 2 TPASS : expected failure - errno = 22 : Invalid argument
shmget02 3 TPASS : expected failure - errno = 17 : File exists
shmget02 4 TPASS : expected failure - errno = 2 : No such file or directory
*** C1381T13 PASSED (4)
*** C1381T14 start *******************************
shmget03 1 TPASS : expected failure - errno = 28 : No space left on device
*** C1381T14 PASSED (1)
*** C1381T15 start *******************************
shmget04 1 TPASS : expected failure - errno = 13 : Permission denied
*** C1381T15 PASSED (1)
*** C1381T16 start *******************************
shmget05 1 TPASS : expected failure - errno = 13 : Permission denied
*** C1381T16 PASSED (1)

View File

@ -1,116 +0,0 @@
*** C1381T01 start *******************************
** Case 1: specified MAP_HUGETLB
[OK] munmap returned -1 and errno: EINVAL
** Case 2: size is aligned on large page
[OK] munmap returned -1 and errno: EINVAL
** Case 3: size is NOT aligned on large page
[OK] munamp succceeded
*** C1381T01 PASSED ******************************
*** C1381T02 start *******************************
futex_wake04 0 TINFO : Hugepagesize 2097152
futex_wake04 1 TPASS : Hi hydra, thread2 awake!
*** C1381T02 PASSED (1)
*** C1381T03 start *******************************
tst_test.c:1096: INFO: Timeout per run is 0h 05m 00s
shmat01.c:147: PASS: shmat() succeeded to attach NULL address
shmat01.c:147: PASS: shmat() succeeded to attach aligned address
shmat01.c:147: PASS: shmat() succeeded to attach unaligned address with SHM_RND
shmat01.c:147: PASS: shmat() succeeded to attach aligned address with SHM_READONLY, and got SIGSEGV on write
Summary:
passed 4
failed 0
skipped 0
warnings 0
*** C1381T03 PASSED (4)
*** C1381T04 start *******************************
tst_test.c:1096: INFO: Timeout per run is 0h 05m 00s
shmat02.c:68: PASS: shmat() failed as expected: EINVAL
shmat02.c:68: PASS: shmat() failed as expected: EINVAL
shmat02.c:68: PASS: shmat() failed as expected: EACCES
Summary:
passed 3
failed 0
skipped 0
warnings 0
*** C1381T04 PASSED (3)
*** C1381T05 start *******************************
tst_test.c:1096: INFO: Timeout per run is 0h 05m 00s
shmat03.c:75: INFO: Attempting to attach shared memory to null page
shmat03.c:91: INFO: Mapped shared memory to 0x2aaaaadea000
shmat03.c:98: PASS: The kernel assigned a different VM address
shmat03.c:101: INFO: Touching shared memory to see if anything strange happens
Summary:
passed 1
failed 0
skipped 0
warnings 0
*** C1381T05 PASSED (1)
*** C1381T06 start *******************************
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
*** C1381T06 PASSED (8)
*** C1381T07 start *******************************
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.
*** C1381T07 PASSED (5)
*** C1381T08 start *******************************
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
*** C1381T08 PASSED (3)
*** C1381T09 start *******************************
shmctl04 1 TPASS : SHM_INFO call succeeded
*** C1381T09 PASSED (1)
*** C1381T10 start *******************************
shmdt01 1 TPASS : shared memory detached correctly
*** C1381T10 PASSED (1)
*** C1381T11 start *******************************
shmdt02 1 TPASS : expected failure - errno = 22 : Invalid argument
*** C1381T11 PASSED (1)
*** C1381T12 start *******************************
shmget01 1 TPASS : size, pid & mode are correct
*** C1381T12 PASSED (1)
*** C1381T13 start *******************************
shmget02 1 TPASS : expected failure - errno = 22 : Invalid argument
shmget02 2 TPASS : expected failure - errno = 22 : Invalid argument
shmget02 3 TPASS : expected failure - errno = 17 : File exists
shmget02 4 TPASS : expected failure - errno = 2 : No such file or directory
*** C1381T13 PASSED (4)
*** C1381T14 start *******************************
shmget03 1 TPASS : expected failure - errno = 28 : No space left on device
*** C1381T14 PASSED (1)
*** C1381T15 start *******************************
shmget04 1 TPASS : expected failure - errno = 13 : Permission denied
*** C1381T15 PASSED (1)
*** C1381T16 start *******************************
shmget05 1 TPASS : expected failure - errno = 13 : Permission denied
*** C1381T16 PASSED (1)