Browse Source

[LibOS,Pal] Remove Graphene IPC completely

Graphene IPC (GIPC) was introduced to perform faster bulk IPC by sharing pages as copy-on-write
across processes. This feature became stale, and it was shown that recent Linux kernels (4.2+)
have zero-copy transfers over UNIX sockets and exhibit similar performance. GIPC is not built and
not tested in Jenkins. Also, GIPC does not work under SGX. This commit completely removes GIPC.
Dmitrii Kuvaiskii 4 years ago
parent
commit
7d99d4788c
46 changed files with 28 additions and 2495 deletions
  1. 0 1
      .ci/run-shellcheck
  2. 0 25
      Documentation/oldwiki/PAL-Host-ABI.md
  3. 0 5
      Documentation/oldwiki/Process-Creation-in-Graphene-SGX.md
  4. 0 2
      Jenkinsfiles/Linux
  5. 0 3
      Jenkinsfiles/Linux-18.04
  6. 0 17
      LibOS/shim/include/shim_checkpoint.h
  7. 0 6
      LibOS/shim/include/shim_defs.h
  8. 0 4
      LibOS/shim/include/shim_vma.h
  9. 5 25
      LibOS/shim/src/bookkeep/shim_vma.c
  10. 16 270
      LibOS/shim/src/shim_checkpoint.c
  11. 0 7
      Pal/ipc/linux/.gitignore
  12. 0 23
      Pal/ipc/linux/Makefile
  13. 0 6
      Pal/ipc/linux/dkms.conf
  14. 0 975
      Pal/ipc/linux/graphene-ipc.c
  15. 0 35
      Pal/ipc/linux/graphene-ipc.h
  16. 0 40
      Pal/ipc/linux/install.sh
  17. 0 23
      Pal/ipc/linux/ksyms.h
  18. 0 12
      Pal/ipc/linux/load.sh
  19. 0 18
      Pal/ipc/linux/uninstall.sh
  20. 0 333
      Pal/regression/Ipc.c
  21. 0 4
      Pal/regression/Symbols.c
  22. 0 55
      Pal/regression/test_pal.py
  23. 1 1
      Pal/src/Makefile
  24. 0 85
      Pal/src/db_ipc.c
  25. 0 4
      Pal/src/db_streams.c
  26. 2 2
      Pal/src/host/FreeBSD/Makefile
  27. 0 72
      Pal/src/host/FreeBSD/db_ipc.c
  28. 0 2
      Pal/src/host/FreeBSD/db_streams.c
  29. 0 6
      Pal/src/host/FreeBSD/pal_host.h
  30. 1 1
      Pal/src/host/Linux-SGX/Makefile
  31. 0 67
      Pal/src/host/Linux-SGX/db_ipc.c
  32. 0 2
      Pal/src/host/Linux-SGX/db_streams.c
  33. 0 4
      Pal/src/host/Linux-SGX/pal_host.h
  34. 1 2
      Pal/src/host/Linux/Makefile
  35. 0 176
      Pal/src/host/Linux/db_ipc.c
  36. 0 1
      Pal/src/host/Linux/db_process.c
  37. 0 2
      Pal/src/host/Linux/db_streams.c
  38. 0 5
      Pal/src/host/Linux/pal_host.h
  39. 1 1
      Pal/src/host/Skeleton/Makefile
  40. 0 59
      Pal/src/host/Skeleton/db_ipc.c
  41. 0 4
      Pal/src/host/Skeleton/pal_host.h
  42. 0 3
      Pal/src/pal-symbols
  43. 0 11
      Pal/src/pal.h
  44. 0 5
      Pal/src/pal_internal.h
  45. 0 90
      Pal/test/Ipc.c
  46. 1 1
      Pal/test/Makefile

+ 0 - 1
.ci/run-shellcheck

@@ -9,7 +9,6 @@ shellcheck "$@" \
     LibOS/shim/test/apps/common_tools/benchmark-http.sh \
     LibOS/shim/test/apps/python-simple/run-tests.sh \
     LibOS/shim/test/native/*.sh \
-    Pal/ipc/linux/*.sh \
     Pal/src/host/FreeBSD/pal-gdb.template \
     Pal/src/host/Linux-SGX/debugger/gdb \
     Pal/src/host/Linux-SGX/sgx-driver/load.sh \

+ 0 - 25
Documentation/oldwiki/PAL-Host-ABI.md

@@ -574,28 +574,3 @@ This API returns the amount of currently available memory for LibOS/application
      PAL_BOL DkCpuIdRetrieve(PAL_IDX leaf, PAL_IDX subleaf, PAL_IDX values[4]);
 
 This API returns CPUID information in the array `values`, based on the leaf/subleaf.
-
-
-### Memory Bulk Copy (Optional)
-
-#### DkCreatePhysicalMemoryChannel
-
-    PAL_HANDLE DkCreatePhysicalMemoryChannel(PAL_NUM* key);
-
-This API creates a physical memory channel for the process to copy virtual memory as copy-on-write.
-Once a channel is created, other processes can connect to the physical memory channel by using
-[DkStreamOpen](#dkstreamopen) with a URI `gipc:<key>`.
-
-#### DkPhysicalMemoryCommit
-
-    PAL_NUM DkPhysicalMemoryCommit(PAL_HANDLE channel, PAL_NUM entries, PAL_PTR* addrs,
-                                   PAL_NUM* sizes);
-
-This API commits (sends) an array of the virtual memory area over the physical memory channel.
-
-#### DkPhysicalMemoryMap
-
-    PAL_NUM DkPhysicalMemoryMap(PAL_HANDLE channel, PAL_NUM entries, PAL_PTR* addrs,
-                                PAL_NUM* sizes, PAL_FLG* prots);
-
-This API maps an array of virtual memory area from the physical memory channel.

+ 0 - 5
Documentation/oldwiki/Process-Creation-in-Graphene-SGX.md

@@ -41,11 +41,6 @@ This function collects absolutely all shim data on the current state of the pare
 For SGX, the data must be encrypted in this function.
 
 
-Note that `do_migrate_process()` checks for GIPC availability, with the assumption that GIPC is
-faster than normal Unix streams. However, SGX PAL does not support GIPC. Thus, the checkpoint
-sending to the child is done via a Unix stream.
-
-
 ### Child: Initialization after Fork
 
 After the child is created, Pal-Linux-SGX enters the enclave using EENTER. The enclave code calls

+ 0 - 2
Jenkinsfiles/Linux

@@ -21,7 +21,6 @@ pipeline {
                             cd ..
                             make -j 8 WERROR=1
                             make -j 8 WERROR=1 test
-                            make -C Pal/ipc/linux KERNELDIR=/lib/modules/4.4.0-161-generic/build
                             make -C Pal/src -j 8 PAL_HOST=Skeleton WERROR=1
                            '''
                     }
@@ -116,7 +115,6 @@ pipeline {
                            make -C Pal/lib distclean
                            rm -r LibOS/glibc-2.23
                            rm LibOS/glibc-*.tar.gz
-                           make -C Pal/ipc/linux KERNELDIR=/lib/modules/4.4.0-161-generic/build clean
                            make -C LibOS/shim/test/regression clean
 
                            make -C LibOS/shim/test/apps/ltp clean

+ 0 - 3
Jenkinsfiles/Linux-18.04

@@ -19,9 +19,6 @@ pipeline {
                         sh '''
                             make -j 8 WERROR=1
                             make -j 8 WERROR=1 test
-                            # We can't build this on 18.04 in our current pipeline
-                            cd Pal/ipc/linux
-                            make KERNELDIR=/lib/modules/4.15.0-20-generic/build
                            '''
                     }
                 }

+ 0 - 17
LibOS/shim/include/shim_checkpoint.h

@@ -94,13 +94,6 @@ struct shim_mem_entry {
     void * data;
 };
 
-struct shim_gipc_entry {
-    struct shim_mem_entry mem;
-#if HASH_GIPC == 1
-    unsigned long first_hash;
-#endif
-};
-
 struct shim_palhdl_entry {
     struct shim_palhdl_entry * prev;
     PAL_HANDLE handle;
@@ -119,11 +112,6 @@ struct shim_cp_store {
     /* check point area */
     ptr_t base, offset, bound;
 
-    /* entries of gipc records */
-    bool use_gipc;
-    struct shim_gipc_entry * last_gipc_entry;
-    int gipc_nentries;
-
     /* entries of out-of-band data */
     struct shim_mem_entry * last_mem_entry;
     int mem_nentries;
@@ -415,11 +403,6 @@ struct newproc_cp_header {
         unsigned long entoffset;
         int nentries;
     } palhdl;
