mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-18 10:46:25 +00:00
hw_x86_64_muen: Add support for mem content to sinfo
This commit is contained in:
parent
98ac87caf4
commit
c16aa05f19
@ -35,19 +35,29 @@ class Genode::Sinfo
|
||||
|
||||
enum Config {
|
||||
PHYSICAL_BASE_ADDR = 0xe00000000,
|
||||
SIZE = 0x7000,
|
||||
SIZE = 0x9000,
|
||||
MAX_NAME_LENGTH = 63,
|
||||
HASH_LENGTH = 32,
|
||||
};
|
||||
|
||||
Sinfo(const addr_t base_addr);
|
||||
|
||||
enum Content {
|
||||
CONTENT_UNINITIALIZED,
|
||||
CONTENT_FILL,
|
||||
CONTENT_FILE,
|
||||
};
|
||||
|
||||
/* Structure holding information about a memory region */
|
||||
struct Memregion_info {
|
||||
enum Content content;
|
||||
char name[MAX_NAME_LENGTH + 1];
|
||||
uint64_t address;
|
||||
uint64_t size;
|
||||
bool writable;
|
||||
bool executable;
|
||||
uint8_t hash[HASH_LENGTH];
|
||||
uint16_t pattern;
|
||||
};
|
||||
|
||||
/* Structure holding information about a Muen channel */
|
||||
|
@ -15,9 +15,10 @@
|
||||
#define _LIB__MUEN__MUSINFO_H_
|
||||
|
||||
#include <base/stdint.h>
|
||||
#include <muen/sinfo.h>
|
||||
|
||||
#define MUEN_SUBJECT_INFO_MAGIC 0x01006f666e69756dULL
|
||||
#define MAX_NAME_LENGTH 63
|
||||
|
||||
#define MAX_RESOURCE_COUNT 255
|
||||
#define NO_RESOURCE 0
|
||||
|
||||
@ -25,17 +26,20 @@ using namespace Genode;
|
||||
|
||||
struct name_type {
|
||||
uint8_t length;
|
||||
char data[MAX_NAME_LENGTH];
|
||||
char data[Sinfo::MAX_NAME_LENGTH];
|
||||
} __attribute__((packed));
|
||||
|
||||
#define MEM_WRITABLE_FLAG (1 << 0)
|
||||
#define MEM_EXECUTABLE_FLAG (1 << 1)
|
||||
|
||||
struct memregion_type {
|
||||
enum Sinfo::Content content;
|
||||
uint64_t address;
|
||||
uint64_t size;
|
||||
uint8_t hash[Sinfo::HASH_LENGTH];
|
||||
uint8_t flags;
|
||||
char padding[7];
|
||||
uint16_t pattern;
|
||||
char padding[1];
|
||||
} __attribute__((packed, aligned (8)));
|
||||
|
||||
#define CHAN_EVENT_FLAG (1 << 0)
|
||||
|
@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
#include <base/log.h>
|
||||
#include <base/snprintf.h>
|
||||
#include <util/string.h>
|
||||
|
||||
#include <muen/sinfo.h>
|
||||
@ -40,15 +41,48 @@ static bool log_channel(
|
||||
}
|
||||
|
||||
|
||||
static const char * const content_names[] = {
|
||||
"uninitialized", "fill", "file",
|
||||
};
|
||||
|
||||
uint8_t no_hash[Sinfo::HASH_LENGTH] = {0};
|
||||
|
||||
/* Return true if given buffer contains a hash */
|
||||
static bool hash_available(const uint8_t * const first)
|
||||
{
|
||||
return memcmp(first, no_hash, Sinfo::HASH_LENGTH) != 0;
|
||||
}
|
||||
|
||||
|
||||
/* Convert given hash to hex string */
|
||||
static const char * const hash_to_hex(char *buffer, const unsigned char *first)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < Sinfo::HASH_LENGTH; i++)
|
||||
snprintf(&buffer[i * 2], 3, "%02x", (unsigned int)*first++);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
/* Log memory region information */
|
||||
static bool log_memregion(const struct Genode::Sinfo::Memregion_info * const region,
|
||||
void *data)
|
||||
{
|
||||
Genode::log("muen-sinfo: [addr ", Genode::Hex(region->address), " "
|
||||
"size ", Genode::Hex(region->size), " ",
|
||||
char hash_str[65];
|
||||
|
||||
Genode::log("muen-sinfo: [", content_names[region->content],
|
||||
", addr ", Genode::Hex(region->address),
|
||||
" size ", Genode::Hex(region->size), " ",
|
||||
region->writable ? "rw" : "ro",
|
||||
region->executable ? "x" : "-",
|
||||
"] ", region->name);
|
||||
|
||||
if (region->content == Sinfo::CONTENT_FILL)
|
||||
Genode::log("muen-sinfo: [pattern ", region->pattern, "]");
|
||||
if (hash_available(region->hash))
|
||||
Genode::log("muen-sinfo: [hash 0x",
|
||||
hash_to_hex(hash_str, region->hash), "]");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -233,8 +267,12 @@ void Sinfo::fill_memregion_data(uint8_t idx, struct Memregion_info *region)
|
||||
memset(®ion->name, 0, MAX_NAME_LENGTH + 1);
|
||||
memcpy(®ion->name, resource.name.data, resource.name.length);
|
||||
|
||||
memcpy(®ion->hash, memregion.hash, HASH_LENGTH);
|
||||
|
||||
region->content = memregion.content;
|
||||
region->address = memregion.address;
|
||||
region->size = memregion.size;
|
||||
region->pattern = memregion.pattern;
|
||||
region->writable = memregion.flags & MEM_WRITABLE_FLAG;
|
||||
region->executable = memregion.flags & MEM_EXECUTABLE_FLAG;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user