Commit a3299f60 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 8cbc77ab
...@@ -96,7 +96,8 @@ LINKC = $(LINK.c) $< $(LOADLIBES) $(LDLIBS) -o $@ ...@@ -96,7 +96,8 @@ LINKC = $(LINK.c) $< $(LOADLIBES) $(LDLIBS) -o $@
# tests without instrumentation # tests without instrumentation
test.t : $(TESTS:%=%.trun) test.t : $(TESTS:%=%.trun)
%.trun : %.t %.trun : %.t
gdb -q -ex run -ex backtrace -ex quit $(XRUN<) #gdb -q -ex run -ex backtrace -ex quit $(XRUN<)
$(XRUN<)
%.t : %.c $(ccan_config) %.t : %.c $(ccan_config)
$(LINKC) $(LINKC)
......
...@@ -1179,11 +1179,15 @@ void test_file_access_mmapbase(void) ...@@ -1179,11 +1179,15 @@ void test_file_access_mmapbase(void)
RAM *ram; RAM *ram;
BigFileH fh_struct, *fh = &fh_struct; BigFileH fh_struct, *fh = &fh_struct;
VMA vma_struct, *vma = &vma_struct; VMA vma_struct, *vma = &vma_struct;
Page *page0, *page2, *page3;
size_t PS, PSb; size_t PS, PSb;
int fd, err; int fd, err;
diag("Testing file access (mmap base)"); diag("Testing file access (mmap base)");
// XXX save/restore sigaction ?
ok1(!pagefault_init());
ram = ram_new(NULL, NULL); ram = ram_new(NULL, NULL);
ok1(ram); ok1(ram);
PS = ram->pagesize; PS = ram->pagesize;
...@@ -1243,6 +1247,7 @@ void test_file_access_mmapbase(void) ...@@ -1243,6 +1247,7 @@ void test_file_access_mmapbase(void)
ok1(!M(vma, 3)); CHECK_NOPAGE( 103 ); ok1(!M(vma, 3)); CHECK_NOPAGE( 103 );
ok1(list_empty(&ram->lru_list)); ok1(list_empty(&ram->lru_list));
ok1(list_empty(&fh->dirty_pages));
/* read page[0] - served from base mmap and no RAM page is loaded */ /* read page[0] - served from base mmap and no RAM page is loaded */
ok1(B(vma, 0*PSb) == 100); ok1(B(vma, 0*PSb) == 100);
...@@ -1251,6 +1256,22 @@ void test_file_access_mmapbase(void) ...@@ -1251,6 +1256,22 @@ void test_file_access_mmapbase(void)
ok1(!M(vma, 1)); CHECK_NOPAGE( 101 ); ok1(!M(vma, 1)); CHECK_NOPAGE( 101 );
ok1(!M(vma, 2)); CHECK_NOPAGE( 102 ); ok1(!M(vma, 2)); CHECK_NOPAGE( 102 );
ok1(!M(vma, 3)); CHECK_NOPAGE( 103 ); ok1(!M(vma, 3)); CHECK_NOPAGE( 103 );
ok1(list_empty(&ram->lru_list));
ok1(list_empty(&fh->dirty_pages));
/* write to page[2] = XXX */
B(vma, 2*PSb) = 12;
page2 = pagemap_get(&fh->pagemap, 102);
ok1(!M(vma, 0)); CHECK_NOPAGE( 100 );
ok1(!M(vma, 1)); CHECK_NOPAGE( 101 );
ok1( M(vma, 2)); CHECK_PAGE (page2, 102, PAGE_DIRTY, 1);
ok1(!M(vma, 3)); CHECK_NOPAGE( 103 );
ok1(ram->lru_list.prev == &page2->lru);
ok1(page2->lru.prev == &ram->lru_list);
} }
......
...@@ -615,7 +615,9 @@ VMFaultResult vma_on_pagefault(VMA *vma, uintptr_t addr, int write) ...@@ -615,7 +615,9 @@ VMFaultResult vma_on_pagefault(VMA *vma, uintptr_t addr, int write)
/* continuing on_pagefault() - see (1) there ... */ /* continuing on_pagefault() - see (1) there ... */
// XXX overlay: assert write /* wcfs: we should get into SIGSEGV handler only on write access */
if (vma->mmap_overlay)
BUG_ON(!write);
/* (2) vma, addr -> fileh, pagen ;idx of fileh page covering addr */ /* (2) vma, addr -> fileh, pagen ;idx of fileh page covering addr */
fileh = vma->fileh; fileh = vma->fileh;
...@@ -624,7 +626,12 @@ VMFaultResult vma_on_pagefault(VMA *vma, uintptr_t addr, int write) ...@@ -624,7 +626,12 @@ VMFaultResult vma_on_pagefault(VMA *vma, uintptr_t addr, int write)
/* (3) fileh, pagen -> page (via pagemap) */ /* (3) fileh, pagen -> page (via pagemap) */
page = pagemap_get(&fileh->pagemap, pagen); page = pagemap_get(&fileh->pagemap, pagen);
// XXX overlay: assert !page /* wcfs: all dirty pages are mmapped when vma is created */
// FIXME no: it could be in PAGE_LOADING state
// XXX and after VM_RETRY it could be in PAGE_LOADED state
// XXX ----//---- even for write
if (vma->mmap_overlay)
BUG_ON(page);
/* (4) no page found - allocate new from ram */ /* (4) no page found - allocate new from ram */
while (!page) { while (!page) {
...@@ -697,7 +704,7 @@ VMFaultResult vma_on_pagefault(VMA *vma, uintptr_t addr, int write) ...@@ -697,7 +704,7 @@ VMFaultResult vma_on_pagefault(VMA *vma, uintptr_t addr, int write)
// XXX overlay: copy data from base image, page.state=DIRTY // XXX overlay: copy data from base image, page.state=DIRTY
// XXX overlay: goto inject_page // XXX overlay: goto inject_page
/* loadblk() -> pageram memory */ /* load block -> pageram memory */
blk = page->f_pgoffset; // NOTE because blksize = pagesize blk = page->f_pgoffset; // NOTE because blksize = pagesize
/* mark page as loading and unlock virtmem before calling loadblk() /* mark page as loading and unlock virtmem before calling loadblk()
...@@ -709,15 +716,23 @@ VMFaultResult vma_on_pagefault(VMA *vma, uintptr_t addr, int write) ...@@ -709,15 +716,23 @@ VMFaultResult vma_on_pagefault(VMA *vma, uintptr_t addr, int write)
page->state = PAGE_LOADING; page->state = PAGE_LOADING;
virt_unlock(); virt_unlock();
err = file->file_ops->loadblk(file, blk, pageram); if (vma->mmap_overlay) {
/* wcfs: copy block data from read-only base mmap.
* NOTE we'll get SIGBUG here if wcfs returns EIO when loading block data */
memcpy(pageram, vma_page_addr(vma, page), page_size(page));
}
else {
/* !wcfs: call loadblk */
err = file->file_ops->loadblk(file, blk, pageram);
/* TODO on error -> try to throw exception somehow to the caller, so /* TODO on error -> try to throw exception somehow to the caller, so
* that it can abort current transaction, but not die. * that it can abort current transaction, but not die.
* *
* NOTE for analogue situation when read for mmaped file fails, the * NOTE for analogue situation when read for mmaped file fails, the
* kernel sends SIGBUS * kernel sends SIGBUS
*/ */
TODO (err); TODO (err);
}
/* relock virtmem */ /* relock virtmem */
virt_lock(); virt_lock();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment