Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

64-bit support.

  • Loading branch information...
commit bcdb148b2c6185794a4a1ee297a55ff63242a096 1 parent 6d3feb5
@acw acw authored
Showing with 318 additions and 156 deletions.
  1. +26 −0 .gitignore
  2. +6 −1 configure.ac
  3. +6 −5 ghc-xen-sparse/rts/xen/GHCShims_memory.c
  4. +3 −2 ghc-xen-sparse/rts/xen/GHCShims_threads.c
  5. +2 −1  ghc-xen-sparse/rts/xen/GHCShims_time.c
  6. +25 −3 ghc-xen-sparse/rts/xen/events.c
  7. +1 −1  ghc-xen-sparse/rts/xen/include/arch.h
  8. +5 −0 ghc-xen-sparse/rts/xen/include/machine/limits.h
  9. +2 −1  ghc-xen-sparse/rts/xen/include/mm.h
  10. +1 −2  ghc-xen-sparse/rts/xen/libc/stdlib.c
  11. +14 −10 ghc-xen-sparse/rts/xen/mm.c
  12. +2 −3 ghc-xen-sparse/rts/xen/mm/core_32p.c
  13. +48 −52 ghc-xen-sparse/rts/xen/mm/core_64.c
  14. +1 −1  ghc-xen-sparse/rts/xen/mm/core_constants.h
  15. +1 −21 ghc-xen-sparse/rts/xen/mm/core_mb.c
  16. +1 −1  libraries/HALVMCore/HALVMCore.buildinfo.in
  17. +2 −2 libraries/HALVMCore/HALVMCore.cabal
  18. +66 −22 libraries/HALVMCore/Hypervisor/Memory.hs
  19. +9 −9 libraries/HALVMCore/Hypervisor/Port.hs
  20. +2 −0  libraries/XenDevice/XenDevice.buildinfo.in
  21. +1 −1  libraries/libDomainBuilder/libDomainBuilder.buildinfo.in
  22. +5 −5 mk/common.mk.in
  23. +21 −11 mk/halvm.mk
  24. +1 −1  mk/infrastructure.mk
  25. +1 −1  static-bits/examples/Misc/GetIdTest/GetId.config
  26. +33 −0 static-bits/lib/ghc_boot_platform.i386.h
  27. +33 −0 static-bits/lib/ghc_boot_platform.x86_64.h
