-
Notifications
You must be signed in to change notification settings - Fork 97
virtio: add device tree support #1006
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
8b771c3
6438bc9
924bca0
eaa0e57
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 |
|---|---|---|
|
|
@@ -59,7 +59,8 @@ pub const ANY_NATIVE_COMPATIBILITY_MASK: u32 = NATIVE_COMPATIBILITY_MASK | VSM_C | |
| const IGVM_GENERAL_PARAMS_PA: u32 = 0; | ||
| const IGVM_MEMORY_MAP_PA: u32 = 1; | ||
| const IGVM_MADT_PA: u32 = 2; | ||
| const IGVM_PARAMETER_COUNT: u32 = 3; | ||
| const IGVM_DT_PA: u32 = 3; | ||
| const IGVM_PARAMETER_COUNT: u32 = 4; | ||
|
Member
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. So now this is 4 for all hypervisor, but DT is used only with QEMU. Is this okay?
Collaborator
Author
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. For qemu IIRC this is not a problem. We had this "issue" in the past with MADT support. |
||
|
|
||
| const _: () = assert!(size_of::<BootParamBlock>() as u64 <= PAGE_SIZE_4K); | ||
| const _: () = assert!(size_of::<InitialGuestContext>() as u64 <= PAGE_SIZE_4K); | ||
|
|
@@ -265,6 +266,14 @@ impl IgvmBuilder { | |
| .gpa_map | ||
| .boot_param_layout | ||
| .get_param_size(BootParamType::Madt), | ||
| dt_offset: self | ||
| .gpa_map | ||
| .boot_param_layout | ||
| .get_param_offset(BootParamType::DeviceTree), | ||
| dt_size: self | ||
| .gpa_map | ||
| .boot_param_layout | ||
| .get_param_size(BootParamType::DeviceTree), | ||
| guest_context_offset: self | ||
| .gpa_map | ||
| .boot_param_layout | ||
|
|
@@ -488,6 +497,18 @@ impl IgvmBuilder { | |
| parameter_area_index: IGVM_MADT_PA, | ||
| initial_data: vec![], | ||
| }); | ||
| if self | ||
| .gpa_map | ||
| .boot_param_layout | ||
| .get_param_size(BootParamType::DeviceTree) | ||
| != 0 | ||
| { | ||
| self.directives.push(IgvmDirectiveHeader::ParameterArea { | ||
| number_of_bytes: PAGE_SIZE_4K, | ||
|
Member
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. Why this is hard coded? Also why that value.
Collaborator
Author
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. good question. I think 4k should be more than enough for a full device tree. Currently DT size is around ~1k. This is why I chose this value. Do you have something else in mind?
Member
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. why need to be a fixed size ?
Member
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. For example for MADT we have: Why we can't do the same here?
Collaborator
Author
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. IIUC this is how igvm works, you tell the HV how much memory you want to allocate, and the HV will do that for you. Disclaimer: I'm not an igvm expert
Member
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. Ah, I see now
Member
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. IIRC OpenHCL already used DT in IGVM, can we check how much space they reserve? TBH 4K doesn't seem too much
Collaborator
Author
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.
yep, this is a problem in the code (probably due to a rebase). I'll use
Member
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. So, going back, exactly because
Collaborator
Author
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. yes! |
||
| parameter_area_index: IGVM_DT_PA, | ||
| initial_data: vec![], | ||
| }); | ||
| } | ||
| self.directives.push(IgvmDirectiveHeader::ParameterArea { | ||
| number_of_bytes: self | ||
| .gpa_map | ||
|
|
@@ -511,6 +532,18 @@ impl IgvmBuilder { | |
| parameter_area_index: IGVM_MADT_PA, | ||
| byte_offset: 0, | ||
| })); | ||
| if self | ||
| .gpa_map | ||
| .boot_param_layout | ||
| .get_param_size(BootParamType::DeviceTree) | ||
| != 0 | ||
| { | ||
| self.directives | ||
| .push(IgvmDirectiveHeader::DeviceTree(IGVM_VHS_PARAMETER { | ||
| parameter_area_index: IGVM_DT_PA, | ||
| byte_offset: 0, | ||
| })); | ||
| } | ||
| self.directives | ||
| .push(IgvmDirectiveHeader::MemoryMap(IGVM_VHS_PARAMETER { | ||
| parameter_area_index: IGVM_MEMORY_MAP_PA, | ||
|
|
@@ -536,6 +569,23 @@ impl IgvmBuilder { | |
| parameter_area_index: IGVM_MADT_PA, | ||
| }, | ||
| )); | ||
| if self | ||
| .gpa_map | ||
| .boot_param_layout | ||
| .get_param_size(BootParamType::DeviceTree) | ||
| != 0 | ||
| { | ||
| self.directives.push(IgvmDirectiveHeader::ParameterInsert( | ||
| IGVM_VHS_PARAMETER_INSERT { | ||
| gpa: self | ||
| .gpa_map | ||
| .boot_param_layout | ||
| .get_param_gpa(image_layout.boot_params_gpa, BootParamType::DeviceTree), | ||
| compatibility_mask: COMPATIBILITY_MASK.get(), | ||
| parameter_area_index: IGVM_DT_PA, | ||
| }, | ||
| )); | ||
| } | ||
| self.directives.push(IgvmDirectiveHeader::ParameterInsert( | ||
| IGVM_VHS_PARAMETER_INSERT { | ||
| gpa: self | ||
|
|
||
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.
Can we just add this for all hypervisors? What will be the issue?
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.
very good question: here i set the device tree size. Later on, using the size I add the device tree directive into the igvm file.
Although there are optional and mandatory directives, QEMU considers them all as mandatory. This means that it will exits if it can't handle it properly.
I'm already working on a fix for QEMU.
I'm not sure if the other HVs are affected by the same bug.