63 const size_t max_length = end -
base;
66 if (max_length <
sizeof(
de)) {
67 warn(
"Malformed dmesg entry\n");
76 if (
de.len <
sizeof(
de) ||
77 max_length <
de.len ||
80 warn(
"Malformed dmesg entry:\n");
81 warn(
"\tMax length: %i\n", max_length);
82 warn(
"\tde.len: %i\n",
de.len);
83 warn(
"\tde.text_len: %i\n",
de.text_len);
88 os.write((
char *)
base +
sizeof(
de),
de.text_len);
98 const ByteOrder
bo =
system->getGuestByteOrder();
99 const auto &symtab =
system->workload->symtab(tc);
102 auto lb = symtab.find(
"__log_buf");
103 auto lb_len = symtab.find(
"log_buf_len");
104 auto first = symtab.find(
"log_first_idx");
105 auto next = symtab.find(
"log_next_idx");
107 auto end_it = symtab.end();
109 if (lb == end_it || lb_len == end_it ||
110 first == end_it || next == end_it) {
111 warn(
"Failed to find kernel dmesg symbols.\n");
115 uint32_t log_buf_len = proxy.
read<uint32_t>(lb_len->address,
bo);
116 uint32_t log_first_idx = proxy.
read<uint32_t>(first->address,
bo);
117 uint32_t log_next_idx = proxy.
read<uint32_t>(next->address,
bo);
119 if (log_first_idx >= log_buf_len || log_next_idx >= log_buf_len) {
120 warn(
"dmesg pointers/length corrupted\n");
127 if (log_first_idx < log_next_idx) {
128 length = log_next_idx - log_first_idx;
129 if (length < 0 || length > log_buf.size()) {
130 warn(
"Unexpected dmesg buffer length\n");
133 proxy.
readBlob(lb->address + log_first_idx, log_buf.data(), length);
135 const int length_2 = log_buf_len - log_first_idx;
136 if (length_2 < 0 || length_2 + log_next_idx > log_buf.size()) {
137 warn(
"Unexpected dmesg buffer length\n");
140 length = log_buf_len;
141 proxy.
readBlob(lb->address + log_first_idx, log_buf.data(), length_2);
142 proxy.
readBlob(lb->address, log_buf.data() + length_2, log_next_idx);
146 const uint8_t *cur = log_buf.data(), *end = log_buf.data() + length;