Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v3.0 #130

Merged
merged 23 commits into from
May 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8c2a3a3
[#108] Correct typo in process.h
hangpark May 8, 2017
19392ec
Merge pull request #109 from hangpark/iss/108
hangpark May 8, 2017
b259184
[#107] Implement frame table
hangpark May 8, 2017
ee7cbd5
Merge pull request #110 from hangpark/iss/107
hangpark May 8, 2017
f1c0082
[#111] Implement supplemental page table
hangpark May 9, 2017
57935ee
Merge pull request #112 from hangpark/iss/111
hangpark May 9, 2017
d1dd75f
[#114] Temporarily reduce test sets
hangpark May 9, 2017
1485d76
Merge pull request #115 from hangpark/iss/114
hangpark May 9, 2017
261b89e
[#113] Implement stack growth
hangpark May 9, 2017
72b9e24
Merge pull request #116 from hangpark/iss/113
hangpark May 9, 2017
25308e4
[#117] Implement swap table and swap in/out
hangpark May 10, 2017
71fdfba
[#117] Implement FIFO page eviction
hangpark May 10, 2017
bafe2cf
Merge pull request #118 from hangpark/iss/117
hangpark May 11, 2017
c828385
[#121] Remove unused method suppl_pt_evict
hangpark May 11, 2017
46f7e6e
Merge pull request #122 from hangpark/iss/121
hangpark May 11, 2017
009eb35
[#120] Change FIFO page replacement to clock algorithm
hangpark May 11, 2017
f263221
Merge pull request #123 from hangpark/iss/120
hangpark May 11, 2017
3d598fd
[#125] Give valid memory size to supplemental page table
hangpark May 11, 2017
f7bba13
Merge pull request #126 from hangpark/iss/125
hangpark May 11, 2017
da3af65
[#124] Change supplemental page table from list to hash
hangpark May 11, 2017
66b5170
Merge pull request #127 from hangpark/iss/124
hangpark May 11, 2017
2edf498
[#128] Validate user memory accessing by syscall
hangpark May 11, 2017
6414d80
Merge pull request #129 from hangpark/iss/128
hangpark May 11, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Makefile.build
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ userprog_SRC += userprog/gdt.c # GDT initialization.
userprog_SRC += userprog/tss.c # TSS management.

# No virtual memory code yet.
#vm_SRC = vm/file.c # Some file.
vm_SRC = vm/frame.c # Frame table management.
vm_SRC += vm/page.c # Supplemental page management.
vm_SRC += vm/swap.c # Swap table management.

# Filesystem code.
filesys_SRC = filesys/filesys.c # Filesystem core.
Expand Down
44 changes: 1 addition & 43 deletions src/tests/vm/Make.tests
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
tests/vm_TESTS = $(addprefix tests/vm/,pt-grow-stack pt-grow-pusha \
pt-grow-bad pt-big-stk-obj pt-bad-addr pt-bad-read pt-write-code \
pt-write-code2 pt-grow-stk-sc page-linear page-parallel page-merge-seq \
page-merge-par page-merge-stk page-merge-mm page-shuffle mmap-read \
mmap-close mmap-unmap mmap-overlap mmap-twice mmap-write mmap-exit \
mmap-shuffle mmap-bad-fd mmap-clean mmap-inherit mmap-misalign \
mmap-null mmap-over-code mmap-over-data mmap-over-stk mmap-remove \
mmap-zero)
page-merge-par page-merge-stk page-shuffle)

tests/vm_PROGS = $(tests/vm_TESTS) $(addprefix tests/vm/,child-linear \
child-sort child-qsort child-qsort-mm child-mm-wrt child-inherit)
Expand All @@ -33,32 +29,10 @@ tests/vm/page-merge-par_SRC = tests/vm/page-merge-par.c \
tests/vm/parallel-merge.c tests/arc4.c tests/lib.c tests/main.c
tests/vm/page-merge-stk_SRC = tests/vm/page-merge-stk.c \
tests/vm/parallel-merge.c tests/arc4.c tests/lib.c tests/main.c
tests/vm/page-merge-mm_SRC = tests/vm/page-merge-mm.c \
tests/vm/parallel-merge.c tests/arc4.c tests/lib.c tests/main.c
tests/vm/page-shuffle_SRC = tests/vm/page-shuffle.c tests/arc4.c \
tests/cksum.c tests/lib.c tests/main.c
tests/vm/mmap-read_SRC = tests/vm/mmap-read.c tests/lib.c tests/main.c
tests/vm/mmap-close_SRC = tests/vm/mmap-close.c tests/lib.c tests/main.c
tests/vm/mmap-unmap_SRC = tests/vm/mmap-unmap.c tests/lib.c tests/main.c
tests/vm/mmap-overlap_SRC = tests/vm/mmap-overlap.c tests/lib.c tests/main.c
tests/vm/mmap-twice_SRC = tests/vm/mmap-twice.c tests/lib.c tests/main.c
tests/vm/mmap-write_SRC = tests/vm/mmap-write.c tests/lib.c tests/main.c
tests/vm/mmap-exit_SRC = tests/vm/mmap-exit.c tests/lib.c tests/main.c
tests/vm/mmap-shuffle_SRC = tests/vm/mmap-shuffle.c tests/arc4.c \
tests/cksum.c tests/lib.c tests/main.c
tests/vm/mmap-bad-fd_SRC = tests/vm/mmap-bad-fd.c tests/lib.c tests/main.c
tests/vm/mmap-clean_SRC = tests/vm/mmap-clean.c tests/lib.c tests/main.c
tests/vm/mmap-inherit_SRC = tests/vm/mmap-inherit.c tests/lib.c tests/main.c
tests/vm/mmap-misalign_SRC = tests/vm/mmap-misalign.c tests/lib.c \
tests/main.c
tests/vm/mmap-null_SRC = tests/vm/mmap-null.c tests/lib.c tests/main.c
tests/vm/mmap-over-code_SRC = tests/vm/mmap-over-code.c tests/lib.c \
tests/main.c
tests/vm/mmap-over-data_SRC = tests/vm/mmap-over-data.c tests/lib.c \
tests/main.c
tests/vm/mmap-over-stk_SRC = tests/vm/mmap-over-stk.c tests/lib.c tests/main.c
tests/vm/mmap-remove_SRC = tests/vm/mmap-remove.c tests/lib.c tests/main.c
tests/vm/mmap-zero_SRC = tests/vm/mmap-zero.c tests/lib.c tests/main.c

tests/vm/child-linear_SRC = tests/vm/child-linear.c tests/arc4.c tests/lib.c
tests/vm/child-qsort_SRC = tests/vm/child-qsort.c tests/vm/qsort.c tests/lib.c
Expand All @@ -70,29 +44,13 @@ tests/vm/child-inherit_SRC = tests/vm/child-inherit.c tests/lib.c tests/main.c

tests/vm/pt-bad-read_PUTFILES = tests/vm/sample.txt
tests/vm/pt-write-code2_PUTFILES = tests/vm/sample.txt
tests/vm/mmap-close_PUTFILES = tests/vm/sample.txt
tests/vm/mmap-read_PUTFILES = tests/vm/sample.txt
tests/vm/mmap-unmap_PUTFILES = tests/vm/sample.txt
tests/vm/mmap-twice_PUTFILES = tests/vm/sample.txt
tests/vm/mmap-overlap_PUTFILES = tests/vm/zeros
tests/vm/mmap-exit_PUTFILES = tests/vm/child-mm-wrt
tests/vm/page-parallel_PUTFILES = tests/vm/child-linear
tests/vm/page-merge-seq_PUTFILES = tests/vm/child-sort
tests/vm/page-merge-par_PUTFILES = tests/vm/child-sort
tests/vm/page-merge-stk_PUTFILES = tests/vm/child-qsort
tests/vm/page-merge-mm_PUTFILES = tests/vm/child-qsort-mm
tests/vm/mmap-clean_PUTFILES = tests/vm/sample.txt
tests/vm/mmap-inherit_PUTFILES = tests/vm/sample.txt tests/vm/child-inherit
tests/vm/mmap-misalign_PUTFILES = tests/vm/sample.txt
tests/vm/mmap-null_PUTFILES = tests/vm/sample.txt
tests/vm/mmap-over-code_PUTFILES = tests/vm/sample.txt
tests/vm/mmap-over-data_PUTFILES = tests/vm/sample.txt
tests/vm/mmap-over-stk_PUTFILES = tests/vm/sample.txt
tests/vm/mmap-remove_PUTFILES = tests/vm/sample.txt

tests/vm/page-linear.output: TIMEOUT = 300
tests/vm/page-shuffle.output: TIMEOUT = 600
tests/vm/mmap-shuffle.output: TIMEOUT = 600
tests/vm/page-merge-seq.output: TIMEOUT = 600
tests/vm/page-merge-par.output: TIMEOUT = 600

Expand Down
103 changes: 103 additions & 0 deletions src/tests/vm/Make.tests.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# -*- makefile -*-

tests/vm_TESTS = $(addprefix tests/vm/,pt-grow-stack pt-grow-pusha \
pt-grow-bad pt-big-stk-obj pt-bad-addr pt-bad-read pt-write-code \
pt-write-code2 pt-grow-stk-sc page-linear page-parallel page-merge-seq \
page-merge-par page-merge-stk page-merge-mm page-shuffle mmap-read \
mmap-close mmap-unmap mmap-overlap mmap-twice mmap-write mmap-exit \
mmap-shuffle mmap-bad-fd mmap-clean mmap-inherit mmap-misalign \
mmap-null mmap-over-code mmap-over-data mmap-over-stk mmap-remove \
mmap-zero)

tests/vm_PROGS = $(tests/vm_TESTS) $(addprefix tests/vm/,child-linear \
child-sort child-qsort child-qsort-mm child-mm-wrt child-inherit)

tests/vm/pt-grow-stack_SRC = tests/vm/pt-grow-stack.c tests/arc4.c \
tests/cksum.c tests/lib.c tests/main.c
tests/vm/pt-grow-pusha_SRC = tests/vm/pt-grow-pusha.c tests/lib.c \
tests/main.c
tests/vm/pt-grow-bad_SRC = tests/vm/pt-grow-bad.c tests/lib.c tests/main.c
tests/vm/pt-big-stk-obj_SRC = tests/vm/pt-big-stk-obj.c tests/arc4.c \
tests/cksum.c tests/lib.c tests/main.c
tests/vm/pt-bad-addr_SRC = tests/vm/pt-bad-addr.c tests/lib.c tests/main.c
tests/vm/pt-bad-read_SRC = tests/vm/pt-bad-read.c tests/lib.c tests/main.c
tests/vm/pt-write-code_SRC = tests/vm/pt-write-code.c tests/lib.c tests/main.c
tests/vm/pt-write-code2_SRC = tests/vm/pt-write-code-2.c tests/lib.c tests/main.c
tests/vm/pt-grow-stk-sc_SRC = tests/vm/pt-grow-stk-sc.c tests/lib.c tests/main.c
tests/vm/page-linear_SRC = tests/vm/page-linear.c tests/arc4.c \
tests/lib.c tests/main.c
tests/vm/page-parallel_SRC = tests/vm/page-parallel.c tests/lib.c tests/main.c
tests/vm/page-merge-seq_SRC = tests/vm/page-merge-seq.c tests/arc4.c \
tests/lib.c tests/main.c
tests/vm/page-merge-par_SRC = tests/vm/page-merge-par.c \
tests/vm/parallel-merge.c tests/arc4.c tests/lib.c tests/main.c
tests/vm/page-merge-stk_SRC = tests/vm/page-merge-stk.c \
tests/vm/parallel-merge.c tests/arc4.c tests/lib.c tests/main.c
tests/vm/page-merge-mm_SRC = tests/vm/page-merge-mm.c \
tests/vm/parallel-merge.c tests/arc4.c tests/lib.c tests/main.c
tests/vm/page-shuffle_SRC = tests/vm/page-shuffle.c tests/arc4.c \
tests/cksum.c tests/lib.c tests/main.c
tests/vm/mmap-read_SRC = tests/vm/mmap-read.c tests/lib.c tests/main.c
tests/vm/mmap-close_SRC = tests/vm/mmap-close.c tests/lib.c tests/main.c
tests/vm/mmap-unmap_SRC = tests/vm/mmap-unmap.c tests/lib.c tests/main.c
tests/vm/mmap-overlap_SRC = tests/vm/mmap-overlap.c tests/lib.c tests/main.c
tests/vm/mmap-twice_SRC = tests/vm/mmap-twice.c tests/lib.c tests/main.c
tests/vm/mmap-write_SRC = tests/vm/mmap-write.c tests/lib.c tests/main.c
tests/vm/mmap-exit_SRC = tests/vm/mmap-exit.c tests/lib.c tests/main.c
tests/vm/mmap-shuffle_SRC = tests/vm/mmap-shuffle.c tests/arc4.c \
tests/cksum.c tests/lib.c tests/main.c
tests/vm/mmap-bad-fd_SRC = tests/vm/mmap-bad-fd.c tests/lib.c tests/main.c
tests/vm/mmap-clean_SRC = tests/vm/mmap-clean.c tests/lib.c tests/main.c
tests/vm/mmap-inherit_SRC = tests/vm/mmap-inherit.c tests/lib.c tests/main.c
tests/vm/mmap-misalign_SRC = tests/vm/mmap-misalign.c tests/lib.c \
tests/main.c
tests/vm/mmap-null_SRC = tests/vm/mmap-null.c tests/lib.c tests/main.c
tests/vm/mmap-over-code_SRC = tests/vm/mmap-over-code.c tests/lib.c \
tests/main.c
tests/vm/mmap-over-data_SRC = tests/vm/mmap-over-data.c tests/lib.c \
tests/main.c
tests/vm/mmap-over-stk_SRC = tests/vm/mmap-over-stk.c tests/lib.c tests/main.c
tests/vm/mmap-remove_SRC = tests/vm/mmap-remove.c tests/lib.c tests/main.c
tests/vm/mmap-zero_SRC = tests/vm/mmap-zero.c tests/lib.c tests/main.c

tests/vm/child-linear_SRC = tests/vm/child-linear.c tests/arc4.c tests/lib.c
tests/vm/child-qsort_SRC = tests/vm/child-qsort.c tests/vm/qsort.c tests/lib.c
tests/vm/child-qsort-mm_SRC = tests/vm/child-qsort-mm.c tests/vm/qsort.c \
tests/lib.c
tests/vm/child-sort_SRC = tests/vm/child-sort.c tests/lib.c
tests/vm/child-mm-wrt_SRC = tests/vm/child-mm-wrt.c tests/lib.c tests/main.c
tests/vm/child-inherit_SRC = tests/vm/child-inherit.c tests/lib.c tests/main.c

tests/vm/pt-bad-read_PUTFILES = tests/vm/sample.txt
tests/vm/pt-write-code2_PUTFILES = tests/vm/sample.txt
tests/vm/mmap-close_PUTFILES = tests/vm/sample.txt
tests/vm/mmap-read_PUTFILES = tests/vm/sample.txt
tests/vm/mmap-unmap_PUTFILES = tests/vm/sample.txt
tests/vm/mmap-twice_PUTFILES = tests/vm/sample.txt
tests/vm/mmap-overlap_PUTFILES = tests/vm/zeros
tests/vm/mmap-exit_PUTFILES = tests/vm/child-mm-wrt
tests/vm/page-parallel_PUTFILES = tests/vm/child-linear
tests/vm/page-merge-seq_PUTFILES = tests/vm/child-sort
tests/vm/page-merge-par_PUTFILES = tests/vm/child-sort
tests/vm/page-merge-stk_PUTFILES = tests/vm/child-qsort
tests/vm/page-merge-mm_PUTFILES = tests/vm/child-qsort-mm
tests/vm/mmap-clean_PUTFILES = tests/vm/sample.txt
tests/vm/mmap-inherit_PUTFILES = tests/vm/sample.txt tests/vm/child-inherit
tests/vm/mmap-misalign_PUTFILES = tests/vm/sample.txt
tests/vm/mmap-null_PUTFILES = tests/vm/sample.txt
tests/vm/mmap-over-code_PUTFILES = tests/vm/sample.txt
tests/vm/mmap-over-data_PUTFILES = tests/vm/sample.txt
tests/vm/mmap-over-stk_PUTFILES = tests/vm/sample.txt
tests/vm/mmap-remove_PUTFILES = tests/vm/sample.txt

tests/vm/page-linear.output: TIMEOUT = 300
tests/vm/page-shuffle.output: TIMEOUT = 600
tests/vm/mmap-shuffle.output: TIMEOUT = 600
tests/vm/page-merge-seq.output: TIMEOUT = 600
tests/vm/page-merge-par.output: TIMEOUT = 600

tests/vm/zeros:
dd if=/dev/zero of=$@ bs=1024 count=6

clean::
rm -f tests/vm/zeros
16 changes: 0 additions & 16 deletions src/tests/vm/Rubric.functionality
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,4 @@ Functionality of virtual memory subsystem:
3 page-shuffle
4 page-merge-seq
4 page-merge-par
4 page-merge-mm
4 page-merge-stk

- Test "mmap" system call.
2 mmap-read
2 mmap-write
2 mmap-shuffle

2 mmap-twice

2 mmap-unmap
1 mmap-exit

3 mmap-clean

2 mmap-close
2 mmap-remove
30 changes: 30 additions & 0 deletions src/tests/vm/Rubric.functionality.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Functionality of virtual memory subsystem:
- Test stack growth.
3 pt-grow-stack
3 pt-grow-stk-sc
3 pt-big-stk-obj
3 pt-grow-pusha

- Test paging behavior.
3 page-linear
3 page-parallel
3 page-shuffle
4 page-merge-seq
4 page-merge-par
4 page-merge-mm
4 page-merge-stk

- Test "mmap" system call.
2 mmap-read
2 mmap-write
2 mmap-shuffle

2 mmap-twice

2 mmap-unmap
1 mmap-exit

3 mmap-clean

2 mmap-close
2 mmap-remove
14 changes: 0 additions & 14 deletions src/tests/vm/Rubric.robustness
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,3 @@ Robustness of virtual memory subsystem:
2 pt-write-code
3 pt-write-code2
4 pt-grow-bad

- Test robustness of "mmap" system call.
1 mmap-bad-fd
1 mmap-inherit
1 mmap-null
1 mmap-zero

2 mmap-misalign

2 mmap-over-code
2 mmap-over-data
2 mmap-over-stk
2 mmap-overlap

21 changes: 21 additions & 0 deletions src/tests/vm/Rubric.robustness.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Robustness of virtual memory subsystem:
- Test robustness of page table support.
2 pt-bad-addr
3 pt-bad-read
2 pt-write-code
3 pt-write-code2
4 pt-grow-bad

- Test robustness of "mmap" system call.
1 mmap-bad-fd
1 mmap-inherit
1 mmap-null
1 mmap-zero

2 mmap-misalign

2 mmap-over-code
2 mmap-over-data
2 mmap-over-stk
2 mmap-overlap

10 changes: 10 additions & 0 deletions src/threads/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
#include "filesys/filesys.h"
#include "filesys/fsutil.h"
#endif
#ifdef VM
#include "vm/frame.h"
#include "vm/swap.h"
#endif

/* Amount of physical memory, in 4 kB pages. */
size_t ram_pages;
Expand Down Expand Up @@ -87,6 +91,9 @@ main (void)
palloc_init ();
malloc_init ();
paging_init ();
#ifdef VM
frame_table_init ();
#endif

/* Segmentation. */
#ifdef USERPROG
Expand All @@ -113,6 +120,9 @@ main (void)
/* Initialize file system. */
disk_init ();
filesys_init (format_filesys);
#ifdef VM
swap_table_init ();
#endif
#endif

printf ("Boot complete.\n");
Expand Down
5 changes: 5 additions & 0 deletions src/threads/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#ifdef USERPROG
#include "userprog/process.h"
#endif
#ifdef VM
#include "vm/page.h"
#endif

/* States in a thread's life cycle. */
enum thread_status
Expand Down Expand Up @@ -106,6 +109,8 @@ struct thread
/* Owned by userprog/process.c. */
struct process process; /* User process. */
uint32_t *pagedir; /* Page directory. */
struct suppl_pt *suppl_pt; /* Suppplemental page table. */
uint32_t *esp; /* Stack pointer. */
#endif

/* Owned by thread.c. */
Expand Down
32 changes: 29 additions & 3 deletions src/userprog/exception.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#include "userprog/exception.h"
#include <debug.h>
#include <inttypes.h>
#include <stdio.h>
#include <debug.h>
#include "userprog/gdt.h"
#include "userprog/syscall.h"
#include "threads/interrupt.h"
#include "threads/thread.h"
#include "threads/vaddr.h"
#include "userprog/gdt.h"
#include "userprog/syscall.h"

#define STACK_LIMIT 0x40000000

/* Number of page faults processed. */
static long long page_fault_cnt;
Expand Down Expand Up @@ -150,6 +153,29 @@ page_fault (struct intr_frame *f)
write = (f->error_code & PF_W) != 0;
user = (f->error_code & PF_U) != 0;

#ifdef VM
void *upage = pg_round_down (fault_addr);

/* Only deal with a fault caused by a non-present page.
See [IA32-v3a] 6-41 for more information. */
if (!not_present)
goto page_level_protection_violation;

/* Stack growth. */
uint32_t *esp = user ? f->esp : thread_current ()->esp;
if (STACK_LIMIT <= fault_addr && fault_addr < PHYS_BASE
&& esp - 16 <= fault_addr && suppl_pt_get_page (upage) == NULL)
{
if (!suppl_pt_set_zero (upage))
goto page_level_protection_violation;
}

/* Load page from appropriate source. */
if (suppl_pt_load_page (upage))
return;
#endif

page_level_protection_violation:
/* Change EIP to the next instruction address which is saved on
EAX, and set EAX by -1 to return the failure code. */
if (!user)
Expand Down
Loading