View
26 .gitignore
@@ -0,0 +1,26 @@
+*.o
+*.a
+autom4te.cache/
+config.log
+config.status
+configure
+dist/
+libIVC/Makefile
+libraries/BitFiddler/dist/
+libraries/BoundedChan-1.0.0.0/
+libraries/HALVMCore/HALVMCore.buildinfo
+libraries/HALVMCore/dist/
+libraries/RealDevice/dist/
+libraries/RendezvousLib/dist/
+libraries/XenDevice/XenDevice.buildinfo
+libraries/XenDevice/dist/
+libraries/cereal-0.3.0.0/
+libraries/communication/dist/
+libraries/libDomainBuilder/libDomainBuilder.buildinfo
+libraries/log4h/dist/
+libraries/stm-2.1.2.2/
+mk/common.mk
+platform_ghc/
+tarballs/
+xen-ghc/
+
View
7 configure.ac
@@ -241,12 +241,15 @@ AC_CHECK_DECL(xc_gnttab_open,
case "$memory_model" in
"32") AC_SUBST(ARCH_OPTION, "-DCONFIG_X86_32")
+ AC_SUBST(ARCH_FLAGS, "")
MEMMODEL_STR="32-bit" ;
ARCH=i386 ;;
"32p") AC_SUBST(ARCH_OPTION, "-DCONFIG_X86_PAE")
+ AC_SUBST(ARCH_FLAGS, "")
MEMMODEL_STR="PAE (36-bit physical / 32-bit virtual)" ;
ARCH=i386 ;;
"64") AC_SUBST(ARCH_OPTION, "-DCONFIG_X86_64")
+ AC_SUBST(ARCH_FLAGS, "-fomit-frame-pointer -fno-asynchronous-unwind-tables -fno-builtin -mno-red-zone")
MEMMODEL_STR="64-bit" ;
ARCH=x86_64 ;;
*) LOG_FAILURE("Unknown memory model (internal error?)") ;;
@@ -283,6 +286,8 @@ else
libraries/HALVMCore/HALVMCore.buildinfo
libraries/XenDevice/XenDevice.buildinfo
libraries/libDomainBuilder/libDomainBuilder.buildinfo
- libIVC/Makefile])
+ libraries/communication/communication.buildinfo
+ libIVC/Makefile
+ libm/Makefile])
AC_OUTPUT
fi
View
11 ghc-xen-sparse/rts/xen/GHCShims_memory.c
@@ -44,17 +44,18 @@ void osMemInit(void)
void *osGetMBlocks(nat n)
{
void *start_attempt = next_request;
- uint32_t size = n * MBLOCK_SIZE;
+ size_t size = n * MBLOCK_SIZE;
- assert( ((uint32_t)start_attempt % MBLOCK_SIZE) == 0);
+ assert( ((uintptr_t)start_attempt % MBLOCK_SIZE) == 0);
do {
if( claim_vspace(next_request, size) ) {
void *retval = next_request;
- back_pages(retval, retval + size, PROT_READ | PROT_WRITE );
- next_request += size;
+ back_pages(retval, (void*)((unsigned long)retval + size),
+ PROT_READ | PROT_WRITE );
+ next_request = (void*)((unsigned long)next_request + size);
return retval;
}
- next_request += MBLOCK_SIZE;
+ next_request = (void*)((unsigned long)next_request + MBLOCK_SIZE);
} while(next_request != start_attempt);
/* EEEK! We couldn't find memory to allocate! */
View
5 ghc-xen-sparse/rts/xen/GHCShims_threads.c
@@ -11,6 +11,7 @@
#include "Schedule.h"
#include "errno.h"
#include "time.h"
+#include "limits.h"
extern lnat getourtimeofday(void);
extern void startSignalHandlers(Capability *cap);
@@ -27,7 +28,7 @@ static rtsBool wakeUpSleepingThreads(lnat ticks)
rtsBool flag = rtsFalse;
while(sleeping_queue != END_TSO_QUEUE &&
- (int)(ticks - sleeping_queue->block_info.target) > 0)
+ (long)(ticks - sleeping_queue->block_info.target) > 0)
{
tso = sleeping_queue;
sleeping_queue = tso->_link;
@@ -56,7 +57,7 @@ void awaitEvent(rtsBool wait)
min = sleeping_queue->block_info.target - ticks; /* in ticks */
min *= RtsFlags.MiscFlags.tickInterval; /* in milliseconds */
} else {
- min = 0x7ffffff;
+ min = LONG_MAX;
}
block_domain(min);
}
View
3  ghc-xen-sparse/rts/xen/GHCShims_time.c
@@ -10,6 +10,7 @@
#include "GetTime.h"
#include "Ticker.h"
#include "time.h"
+#include "limits.h"
// Below to remove warnings.
lnat getourtimeofday(void);
@@ -76,7 +77,7 @@ lnat getourtimeofday(void)
work += (u64)tv.tv_usec / (interval * 1000);
//assert(last_time <= work);
last_time = work;
- work &= 0x7FFFFFFF;
+ work &= LONG_MAX;
return (lnat)work;
}
View
28 ghc-xen-sparse/rts/xen/events.c
@@ -305,7 +305,7 @@ void init_events(void)
void do_hypervisor_callback(struct pt_regs *regs)
{
- u32 l1, l2;
+ unsigned long l1, l2;
unsigned int l1i, l2i, port;
int cpu = 0;
shared_info_t *s = HYPERVISOR_shared_info;
@@ -324,8 +324,8 @@ void do_hypervisor_callback(struct pt_regs *regs)
l2i = __ffs(l2);
l2 &= ~(1 << l2i);
- port = (l1i << 5) + l2i;
- do_event(port, regs);
+ port = (l1i * (sizeof(unsigned long) * 8)) + l2i;
+ do_event(port, regs);
}
}
}
@@ -360,6 +360,27 @@ int pause(void)
return -1;
}
+#if defined(__x86_64__)
+u32 irq_get_status(u32 irq)
+{
+ struct physdev_irq_status_query op;
+
+ bzero(&op, sizeof(struct physdev_irq_status_query));
+ op.irq = irq;
+ assert(!HYPERVISOR_physdev_op(PHYSDEVOP_irq_status_query, &op));
+ return op.flags;
+}
+
+void irq_send_eoi(u32 irq)
+{
+ struct physdev_eoi op;
+
+ bzero(&op, sizeof(struct physdev_eoi));
+ op.irq = irq;
+ assert(!HYPERVISOR_physdev_op(PHYSDEVOP_eoi, &op));
+}
+
+#else
u32 irq_get_status(u32 irq)
{
struct physdev_op op;
@@ -388,3 +409,4 @@ void irq_send_eoi(u32 irq)
assert(!HYPERVISOR_physdev_op_compat(&op));
}
+#endif
View
2  ghc-xen-sparse/rts/xen/include/arch.h
@@ -15,7 +15,7 @@
#define smp_processor_id() 0
-#define HALVM_STACK_SIZE 0x10000
+#define HALVM_STACK_SIZE 0x50000
#ifndef __ASSEMBLY__
#include <types.h>
View
5 ghc-xen-sparse/rts/xen/include/machine/limits.h
@@ -1,7 +1,12 @@
#ifndef MACHINE_LIMITS_H
#define MACHINE_LIMITS_H
+#if defined(__x86_64__)
+#define LONG_MAX 9223372036854775807L
+#else
#define LONG_MAX 2147483647L
+#endif
+
#define LONG_MIN (-LONG_MAX - 1L)
#define LLONG_MAX 9223372036854775807LL
View
3  ghc-xen-sparse/rts/xen/include/mm.h
@@ -21,10 +21,11 @@
#if defined(__x86_64__)
typedef uint64_t mfn_t; // machine frame number
+typedef uint64_t pfn_t; // pseudo-physical frame number
#else
typedef uint32_t mfn_t;
-#endif
typedef uint32_t pfn_t; // pseudo-physical frame number
+#endif
#if defined(CONFIG_X86_PAE) || defined(__x86_64__)
typedef uint64_t maddr_t; // machine address
#else
View
3  ghc-xen-sparse/rts/xen/libc/stdlib.c
@@ -13,6 +13,7 @@
#include <errno.h>
#include <string.h>
#include <unistd.h>
+#include <machine/limits.h>
char *getenv(const char *name __attribute__((unused)))
{
@@ -139,8 +140,6 @@ long int strtol(const char *nptr, char **endptr, int base)
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#define LONG_MAX 0x7fffffffL /* max value for a long */
-#define LONG_MIN (-0x7fffffffL-1) /* min value for a long */
#define isalpha(c) (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')))
#define isupper(c) ((c >= 'A') && (c <= 'Z'))
#define isspace(c) ((c == ' ') || (c == '\n') || (c == '\t'))
View
24 ghc-xen-sparse/rts/xen/mm.c
@@ -42,7 +42,7 @@ static pfn_t last_found_pfn = 0;
// maddr_t virtual_to_machine(vaddr_t);
// vaddr_t *machine_to_virtual(maddr_t);
// static pt_entry_t pte_phys_address(vaddr_t);
-// static pt_entry_t *pte_virt_address(vaddr_t);
+// static pt_entry_t pte_virt_address(vaddr_t);
// static void force_page_table_for_vaddr(vaddr_t);
// static void initialize_mm_state();
//
@@ -51,7 +51,7 @@ static pfn_t last_found_pfn = 0;
// and that the physical frame handling routines are functional.
//
#if defined(__x86_64__)
-# define MFN_IN_USE_BIT 0x8000000000000000
+# define MFN_IN_USE_BIT 0x8000000000000000UL
#else
# define MFN_IN_USE_BIT 0x80000000
#endif
@@ -59,6 +59,7 @@ static pfn_t last_found_pfn = 0;
#define MFN_IN_USE(x) (((mfn_t)x) & MFN_IN_USE_BIT)
#define SET_MFN_IN_USE(x) ((x) | MFN_IN_USE_BIT)
#define CLEAR_MFN_IN_USE(x) ((x) & (~MFN_IN_USE_BIT))
+#define NUM(x) ((uintptr_t)(x))
static inline void set_pframe_used(pfn_t pfn)
{
@@ -85,8 +86,9 @@ int set_page_writable(vaddr_t addr, int write, domid_t dom)
mmu_update_t request;
pt_entry_t val;
+ memset(&request, 0, sizeof(mmu_update_t));
assert(PAGE_ALIGNED((vaddr_num_t)addr));
- val = *pte_virt_address(addr);
+ val = pte_virt_address(addr);
if(write) val = val | PTE_RW; else val = val & (~PTE_RW);
request.ptr = pte_phys_address(addr);
request.val = val;
@@ -99,7 +101,7 @@ int get_page_protection(vaddr_t ptr)
int res = 0;
assert(PAGE_ALIGNED((vaddr_num_t)ptr));
- val = *pte_virt_address(ptr);
+ val = pte_virt_address(ptr);
if(ENTRY_PRESENT(val))
res |= PROT_READ;
@@ -230,18 +232,19 @@ static void claim_addresses(void *start, void *end)
// Force the page table to exist, because we're probably about to use
// this space.
- for(ptr = start; ptr < end; ptr = (void*)(NUM(ptr) + PAGE_SIZE))
+ for(ptr = start; ptr < end; ptr = (void*)(NUM(ptr) + PAGE_SIZE)) {
force_page_table_for_vaddr(ptr);
+ }
// Now do the updates.
ptr = start;
while(num_updates > 0) {
int updates_this_time = (num_updates > 16) ? 16 : num_updates;
- mmu_update_t *updates = alloca(updates_this_time * sizeof(mmu_update_t));
+ mmu_update_t updates[16];
int res, i;
for(i = 0; i < updates_this_time; i++) {
- pt_entry_t curval = *pte_virt_address(ptr);
+ pt_entry_t curval = pte_virt_address(ptr);
updates[i].ptr = pte_phys_address(ptr);
updates[i].val = curval | PTE_CLAIMED;
ptr = (void*)(NUM(ptr) + PAGE_SIZE);
@@ -262,11 +265,11 @@ static void disclaim_addresses(void *start, void *end)
ptr = start;
while(num_updates > 0) {
int updates_this_time = (num_updates > 16) ? 16 : num_updates;
- mmu_update_t *updates = alloca(updates_this_time * sizeof(mmu_update_t));
+ mmu_update_t updates[16];
int res, i;
for(i = 0; i < updates_this_time; i++) {
- pt_entry_t curval = *pte_virt_address(ptr);
+ pt_entry_t curval = pte_virt_address(ptr);
updates[i].ptr = pte_phys_address(ptr);
updates[i].val = curval & (~PTE_CLAIMED);
ptr = (void*)(NUM(ptr) + PAGE_SIZE);
@@ -401,7 +404,8 @@ static void increase_memory_balloon(void)
if(res <= 0) pabort("MM: Couldn't increase reservation: %d\n", res);
current_memory_reservation += res;
printf("MM: Increased memory reservation to %lld of %lld MB.\n",
- current_memory_reservation / 256, maximum_memory_reservation / 256);
+ (long long)current_memory_reservation / 256,
+ (long long)maximum_memory_reservation / 256);
}
static void reset_memory_balloon(void)
View
5 ghc-xen-sparse/rts/xen/mm/core_32p.c
@@ -15,7 +15,6 @@ static unsigned char clearing_space[4096] __attribute__ ((aligned (4096) ));
static void *page_tables_start = NULL;
#define PTENTRYP(x) ((pt_entry_t*)(x))
-#define NUM(x) ((uintptr_t)(x))
#define ptable_for_vaddr(x) PTENTRYP(NUM(page_tables_start) + \
(4096 * VADDR_TO_L3PD_INDEX(NUM(x))))
#define RM_PT_BITS(x) (x & 0xFFFFFFFFFFFFF000ULL)
@@ -95,10 +94,10 @@ static pt_entry_t pte_phys_address(vaddr_t ptr)
// NOTE: The use of uint32_t is safe here because (0 <= pt_index <= 512)
}
-static pt_entry_t *pte_virt_address(vaddr_t ptr)
+static pt_entry_t pte_virt_address(vaddr_t ptr)
{
pt_entry_t *ptable = ptable_for_vaddr(ptr);
- return &(ptable[VADDR_TO_PT_INDEX(ptr)]);
+ return ptable[VADDR_TO_PT_INDEX(ptr)];
}
static void force_page_table_for_vaddr(vaddr_t);
View
100 ghc-xen-sparse/rts/xen/mm/core_64.c
@@ -5,6 +5,7 @@
// - terms and conditions.
// Author: Adam Wick <awick@galois.com>
// BANNEREND
+#include <string.h>
typedef uint64_t pt_entry_t;
@@ -14,7 +15,7 @@ static maddr_t l4_base = NULL;
// static pt_entry_t temp_tab[512] __attribute__ ((aligned(PAGE_SIZE)));
// static pt_entry_t clear_block[512] __attribute__ ((aligned(PAGE_SIZE)));
-static pt_entry_t *temp_tab = NULL;
+static volatile pt_entry_t *temp_tab = NULL;
static pt_entry_t* clear_block;
static maddr_t temp_tab_pt_entry = NULL;
@@ -93,12 +94,12 @@ static maddr_t pte_phys_address(vaddr_t ptr)
// so why not just return the entry?
// On failure, returns 0.
// NOTE: Modifies temp_table.
-static pt_entry_t *pte_virt_address(vaddr_t ptr) {
+static pt_entry_t pte_virt_address(vaddr_t ptr) {
maddr_t addr = pte_phys_address(ptr);
- if (addr == 1) return NULL;
+ if (addr == 1) return -1;
temporarily_map_page_table(addr);
- return temp_tab + VADDR_TO_PT_INDEX(ptr);
+ return *(temp_tab + VADDR_TO_PT_INDEX(ptr));
}
@@ -108,8 +109,8 @@ static pt_entry_t *pte_virt_address(vaddr_t ptr) {
// On failure, returns 0.
// NOTE: Modifies temp_table.
static pt_entry_t map_page_table_for(vaddr_t ptr) {
- pt_entry_t *entry = pte_virt_address(ptr);
- return entry == 0 ? 0 : *entry;
+ pt_entry_t entry = pte_virt_address(ptr);
+ return entry == (-1) ? 0 : entry;
}
@@ -169,7 +170,7 @@ vaddr_t machine_to_virtual(maddr_t mptr)
}
}
// Restore L3 table
- temporarily_map_page_table(l4_table[i]);
+ temporarily_map_page_table(ENTRY_MADDR(l4_table[i]));
}
}
}
@@ -239,7 +240,6 @@ static void force_page_table_for_vaddr(vaddr_t ptr)
{
maddr_t entry_base = l4_base;
pt_entry_t entry = l4_table[VADDR_TO_L4_INDEX(ptr)];
- int i;
// Is there an entry in the L4 table for this address?
if(!ENTRY_PRESENT(entry)) {
@@ -259,19 +259,18 @@ static void force_page_table_for_vaddr(vaddr_t ptr)
// There is now a page directory for the address. So see if there's a
// page table.
- temporarily_map_page_table(entry & PAGE_MASK);
+ temporarily_map_page_table(ENTRY_MADDR(entry));
entry_base = ENTRY_MADDR(entry);
entry = temp_tab[VADDR_TO_PD_INDEX(ptr)];
if(!ENTRY_PRESENT(entry)) {
entry = generate_new_page_table(MMUEXT_PIN_L1_TABLE);
bind_page_table(entry_base, VADDR_TO_PD_INDEX(ptr), entry);
}
-
}
// Compute the pseudo-physical page containing a particular virtual address.
static inline pfn_t vaddr_to_pfn(vaddr_t ptr) {
- return (ptr - text_start) >> PAGE_SHIFT;
+ return ((unsigned long)ptr - (unsigned long)text_start) >> PAGE_SHIFT;
}
@@ -293,12 +292,14 @@ static inline maddr_t pre_initialization_get_pte(vaddr_t ptr)
entry = table[VADDR_TO_L4_INDEX(ptr)];
mfn = ENTRY_MFN(entry);
pfn = machine_to_phys_mapping[mfn];
- table = (pt_entry_t*)(text_start + (((maddr_t)pfn) << PAGE_SHIFT)); // 3
+ table = (pt_entry_t*)((unsigned long)text_start +
+ (((maddr_t)pfn) << PAGE_SHIFT)); // 3
entry = table[VADDR_TO_L3_INDEX(ptr)];
mfn = ENTRY_MFN(entry);
pfn = machine_to_phys_mapping[mfn];
- table = (pt_entry_t*)(text_start + (((maddr_t)pfn) << PAGE_SHIFT)); // 2
+ table = (pt_entry_t*)((unsigned long)text_start +
+ (((maddr_t)pfn) << PAGE_SHIFT)); // 2
entry = table[VADDR_TO_PD_INDEX(ptr)];
@@ -313,15 +314,12 @@ static inline maddr_t pre_initialization_get_pte(vaddr_t ptr)
#define vmm_page(x) ((x == l4_table) || \
(x == temp_tab) || \
(x == clear_block_addr))
-
+*/
#define all_xen(a,b) \
((BUILD_ADDR(a,b, 0,0,0) >= (vaddr_t)HYPERVISOR_VIRT_START) && \
(BUILD_ADDR(a,b+1,0,0,0) <= (vaddr_t)HYPERVISOR_VIRT_END))
#define important_page(x) (text_page(x) || xen_page(x) || vmm_page(x))
-*/
-
-static inline void set_pframe_used(pfn_t);
// Initialize what physical memory is already used by the HaLVM.
// Our memory allocator uses one bit (MFN_IN_USE_BIT) for each
@@ -329,14 +327,24 @@ static inline void set_pframe_used(pfn_t);
// page is allocated. Upon start this bit is unset.
// Here we traverse the pages that are used by the HaLLVM and mark them as used.
static void setup_used(void) {
- unsigned long page_num =
- (start_info->pt_base + (PAGE_SIZE * start_info->nr_pt_frames)
- - (unsigned long)text_start) >> PAGE_SHIFT;
+ unsigned long the_end = start_info->pt_base
+ + PAGE_SIZE * start_info->nr_pt_frames;
+
+ unsigned long plus_stack = the_end + 512 * 1024;
+ unsigned long four_mb_mask = 4 * 1024 * 1024 - 1;
+ unsigned long rounded_up = (plus_stack + four_mb_mask) & ~four_mb_mask;
+ unsigned long start = (unsigned long)text_start & PAGE_MASK;
+ unsigned long num_bytes = rounded_up - start;
+ unsigned long page_num = (num_bytes >> PAGE_SHIFT);
- // round up to 4MB
- unsigned long page_num1 = (page_num + 1023) & ~1023;
pfn_t pfn;
- for (pfn = 0; pfn < page_num1; ++pfn) {
+ for (pfn = 0; pfn < page_num; ++pfn) {
+ set_pframe_used(pfn);
+ }
+
+ claim_vspace((void*)start, num_bytes);
+
+ for (pfn = page_num + 0x100; pfn < page_num + 0x200; ++pfn) {
set_pframe_used(pfn);
}
}
@@ -344,10 +352,8 @@ static void setup_used(void) {
static void initialize_mm_state(void)
{
- // pt_entry_t *l3_table, *l2_table, *l1_table;
- pt_entry_t *l1_table;
- // int i, j, k, l;
- int i;
+ pt_entry_t l3_table[512], l2_table[512], l1_table[512];
+ int i, j, k, l;
pfn_t pfn;
// void *ptr;
@@ -364,42 +370,33 @@ static void initialize_mm_state(void)
assert(start_info->nr_pt_frames >= 3);
temp_tab = l4_table + 512;
- clear_block = temp_tab + 512;
-
- temp_tab_pt_entry = pre_initialization_get_pte(temp_tab);
- clear_block_pt_entry = pre_initialization_get_pte(clear_block);
-
- machine_to_virtual(temp_tab);
+ clear_block = (pt_entry_t*)(temp_tab + 512);
+ temp_tab_pt_entry = pre_initialization_get_pte((vaddr_t)temp_tab);
+ clear_block_pt_entry = (maddr_t)pre_initialization_get_pte(clear_block);
setup_used();
-/*
// For each mapped page, either (a) mark it as used if it's important, or
// (b) unmap it.
- for(i = 0; i < 512; i++) {
+ for(i = 0; i < 256; i++) {
if(ENTRY_PRESENT(l4_table[i])) {
- printf("L3 table, entry %d, mfn %p\n", i, l4_table[i] & PAGE_MASK);
- l3_table = temporarily_map_page_table(l4_table[i] & PAGE_MASK);
+ temporarily_map_page_table(ENTRY_MADDR(l4_table[i]));
+ memcpy((void*)l3_table, (void*)temp_tab, sizeof(l3_table));
+
for(j = 0; j < 512; j++) {
if(ENTRY_PRESENT(l3_table[j]) && !all_xen(i,j) ) {
+ temporarily_map_page_table(ENTRY_MADDR(l3_table[j]));
+ memcpy((void*)l2_table, (void*)temp_tab, sizeof(l2_table));
+
for(k = 0; k < 512; k++) {
- printf("L2: %d\n", k);
- l2_table = temporarily_map_page_table(l3_table[j] & PAGE_MASK);
if(ENTRY_PRESENT(l2_table[k])) {
+ temporarily_map_page_table(ENTRY_MADDR(l2_table[k]));
+ memcpy((void*)l1_table, (void*)temp_tab, sizeof(l1_table));
+
for(l = 0; l < 512; l++) {
- l1_table = temporarily_map_page_table(l2_table[k] & PAGE_MASK);
if(ENTRY_PRESENT(l1_table[l])) {
- vaddr_t page = BUILD_ADDR(i, j, k, l, 0);
-
- if( important_page(page) ) {
- pfn_t fn = machine_to_phys_mapping[l1_table[l]>>PAGE_SHIFT];
- set_pframe_used(fn);
- } else {
- mmu_update_t u;
- u.ptr = (l2_table[k] & PAGE_MASK) | (i * 8);
- u.val = 0;
- assert(HYPERVISOR_mmu_update(&u, 1, NULL, DOMID_SELF) >= 0);
- }
+ pfn_t fn = machine_to_phys_mapping[ENTRY_MFN(l1_table[l])];
+ assert(MFN_IN_USE(phys_to_machine_mapping[fn]));
}
}
}
@@ -408,6 +405,5 @@ static void initialize_mm_state(void)
}
}
}
-*/
// wow that's a lot of close braces, but I think that's it!
}
View
2  ghc-xen-sparse/rts/xen/mm/core_constants.h
@@ -56,7 +56,7 @@
# define VADDR_TO_PT_INDEX(x) ((((vaddr_num_t)x) >> PAGE_SHIFT) & 1023)
#endif
-#define VADDR_TO_PAGE_INDEX(x) (((vaddr_num_t)x) & PAGE_MASK)
+#define VADDR_TO_PAGE_INDEX(x) (((vaddr_num_t)x) & (PAGE_SIZE - 1))
#define MFN_MASK ((((pt_entry_t)1) << MFN_BITS) - 1)
#define MADDR_MASK (((pt_entry_t)(MFN_MASK)) << PAGE_SHIFT)
View
22 ghc-xen-sparse/rts/xen/mm/core_mb.c
@@ -5,27 +5,7 @@
// - terms and conditions.
// Author: Adam Wick <awick@galois.com>
// BANNEREND
-
-#if defined(__i386__)
-#define mb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
-#define rmb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
-#define wmb() __asm__ __volatile__ ( "" : : : "memory")
-#elif defined(__x86_64__)
-#define mb() __asm__ __volatile__ ( "mfence" : : : "memory")
-#define rmb() __asm__ __volatile__ ( "lfence" : : : "memory")
-#define wmb() __asm__ __volatile__ ( "" : : : "memory")
-#elif defined(__ia64__)
-#define mb() __asm__ __volatile__ ("mf" ::: "memory")
-#define rmb() __asm__ __volatile__ ("mf" ::: "memory")
-#define wmb() __asm__ __volatile__ ("mf" ::: "memory")
-#elif defined(__powerpc__)
-/* XXX loosen these up later */
-#define mb() __asm__ __volatile__ ("sync" : : : "memory")
-#define rmb() __asm__ __volatile__ ("sync" : : : "memory") /* lwsync? */
-#define wmb() __asm__ __volatile__ ("sync" : : : "memory") /* eieio? */
-#else
-#error "Define barriers"
-#endif
+#include <arch.h>
void system_wmb()
{
View
2  libraries/HALVMCore/HALVMCore.buildinfo.in
@@ -1,4 +1,4 @@
ghc-options: @ARCH_OPTION@
-cc-options: @ARCH_OPTION@ @NO_STACK_PROTECTOR_OPT@
+cc-options: @ARCH_OPTION@ @ARCH_FLAGS@ @NO_STACK_PROTECTOR_OPT@
include-dirs: @XEN_INCLUDE_DIRECTORY@
View
4 libraries/HALVMCore/HALVMCore.cabal
@@ -1,5 +1,5 @@
name: HALVMCore
-version: 1.0.0
+version: 1.1.0
license: BSD3
author: Adam Wick <awick@galois.com>, Andrew Tolmach <apt@galois.com>
maintainer: Adam Wick <awick@galois.com>
@@ -36,7 +36,7 @@ library
Rank2Types, FlexibleContexts, UndecidableInstances,
OverlappingInstances, Generics, ForeignFunctionInterface
hs-source-dirs: .
- ghc-options: -O2 -Wall
+ ghc-options: -O2 -Wall -optc-mno-red-zone
include-dirs: cbits/include
c-sources: cbits/io.c,
cbits/start_info.c,
View
88 libraries/HALVMCore/Hypervisor/Memory.hs
@@ -19,7 +19,7 @@ module Hypervisor.Memory(
, pageSize
-- * Routines for creating, destroying, and modifying pages.
, allocPage
- , AllocProt(..)
+ , AllocProt(..), defaultProt
, allocPageProt
, freePage
, withPage
@@ -67,12 +67,15 @@ import Data.Int
import Data.IORef
import Data.Word
import Foreign.Ptr
+import Foreign.C.Types (CSize)
import Foreign.Marshal.Alloc
import Foreign.Marshal.Array
import Foreign.Storable
-import GHC.IOBase(unsafePerformIO)
+import GHC.IO(unsafePerformIO)
import Hypervisor.Basics
+#if !defined(CONFIG_X86_64)
import Hypervisor.Privileged
+#endif
import Data.Generics.Instances()
import Data.Generics.Basics(Data,Typeable)
import Numeric
@@ -84,14 +87,14 @@ import Numeric
-- |Pseudo-physical frame numbers. These frame numbers have very little to
-- do with the machine address or the virtual address, but are used in some
-- Xen hypercalls.
-newtype PFN = PFN Word32
+newtype PFN = PFN Word
_ignore :: Int
_ignore = undefined PFN
-- |Machine frame numbers. These frame numbers identify a phyical 4096-byte
-- frame on the underlying hardware.
-newtype MFN = MFN Word32
+newtype MFN = MFN Word
deriving (Eq, Ord, Num, Read, Data, Typeable)
instance Show MFN where
@@ -110,13 +113,13 @@ instance Bits MFN where
complement (MFN x) = MFN $ complement x
bit x = MFN $ bit x
(MFN x) `testBit` y = testBit x y
- bitSize _ = 32
+ bitSize _ = bitSize (0 :: Word)
isSigned _ = False
-- NOTE: we could derive this
instance Storable MFN where
- sizeOf _ = 4
- alignment _ = 1
+ sizeOf _ = sizeOf (0 :: Word)
+ alignment _ = alignment (0 :: Word)
peek ptr = MFN `fmap` peek (castPtr ptr)
poke ptr (MFN v) = poke (castPtr ptr) v
@@ -139,18 +142,18 @@ mptrToInteger (MPtr x) = fromIntegral x
-- |Convert a 32-bit word, from some other source, into an MFN. Manufacturing
-- your own MFNs is dangerous, so make sure you know what you're doing if
-- you use this function.
-toMFN :: Word32 -> MFN
+toMFN :: Word -> MFN
toMFN = MFN
-- | This is used when passing MFNs to some primitives.
-- Eventually, we should change the primitives to take MFNs directly.
-fromMFN :: MFN -> Word32
+fromMFN :: MFN -> Word
fromMFN (MFN x) = x
-- |Convert a machine frame number to the initial machine address within the
-- block.
mfnToMPtr :: MFN -> MPtr a
-mfnToMPtr (MFN f) = MPtr ((fromIntegral f :: Word64) `shiftL` 12)
+mfnToMPtr (MFN f) = MPtr (fromIntegral f `shiftL` 12)
-- |Convert a machine frame number to the address at which it is mapped in
-- the address space. Note that, obviously, if the page isn't currently
@@ -259,7 +262,7 @@ setPageWritable x val (Just (DomId dom)) = do
-- Use level '3' for PAE base tables
markAsPageTable :: Int -> VPtr a -> DomId -> Xen ()
markAsPageTable l addr (DomId dom)
- | (l >= 1) && (l <= 3) = do
+ | (l >= 1) && (l <= 4) = do
res <- mark_as_page_table l addr dom
case res of
0 -> return ()
@@ -269,7 +272,7 @@ markAsPageTable l addr (DomId dom)
markAsPageTableMFN :: Int -> MFN -> DomId -> Xen ()
markAsPageTableMFN l mfn (DomId dom)
- | (l >= 1) && (l <= 3) = do
+ | (l >= 1) && (l <= 4) = do
res <- mark_as_page_table_mfn l mfn dom
case res of
0 -> return ()
@@ -289,6 +292,7 @@ newtype GrantRef = GrantRef Word16
num_grant_entries :: Num a => a
num_grant_entries = 2048
+{-# NOINLINE unusedGrantRefs #-}
unusedGrantRefs :: IORef [Word16]
unusedGrantRefs = unsafePerformIO $ newIORef [8..num_grant_entries-1]
@@ -363,7 +367,7 @@ grantRefToAddress (GrantRef gr) = do
-- |The type of a grant handle, or (in other words), the handle to a
-- grant from another domain that we've mapped.
-newtype GrantHandle = GrantHandle Word16
+newtype GrantHandle = GrantHandle Word32
deriving (Eq, Ord, Show, Read)
-- |Map another domain's grant into our own address space. The return
@@ -403,7 +407,7 @@ mapGrants (DomId remoteDomain) refs writable = do
mapM_ (`unmapGrant` Nothing) rest'
return $! (hndl:rest')
-mapGrant' :: VPtr a -> Word32 -> Word32 -> Bool -> Xen (VPtr a, GrantHandle)
+mapGrant' :: VPtr a -> Word16 -> Word32 -> Bool -> Xen (VPtr a, GrantHandle)
mapGrant' vaddr dom gref writable = do
res <- gnttab_map_grant_ref vaddr dom gref writable
case res of
@@ -515,17 +519,56 @@ foreign import ccall unsafe "gnttab.h gnttab_grant_copy"
-- !Lookup the MFN that a given address is mapped to in a foreign
-- domain's address-space.
+#if defined(CONFIG_X86_64)
+translateForeignAddress :: DomId -> VCPU -> Ptr a -> Xen MFN
+translateForeignAddress _did _vcpu _remAddr = do
+ fail "translateForeignAddress: not implemented"
+{-
+ ctxt <- domainRegisterContext did vcpu
+ let l4 = fromIntegral (cr3 (ctrlreg ctxt))
+ l3 <- lookupPT l4 (ptIndex 4)
+ l2 <- lookupPT l3 (ptIndex 3)
+ l1 <- lookupPT l2 (ptIndex 2)
+ mfn <- lookupPT l1 (ptIndex 1)
+
+ return (MFN mfn)
+
+
+ where
+ ra :: Word
+ ra = fromIntegral $ ptrToIntPtr remAddr
+
+ ptIndex l = ra `shiftR` (3 + l * 9)
+
+ lookupPT maddr i = do
+ pt <- mapForeignMachineFramesReadOnly did [MFN (0xFFFFFFFFF .&. (maddr `shiftR` 12))]
+ pte <- readPageEnt pt i
+ unmapForeignMachineFrames pt 4096
+ if (pte .&. 1) == 0
+ then xThrow EINVAL
+ else return (pte `shiftR` 12)
+
+ readPageEnt :: VPtr a -> Int -> IO Word64
+ readPageEnt base shft = do
+ let base' = fromIntegral (ptrToIntPtr base)
+ ent_addr = base' + 8 * shft
+ peek (intPtrToPtr (fromIntegral ent_addr))
+-}
+#else
translateForeignAddress :: DomId -> VCPU -> Ptr a -> Xen MFN
translateForeignAddress did vcpu remAddr = do
ctxt <- domainRegisterContext did vcpu
- lookupPD ((cr3 . ctrlreg) ctxt)
+ lookupPD $ fromIntegral ((cr3 . ctrlreg) ctxt)
where
ra :: Word32
ra = fromIntegral $ ptrToIntPtr remAddr
--
+ makeMFN :: Word32 -> MFN
+ makeMFN = MFN . fromIntegral
+ --
lookupPD :: Word32 -> Xen MFN
lookupPD pdpe = do
- pd <- mapForeignMachineFramesReadOnly did [MFN $ pdpe `shiftR` 12]
+ pd <- mapForeignMachineFramesReadOnly did [makeMFN $ pdpe `shiftR` 12]
pde <- readPageEnt pd 22
unmapForeignMachineFrames pd 4096
lookupPT pde
@@ -534,18 +577,19 @@ translateForeignAddress did vcpu remAddr = do
lookupPT pde
| pde .&. 1 == 0 = xThrow EINVAL
| otherwise = do
- pt <- mapForeignMachineFramesReadOnly did [MFN $ pde `shiftR` 12]
+ pt <- mapForeignMachineFramesReadOnly did [makeMFN $ pde `shiftR` 12]
pte <- readPageEnt pt 12
unmapForeignMachineFrames pt 4096
if (pte .&. 1) == 0
then xThrow EINVAL
- else return $ MFN (pte `shiftR` 12)
+ else return $ makeMFN (pte `shiftR` 12)
--
readPageEnt :: VPtr a -> Int -> IO Word32
readPageEnt base shft = do
let base' = fromIntegral (ptrToIntPtr base)
ent_addr = base' + 4 * ((ra `shiftR` shft) .&. 0x3ff)
peek (intPtrToPtr (fromIntegral ent_addr))
+#endif
-- |Map a set of foreign machine frame numbers into the address space read-only,
-- returning the new address.
@@ -593,7 +637,7 @@ machineToVirtual (MPtr x) = machine_to_virtual x >>= \ x'->
-- the returned addresses will cause a page fault.
reserveVirtualFrames :: Word32 -> Xen (VPtr a)
reserveVirtualFrames num = do
- va <- claim_vspace nullPtr (num * 4096)
+ va <- claim_vspace nullPtr (fromIntegral num * 4096)
if va == nullPtr then xThrow ENOMEM else return $ va
-- |Unreserve a previously reserved set of virtual frames, so
@@ -624,7 +668,7 @@ addressMapped addr = (/= 0) `fmap` address_mapped addr
-- Functions from mm.h
foreign import ccall unsafe "mm.h claim_vspace"
- claim_vspace :: C_VADDR_T -> Word32 -> IO C_VADDR_T
+ claim_vspace :: C_VADDR_T -> CSize -> IO C_VADDR_T
foreign import ccall unsafe "mm.h disclaim_vspace"
disclaim_vspace :: C_VADDR_T -> C_VADDR_T -> IO ()
foreign import ccall unsafe "mm.h alloc_page"
@@ -678,6 +722,6 @@ foreign import ccall unsafe "gnttab.h gnttab_transfer_page_to_dom"
foreign import ccall unsafe "gnttab.h gnttab_address_of"
gnttab_address_of :: Word16 -> IO (VPtr a)
foreign import ccall unsafe "gnttab.h gnttab_map_grant_ref"
- gnttab_map_grant_ref :: VPtr a -> Word32 -> Word32 -> Bool -> IO Int32
+ gnttab_map_grant_ref :: VPtr a -> Word16 -> Word32 -> Bool -> IO Int32
foreign import ccall unsafe "gnttab.h gnttab_unmap_grant_ref"
- gnttab_unmap_grant_ref :: VPtr a -> Word16 -> IO Int32
+ gnttab_unmap_grant_ref :: VPtr a -> Word32 -> IO Int32
View
18 libraries/HALVMCore/Hypervisor/Port.hs
@@ -83,7 +83,7 @@ unsetPortHandler p = do
allocPort :: DomId -> Xen Port
allocPort (DomId remoteDomain) = do
let (DomId domSelf) = domidSelf
- res <- evtchn_alloc_unbound domSelf remoteDomain
+ res <- evtchn_alloc_unbound (fromIntegral domSelf) (fromIntegral remoteDomain)
case () of
() | res < 0 -> toError res
| res < 1024 -> return $ Port (fromIntegral res)
@@ -92,7 +92,7 @@ allocPort (DomId remoteDomain) = do
-- |Bind another domain's port, which they've shared with us.
bindRemotePort :: DomId -> Port -> Xen Port
bindRemotePort (DomId remoteDomain) (Port remotePort) = do
- res <- evtchn_bind_interdomain remoteDomain remotePort
+ res <- evtchn_bind_interdomain (fromIntegral remoteDomain) (fromIntegral remotePort)
case () of
() | res < 0 -> toError res
| res < 1024 -> return $ Port (fromIntegral res)
@@ -122,7 +122,7 @@ closePort (Port p) = do
-- The second is the domain it's allocating a port to.
allocUnboundPort :: DomId -> DomId -> Xen Port
allocUnboundPort (DomId fromDom) (DomId toDom) = do
- res <- evtchn_alloc_unbound fromDom toDom
+ res <- evtchn_alloc_unbound (fromIntegral fromDom) (fromIntegral toDom)
case () of
() | res < 0 -> toError res
| res < 1024 -> return $ Port (fromIntegral res)
@@ -140,9 +140,9 @@ sendOnPort (Port p) = do
-- given port disabled.
withPortMasked :: Port -> IO a -> IO a
withPortMasked (Port p) a =
- do mask_evtchn p
+ do mask_evtchn (fromIntegral p)
r <- a
- unmask_evtchn p
+ unmask_evtchn (fromIntegral p)
return r
-- |Bind a physical IRQ to an event channel. The arguments are the IRQ to
@@ -183,13 +183,13 @@ foreign import ccall unsafe "events.h unset_port_handler"
unset_port_handler :: Port -> IO (StablePtr(IO ()))
foreign import ccall unsafe "events.h evtchn_alloc_unbound"
- evtchn_alloc_unbound :: Word16 -> Word16 -> IO Int32
+ evtchn_alloc_unbound :: Word32 -> Word32 -> IO Int32
foreign import ccall unsafe "events.h bind_virq"
bind_virq :: Word32 -> Word32 -> IO Int32
foreign import ccall unsafe "events.h evtchn_bind_interdomain"
- evtchn_bind_interdomain :: Word16 -> Word10 -> IO Int32
+ evtchn_bind_interdomain :: Word32 -> Word32 -> IO Int32
foreign import ccall unsafe "events.h evtchn_close"
evtchn_close :: Word10 -> IO Int32
@@ -198,10 +198,10 @@ foreign import ccall unsafe "events.h evtchn_send"
evtchn_send :: Word10 -> IO Int32
foreign import ccall unsafe "events.h mask_evtchn"
- mask_evtchn :: Word10 -> IO ()
+ mask_evtchn :: Word32 -> IO ()
foreign import ccall unsafe "events.h unmask_evtchn"
- unmask_evtchn :: Word10 -> IO ()
+ unmask_evtchn :: Word32 -> IO ()
foreign import ccall unsafe "events.h bind_pirq"
bind_pirq :: Word32 -> Bool -> IO Int32
View
2  libraries/XenDevice/XenDevice.buildinfo.in
@@ -1 +1,3 @@
+ghc-options: @ARCH_OPTION@
+cc-options: @ARCH_OPTION@ @ARCH_FLAGS@ @NO_STACK_PROTECTOR_OPT@
include-dirs: @XEN_INCLUDE_DIRECTORY@
View
2  libraries/libDomainBuilder/libDomainBuilder.buildinfo.in
@@ -1,4 +1,4 @@
GHC-Options: @ARCH_OPTION@
-cc-Options: @ARCH_OPTION@
+cc-Options: @ARCH_OPTION@ @ARCH_FLAGS@
include-dirs: @XEN_INCLUDE_DIRECTORY@
View
10 mk/common.mk.in
@@ -79,14 +79,16 @@ NO_STACK_PROTECTOR_OPT = @NO_STACK_PROTECTOR_OPT@
SANITY_CHECKER_OPT = @SANITY_CHECKER_OPT@
BYTECODE_INTERP_OPT = @BYTECODE_INTERP_OPT@
ARCH_OPT = @ARCH_OPTION@
-GHC_ARCH_OPT = -optc@ARCH_OPTION@
+ARCH_FLAGS = @ARCH_FLAGS@
+GHC_ARCH_OPT = -optc$(ARCH_OPT)
+GHC_ARCH_FLAGS = $(foreach opt,$(ARCH_FLAGS),-optc$(opt))
NO_UNIT_AT_A_TIME_OPT = @NO_UNIT_AT_A_TIME_OPT@
ARCH = @ARCHITECTURE@
XEN_INCLUDE_DIR = @XEN_INCLUDE_DIRECTORY@
CFLAGS = -Wall -Wno-unused-variable
CFLAGS += -O2 -fno-builtin
CFLAGS += -I$(XEN_INCLUDE_DIR)
-CFLAGS += $(ARCH_OPT) $(NO_STACK_PROTECTOR_OPT)
+CFLAGS += $(ARCH_OPT) $(ARCH_FLAGS) $(NO_STACK_PROTECTOR_OPT)
CFLAGS += $(NO_UNIT_AT_A_TIME_OPT)
#
@@ -219,12 +221,10 @@ HTTP_TARGET = $(call build_hackage_target,HTTP,$(HTTP_VERSION))
CI_VER = 0.8.2
CABAL_INST_LINK = $(call build_hackage_link,cabal-install,$(CI_VER))
CABAL_INST_TARBALL = $(call build_hackage_tarball,cabal-install,$(CI_VER))
-ifeq (@ARCHITECTURE@,x86_64)
+ifeq ($(ARCH),x86_64)
CABAL_ORIG_SIG = e4d9e6cfffe2de416a529213f6ec0f28
-GHC_PRIM_OPTIONS = --ghc-options=-fvia-c
else
CABAL_ORIG_SIG = 0fa5fba8bc5459391e6ec30b2b2ff632
-GHC_PRIM_OPTIONS =
endif
FGL_VER = 5.4.2.2
FGL_LINK = $(call build_hackage_link,fgl,$(FGL_VER))
View
32 mk/halvm.mk
@@ -8,7 +8,6 @@
include mk/common.mk
-
################################################################################
# Handy Name-related Macros
################################################################################
@@ -27,11 +26,24 @@ HALVM_EXTRA_HEADERS =
define rts-header
# $1 - header path, relative to $(TOPDIR)/xen-ghc/rts
$(call halvm-rts-header-path,$1): $(call rts-header-path,$1)
- [ ! -d $$(dir $$@) ] && $(MKDIR) -p $$(dir $$@)
$(CP) $$< $$@
+ifneq "$(dir $1)" "./"
+$(call halvm-rts-header-path,$1): $(call halvm-rts-header-path,$(dir $1))
+endif
+
HALVM_EXTRA_HEADERS += $(call halvm-rts-header-path,$1)
endef
+define halvm-rts-header-dir
+# $1 - the directory relative to $(HALVM_LIBDIR)/include/rts to create
+$(call halvm-rts-header-path,$1):
+ $(MKDIR) -p $$@
+endef
+
+$(eval $(call halvm-rts-header-dir,sm))
+$(eval $(call rts-header,sm/GC.h))
+
+
################################################################################
# Halvm
@@ -98,9 +110,9 @@ DIST_DIR_TREE=$(TOPDIR)/dist/README
HALVM_INCLUDE_DIR=$(HALVM_LIBDIR)/include/ghcconfig.h
# Useful flags
-RTS_FLAGS=-optc-nostdinc -optc-Dxen_HOST_OS -optc-DRtsWay=\"rts_v\" -optc-Wall -optc-Wextra -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Winline -optc-Waggregate-return -optc-Wpointer-arith -optc-Wmissing-noreturn -optc-Wnested-externs -optc-Wredundant-decls -optc-I$(TOPDIR)/xen-ghc/rts -optc-I$(HALVM_LIBDIR)/include -optc-DCOMPILING_RTS -optc-fno-strict-aliasing -optc-fno-common -optc-I$(HALVM_LIBDIR)/include/ffi -optc-fomit-frame-pointer -O -package-name rts -static -dcmm-lint -optc-O2 -optc-DProjectVersion=\"$(GHC_VER)\" -optc-DHostPlatform=\"$(ARCH)-unknown-xen\" -optc-DHostArch=\"$(ARCH)\" -optc-DHostOS=\"xen\" -optc-DHostVendor=\"unknown\" -optc-DBuildPlatform=\"$(ARCH)-unknown-linux\" -optc-DBuildArch=\"$(ARCH)\" -optc-DBuildOS=\"linux\" -optc-DBuildVendor=\"unknown\" -optc-DTargetPlatform=\"$(ARCH)-unknown-xen\" -optc-DTargetArch=\"$(ARCH)\" -optc-DTargetOS=\"xen\" -optc-DTargetVendor=\"unknown\" -optc-DGhcUnregisterised=\"NO\" -optc-DGhcEnableTablesNextToCode=\"YES\" -I$(TOPDIR)/xen-ghc/rts/xen/include -I$(TOPDIR)/xen-ghc/rts/xen/include/sys -I$(TOPDIR)/xen-ghc/includes/rts $(GHC_ARCH_OPT)
+RTS_FLAGS=-optc-fno-delete-null-pointer-checks -optc-mno-red-zone -optc-nostdinc -optc-Dxen_HOST_OS -optc-DRtsWay=\"rts_v\" -optc-Wall -optc-Wextra -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Winline -optc-Waggregate-return -optc-Wpointer-arith -optc-Wmissing-noreturn -optc-Wnested-externs -optc-Wredundant-decls -optc-I$(TOPDIR)/xen-ghc/rts -optc-I$(HALVM_LIBDIR)/include -optc-DCOMPILING_RTS -optc-fno-strict-aliasing -optc-fno-common -optc-I$(HALVM_LIBDIR)/include/ffi -optc-fomit-frame-pointer -O -package-name rts -static -dcmm-lint -optc-O2 -optc-DProjectVersion=\"$(GHC_VER)\" -optc-DHostPlatform=\"$(ARCH)-unknown-xen\" -optc-DHostArch=\"$(ARCH)\" -optc-DHostOS=\"xen\" -optc-DHostVendor=\"unknown\" -optc-DBuildPlatform=\"$(ARCH)-unknown-linux\" -optc-DBuildArch=\"$(ARCH)\" -optc-DBuildOS=\"linux\" -optc-DBuildVendor=\"unknown\" -optc-DTargetPlatform=\"$(ARCH)-unknown-xen\" -optc-DTargetArch=\"$(ARCH)\" -optc-DTargetOS=\"xen\" -optc-DTargetVendor=\"unknown\" -optc-DGhcUnregisterised=\"NO\" -optc-DGhcEnableTablesNextToCode=\"YES\" -I$(TOPDIR)/xen-ghc/rts/xen/include -I$(TOPDIR)/xen-ghc/rts/xen/include/sys -I$(TOPDIR)/xen-ghc/includes/rts $(GHC_ARCH_OPT) $(GHC_ARCH_FLAGS)
-CONF_FLAGS=-Dxen_HOST_OS -I$(TOPDIR)/xen-ghc/includes -I$(HALVM_LIBDIR)/include -DTOP=$(TOPDIR)/dist -DINSTALLING -DLIB_DIR=$(HALVM_LIBDIR) -DPAPI_LIB_DIR= -DINCLUDE_DIR=$(HALVM_LIBDIR)/include -DPAPI_INCLUDE_DIR=
+CONF_FLAGS=-Dxen_HOST_OS -I$(TOPDIR)/xen-ghc/includes -I$(HALVM_LIBDIR)/include -DTOP=$(TOPDIR)/dist -DINSTALLING -DLIB_DIR=$(HALVM_LIBDIR) -DPAPI_LIB_DIR= -DINCLUDE_DIR=$(HALVM_LIBDIR)/include -DPAPI_INCLUDE_DIR= $(ARCH_OPT) $(ARCH_FLAGS)
define version_copy_exec
$(SED) -e 's!HALVM_VER!$(HaLVM_VERSION)!g' \
@@ -227,7 +239,7 @@ $(HALVM_GHC_BIN): $(DIST_DIR_TREE) $(HALVM_LIBDIR)/extra-gcc-opts \
$(TOPDIR)/xen-ghc/compiler/main/Config.hs \
$(ALL_HS_INCLS)
$(MKDIR) -p xen-ghc/compiler/stage2
- $(CP) static-bits/lib/ghc_boot_platform.h $(TOPDIR)/xen-ghc/compiler/
+ $(CP) static-bits/lib/ghc_boot_platform.$(ARCH).h $(TOPDIR)/xen-ghc/compiler/ghc_boot_platform.h
( cd xen-ghc/compiler && $(PLATFORM_CABAL) install -fncg -fstage2 -fghci -fbase4 --with-hsc2hs=$(PLATFORM_HSC2HS) --extra-include-dirs=$(TOPDIR)/xen-ghc/compiler/stage2 --ghc-option=-DSTAGE=2)
$(PLATFORM_GHC) -o $@ -package ghc-6.12.3 -XCPP --make -hidir=$(TOPDIR)/xen-ghc/compiler/dist/build -odir=$(TOPDIR)/xen-ghc/compiler/dist/build $(TOPDIR)/xen-ghc/ghc/Main.hs
@@ -305,8 +317,6 @@ $(HALVM_GHC_ASM): $(DIST_DIR_TREE) $(HALVM_UNLIT)
# builtin-rts
################################################################################
-$(eval $(call rts-header,sm/GC.h))
-
RTS_CFILES=Adjustor.c Arena.c Capability.c ClosureFlags.c Disassembler.c \
FrontPanel.c Globals.c Hash.c HsFFI.c Inlines.c Interpreter.c \
LdvProfile.c Papi.c Printer.c ProfHeap.c Profiling.c \
@@ -340,7 +350,7 @@ RTS_CMMFILES= PrimOps.cmm StgStartup.cmm Exception.cmm Updates.cmm \
RTS_OFILES =$(addprefix $(TOPDIR)/xen-ghc/rts/,$(RTS_CFILES:.c=.o))
RTS_OFILES+=$(addprefix $(TOPDIR)/xen-ghc/rts/,$(RTS_CMMFILES:.cmm=.o))
-%.o: %.c $(call halvm-rts-header-path,sm/GC.h)
+%.o: %.c
$(QUIET_CC)$(PLATFORM_GHC) $(RTS_FLAGS) -c -o $@ $<
%.o: %.cmm
@@ -390,7 +400,7 @@ $(call package-name,ghc-prim,0.2.0.0) : \
$(TOPDIR)/xen-ghc/libraries/ghc-prim/GHC/PrimopWrappers.hs \
$(HALVM_CABAL)
( cd $(TOPDIR)/xen-ghc/libraries/ghc-prim && \
- $(HALVM_CABAL) install $(GHC_PRIM_OPTIONS) && \
+ $(HALVM_CABAL) install && \
$(HALVM_GHC_PKG) describe ghc-prim > inplace-pkg-config && \
$(SED) -i 's/GHC.Unit/GHC.Unit GHC.Prim/' inplace-pkg-config && \
$(HALVM_GHC_PKG) update --force inplace-pkg-config \
@@ -398,11 +408,11 @@ $(call package-name,ghc-prim,0.2.0.0) : \
$(TOPDIR)/xen-ghc/compiler/stage2/ghc_boot_platform.h:
$(MKDIR) $(TOPDIR)/xen-ghc/compiler/stage2
- $(CP) $(TOPDIR)/static-bits/lib/ghc_boot_platform.h $@
+ $(CP) $(TOPDIR)/static-bits/lib/ghc_boot_platform.$(ARCH).h $@
$(TOPDIR)/xen-ghc/compiler/stage1/ghc_boot_platform.h:
$(MKDIR) $(TOPDIR)/xen-ghc/compiler/stage1
- $(CP) $(TOPDIR)/static-bits/lib/ghc_boot_platform.h $@
+ $(CP) $(TOPDIR)/static-bits/lib/ghc_boot_platform.$(ARCH).h $@
################################################################################
# STG Application
View
2  mk/infrastructure.mk
@@ -44,7 +44,7 @@ $(GHC_XENDIR_TARGET): $(PLATFORM_TOOLS) $(GHC_SRC_TARBALL)
$(FIND) * -type d -exec $(MKDIR) -p ../xen-ghc/'{}' \; )
( cd ghc-xen-sparse && \
$(FIND) * -type f -exec $(LN) -sf `pwd`/'{}' ../xen-ghc/'{}' \; )
- $(ECHO) "SRC_HC_OPTS = -H32m -O2 -optc$(NO_STACK_PROTECTOR_OPT) $(SANITY_CHECKER_OPT) $(BYTECODE_INTERP_OPT) $(GHC_ARCH_OPT) -I$(TOPDIR)/xen-ghc/rts/xen/include -I$(TOPDIR)/xen-ghc/rts/xen/include/sys"> $@
+ $(ECHO) "SRC_HC_OPTS = -H32m -O2 -optc$(NO_STACK_PROTECTOR_OPT) $(SANITY_CHECKER_OPT) $(BYTECODE_INTERP_OPT) $(GHC_ARCH_OPT) $(GHC_ARCH_FLAGS) -I$(TOPDIR)/xen-ghc/rts/xen/include -I$(TOPDIR)/xen-ghc/rts/xen/include/sys"> $@
$(ECHO) "SRC_CC_OPTS = $(CFLAGS)" >> $@
test -n $(USE_GMP) && $(ECHO) "INTEGER_LIBRARY = $(INTEGER_LIBRARY)" >> $@
$(SED) -e 's!@ProjectVersion@!$(GHC_VER)!g' xen-ghc/compiler/ghc.cabal.in \
View
2  static-bits/examples/Misc/GetIdTest/GetId.config
@@ -2,7 +2,7 @@ from os import getcwd
name = "GetId"
kernel = getcwd() + "/GetId"
-memory = 6
+memory = 16
disk = []
vif = []
on_crash = "destroy"
View
33 static-bits/lib/ghc_boot_platform.i386.h
@@ -0,0 +1,33 @@
+#ifndef __PLATFORM_H__
+#define __PLATFORM_H__
+
+#define BuildPlatform_NAME "i386-unknown-xen"
+#define HostPlatform_NAME "i386-unknown-xen"
+#define TargetPlatform_NAME "i386-unknown-xen"
+
+#define i386_unknown_xen_BUILD 1
+#define i386_unknown_xen_HOST 1
+#define i386_unknown_xen_TARGET 1
+
+#define i386_BUILD_ARCH 1
+#define i386_HOST_ARCH 1
+#define i386_TARGET_ARCH 1
+#define BUILD_ARCH "i386"
+#define HOST_ARCH "i386"
+#define TARGET_ARCH "i386"
+
+#define xen_BUILD_OS 1
+#define xen_HOST_OS 1
+#define xen_TARGET_OS 1
+#define BUILD_OS "xen"
+#define HOST_OS "xen"
+#define TARGET_OS "xen"
+
+#define unknown_BUILD_VENDOR 1
+#define unknown_HOST_VENDOR 1
+#define unknown_TARGET_VENDOR 1
+#define BUILD_VENDOR "unknown"
+#define HOST_VENDOR "unknown"
+#define TARGET_VENDOR "unknown"
+
+#endif /* __PLATFORM_H__ */
View
33 static-bits/lib/ghc_boot_platform.x86_64.h
@@ -0,0 +1,33 @@
+#ifndef __PLATFORM_H__
+#define __PLATFORM_H__
+
+#define BuildPlatform_NAME "x86_64-unknown-xen"
+#define HostPlatform_NAME "x86_64-unknown-xen"
+#define TargetPlatform_NAME "x86_64-unknown-xen"
+
+#define x86_64_unknown_xen_BUILD 1
+#define x86_64_unknown_xen_HOST 1
+#define x86_64_unknown_xen_TARGET 1
+
+#define x86_64_BUILD_ARCH 1
+#define x86_64_HOST_ARCH 1
+#define x86_64_TARGET_ARCH 1
+#define BUILD_ARCH "x86_64"
+#define HOST_ARCH "x86_64"
+#define TARGET_ARCH "x86_64"
+
+#define xen_BUILD_OS 1
+#define xen_HOST_OS 1
+#define xen_TARGET_OS 1
+#define BUILD_OS "xen"
+#define HOST_OS "xen"
+#define TARGET_OS "xen"
+
+#define unknown_BUILD_VENDOR 1
+#define unknown_HOST_VENDOR 1
+#define unknown_TARGET_VENDOR 1
+#define BUILD_VENDOR "unknown"
+#define HOST_VENDOR "unknown"
+#define TARGET_VENDOR "unknown"
+
+#endif /* __PLATFORM_H__ */
Please sign in to comment.
Something went wrong with that request. Please try again.