Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion examples/qemu-aarch64/with_virtio_blk_console/qemu_aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,19 @@ pub const ROOT_PCI_CONFIG: HvPciConfig = HvPciConfig {
mem64_base: 0x8000000000,
mem64_size: 0x8000000000,
pci_mem64_base: 0x8000000000,
bus_range_begin: 0x0,
bus_range_end: 0x1f,
};

pub const ROOT_ZONE_IVC_CONFIG: [HvIvcConfig; 0] = [];

pub const ROOT_PCI_DEVS: [u64; 2] = [0, 1 << 3];
pub const ROOT_PCI_DEVS: [hv_pci_dev_config_t; 2] = [
hv_pci_dev_config_t {
bdf: 0,
dev_type: 0,
},
hv_pci_dev_config_t {
Comment on lines +69 to +74
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

The type name uses the underscore suffix convention (hv_pci_dev_config_t) which is inconsistent with the type name used in the other Rust file (hv_pci_dev_config without _t suffix). For consistency, both files should use the same type name.

Suggested change
pub const ROOT_PCI_DEVS: [hv_pci_dev_config_t; 2] = [
hv_pci_dev_config_t {
bdf: 0,
dev_type: 0,
},
hv_pci_dev_config_t {
pub const ROOT_PCI_DEVS: [hv_pci_dev_config; 2] = [
hv_pci_dev_config {
bdf: 0,
dev_type: 0,
},
hv_pci_dev_config {

Copilot uses AI. Check for mistakes.
bdf: 1 << 3,
dev_type: 0,
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"name": "linux2",
"zone_id": 1,
"cpus": [2, 3],
"memory_regions": [
{
"type": "ram",
"physical_start": "0x50000000",
"virtual_start": "0x50000000",
"size": "0x30000000"
},
{
"type": "virtio",
"physical_start": "0xa000000",
"virtual_start": "0xa000000",
"size": "0x4000"
}
],
"interrupts": [76, 78],
"ivc_configs": [],
"kernel_filepath": "./Image",
"dtb_filepath": "./linux2.dtb",
"kernel_load_paddr": "0x50400000",
"dtb_load_paddr": "0x50000000",
"entry_point": "0x50400000",
"arch_config": {
"gic_version": "v3",
"gicd_base": "0x8000000",
"gicd_size": "0x10000",
"gicr_base": "0x80a0000",
"gicr_size": "0xf60000",
"gits_base": "0x8080000",
"gits_size": "0x20000",
"is_aarch32": false
},
"pci_config": [{
"ecam_base": "0x4010000000",
"ecam_size": "0x10000000",
"io_base": "0x3eff0000",
"io_size": "0x10000",
"pci_io_base": "0x0",
"mem32_base": "0x10000000",
"mem32_size": "0x2eff0000",
"pci_mem32_base": "0x10000000",
"mem64_base": "0x8000000000",
"mem64_size": "0x8000000000",
"pci_mem64_base": "0x8000000000",
"bus_range_begin": "0x0",
"bus_range_end": "0x1f"
Comment on lines +48 to +49
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

The C parsing code expects a "domain" field in the pci_config object, but none of the JSON example files include this field. This will cause a null pointer dereference when parsing. Add the "domain" field to the pci_config object.

Copilot uses AI. Check for mistakes.
}],
"num_pci_devs": 2,
"alloc_pci_devs": [
{
"bdf": "0x0",
"dev_type": "0x0"
},
{
"bdf": "0x18",
Comment on lines +54 to +58
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

The JSON uses "bdf" field, but the C struct hv_pci_dev_config expects separate "domain", "bus", "device", and "function" fields. The JSON configuration should be updated to use these separate fields to match the struct definition in zone_config.h, or the parsing code needs to extract these components from the bdf value.

Suggested change
"bdf": "0x0",
"dev_type": "0x0"
},
{
"bdf": "0x18",
"domain": "0x0",
"bus": "0x0",
"device": "0x0",
"function": "0x0",
"dev_type": "0x0"
},
{
"domain": "0x0",
"bus": "0x0",
"device": "0x3",
"function": "0x0",

Copilot uses AI. Check for mistakes.
"dev_type": "0x0"
}
]
}
17 changes: 16 additions & 1 deletion examples/qemu-aarch64/with_virtio_gpu/qemu_aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,23 @@ pub const ROOT_PCI_CONFIG: HvPciConfig = HvPciConfig {
mem64_base: 0x8000000000,
mem64_size: 0x8000000000,
pci_mem64_base: 0x8000000000,
bus_range_begin: 0x0,
bus_range_end: 0x1f,
};

pub const ROOT_ZONE_IVC_CONFIG: [HvIvcConfig; 0] = [];

pub const ROOT_PCI_DEVS: [u64; 3] = [0, 1 << 3, 6 << 3];
pub const ROOT_PCI_DEVS: [hv_pci_dev_config; 3] = [
hv_pci_dev_config {
bdf: 0,
dev_type: 0,
},
hv_pci_dev_config {
bdf: 1 << 3,
dev_type: 0,
},
hv_pci_dev_config {
bdf: 6 << 3,
dev_type: 0,
},
];
21 changes: 18 additions & 3 deletions examples/qemu-riscv64/linux2-aia.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,23 @@
"pci_mem32_base": "0x40000000",
"mem64_base": "0x400000000",
"mem64_size": "0x400000000",
"pci_mem64_base": "0x400000000"
"pci_mem64_base": "0x400000000",
"bus_range_begin": "0x0",
"bus_range_end": "0x1f"
Comment on lines +51 to +52
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

The C parsing code expects a "domain" field in the pci_config object, but none of the JSON example files include this field. This will cause a null pointer dereference when parsing. Add the "domain" field to the pci_config object.

Copilot uses AI. Check for mistakes.
},
"num_pci_devs": 2,
"alloc_pci_devs": [0, 16]
"num_pci_devs": 3,
"alloc_pci_devs": [
{
"bdf": "0x0",
"dev_type": "0x0"
},
{
"bdf": "0x10",
"dev_type": "0x0"
},
{
"bdf": "0x20",
Comment on lines +57 to +65
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

The JSON uses "bdf" field, but the C struct hv_pci_dev_config expects separate "domain", "bus", "device", and "function" fields. The JSON configuration should be updated to use these separate fields to match the struct definition in zone_config.h, or the parsing code needs to extract these components from the bdf value.

Suggested change
"bdf": "0x0",
"dev_type": "0x0"
},
{
"bdf": "0x10",
"dev_type": "0x0"
},
{
"bdf": "0x20",
"domain": "0x0",
"bus": "0x0",
"device": "0x0",
"function": "0x0",
"dev_type": "0x0"
},
{
"domain": "0x0",
"bus": "0x0",
"device": "0x2",
"function": "0x0",
"dev_type": "0x0"
},
{
"domain": "0x0",
"bus": "0x0",
"device": "0x4",
"function": "0x0",

Copilot uses AI. Check for mistakes.
"dev_type": "0x0"
}
]
}
21 changes: 18 additions & 3 deletions examples/qemu-riscv64/linux2.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,23 @@
"pci_mem32_base": "0x40000000",
"mem64_base": "0x400000000",
"mem64_size": "0x400000000",
"pci_mem64_base": "0x400000000"
"pci_mem64_base": "0x400000000",
"bus_range_begin": "0x0",
"bus_range_end": "0x1f"
Comment on lines +51 to +52
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

The C parsing code expects a "domain" field in the pci_config object, but none of the JSON example files include this field. This will cause a null pointer dereference when parsing. Add the "domain" field to the pci_config object.

Copilot uses AI. Check for mistakes.
},
"num_pci_devs": 2,
"alloc_pci_devs": [0, 16]
"num_pci_devs": 3,
"alloc_pci_devs": [
{
"bdf": "0x0",
"dev_type": "0x0"
},
{
"bdf": "0x10",
"dev_type": "0x0"
},
{
"bdf": "0x20",
Comment on lines +57 to +65
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

The JSON uses "bdf" field, but the C struct hv_pci_dev_config expects separate "domain", "bus", "device", and "function" fields. The JSON configuration should be updated to use these separate fields to match the struct definition in zone_config.h, or the parsing code needs to extract these components from the bdf value.

Suggested change
"bdf": "0x0",
"dev_type": "0x0"
},
{
"bdf": "0x10",
"dev_type": "0x0"
},
{
"bdf": "0x20",
"domain": "0x0",
"bus": "0x0",
"device": "0x0",
"function": "0x0",
"dev_type": "0x0"
},
{
"domain": "0x0",
"bus": "0x0",
"device": "0x2",
"function": "0x0",
"dev_type": "0x0"
},
{
"domain": "0x0",
"bus": "0x0",
"device": "0x4",
"function": "0x0",

Copilot uses AI. Check for mistakes.
"dev_type": "0x0"
}
]
}
21 changes: 18 additions & 3 deletions include/zone_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ typedef __u32 BitmapWord;
#define CONFIG_MAX_ZONES 32
#define CONFIG_NAME_MAXLEN 32
#define CONFIG_MAX_PCI_DEV 32
#define CONFIG_PCI_BUS_MAXNUM 4

#define IVC_PROTOCOL_USER 0x0
#define IVC_PROTOCOL_HVISOR 0x01
Expand All @@ -39,6 +40,16 @@ struct memory_region {

typedef struct memory_region memory_region_t;

struct hv_pci_dev_config {
__u8 domain;
__u8 bus;
__u8 device;
__u8 function;
__u32 dev_type;
};

typedef struct hv_pci_dev_config hv_pci_dev_config_t;

struct pci_config {

Choose a reason for hiding this comment

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

Since we added bus_range_begin and bus_range_end to the pci_config of hvisor,
we should probably add the same fields to the pci_config of hvisor-tools as well.
It would also be better to implement the corresponding JSON parsing logic.
Or the hvisor would panic at https://github.com/syswonder/hvisor/blob/new_pcie/src/hypercall/mod.rs#L200
See the following link for reference: https://github.com/syswonder/hvisor/blob/new_pcie/src/config.rs#L58

__u64 ecam_base;
__u64 ecam_size;
Expand All @@ -51,6 +62,9 @@ struct pci_config {
__u64 mem64_base;
__u64 mem64_size;
__u64 pci_mem64_base;
__u32 bus_range_begin;
__u32 bus_range_end;
__u8 domain;
};

typedef struct pci_config pci_config_t;
Expand Down Expand Up @@ -142,7 +156,7 @@ struct ivc_config {
};
typedef struct ivc_config ivc_config_t;

#define CONFIG_MAGIC_VERSION 0x04
#define CONFIG_MAGIC_VERSION 0x05

// Every time you change the struct, you should also change the
// `CONFIG_MAGIC_VERSION`
Expand All @@ -164,9 +178,10 @@ struct zone_config {
char name[CONFIG_NAME_MAXLEN];

arch_zone_config_t arch_config;
pci_config_t pci_config;
__u64 num_pci_bus;
pci_config_t pci_config[CONFIG_PCI_BUS_MAXNUM];
__u64 num_pci_devs;
__u64 alloc_pci_devs[CONFIG_MAX_PCI_DEV];
hv_pci_dev_config_t alloc_pci_devs[CONFIG_MAX_PCI_DEV];
};

typedef struct zone_config zone_config_t;
Expand Down
Loading