40 #include "config/the_isa.hh"
59 const size_t max_length = end -
base;
62 if (max_length <
sizeof(
de)) {
63 warn(
"Malformed dmesg entry\n");
72 if (
de.len <
sizeof(
de) ||
73 max_length <
de.len ||
76 warn(
"Malformed dmesg entry:\n");
77 warn(
"\tMax length: %i\n", max_length);
78 warn(
"\tde.len: %i\n",
de.len);
79 warn(
"\tde.text_len: %i\n",
de.text_len);
84 os.write((
char *)
base +
sizeof(
de),
de.text_len);
94 const ByteOrder
bo =
system->getGuestByteOrder();
95 const auto &symtab =
system->workload->symtab(tc);
98 auto lb = symtab.find(
"__log_buf");
99 auto lb_len = symtab.find(
"log_buf_len");
100 auto first = symtab.find(
"log_first_idx");
101 auto next = symtab.find(
"log_next_idx");
103 auto end_it = symtab.end();
105 if (lb == end_it || lb_len == end_it ||
106 first == end_it || next == end_it) {
107 warn(
"Failed to find kernel dmesg symbols.\n");
111 uint32_t log_buf_len = proxy.
read<uint32_t>(lb_len->address,
bo);
112 uint32_t log_first_idx = proxy.
read<uint32_t>(first->address,
bo);
113 uint32_t log_next_idx = proxy.
read<uint32_t>(next->address,
bo);
115 if (log_first_idx >= log_buf_len || log_next_idx >= log_buf_len) {
116 warn(
"dmesg pointers/length corrupted\n");
123 if (log_first_idx < log_next_idx) {
124 length = log_next_idx - log_first_idx;
125 if (length < 0 || length > log_buf.size()) {
126 warn(
"Unexpected dmesg buffer length\n");
129 proxy.
readBlob(lb->address + log_first_idx, log_buf.data(),
length);
131 const int length_2 = log_buf_len - log_first_idx;
132 if (length_2 < 0 || length_2 + log_next_idx > log_buf.size()) {
133 warn(
"Unexpected dmesg buffer length\n");
137 proxy.
readBlob(lb->address + log_first_idx, log_buf.data(), length_2);
138 proxy.
readBlob(lb->address, log_buf.data() + length_2, log_next_idx);
142 const uint8_t *cur = log_buf.data(), *end = log_buf.data() +
length;