Permalink
Browse files

64-bit support.

  • Loading branch information...
1 parent 6d3feb5 commit bcdb148b2c6185794a4a1ee297a55ff63242a096 @acw acw committed Dec 15, 2011
View
@@ -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
@@ -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
@@ -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! */
@@ -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);
}
@@ -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;
}
@@ -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
@@ -15,7 +15,7 @@
#define smp_processor_id() 0
-#define HALVM_STACK_SIZE 0x10000
+#define HALVM_STACK_SIZE 0x50000
#ifndef __ASSEMBLY__
#include <types.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
@@ -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
@@ -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'))
@@ -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,14 +51,15 @@ 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
#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)
@@ -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);
Oops, something went wrong.

0 comments on commit bcdb148

Please sign in to comment.