Skip to content
This repository has been archived by the owner on Jun 9, 2020. It is now read-only.

can we have the oposit of noah ? #87

Open
wants to merge 81 commits into
base: bench
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
5745695
Merge remote-tracking branch 'origin/bench'
nyuichi Jul 10, 2017
0e06212
HACKING.md: add a note about noahstrap
nyuichi Jul 10, 2017
144b062
version 0.5.0
nyuichi Jul 10, 2017
9c83116
update README
nyuichi Jul 10, 2017
827616a
Update README.md
nullpo-head Nov 22, 2017
093dd50
Fix the screenshot's size
nullpo-head Nov 22, 2017
7850591
support macOS High Sierra by removing unnecessary save of VMCS fields
utshina Jan 19, 2018
c97fe60
Merge pull request #45 from utshina/high_sierra
nullpo-head Jan 24, 2018
32d1fa6
Fix unlink() not to follow symlinks
utshina Feb 8, 2018
7a5bacd
Fix rename() not to follow old file symlinks
utshina Feb 8, 2018
dc59dca
Fix a bound check error in msync()
utshina Feb 8, 2018
9468dcf
Fix mmap() to return errno rather than panic
utshina Feb 9, 2018
1434bc5
Fix shmat() to work correctly
utshina Feb 9, 2018
506d5bd
Fix sendto() to use sockaddr
utshina Feb 12, 2018
aa68538
Fix socketpair() to work correctly
utshina Feb 13, 2018
e487d0b
Fix recvfrom() to avoid unnecessary copy
utshina Feb 13, 2018
46437cb
Fix open() to avoid use-after-free
utshina Feb 14, 2018
fcab6c6
Fix futex() to return EWOULDBLOCK if *uaddr != val
utshina Feb 19, 2018
ac07075
Fix launcher to pass arguments with spaces correctly
clashman Feb 20, 2018
b31cfa0
Merge pull request #49 from clashman/master
nyuichi Feb 21, 2018
4958daf
Describe the requirements of macOS version
nullpo-head Feb 27, 2018
305b046
Enable AVX instructions on demand
utshina Feb 27, 2018
176ba09
version 0.5.1
nullpo-head Mar 5, 2018
c11c9e5
version section is not mandatory. thanks you, @equal-l2!
nyuichi Mar 10, 2018
c48a0af
Fix getrlimit() to return RLIM_INFINITY
kazumi007 Mar 30, 2018
fdfb667
Merge pull request #54 from kazumi007/fix-getrlimit
nyuichi Mar 30, 2018
6869b5f
Fix getrlimit() to return EINVAL if a resource value isn't valid.
kazumi007 Mar 31, 2018
39593a7
Merge pull request #55 from kazumi007/fix-getrlimit-res-invalid
nyuichi Mar 31, 2018
3b861d2
Preserve rbx regsiter when cpuid is called.
kazumi007 Apr 3, 2018
15baf0b
Add get_cpu_count function
kazumi007 Apr 4, 2018
296fa1d
Merge pull request #57 from kazumi007/preserve-rbx
nyuichi Apr 4, 2018
34db718
Fix the wrong offset in alloc fdtable
kazumi007 Apr 4, 2018
a7905c0
Merge pull request #59 from kazumi007/fix-offset
nyuichi Apr 8, 2018
1861bc4
Support TCXONC, FIONREAD and FIONBIO commands in ioctl
kazumi007 Apr 11, 2018
ae9e014
Merge pull request #61 from kazumi007/add-ioctl-cmd2
nyuichi Apr 11, 2018
248993e
Add support for MSG_NOSIGNAL flag in sendmsg and sendmmsg
kazumi007 Apr 11, 2018
70e1d52
Fix wrong address error in print_gstr
kazumi007 Apr 16, 2018
6a7279c
Merge pull request #63 from kazumi007/fix-print_gstr2
nyuichi Apr 17, 2018
36ee750
Use panic function if setsockopt fail
kazumi007 Apr 17, 2018
788ba08
Merge pull request #62 from kazumi007/add-msg-nosignal
nyuichi Apr 17, 2018
a83dc3d
Use panic() instead of assert() in darwin_statfs
kazumi007 Apr 18, 2018
2e570f7
Merge pull request #64 from kazumi007/fix-statfs
nyuichi Apr 18, 2018
e02e6b9
Add PR_SET_NAME cmd in prctl()
kazumi007 Apr 20, 2018
8dee88d
Merge pull request #65 from kazumi007/impl-pr-set-name
nyuichi Apr 20, 2018
af7efc8
update README
nyuichi Apr 23, 2018
86a4903
Add LOOKUP_NOFOLLOW option to the newpath
kazumi007 Apr 27, 2018
8997a6f
Merge pull request #66 from kazumi007/fix-renameat
nyuichi Apr 27, 2018
a3bf9ab
Remove copy_to_user from pwrite64
kazumi007 Apr 27, 2018
1a21a48
Merge pull request #67 from kazumi007/fix-pwrite64
nyuichi Apr 28, 2018
c856284
add setitimer and getitimer systemcalls
kazumi007 May 2, 2018
ab0f2cd
Better debuging for unhandled VM exit reasons.
May 4, 2018
c183515
Fix unlink to return EISDIR when pathname refers to a directory
kazumi007 May 4, 2018
296659d
Merge pull request #70 from kazumi007/fix-unlink
nyuichi May 5, 2018
e53ca10
Merge pull request #69 from georghe-crihan/master
nyuichi May 5, 2018
1acb7c4
Add comment about which value
kazumi007 May 5, 2018
e3a8af8
Merge pull request #68 from kazumi007/impl-setitimer
nyuichi May 5, 2018
2930caa
Add a macports Portfile for noah.
May 6, 2018
2d947b6
Merge pull request #71 from georghe-crihan/master
nyuichi May 6, 2018
cdb9817
Add noah(1) manual page with command line options and detailed descri…
May 6, 2018
5802383
Update noah.1
georghe-crihan May 6, 2018
1874c12
Update noah.md
georghe-crihan May 6, 2018
ed0072d
Update README.md
georghe-crihan May 6, 2018
d30a9be
Merge pull request #72 from georghe-crihan/master
nyuichi May 6, 2018
7b38bce
Add mkfifo
kazumi007 May 7, 2018
de925ac
Check strncpy return value
kazumi007 May 7, 2018
a41116d
Merge pull request #73 from kazumi007/add-mkfifo
nyuichi May 7, 2018
83eeaec
Fix crash when directory is specified in elf path
kazumi007 May 16, 2018
528d716
Merge pull request #75 from kazumi007/fix-exec
nyuichi May 16, 2018
5d9c216
Change the macro name PAGE_SIZE() to PAGE_SIZEOF() to avoid conflict …
utshina Oct 18, 2018
4e0f847
Change the macro name PAGE_SHIFT() to PAGE_SHIFTOF() to avoid conflic…
utshina Oct 18, 2018
b61c85c
Add support for the MAP_HUGETLB flag in mmap()
utshina Oct 18, 2018
fe98199
Pre-MacOS 16 system clock support
araven Dec 29, 2018
b367b67
update sysctlbyname()
johnothwolo Feb 8, 2020
c339845
Better fix for sysctlbyname()
johnothwolo Feb 8, 2020
efdc358
Update MacPorts installation instructions
ryandesign May 28, 2020
d5d5407
Fix spelling
Skaldebane Jun 5, 2020
31f779b
Merge pull request #103 from johnothwolo/master
nullpo-head Jun 9, 2020
cc7037a
Merge pull request #106 from Skaldebane/patch-1
nullpo-head Jun 9, 2020
80e56a7
Merge pull request #105 from ryandesign/macports
nullpo-head Jun 9, 2020
6020a6a
Merge pull request #89 from araven/master
nullpo-head Jun 9, 2020
cab1ee3
Update README.md
nullpo-head Jun 9, 2020
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
13 changes: 10 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
cmake_minimum_required(VERSION 3.7)

