cross_vm_connectors: Add a device name register
The event PCI BAR allocates a 4K frame but only uses the first 8 bytes
for sending and receiving events. The next 50 bytes are now used to
store a device name that a guest OS can use to identify different
devices.
A default of "connector" is used because this was the name that the
Linux kernel module would give to all devices before this change.
diff --git a/libsel4vmmplatsupport/include/sel4vmmplatsupport/drivers/cross_vm_connection.h b/libsel4vmmplatsupport/include/sel4vmmplatsupport/drivers/cross_vm_connection.h
index da8ff9b..df4cad4 100644
--- a/libsel4vmmplatsupport/include/sel4vmmplatsupport/drivers/cross_vm_connection.h
+++ b/libsel4vmmplatsupport/include/sel4vmmplatsupport/drivers/cross_vm_connection.h
@@ -55,6 +55,7 @@
crossvm_dataport_handle_t *dataport;
emit_fn emit_fn;
seL4_Word consume_id;
+ const char *connection_name;
} crossvm_handle_t;
/***
diff --git a/libsel4vmmplatsupport/src/drivers/cross_vm_connection.c b/libsel4vmmplatsupport/src/drivers/cross_vm_connection.c
index d875175..dde6f3b 100644
--- a/libsel4vmmplatsupport/src/drivers/cross_vm_connection.c
+++ b/libsel4vmmplatsupport/src/drivers/cross_vm_connection.c
@@ -35,6 +35,8 @@
#define EVENT_BAR_EMIT_REGISTER_INDEX 0
#define EVENT_BAR_CONSUME_EVENT_REGISTER 0x4
#define EVENT_BAR_CONSUME_EVENT_REGISTER_INDEX 1
+#define EVENT_BAR_DEVICE_NAME_REGISTER 0x8
+#define EVENT_BAR_DEVICE_NAME_MAX_LEN 50
struct connection_info {
uintptr_t event_address;
@@ -291,6 +293,12 @@
return -1;
}
info[i].connection = connections[i];
+ if (connections[i].connection_name == NULL) {
+ connections[i].connection_name = "connector";
+ }
+ strncpy(info[i].event_registers + EVENT_BAR_DEVICE_NAME_REGISTER, connections[i].connection_name,
+ EVENT_BAR_DEVICE_NAME_MAX_LEN);
+
connection_curr_addr += dataport_size;
}
return 0;