Merge large page support code.
authorSimon Gerber <simon.gerber@inf.ethz.ch>
Mon, 4 May 2015 09:31:03 +0000 (11:31 +0200)
committerSimon Gerber <simon.gerber@inf.ethz.ch>
Mon, 4 May 2015 09:31:03 +0000 (11:31 +0200)
This code was originally written by Andreas Dillier as a deliverable for his
Bachelor thesis at ETH Zurich in 2013. Simon Gerber then fixed and extended
the implementation of large page support while employed by HP Labs in summer
2014.
The files that contain code written while Simon was employed by HP Labs have
updated copyright notices and the relevant commits are marked with
"Signed-off-by: Simon Gerber <simon.gerber@hp.com>" (as is this merge).

Signed-off-by: Simon Gerber <simon.gerber@hp.com>
Signed-off-by: Simon Gerber <simon.gerber@inf.ethz.ch>

18 files changed:
1  2 
errors/errno.fugu
hake/Config.hs.template
hake/symbolic_targets.mk
include/barrelfish/vregion.h
include/barrelfish/vspace_mmu_aware.h
kernel/arch/armv7/paging.c
kernel/arch/x86_32/page_mappings_arch.c
kernel/arch/x86_32/startup_arch.c
kernel/arch/x86_64/page_mappings_arch.c
kernel/include/target/x86_64/paging_kernel_target.h
kernel/paging_generic.c
lib/barrelfish/Hakefile
lib/barrelfish/arch/arm/pmap_arch.c
lib/barrelfish/init.c
lib/barrelfish/morecore.c
lib/barrelfish/target/x86_64/pmap_target.c
lib/barrelfish/vspace/memobj_anon.c
lib/barrelfish/vspace/utils.c

