-
Notifications
You must be signed in to change notification settings - Fork 21
Adjust the pci format and add new example for qemu with pci #51
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 2 commits
7b5cf7c
9f5073e
7b6ff70
febd052
b3ff20f
9fd2351
b38e455
23d3311
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 |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| { | ||
| "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" | ||
| }], | ||
| "num_pci_devs": 2, | ||
| "alloc_pci_devs": [ | ||
| { | ||
| "bdf": "0x0", | ||
| "vbdf": "0x0" | ||
| }, | ||
| { | ||
| "bdf": "0x18", | ||
| "vbdf": "0x18" | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| #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 | ||
|
|
@@ -35,6 +36,13 @@ struct memory_region { | |
|
|
||
| typedef struct memory_region memory_region_t; | ||
|
|
||
| struct hv_pci_dev_config { | ||
| __u64 bdf; | ||
| __u64 vbdf; | ||
| }; | ||
|
|
||
| typedef struct hv_pci_dev_config hv_pci_dev_config_t; | ||
|
|
||
| struct pci_config { | ||
|
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. Since we added |
||
| __u64 ecam_base; | ||
| __u64 ecam_size; | ||
|
|
@@ -123,7 +131,7 @@ struct ivc_config { | |
| }; | ||
| typedef struct ivc_config ivc_config_t; | ||
|
|
||
| #define CONFIG_MAGIC_VERSION 0x03 | ||
| #define CONFIG_MAGIC_VERSION 0x04 | ||
|
|
||
| // Every time you change the struct, you should also change the | ||
| // `CONFIG_MAGIC_VERSION` | ||
|
|
@@ -145,9 +153,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; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -285,80 +285,98 @@ static int parse_arch_config(cJSON *root, zone_config_t *config) { | |||||
| } | ||||||
|
|
||||||
| static int parse_pci_config(cJSON *root, zone_config_t *config) { | ||||||
| cJSON *pci_config_json = SAFE_CJSON_GET_OBJECT_ITEM(root, "pci_config"); | ||||||
| if (pci_config_json == NULL) { | ||||||
| log_warn("No pci_config field found."); | ||||||
| return -1; | ||||||
| } else { | ||||||
| printf("pci_config field found.\n"); | ||||||
| } | ||||||
| cJSON *pci_configs_json = SAFE_CJSON_GET_OBJECT_ITEM(root, "pci_config"); | ||||||
| CHECK_JSON_NULL_ERR_OUT(pci_configs_json, "pci_configs") | ||||||
|
||||||
| CHECK_JSON_NULL_ERR_OUT(pci_configs_json, "pci_configs") | |
| CHECK_JSON_NULL_ERR_OUT(pci_configs_json, "pci_config") |
Copilot
AI
Jan 3, 2026
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 format specifier %llx is used for num_pci_bus which is of type int. This is incorrect and should use %d instead. Using %llx for an int can lead to undefined behavior and incorrect output.
| log_info("num pci bus %llx", num_pci_bus); | |
| log_info("num pci bus %d", num_pci_bus); |
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.
There are no corresponding items in the new_pcie branch of hvisor:
https://github.com/syswonder/hvisor/tree/new_pcie
Perhaps this config needs to be updated.
See the following link for reference:
https://github.com/syswonder/hvisor/blob/new_pcie/src/config.rs#L212