Skip to content

Commit a01561e

Browse files
bullhhszyZR233
authored
Fix the bug when the dtb_load_addr field is missing. (#263)
* fix no dtb_load_gpa error --------- Co-authored-by: szy <[email protected]> Co-authored-by: 周睿 <[email protected]>
1 parent 1502016 commit a01561e

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

configs/vms/nimbos-aarch64-qemu-smp1.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ emu_devices = [
6666
# Name Base-Ipa Base-Pa Length Alloc-Irq.
6767
passthrough_devices = [
6868
["/"],
69-
#["/timer"],
69+
#["/pl011@9000000"],
7070
]
7171

7272
# Devices that are not desired to be passed through to the guest
7373
excluded_devices = [
74-
# ["/gic-v3"],
74+
["/pcie@10000000"],
7575
]

src/vmm/images/mod.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,19 @@ impl ImageLoader {
107107
.expect("Failed to load VM images");
108108
// Load DTB image
109109
let vm_config = axvm::config::AxVMConfig::from(self.config.clone());
110-
if let Some(dtb_arc) = get_vm_dtb_arc(&vm_config) {
110+
if let Some(dtb_arc) = get_vm_dtb_arc(&vm_config)
111+
&& let Some(dtb_load_gpa) = self.dtb_load_gpa
112+
{
111113
let dtb_slice: &[u8] = &dtb_arc;
112114
debug!(
113115
"DTB buffer addr: {:x}, size: {:#}",
114-
self.dtb_load_gpa.unwrap(),
116+
dtb_load_gpa,
115117
Byte::from(dtb_slice.len())
116118
);
117119

118120
#[cfg(target_arch = "aarch64")]
119121
update_fdt(
120-
self.dtb_load_gpa.unwrap(),
122+
dtb_load_gpa,
121123
NonNull::new(dtb_slice.as_ptr() as *mut u8).unwrap(),
122124
dtb_slice.len(),
123125
self.vm.clone(),
@@ -254,17 +256,19 @@ mod fs {
254256
};
255257
// Load DTB image if needed.
256258
let vm_config = axvm::config::AxVMConfig::from(loader.config.clone());
257-
if let Some(dtb_arc) = get_vm_dtb_arc(&vm_config) {
259+
if let Some(dtb_arc) = get_vm_dtb_arc(&vm_config)
260+
&& let Some(dtb_load_gpa) = loader.dtb_load_gpa
261+
{
258262
let dtb_slice: &[u8] = &dtb_arc;
259263
debug!(
260264
"DTB buffer addr: {:x}, size: {:#}",
261-
loader.dtb_load_gpa.unwrap(),
265+
dtb_load_gpa,
262266
Byte::from(dtb_slice.len())
263267
);
264268

265269
#[cfg(target_arch = "aarch64")]
266270
update_fdt(
267-
loader.dtb_load_gpa.unwrap(),
271+
dtb_load_gpa,
268272
NonNull::new(dtb_slice.as_ptr() as *mut u8).unwrap(),
269273
dtb_slice.len(),
270274
loader.vm.clone(),

0 commit comments

Comments
 (0)