diff --git a/arch/x86_64/kernel/uart.c b/arch/x86_64/kernel/uart.c index 38ce21427..95fdb635f 100644 --- a/arch/x86_64/kernel/uart.c +++ b/arch/x86_64/kernel/uart.c @@ -105,7 +105,7 @@ static inline unsigned char read_from_uart(uint32_t off) { uint8_t c = 0; - if (uartport) + if (!is_uhyve() && uartport) c = inportb(uartport + off); return c; @@ -113,6 +113,9 @@ static inline unsigned char read_from_uart(uint32_t off) static inline int is_transmit_empty(void) { + if (is_uhyve()) + return 1; + if (uartport) return inportb(uartport + UART_LSR) & 0x20; diff --git a/tools/uhyve-x86_64.c b/tools/uhyve-x86_64.c index 0a716454c..6550e2b0a 100644 --- a/tools/uhyve-x86_64.c +++ b/tools/uhyve-x86_64.c @@ -1008,7 +1008,7 @@ int load_kernel(uint8_t* mem, char* path) *((uint32_t*) (mem+paddr-GUEST_OFFSET + 0x30)) = 0; // apicid *((uint32_t*) (mem+paddr-GUEST_OFFSET + 0x60)) = 1; // numa nodes *((uint32_t*) (mem+paddr-GUEST_OFFSET + 0x94)) = 1; // announce uhyve - + *((uint64_t*) (mem+paddr-GUEST_OFFSET + 0x98)) = UHYVE_UART_PORT ; // announce uhyve char* str = getenv("HERMIT_IP"); if (str) { @@ -1042,7 +1042,8 @@ int load_kernel(uint8_t* mem, char* path) *((uint8_t*) (mem+paddr-GUEST_OFFSET + 0xBB)) = (uint8_t) ip[3]; } - *((uint64_t*) (mem+paddr-GUEST_OFFSET + 0xbc)) = guest_mem; + if (verbose) + *((uint64_t*) (mem+paddr-GUEST_OFFSET + 0xbc)) = (uint64_t) guest_mem; } *((uint64_t*) (mem+paddr-GUEST_OFFSET + 0x38)) += memsz; // total kernel size } diff --git a/tools/uhyve.c b/tools/uhyve.c index 699337f9c..d46cd859b 100644 --- a/tools/uhyve.c +++ b/tools/uhyve.c @@ -180,16 +180,6 @@ static void uhyve_exit(void* arg) close_fd(&vcpufd); } -static void dump_log(void) -{ - if (klog && verbose) - { - fputs("\nDump kernel log:\n", stderr); - fputs("================\n", stderr); - fprintf(stderr, "%s\n", klog); - } -} - static void uhyve_atexit(void) { uhyve_exit(NULL); @@ -207,8 +197,6 @@ static void uhyve_atexit(void) if (vcpu_fds) free(vcpu_fds); - dump_log(); - // clean up and close KVM close_fd(&vmfd); close_fd(&kvm); @@ -321,6 +309,10 @@ static int vcpu_loop(void) //printf("port 0x%x\n", run->io.port); switch (port) { + case UHYVE_UART_PORT: + if (verbose) + putc((unsigned char) raddr, stderr); + break; case UHYVE_PORT_WRITE: { uhyve_write_t* uhyve_write = (uhyve_write_t*) (guest_mem+raddr); @@ -471,7 +463,6 @@ static int vcpu_loop(void) case KVM_EXIT_DEBUG: print_registers(); - dump_log(); exit(EXIT_FAILURE); default: diff --git a/tools/uhyve.h b/tools/uhyve.h index 126a9a427..e52b68641 100644 --- a/tools/uhyve.h +++ b/tools/uhyve.h @@ -48,6 +48,8 @@ #define UHYVE_PORT_CMDSIZE 0x740 #define UHYVE_PORT_CMDVAL 0x780 +#define UHYVE_UART_PORT 0x800 + #define UHYVE_IRQ 11 #define kvm_ioctl(fd, cmd, arg) ({ \