Skip to content
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

Multiple OS Support #48

Merged
merged 5 commits into from
Mar 7, 2023
Merged

Multiple OS Support #48

merged 5 commits into from
Mar 7, 2023

Conversation

chrisguikema
Copy link
Contributor

@chrisguikema chrisguikema force-pushed the multiple_os branch 2 times, most recently from 3257659 to 9f72dee Compare October 27, 2022 00:40
Copy link
Member

@axel-h axel-h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to get merged now for me.

@chrisguikema
Copy link
Contributor Author

Thanks for the review, Axel. Appreciate it!

@axel-h
Copy link
Member

axel-h commented Feb 22, 2023

Thanks for the review, Axel. Appreciate it!

The stuff in these PR is really useful and having all these config option do avoid some hacks on our side, too. Also, now that I have looked into this again, this explains some things I have been really wondering about...

string linux_ram_paddr_base; \
string linux_ram_size; \
string linux_ram_offset; \
string ram_base; \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are doing a breaking change here anyway, I wonder if we should also change stringto uint64_t here. There seems no point why these are string, except that in the past this was necessary because uint64_t did not exist.

@@ -856,7 +864,7 @@ static int load_vm(vm_t *vm, const char *kernel_name, const char *dtb_name, cons

/* Attempt to load initrd if provided */
guest_image_t initrd_image;
if (config_set(CONFIG_VM_INITRD_FILE)) {
if (vm_image_config.provide_initrd) {
Copy link
Contributor

@hlyytine hlyytine Mar 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about just if (strlen(initrd_name))? Then you could set initrd_name to empty string in CAmkES file to not load any. No need to introduce additional option.

Copy link
Member

@axel-h axel-h Mar 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that would be sufficient to keep the config options lighter. Should we put this into

string initrd_name = "linux-initrd"; \
then:

string initrd_name = ""; /* no inird by default */ \

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @chrisguikema for stealing the show, but let me show how I think this per-VM initrd is handled best: #59.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Figured out we still have 3 special cases for guest's data blobs: kernel, DTB and initrd. I got an idea how to write that in a more generic way and remove lots of code from VM. Please give me a day or two so I can show my suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the review, Hannu, and I also appreciate that you're creating new MRs that address your comments

@@ -865,7 +873,10 @@ static int load_vm(vm_t *vm, const char *kernel_name, const char *dtb_name, cons
}
}

if (!config_set(CONFIG_VM_DTB_FILE)) {
ZF_LOGW_IF(vm_image_config.provide_dtb && vm_image_config.generate_dtb,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about getting rid of both these booleans and reserving some magic string for autogeneration. For example, setting dtb_name to <generate> is not a likely filename since it would create havoc in build systems due to < and > being shell redirections. The second case is leaving dtb_name empty and no DTB is loaded. Any other string should be considered a filename.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, there are multiple options, see also my comment #48 (comment), so using your proposal we'd have:

  • don't provide DTB. Could be dtb_name = ""
  • provide a fixed TB from dtb_name. Do not modify it. Could be dtb_name = "some.dtb"
  • generate as DTB from scratch. Could be dtb_name = "<generate>"
  • generate as DTB based on a give DTB. Should this be handled via dtb_name = "<generate>some.dtb"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

  • Don't provide DTB: dtb_name = ""
  • Provide fixed DTB: dtb_name = "some.dtb"
  • Generate from scratch: dtb_name = "<"
  • Generate from given DTB: dtb_name = "<some.dtb"

Note dropped > at the end. Now you can just check if first character is <, if yes, use the remaining string (which might be empty) as filename. No need for error prone string copies. Any other character than < would be fine to me, as long as it is unlikely to appear in real world filenames.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks nice actually. We just have to clearly document this somewhere then also.

@chrisguikema chrisguikema force-pushed the multiple_os branch 2 times, most recently from 3498826 to d4e6dfc Compare March 6, 2023 21:41
unsigned long initrd_max_size = /*? vm_address_config.get('initrd_max_size') ?*/;
unsigned long initrd_addr = /*? vm_address_config.get('initrd_addr') ?*/;

/*- if vm_address_config.get('kernel_entry_addr') != '-1' -*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since vm_address_config is really new, why do we want to still support "-1" then at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to be set or else it will cause an KeyError during the init-build.sh script. So keeping the -1 default value allows for the automatic calculation to function if its not set by the user.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No sure I follow, wan't the point that we want the user to set this explicitly in the configuration, so it's more transparent what happens and there is less magic at the bottom? We could have an explicit linux template that provides defaults for Linux VMs, so users can use this one. Or a flag that says it's a linux kernel, which then enabled these well known defaults and maybe more convenince features. Also, it could be addressed in a meta VM creation system, that has more insight about the actual VMs, like the "vm composer" you have.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm saying that every member of the vm_address_config struct must have a value or the init-build.sh script will fail. We want to encourage the users to explicitly set the value, so when it is not set, CAmkES calculates a default, based off linux's offset, and the following warning will appear:

[258/305] Building C object CMakeFiles/vm0.instance.bin.dir/vm0/seL4VMParameters.template.c.obj
vm0/seL4VMParameters.template.c:27:2: warning: #warning Entry address has been calculated. Please use vm_address_config.kernel_entry_addr [-Wcpp]
   27 | #warning Entry address has been calculated. Please use vm_address_config.kernel_entry_addr
      |  ^~~~~~~

We need the -1 default value because if the user didn't set the value, the configuration wouldn't even be able to compile. The #warning is what encourages the user to set the value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. So I wonder, should the complete macro VM_INIT_DEF() be deprecated then? It is creating a vm_address_config and a linux_address_config block now, which seems a bit odd. Is it somehow possible to not have it create a vm_address_config block and then print a warning if that it's outdated? And there is another new macro (maybe VM_GENERIC_INIT_DEF()) to be used that creates only a vm_address_config now. And if this new macro is used, the all fields must be set by the user?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we have a version, like Hannu was suggesting, we can only include the necessary attribute. So for now this is okay, but we can make that part of the next discussion.

@chrisguikema chrisguikema force-pushed the multiple_os branch 2 times, most recently from 05ac8ee to 35032be Compare March 7, 2023 00:25
The VMM can run other Operating Systems, so referencing Linux isn't
necessarily correct. In order to maintain backwards compatibility, a new
template was created to set the address parameters during compile time.
The template first pulls from vm_XXXX_config, but if that structure
isn't available, it will pull from linux_XXXX_config.

Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
This commit allows the vm_arm component to run multiple OSs by removing
cmake variables and replacing them with camkes variables. Since cmake
variables apply to the entire project, this forces a system with two
VMs to each apply the CMake variables, which could break one of the
VMs. By replacing the variables with camkes flags, the functionality
remains, while allowing for more flexibility.

Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
This markdown document overviews how to configure a guest's address
space.

Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
ram_offset and initrd_max_size were not used in the VMM. Since there is
a new configuration block, its safe to remove the attributes

Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
These are now defined in the camkes configuration and are not needed in
the vmlinux.h header files.

Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
@kent-mcleod
Copy link
Member

@chrisguikema Can you let me know if you're ready for these 3 PRs to be merged.

@chrisguikema
Copy link
Contributor Author

Yeah I'm all good on my end!

@kent-mcleod kent-mcleod merged commit 03d8c3d into seL4:master Mar 7, 2023
@chrisguikema chrisguikema deleted the multiple_os branch March 7, 2023 14:19
hlyytine added a commit to tiiuae/tii-sel4-vm that referenced this pull request Mar 22, 2023
seL4/camkes-vm#48 made this possible.

Signed-off-by: Hannu Lyytinen <hannux@ssrc.tii.ae>
hlyytine added a commit to tiiuae/tii-sel4-vm that referenced this pull request Mar 24, 2023
seL4/camkes-vm#48 made this possible.

Signed-off-by: Hannu Lyytinen <hannux@ssrc.tii.ae>
hlyytine added a commit to tiiuae/tii-sel4-vm that referenced this pull request Mar 24, 2023
seL4/camkes-vm#48 made this possible.

Signed-off-by: Hannu Lyytinen <hannux@ssrc.tii.ae>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants