mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-25 06:51:49 +00:00
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 <kaige.fu@intel.com> Reviewed-by: Eddie Dong <eddie.dong@intel.com> Reviewed-by: Yan, Like <like.yan@intel.com>
This commit is contained in:
parent
9f13a51e8a
commit
e555f75b8d
@ -19,57 +19,10 @@ struct logmsg {
|
|||||||
|
|
||||||
static struct logmsg 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)
|
void init_logmsg(uint32_t flags)
|
||||||
{
|
{
|
||||||
uint16_t pcpu_id;
|
|
||||||
|
|
||||||
logmsg.flags = flags;
|
logmsg.flags = flags;
|
||||||
logmsg.seq = 0;
|
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, ...)
|
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 */
|
/* Check if flags specify to output to memory */
|
||||||
if (do_mem_log) {
|
if (do_mem_log) {
|
||||||
unsigned int i, msg_len;
|
unsigned int i, msg_len;
|
||||||
struct shared_buf *sbuf = (struct shared_buf *)
|
struct shared_buf *sbuf = (struct shared_buf *)per_cpu(sbuf, pcpu_id)[ACRN_HVLOG];
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/* If sbuf is not ready, we just drop the massage */
|
||||||
if (sbuf != NULL) {
|
if (sbuf != NULL) {
|
||||||
msg_len = strnlen_s(buffer, LOG_MESSAGE_MAX_SIZE);
|
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);
|
|
||||||
}
|
|
||||||
|
@ -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_ptdev_info(__unused int argc, __unused char **argv);
|
||||||
static int shell_show_vioapic_info(int argc, 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_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_loglevel(int argc, char **argv);
|
||||||
static int shell_cpuid(int argc, char **argv);
|
static int shell_cpuid(int argc, char **argv);
|
||||||
static int shell_trigger_crash(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,
|
.help_str = SHELL_CMD_IOAPIC_HELP,
|
||||||
.fcn = shell_show_ioapic_info,
|
.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,
|
.str = SHELL_CMD_LOG_LVL,
|
||||||
.cmd_param = SHELL_CMD_LOG_LVL_PARAM,
|
.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;
|
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)
|
static int shell_loglevel(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char str[MAX_STR_SIZE] = {0};
|
char str[MAX_STR_SIZE] = {0};
|
||||||
|
@ -78,10 +78,6 @@ struct shell {
|
|||||||
#define SHELL_CMD_VIOAPIC_PARAM "<vm id>"
|
#define SHELL_CMD_VIOAPIC_PARAM "<vm id>"
|
||||||
#define SHELL_CMD_VIOAPIC_HELP "show vioapic info"
|
#define SHELL_CMD_VIOAPIC_HELP "show vioapic info"
|
||||||
|
|
||||||
#define SHELL_CMD_LOGDUMP "logdump"
|
|
||||||
#define SHELL_CMD_LOGDUMP_PARAM "<pcpu id>"
|
|
||||||
#define SHELL_CMD_LOGDUMP_HELP "log buffer dump"
|
|
||||||
|
|
||||||
#define SHELL_CMD_LOG_LVL "loglevel"
|
#define SHELL_CMD_LOG_LVL "loglevel"
|
||||||
#define SHELL_CMD_LOG_LVL_PARAM "[<console_loglevel> [<mem_loglevel> " \
|
#define SHELL_CMD_LOG_LVL_PARAM "[<console_loglevel> [<mem_loglevel> " \
|
||||||
"[npk_loglevel]]]"
|
"[npk_loglevel]]]"
|
||||||
|
@ -25,8 +25,6 @@ struct per_cpu_region {
|
|||||||
#ifdef HV_DEBUG
|
#ifdef HV_DEBUG
|
||||||
uint64_t *sbuf[ACRN_SBUF_ID_MAX];
|
uint64_t *sbuf[ACRN_SBUF_ID_MAX];
|
||||||
char logbuf[LOG_MESSAGE_MAX_SIZE];
|
char logbuf[LOG_MESSAGE_MAX_SIZE];
|
||||||
bool is_early_logbuf;
|
|
||||||
char early_logbuf[CONFIG_LOG_BUF_SIZE];
|
|
||||||
uint32_t npk_log_ref;
|
uint32_t npk_log_ref;
|
||||||
#endif
|
#endif
|
||||||
uint64_t irq_count[NR_IRQS];
|
uint64_t irq_count[NR_IRQS];
|
||||||
|
Loading…
Reference in New Issue
Block a user