-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vm-arm: inline memory initializtion module #68
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -679,6 +679,31 @@ static void irq_handler(void *data, ps_irq_acknowledge_fn_t acknowledge_fn, void | |
} | ||
} | ||
|
||
/* Default RAM initialization. Modules can overwrite this weak function with a | ||
* custom initialization, e.g. to use memory shared with other components or | ||
* mapped on demand. | ||
*/ | ||
WEAK int vm_init_ram(vm_t *vm, const vm_config_t *vm_config) | ||
{ | ||
/* A VM without RAM is highly unusual and unlikely to work. But there might | ||
* be special VM configurations where modules create specific RAM areas. In | ||
* this case, this weak RAM init function here should be overwritten also, | ||
* that's why we print the warning. | ||
*/ | ||
if (0 == vm_config->ram.size) { | ||
ZF_LOGW("no standard RAM defined"); | ||
return 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was under illusion that we agreed that all systems have some RAM, even if very small amount. Now this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've kept this with the comment as sanity check. But I can remove it also completely. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another option is to put this check to And I have to nag about style issue once again. Could you use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will create a PR that adds a sanity check in |
||
} | ||
|
||
int err = vm_ram_register_at(vm, vm_config->ram.base, vm_config->ram.size, | ||
vm->mem.map_one_to_one); | ||
if (err) { | ||
ZF_LOGE("RAM registration failed (%d)", err); | ||
axel-h marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return -1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about returning There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if we have global error codes that each caller can make sense on. So that is why I think it is better if each specific function prints the error and then returns a generic error to the caller, as the caller may not make much sende of the specific error code. But in non-debug builds the error code would get lost then, so you have a point there, that we should change this in the whole file to ensure error codes bubble up and there is a change to have them in non-debug builds also at the top level. |
||
} | ||
|
||
return 0; | ||
} | ||
|
||
/* Force the _vmm_module section to be created even if no modules are defined. */ | ||
static USED SECTION("_vmm_module") struct {} dummy_module; | ||
|
@@ -689,6 +714,13 @@ static int install_vm_devices(vm_t *vm, const vm_config_t *vm_config) | |
{ | ||
int err; | ||
|
||
/* Initialize guest RAM. */ | ||
err = vm_init_ram(vm, vm_config); | ||
if (err) { | ||
ZF_LOGE("Failed to initialize RAM (%d)", err); | ||
return -1; | ||
} | ||
|
||
/* Install virtual devices */ | ||
if (config_set(CONFIG_VM_PCI_SUPPORT)) { | ||
err = vm_install_vpci(vm, io_ports, pci); | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you renamed
init_ram_module()
tovm_init_ram()
. This means at leastvm_introspect
example in https://github.com/seL4/camkes-vm-examples gets broken (it is broken currently for other reasons, but that's another story). Perhaps some code we don't know of.Personally I'm not against breaking the ABI but others might be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The different name is intentional, it's based on you last comment that changing the signature of an existing function is not a good idea. It this PR gets merged, I will create an issue for
vm_introspect
so this gets adapted.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think seL4/camkes-vm-examples#39 will fix the brokenness you are referring to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good spotting but not exactly: at some point CAmkES started using as large as possible frames for dataports. Hence if you had more than 2 MB dataport, it uses ARM large pages. On the other hand, currently VMM always uses 4 kB pages in
vm_ram_touch()
. To be able to use 2 MB pages from dataport as guest RAM, we use this kind of hack in tiiuae/seL4_projects_libs@fa99679.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to add that you need to use large pages here as well: https://github.com/seL4/camkes-vm-examples/blob/master/apps/Arm/vm_introspect/src/init_dataport_ram.c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hlyytine: Could you create an issue in https://github.com/seL4/camkes-vm-examples to track this?