page_fault_process_memory_range: Remove ihk_mc_map_virtual for CoW of device map
Device map with MAP_PRIVATE is copied when forking using copy_user_pte. So the map isn't copied by those statements. Futjitsu: POSTK_TEMP_FIX_14 Refs: #1039 Change-Id: I1a697ed2e003055d66a8eebd3e8d5e9e49d094ad
This commit is contained in:
committed by
Masamichi Takagi
parent
9a20cfaefb
commit
5fcbfa2eb5
@ -1868,29 +1868,8 @@ retry:
|
||||
}
|
||||
dkprintf("%s: cow,copying virt:%lx<-%lx,phys:%lx<-%lx,pgsize=%lu\n",
|
||||
__FUNCTION__, virt, phys_to_virt(phys), virt_to_phys(virt), phys, pgsize);
|
||||
#ifdef POSTK_DEBUG_TEMP_FIX_14
|
||||
if (page) {
|
||||
// McKernel memory space
|
||||
memcpy(virt, phys_to_virt(phys), pgsize);
|
||||
} else {
|
||||
// Host Kernel memory space
|
||||
const enum ihk_mc_pt_attribute attr = 0;
|
||||
void* vmap;
|
||||
|
||||
vmap = ihk_mc_map_virtual(phys, npages, attr);
|
||||
if (!vmap) {
|
||||
error = -ENOMEM;
|
||||
kprintf("page_fault_process_memory_range(%p,%lx-%lx %lx,%lx,%lx):cannot virtual mapping. %d\n", vm, range->start, range->end, range->flag, fault_addr, reason, error);
|
||||
ihk_mc_free_pages(virt, npages);
|
||||
goto out;
|
||||
}
|
||||
memcpy(virt, vmap, pgsize);
|
||||
ihk_mc_unmap_virtual(vmap, npages);
|
||||
}
|
||||
#else /*POSTK_DEBUG_TEMP_FIX_14*/
|
||||
memcpy(virt, phys_to_virt(phys), pgsize);
|
||||
|
||||
#endif /*POSTK_DEBUG_TEMP_FIX_14*/
|
||||
/* Call rusage_memory_stat_add() because remote page fault may create a page not pointed-to by PTE */
|
||||
if(rusage_memory_stat_add(range, phys, pgsize, pgsize)) {
|
||||
dkprintf("%lx+,%s: remote page fault + cow, calling memory_stat_rss_add(),pgsize=%ld\n",
|
||||
|
||||
68
test/issues/1039/C1039.sh
Executable file
68
test/issues/1039/C1039.sh
Executable file
@ -0,0 +1,68 @@
|
||||
#!/bin/sh
|
||||
BIN=
|
||||
SBIN=
|
||||
LTP=
|
||||
BOOTPARAM="-c 1-7,17-23,9-15,25-31 -m 10G@0,10G@1"
|
||||
|
||||
if [ -f ../../../config.h ]; then
|
||||
str=`grep "^#define BINDIR " ../../../config.h | head -1 | sed 's/^#define BINDIR /BINDIR=/'`
|
||||
eval $str
|
||||
fi
|
||||
if [ "x$BINDIR" = x ];then
|
||||
BINDIR="$BIN"
|
||||
fi
|
||||
|
||||
if [ -f ../../../Makefile ]; then
|
||||
str=`grep ^SBINDIR ../../../Makefile | head -1 | sed 's/ //g'`
|
||||
eval $str
|
||||
fi
|
||||
if [ "x$SBINDIR" = x ];then
|
||||
SBINDIR="$SBIN"
|
||||
fi
|
||||
|
||||
if [ -f $HOME/ltp/testcases/bin/fork01 ]; then
|
||||
LTPDIR=$HOME/ltp/testcases
|
||||
fi
|
||||
if [ "x$LTPDIR" = x ]; then
|
||||
LTPDIR="$LTP"
|
||||
fi
|
||||
|
||||
if [ ! -x $SBINDIR/mcstop+release.sh ]; then
|
||||
echo mcstop+release: not found >&2
|
||||
exit 1
|
||||
fi
|
||||
echo -n "mcstop+release.sh ... "
|
||||
sudo $SBINDIR/mcstop+release.sh
|
||||
echo "done"
|
||||
|
||||
if [ ! -x $SBINDIR/mcreboot.sh ]; then
|
||||
echo mcreboot: not found >&2
|
||||
exit 1
|
||||
fi
|
||||
echo -n "mcreboot.sh $BOOTPARAM ... "
|
||||
sudo $SBINDIR/mcreboot.sh $BOOTPARAM
|
||||
echo "done"
|
||||
|
||||
if [ ! -x $BINDIR/mcexec ]; then
|
||||
echo no mcexec found >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
if [ x$LTPDIR = x ]; then
|
||||
echo no LTP found >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for i in fork02:01 fork03:02 execve01:03 execve02:04 execve03:05 mmap12:06; do
|
||||
tp=`echo $i|sed 's/:.*//'`
|
||||
id=`echo $i|sed 's/.*://'`
|
||||
sudo sh -c "PATH=$LTPDIR/bin:$PATH $BINDIR/mcexec $LTPDIR/bin/$tp" 2>&1 | tee $tp.txt
|
||||
ok=`grep TPASS $tp.txt | wc -l`
|
||||
ng=`grep TFAIL $tp.txt | wc -l`
|
||||
if [ $ng = 0 ]; then
|
||||
echo "*** C1039T$id: $tp OK ($ok)"
|
||||
else
|
||||
echo "*** C1039T$id: $tp NG (ok=$ok ng=%ng)"
|
||||
fi
|
||||
done
|
||||
37
test/issues/1039/C1039.txt
Normal file
37
test/issues/1039/C1039.txt
Normal file
@ -0,0 +1,37 @@
|
||||
Script started on Mon Aug 27 11:54:38 2018
|
||||
bash-4.2$ make test
|
||||
sh ./C1039.sh
|
||||
fork02 0 TINFO : Inside parent
|
||||
fork02 0 TINFO : Inside child
|
||||
fork02 0 TINFO : exit status of wait 0
|
||||
fork02 1 TPASS : test 1 PASSED
|
||||
*** C1039T01: fork02 OK (1)
|
||||
fork03 0 TINFO : process id in parent of child from fork : 29001
|
||||
fork03 1 TPASS : test 1 PASSED
|
||||
*** C1039T02: fork03 OK (1)
|
||||
execl01_child 1 TPASS : execve01_child executed
|
||||
execve01 0 TINFO : Child process returned TPASS
|
||||
*** C1039T03: execve01 OK (2)
|
||||
Error: Failed to open execve_child
|
||||
execve(): error loading ELF for file execve_child
|
||||
execve02 1 TPASS : execve() failed expectedly: TEST_ERRNO=EACCES(13): Permission denied
|
||||
execve02 0 TINFO : Child process returned TPASS
|
||||
*** C1039T04: execve02 OK (2)
|
||||
execve03 1 TPASS : execve failed as expected: TEST_ERRNO=ENAMETOOLONG(36): File name too long
|
||||
execve03 2 TPASS : execve failed as expected: TEST_ERRNO=ENOENT(2): No such file or directory
|
||||
lookup_exec_path: lookup_exec_path(): error stat
|
||||
execve03 3 TPASS : execve failed as expected: TEST_ERRNO=ENOTDIR(20): Not a directory
|
||||
execve03 4 TPASS : execve failed as expected: TEST_ERRNO=EFAULT(14): Bad address
|
||||
Error: /tmp/exe0BQ0Va/fake.29225 is not an executable?, errno: 13
|
||||
execve(): error loading ELF for file /tmp/exe0BQ0Va/fake.29225
|
||||
execve03 5 TPASS : execve failed as expected: TEST_ERRNO=EACCES(13): Permission denied
|
||||
Error: file /tmp/exe0BQ0Va/execve03.29225 is zero length
|
||||
execve(): error loading ELF for file /tmp/exe0BQ0Va/execve03.29225
|
||||
execve03 6 TPASS : execve failed as expected: TEST_ERRNO=ENOEXEC(8): Exec format error
|
||||
*** C1039T05: execve03 OK (6)
|
||||
mmap12 1 TPASS : Functionality of mmap() successful
|
||||
*** C1039T06: mmap12 OK (1)
|
||||
bash-4.2$ exit
|
||||
exit
|
||||
|
||||
Script done on Mon Aug 27 11:54:58 2018
|
||||
10
test/issues/1039/Makefile
Normal file
10
test/issues/1039/Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
CC=gcc
|
||||
TARGET=
|
||||
|
||||
all:: $(TARGET)
|
||||
|
||||
test:: $(TARGET)
|
||||
sh ./C1039.sh
|
||||
|
||||
clean::
|
||||
rm -f *.o $(TARGET)
|
||||
26
test/issues/1039/README
Normal file
26
test/issues/1039/README
Normal file
@ -0,0 +1,26 @@
|
||||
【Issue#1039 動作確認】
|
||||
□ テスト内容
|
||||
調査の結果、Issue#1039の指摘は本来発生しない現象なことが判明し、
|
||||
Issue#1039向けパッチ(POSTK_TEMP_FIX_14)は不要なため、本パッチの除去を行った。
|
||||
|
||||
このため、パッチ除去により動作に影響が無いことをLTPを用いて確認した。
|
||||
page faultのcopy on write処理が呼び出される以下のテストプログラムを選定した。
|
||||
|
||||
C1039T01 fork02
|
||||
C1039T02 fork03
|
||||
C1039T03 execve01
|
||||
C1039T04 execve02
|
||||
C1039T05 execve03
|
||||
C1039T06 mmap12
|
||||
|
||||
□ 実行手順
|
||||
$ make test
|
||||
|
||||
実行できない場合は、C1039.shの以下の行を適切に書き換えた後に実行。
|
||||
BIN= mcexec が存在するパス
|
||||
SBIN= mcreboot.sh が存在するパス
|
||||
LTP= LTP が存在するパス
|
||||
|
||||
□ 実行結果
|
||||
C1039.txt 参照。
|
||||
全ての項目が OK となっていることを確認。
|
||||
Reference in New Issue
Block a user