Commit 088970e6 authored by Charles Jacobsen's avatar Charles Jacobsen Committed by Vikram Narayanan
Browse files

build-refactor-2: Fix build errors. Microkernel and kliblcd build.

Now that microkernel libcap build is separated from microkernel build
itself, when we trigger a top-level microkernel build, it doesn't
rebuild the whole thing every time. Kind of nice.
parent 0a3b25ab
......@@ -45,7 +45,7 @@ MICROKERNEL_DIRS= \
MICROKERNEL_BUILD_DIRS=$(foreach dir,$(MICROKERNEL_DIRS),\
$(MICROKERNEL_BUILD_DIR)/$(dir))
MICROKERNEL_LIBCAP=$(MICROKERNEL_BUILD_DIR)/libcap.install/src/platform/kernel/libcap.a
MICROKERNEL_LIBCAP=$(MICROKERNEL_BUILD_DIR)/libcap.install/lib/libcap.a
microkernel: $(MICROKERNEL_BUILD_DIR)/Kbuild $(MICROKERNEL_LIBCAP) | \
$(MICROKERNEL_BUILD_DIRS)
......
......@@ -22,11 +22,11 @@ static int do_grant_and_map_for_mem(cptr_t lcd, struct lcd_create_ctx *ctx,
{
int ret;
cptr_t mo;
unsigned int order;
unsigned long size;
/*
* Look up the cptr for the *creator*
*/
ret = lcd_virt_to_cptr(__gva((unsigned long)mem), &mo, &order);
ret = lcd_virt_to_cptr(__gva((unsigned long)mem), &mo, &size);
if (ret) {
LIBLCD_ERR("lookup failed");
goto fail1;
......
......@@ -207,7 +207,7 @@ __lcd_build_checks__(void)
/* HOLE */
#define LCD_STACK_REGION_OFFSET \
(LCD_MISC_REGION_OFFSET + LCD_MISC_REGION_SIZE + 1UL << 30)
(LCD_MISC_REGION_OFFSET + LCD_MISC_REGION_SIZE + (1UL << 30))
#define LCD_STACK_OFFSET \
(LCD_STACK_REGION_OFFSET + LCD_STACK_REGION_SIZE - LCD_STACK_SIZE)
......@@ -239,35 +239,35 @@ __lcd_build_checks__(void)
#define LCD_PHYS_BASE (0UL)
#define LCD_VIRT_BASE (0xFFFFFF7FFFFFFFFFUL)
#define LCD_UTCB_GP_ADDR __gpa(LCD_PHYS_BASE + LCD_UTCB_OFFSET)
#define LCD_UTCB_GV_ADDR __gva(LCD_VIRT_BASE + LCD_UTCB_OFFSET)
#define LCD_UTCB_GP_ADDR (__gpa(LCD_PHYS_BASE + LCD_UTCB_OFFSET))
#define LCD_UTCB_GV_ADDR (__gva(LCD_VIRT_BASE + LCD_UTCB_OFFSET))
#define LCD_BOOTSTRAP_PAGES_GP_ADDR \
__gpa(LCD_PHYS_BASE + LCD_BOOTSTRAP_PAGES_OFFSET)
(__gpa(LCD_PHYS_BASE + LCD_BOOTSTRAP_PAGES_OFFSET))
#define LCD_BOOTSTRAP_PAGES_GV_ADDR \
__gva(LCD_VIRT_BASE + LCD_BOOTSTRAP_PAGES_OFFSET)
(__gva(LCD_VIRT_BASE + LCD_BOOTSTRAP_PAGES_OFFSET))
#define LCD_BOOTSTRAP_PAGE_TABLES_GP_ADDR \
__gpa(LCD_PHYS_BASE + LCD_BOOTSTRAP_PAGE_TABLES_OFFSET)
(__gpa(LCD_PHYS_BASE + LCD_BOOTSTRAP_PAGE_TABLES_OFFSET))
#define LCD_BOOTSTRAP_PAGE_TABLES_GV_ADDR \
__gva(LCD_VIRT_BASE + LCD_BOOTSTRAP_PAGE_TABLES_OFFSET)
(__gva(LCD_VIRT_BASE + LCD_BOOTSTRAP_PAGE_TABLES_OFFSET))
#define LCD_STACK_GP_ADDR __gpa(LCD_PHYS_BASE + LCD_STACK_OFFSET)
#define LCD_STACK_GV_ADDR __gva(LCD_VIRT_BASE + LCD_STACK_OFFSET)
#define LCD_STACK_GP_ADDR (__gpa(LCD_PHYS_BASE + LCD_STACK_OFFSET))
#define LCD_STACK_GV_ADDR (__gva(LCD_VIRT_BASE + LCD_STACK_OFFSET))
#define LCD_HEAP_GP_ADDR __gpa(LCD_PHYS_BASE + LCD_HEAP_OFFSET)
#define LCD_HEAP_GV_ADDR __gva(LCD_VIRT_BASE + LCD_HEAP_OFFSET)
#define LCD_HEAP_GP_ADDR (__gpa(LCD_PHYS_BASE + LCD_HEAP_OFFSET))
#define LCD_HEAP_GV_ADDR (__gva(LCD_VIRT_BASE + LCD_HEAP_OFFSET))
#define LCD_RAM_MAP_GP_ADDR __gpa(LCD_PHYS_BASE + LCD_RAM_MAP_OFFSET)
#define LCD_RAM_MAP_GV_ADDR __gva(LCD_VIRT_BASE + LCD_RAM_MAP_OFFSET)
#define LCD_RAM_MAP_GP_ADDR (__gpa(LCD_PHYS_BASE + LCD_RAM_MAP_OFFSET))
#define LCD_RAM_MAP_GV_ADDR (__gva(LCD_VIRT_BASE + LCD_RAM_MAP_OFFSET))
#define LCD_IOREMAP_GP_ADDR __gpa(LCD_PHYS_BASE + LCD_IOREMAP_OFFSET)
#define LCD_IOREMAP_GV_ADDR __gva(LCD_VIRT_BASE + LCD_IOREMAP_OFFSET)
#define LCD_IOREMAP_GP_ADDR (__gpa(LCD_PHYS_BASE + LCD_IOREMAP_OFFSET))
#define LCD_IOREMAP_GV_ADDR (__gva(LCD_VIRT_BASE + LCD_IOREMAP_OFFSET))
#define LCD_KERNEL_MODULE_REGION_GP_ADDR \
__gpa(LCD_PHYS_BASE + LCD_KERNEL_MODULE_REGION_OFFSET)
(__gpa(LCD_PHYS_BASE + LCD_KERNEL_MODULE_REGION_OFFSET))
#define LCD_KERNEL_MODULE_REGION_GV_ADDR \
__gva(LCD_VIRT_BASE + LCD_KERNEL_MODULE_REGION_OFFSET)
(__gva(LCD_VIRT_BASE + LCD_KERNEL_MODULE_REGION_OFFSET))
/**
* lcd_gva2gpa -- Convert a guest virtual to a guest physical address
......
......@@ -133,10 +133,11 @@ int _lcd_mmap(cptr_t mo, unsigned int order, gpa_t base);
* guest physical address space. If the memory object isn't mapped,
* silently fails / does nothing.
*
* You may wonder: why don't we pass just the guest physical address
* that we want unmapped? Answer: the microkernel needs to keep track
* of where memory objects are mapped (so that if rights are revoked,
* it knows how to unmap them).
* Although the microkernel doesn't use the guest physical address (it
* tracks where the memory object is mapped internally), liblcd
* needs the address so it can update some internal data structures
* (we can cheat with kliblcd since kliblcd can talk directly to the
* microkernel internally).
*
* The semantics is a bit different depending on the environment.
*
......@@ -158,7 +159,7 @@ int _lcd_mmap(cptr_t mo, unsigned int order, gpa_t base);
* space, and remove from the internal resource tree used for
* address -> cptr translation.
*/
void _lcd_munmap(cptr_t mo);
void _lcd_munmap(cptr_t mo, gpa_t base);
/* HIGH-LEVEL ALLOC/FREE ---------------------------------------- */
......
......@@ -287,8 +287,8 @@ fail1:
/* LOW-LEVEL MAP -------------------------------------------------- */
static int do_map_phys(struct lcd *lcd, struct lcd_memory_object *mo,
struct cnode *cnode, cptr_t mo_cptr, gpa_t base)
static int do_map(struct lcd *lcd, struct lcd_memory_object *mo,
struct cnode *cnode, cptr_t mo_cptr)
{
int ret;
/*
......@@ -405,7 +405,7 @@ struct page *lcd_alloc_pages_exact_node(int nid, unsigned int flags,
* (all this really does is put the allocated pages in the
* proper resource tree)
*/
ret = _lcd_mmap(slot, __gpa(0));
ret = _lcd_mmap(slot, order, __gpa(0));
if (ret) {
LIBLCD_ERR("internal error: putting mem obj in tree");
goto fail2;
......@@ -453,7 +453,7 @@ struct page *lcd_alloc_pages(unsigned int flags, unsigned int order)
* (all this really does is put the allocated pages in the
* proper resource tree)
*/
ret = _lcd_mmap(slot, __gpa(0));
ret = _lcd_mmap(slot, order, __gpa(0));
if (ret) {
LIBLCD_ERR("internal error: putting mem obj in tree");
goto fail2;
......@@ -543,7 +543,7 @@ void* lcd_vmalloc(unsigned long sz)
* (all this really does is put the allocated vmalloc mem in the
* proper resource tree)
*/
ret = _lcd_mmap(slot, __gpa(0));
ret = _lcd_mmap(slot, order, __gpa(0));
if (ret) {
LIBLCD_ERR("internal error: putting mem obj in tree");
goto fail2;
......@@ -574,7 +574,7 @@ void lcd_vfree(void *vptr)
{
cptr_t vmalloc_mem_cptr;
int ret;
unsigned int unused;
unsigned long unused;
/*
* Resolve vptr to cptr
*/
......@@ -628,7 +628,7 @@ int lcd_map_phys(cptr_t pages, unsigned int order, gpa_t *base_out)
/*
* "Map" the pages (adds pages to proper resource tree)
*/
ret = __lcd_mmap(current->lcd, mo, cnode, pages);
ret = do_map(current->lcd, mo, cnode, pages);
if (ret) {
LIBLCD_ERR("error mapping pages in resource tree");
goto fail3;
......@@ -653,7 +653,6 @@ fail1:
int lcd_map_virt(cptr_t pages, unsigned int order, gva_t *gva_out)
{
int ret;
struct page *p;
struct cnode *cnode;
struct lcd_memory_object *mo;
/*
......@@ -676,14 +675,14 @@ int lcd_map_virt(cptr_t pages, unsigned int order, gva_t *gva_out)
/*
* "Map" the memory (adds pages to proper resource tree)
*/
ret = __lcd_mmap(current->lcd, mo, cnode, pages);
ret = do_map(current->lcd, mo, cnode, pages);
if (ret) {
LIBLCD_ERR("error mapping pages in resource tree");
goto fail3;
}
/* guest virtual == host virtual for non-isolated */
*base_out = __gva(hva_val(__lcd_memory_object_hva(mo)));
*gva_out = __gva(hva_val(__lcd_memory_object_hva(mo)));
/*
* Release memory object
......
......@@ -130,7 +130,7 @@ static int dup_module_pages(hva_t pages_base, unsigned long size,
{
int ret;
void *dup_pages;
unsigned int unused;
unsigned long unused;
/*
* Alloc dup pages, and memcpy the bits over
*/
......
......@@ -39,7 +39,7 @@ static int handle_syscall_create(struct lcd *lcd)
static int handle_syscall_cap_grant(struct lcd *lcd)
{
cptr_t lcd, src, dest;
cptr_t dest_lcd, src, dest;
/*
* Args
*/
......@@ -96,8 +96,8 @@ static int handle_syscall_config_registers(struct lcd *lcd)
/*
* Do config
*/
return __lcd_config_registers(lcd, dest_lcd, pc, sp, gva_root,
utcb_page);
return __lcd_config(lcd, dest_lcd, pc, sp, gva_root,
utcb_page);
}
static int handle_syscall_memory_grant_and_map(struct lcd *lcd)
......
File mode changed from 100644 to 100755
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment