From e555f75b8d540853373636f8fee4a3b777a2be5a Mon Sep 17 00:00:00 2001 From: Kaige Fu Date: Fri, 23 Nov 2018 09:47:18 +0000 Subject: [PATCH] debug: Remove early logbuf support This patch remove early logbuf support which is used to hold log massges before shared buf setup by SOS. Tracked-On: #1801 Signed-off-by: Kaige Fu Reviewed-by: Eddie Dong Reviewed-by: Yan, Like --- hypervisor/debug/logmsg.c | 106 +------------------------- hypervisor/debug/shell.c | 24 ------ hypervisor/debug/shell_priv.h | 4 - hypervisor/include/arch/x86/per_cpu.h | 2 - 4 files changed, 2 insertions(+), 134 deletions(-) diff --git a/hypervisor/debug/logmsg.c b/hypervisor/debug/logmsg.c index d922faadd..34509d171 100644 --- a/hypervisor/debug/logmsg.c +++ b/hypervisor/debug/logmsg.c @@ -19,57 +19,10 @@ struct logmsg { static struct logmsg logmsg; -static inline void init_earlylog_sbuf(uint16_t pcpu_id) -{ - struct shared_buf *sbuf = (struct shared_buf *)per_cpu(early_logbuf, pcpu_id); - uint32_t ele_size = LOG_ENTRY_SIZE; - uint32_t ele_num = ((CONFIG_LOG_BUF_SIZE - SBUF_HEAD_SIZE) / ele_size); - - sbuf->ele_num = ele_num; - sbuf->ele_size = ele_size; - sbuf->size = ele_num * ele_size; - sbuf->magic = SBUF_MAGIC; -} - -static void do_copy_earlylog(struct shared_buf *dst_sbuf, - const struct shared_buf *src_sbuf) -{ - uint32_t buf_size, valid_size; - uint32_t cur_tail; - uint64_t rflags; - - if ((src_sbuf->ele_size != dst_sbuf->ele_size) - && (src_sbuf->ele_num != dst_sbuf->ele_num)) { - spinlock_irqsave_obtain(&(logmsg.lock), &rflags); - printf("Error to copy early hvlog: size mismatch\n"); - spinlock_irqrestore_release(&(logmsg.lock), rflags); - return; - } - - cur_tail = src_sbuf->tail; - buf_size = SBUF_HEAD_SIZE + dst_sbuf->size; - valid_size = SBUF_HEAD_SIZE + cur_tail; - - (void)memcpy_s((void *)dst_sbuf, buf_size, - (void *)src_sbuf, valid_size); - if (dst_sbuf->tail != cur_tail) { - /* there is chance to lose new log from certain pcpu */ - dst_sbuf->tail = cur_tail; - } -} - void init_logmsg(uint32_t flags) { - uint16_t pcpu_id; - logmsg.flags = flags; logmsg.seq = 0; - - /* allocate sbuf for log before sos booting */ - for (pcpu_id = 0U; (pcpu_id < phys_cpu_num) && (pcpu_id < CONFIG_MAX_PCPU_NUM); pcpu_id++) { - init_earlylog_sbuf(pcpu_id); - per_cpu(is_early_logbuf, pcpu_id) = true; - } } void do_logmsg(uint32_t severity, const char *fmt, ...) @@ -135,21 +88,9 @@ void do_logmsg(uint32_t severity, const char *fmt, ...) /* Check if flags specify to output to memory */ if (do_mem_log) { unsigned int i, msg_len; - struct shared_buf *sbuf = (struct shared_buf *) - per_cpu(sbuf, pcpu_id)[ACRN_HVLOG]; - struct shared_buf *early_sbuf = (struct shared_buf *)per_cpu(early_logbuf, pcpu_id); - - if (per_cpu(is_early_logbuf, pcpu_id)) { - if (sbuf != NULL) { - /* switch to sbuf from sos */ - do_copy_earlylog(sbuf, early_sbuf); - per_cpu(is_early_logbuf, pcpu_id) = false; - } else { - /* use earlylog sbuf if no sbuf from sos */ - sbuf = early_sbuf; - } - } + struct shared_buf *sbuf = (struct shared_buf *)per_cpu(sbuf, pcpu_id)[ACRN_HVLOG]; + /* If sbuf is not ready, we just drop the massage */ if (sbuf != NULL) { msg_len = strnlen_s(buffer, LOG_MESSAGE_MAX_SIZE); @@ -161,46 +102,3 @@ void do_logmsg(uint32_t severity, const char *fmt, ...) } } } - -void print_logmsg_buffer(uint16_t pcpu_id) -{ - char buffer[LOG_ENTRY_SIZE + 1]; - uint32_t read_cnt; - struct shared_buf *sbuf; - int is_earlylog = 0; - uint64_t rflags; - - if (pcpu_id >= phys_cpu_num) { - return; - } - - sbuf = (struct shared_buf *)per_cpu(early_logbuf, pcpu_id); - is_earlylog = 1; - - spinlock_irqsave_obtain(&(logmsg.lock), &rflags); - - printf("CPU%hu: head: 0x%x, tail: 0x%x %s\n\r", - pcpu_id, (sbuf)->head, (sbuf)->tail, - (is_earlylog != 0) ? "[earlylog]" : ""); - - spinlock_irqrestore_release(&(logmsg.lock), rflags); - - do { - uint32_t idx; - (void)memset(buffer, 0U, LOG_ENTRY_SIZE + 1U); - - read_cnt = sbuf_get(sbuf, (uint8_t *)buffer); - - if (read_cnt == 0U) { - return; - } - - idx = ((uint32_t)read_cnt < LOG_ENTRY_SIZE) ? - (uint32_t)read_cnt : LOG_ENTRY_SIZE; - buffer[idx] = '\0'; - - spinlock_irqsave_obtain(&(logmsg.lock), &rflags); - printf("%s\n\r", buffer); - spinlock_irqrestore_release(&(logmsg.lock), rflags); - } while (read_cnt > 0U); -} diff --git a/hypervisor/debug/shell.c b/hypervisor/debug/shell.c index 4595bd375..fc48cc224 100644 --- a/hypervisor/debug/shell.c +++ b/hypervisor/debug/shell.c @@ -29,7 +29,6 @@ static int shell_show_cpu_int(__unused int argc, __unused char **argv); static int shell_show_ptdev_info(__unused int argc, __unused char **argv); static int shell_show_vioapic_info(int argc, char **argv); static int shell_show_ioapic_info(__unused int argc, __unused char **argv); -static int shell_dump_logbuf(int argc, char **argv); static int shell_loglevel(int argc, char **argv); static int shell_cpuid(int argc, char **argv); static int shell_trigger_crash(int argc, char **argv); @@ -95,12 +94,6 @@ static struct shell_cmd shell_cmds[] = { .help_str = SHELL_CMD_IOAPIC_HELP, .fcn = shell_show_ioapic_info, }, - { - .str = SHELL_CMD_LOGDUMP, - .cmd_param = SHELL_CMD_LOGDUMP_PARAM, - .help_str = SHELL_CMD_LOGDUMP_HELP, - .fcn = shell_dump_logbuf, - }, { .str = SHELL_CMD_LOG_LVL, .cmd_param = SHELL_CMD_LOG_LVL_PARAM, @@ -1181,23 +1174,6 @@ static int shell_show_ioapic_info(__unused int argc, __unused char **argv) return err; } -static int shell_dump_logbuf(int argc, char **argv) -{ - uint16_t pcpu_id; - int val; - - if (argc == 2) { - val = atoi(argv[1]); - if (val >= 0) { - pcpu_id = (uint16_t)val; - print_logmsg_buffer(pcpu_id); - return 0; - } - } - - return -EINVAL; -} - static int shell_loglevel(int argc, char **argv) { char str[MAX_STR_SIZE] = {0}; diff --git a/hypervisor/debug/shell_priv.h b/hypervisor/debug/shell_priv.h index c7d87cfd3..01c63ca26 100644 --- a/hypervisor/debug/shell_priv.h +++ b/hypervisor/debug/shell_priv.h @@ -78,10 +78,6 @@ struct shell { #define SHELL_CMD_VIOAPIC_PARAM "" #define SHELL_CMD_VIOAPIC_HELP "show vioapic info" -#define SHELL_CMD_LOGDUMP "logdump" -#define SHELL_CMD_LOGDUMP_PARAM "" -#define SHELL_CMD_LOGDUMP_HELP "log buffer dump" - #define SHELL_CMD_LOG_LVL "loglevel" #define SHELL_CMD_LOG_LVL_PARAM "[ [ " \ "[npk_loglevel]]]" diff --git a/hypervisor/include/arch/x86/per_cpu.h b/hypervisor/include/arch/x86/per_cpu.h index 45a7eaa6f..3959021e2 100644 --- a/hypervisor/include/arch/x86/per_cpu.h +++ b/hypervisor/include/arch/x86/per_cpu.h @@ -25,8 +25,6 @@ struct per_cpu_region { #ifdef HV_DEBUG uint64_t *sbuf[ACRN_SBUF_ID_MAX]; char logbuf[LOG_MESSAGE_MAX_SIZE]; - bool is_early_logbuf; - char early_logbuf[CONFIG_LOG_BUF_SIZE]; uint32_t npk_log_ref; #endif uint64_t irq_count[NR_IRQS];