LINUXINCLUDE := -I$(src)/arch/$(SRCARCH)/include -I$(src)/include
KBUILD_CFLAGS := -g -Os -Wall -Wstrict-prototypes -Wtype-limits \
-Wmissing-declarations -Wmissing-prototypes \
- -fno-strict-aliasing -fpic -fpie -fno-common \
+ -fno-strict-aliasing -fno-pic -fno-common \
-fno-stack-protector
+
+ifeq ($(SRCARCH),x86)
+KBUILD_CFLAGS += -mcmodel=kernel
+endif
+
ifneq ($(wildcard $(src)/include/jailhouse/config.h),)
KBUILD_CFLAGS += -include $(src)/include/jailhouse/config.h
endif
* the COPYING file in the top-level directory.
*/
+#define JAILHOUSE_BASE 0xf0000000
+
#define JAILHOUSE_CALL_INS ".arch_extension virt\n\t" \
"hvc #0x4a48"
#define JAILHOUSE_CALL_NUM_RESULT "r0"
#define __asmeq(x, y) ".ifnc " x "," y " ; .err ; .endif\n\t"
#endif
+#ifndef __ASSEMBLY__
+
static inline __u32 jailhouse_call0(__u32 num)
{
register __u32 num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num;
asm volatile("dmb ishst" : : : "memory");
comm_region->reply_from_cell = reply;
}
+
+#endif /* !__ASSEMBLY__ */
int err;
if (apicbase & APIC_BASE_EXTD) {
- /* set programmatically to enable address fixup */
apic_ops.read = read_x2apic;
apic_ops.read_id = read_x2apic_id;
apic_ops.write = write_x2apic;
ret
-/* Fix up Global Offset Table with absolute hypervisor address */
- .globl got_init
-got_init:
- lea __got_start(%rip),%rdx
- lea __got_end(%rip),%rcx
- lea hypervisor_header(%rip),%rax
-
-got_loop:
- cmp %rdx,%rcx
- je got_done
-
- add %rax,(%rdx)
- add $8,%rdx
- jmp got_loop
-
-got_done:
- ret
-
-
/* Exception/interrupt entry points */
.macro common_exception_entry vector
pushq $\vector
#error 64-bit kernel required!
#endif
+#define JAILHOUSE_BASE 0xfffffffff0000000
+
#define JAILHOUSE_CALL_INS "vmcall"
#define JAILHOUSE_CALL_RESULT "=a" (result)
#define JAILHOUSE_CALL_NUM "a" (num)
#define JAILHOUSE_CALL_ARG3 "d" (arg3)
#define JAILHOUSE_CALL_ARG4 "c" (arg4)
+#ifndef __ASSEMBLY__
+
static inline __u32 jailhouse_call0(__u32 num)
{
__u32 result;
asm volatile("mfence" : : : "memory");
comm_region->reply_from_cell = reply;
}
+
+#endif /* !__ASSEMBLY__ */
*/
#include <asm/paging.h>
+#include <asm/jailhouse_hypercall.h>
SECTIONS
{
- . = 0;
+ . = JAILHOUSE_BASE;
.header : { *(.header) }
. = ALIGN(16);
. = ALIGN(16);
.data : { *(.data) }
- .got : {
- __got_start = .;
- *(.got*)
- __got_end = .;
- }
-
. = ALIGN(16);
.bss : { *(.bss) }
__hv_core_end = .;
extern struct jailhouse_header hypervisor_header;
extern void *config_memory;
-int arch_entry(int cpu_id);
-void got_init(void);
+int arch_entry(unsigned int cpu_id);
void vm_exit(void);
int entry(struct per_cpu *cpu_data);
char signature[8];
unsigned long core_size;
unsigned long percpu_size;
- unsigned long entry;
+ int (*entry)(unsigned int);
/* filled by loader */
unsigned long size;
unsigned int possible_cpus;
unsigned int online_cpus;
};
-
-typedef int (*entry_func)(unsigned int);
master_cpu_id = cpu_id;
- /* must be first, printk/arch_dbg_write uses the GOT */
- got_init();
-
arch_dbg_write_init();
printk("\nInitializing Jailhouse hypervisor on CPU %d\n", cpu_id);
struct jailhouse_header __attribute__((section(".header")))
hypervisor_header = {
.signature = JAILHOUSE_SIGNATURE,
- .core_size = (unsigned long)__hv_core_end,
+ .core_size = (unsigned long)__hv_core_end - JAILHOUSE_BASE,
.percpu_size = sizeof(struct per_cpu),
- .entry = (unsigned long)arch_entry,
+ .entry = arch_entry,
};
(cpu) = cell_cpumask_next((cpu), (config)), \
(cpu) < (config)->cpu_set_size * 8;)
-#ifdef CONFIG_X86
-#define JAILHOUSE_BASE 0xfffffffff0000000
-#elif defined(CONFIG_ARM)
-#define JAILHOUSE_BASE 0xe0000000
-#else
-#error Unsupported architecture
-#endif
-
static void *jailhouse_ioremap(phys_addr_t phys, unsigned long virt,
unsigned long size)
{
static void enter_hypervisor(void *info)
{
struct jailhouse_header *header = info;
- entry_func entry;
int err;
- entry = (entry_func)(hypervisor_mem + header->entry);
-
/* either returns 0 or the same error code across all CPUs */
- err = entry(smp_processor_id());
+ err = header->entry(smp_processor_id());
if (err)
error_code = err;