-    struct gipc_header {
-        char uri[16];
-        unsigned long entoffset;
-        int nentries;
-    } gipc;
 };
 
 struct newproc_header {

+ 0 - 6
LibOS/shim/include/shim_defs.h

@@ -1,10 +1,6 @@
 #ifndef _SHIM_DEFS_H_
 #define _SHIM_DEFS_H_
 
-#define MIGRATE_MORE_GIPC           0
-
-#define HASH_GIPC                   0
-
 /*
  * If enable CPSTORE_DERANDOMIZATION, the library OS will try to
  * load the checkpoint (either from the parent or a file) at the
@@ -63,6 +59,4 @@
 #define REQUIRED_ELF_AUXV           8   /* number of LibOS-supported vectors */
 #define REQUIRED_ELF_AUXV_SPACE     16  /* extra memory space (in bytes) */
 
-#define WARN_NO_GIPC                0   /* warn if GIPC is not supported for process creation */
-
 #endif /* _SHIM_DEFS_H_ */

+ 0 - 4
LibOS/shim/include/shim_vma.h

@@ -80,10 +80,6 @@ static inline void free_vma_val_array(struct shim_vma_val* vmas, size_t count) {
 #define NEED_MIGRATE_MEMORY(vma) \
     (((vma)->flags & VMA_TAINTED || !(vma)->file) && !((vma)->flags & VMA_UNMAPPED))
 
-#define NEED_MIGRATE_MEMORY_IF_GIPC(vma)                                                   \
-    (!((vma)->flags & VMA_UNMAPPED) && !(!(vma)->prot && !((vma)->flags & VMA_TAINTED)) && \
-     !((vma)->file && ((vma)->flags & MAP_SHARED)))
-
 static inline PAL_FLG PAL_PROT(int prot, int flags) {
     PAL_FLG pal_prot = 0;
 

+ 5 - 25
LibOS/shim/src/bookkeep/shim_vma.c

@@ -1062,13 +1062,8 @@ BEGIN_CP_FUNC(vma)
 
         void * need_mapped = vma->addr;
 
-        if (
-#if MIGRATE_MORE_GIPC == 1
-            store->use_gipc ?
-            NEED_MIGRATE_MEMORY_IF_GIPC(vma) :
-#endif
-            NEED_MIGRATE_MEMORY(vma)) {
-            void *   send_addr = vma->addr;
+        if (NEED_MIGRATE_MEMORY(vma)) {
+            void* send_addr  = vma->addr;
             size_t send_size = vma->length;
             if (vma->file) {
                 /*
@@ -1095,32 +1090,17 @@ BEGIN_CP_FUNC(vma)
                 }
             }
             if (send_size > 0) {
-#if HASH_GIPC == 1
                 if (!(pal_prot & PAL_PROT_READ)) {
-#else
-                if (!store->use_gipc && !(pal_prot & PAL_PROT_READ)) {
-#endif
                     /* Make the area readable */
                     DkVirtualMemoryProtect(send_addr, send_size,
                                            pal_prot|PAL_PROT_READ);
                 }
 
-                if (store->use_gipc) {
-                    struct shim_gipc_entry * gipc;
-                    DO_CP_SIZE(gipc, send_addr, send_size, &gipc);
-                    gipc->mem.prot = pal_prot;
-                } else {
-                    struct shim_mem_entry * mem;
-                    DO_CP_SIZE(memory, send_addr, send_size, &mem);
-                    mem->prot = pal_prot;
-                }
+                struct shim_mem_entry * mem;
+                DO_CP_SIZE(memory, send_addr, send_size, &mem);
+                mem->prot = pal_prot;
 
                 need_mapped = vma->addr + vma->length;
-
-#if HASH_GIPC == 1
-                if (store->use_gipc && !(pal_prot & PAL_PROT_READ))
-                    DkVirtualMemoryProtect(send_addr, send_size, pal_prot);
-#endif
             }
         }
         ADD_CP_FUNC_ENTRY(off);

+ 16 - 270
LibOS/shim/src/shim_checkpoint.c

@@ -55,8 +55,6 @@ DEFINE_PROFILE_INTERVAL(child_created_in_new_process,  resume);
 DEFINE_PROFILE_INTERVAL(child_wait_header,             resume);
 DEFINE_PROFILE_INTERVAL(child_receive_header,          resume);
 DEFINE_PROFILE_INTERVAL(do_migration,                  resume);
-DEFINE_PROFILE_INTERVAL(child_load_checkpoint_by_gipc, resume);
-DEFINE_PROFILE_INTERVAL(child_load_memory_by_gipc,     resume);
 DEFINE_PROFILE_INTERVAL(child_load_checkpoint_on_pipe, resume);
 DEFINE_PROFILE_INTERVAL(child_receive_handles,         resume);
 DEFINE_PROFILE_INTERVAL(restore_checkpoint,            resume);
@@ -335,139 +333,6 @@ BEGIN_RS_FUNC(qstr)
 }
 END_RS_FUNC(qstr)
 
-BEGIN_CP_FUNC(gipc)
-{
-    ptr_t off = ADD_CP_OFFSET(sizeof(struct shim_gipc_entry));
-
-    void* send_addr  = (void*)ALLOC_ALIGN_DOWN_PTR(obj);
-    size_t send_size = (void*)ALLOC_ALIGN_UP_PTR(obj + size) - send_addr;
-
-    struct shim_gipc_entry * entry = (void *) (base + off);
-
-    entry->mem.addr = send_addr;
-    entry->mem.size = send_size;
-    entry->mem.prot = PAL_PROT_READ|PAL_PROT_WRITE;
-    entry->mem.prev = (void *) store->last_gipc_entry;
-    store->last_gipc_entry = entry;
-    store->gipc_nentries++;
-
-#if HASH_GIPC == 1
-    struct md5_ctx ctx;
-    md5_init(&ctx);
-    md5_update(&ctx, send_addr, g_pal_alloc_align);
-    md5_final(&ctx);
-    entry->first_hash = *(unsigned long *) ctx.digest;
-#endif /* HASH_GIPC == 1 */
-
-    ADD_CP_FUNC_ENTRY(off);
-
-    if (objp)
-        *objp = entry;
-}
-END_CP_FUNC(gipc)
-
-BEGIN_RS_FUNC(gipc)
-{
-    __UNUSED(rebase);
-    __UNUSED(offset);
-    __UNUSED(base);
-    __UNUSED(entry);
-
-#if HASH_GIPC == 1
-    struct shim_gipc_entry * entry = (void *) (base + GET_CP_FUNC_ENTRY());
-
-    PAL_FLG pal_prot = PAL_PROT(entry->prot, 0);
-    if (!(pal_prot & PROT_READ))
-        DkVirtualMemoryProtect(entry->addr, entry->npages * g_pal_alloc_align,
-                               pal_prot|PAL_PROT_READ);
-
-    struct md5_ctx ctx;
-    md5_init(&ctx);
-    md5_update(&ctx, entry->addr, g_pal_alloc_align);
-    md5_final(&ctx);
-    assert(*(unsigned long *) ctx.digest == entry->first_hash);
-
-    if (!(pal_prot & PAL_PROT_READ))
-        DkVirtualMemoryProtect(entry->addr, entry->npages * g_pal_alloc_align,
-                               pal_prot);
-#endif /* HASH_GIPC == 1 */
-}
-END_RS_FUNC(gipc)
-
-static int send_checkpoint_by_gipc (PAL_HANDLE gipc_store,
-                                    struct shim_cp_store * store)
-{
-    PAL_PTR hdr_addr = (PAL_PTR) store->base;
-    PAL_NUM hdr_size = (PAL_NUM) store->offset + store->mem_size;
-    assert(IS_ALLOC_ALIGNED_PTR(hdr_addr));
-
-    int mem_nentries = store->mem_nentries;
-
-    if (mem_nentries) {
-        struct shim_mem_entry ** mem_entries =
-                    __alloca(sizeof(struct shim_mem_entry *) * mem_nentries);
-        int mem_cnt = mem_nentries;
-        struct shim_mem_entry * mem_ent = store->last_mem_entry;
-
-        for (; mem_ent ; mem_ent = mem_ent->prev) {
-            if (!mem_cnt)
-                return -EINVAL;
-            mem_entries[--mem_cnt] = mem_ent;
-        }
-
-        mem_entries  += mem_cnt;
-        mem_nentries -= mem_cnt;
-
-        for (int i = 0 ; i < mem_nentries ; i++) {
-            void * mem_addr = (void *) store->base +
-                              __ADD_CP_OFFSET(mem_entries[i]->size);
-
-            assert(store->offset <= hdr_size);
-            memcpy(mem_addr, mem_entries[i]->addr, mem_entries[i]->size);
-            mem_entries[i]->data = mem_addr;
-        }
-    }
-
-    hdr_size = ALLOC_ALIGN_UP(hdr_size);
-    int npages = DkPhysicalMemoryCommit(gipc_store, 1, &hdr_addr, &hdr_size);
-    if (!npages)
-        return -EPERM;
-
-    int nentries = store->gipc_nentries;
-    PAL_PTR * gipc_addrs = __alloca(sizeof(PAL_PTR) * nentries);
-    PAL_NUM * gipc_sizes = __alloca(sizeof(PAL_NUM) * nentries);
-    int total_pages = 0;
-    int cnt = nentries;
-    struct shim_gipc_entry * ent = store->last_gipc_entry;
-
-    for (; ent ; ent = (void *) ent->mem.prev) {
-        if (!cnt)
-            return -EINVAL;
-        cnt--;
-        gipc_addrs[cnt] = ent->mem.addr;
-        gipc_sizes[cnt] = ent->mem.size;
-        total_pages += ent->mem.size / g_pal_alloc_align;
-    }
-
-    gipc_addrs += cnt;
-    gipc_sizes += cnt;
-    nentries   -= cnt;
-
-    /* Chia-Che: sending an empty page can't ever be a smart idea.
-       we might rather fail here */
-    npages = DkPhysicalMemoryCommit(gipc_store, nentries, gipc_addrs,
-                                    gipc_sizes);
-
-    if (npages < total_pages) {
-        debug("gipc supposed to send %d pages, but only %d pages sent\n",
-              total_pages, npages);
-        return -ENOMEM;
-    }
-
-    ADD_PROFILE_OCCURENCE(migrate_send_gipc_pages, npages);
-    return 0;
-}
-
 static int send_checkpoint_on_stream (PAL_HANDLE stream,
                                       struct shim_cp_store * store)
 {
@@ -539,55 +404,6 @@ static int send_checkpoint_on_stream (PAL_HANDLE stream,
         ADD_PROFILE_OCCURENCE(migrate_send_on_stream, mem_size);
     }
 
-    return 0;
- }
-
-
-static int restore_gipc (PAL_HANDLE gipc, struct gipc_header * hdr, ptr_t base,
-                         long rebase)
-{
-    struct shim_gipc_entry * gipc_entries = (void *) (base + hdr->entoffset);
-    int nentries = hdr->nentries;
-
-    if (!nentries)
-        return 0;
-
-    debug("restore memory by gipc: %d entries\n", nentries);
-
-    struct shim_gipc_entry ** entries =
-            __alloca(sizeof(struct shim_gipc_entry *) * nentries);
-
-    struct shim_gipc_entry * entry = gipc_entries;
-    int cnt = nentries;
-
-    while (entry) {
-        CP_REBASE(entry->mem.prev);
-        CP_REBASE(entry->mem.paddr);
-        if (!cnt)
-            return -EINVAL;
-        entries[--cnt] = entry;
-        entry = (void *) entry->mem.prev;
-    }
-
-    entries  += cnt;
-    nentries -= cnt;
-    PAL_PTR * addrs = __alloca(sizeof(PAL_PTR) * nentries);
-    PAL_NUM * sizes = __alloca(sizeof(PAL_NUM) * nentries);
-    PAL_FLG * prots = __alloca(sizeof(PAL_FLG) * nentries);
-
-    for (int i = 0 ; i < nentries ; i++) {
-        addrs[i] = entries[i]->mem.paddr ? NULL : (PAL_PTR) entries[i]->mem.addr;
-        sizes[i] = entries[i]->mem.size;
-        prots[i] = entries[i]->mem.prot;
-    }
-
-    if (!DkPhysicalMemoryMap(gipc, nentries, addrs, sizes, prots))
-        return -PAL_ERRNO;
-
-    for (int i = 0 ; i < nentries ; i++)
-        if (entries[i]->mem.paddr)
-            *(void **) entries[i]->mem.paddr = (void *) addrs[i];
-
     return 0;
 }
 
@@ -897,22 +713,16 @@ static void * cp_alloc (struct shim_cp_store * store, void * addr, size_t size)
 
 DEFINE_PROFILE_CATEGORY(migrate_proc, migrate);
 DEFINE_PROFILE_INTERVAL(migrate_create_process,   migrate_proc);
-DEFINE_PROFILE_INTERVAL(migrate_create_gipc,      migrate_proc);
 DEFINE_PROFILE_INTERVAL(migrate_connect_ipc,      migrate_proc);
 DEFINE_PROFILE_INTERVAL(migrate_init_checkpoint,  migrate_proc);
 DEFINE_PROFILE_INTERVAL(migrate_save_checkpoint,  migrate_proc);
 DEFINE_PROFILE_INTERVAL(migrate_send_header,      migrate_proc);
 DEFINE_PROFILE_INTERVAL(migrate_send_checkpoint,  migrate_proc);
 DEFINE_PROFILE_OCCURENCE(migrate_send_on_stream,  migrate_proc);
-DEFINE_PROFILE_OCCURENCE(migrate_send_gipc_pages, migrate_proc);
 DEFINE_PROFILE_INTERVAL(migrate_send_pal_handles, migrate_proc);
 DEFINE_PROFILE_INTERVAL(migrate_free_checkpoint,  migrate_proc);
 DEFINE_PROFILE_INTERVAL(migrate_wait_response,    migrate_proc);
 
-#if WARN_NO_GIPC == 1
-static bool warn_no_gipc __attribute_migratable = true;
-#endif
-
 /*
  * Create a new process and migrate the process states to the new process.
  *
@@ -934,7 +744,6 @@ int do_migrate_process (int (*migrate) (struct shim_cp_store *,
     struct shim_process * new_process = NULL;
     struct newproc_header hdr;
     PAL_NUM bytes;
-    PAL_HANDLE gipc_hdl = NULL;
     memset(&hdr, 0, sizeof(hdr));
 
 #ifdef PROFILE
@@ -959,29 +768,6 @@ int do_migrate_process (int (*migrate) (struct shim_cp_store *,
 
     SAVE_PROFILE_INTERVAL(migrate_create_process);
 
-    /*
-     * Detect if GIPC is supported by the host. If GIPC is not supported
-     * forking may be slow because we have to use RPC streams for migrating
-     * user memory.
-     */
-    bool use_gipc = false;
-    PAL_NUM gipc_key;
-    gipc_hdl = DkCreatePhysicalMemoryChannel(&gipc_key);
-
-    if (gipc_hdl) {
-        debug("created gipc store: gipc:%lu\n", gipc_key);
-        use_gipc = true;
-        SAVE_PROFILE_INTERVAL(migrate_create_gipc);
-    } else {
-#if WARN_NO_GIPC == 1
-        if (warn_no_gipc) {
-            warn_no_gipc = false;
-            SYS_PRINTF("WARNING: no physical memory support, process creation "
-                       "may be slow.\n");
-        }
-#endif
-    }
-
     /* Create process and IPC bookkeepings */
     new_process = create_process(exec ? /*execve case*/ true : /*fork case*/ false);
     if (!new_process) {
@@ -995,7 +781,6 @@ int do_migrate_process (int (*migrate) (struct shim_cp_store *,
     struct shim_cp_store cpstore;
     memset(&cpstore, 0, sizeof(cpstore));
     cpstore.alloc    = cp_alloc;
-    cpstore.use_gipc = use_gipc;
     cpstore.bound    = CP_INIT_VMA_SIZE;
 
     while (1) {
@@ -1049,17 +834,6 @@ int do_migrate_process (int (*migrate) (struct shim_cp_store *,
         hdr.checkpoint.mem.nentries  = cpstore.mem_nentries;
     }
 
-    if (cpstore.use_gipc) {
-        snprintf(hdr.checkpoint.gipc.uri, sizeof(hdr.checkpoint.gipc.uri),
-                 "gipc:%ld", gipc_key);
-
-        if (cpstore.gipc_nentries) {
-            hdr.checkpoint.gipc.entoffset =
-                        (ptr_t) cpstore.last_gipc_entry - cpstore.base;
-            hdr.checkpoint.gipc.nentries  = cpstore.gipc_nentries;
-        }
-    }
-
     if (cpstore.palhdl_nentries) {
         hdr.checkpoint.palhdl.entoffset =
                     (ptr_t) cpstore.last_palhdl_entry - cpstore.base;
@@ -1089,9 +863,7 @@ int do_migrate_process (int (*migrate) (struct shim_cp_store *,
     ADD_PROFILE_OCCURENCE(migrate_send_on_stream, bytes);
     SAVE_PROFILE_INTERVAL(migrate_send_header);
 
-    /* Sending the checkpoint either through GIPC or the RPC stream */
-    ret = cpstore.use_gipc ? send_checkpoint_by_gipc(gipc_hdl, &cpstore) :
-          send_checkpoint_on_stream(proc, &cpstore);
+    ret = send_checkpoint_on_stream(proc, &cpstore);
 
     if (ret < 0) {
         debug("failed sending checkpoint (ret = %d)\n", ret);
@@ -1155,8 +927,6 @@ int do_migrate_process (int (*migrate) (struct shim_cp_store *,
 
     ret = 0;
 out:
-    if (gipc_hdl)
-        DkObjectClose(gipc_hdl);
     if (new_process)
         free_process(new_process);
 
@@ -1182,8 +952,6 @@ int do_migration (struct newproc_cp_header * hdr, void ** cpptr)
     PAL_PTR mapaddr;
     PAL_NUM mapsize;
     long rebase;
-    bool use_gipc = !!hdr->gipc.uri[0];
-    PAL_HANDLE gipc_store;
     int ret = 0;
     BEGIN_PROFILE_INTERVAL();
 
@@ -1227,22 +995,10 @@ int do_migration (struct newproc_cp_header * hdr, void ** cpptr)
     debug("checkpoint mapped at %p-%p\n", base, base + size);
 
     PAL_FLG pal_prot = PAL_PROT_READ|PAL_PROT_WRITE;
-    PAL_PTR mapped = mapaddr;
 
-    if (use_gipc) {
-        debug("open gipc store: %s\n", hdr->gipc.uri);
-
-        gipc_store = DkStreamOpen(hdr->gipc.uri, 0, 0, 0, 0);
-        if (!gipc_store ||
-            !DkPhysicalMemoryMap(gipc_store, 1, &mapped, &mapsize, &pal_prot))
-            return -PAL_ERRNO;
-
-        SAVE_PROFILE_INTERVAL(child_load_checkpoint_by_gipc);
-    } else {
-        void * mapped = DkVirtualMemoryAlloc(mapaddr, mapsize, 0, pal_prot);
-        if (!mapped)
-            return -PAL_ERRNO;
-    }
+    PAL_PTR mapped = DkVirtualMemoryAlloc(mapaddr, mapsize, 0, pal_prot);
+    if (!mapped)
+        return -PAL_ERRNO;
 
     assert(mapaddr == mapped);
     /*
@@ -1251,34 +1007,24 @@ int do_migration (struct newproc_cp_header * hdr, void ** cpptr)
      */
     rebase = (long) ((uintptr_t) base - (uintptr_t) hdr->hdr.addr);
 
-    /* Load the memory data sent separately over GIPC or the RPC stream. */
-    if (use_gipc) {
-        if ((ret = restore_gipc(gipc_store, &hdr->gipc, (ptr_t) base, rebase)) < 0)
-            return ret;
+    size_t total_bytes = 0;
+    while (total_bytes < size) {
+        PAL_NUM bytes = DkStreamRead(PAL_CB(parent_process), 0, size - total_bytes,
+                                     (void*)base + total_bytes, NULL, 0);
 
-        SAVE_PROFILE_INTERVAL(child_load_memory_by_gipc);
-        DkStreamDelete(gipc_store, 0);
-    } else {
-        size_t total_bytes = 0;
-        while (total_bytes < size) {
-            PAL_NUM bytes = DkStreamRead(PAL_CB(parent_process), 0,
-                                         size - total_bytes,
-                                         (void *) base + total_bytes, NULL, 0);
-
-            if (bytes == PAL_STREAM_ERROR) {
-                if (PAL_ERRNO == EINTR || PAL_ERRNO == EAGAIN ||
+        if (bytes == PAL_STREAM_ERROR) {
+            if (PAL_ERRNO == EINTR || PAL_ERRNO == EAGAIN ||
                     PAL_ERRNO == EWOULDBLOCK)
-                    continue;
-                return -PAL_ERRNO;
-            }
-
-            total_bytes += bytes;
+                continue;
+            return -PAL_ERRNO;
         }
 
-        SAVE_PROFILE_INTERVAL(child_load_checkpoint_on_pipe);
-        debug("%lu bytes read on stream\n", total_bytes);
+        total_bytes += bytes;
     }
 
+    SAVE_PROFILE_INTERVAL(child_load_checkpoint_on_pipe);
+    debug("%lu bytes read on stream\n", total_bytes);
+
     /* Receive socket or RPC handles from the parent process. */
     ret = receive_handles_on_stream(&hdr->palhdl, (ptr_t) base, rebase);
     if (ret < 0) {

+ 0 - 7
Pal/ipc/linux/.gitignore

@@ -1,7 +0,0 @@
-*.ko
-*.cmd
-*.mod.c
-/Module.symvers
-/modules.order
-/.tmp_versions/
-/graphene-ipc.o.*

+ 0 - 23
Pal/ipc/linux/Makefile

@@ -1,23 +0,0 @@
-# If KERNELRELEASE is defined, we've been invoked from the
-# kernel build system and can use its language.
-ifneq ($(KERNELRELEASE),)
-	obj-m := graphene-ipc.o
-# Otherwise we were called directly from the command
-# line; invoke the kernel build system.
-else
-	KERNELDIR ?= /lib/modules/$(shell uname -r)/build
-	PWD := $(shell pwd)
-
-.PHONY: default
-default:
-	$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
-
-graphene-ipc.i: graphene-ipc.c
-	$(MAKE) -C $(KERNELDIR) M=$(PWD) $@
-
-.PHONY: clean
-clean:
-	$(MAKE) -C $(KERNELDIR) M=$(PWD) clean
-	rm -rf *.o.ur-safe
-
-endif

+ 0 - 6
Pal/ipc/linux/dkms.conf

@@ -1,6 +0,0 @@
-PACKAGE_NAME="graphene-ipc"
-PACKAGE_VERSION="0.0.1"
-CLEAN="rm -f *.*o"
-BUILT_MODULE_NAME[0]="graphene-ipc"
-DEST_MODULE_LOCATION[0]="/updates"
-AUTOINSTALL="yes"

+ 0 - 975
Pal/ipc/linux/graphene-ipc.c

@@ -1,975 +0,0 @@
-#include <linux/bitmap.h>
-#include <linux/fs.h>
-#include <linux/init.h>
-#include <linux/kallsyms.h>
-#include <linux/miscdevice.h>
-#include <linux/mm.h>
-#include <linux/mm_types.h>
-#include <linux/mmu_notifier.h>
-#include <linux/module.h>
-#include <linux/pagemap.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/swap.h>
-#include <linux/swapops.h>
-#include <linux/version.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
-#include <linux/sched/signal.h>
-#endif
-#include <asm/mman.h>
-#include <asm/tlb.h>
-
-#include "graphene-ipc.h"
-#include "ksyms.h"
-
-MODULE_LICENSE("Dual BSD/GPL");
-
-#define FILE_POISON LIST_POISON1
-
-struct kmem_cache* gipc_queue_cachep;
-struct kmem_cache* gipc_send_buffer_cachep;
-
-#define GIPC_DEBUG 0
-
-#if defined(GIPC_DEBUG) && GIPC_DEBUG == 1
-#define DEBUG(...)        printk(KERN_INFO __VA_ARGS__)
-#define GIPC_BUG_ON(cond) BUG_ON(cond)
-#else
-#define DEBUG(...)
-#define GIPC_BUG_ON(cond)
-#endif
-
-#if defined(CONFIG_GRAPHENE_BULK_IPC) || LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0)
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
-#define DO_MMAP_PGOFF(file, addr, len, prot, flags, pgoff)                                \
-    ({                                                                                    \
-        unsigned long populate;                                                           \
-        unsigned long rv = do_mmap_pgoff(file, addr, len, prot, flags, pgoff, &populate); \
-        rv;                                                                               \
-    })
-#else
-#define DO_MMAP_PGOFF(file, addr, len, prot, flags, pgoff) \
-    do_mmap_pgoff(file, addr, len, prot, flags, pgoff)
-#endif /* kernel_version < 3.9.0 */
-#else
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
-#define MY_DO_MMAP
-#define DO_MMAP_PGOFF(file, addr, len, prot, flags, pgoff)                           \
-    ({                                                                               \
-        unsigned long populate;                                                      \
-        unsigned long rv;                                                            \
-        rv = KSYM(do_mmap)(file, addr, len, prot, flags, 0, pgoff, &populate, NULL); \
-        rv;                                                                          \
-    })
-
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
-#define MY_DO_MMAP
-#define DO_MMAP_PGOFF(file, addr, len, prot, flags, pgoff)                     \
-    ({                                                                         \
-        unsigned long populate;                                                \
-        unsigned long rv;                                                      \
-        rv = KSYM(do_mmap)(file, addr, len, prot, flags, 0, pgoff, &populate); \
-        rv;                                                                    \
-    })
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
-#define MY_DO_MMAP_PGOFF
-#define DO_MMAP_PGOFF(file, addr, len, prot, flags, pgoff)                        \
-    ({                                                                            \
-        unsigned long populate;                                                   \
-        unsigned long rv;                                                         \
-        rv = KSYM(do_mmap_pgoff)(file, addr, len, prot, flags, pgoff, &populate); \
-        rv;                                                                       \
-    })
-#else
-#define MY_DO_MMAP_PGOFF
-#define DO_MMAP_PGOFF(file, addr, len, prot, flags, pgoff) \
-    KSYM(do_mmap_pgoff)(file, addr, len, prot, flags, pgoff)
-#endif /* kernel version < 3.9 */
-#endif /* !CONFIG_GRAPHENE_BULK_IPC && kernel version > 3.4.0 */
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
-#ifdef CONFIG_GRAPHENE_BULK_IPC
-#define FLUSH_TLB_MM_RANGE flush_tlb_mm_range
-#else
-#define MY_FLUSH_TLB_MM_RANGE
-#define FLUSH_TLB_MM_RANGE KSYM(flush_tlb_mm_range)
-#endif
-#else /* LINUX_VERSION_CODE < 3.7.0 */
-#if defined(CONFIG_GRAPHENE_BULK_IPC) || LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0)
-#define FLUSH_TLB_PAGE flush_tlb_page
-#else
-#define MY_FLUSH_TLB_PAGE
-#define FLUSH_TLB_PAGE KSYM(flush_tlb_page)
-#endif
-#endif
-
-#ifdef MY_DO_MMAP
-IMPORT_KSYM(do_mmap);
-#endif
-#ifdef MY_DO_MMAP_PGOFF
-IMPORT_KSYM(do_mmap_pgoff);
-#endif
-#ifdef MY_FLUSH_TLB_MM_RANGE
-IMPORT_KSYM(flush_tlb_mm_range);
-#endif
-#ifdef MY_FLUSH_TLB_PAGE
-IMPORT_KSYM(flush_tlb_page);
-#endif
-
-#ifndef gipc_get_session
-u64 (*my_gipc_get_session)(struct task_struct*) = NULL;
-#endif
-
-struct gipc_queue {
-    struct list_head list;
-    s64 token;
-    u64 owner;
-    atomic_t count;
-
-    struct mutex send_lock, recv_lock;
-    wait_queue_head_t send, recv;
-    volatile int next, last;
-
-    struct {
-        struct page* page;
-        struct file* file;
-        u64 pgoff;
-    } pages[PAGE_QUEUE];
-};
-
-struct gipc_send_buffer {
-    unsigned long page_bit_map[PAGE_BITS];
-    struct page* pages[PAGE_QUEUE];
-    struct vm_area_struct* vmas[PAGE_QUEUE];
-    struct file* files[PAGE_QUEUE];
-    unsigned long pgoffs[PAGE_QUEUE];
-};
-
-struct {
-    spinlock_t lock;
-    /*
-     * For now, just make them monotonically increasing.  XXX: At
-     * some point, do something smarter for security.
-     */
-    u64 max_token;
-    struct list_head channels;  // gipc_queue structs
-} gdev;
-
-#ifdef gipc_get_session
-#define GIPC_OWNER gipc_get_session(current)
-#else
-#define GIPC_OWNER (my_gipc_get_session ? my_gipc_get_session(current) : 0)
-#endif
-
-static inline struct gipc_queue* create_gipc_queue(struct file* creator) {
-    struct gipc_queue* gq = kmem_cache_alloc(gipc_queue_cachep, GFP_KERNEL);
-
-    if (!gq)
-        return gq;
-
-    memset(gq, 0, sizeof(*gq));
-    INIT_LIST_HEAD(&gq->list);
-    mutex_init(&gq->send_lock);
-    mutex_init(&gq->recv_lock);
-    init_waitqueue_head(&gq->send);
-    init_waitqueue_head(&gq->recv);
-    gq->owner             = GIPC_OWNER;
-    creator->private_data = gq;
-    atomic_set(&gq->count, 1);
-
-    spin_lock(&gdev.lock);
-    list_add(&gq->list, &gdev.channels);
-    gq->token = gdev.max_token++;
-    spin_unlock(&gdev.lock);
-
-    return gq;
-}
-
-static inline void release_gipc_queue(struct gipc_queue* gq, bool locked) {
-    int idx;
-
-    if (!atomic_dec_and_test(&gq->count))
-        return;
-
-    if (!locked)
-        spin_lock(&gdev.lock);
-
-    while (gq->next != gq->last) {
-        idx = gq->next;
-        if (gq->pages[idx].page) {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
-            put_page(gq->pages[idx].page);
-#else
-            page_cache_release(gq->pages[idx].page);
-#endif
-            gq->pages[idx].page = NULL;
-        }
-        if (gq->pages[idx].file) {
-            fput_atomic(gq->pages[idx].file);
-            gq->pages[idx].file  = NULL;
-            gq->pages[idx].pgoff = 0;
-        }
-        gq->next++;
-        gq->next &= (PAGE_QUEUE - 1);
-    }
-
-    list_del(&gq->list);
-
-    if (!locked)
-        spin_unlock(&gdev.lock);
-
-    kmem_cache_free(gipc_queue_cachep, gq);
-}
-
-#if defined(SPLIT_RSS_COUNTING)
-static void add_mm_counter_fast(struct mm_struct* mm, int member, int val) {
-    struct task_struct* task = current;
-
-    if (likely(task->mm == mm))
-        task->rss_stat.count[member] += val;
-    else
-        add_mm_counter(mm, member, val);
-}
-#else
-#define add_mm_counter_fast(mm, member, val) add_mm_counter(mm, member, val)
-#endif
-
-#define inc_mm_counter_fast(mm, member) add_mm_counter_fast(mm, member, 1)
-#define dec_mm_counter_fast(mm, member) add_mm_counter_fast(mm, member, -1)
-
-inline int make_page_cow(struct mm_struct* mm, struct vm_area_struct* vma, unsigned long addr) {
-    pgd_t* pgd;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
-    p4d_t* p4d;
-#endif
-    pud_t* pud;
-    pmd_t* pmd;
-    pte_t* pte;
-    spinlock_t* ptl;
-
-    pgd = pgd_offset(mm, addr);
-    if (pgd_none(*pgd) || unlikely(pgd_bad(*pgd)))
-        goto no_page;
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
-    p4d = p4d_offset(pgd, addr);
-    if (p4d_none(*p4d) || unlikely(p4d_bad(*p4d)))
-        goto no_page;
-
-    pud = pud_offset(p4d, addr);
-#else
-    pud = pud_offset(pgd, addr);
-#endif
-    if (pud_none(*pud) || unlikely(pud_bad(*pud)))
-        goto no_page;
-
-    pmd = pmd_offset(pud, addr);
-    if (pmd_none(*pmd) || unlikely(pmd_bad(*pmd)))
-        goto no_page;
-
-    BUG_ON(pmd_trans_huge(*pmd));
-
-    pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
-    if (!pte_present(*pte)) {
-        spin_unlock(ptl);
-        goto no_page;
-    }
-
-    ptep_set_wrprotect(mm, addr, pte);
-    spin_unlock(ptl);
-    DEBUG("make page COW at %lx\n", addr);
-    return 0;
-no_page:
-    return -EFAULT;
-}
-
-static void fill_page_bit_map(struct mm_struct* mm, unsigned long addr, unsigned long nr_pages,
-                              unsigned long page_bit_map[PAGE_BITS]) {
-    int i = 0;
-
-    DEBUG("GIPC_SEND fill_page_bit_map %lx - %lx\n", addr, addr + (nr_pages << PAGE_SHIFT));
-
-    do {
-        struct vm_area_struct* vma;
-        pgd_t* pgd;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
-        p4d_t* p4d;
-#endif
-        pud_t* pud;
-        pmd_t* pmd;
-        pte_t* pte;
-        spinlock_t* ptl;
-        bool has_page = false;
-
-        vma = find_vma(mm, addr);
-        if (!vma)
-            goto next;
-
-        BUG_ON(vma->vm_flags & VM_HUGETLB);
-
-        pgd = pgd_offset(mm, addr);
-        if (pgd_none(*pgd) || pgd_bad(*pgd))
-            goto next;
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
-        p4d = p4d_offset(pgd, addr);
-        if (p4d_none(*p4d) || unlikely(p4d_bad(*p4d)))
-            goto next;
-
-        pud = pud_offset(p4d, addr);
-#else
-        pud = pud_offset(pgd, addr);
-#endif
-        if (pud_none(*pud) || pud_bad(*pud))
-            goto next;
-
-        pmd = pmd_offset(pud, addr);
-        if (pmd_none(*pmd))
-            goto next;
-
-        if (unlikely(pmd_trans_huge(*pmd))) {
-            has_page = true;
-            goto next;
-        }
-
-        if (pmd_bad(*pmd))
-            goto next;
-
-        pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
-
-        if (pte_none(*pte))
-            goto next_locked;
-#if 0
-        if (unlikely(!pte_present(*pte)) && pte_file(*pte))
-            goto next_locked;
-#endif
-        has_page = true;
-    next_locked:
-        spin_unlock(ptl);
-    next:
-        if (has_page) {
-            DEBUG("found a page at %lx\n", addr);
-            set_bit(i, page_bit_map);
-        } else {
-            clear_bit(i, page_bit_map);
-        }
-    } while (i++, addr += PAGE_SIZE, i < nr_pages);
-}
-
-static int get_pages(struct task_struct* task, unsigned long start, unsigned long nr_pages,
-                     unsigned long page_bit_map[PAGE_BITS], struct page* pages[PAGE_QUEUE],
-                     struct vm_area_struct* vmas[PAGE_QUEUE]) {
-    struct mm_struct* mm       = task->mm;
-    struct vm_area_struct* vma = NULL;
-    unsigned long addr         = start, nr;
-    int i                      = 0, j, rv;
-
-    while (i < nr_pages) {
-        unsigned long flushed, vmflags;
-        int last = i;
-
-        if (test_bit(last, page_bit_map)) {
-            i = find_next_zero_bit(page_bit_map, PAGE_QUEUE, last + 1);
-            if (i > nr_pages)
-                i = nr_pages;
-            nr = i - last;
-
-            DEBUG("GIPC_SEND get_user_pages %ld pages at %lx\n", addr, nr);
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
-            rv = get_user_pages(addr, nr, FOLL_GET | FOLL_FORCE | FOLL_SPLIT, pages + last,
-                                vmas + last);
-#else
-            rv = __get_user_pages(task, mm, addr, nr, FOLL_GET | FOLL_FORCE | FOLL_SPLIT,
-                                  pages + last, vmas + last, NULL);
-#endif
-            if (rv <= 0) {
-                printk(KERN_ERR "Graphene error: get_user_pages at 0x%016lx-0x%016lx\n",
-                       addr, addr + (nr << PAGE_SHIFT));
-                return rv;
-            }
-
-            if (rv != nr) {
-                printk(KERN_ERR "Graphene error: get_user_pages at 0x%016lx\n",
-                       addr + (rv << PAGE_SHIFT));
-                return -EACCES;
-            }
-
-            flushed = addr;
-            vmflags = 0;
-            for (j = 0; j < nr; j++) {
-                unsigned long target = addr + (j << PAGE_SHIFT);
-
-                /* Mark source COW */
-                rv = make_page_cow(mm, vmas[last + j], target);
-                if (rv)
-                    return rv;
-
-                if (PageAnon(pages[last + j])) {
-                    /* Fix up the counters */
-                    inc_mm_counter_fast(mm, MM_FILEPAGES);
-                    dec_mm_counter_fast(mm, MM_ANONPAGES);
-                    pages[last + j]->mapping = NULL;
-                }
-
-#ifdef FLUSH_TLB_MM_RANGE
-                if (vmflags == vmas[last + j]->vm_flags)
-                    continue;
-                if (flushed < target)
-                    FLUSH_TLB_MM_RANGE(mm, flushed, target, vmflags);
-                flushed = target;
-                vmflags = vmas[last + j]->vm_flags;
-#else
-                FLUSH_TLB_PAGE(vmas[last + j], target);
-#endif
-            }
-
-#ifdef FLUSH_TLB_MM_RANGE
-            if (flushed < addr + (nr << PAGE_SHIFT))
-                FLUSH_TLB_MM_RANGE(mm, flushed, addr + (nr << PAGE_SHIFT), vmflags);
-#endif
-            vma = vmas[i - 1];
-            addr += nr << PAGE_SHIFT;
-        } else {
-            /* This is the case where a page (or pages) are not
-             * currently mapped.
-             * Handle the hole appropriately. */
-            i = find_next_bit(page_bit_map, PAGE_QUEUE, last + 1);
-            if (i > nr_pages)
-                i = nr_pages;
-            nr = i - last;
-
-            DEBUG("GIPC_SEND skip %ld pages at %lx\n", addr, nr);
-
-            for (j = 0; j < nr; j++) {
-                if (!vma) {
-                    vma = find_vma(mm, addr);
-                } else {
-                    /* DEP 6/17/13 - these addresses should
-                     * be monotonically increasing. */
-                    for (; vma && addr >= vma->vm_end; vma = vma->vm_next)
-                        ;
-
-                    /* Leverage monotonic increasing vmas
-                     * to more quickly detect holes in the
-                     * address space. */
-                    if (vma && addr < vma->vm_start)
-                        vma = NULL;
-                }
-
-                pages[last + j] = NULL;
-                vmas[last + j]  = vma;
-                addr += PAGE_SIZE;
-            }
-        }
-    }
-
-    return i;
-}
-
-static int do_gipc_send(struct task_struct* task, struct gipc_queue* gq,
-                        struct gipc_send_buffer* gbuf, unsigned long __user* uaddr,
-                        unsigned long __user* ulen, unsigned long* copied_pages) {
-    struct mm_struct* mm = task->mm;
-    unsigned long addr, len, nr_pages;
-    int rv, i;
-
-    DEBUG("GIPC_SEND uaddr = %p, ulen = %p\n", uaddr, ulen);
-
-    rv = copy_from_user(&addr, uaddr, sizeof(unsigned long));
-    if (rv) {
-        printk(KERN_ALERT "Graphene SEND: bad buffer %p\n", uaddr);
-        return -EFAULT;
-    }
-
-    rv = copy_from_user(&len, ulen, sizeof(unsigned long));
-    if (rv) {
-        printk(KERN_ALERT "Graphene SEND: bad buffer %p\n", ulen);
-        return -EFAULT;
-    }
-
-    if (addr > addr + len) {
-        printk(KERN_ALERT
-               "Graphene SEND: attempt to send %p - %p by thread %d FAIL: bad argument\n",
-               (void*)addr, (void*)(addr + len), task->pid);
-        return -EINVAL;
-    }
-
-    DEBUG("GIPC_SEND addr = %lx, len = %ld\n", addr, len);
-
-    nr_pages = len >> PAGE_SHIFT;
-
-    if (!access_ok(VERIFY_READ, addr, len)) {
-        printk(KERN_ALERT "Graphene SEND: attempt to send %p - %p (%ld pages) by thread %d FAIL: "
-               "bad permission\n",
-               (void*)addr, (void*)(addr + len), nr_pages, task->pid);
-        return -EFAULT;
-    }
-
-    DEBUG("    %p - %p (%ld pages) sent by thread %d\n", (void*)addr, (void*)(addr + len), nr_pages,
-          task->pid);
-
-    while (nr_pages) {
-        unsigned long nr = (nr_pages <= PAGE_QUEUE) ? nr_pages : PAGE_QUEUE;
-
-        /* for each of these addresses - check if
-         * demand faulting will be triggered
-         * if vma is present, but there is no page
-         * present(pmd/pud not present or PTE_PRESENT
-         * is off) then get_user_pages will trigger
-         * the creation of those */
-
-        down_write(&mm->mmap_sem);
-
-        fill_page_bit_map(mm, addr, nr, gbuf->page_bit_map);
-
-        rv = get_pages(task, addr, nr, gbuf->page_bit_map, gbuf->pages, gbuf->vmas);
-        if (rv < 0) {
-            up_write(&mm->mmap_sem);
-            break;
-        }
-
-        for (i = 0; i < nr; i++) {
-            BUG_ON((!gbuf->vmas[i]) && (!!gbuf->pages[i]));
-            if (gbuf->vmas[i] && gbuf->vmas[i]->vm_file) {
-                gbuf->files[i] = get_file(gbuf->vmas[i]->vm_file);
-                gbuf->pgoffs[i] =
-                    ((addr - gbuf->vmas[i]->vm_start) >> PAGE_SHIFT) + gbuf->vmas[i]->vm_pgoff;
-            } else {
-                gbuf->files[i]  = NULL;
-                gbuf->pgoffs[i] = 0;
-            }
-            addr += PAGE_SIZE;
-        }
-
-        up_write(&mm->mmap_sem);
-
-        for (i = 0; i < nr; i++) {
-            /* Put in the pending buffer*/
-            if (((gq->last + 1) & (PAGE_QUEUE - 1)) == gq->next) {
-                /* The blocking condition for send
-                 * and recv can't both be true! */
-                wake_up_all(&gq->recv);
-                wait_event_interruptible(gq->send, ((gq->last + 1) & (PAGE_QUEUE - 1)) != gq->next);
-                if (signal_pending(task)) {
-                    rv = -ERESTARTSYS;
-                    goto out;
-                }
-            }
-            gq->pages[gq->last].page  = gbuf->pages[i];
-            gq->pages[gq->last].file  = gbuf->files[i];
-            gq->pages[gq->last].pgoff = gbuf->pgoffs[i];
-            gq->last++;
-            gq->last &= PAGE_QUEUE - 1;
-            (*copied_pages)++;
-        }
-
-        wake_up_all(&gq->recv);
-        nr_pages -= nr;
-    }
-
-out:
-    return rv;
-}
-
-static inline int recv_next(struct task_struct* task, struct gipc_queue* gq) {
-    if (gq->next == gq->last) {
-        /* The blocking condition for send & recv can't both be true */
-        wake_up_all(&gq->send);
-        wait_event_interruptible(gq->recv, gq->next != gq->last);
-        if (signal_pending(task))
-            return -ERESTARTSYS;
-    }
-
-    return gq->next;
-}
-
-static int do_gipc_recv(struct task_struct* task, struct gipc_queue* gq,
-                        unsigned long __user* uaddr, unsigned long __user* ulen,
-                        unsigned long __user* uprot, unsigned long* copied_pages) {
-    struct mm_struct* mm       = task->mm;
-    struct vm_area_struct* vma = NULL;
-    unsigned long start, addr, len, nr_pages, prot, pgoff;
-    struct page* page = NULL;
-    struct file* file = NULL;
-    int i             = 0, rv;
-
-    rv = copy_from_user(&addr, uaddr, sizeof(unsigned long));
-    if (rv) {
-        printk(KERN_ALERT "Graphene RECV: bad buffer %p\n", uaddr);
-        return -EFAULT;
-    }
-
-    rv = copy_from_user(&len, ulen, sizeof(unsigned long));
-    if (rv) {
-        printk(KERN_ALERT "Graphene RECV: bad buffer %p\n", ulen);
-        return -EFAULT;
-    }
-
-    rv = copy_from_user(&prot, uprot, sizeof(unsigned long));
-    if (rv) {
-        printk(KERN_ALERT "Graphene RECV: bad buffer %p\n", uprot);
-        return -EFAULT;
-    }
-
-    nr_pages = len >> PAGE_SHIFT;
-    start    = addr;
-    down_write(&mm->mmap_sem);
-
-    while (i < nr_pages) {
-        int found    = recv_next(task, gq);
-        int need_map = 1;
-
-        if (found < 0) {
-            rv = found;
-            goto finish;
-        }
-
-        page  = gq->pages[found].page;
-        file  = gq->pages[found].file;
-        pgoff = gq->pages[found].pgoff;
-        gq->next++;
-        gq->next &= PAGE_QUEUE - 1;
-        wake_up_all(&gq->send);
-
-        if (vma) {
-            need_map = 0;
-            if (vma->vm_file != file)
-                need_map = 1;
-            if (file && vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT) != addr)
-                need_map = 1;
-            if (prot != (vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)))
-                need_map = 1;
-        }
-
-        if (need_map) {
-            unsigned long flags = MAP_PRIVATE;
-
-            if (addr)
-                flags |= MAP_FIXED;
-            if (file)
-                flags |= MAP_FILE;
-            else
-                flags |= MAP_ANONYMOUS;
-
-            addr = DO_MMAP_PGOFF(file, addr, (nr_pages - i) << PAGE_SHIFT, prot, flags, pgoff);
-
-            if (IS_ERR_VALUE(addr)) {
-                rv = PTR_ERR((void*)addr);
-                printk(KERN_ERR "Graphene error: failed to mmap (%d)\n", -rv);
-                goto finish;
-            }
-
-            if (file)
-                DEBUG("map %08lx-%08lx file %p\n", addr, addr + ((nr_pages - i) << PAGE_SHIFT),
-                      file);
-            else
-                DEBUG("map %08lx-%08lx\n", addr, addr + ((nr_pages - i) << PAGE_SHIFT));
-
-            if (!start)
-                start = addr;
-
-            vma = find_vma(mm, addr);
-            if (!vma) {
-                printk(KERN_ERR "Graphene error: can't find vma at %p\n", (void*)addr);
-                rv = -ENOENT;
-                goto finish;
-            }
-        } else {
-            BUG_ON(!vma);
-        }
-
-        if (page) {
-            rv = vm_insert_page(vma, addr, page);
-            if (rv) {
-                printk(KERN_ERR "Graphene error: fail to insert page %d\n", rv);
-                goto finish;
-            }
-            rv = make_page_cow(mm, vma, addr);
-            if (rv) {
-                printk(KERN_ERR "Graphene error: can't make vma copy-on-write at %p\n",
-                       (void*)addr);
-                goto finish;
-            }
-        }
-
-    finish:
-        /* Drop the kernel's reference to this page */
-        if (page)
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
-            put_page(page);
-#else
-            page_cache_release(page);
-#endif
-        if (file)
-            fput_atomic(file);
-        if (rv)
-            break;
-        i++;
-        addr += PAGE_SIZE;
-        (*copied_pages)++;
-    }
-
-    up_write(&mm->mmap_sem);
-
-    if (i)
-        DEBUG("    %p - %p (%d pages) received by thread %d\n", (void*)start,
-              (void*)start + (i << PAGE_SHIFT), i, task->pid);
-
-    if (start) {
-        rv = copy_to_user(uaddr, &start, sizeof(unsigned long));
-        if (rv) {
-            printk(KERN_ERR "Graphene error: bad buffer %p\n", uaddr);
-            return -EFAULT;
-        }
-    }
-
-    return rv;
-}
-
-static long gipc_ioctl(struct file* file, unsigned int cmd, unsigned long arg) {
-    struct task_struct* task = current;
-    struct gipc_queue* gq    = NULL;
-    long rv                  = 0;
-
-    switch (cmd) {
-        case GIPC_SEND: {
-            struct gipc_send gs;
-            struct gipc_send_buffer* gbuf;
-            int i;
-            unsigned long nr_pages = 0;
-
-            rv = copy_from_user(&gs, (void*)arg, sizeof(gs));
-            if (rv) {
-                printk(KERN_ALERT "Graphene SEND: bad buffer %p\n", (void*)arg);
-                return -EFAULT;
-            }
-
-            /* Find/allocate the gipc_pages struct for our recipient */
-            gq = (struct gipc_queue*)file->private_data;
-            if (!gq)
-                return -EFAULT;
-
-            gbuf = kmem_cache_alloc(gipc_send_buffer_cachep, GFP_KERNEL);
-            if (!gbuf)
-                return -ENOMEM;
-
-            DEBUG("GIPC_SEND %ld entries to token %lld by thread %d\n", gs.entries, gq->token,
-                  task->pid);
-
-            mutex_lock(&gq->send_lock);
-
-            for (i = 0; i < gs.entries; i++) {
-                rv = do_gipc_send(task, gq, gbuf, gs.addr + i, gs.len + i, &nr_pages);
-                if (rv < 0)
-                    break;
-            }
-
-            mutex_unlock(&gq->send_lock);
-            DEBUG("GIPC_SEND return to thread %d, %ld pages are sent\n", task->pid, nr_pages);
-            kmem_cache_free(gipc_send_buffer_cachep, gbuf);
-            rv = nr_pages ?: rv;
-            break;
-        }
-
-        case GIPC_RECV: {
-            struct gipc_recv gr;
-            int i;
-            unsigned long nr_pages = 0;
-
-            rv = copy_from_user(&gr, (void*)arg, sizeof(gr));
-            if (rv) {
-                printk(KERN_ERR "Graphene error: bad buffer %p\n", (void*)arg);
-                return -EFAULT;
-            }
-
-            gq = (struct gipc_queue*)file->private_data;
-            if (!gq)
-                return -EBADF;
-
-            DEBUG("GIPC_RECV %ld entries to token %lld by thread %d\n", gr.entries, gq->token,
-                  task->pid);
-            mutex_lock(&gq->recv_lock);
-
-            for (i = 0; i < gr.entries; i++) {
-                rv = do_gipc_recv(task, gq, gr.addr + i, gr.len + i, gr.prot + i, &nr_pages);
-                if (rv < 0)
-                    break;
-            }
-
-            mutex_unlock(&gq->recv_lock);
-            DEBUG("GIPC_RECV return to thread %d, %ld pages are received\n", task->pid, nr_pages);
-            rv = nr_pages ?: rv;
-            break;
-        }
-
-        case GIPC_CREATE: {
-            gq = create_gipc_queue(file);
-            if (!gq) {
-                rv = -ENOMEM;
-                break;
-            }
-
-            DEBUG("GIPC_CREATE token %lld by thread %d\n", gq->token, task->pid);
-            rv = gq->token;
-            break;
-        }
-
-        case GIPC_JOIN: {
-            struct gipc_queue* q;
-            u64 token   = arg;
-            u64 session = GIPC_OWNER;
-
-            if (file->private_data != NULL)
-                return -EBUSY;
-
-            /* Search for this token */
-            spin_lock(&gdev.lock);
-            list_for_each_entry(q, &gdev.channels, list) {
-                if (q->token == token) {
-                    gq = q;
-                    break;
-                }
-            }
-
-            /* Fail if we didn't find it */
-            if (!gq) {
-                spin_unlock(&gdev.lock);
-                return -ENOENT;
-            }
-
-            if (gq->owner != session) {
-                spin_unlock(&gdev.lock);
-                return -EPERM;
-            }
-
-            atomic_inc(&gq->count);
-            file->private_data = gq;
-
-            /* Hold the lock until we allocate so only one process
-             * gets the queue */
-            spin_unlock(&gdev.lock);
-            DEBUG("GIPC_JOIN token %lld by thread %d\n", token, task->pid);
-            rv = 0;
-            break;
-        }
-
-        default:
-            printk(KERN_ALERT "Graphene unknown ioctl %u %lu\n", cmd, arg);
-            rv = -ENOSYS;
-            break;
-    }
-
-    return rv;
-}
-
-static int gipc_release(struct inode* inode, struct file* file) {
-    struct gipc_queue* gq = (struct gipc_queue*)file->private_data;
-
-    if (!gq)
-        return 0;
-
-    file->private_data = NULL;
-    release_gipc_queue(gq, false);
-    return 0;
-}
-
-static int gipc_open(struct inode* inode, struct file* file) {
-    file->private_data = NULL;
-    return 0;
-}
-
-static struct file_operations gipc_fops = {
-    .owner          = THIS_MODULE,
-    .release        = gipc_release,
-    .open           = gipc_open,
-    .unlocked_ioctl = gipc_ioctl,
-    .compat_ioctl   = gipc_ioctl,
-    .llseek         = noop_llseek,
-};
-
-static struct miscdevice gipc_dev = {
-    .minor = GIPC_MINOR,
-    .name  = "gipc",
-    .fops  = &gipc_fops,
-    .mode  = 0666,
-};
-
-static int __init gipc_init(void) {
-    int rv = 0;
-
-#ifdef MY_DO_MMAP
-    LOOKUP_KSYM(do_mmap);
-#endif
-#ifdef MY_DO_MMAP_PGOFF
-    LOOKUP_KSYM(do_mmap_pgoff);
-#endif
-#ifdef MY_FLUSH_TLB_MM_RANGE
-    LOOKUP_KSYM(flush_tlb_mm_range);
-#endif
-#ifdef MY_FLUSH_TLB_PAGE
-    LOOKUP_KSYM(flush_tlb_page);
-#endif
-
-#ifndef gipc_get_session
-    my_gipc_get_session = (void*)kallsyms_lookup_name("gipc_get_session");
-#endif
-
-    /* Register the kmem cache */
-    gipc_queue_cachep = kmem_cache_create("gipc_queue", sizeof(struct gipc_queue), 0,
-                                          SLAB_HWCACHE_ALIGN |
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
-                                              SLAB_TYPESAFE_BY_RCU,
-#else
-                                              SLAB_DESTROY_BY_RCU,
-#endif
-                                          NULL);
-    if (!gipc_queue_cachep) {
-        printk(KERN_ERR "Graphene error: failed to create a gipc queues cache\n");
-        return -ENOMEM;
-    }
-
-    gipc_send_buffer_cachep =
-        kmem_cache_create("gipc_send_buffer", sizeof(struct gipc_send_buffer), 0,
-                          SLAB_HWCACHE_ALIGN |
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
-                              SLAB_TYPESAFE_BY_RCU,
-#else
-                              SLAB_DESTROY_BY_RCU,
-#endif
-                          NULL);
-    if (!gipc_send_buffer_cachep) {
-        printk(KERN_ERR "Graphene error: failed to create a gipc buffers cache\n");
-        return -ENOMEM;
-    }
-
-    INIT_LIST_HEAD(&gdev.channels);
-    spin_lock_init(&gdev.lock);
-    gdev.max_token = 1;
-
-    rv = misc_register(&gipc_dev);
-    if (rv) {
-        printk(KERN_ERR "Graphene error: failed to add a char device (rv=%d)\n", rv);
-        return rv;
-    }
-
-    printk(KERN_ALERT "Graphene IPC: Hello, world\n");
-    return 0;
-}
-
-static void __exit gipc_exit(void) {
-    struct gipc_queue *gq, *n;
-    spin_lock(&gdev.lock);
-    list_for_each_entry_safe(gq, n, &gdev.channels, list) {
-        release_gipc_queue(gq, true);
-    }
-    spin_unlock(&gdev.lock);
-
-    misc_deregister(&gipc_dev);
-    kmem_cache_destroy(gipc_queue_cachep);
-
-    printk(KERN_ALERT "Graphene IPC: Goodbye, cruel world\n");
-}
-
-module_init(gipc_init);
-module_exit(gipc_exit);

+ 0 - 35
Pal/ipc/linux/graphene-ipc.h

@@ -1,35 +0,0 @@
-#ifndef _GRAPHENE_IPC_H
-#define _GRAPHENE_IPC_H
-
-#include <linux/ioctl.h>
-
-#define GIPC_FILE  "/dev/gipc"
-#define GIPC_MINOR 240
-
-/* Ioctl codes */
-#define GIPC_SEND   _IOW('k', 0, void*)
-#define GIPC_RECV   _IOR('k', 1, void*)
-#define GIPC_CREATE _IOR('k', 2, void*)
-#define GIPC_JOIN   _IOR('k', 3, void*)
-
-// Must be a power of 2!
-#define PAGE_QUEUE 2048
-#define PAGE_BITS  (PAGE_QUEUE / sizeof(unsigned long))
-
-#define PAGE_PRESENT 1
-
-/* Argument Structures */
-typedef struct gipc_send {
-    unsigned long entries;
-    unsigned long* addr;
-    unsigned long* len;
-} gipc_send;
-
-typedef struct gipc_recv {
-    unsigned long entries;
-    unsigned long* addr;
-    unsigned long* len;
-    unsigned long* prot;
-} gipc_recv;
-
-#endif  // _GRAPHENE_IPC_H

+ 0 - 40
Pal/ipc/linux/install.sh

@@ -1,40 +0,0 @@
-#!/usr/bin/env bash
-
-SCRIPT=`readlink -f "${BASH_SOURCE[0]}"`
-DIR=`dirname $SCRIPT`
-MOD=graphene-ipc
-MODNAME=graphene_ipc
-VER=0.0.1
-
-/sbin/lsmod | grep -q $MODNAME
-if [ $? -eq 0 ]; then
-	echo "$MOD already running"
-	exit 0
-fi
-
-/usr/sbin/dkms status | grep -q $MOD
-if [ $? -eq 0 ]; then
-	modprobe $MOD || exit $?
-	echo "$MOD loaded"
-	exit 0
-fi
-
-dkms add $DIR || exit $?
-
-dkms build -m $MOD -v $VER
-if [ $? -ne 0 ]; then
-	err=$?
-	rm -rf /usr/src/$MOD-$VER
-	exit $err
-fi
-
-dkms install -m $MOD -v $VER
-if [ $? -ne 0 ]; then
-	err=$?
-	dkms remove $MOD/$VER --all
-	rm -rf /usr/src/$MOD-$VER
-	exit $err
-fi
-
-modprobe $MOD || exit $?
-echo "$MOD loaded"

+ 0 - 23
Pal/ipc/linux/ksyms.h

@@ -1,23 +0,0 @@
-#ifndef _KSYM_H
-#define _KSYM_H
-
-#include <linux/kallsyms.h>
-
-#define __KSYM(name) __ksym_##name
-#define KSYM(name)             \
-    ({                         \
-        BUG_ON(!__KSYM(name)); \
-        __KSYM(name);          \
-    })
-#define IMPORT_KSYM(name)                 __typeof(name)* __KSYM(name)
-#define IMPORT_KSYM_PROTO(name, ret, ...) ret (*__KSYM(name))(__VA_ARGS__)
-#define LOOKUP_KSYM(name)                                  \
-    do {                                                   \
-        __KSYM(name) = (void*)kallsyms_lookup_name(#name); \
-        if (!__KSYM(name)) {                               \
-            pr_err("Unknown symbol: " #name "\n");         \
-            return -EINVAL;                                \
-        }                                                  \
-    } while (0)
-
-#endif

+ 0 - 12
Pal/ipc/linux/load.sh

@@ -1,12 +0,0 @@
-#!/usr/bin/env bash
-
-MOD=graphene-ipc
-MODNAME=graphene_ipc
-
-(/sbin/lsmod | grep -q $MODNAME) && \
-((echo "unloading $MODNAME..."; /sbin/rmmod $MODNAME) || exit 1) || continue
-
-# invoke insmod with all arguments we got
-# and use a pathname, as newer modutils don't look in . by default
-echo "loading $MODNAME..."
-/sbin/insmod ./$MOD.ko $* || exit 1

+ 0 - 18
Pal/ipc/linux/uninstall.sh

@@ -1,18 +0,0 @@
-#!/usr/bin/env bash
-
-DIR=`readlink -f "${BASH_SOURCE[0]}"`
-MOD=graphene-ipc
-MODNAME=graphene_ipc
-VER=0.0.1
-
-/sbin/lsmod | grep -q $MODNAME
-if [ $? -eq 0 ]; then
-	modprobe -r $MODNAME
-fi
-
-/usr/sbin/dkms status | grep -q $MOD
-if [ $? -eq 0 ]; then
-	dkms remove $MOD/$VER --all
-fi
-
-rm -rf /usr/src/$MOD-$VER

+ 0 - 333
Pal/regression/Ipc.c

@@ -1,333 +0,0 @@
-#include "api.h"
-#include "pal.h"
-#include "pal_debug.h"
-
-#define UNIT (pal_control.alloc_align)
-
-static const char* volatile message = NULL;
-
-void handler(PAL_PTR event, PAL_NUM arg, PAL_CONTEXT* context) {
-    if (message)
-        pal_printf("%s", message);
-
-    while (*(unsigned char*)context->rip != 0x90) {
-        context->rip++;
-    }
-
-    DkExceptionReturn(event);
-}
-
-int main(int argc, char** argv, char** envp) {
-    char gipc_uri[20];
-    int ret;
-
-    DkSetExceptionHandler(handler, PAL_EVENT_MEMFAULT);
-
-    if (argc > 1 && !memcmp(argv[1], "Child", 6)) {
-        /* private memory */
-
-        ret = DkStreamRead(pal_control.parent_process, 0, 20, gipc_uri, NULL, 0);
-
-        if (ret > 0) {
-            PAL_HANDLE ipc1 = DkStreamOpen(gipc_uri, 0, 0, 0, 0);
-
-            if (ipc1) {
-                pal_printf("Join Physical Memory Store OK\n");
-
-                PAL_PTR mem_addr = 0;
-                PAL_NUM mem_size = UNIT;
-                PAL_FLG mem_prot = PAL_PROT_READ | PAL_PROT_WRITE;
-
-                ret = DkPhysicalMemoryMap(ipc1, 1, &mem_addr, &mem_size, &mem_prot);
-
-                if (ret > 0) {
-                    pal_printf("[Test 1] Physical Memory Map   : %s\n", (char*)mem_addr);
-                    memcpy((void*)mem_addr, "Hello World, Bob", 20);
-                    pal_printf("[Test 1] Receiver After  Map   : %s\n", (char*)mem_addr);
-                }
-
-                ret = 0;
-                DkStreamWrite(pal_control.parent_process, 0, sizeof(int), &ret, NULL);
-                DkObjectClose(ipc1);
-            }
-        }
-
-        /* private untouched memory */
-
-        ret = DkStreamRead(pal_control.parent_process, 0, 20, gipc_uri, NULL, 0);
-
-        if (ret > 0) {
-            PAL_HANDLE ipc2 = DkStreamOpen(gipc_uri, 0, 0, 0, 0);
-
-            if (ipc2) {
-                pal_printf("Join Physical Memory Store OK\n");
-
-                PAL_PTR mem_addr = 0;
-                PAL_NUM mem_size = UNIT;
-                PAL_FLG mem_prot = PAL_PROT_READ | PAL_PROT_WRITE;
-
-                ret = DkPhysicalMemoryMap(ipc2, 1, &mem_addr, &mem_size, &mem_prot);
-
-                if (ret > 0) {
-                    pal_printf("[Test 2] Physical Memory Map   : %s\n", (char*)mem_addr);
-                    memcpy((void*)mem_addr, "Hello World, Bob", 20);
-                    pal_printf("[Test 2] Receiver After  Map   : %s\n", (char*)mem_addr);
-                }
-
-                ret = 0;
-                DkStreamWrite(pal_control.parent_process, 0, sizeof(int), &ret, NULL);
-                DkStreamDelete(ipc2, 0);
-                DkObjectClose(ipc2);
-            }
-        }
-
-        /* file-backed memory */
-
-        ret = DkStreamRead(pal_control.parent_process, 0, 20, gipc_uri, NULL, 0);
-
-        if (ret > 0) {
-            PAL_HANDLE ipc3 = DkStreamOpen(gipc_uri, 0, 0, 0, 0);
-
-            if (ipc3) {
-                pal_printf("Join Physical Memory Store OK\n");
-
-                PAL_PTR mem_addr = 0;
-                PAL_NUM mem_size = UNIT;
-                PAL_FLG mem_prot = PAL_PROT_READ | PAL_PROT_WRITE;
-
-                ret = DkPhysicalMemoryMap(ipc3, 1, &mem_addr, &mem_size, &mem_prot);
-
-                if (ret > 0) {
-                    pal_printf("[Test 3] Physical Memory Map   : %s\n", (char*)mem_addr);
-                    memcpy((void*)mem_addr, "Hello World, Bob", 20);
-                    pal_printf("[Test 3] Receiver After  Map   : %s\n", (char*)mem_addr);
-                }
-
-                ret = 0;
-                DkStreamWrite(pal_control.parent_process, 0, sizeof(int), &ret, NULL);
-                DkObjectClose(ipc3);
-            }
-        }
-
-        /* file-backed memory beyond file size */
-
-        ret = DkStreamRead(pal_control.parent_process, 0, 20, gipc_uri, NULL, 0);
-
-        if (ret > 0) {
-            PAL_HANDLE ipc4 = DkStreamOpen(gipc_uri, 0, 0, 0, 0);
-
-            if (ipc4) {
-                pal_printf("Join Physical Memory Store OK\n");
-
-                PAL_PTR mem_addr = 0;
-                PAL_NUM mem_size = UNIT;
-                PAL_FLG mem_prot = PAL_PROT_READ | PAL_PROT_WRITE;
-
-                ret = DkPhysicalMemoryMap(ipc4, 1, &mem_addr, &mem_size, &mem_prot);
-
-                if (ret > 0) {
-                    message = "[Test 4] Physical Memory Map   : Memory Fault\n";
-                    *(volatile int*)mem_addr;
-                    __asm__ volatile("nop");
-                    message = NULL;
-                }
-
-                ret = 0;
-                DkStreamWrite(pal_control.parent_process, 0, sizeof(int), &ret, NULL);
-                DkObjectClose(ipc4);
-            }
-        }
-
-        /* large memory */
-
-        ret = DkStreamRead(pal_control.parent_process, 0, 20, gipc_uri, NULL, 0);
-
-        if (ret > 0) {
-            PAL_HANDLE ipc5 = DkStreamOpen(gipc_uri, 0, 0, 0, 0);
-
-            if (ipc5) {
-                pal_printf("Join Physical Memory Store OK\n");
-
-                PAL_PTR mem_addr = 0;
-                PAL_NUM mem_size = UNIT * 1024 * 64;
-                PAL_FLG mem_prot = PAL_PROT_READ | PAL_PROT_WRITE;
-
-                ret = DkPhysicalMemoryMap(ipc5, 1, &mem_addr, &mem_size, &mem_prot);
-
-                if (ret > 0) {
-                    pal_printf("[Test 5] Physical Memory Map   : %s\n",
-                               (char*)mem_addr + UNIT * 1024);
-                }
-
-                ret = 0;
-                DkStreamWrite(pal_control.parent_process, 0, sizeof(int), &ret, NULL);
-                DkObjectClose(ipc5);
-            }
-        }
-    } else {
-        PAL_STR args[3] = {"Ipc", "Child", 0};
-        PAL_HANDLE proc = DkProcessCreate("file:Ipc", args);
-
-        if (!proc)
-            return 0;
-
-        /* private memory */
-
-        PAL_NUM key1;
-        PAL_HANDLE ipc1 = DkCreatePhysicalMemoryChannel(&key1);
-
-        if (ipc1) {
-            snprintf(gipc_uri, 20, "gipc:%ld", key1);
-            pal_printf("Create Physical Memory Store OK\n");
-
-            void* mem1 = (void*)DkVirtualMemoryAlloc(NULL, UNIT, 0, PAL_PROT_READ | PAL_PROT_WRITE);
-
-            if (mem1) {
-                memcpy(mem1, "Hello World", 20);
-
-                PAL_PTR mem_addr = mem1;
-                PAL_NUM mem_size = UNIT;
-
-                if (DkPhysicalMemoryCommit(ipc1, 1, &mem_addr, &mem_size)) {
-                    pal_printf("[Test 1] Physical Memory Commit OK\n");
-                    memcpy(mem1, "Hello World, Alice", 20);
-                    pal_printf("[Test 1] Sender   After  Commit: %s\n", (char*)mem1);
-                    DkStreamWrite(proc, 0, 20, gipc_uri, NULL);
-                    memcpy(mem1, "Alice, Hello World", 20);
-                    pal_printf("[Test 1] Sender   Before Map   : %s\n", (char*)mem1);
-                    DkStreamRead(proc, 0, sizeof(int), &ret, NULL, 0);
-                    pal_printf("[Test 1] Sender   After  Map   : %s\n", (char*)mem1);
-                }
-            }
-
-            DkObjectClose(ipc1);
-        }
-
-        /* private untouched memory */
-
-        PAL_NUM key2;
-        PAL_HANDLE ipc2 = DkCreatePhysicalMemoryChannel(&key2);
-
-        if (ipc2) {
-            snprintf(gipc_uri, 20, "gipc:%ld", key2);
-            pal_printf("Create Physical Memory Store OK\n");
-
-            void* mem2 = (void*)DkVirtualMemoryAlloc(NULL, UNIT, 0, PAL_PROT_READ | PAL_PROT_WRITE);
-
-            if (mem2) {
-                PAL_PTR mem_addr = mem2;
-                PAL_NUM mem_size = UNIT;
-
-                if (DkPhysicalMemoryCommit(ipc2, 1, &mem_addr, &mem_size)) {
-                    pal_printf("[Test 2] Physical Memory Commit OK\n");
-                    memcpy(mem2, "Hello World, Alice", 20);
-                    pal_printf("[Test 2] Sender   After  Commit: %s\n", (char*)mem2);
-                    DkStreamWrite(proc, 0, 20, gipc_uri, NULL);
-                    memcpy(mem2, "Alice, Hello World", 20);
-                    pal_printf("[Test 2] Sender   Before Map   : %s\n", (char*)mem2);
-                    DkStreamRead(proc, 0, sizeof(int), &ret, NULL, 0);
-                    pal_printf("[Test 2] Sender   After  Map   : %s\n", (char*)mem2);
-                }
-            }
-
-            DkObjectClose(ipc2);
-        }
-
-        /* file-backed memory */
-
-        PAL_NUM key3;
-        PAL_HANDLE ipc3 = DkCreatePhysicalMemoryChannel(&key3);
-
-        if (ipc3) {
-            snprintf(gipc_uri, 20, "gipc:%ld", key3);
-            pal_printf("Create Physical Memory Store OK\n");
-
-            void* mem3       = NULL;
-            PAL_HANDLE file1 = DkStreamOpen("file:ipc_mapping.tmp", PAL_ACCESS_RDWR, 0, 0, 0);
-
-            if (file1) {
-                mem3 = (void*)DkStreamMap(file1, NULL, PAL_PROT_READ | PAL_PROT_WRITE, 0, UNIT);
-                DkObjectClose(file1);
-            }
-
-            if (mem3) {
-                PAL_PTR mem_addr = mem3;
-                PAL_NUM mem_size = UNIT;
-
-                if (DkPhysicalMemoryCommit(ipc3, 1, &mem_addr, &mem_size)) {
-                    pal_printf("[Test 3] Physical Memory Commit OK\n");
-                    DkStreamWrite(proc, 0, 20, gipc_uri, NULL);
-                    pal_printf("[Test 3] Sender   After  Commit: %s\n", (char*)mem3);
-                    DkStreamRead(proc, 0, sizeof(int), &ret, NULL, 0);
-                    pal_printf("[Test 3] Sender   After  Map   : %s\n", (char*)mem3);
-                }
-            }
-
-            DkObjectClose(ipc3);
-        }
-
-        /* file-backed memory beyond file size */
-
-        PAL_NUM key4;
-        PAL_HANDLE ipc4 = DkCreatePhysicalMemoryChannel(&key4);
-
-        if (ipc4) {
-            snprintf(gipc_uri, 20, "gipc:%ld", key4);
-            pal_printf("Create Physical Memory Store OK\n");
-
-            void* mem4       = NULL;
-            PAL_HANDLE file2 = DkStreamOpen("file:ipc_mapping.tmp", PAL_ACCESS_RDWR, 0, 0, 0);
-
-            if (file2) {
-                mem4 = (void*)DkStreamMap(file2, NULL, PAL_PROT_READ | PAL_PROT_WRITE, UNIT, UNIT);
-                DkObjectClose(file2);
-            }
-
-            if (mem4) {
-                PAL_PTR mem_addr = mem4;
-                PAL_NUM mem_size = UNIT;
-
-                if (DkPhysicalMemoryCommit(ipc4, 1, &mem_addr, &mem_size)) {
-                    pal_printf("[Test 4] Physical Memory Commit OK\n");
-                    DkStreamWrite(proc, 0, 20, gipc_uri, NULL);
-                    DkStreamRead(proc, 0, sizeof(int), &ret, NULL, 0);
-                }
-            }
-
-            DkObjectClose(ipc4);
-        }
-
-        /* large memory */
-
-        PAL_NUM key5;
-        PAL_HANDLE ipc5 = DkCreatePhysicalMemoryChannel(&key5);
-
-        if (ipc5) {
-            snprintf(gipc_uri, 20, "gipc:%ld", key5);
-            pal_printf("Create Physical Memory Store OK\n");
-
-            void* mem5 = (void*)DkVirtualMemoryAlloc(NULL, UNIT * 1024 * 64, 0,
-                                                     PAL_PROT_READ | PAL_PROT_WRITE);
-
-            if (mem5) {
-                pal_printf("Touch Memory at %p\n", mem5 + UNIT * 1024);
-
-                memcpy(mem5 + UNIT * 1024, "Hello World", 20);
-
-                PAL_PTR mem_addr = mem5;
-                PAL_NUM mem_size = UNIT * 1024 * 64;
-
-                DkStreamWrite(proc, 0, 20, gipc_uri, NULL);
-
-                if (DkPhysicalMemoryCommit(ipc5, 1, &mem_addr, &mem_size)) {
-                    pal_printf("[Test 5] Physical Memory Commit OK\n");
-                    DkStreamRead(proc, 0, sizeof(int), &ret, NULL, 0);
-                }
-            }
-
-            DkObjectClose(ipc1);
-        }
-    }
-
-    return 0;
-}

+ 0 - 4
Pal/regression/Symbols.c

@@ -60,9 +60,5 @@ int main(int argc, char** argv, char** envp) {
     PRINT_SYMBOL(DkSegmentRegister);
     PRINT_SYMBOL(DkMemoryAvailableQuota);
 
-    PRINT_SYMBOL(DkCreatePhysicalMemoryChannel);
-    PRINT_SYMBOL(DkPhysicalMemoryCommit);
-    PRINT_SYMBOL(DkPhysicalMemoryMap);
-
     return 0;
 }

+ 0 - 55
Pal/regression/test_pal.py

@@ -198,9 +198,6 @@ class TC_02_Symbols(RegressionTestCase):
         'DkInstructionCacheFlush',
         'DkSegmentRegister',
         'DkMemoryAvailableQuota',
-        'DkCreatePhysicalMemoryChannel',
-        'DkPhysicalMemoryCommit',
-        'DkPhysicalMemoryMap',
     ]
 
     def test_000_symbols(self):
@@ -552,58 +549,6 @@ class TC_21_ProcessCreation(RegressionTestCase):
         self.assertEqual(counter['Binary 1 Preloaded'], 2)
         self.assertEqual(counter['Binary 2 Preloaded'], 2)
 
-
-@unittest.skipIf(HAS_SGX, 'GIPC not supported on SGX')
-
-## XXX Should really be running these tests as part of CI
-@unittest.skipUnless(pathlib.Path('/dev/gipc').exists(), 'GIPC not loaded')
-
-class TC_22_GIPC(RegressionTestCase):
-    def test_000_gipc(self):
-        with open('ipc_mapping.tmp', 'w') as file:
-            file.write('Hello World')
-            os.ftruncate(file.fileno(), mmap.PAGESIZE)
-
-        stdout, stderr = self.run_binary(['Ipc'])
-        counter = collections.Counter(stderr.split('\n'))
-
-        # Create and Join Physical Memory Bulk Copy Store
-        self.assertEqual(counter['Create Physical Memory Store OK'], 5)
-        self.assertEqual(counter['Join Physical Memory Store OK'], 5)
-
-        # Map and Commit Anonymous Physical Memory
-        self.assertIn('[Test 1] Physical Memory Commit OK', stderr)
-        self.assertIn('[Test 1] Physical Memory Map   : Hello World', stderr)
-
-        # Transfer Anonymous Physical Memory as Copy-on-Write
-        self.assertIn('[Test 1] Sender   After  Commit: Hello World, Alice', stderr)
-        self.assertIn('[Test 1] Sender   Before Map   : Alice, Hello World', stderr)
-        self.assertIn('[Test 1] Receiver After  Map   : Hello World, Bob', stderr)
-        self.assertIn('[Test 1] Sender   After  Map   : Alice, Hello World', stderr)
-
-        # Map and Commit Untouched Physical Memory
-        self.assertIn('[Test 2] Physical Memory Commit OK', stderr)
-        self.assertIn('[Test 2] Physical Memory Map   : ', stderr)
-        self.assertIn('[Test 2] Sender   After  Commit: Hello World, Alice', stderr)
-        self.assertIn('[Test 2] Sender   Before Map   : Alice, Hello World', stderr)
-        self.assertIn('[Test 2] Receiver After  Map   : Hello World, Bob', stderr)
-        self.assertIn('[Test 2] Sender   After  Map   : Alice, Hello World', stderr)
-
-        # Map and Commit File-Backed Physical Memory
-        self.assertIn('[Test 3] Physical Memory Commit OK', stderr)
-        self.assertIn('[Test 3] Physical Memory Map   : Hello World', stderr)
-        self.assertIn('[Test 3] Sender   After  Commit: Hello World', stderr)
-        self.assertIn('[Test 3] Receiver After  Map   : Hello World, Bob', stderr)
-        self.assertIn('[Test 3] Sender   After  Map   : Hello World', stderr)
-
-        # Map and Commit File-Backed Physical Memory Beyond File Size
-        self.assertIn('[Test 4] Physical Memory Commit OK', stderr)
-        self.assertIn('[Test 4] Physical Memory Map   : Memory Fault', stderr)
-
-        # Map and Commit Huge Physical Memory
-        self.assertIn('[Test 5] Physical Memory Commit OK', stderr)
-        self.assertIn('[Test 5] Physical Memory Map   : Hello World', stderr)
-
 class TC_23_SendHandle(RegressionTestCase):
     def test_000_send_handle(self):
         stdout, stderr = self.run_binary(['SendHandle'])

+ 1 - 1
Pal/src/Makefile

@@ -39,7 +39,7 @@ defs	= -DIN_PAL -DHOST_TYPE="$(PAL_HOST)" -D$(PAL_HOST_MACRO) -DPAL_DIR=$(PAL_DI
 	  -DRUNTIME_DIR=$(RUNTIME_DIR)
 CFLAGS += $(defs)
 objs	= $(addprefix db_,streams memory threading mutex events process \
-	    object main misc ipc exception rtld) slab printf pal_error
+	    object main misc exception rtld) slab printf pal_error
 
 graphene_lib = $(LIB_DIR)/graphene-lib.a
 host_lib = $(HOST_DIR)/libpal-$(PAL_HOST).a

+ 0 - 85
Pal/src/db_ipc.c

@@ -1,85 +0,0 @@
-/* Copyright (C) 2014 Stony Brook University
-   This file is part of Graphene Library OS.
-
-   Graphene Library OS is free software: you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public License
-   as published by the Free Software Foundation, either version 3 of the
-   License, or (at your option) any later version.
-
-   Graphene Library OS is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/*
- * db_ipc.c
- *
- * This file contains APIs for physical memory bulk copy across processes.
- */
-
-#include "pal_defs.h"
-#include "pal.h"
-#include "pal_internal.h"
-#include "pal_error.h"
-#include "api.h"
-
-PAL_HANDLE
-DkCreatePhysicalMemoryChannel (PAL_NUM * key)
-{
-    ENTER_PAL_CALL(DkCreatePhysicalMemoryChannel);
-
-    PAL_HANDLE handle = NULL;
-    int ret = _DkCreatePhysicalMemoryChannel(&handle, key);
-
-    if (ret < 0) {
-        _DkRaiseFailure(-ret);
-        handle = NULL;
-    }
-
-    LEAVE_PAL_CALL_RETURN(handle);
-}
-
-PAL_NUM
-DkPhysicalMemoryCommit (PAL_HANDLE channel, PAL_NUM entries, PAL_PTR * addrs,
-                        PAL_NUM * sizes)
-{
-    ENTER_PAL_CALL(DkPhysicalMemoryCommit);
-
-    if (!addrs || !sizes || !channel || !IS_HANDLE_TYPE(channel, gipc)) {
-        _DkRaiseFailure(PAL_ERROR_INVAL);
-        LEAVE_PAL_CALL_RETURN(0);
-    }
-
-    int ret = _DkPhysicalMemoryCommit(channel, entries, addrs, sizes);
-
-    if (ret < 0) {
-        _DkRaiseFailure(-ret);
-        ret = 0;
-    }
-
-    LEAVE_PAL_CALL_RETURN(ret);
-}
-
-PAL_NUM
-DkPhysicalMemoryMap (PAL_HANDLE channel, PAL_NUM entries, PAL_PTR * addrs,
-                     PAL_NUM * sizes, PAL_FLG * prots)
-{
-    ENTER_PAL_CALL(DkPhysicalMemoryMap);
-
-    if (!sizes || !channel || !IS_HANDLE_TYPE(channel, gipc)) {
-        _DkRaiseFailure(PAL_ERROR_INVAL);
-        LEAVE_PAL_CALL_RETURN(0);
-    }
-
-    int ret = _DkPhysicalMemoryMap(channel, entries, addrs, sizes, prots);
-
-    if (ret < 0) {
-        _DkRaiseFailure(-ret);
-        ret = 0;
-    }
-
-    LEAVE_PAL_CALL_RETURN(ret);
-}

+ 0 - 4
Pal/src/db_streams.c

@@ -43,7 +43,6 @@ extern struct handle_ops thread_ops;
 extern struct handle_ops proc_ops;
 extern struct handle_ops mutex_ops;
 extern struct handle_ops event_ops;
-extern struct handle_ops gipc_ops;
 extern struct handle_ops mcast_ops;
 extern struct handle_ops eventfd_ops;
 
@@ -64,7 +63,6 @@ const struct handle_ops* pal_handle_ops[PAL_HANDLE_TYPE_BOUND] = {
     [pal_type_thread]  = &thread_ops,
     [pal_type_mutex]   = &mutex_ops,
     [pal_type_event]   = &event_ops,
-    [pal_type_gipc]    = &gipc_ops,
     [pal_type_eventfd] = &eventfd_ops,
 };
 
@@ -99,8 +97,6 @@ static int parse_stream_uri(const char** uri, char** prefix, struct handle_ops**
                 hops = &file_ops;
             else if (strstartswith_static(u, "pipe"))
                 hops = &pipe_ops;
-            else if (strstartswith_static(u, "gipc"))
-                hops = &gipc_ops;
             break;
 
         case 7:

+ 2 - 2
Pal/src/host/FreeBSD/Makefile

@@ -1,7 +1,7 @@
 include ../../../../Makefile.configs
 include Makefile.am
 
-CFLAGS	+= -I. -Iinclude -I../.. -I../../../include -I../../../lib -I../../../ipc/linux \
+CFLAGS	+= -I. -Iinclude -I../.. -I../../../include -I../../../lib \
 	   -I../../../linux-kernel/graphene
 ASFLAGS += -I. -Iinclude -I../.. -I../../../include
 
@@ -11,7 +11,7 @@ defs	= -DIN_PAL -DPAL_DIR="$(PAL_DIR)"
 CFLAGS += $(defs)
 ASFLAGS += $(defs)
 objs	= $(addprefix db_,files devices pipes sockets streams memory threading \
-	    mutex events process object main rtld misc ipc \
+	    mutex events process object main rtld misc \
 	    exception2) rfork_thread
 graphene_lib = .lib/graphene-lib.a
 headers	= $(wildcard *.h) $(wildcard ../../*.h) $(wildcard ../../../lib/*.h)

+ 0 - 72
Pal/src/host/FreeBSD/db_ipc.c

@@ -1,72 +0,0 @@
-/* Copyright (C) 2014 Stony Brook University
-   This file is part of Graphene Library OS.
-
-   Graphene Library OS is free software: you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public License
-   as published by the Free Software Foundation, either version 3 of the
-   License, or (at your option) any later version.
-
-   Graphene Library OS is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/*
- * db_ipc.c
- *
- * This file contains APIs for physical memory bulk copy across processes.
- */
-
-#include "pal_defs.h"
-#include "pal_freebsd_defs.h"
-#include "pal.h"
-#include "pal_internal.h"
-#include "pal_freebsd.h"
-#include "pal_error.h"
-#include "pal_security.h"
-#include "api.h"
-
-#include <fcntl.h>
-#include <sched.h>
-
-int gipc_open (PAL_HANDLE * handle, const char * type, const char * uri,
-               int access, int share, int create, int options)
-{
-    return -PAL_ERROR_NOTIMPLEMENTED;
-}
-
-int gipc_close (PAL_HANDLE handle)
-{
-    return 0;
-}
-
-const char * gipc_getrealpath (PAL_HANDLE handle)
-{
-    return NULL;
-}
-
-struct handle_ops gipc_ops = {
-        .getrealpath        = &gipc_getrealpath,
-        .open               = &gipc_open,
-        .close              = &gipc_close,
-    };
-
-int _DkCreatePhysicalMemoryChannel (PAL_HANDLE * handle, uint64_t * key)
-{
-    return -PAL_ERROR_NOTIMPLEMENTED;
-}
-
-int _DkPhysicalMemoryCommit (PAL_HANDLE channel, int entries,
-                             PAL_PTR * addrs, PAL_NUM * sizes, int flags)
-{
-    return -PAL_ERROR_NOTIMPLEMENTED;
-}
-
-int _DkPhysicalMemoryMap (PAL_HANDLE channel, int entries,
-                          PAL_PTR * addrs, PAL_NUM * sizes, PAL_FLG * prots)
-{
-    return -PAL_ERROR_NOTIMPLEMENTED;
-}

+ 0 - 2
Pal/src/host/FreeBSD/db_streams.c

@@ -152,7 +152,6 @@ int handle_serialize (PAL_HANDLE handle, void ** data)
                 dsz2 = addr_size(handle->sock.conn);
             }
             break;
-        case pal_type_gipc:
         case pal_type_process:
             break;
         default:
@@ -250,7 +249,6 @@ int handle_deserialize (PAL_HANDLE * handle, const void * data, int size)
             }
             break;
         }
-        case pal_type_gipc:
         case pal_type_process:
             hdl = malloc_copy(hdl_data, hdlsz);
             break;

+ 0 - 6
Pal/src/host/FreeBSD/pal_host.h

@@ -107,12 +107,6 @@ typedef union pal_handle
         PAL_BOL endofstream;
     } dir;
 
-    struct {
-        PAL_HDR hdr;
-        PAL_IDX fd;
-        PAL_NUM token;
-    } gipc;
-
     struct {
         PAL_HDR hdr;
         PAL_IDX fd;

+ 1 - 1
Pal/src/host/Linux-SGX/Makefile

@@ -14,7 +14,7 @@ CFLAGS += $(defs)
 ASFLAGS += $(defs)
 enclave-objs = $(addprefix db_,files devices pipes eventfd sockets streams memory \
 		 threading mutex events process object main rtld \
-		 exception misc ipc spinlock) \
+		 exception misc spinlock) \
 	       $(addprefix enclave_,ocalls ecalls framework platform pages untrusted)
 enclave-asm-objs = enclave_entry
 urts-objs = $(addprefix sgx_,enclave framework platform main rtld thread process exception graphene) \

+ 0 - 67
Pal/src/host/Linux-SGX/db_ipc.c

@@ -1,67 +0,0 @@
-/* Copyright (C) 2014 Stony Brook University
-   This file is part of Graphene Library OS.
-
-   Graphene Library OS is free software: you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public License
-   as published by the Free Software Foundation, either version 3 of the
-   License, or (at your option) any later version.
-
-   Graphene Library OS is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/*
- * db_ipc.c
- *
- * This file contains APIs for physical memory bulk copy across processes.
- */
-
-#include "pal.h"
-#include "pal_defs.h"
-#include "pal_error.h"
-#include "pal_internal.h"
-#include "pal_linux_defs.h"
-
-/* Mute warning for the file with all unimplemented functions
- * Remove the following pragma when implementing the functions
- */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-
-int gipc_open(PAL_HANDLE* handle, const char* type, const char* uri, int access, int share,
-              int create, int options) {
-    return -PAL_ERROR_NOTIMPLEMENTED;
-}
-
-int gipc_close(PAL_HANDLE handle) {
-    return -PAL_ERROR_NOTIMPLEMENTED;
-}
-
-const char* gipc_getrealpath(PAL_HANDLE handle) {
-    return NULL;
-}
-
-struct handle_ops gipc_ops = {
-    .getrealpath = &gipc_getrealpath,
-    .open        = &gipc_open,
-    .close       = &gipc_close,
-};
-
-int _DkCreatePhysicalMemoryChannel(PAL_HANDLE* handle, uint64_t* key) {
-    return -PAL_ERROR_NOTIMPLEMENTED;
-}
-
-int _DkPhysicalMemoryCommit(PAL_HANDLE channel, int entries, PAL_PTR* addrs, PAL_NUM* sizes) {
-    return -PAL_ERROR_NOTIMPLEMENTED;
-}
-
-int _DkPhysicalMemoryMap(PAL_HANDLE channel, int entries, PAL_PTR* addrs, PAL_NUM* sizes,
-                         PAL_FLG* prots) {
-    return -PAL_ERROR_NOTIMPLEMENTED;
-}
-
-#pragma GCC diagnostic pop

+ 0 - 2
Pal/src/host/Linux-SGX/db_streams.c

@@ -134,7 +134,6 @@ int handle_serialize(PAL_HANDLE handle, void** data) {
                 dsz2 = addr_size(handle->sock.conn);
             }
             break;
-        case pal_type_gipc:
         case pal_type_process:
         case pal_type_eventfd:
             break;
@@ -233,7 +232,6 @@ int handle_deserialize(PAL_HANDLE* handle, const void* data, int size) {
             }
             break;
         }
-        case pal_type_gipc:
         case pal_type_process:
         case pal_type_eventfd:
             hdl = malloc_copy(hdl_data, hdlsz);

+ 0 - 4
Pal/src/host/Linux-SGX/pal_host.h

@@ -134,10 +134,6 @@ typedef struct pal_handle
             PAL_BOL endofstream;
         } dir;
 
-        struct {
-            PAL_IDX fd;
-        } gipc;
-
         struct {
             PAL_IDX fd;
             PAL_PTR bind;

+ 1 - 2
Pal/src/host/Linux/Makefile

@@ -2,7 +2,6 @@ include ../../../../Makefile.configs
 include Makefile.am
 
 CFLAGS	+= -I. -Iinclude -I../.. -I../../../include -I../../../lib \
-	   -I../../../ipc/linux \
 	   -I../../../linux-kernel/graphene
 ASFLAGS += -I. -Iinclude -I../.. -I../../../include
 
@@ -16,7 +15,7 @@ defs	= -DIN_PAL -DPAL_DIR=$(PAL_DIR) -DRUNTIME_DIR=$(RUNTIME_DIR)
 CFLAGS += $(defs)
 ASFLAGS += $(defs)
 objs	= $(addprefix db_,files devices pipes eventfd sockets streams memory threading \
-	    mutex events process object main rtld misc ipc \
+	    mutex events process object main rtld misc \
 	    exception) clone-x86_64
 graphene_lib = .lib/graphene-lib.a
 

+ 0 - 176
Pal/src/host/Linux/db_ipc.c

@@ -1,176 +0,0 @@
-/* Copyright (C) 2014 Stony Brook University
-   This file is part of Graphene Library OS.
-
-   Graphene Library OS is free software: you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public License
-   as published by the Free Software Foundation, either version 3 of the
-   License, or (at your option) any later version.
-
-   Graphene Library OS is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/*
- * db_ipc.c
- *
- * This file contains APIs for physical memory bulk copy across processes.
- */
-
-#include "pal_defs.h"
-#include "pal_linux_defs.h"
-#include "pal.h"
-#include "pal_internal.h"
-#include "pal_linux.h"
-#include "pal_error.h"
-#include "pal_debug.h"
-#include "pal_security.h"
-#include "graphene-ipc.h"
-#include "api.h"
-
-int gipc_open (PAL_HANDLE * handle, const char * type, const char * uri,
-               int access, int share, int create, int options)
-{
-    if (strcmp_static(type, "gipc"))
-        return -PAL_ERROR_INVAL;
-
-    if (!WITHIN_MASK(access, PAL_ACCESS_MASK) ||
-        !WITHIN_MASK(share, PAL_SHARE_MASK) ||
-        !WITHIN_MASK(create, PAL_CREATE_MASK) ||
-        !WITHIN_MASK(options, PAL_OPTION_MASK))
-        return -PAL_ERROR_INVAL;
-
-    int64_t token;
-    int rv;
-
-    int fd = INLINE_SYSCALL(open, 3, GIPC_FILE, O_RDONLY|O_CLOEXEC, 0);
-
-    if (IS_ERR(fd))
-        return -PAL_ERROR_DENIED;
-
-    token = atoi(uri);
-
-    rv = INLINE_SYSCALL(ioctl, 3, fd, GIPC_JOIN, token);
-
-    if (rv < 0) {
-        INLINE_SYSCALL(close, 1, fd);
-        return -PAL_ERROR_DENIED;
-    }
-
-    PAL_HANDLE hdl = malloc(HANDLE_SIZE(gipc));
-    SET_HANDLE_TYPE(hdl, gipc);
-    hdl->gipc.fd = fd;
-    hdl->gipc.token = token;
-    *handle = hdl;
-    return 0;
-}
-
-int gipc_close (PAL_HANDLE handle)
-{
-    int ret = INLINE_SYSCALL(close, 1, handle->gipc.fd);
-
-    return (IS_ERR(ret)) ? -PAL_ERROR_BADHANDLE : 0;
-}
-
-const char * gipc_getrealpath (PAL_HANDLE handle)
-{
-    __UNUSED(handle);
-
-    return GIPC_FILE;
-}
-
-struct handle_ops gipc_ops = {
-        .getrealpath        = &gipc_getrealpath,
-        .open               = &gipc_open,
-        .close              = &gipc_close,
-    };
-
-int _DkCreatePhysicalMemoryChannel (PAL_HANDLE * handle, uint64_t * key)
-{
-    int token = 0;
-    int fd = INLINE_SYSCALL(open, 3, GIPC_FILE, O_RDONLY|O_CLOEXEC, 0);
-
-    if (IS_ERR(fd))
-        goto err;
-
-
-    PAL_HANDLE hdl = malloc(HANDLE_SIZE(gipc));
-    SET_HANDLE_TYPE(hdl, gipc);
-    hdl->gipc.fd = fd;
-
-    // ioctl to create a new queue
-    token = INLINE_SYSCALL(ioctl, 3, fd, GIPC_CREATE, 0);
-    if (token < 0)
-        goto err_fd;
-
-    *handle = hdl;
-    *key = token;
-    return 0;
-
- err_fd:
-    INLINE_SYSCALL(close, 1, fd);
-
- err:
-    return -PAL_ERROR_DENIED;
-}
-
-int _DkPhysicalMemoryCommit (PAL_HANDLE channel, int entries,
-                             PAL_PTR * addrs, PAL_NUM * sizes)
-{
-    int fd = channel->gipc.fd;
-    struct gipc_send gs;
-
-    gs.addr = __alloca(sizeof(unsigned long) * entries);
-    gs.len  = __alloca(sizeof(unsigned long) * entries);
-
-    for (int i = 0 ; i < entries ; i++) {
-        if (!addrs[i] || !sizes[i] || !IS_ALLOC_ALIGNED_PTR(addrs[i]) ||
-            !IS_ALLOC_ALIGNED(sizes[i]))
-            return -PAL_ERROR_INVAL;
-
-        gs.addr[i] = (unsigned long) addrs[i];
-        gs.len[i]  = sizes[i];
-    }
-
-    gs.entries = entries;
-    int ret = INLINE_SYSCALL(ioctl, 3, fd, GIPC_SEND, &gs);
-
-    if (IS_ERR(ret))
-        return -PAL_ERROR_DENIED;
-
-    return ret;
-}
-
-int _DkPhysicalMemoryMap (PAL_HANDLE channel, int entries,
-                          PAL_PTR * addrs, PAL_NUM * sizes, PAL_FLG * prots)
-{
-    int fd = channel->gipc.fd;
-    struct gipc_recv gr;
-
-    gr.addr = __alloca(sizeof(unsigned long) * entries);
-    gr.len  = __alloca(sizeof(unsigned long) * entries);
-    gr.prot = __alloca(sizeof(unsigned long) * entries);
-
-    for (int i = 0 ; i < entries ; i++) {
-        if (!sizes[i] || !IS_ALLOC_ALIGNED_PTR(addrs[i]) || !IS_ALLOC_ALIGNED(sizes[i]))
-            return -PAL_ERROR_INVAL;
-
-        gr.addr[i] = (unsigned long) addrs[i];
-        gr.len[i]  = sizes[i];
-        gr.prot[i] = HOST_PROT(prots[i]);
-    }
-
-    gr.entries = entries;
-    int ret = INLINE_SYSCALL(ioctl, 3, fd, GIPC_RECV, &gr);
-
-    if (IS_ERR(ret))
-        return -PAL_ERROR_DENIED;
-
-    for (int i = 0 ; i < entries ; i++)
-        addrs[i] = (PAL_PTR) gr.addr[i];
-
-    return ret;
-}

+ 0 - 1
Pal/src/host/Linux/db_process.c

@@ -34,7 +34,6 @@
 #include "pal_error.h"
 #include "pal_security.h"
 #include "pal_rtld.h"
-#include "graphene-ipc.h"
 #include "api.h"
 
 #include <linux/sched.h>

+ 0 - 2
Pal/src/host/Linux/db_streams.c

@@ -147,7 +147,6 @@ int handle_serialize(PAL_HANDLE handle, void** data) {
                 dsz2 = addr_size(handle->sock.conn);
             }
             break;
-        case pal_type_gipc:
         case pal_type_process:
         case pal_type_eventfd:
             break;
@@ -245,7 +244,6 @@ int handle_deserialize(PAL_HANDLE* handle, const void* data, int size) {
             }
             break;
         }
-        case pal_type_gipc:
         case pal_type_process:
         case pal_type_eventfd:
             hdl = malloc_copy(hdl_data, hdlsz);

+ 0 - 5
Pal/src/host/Linux/pal_host.h

@@ -118,11 +118,6 @@ typedef struct pal_handle
             PAL_BOL endofstream;
         } dir;
 
-        struct {
-            PAL_IDX fd;
-            PAL_NUM token;
-        } gipc;
-
         struct {
             PAL_IDX fd;
             PAL_PTR bind;

+ 1 - 1
Pal/src/host/Skeleton/Makefile

@@ -10,7 +10,7 @@ defs	= -DIN_PAL
 CFLAGS += $(defs)
 ASFLAGS += $(defs)
 objs	= $(addprefix db_,files devices pipes eventfd sockets streams memory threading \
-	    mutex events process object main rtld misc ipc exception)
+	    mutex events process object main rtld misc exception)
 headers	= $(wildcard *.h) $(wildcard ../../*.h) $(wildcard ../../../lib/*.h)
 
 .PHONY: all

+ 0 - 59
Pal/src/host/Skeleton/db_ipc.c

@@ -1,59 +0,0 @@
-/* Copyright (C) 2014 Stony Brook University
-   This file is part of Graphene Library OS.
-
-   Graphene Library OS is free software: you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public License
-   as published by the Free Software Foundation, either version 3 of the
-   License, or (at your option) any later version.
-
-   Graphene Library OS is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/*
- * db_ipc.c
- *
- * This file contains APIs for physical memory bulk copy across processes.
- */
-
-#include "api.h"
-#include "pal.h"
-#include "pal_defs.h"
-#include "pal_error.h"
-#include "pal_internal.h"
-
-int gipc_open(PAL_HANDLE* handle, const char* type, const char* uri, int access, int share,
-              int create, int options) {
-    return -PAL_ERROR_NOTIMPLEMENTED;
-}
-
-int gipc_close(PAL_HANDLE handle) {
-    return -PAL_ERROR_NOTIMPLEMENTED;
-}
-
-const char* gipc_getrealpath(PAL_HANDLE handle) {
-    return NULL;
-}
-
-struct handle_ops gipc_ops = {
-    .getrealpath = &gipc_getrealpath,
-    .open        = &gipc_open,
-    .close       = &gipc_close,
-};
-
-int _DkCreatePhysicalMemoryChannel(PAL_HANDLE* handle, unsigned long* key) {
-    return -PAL_ERROR_NOTIMPLEMENTED;
-}
-
-int _DkPhysicalMemoryCommit(PAL_HANDLE channel, int entries, PAL_PTR* addrs, PAL_NUM* sizes) {
-    return -PAL_ERROR_NOTIMPLEMENTED;
-}
-
-int _DkPhysicalMemoryMap(PAL_HANDLE channel, int entries, PAL_PTR* addrs, PAL_NUM* sizes,
-                         PAL_FLG* prots) {
-    return -PAL_ERROR_NOTIMPLEMENTED;
-}

+ 0 - 4
Pal/src/host/Skeleton/pal_host.h

@@ -77,10 +77,6 @@ typedef struct pal_handle
             PAL_IDX fd;
         } dir;
 
-        struct {
-            PAL_IDX fd;
-        } gipc;
-
         struct {
             PAL_IDX fd;
         } sock;

+ 0 - 3
Pal/src/pal-symbols

@@ -37,9 +37,6 @@ DkCpuIdRetrieve
 DkObjectClose
 DkSetExceptionHandler
 DkExceptionReturn
-DkCreatePhysicalMemoryChannel
-DkPhysicalMemoryCommit
-DkPhysicalMemoryMap
 DkSegmentRegister
 DkStreamChangeName
 DkStreamAttributesSetByHandle

+ 0 - 11
Pal/src/pal.h

@@ -127,7 +127,6 @@ enum {
     pal_type_thread,
     pal_type_mutex,
     pal_type_event,
-    pal_type_gipc,
     pal_type_eventfd,
     PAL_HANDLE_TYPE_BOUND,
 };
@@ -524,16 +523,6 @@ DkInstructionCacheFlush (PAL_PTR addr, PAL_NUM size);
 
 PAL_PTR DkSegmentRegister (PAL_FLG reg, PAL_PTR addr);
 
-PAL_HANDLE
-DkCreatePhysicalMemoryChannel (PAL_NUM * key);
-
-PAL_NUM
-DkPhysicalMemoryCommit (PAL_HANDLE channel, PAL_NUM entries, PAL_PTR * addrs, PAL_NUM * sizes);
-
-PAL_NUM
-DkPhysicalMemoryMap (PAL_HANDLE channel, PAL_NUM entries, PAL_PTR * addrs,
-                     PAL_NUM * sizes, PAL_FLG * prots);
-
 PAL_NUM DkMemoryAvailableQuota (void);
 
 #define PAL_CPUID_WORD_EAX  0

+ 0 - 5
Pal/src/pal_internal.h

@@ -346,11 +346,6 @@ size_t _DkRandomBitsRead (void * buffer, size_t size);
 int _DkSegmentRegisterSet (int reg, const void * addr);
 int _DkSegmentRegisterGet (int reg, void ** addr);
 int _DkInstructionCacheFlush (const void * addr, int size);
-int _DkCreatePhysicalMemoryChannel (PAL_HANDLE * handle, uint64_t * key);
-int _DkPhysicalMemoryCommit (PAL_HANDLE channel, int entries,
-                             PAL_PTR * addrs, PAL_NUM * sizes);
-int _DkPhysicalMemoryMap (PAL_HANDLE channel, int entries,
-                          PAL_PTR * addrs, PAL_NUM * sizes, PAL_FLG * prots);
 int _DkCpuIdRetrieve (unsigned int leaf, unsigned int subleaf, unsigned int values[4]);
 
 #define INIT_FAIL(exitcode, reason)                                     \

+ 0 - 90
Pal/test/Ipc.c

@@ -1,90 +0,0 @@
-#include "api.h"
-#include "pal.h"
-#include "pal_debug.h"
-
-int main(int argc, char** argv) {
-    char* name = "parent";
-
-    if (argc == 1) {
-        const char* args[3];
-        char uri[20];
-
-        args[0] = "Ipc";
-        args[1] = uri;
-        args[2] = NULL;
-
-        void* mem = (void*)DkVirtualMemoryAlloc(NULL, pal_control.alloc_align, 0,
-                                                PAL_PROT_READ | PAL_PROT_WRITE);
-
-        pal_printf("mem = %p\n", mem);
-        snprintf((char*)mem, 4096, "Hello World");
-
-        PAL_NUM key     = 0;
-        PAL_HANDLE chdl = DkCreatePhysicalMemoryChannel(&key);
-
-        if (chdl == NULL) {
-            pal_printf(
-                "(parent) DkCreatePhysicalMemoryChannel Failed, Make sure gipc module is loaded\n");
-            return 0;
-        }
-
-        snprintf(uri, 20, "gipc:%ld", key);
-
-        PAL_HANDLE phdl = DkProcessCreate("file:Ipc", args);
-
-        if (phdl == NULL)
-            pal_printf("ProcessCreate Failed\n");
-
-        PAL_PTR addr = (PAL_PTR)mem;
-        PAL_NUM size = pal_control.alloc_align;
-        DkPhysicalMemoryCommit(chdl, 1, &addr, &size);
-        DkObjectClose(chdl);
-
-        char x;
-        int rv = DkStreamRead(phdl, 0, 1, &x, NULL, 0);
-        if (rv != 1) {
-            pal_printf("Failed to get exit signal from child, %d\n", rv);
-            return -1;
-        }
-    } else {
-        name = argv[1];
-
-        PAL_HANDLE chdl = DkStreamOpen(name, 0, 0, 0, 0);
-
-        if (chdl == NULL) {
-            pal_printf("(child) StreamOpen Failed\n");
-            return 0;
-        }
-
-        PAL_PTR addr = NULL;
-        PAL_NUM size = pal_control.alloc_align;
-        PAL_FLG prot = PAL_PROT_READ | PAL_PROT_WRITE;
-
-        int len = DkPhysicalMemoryMap(chdl, 1, &addr, &size, &prot);
-
-        if (!len) {
-            pal_printf("PhysicalMemoryMap Failed\n");
-            return 0;
-        }
-
-        pal_printf("(child) mem = %p\n", addr);
-        pal_printf("(child) receive string: %s\n", (char*)addr);
-
-        DkStreamDelete(chdl, 0);
-        DkObjectClose(chdl);
-
-        // Write a byte to the parent
-        int rv = DkStreamWrite(pal_control.parent_process, 0, 1, "z", NULL);
-        if (rv < 0) {
-            pal_printf("Failed to write an exit byte\n");
-            return -1;
-        }
-    }
-
-    pal_printf("Enter Main Thread (%s)\n", name);
-
-    DkThreadDelayExecution(3000);
-
-    pal_printf("Leave Main Thread\n");
-    return 0;
-}

+ 1 - 1
Pal/test/Makefile

@@ -11,7 +11,7 @@ include ../../Makefile.rules
 include ../src/Makefile.Test
 
 executables = HelloWorld File Failure Thread Fork Event Process Exception \
-	      Memory Pipe Tcp Udp Yield Broadcast Ipc Server Wait HandleSend \
+	      Memory Pipe Tcp Udp Yield Broadcast Server Wait HandleSend \
 	      Select Segment Sleep Cpuid Pie
 manifests = manifest