@@@ -1,6 -1,6 +1,7 @@@
 +
  /*
   * Copyright (c) 2009, 2010, 2011, 2012, ETH Zurich.
+  * Copyright (c) 2014, HP Labs.
   * All rights reserved.
   *
   * This file is distributed under the terms in the attached LICENSE file.
@@@ -1,5 -1,6 +1,6 @@@
  --------------------------------------------------------------------------
 --- Copyright (c) 2007-2010, 2012, ETH Zurich.
 +-- Copyright (c) 2007-2010, 2012, 2013, ETH Zurich.
+ -- Copyright (c) 2014, HP Labs.
  -- All rights reserved.
  --
  -- This file is distributed under the terms in the attached LICENSE file.
@@@ -220,35 -127,51 +220,36 @@@ MODULES_x86_64= 
        sbin/pci \
        sbin/acpi \
        sbin/kaluga \
 -      sbin/placement_bench \
 -      sbin/phases_bench \
 -      sbin/phases_scale_bench \
 -      sbin/phoenix_kmeans \
 -      $(BIN_RCCE_BT) \
 -      $(BIN_RCCE_LU) \
 -      sbin/rcce_pingpong \
        sbin/serial \
 -      sbin/shared_mem_clock_bench \
 +      sbin/angler \
 +      sbin/sshd \
 +      sbin/lshw \
        sbin/sif \
        sbin/slideshow \
 -      sbin/spantest \
 -      sbin/testconcurrent \
 -      sbin/thc_v_flounder_empty \
 -      sbin/thcidctest \
 -      sbin/thcminitest \
 -      sbin/thctest \
 -      sbin/tsc_bench \
 -      sbin/tweedtest \
 -      sbin/udp_throughput \
 -      sbin/ump_latency \
 -      sbin/ump_exchange \
 -      sbin/ump_latency_cache \
 -      sbin/ump_throughput \
 -      sbin/ump_send \
 -      sbin/ump_receive \
        sbin/vbe \
        sbin/vmkitmon \
++      sbin/vnode_map_test \
        sbin/webserver \
 -      sbin/tlstest \
 -      sbin/timer_test \
 -      sbin/net_openport_test \
 -      sbin/perfmontest \
        sbin/routing_setup \
 -      sbin/multihoptest \
 -      sbin/multihop_latency_bench \
 -      sbin/cryptotest \
 -      $(BIN_CONSENSUS) \
        sbin/bcached \
 -      sbin/testdesc \
 -      sbin/testdesc-child \
 -      sbin/angler \
 -      sbin/sshd \
 -      sbin/lshw \
 -      sbin/vnode_map_test \
 +      sbin/xeon_phi_mgr \
 +      sbin/xeon_phi \
 +      sbin/dma_mgr \
 +      sbin/ioat_dma \
 +      sbin/virtio_blk_host \
 +      sbin/virtio_blk \
 +      sbin/block_server \
 +      sbin/block_server_client \
 +      sbin/bs_user \
 +      sbin/bulk_shm \
 +      sbin/corectrl
 +
 +MODULES_k1om= \
 +      sbin/weever \
 +      sbin/cpu \
 +      sbin/xeon_phi \
 +      sbin/corectrl \
 +      xeon_phi_multiboot \
  
  # the following are broken in the newidc system
  MODULES_x86_64_broken= \
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -434,12 -481,11 +482,11 @@@ errval_t page_mappings_modify_flags(str
  void paging_dump_tables(struct dcb *dispatcher)
  {
      lvaddr_t root_pt = local_phys_to_mem(dispatcher->vspace);
 -    union x86_64_ptable_entry *pt;
 -    // loop over pdpts (ignore kernel space)
 -    int first_kernel_pml4e = X86_64_PML4_BASE(X86_64_MEMORY_OFFSET);
 -    for (int pdpt_index = 0; pdpt_index < first_kernel_pml4e; pdpt_index++) {
  
 +    // loop over pdpts
++    union x86_64_ptable_entry *pt;
 +    size_t kernel_pml4e = X86_64_PML4_BASE(X86_64_MEMORY_OFFSET);
-     printk(LOG_NOTE, "1st kernel pml4e: %zu\n", kernel_pml4e);
 +    for (int pdpt_index = 0; pdpt_index < kernel_pml4e; pdpt_index++) {
          union x86_64_pdir_entry *pdpt = (union x86_64_pdir_entry *)root_pt + pdpt_index;
          if (!pdpt->raw) { continue; }
          genpaddr_t pdpt_gp = pdpt->d.base_addr << BASE_PAGE_BITS;
@@@ -108,9 -83,27 +108,27 @@@ union x86_64_ptable_entry 
          uint64_t        global          :1;
          uint64_t        available       :3;
          uint64_t        attr_index      :1;
+         uint64_t        reserved        :17;
+         uint64_t        base_addr       :10;
+         uint64_t        reserved2       :12;
+         uint64_t        available2      :11;
+         uint64_t        execute_disable :1;
+     } huge;
+     struct {
+         uint64_t        present         :1;
+         uint64_t        read_write      :1;
+         uint64_t        user_supervisor :1;
+         uint64_t        write_through   :1;
+         uint64_t        cache_disabled  :1;
+         uint64_t        accessed        :1;
+         uint64_t        dirty           :1;
+         uint64_t        always1         :1;
+         uint64_t        global          :1;
+         uint64_t        available       :3;
+         uint64_t        attr_index      :1;
          uint64_t        reserved        :8;
 -        uint64_t        base_addr       :19;
 -        uint64_t        reserved2       :12;
 +        uint64_t        base_addr       :X86_64_PAGING_LARGE_BASE_BITS;
 +        uint64_t        reserved2       :X86_64_PAGING_RESERVED_BITS;
          uint64_t        available2      :11;
          uint64_t        execute_disable :1;
      } large;
Simple merge
                                              ("monitor_blocking", ["lmp", "rpcclient"]),
                                                ("mem", ["rpcclient"]),
                                                ("octopus", ["rpcclient"]),
 -                                              ("spawn", ["rpcclient"])],
 +                                              ("spawn", ["rpcclient"]),
 +                                              ("arrakis", ["rpcclient"])],
+                     addCFlags = [ "-DMORECORE_PAGESIZE="++(morecore_pagesize arch) ],
                      addIncludes = [ "include", "include" ./. arch_dir ],
                      addGeneratedDependencies = [ "/include/asmoffsets.h" ]
                    }
 + ) | arch <- allArchitectures ] ++
 +[(let arch_dir = "arch" ./. archFamily arch
 +      common_srcs = [ "capabilities.c", "init.c", "dispatch.c", "threads.c",
 +                      "thread_sync.c", "slab.c", "domain.c", "idc.c",
 +                      "waitset.c", "event_queue.c", "event_mutex.c",
 +                      "idc_export.c", "nameservice_client.c", "msgbuf.c",
 +                      "monitor_client.c", "flounder_support.c", "flounder_glue_binding.c",
 +                      "morecore.c", "debug.c", "heap.c", "ram_alloc.c",
 +                      "terminal.c", "spawn_client.c", "vspace/vspace.c",
 +                      "vspace/vregion.c", "vspace/memobj_one_frame.c",
 +                      "vspace/memobj_one_frame_lazy.c",
 +                      "vspace/utils.c",
 +                      "vspace/memobj_one_frame_one_map.c", "vspace/mmu_aware.c",
 +                      "slot_alloc/single_slot_alloc.c", "slot_alloc/multi_slot_alloc.c",
 +                      "slot_alloc/slot_alloc.c", "slot_alloc/range_slot_alloc.c",
 +                      "bulk_transfer.c", "trace.c", "resource_ctrl.c", "coreset.c",
 +                      "inthandler.c", "deferred.c"
 +                    ]
 +
 +      idc_srcs = concat $ map getsrcs $ optInterconnectDrivers $ options arch
 +          where
 +            getsrcs "lmp" = [ "lmp_chan.c", "lmp_endpoints.c" ]
 +            getsrcs "ump" = [ "ump_chan.c", "ump_endpoint.c" ]
 +            getsrcs "multihop" = [ "multihop_chan.c" ]
 +            getsrcs _ = []
 +
++      -- configure default morecore pagesize based on Config.hs
++      morecore_pagesize "x86_64" = case Config.morecore_pagesize of
++          "large" -> "LARGE_PAGE_SIZE"
++          "huge"  -> "HUGE_PAGE_SIZE"
++          _       -> "BASE_PAGE_SIZE"
++      morecore_pagesize "x86_32" = case Config.morecore_pagesize of
++          "large" -> "LARGE_PAGE_SIZE"
++          _       -> "BASE_PAGE_SIZE"
++      morecore_pagesize _ = "BASE_PAGE_SIZE"
++
++
 +      -- sources specific to the architecture family
 +      archfam_srcs "x86_32"  = [ "arch/x86_32/debug.c" ,
 +                              "arch/x86_32/dispatch.c" , "arch/x86_32/syscalls.c" ,
 +                              "arch/x86_32/sys_debug.c", "target/x86_32/pmap_target.c",
 +                              "target/x86/pmap_x86.c",
 +                              "vspace/arch/x86_32/layout.c" , "vspace/memobj_pinned.c" ,
 +                              "vspace/pinned.c", "vspace/memobj_anon.c",
 +                              "arch/x86/perfmon.c", "arch/x86/tls.c"]
 +      archfam_srcs "x86_64"  = [ "arch/x86_64/debug.c", "arch/x86_64/dispatch.c" ,
 +                                 "arch/x86_64/syscalls.c", "arch/x86_64/sys_debug.c",
 +                                 "arch/x86_64/ldt.c",
 +                                 "target/x86_64/pmap_target.c", "target/x86/pmap_x86.c",
 +                                 "vspace/arch/x86_64/layout.c",
 +                                 "vspace/memobj_pinned.c", "vspace/pinned.c", "vspace/memobj_anon.c",
 +                                 "arch/x86/perfmon.c", "arch/x86/tls.c"]
 +      archfam_srcs "arm"     = [ "arch/arm/debug.c", "arch/arm/dispatch.c",
 +                                 "arch/arm/pmap_arch.c", "arch/arm/sys_debug.c",
 +                                 "arch/arm/syscalls.c", "vspace/memobj_pinned.c" ,
 +                                 "vspace/pinned.c", "vspace/memobj_anon.c",
 +                                 "vspace/arch/arm/layout.c" ]
 +      archfam_srcs _         = []
 +
 +      -- sources specific to the architecture
 +      arch_srcs "scc" = [ "arch/x86/ipi_notify.c" ]
 +      arch_srcs "x86_32" = [ "arch/x86/ipi_notify.c" ]
 +      arch_srcs "x86_64" = [ "arch/x86/ipi_notify.c" ]
 +      arch_srcs _     = []
 +
 +      arch_assembly "x86_32"  = [ "arch/x86_32/entry.S" ]
 +      arch_assembly "x86_64"  = [ "arch/x86_64/entry.S" ]
 +      arch_assembly "arm"     = [ "arch/arm/entry.S", "arch/arm/syscall.S" ]
 +      arch_assembly _         = []
 +
 +  in
 +    build library { target = "arrakis",
 +                    architectures = [arch],
 +                    cFiles = arch_srcs arch ++ archfam_srcs (archFamily arch)
 +                             ++ common_srcs ++ idc_srcs,
 +                    assemblyFiles = arch_assembly (archFamily arch),
-                     addCFlags = [ "-DARRAKIS" ],
++                    addCFlags = [ "-DARRAKIS", "-DMORECORE_PAGESIZE="++(morecore_pagesize arch) ],
 +                    flounderBindings = [ "mem", "octopus", "interdisp", "spawn", "arrakis",
 +                                         "terminal" ],
 +                    -- only makes sense to compile monitor binding for lmp
 +                    flounderTHCStubs = [ "octopus" ],
 +                    flounderExtraBindings = [ ("monitor", ["lmp"]),
 +                                            ("monitor_blocking", ["lmp", "rpcclient"]),
 +                                              ("mem", ["rpcclient"]),
 +                                              ("octopus", ["rpcclient"]),
 +                                              ("spawn", ["rpcclient"]),
 +                                              ("arrakis", ["rpcclient"])],
 +                    addIncludes = [ "include", "include" ./. arch_dir ],
 +                    addGeneratedDependencies = [ "/include/asmoffsets.h" ]
 +                  }
   ) | arch <- allArchitectures ]
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -133,10 -135,9 +134,10 @@@ errval_t vspace_map_anon_attr(void **re
                                size_t *retsize, vregion_flags_t flags)
  {
      errval_t err;
 +
      struct memobj_anon *memobj = NULL;
      struct vregion *vregion = NULL;
-     
      // Allocate space
      memobj = malloc(sizeof(struct memobj_anon));
      assert(memobj != NULL);