64 const size_t max_length = end -
base;
67 if (max_length <
sizeof(
de)) {
68 warn(
"Malformed dmesg entry\n");
77 if (
de.len <
sizeof(
de) ||
78 max_length <
de.len ||
81 warn(
"Malformed dmesg entry:\n");
82 warn(
"\tMax length: %i\n", max_length);
83 warn(
"\tde.len: %i\n",
de.len);
84 warn(
"\tde.text_len: %i\n",
de.text_len);
89 os.write((
char *)
base +
sizeof(
de),
de.text_len);
99 const ByteOrder
bo =
system->getGuestByteOrder();
100 const auto &symtab =
system->workload->symtab(tc);
103 auto lb = symtab.find(
"__log_buf");
104 auto lb_len = symtab.find(
"log_buf_len");
105 auto first = symtab.find(
"log_first_idx");
106 auto next = symtab.find(
"log_next_idx");
108 auto end_it = symtab.end();
110 if (lb == end_it || lb_len == end_it ||
111 first == end_it || next == end_it) {
112 warn(
"Failed to find kernel dmesg symbols.\n");
116 uint32_t log_buf_len = proxy.
read<uint32_t>(lb_len->address,
bo);
117 uint32_t log_first_idx = proxy.
read<uint32_t>(first->address,
bo);
118 uint32_t log_next_idx = proxy.
read<uint32_t>(next->address,
bo);
120 if (log_first_idx >= log_buf_len || log_next_idx >= log_buf_len) {
121 warn(
"dmesg pointers/length corrupted\n");
128 if (log_first_idx < log_next_idx) {
129 length = log_next_idx - log_first_idx;
130 if (length < 0 || length > log_buf.size()) {
131 warn(
"Unexpected dmesg buffer length\n");
134 proxy.
readBlob(lb->address + log_first_idx, log_buf.data(), length);
136 const int length_2 = log_buf_len - log_first_idx;
137 if (length_2 < 0 || length_2 + log_next_idx > log_buf.size()) {
138 warn(
"Unexpected dmesg buffer length\n");
141 length = log_buf_len;
142 proxy.
readBlob(lb->address + log_first_idx, log_buf.data(), length_2);
143 proxy.
readBlob(lb->address, log_buf.data() + length_2, log_next_idx);
147 const uint8_t *cur = log_buf.data(), *end = log_buf.data() + length;