project(noah VERSION 0.3.9)
project(noah VERSION 0.5.1)

configure_file(bin/noah.in ${PROJECT_SOURCE_DIR}/bin/noah @ONLY)
configure_file(include/version.h.in ${PROJECT_SOURCE_DIR}/include/version.h)

if (CMAKE_HOST_SYSTEM_VERSION VERSION_LESS 16.0.0)
add_definitions("-DMACOS_PRE_16")
endif()

find_library(HYPERVISOR_FRAMEWORK Hypervisor)
find_library(PTHREAD_LIBRARY pthread)

set(CMAKE_C_FLAGS "-Wall -Wextra -Wno-unused-parameter -std=gnu11")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2")
include_directories(include)

add_executable(noah
Expand All @@ -33,10 +39,11 @@ add_executable(noah
src/mm/shm.c
src/ipc/sem.c
)
target_link_libraries(noah pthread "-framework Hypervisor")
target_link_libraries(noah ${PTHREAD_LIBRARY} ${HYPERVISOR_FRAMEWORK})

install(PROGRAMS bin/noah DESTINATION bin)
install(TARGETS noah DESTINATION libexec)
install(FILES man/noah.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/man/man1)

enable_testing()
add_subdirectory(test)
9 changes: 9 additions & 0 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ $ INSTALL_PREFIX/libexec/noah -m ROOT_PATH PATH_TO_INIT
```
where `ROOT_PATH` is a path to the directory that is treated as the root mount point in the Linux box, and `PATH_TO_INIT` is a path to the first command to be run in the boot sequence, like `/bin/bash`.

`noahstrap` helps you set up a Linux environment on your local machine.
It retrieves a ready-to-use distro image from the Internet and extracts it to a specified directory.
`noahstrap` is installed via homebrew.

```console
$ brew install linux-noah/noah/noahstrap
$ noahstrap --help # prints help message
```

## Debugging

There are several methods to debug `noah`.
Expand Down
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
# Noah [![Build Status](http://noah-ci.idylls.jp/job/noah/badge/icon)](http://noah-ci.idylls.jp/job/noah/)
# Noah

Noah is a Darwin subsystem for Linux, or "Bash on Ubuntu on Mac OS X". Noah is implemented as a hypervisor that traps linux system calls and translates them into Darwin's system calls. Noah also has an interpreter of ELF files so that binary executables of Linux run directly and flawlessly without any modifications.

__Noah is an experimental product__. Most Linux apps don't work well due to missing system calls. For the technical details, please refer to [its academic paper](https://dl.acm.org/doi/abs/10.1145/3381052.3381327). Currently, this repository is not actively maintained. It might not run on the latest macOS.

<img src="https://github.com/linux-noah/noah/blob/master/images/screenshot.png" width="600">

## Quick Start

Noah is installed via homebrew. On the first run, noah automatically downloads and installs a comprehensive linux environment in your home directory (by default, ubuntu 16.04 is installed in `~/.noah/tree`).
Noah is installed via Homebrew or MacPorts. On the first run, noah automatically downloads and installs a comprehensive linux environment in your home directory (by default, ubuntu 16.04 is installed in `~/.noah/tree`).
macOS Sierra or higher is required.

### Homebrew

```console
$ brew install linux-noah/noah/noah
$ noah
```
### MacPorts

$ brew tap linux-noah/noah
$ brew install noah
$ noah
```console
$ sudo port install noah
$ noah
```

## Hacking

See [HACKING.md](HACKING.md).

## LICENSE

Dual MITL/GPL, for all files without explicit notaiton.
Dual MITL/GPL, for all files without explicit notation.
2 changes: 1 addition & 1 deletion bin/noah.in
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if ($> != 0) {

my $init = "/bin/bash -i";
if (@ARGV != 0) {
$init = "@ARGV";
$init = join(" ", map {"'$_'"} @ARGV);
}

my $opts = "";
Expand Down
Binary file added images/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions include/linux/futex.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,51 @@ struct linux_robust_list_head {
l_uintptr_t pending_list;
};

#define LINUX_PR_SET_PDEATHSIG 1
#define LINUX_PR_GET_PDEATHSIG 2
#define LINUX_PR_GET_DUMPABLE 3
#define LINUX_PR_SET_DUMPABLE 4
#define LINUX_PR_GET_UNALIGN 5
#define LINUX_PR_SET_UNALIGN 6
#define LINUX_PR_GET_KEEPCAPS 7
#define LINUX_PR_SET_KEEPCAPS 8
#define LINUX_PR_GET_FPEMU 9
#define LINUX_PR_SET_FPEMU 10
#define LINUX_PR_GET_FPEXC 11
#define LINUX_PR_SET_FPEXC 12
#define LINUX_PR_GET_TIMING 13
#define LINUX_PR_SET_TIMING 14
#define LINUX_PR_SET_NAME 15
#define LINUX_PR_GET_NAME 16

#define LINIX_PR_GET_ENDIAN 19
#define LINIX_PR_SET_ENDIAN 20
#define LINIX_PR_GET_SECCOMP 21
#define LINIX_PR_SET_SECCOMP 22
#define LINIX_PR_CAPBSET_READ 23
#define LINIX_PR_CAPBSET_DROP 24
#define LINIX_PR_GET_TSC 25
#define LINIX_PR_SET_TSC 26
#define LINIX_PR_GET_SECUREBITS 27
#define LINIX_PR_SET_SECUREBITS 28
#define LINIX_PR_SET_TIMERSLACK 29
#define LINIX_PR_GET_TIMERSLACK 30
#define LINIX_PR_TASK_PERF_EVENTS_DISABLE 31
#define LINIX_PR_TASK_PERF_EVENTS_ENABLE 32
#define LINIX_PR_MCE_KILL 33
#define LINIX_PR_MCE_KILL_GET 34
#define LINIX_PR_SET_MM 35
#define LINIX_PR_SET_CHILD_SUBREAPER 36
#define LINIX_PR_GET_CHILD_SUBREAPER 37
#define LINIX_PR_SET_NO_NEW_PRIVS 38
#define LINIX_PR_GET_NO_NEW_PRIVS 39
#define LINIX_PR_GET_TID_ADDRESS 40
#define LINIX_PR_SET_THP_DISABLE 41
#define LINIX_PR_GET_THP_DISABLE 42
#define LINIX_PR_MPX_ENABLE_MANAGEMENT 43
#define LINIX_PR_MPX_DISABLE_MANAGEMENT 44
#define LINIX_PR_SET_FP_MODE 45
#define LINIX_PR_GET_FP_MODE 46
#define LINIX_PR_CAP_AMBIENT 47

#endif /* !_LINUX_FUTEX_H */
2 changes: 2 additions & 0 deletions include/linux/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ struct l___sysctl_args

#define LINUX_RLIM_NLIMITS 10

#define LINUX_RLIM_INFINITY (~0UL)

struct l_rlimit {
l_ulong rlim_cur;
l_ulong rlim_max;
Expand Down
5 changes: 5 additions & 0 deletions include/linux/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ struct l_timezone {

typedef uint32_t l_clockid_t;

struct l_itimerval {
struct l_timeval it_interval;
struct l_timeval it_value;
};

#define LINUX_CLOCK_REALTIME 0
#define LINUX_CLOCK_MONOTONIC 1
#define LINUX_CLOCK_PROCESS_CPUTIME_ID 2
Expand Down
2 changes: 1 addition & 1 deletion include/noah.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct task {
struct fdtable {
int start; // First fd number of this table
int size; // Current table size expressed in number of bits
struct file *files;
struct file **files;
uint64_t *open_fds;
uint64_t *cloexec_fds;
};
Expand Down
8 changes: 4 additions & 4 deletions include/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
SYSCALL(33, dup2) \
SYSCALL(34, unimplemented) \
SYSCALL(35, nanosleep) \
SYSCALL(36, unimplemented) \
SYSCALL(36, getitimer) \
SYSCALL(37, alarm) \
SYSCALL(38, unimplemented) \
SYSCALL(38, setitimer) \
SYSCALL(39, getpid) \
SYSCALL(40, unimplemented) \
SYSCALL(41, socket) \
Expand Down Expand Up @@ -134,7 +134,7 @@
SYSCALL(130, rt_sigsuspend) \
SYSCALL(131, sigaltstack) \
SYSCALL(132, utime) \
SYSCALL(133, unimplemented) \
SYSCALL(133, mknod) \
SYSCALL(134, uselib) \
SYSCALL(135, unimplemented) \
SYSCALL(136, unimplemented) \
Expand Down Expand Up @@ -260,7 +260,7 @@
SYSCALL(256, unimplemented) \
SYSCALL(257, openat) \
SYSCALL(258, mkdirat) \
SYSCALL(259, unimplemented) \
SYSCALL(259, mknodat) \
SYSCALL(260, fchownat) \
SYSCALL(261, unimplemented) \
SYSCALL(262, newfstatat) \
Expand Down
4 changes: 2 additions & 2 deletions include/vmm.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

struct vcpu_snapshot {
uint64_t vcpu_reg[NR_X86_REG_LIST];
uint64_t vmcs[NR_VMCS_FIELD];
char fpu_states[512] __attribute__((aligned(16)));
uint64_t vmcs[NR_VMCS_FIELD_MASKED];
char fpu_states[2496] __attribute__((aligned(16)));
};

struct vmm_snapshot {
Expand Down
3 changes: 3 additions & 0 deletions include/x86/specialreg.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@
#define MSR_TIME_STAMP_COUNTER 0x00000010
#define MSR_KERNEL_GS_BASE 0xc0000102
#define MSR_TSC_AUX 0xc0000103

#define XCR0_SSE_STATE 0x00000002
#define XCR0_AVX_STATE 0x00000004
6 changes: 3 additions & 3 deletions include/x86/vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ typedef enum {
PAGE_PML4E,
} page_type_t;

#define PAGE_SHIFT(page_type) (12 + (page_type) * 9)
#define PAGE_SIZE(page_type) (1ULL << PAGE_SHIFT(page_type))
#define PAGE_SHIFTOF(page_type) (12 + (page_type) * 9)
#define PAGE_SIZEOF(page_type) (1ULL << PAGE_SHIFTOF(page_type))
#define NR_PAGE_ENTRY 512

static inline int is_page_aligned(void *addr, page_type_t page)
{
return ((uint64_t)addr & (PAGE_SIZE(page) - 1)) == 0;
return ((uint64_t)addr & (PAGE_SIZEOF(page) - 1)) == 0;
}

/* idt */
Expand Down
Loading