-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Eric Chan <[email protected]>
- Loading branch information
1 parent
26f6bdb
commit 8d3f665
Showing
13 changed files
with
399 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright 2024, UNSW | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
#pragma once | ||
|
||
#include <microkit.h> | ||
#include <stdint.h> | ||
|
||
/* This sets up the resources needed by a userspace driver. Includes registering | ||
* the uio virq and vmm notify region. The uio driver will write into the notify | ||
* region in order to transfer execution to the VMM for it to then notify other | ||
* microkit components. | ||
*/ | ||
bool uio_register_driver(int irq, microkit_channel *ch, | ||
uintptr_t notify_region_base, | ||
size_t notify_region_size); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
/* | ||
* Copyright 2024, UNSW | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#include <libvmm/arch/aarch64/fault.h> | ||
#include <libvmm/util/util.h> | ||
#include <libvmm/virq.h> | ||
#include <microkit.h> | ||
#include <stddef.h> | ||
#include <stdint.h> | ||
|
||
bool uio_notify_fault_handle(size_t vcpu_id, size_t offset, size_t fsr, | ||
seL4_UserContext *regs, void *data) { | ||
microkit_channel ch = *(microkit_channel *)data; | ||
if (fault_is_read(fsr)) { | ||
LOG_VMM_ERR( | ||
"Read into VMM notify region, but uio driver should never do that\n"); | ||
return false; | ||
} else { | ||
microkit_notify(ch); | ||
} | ||
return true; | ||
} | ||
|
||
void uio_ack(size_t vcpu_id, int irq, void *cookie) { | ||
/* Do nothing for UIO ack */ | ||
} | ||
|
||
bool uio_register_driver(int irq, microkit_channel *ch, | ||
uintptr_t notify_region_base, | ||
size_t notify_region_size) { | ||
bool success = virq_register(GUEST_VCPU_ID, irq, uio_ack, NULL); | ||
assert(success); | ||
success = fault_register_vm_exception_handler( | ||
notify_region_base, notify_region_size, &uio_notify_fault_handle, ch); | ||
if (!success) { | ||
LOG_VMM_ERR("Could not register uio virtual memory fault handler for " | ||
"uio notify region [0x%lx..0x%lx)\n", | ||
notify_region_base, notify_region_base + notify_region_size); | ||
return false; | ||
} | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.