...
...
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
https://github.com/legoater/qemu/ tags/pull-vfio-20230710
7
https://github.com/legoater/qemu/ tags/pull-vfio-20230710
8
8
9
for you to fetch changes up to 9495bf68dd2fe305f5e95a53ae146ca523dc2a02:
9
for you to fetch changes up to c00aac6f1428d40a4ca2ab9b89070afc2a5bf979:
10
10
11
vfio/pci: Enable AtomicOps completers on root ports (2023-07-10 09:46:09 +0200)
11
vfio/pci: Enable AtomicOps completers on root ports (2023-07-10 09:52:52 +0200)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
vfio queue:
14
vfio queue:
15
15
16
* Fixes in error handling paths of VFIO PCI devices
16
* Fixes in error handling paths of VFIO PCI devices
...
...
38
vfio/pci: Disable INTx in vfio_realize error path
38
vfio/pci: Disable INTx in vfio_realize error path
39
vfio/migration: Change vIOMMU blocker from global to per device
39
vfio/migration: Change vIOMMU blocker from global to per device
40
vfio/migration: Free resources when vfio_migration_realize fails
40
vfio/migration: Free resources when vfio_migration_realize fails
41
vfio/migration: Remove print of "Migration disabled"
41
vfio/migration: Remove print of "Migration disabled"
42
vfio/migration: Return bool type for vfio_migration_realize()
42
vfio/migration: Return bool type for vfio_migration_realize()
43
44
Changes in v2:
45
46
Fixed broken S-o-b in "linux-headers: update to v6.5-rc1" commit
43
47
44
hw/vfio/pci.h | 1 +
48
hw/vfio/pci.h | 1 +
45
include/hw/pci/pcie.h | 1 +
49
include/hw/pci/pcie.h | 1 +
46
include/hw/vfio/vfio-common.h | 5 +-
50
include/hw/vfio/vfio-common.h | 5 +-
47
include/standard-headers/drm/drm_fourcc.h | 43 ++++++++
51
include/standard-headers/drm/drm_fourcc.h | 43 ++++++++
...
...
diff view generated by jsdifflib
Deleted patch
1
From: Alex Williamson <alex.williamson@redhat.com>
2
1
3
Coverity reports a tained scalar when traversing the capabilities
4
chain (CID 1516589). In practice I've never seen a device with a
5
chain so broken as to cause an issue, but it's also pretty easy to
6
sanitize.
7
8
Fixes: f6b30c1984f7 ("hw/vfio/pci-quirks: Support alternate offset for GPUDirect Cliques")
9
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
10
Reviewed-by: Cédric Le Goater <clg@redhat.com>
11
Signed-off-by: Cédric Le Goater <clg@redhat.com>
12
---
13
hw/vfio/pci-quirks.c | 10 ++++++++--
14
1 file changed, 8 insertions(+), 2 deletions(-)
15
16
diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/vfio/pci-quirks.c
19
+++ b/hw/vfio/pci-quirks.c
20
@@ -XXX,XX +XXX,XX @@ const PropertyInfo qdev_prop_nv_gpudirect_clique = {
21
.set = set_nv_gpudirect_clique_id,
22
};
23
24
+static bool is_valid_std_cap_offset(uint8_t pos)
25
+{
26
+ return (pos >= PCI_STD_HEADER_SIZEOF &&
27
+ pos <= (PCI_CFG_SPACE_SIZE - PCI_CAP_SIZEOF));
28
+}
29
+
30
static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice *vdev, Error **errp)
31
{
32
PCIDevice *pdev = &vdev->pdev;
33
@@ -XXX,XX +XXX,XX @@ static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice *vdev, Error **errp)
34
*/
35
ret = pread(vdev->vbasedev.fd, &tmp, 1,
36
vdev->config_offset + PCI_CAPABILITY_LIST);
37
- if (ret != 1 || !tmp) {
38
+ if (ret != 1 || !is_valid_std_cap_offset(tmp)) {
39
error_setg(errp, "NVIDIA GPUDirect Clique ID: error getting cap list");
40
return -EINVAL;
41
}
42
@@ -XXX,XX +XXX,XX @@ static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice *vdev, Error **errp)
43
d4_conflict = true;
44
}
45
tmp = pdev->config[tmp + PCI_CAP_LIST_NEXT];
46
- } while (tmp);
47
+ } while (is_valid_std_cap_offset(tmp));
48
49
if (!c8_conflict) {
50
pos = 0xC8;
51
--
52
2.41.0
53
54
diff view generated by jsdifflib
Deleted patch
1
From: Zhenzhong Duan <zhenzhong.duan@intel.com>
2
1
3
When vfio realize fails, INTx isn't disabled if it has been enabled.
4
This may confuse host side with unhandled interrupt report.
5
6
Fixes: c5478fea27ac ("vfio/pci: Respond to KVM irqchip change notifier")
7
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
8
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
9
Reviewed-by: Cédric Le Goater <clg@redhat.com>
10
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11
---
12
hw/vfio/pci.c | 3 +++
13
1 file changed, 3 insertions(+)
14
15
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/vfio/pci.c
18
+++ b/hw/vfio/pci.c
19
@@ -XXX,XX +XXX,XX @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
20
return;
21
22
out_deregister:
23
+ if (vdev->interrupt == VFIO_INT_INTx) {
24
+ vfio_intx_disable(vdev);
25
+ }
26
pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);
27
if (vdev->irqchip_change_notifier.notify) {
28
kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier);
29
--
30
2.41.0
31
32
diff view generated by jsdifflib
Deleted patch
1
From: Zhenzhong Duan <zhenzhong.duan@intel.com>
2
1
3
Contrary to multiple device blocker which needs to consider already-attached
4
devices to unblock/block dynamically, the vIOMMU migration blocker is a device
5
specific config. Meaning it only needs to know whether the device is bypassing
6
or not the vIOMMU (via machine property, or per pxb-pcie::bypass_iommu), and
7
does not need the state of currently present devices. For this reason, the
8
vIOMMU global migration blocker can be consolidated into the per-device
9
migration blocker, allowing us to remove some unnecessary code.
10
11
This change also makes vfio_mig_active() more accurate as it doesn't check for
12
global blocker.
13
14
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
15
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
16
Reviewed-by: Cédric Le Goater <clg@redhat.com>
17
Signed-off-by: Cédric Le Goater <clg@redhat.com>
18
---
19
include/hw/vfio/vfio-common.h | 3 +--
20
hw/vfio/common.c | 51 ++---------------------------------
21
hw/vfio/migration.c | 7 ++---
22
hw/vfio/pci.c | 1 -
23
4 files changed, 7 insertions(+), 55 deletions(-)
24
25
diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
26
index XXXXXXX..XXXXXXX 100644
27
--- a/include/hw/vfio/vfio-common.h
28
+++ b/include/hw/vfio/vfio-common.h
29
@@ -XXX,XX +XXX,XX @@ extern VFIOGroupList vfio_group_list;
30
bool vfio_mig_active(void);
31
int vfio_block_multiple_devices_migration(VFIODevice *vbasedev, Error **errp);
32
void vfio_unblock_multiple_devices_migration(void);
33
-int vfio_block_giommu_migration(VFIODevice *vbasedev, Error **errp);
34
+bool vfio_viommu_preset(VFIODevice *vbasedev);
35
int64_t vfio_mig_bytes_transferred(void);
36
void vfio_reset_bytes_transferred(void);
37
38
@@ -XXX,XX +XXX,XX @@ int vfio_spapr_remove_window(VFIOContainer *container,
39
40
int vfio_migration_realize(VFIODevice *vbasedev, Error **errp);
41
void vfio_migration_exit(VFIODevice *vbasedev);
42
-void vfio_migration_finalize(void);
43
44
#endif /* HW_VFIO_VFIO_COMMON_H */
45
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
46
index XXXXXXX..XXXXXXX 100644
47
--- a/hw/vfio/common.c
48
+++ b/hw/vfio/common.c
49
@@ -XXX,XX +XXX,XX @@ bool vfio_mig_active(void)
50
}
51
52
static Error *multiple_devices_migration_blocker;
53
-static Error *giommu_migration_blocker;
54
55
static unsigned int vfio_migratable_device_num(void)
56
{
57
@@ -XXX,XX +XXX,XX @@ void vfio_unblock_multiple_devices_migration(void)
58
multiple_devices_migration_blocker = NULL;
59
}
60
61
-static bool vfio_viommu_preset(void)
62
+bool vfio_viommu_preset(VFIODevice *vbasedev)
63
{
64
- VFIOAddressSpace *space;
65
-
66
- QLIST_FOREACH(space, &vfio_address_spaces, list) {
67
- if (space->as != &address_space_memory) {
68
- return true;
69
- }
70
- }
71
-
72
- return false;
73
-}
74
-
75
-int vfio_block_giommu_migration(VFIODevice *vbasedev, Error **errp)
76
-{
77
- int ret;
78
-
79
- if (giommu_migration_blocker ||
80
- !vfio_viommu_preset()) {
81
- return 0;
82
- }
83
-
84
- if (vbasedev->enable_migration == ON_OFF_AUTO_ON) {
85
- error_setg(errp,
86
- "Migration is currently not supported with vIOMMU enabled");
87
- return -EINVAL;
88
- }
89
-
90
- error_setg(&giommu_migration_blocker,
91
- "Migration is currently not supported with vIOMMU enabled");
92
- ret = migrate_add_blocker(giommu_migration_blocker, errp);
93
- if (ret < 0) {
94
- error_free(giommu_migration_blocker);
95
- giommu_migration_blocker = NULL;
96
- }
97
-
98
- return ret;
99
-}
100
-
101
-void vfio_migration_finalize(void)
102
-{
103
- if (!giommu_migration_blocker ||
104
- vfio_viommu_preset()) {
105
- return;
106
- }
107
-
108
- migrate_del_blocker(giommu_migration_blocker);
109
- error_free(giommu_migration_blocker);
110
- giommu_migration_blocker = NULL;
111
+ return vbasedev->group->container->space->as != &address_space_memory;
112
}
113
114
static void vfio_set_migration_error(int err)
115
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
116
index XXXXXXX..XXXXXXX 100644
117
--- a/hw/vfio/migration.c
118
+++ b/hw/vfio/migration.c
119
@@ -XXX,XX +XXX,XX @@ int vfio_migration_realize(VFIODevice *vbasedev, Error **errp)
120
return ret;
121
}
122
123
- ret = vfio_block_giommu_migration(vbasedev, errp);
124
- if (ret) {
125
- return ret;
126
+ if (vfio_viommu_preset(vbasedev)) {
127
+ error_setg(&err, "%s: Migration is currently not supported "
128
+ "with vIOMMU enabled", vbasedev->name);
129
+ return vfio_block_migration(vbasedev, err, errp);
130
}
131
132
trace_vfio_migration_realize(vbasedev->name);
133
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
134
index XXXXXXX..XXXXXXX 100644
135
--- a/hw/vfio/pci.c
136
+++ b/hw/vfio/pci.c
137
@@ -XXX,XX +XXX,XX @@ static void vfio_instance_finalize(Object *obj)
138
*/
139
vfio_put_device(vdev);
140
vfio_put_group(group);
141
- vfio_migration_finalize();
142
}
143
144
static void vfio_exitfn(PCIDevice *pdev)
145
--
146
2.41.0
147
148
diff view generated by jsdifflib
Deleted patch
1
From: Zhenzhong Duan <zhenzhong.duan@intel.com>
2
1
3
When vfio_realize() succeeds, hot unplug will call vfio_exitfn()
4
to free resources allocated in vfio_realize(); when vfio_realize()
5
fails, vfio_exitfn() is never called and we need to free resources
6
in vfio_realize().
7
8
In the case that vfio_migration_realize() fails,
9
e.g: with -only-migratable & enable-migration=off, we see below:
10
11
(qemu) device_add vfio-pci,host=81:11.1,id=vfio1,bus=root1,enable-migration=off
12
0000:81:11.1: Migration disabled
13
Error: disallowing migration blocker (--only-migratable) for: 0000:81:11.1: Migration is disabled for VFIO device
14
15
If we hotplug again we should see same log as above, but we see:
16
(qemu) device_add vfio-pci,host=81:11.1,id=vfio1,bus=root1,enable-migration=off
17
Error: vfio 0000:81:11.1: device is already attached
18
19
That's because some references to VFIO device isn't released.
20
For resources allocated in vfio_migration_realize(), free them by
21
jumping to out_deinit path with calling a new function
22
vfio_migration_deinit(). For resources allocated in vfio_realize(),
23
free them by jumping to de-register path in vfio_realize().
24
25
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
26
Fixes: a22651053b59 ("vfio: Make vfio-pci device migration capable")
27
Reviewed-by: Cédric Le Goater <clg@redhat.com>
28
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
29
Signed-off-by: Cédric Le Goater <clg@redhat.com>
30
---
31
hw/vfio/migration.c | 33 +++++++++++++++++++++++----------
32
hw/vfio/pci.c | 1 +
33
2 files changed, 24 insertions(+), 10 deletions(-)
34
35
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
36
index XXXXXXX..XXXXXXX 100644
37
--- a/hw/vfio/migration.c
38
+++ b/hw/vfio/migration.c
39
@@ -XXX,XX +XXX,XX @@ static int vfio_migration_init(VFIODevice *vbasedev)
40
return 0;
41
}
42
43
+static void vfio_migration_deinit(VFIODevice *vbasedev)
44
+{
45
+ VFIOMigration *migration = vbasedev->migration;
46
+
47
+ remove_migration_state_change_notifier(&migration->migration_state);
48
+ qemu_del_vm_change_state_handler(migration->vm_state);
49
+ unregister_savevm(VMSTATE_IF(vbasedev->dev), "vfio", vbasedev);
50
+ vfio_migration_free(vbasedev);
51
+ vfio_unblock_multiple_devices_migration();
52
+}
53
+
54
static int vfio_block_migration(VFIODevice *vbasedev, Error *err, Error **errp)
55
{
56
int ret;
57
@@ -XXX,XX +XXX,XX @@ int vfio_migration_realize(VFIODevice *vbasedev, Error **errp)
58
error_setg(&err,
59
"%s: VFIO device doesn't support device dirty tracking",
60
vbasedev->name);
61
- return vfio_block_migration(vbasedev, err, errp);
62
+ goto add_blocker;
63
}
64
65
warn_report("%s: VFIO device doesn't support device dirty tracking",
66
@@ -XXX,XX +XXX,XX @@ int vfio_migration_realize(VFIODevice *vbasedev, Error **errp)
67
68
ret = vfio_block_multiple_devices_migration(vbasedev, errp);
69
if (ret) {
70
- return ret;
71
+ goto out_deinit;
72
}
73
74
if (vfio_viommu_preset(vbasedev)) {
75
error_setg(&err, "%s: Migration is currently not supported "
76
"with vIOMMU enabled", vbasedev->name);
77
- return vfio_block_migration(vbasedev, err, errp);
78
+ goto add_blocker;
79
}
80
81
trace_vfio_migration_realize(vbasedev->name);
82
return 0;
83
+
84
+add_blocker:
85
+ ret = vfio_block_migration(vbasedev, err, errp);
86
+out_deinit:
87
+ if (ret) {
88
+ vfio_migration_deinit(vbasedev);
89
+ }
90
+ return ret;
91
}
92
93
void vfio_migration_exit(VFIODevice *vbasedev)
94
{
95
if (vbasedev->migration) {
96
- VFIOMigration *migration = vbasedev->migration;
97
-
98
- remove_migration_state_change_notifier(&migration->migration_state);
99
- qemu_del_vm_change_state_handler(migration->vm_state);
100
- unregister_savevm(VMSTATE_IF(vbasedev->dev), "vfio", vbasedev);
101
- vfio_migration_free(vbasedev);
102
- vfio_unblock_multiple_devices_migration();
103
+ vfio_migration_deinit(vbasedev);
104
}
105
106
if (vbasedev->migration_blocker) {
107
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
108
index XXXXXXX..XXXXXXX 100644
109
--- a/hw/vfio/pci.c
110
+++ b/hw/vfio/pci.c
111
@@ -XXX,XX +XXX,XX @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
112
ret = vfio_migration_realize(vbasedev, errp);
113
if (ret) {
114
error_report("%s: Migration disabled", vbasedev->name);
115
+ goto out_deregister;
116
}
117
}
118
119
--
120
2.41.0
121
122
diff view generated by jsdifflib
Deleted patch
1
From: Zhenzhong Duan <zhenzhong.duan@intel.com>
2
1
3
Property enable_migration supports [on/off/auto].
4
In ON mode, error pointer is passed to errp and logged.
5
In OFF mode, we doesn't need to log "Migration disabled" as it's intentional.
6
In AUTO mode, we should only ever see errors or warnings if the device
7
supports migration and an error or incompatibility occurs while further
8
probing or configuring it. Lack of support for migration shoundn't
9
generate an error or warning.
10
11
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
12
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
13
Reviewed-by: Cédric Le Goater <clg@redhat.com>
14
Signed-off-by: Cédric Le Goater <clg@redhat.com>
15
---
16
hw/vfio/pci.c | 1 -
17
1 file changed, 1 deletion(-)
18
19
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/vfio/pci.c
22
+++ b/hw/vfio/pci.c
23
@@ -XXX,XX +XXX,XX @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
24
if (!pdev->failover_pair_id) {
25
ret = vfio_migration_realize(vbasedev, errp);
26
if (ret) {
27
- error_report("%s: Migration disabled", vbasedev->name);
28
goto out_deregister;
29
}
30
}
31
--
32
2.41.0
33
34
diff view generated by jsdifflib
Deleted patch
1
From: Zhenzhong Duan <zhenzhong.duan@intel.com>
2
1
3
Make vfio_migration_realize() adhere to the convention of other realize()
4
callbacks(like qdev_realize) by returning bool instead of int.
5
6
Suggested-by: Cédric Le Goater <clg@redhat.com>
7
Suggested-by: Joao Martins <joao.m.martins@oracle.com>
8
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
9
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
10
Reviewed-by: Cédric Le Goater <clg@redhat.com>
11
Signed-off-by: Cédric Le Goater <clg@redhat.com>
12
---
13
include/hw/vfio/vfio-common.h | 2 +-
14
hw/vfio/migration.c | 15 ++++++++++-----
15
hw/vfio/pci.c | 3 +--
16
3 files changed, 12 insertions(+), 8 deletions(-)
17
18
diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
19
index XXXXXXX..XXXXXXX 100644
20
--- a/include/hw/vfio/vfio-common.h
21
+++ b/include/hw/vfio/vfio-common.h
22
@@ -XXX,XX +XXX,XX @@ int vfio_spapr_create_window(VFIOContainer *container,
23
int vfio_spapr_remove_window(VFIOContainer *container,
24
hwaddr offset_within_address_space);
25
26
-int vfio_migration_realize(VFIODevice *vbasedev, Error **errp);
27
+bool vfio_migration_realize(VFIODevice *vbasedev, Error **errp);
28
void vfio_migration_exit(VFIODevice *vbasedev);
29
30
#endif /* HW_VFIO_VFIO_COMMON_H */
31
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/vfio/migration.c
34
+++ b/hw/vfio/migration.c
35
@@ -XXX,XX +XXX,XX @@ void vfio_reset_bytes_transferred(void)
36
bytes_transferred = 0;
37
}
38
39
-int vfio_migration_realize(VFIODevice *vbasedev, Error **errp)
40
+/*
41
+ * Return true when either migration initialized or blocker registered.
42
+ * Currently only return false when adding blocker fails which will
43
+ * de-register vfio device.
44
+ */
45
+bool vfio_migration_realize(VFIODevice *vbasedev, Error **errp)
46
{
47
Error *err = NULL;
48
int ret;
49
@@ -XXX,XX +XXX,XX @@ int vfio_migration_realize(VFIODevice *vbasedev, Error **errp)
50
if (vbasedev->enable_migration == ON_OFF_AUTO_OFF) {
51
error_setg(&err, "%s: Migration is disabled for VFIO device",
52
vbasedev->name);
53
- return vfio_block_migration(vbasedev, err, errp);
54
+ return !vfio_block_migration(vbasedev, err, errp);
55
}
56
57
ret = vfio_migration_init(vbasedev);
58
@@ -XXX,XX +XXX,XX @@ int vfio_migration_realize(VFIODevice *vbasedev, Error **errp)
59
vbasedev->name, ret, strerror(-ret));
60
}
61
62
- return vfio_block_migration(vbasedev, err, errp);
63
+ return !vfio_block_migration(vbasedev, err, errp);
64
}
65
66
if (!vbasedev->dirty_pages_supported) {
67
@@ -XXX,XX +XXX,XX @@ int vfio_migration_realize(VFIODevice *vbasedev, Error **errp)
68
}
69
70
trace_vfio_migration_realize(vbasedev->name);
71
- return 0;
72
+ return true;
73
74
add_blocker:
75
ret = vfio_block_migration(vbasedev, err, errp);
76
@@ -XXX,XX +XXX,XX @@ out_deinit:
77
if (ret) {
78
vfio_migration_deinit(vbasedev);
79
}
80
- return ret;
81
+ return !ret;
82
}
83
84
void vfio_migration_exit(VFIODevice *vbasedev)
85
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
86
index XXXXXXX..XXXXXXX 100644
87
--- a/hw/vfio/pci.c
88
+++ b/hw/vfio/pci.c
89
@@ -XXX,XX +XXX,XX @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
90
}
91
92
if (!pdev->failover_pair_id) {
93
- ret = vfio_migration_realize(vbasedev, errp);
94
- if (ret) {
95
+ if (!vfio_migration_realize(vbasedev, errp)) {
96
goto out_deregister;
97
}
98
}
99
--
100
2.41.0
101
102
diff view generated by jsdifflib
Deleted patch
1
From: Avihai Horon <avihaih@nvidia.com>
2
1
3
vfio_realize() has the following flow:
4
1. vfio_bars_prepare() -- sets VFIOBAR->size.
5
2. msix_early_setup().
6
3. vfio_bars_register() -- allocates VFIOBAR->mr.
7
8
After vfio_bars_prepare() is called msix_early_setup() can fail. If it
9
does fail, vfio_bars_register() is never called and VFIOBAR->mr is not
10
allocated.
11
12
In this case, vfio_bars_finalize() is called as part of the error flow
13
to free the bars' resources. However, vfio_bars_finalize() calls
14
object_unparent() for VFIOBAR->mr after checking only VFIOBAR->size, and
15
thus we get a null pointer dereference.
16
17
Fix it by checking VFIOBAR->mr in vfio_bars_finalize().
18
19
Fixes: 89d5202edc50 ("vfio/pci: Allow relocating MSI-X MMIO")
20
Signed-off-by: Avihai Horon <avihaih@nvidia.com>
21
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
22
Reviewed-by: Cédric Le Goater <clg@redhat.com>
23
Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
24
Signed-off-by: Cédric Le Goater <clg@redhat.com>
25
---
26
hw/vfio/pci.c | 4 +++-
27
1 file changed, 3 insertions(+), 1 deletion(-)
28
29
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/hw/vfio/pci.c
32
+++ b/hw/vfio/pci.c
33
@@ -XXX,XX +XXX,XX @@ static void vfio_bars_finalize(VFIOPCIDevice *vdev)
34
35
vfio_bar_quirk_finalize(vdev, i);
36
vfio_region_finalize(&bar->region);
37
- if (bar->size) {
38
+ if (bar->mr) {
39
+ assert(bar->size);
40
object_unparent(OBJECT(bar->mr));
41
g_free(bar->mr);
42
+ bar->mr = NULL;
43
}
44
}
45
46
--
47
2.41.0
48
49
diff view generated by jsdifflib
Deleted patch
1
Reviewed-by: Thomas Huth <thuth@redhat.com>
2
igned-off-by: Cédric Le Goater <clg@redhat.com>
3
Signed-off-by: Cédric Le Goater <clg@redhat.com>
4
---
5
include/standard-headers/drm/drm_fourcc.h | 43 ++++++
6
include/standard-headers/linux/const.h | 2 +-
7
include/standard-headers/linux/pci_regs.h | 1 +
8
include/standard-headers/linux/vhost_types.h | 16 +++
9
include/standard-headers/linux/virtio_blk.h | 18 +--
10
.../standard-headers/linux/virtio_config.h | 6 +
11
include/standard-headers/linux/virtio_net.h | 1 +
12
linux-headers/asm-arm64/bitsperlong.h | 23 ---
13
linux-headers/asm-arm64/kvm.h | 33 +++++
14
linux-headers/asm-generic/bitsperlong.h | 13 +-
15
linux-headers/asm-generic/unistd.h | 134 +++++-------------
16
linux-headers/asm-mips/unistd_n32.h | 1 +
17
linux-headers/asm-mips/unistd_n64.h | 1 +
18
linux-headers/asm-mips/unistd_o32.h | 1 +
19
linux-headers/asm-powerpc/unistd_32.h | 1 +
20
linux-headers/asm-powerpc/unistd_64.h | 1 +
21
linux-headers/asm-riscv/bitsperlong.h | 13 --
22
linux-headers/asm-riscv/kvm.h | 134 +++++++++++++++++-
23
linux-headers/asm-riscv/unistd.h | 9 ++
24
linux-headers/asm-s390/unistd_32.h | 2 +
25
linux-headers/asm-s390/unistd_64.h | 2 +
26
linux-headers/asm-x86/kvm.h | 3 +
27
linux-headers/asm-x86/unistd_32.h | 1 +
28
linux-headers/asm-x86/unistd_64.h | 1 +
29
linux-headers/asm-x86/unistd_x32.h | 1 +
30
linux-headers/linux/const.h | 2 +-
31
linux-headers/linux/kvm.h | 18 ++-
32
linux-headers/linux/mman.h | 14 ++
33
linux-headers/linux/psp-sev.h | 7 +
34
linux-headers/linux/userfaultfd.h | 17 ++-
35
linux-headers/linux/vfio.h | 27 ++++
36
linux-headers/linux/vhost.h | 31 ++++
37
32 files changed, 423 insertions(+), 154 deletions(-)
38
1
39
diff --git a/include/standard-headers/drm/drm_fourcc.h b/include/standard-headers/drm/drm_fourcc.h
40
index XXXXXXX..XXXXXXX 100644
41
--- a/include/standard-headers/drm/drm_fourcc.h
42
+++ b/include/standard-headers/drm/drm_fourcc.h
43
@@ -XXX,XX +XXX,XX @@ extern "C" {
44
*/
45
#define I915_FORMAT_MOD_4_TILED_DG2_RC_CCS_CC fourcc_mod_code(INTEL, 12)
46
47
+/*
48
+ * Intel Color Control Surfaces (CCS) for display ver. 14 render compression.
49
+ *
50
+ * The main surface is tile4 and at plane index 0, the CCS is linear and
51
+ * at index 1. A 64B CCS cache line corresponds to an area of 4x1 tiles in
52
+ * main surface. In other words, 4 bits in CCS map to a main surface cache
53
+ * line pair. The main surface pitch is required to be a multiple of four
54
+ * tile4 widths.
55
+ */
56
+#define I915_FORMAT_MOD_4_TILED_MTL_RC_CCS fourcc_mod_code(INTEL, 13)
57
+
58
+/*
59
+ * Intel Color Control Surfaces (CCS) for display ver. 14 media compression
60
+ *
61
+ * The main surface is tile4 and at plane index 0, the CCS is linear and
62
+ * at index 1. A 64B CCS cache line corresponds to an area of 4x1 tiles in
63
+ * main surface. In other words, 4 bits in CCS map to a main surface cache
64
+ * line pair. The main surface pitch is required to be a multiple of four
65
+ * tile4 widths. For semi-planar formats like NV12, CCS planes follow the
66
+ * Y and UV planes i.e., planes 0 and 1 are used for Y and UV surfaces,
67
+ * planes 2 and 3 for the respective CCS.
68
+ */
69
+#define I915_FORMAT_MOD_4_TILED_MTL_MC_CCS fourcc_mod_code(INTEL, 14)
70
+
71
+/*
72
+ * Intel Color Control Surface with Clear Color (CCS) for display ver. 14 render
73
+ * compression.
74
+ *
75
+ * The main surface is tile4 and is at plane index 0 whereas CCS is linear
76
+ * and at index 1. The clear color is stored at index 2, and the pitch should
77
+ * be ignored. The clear color structure is 256 bits. The first 128 bits
78
+ * represents Raw Clear Color Red, Green, Blue and Alpha color each represented
79
+ * by 32 bits. The raw clear color is consumed by the 3d engine and generates
80
+ * the converted clear color of size 64 bits. The first 32 bits store the Lower
81
+ * Converted Clear Color value and the next 32 bits store the Higher Converted
82
+ * Clear Color value when applicable. The Converted Clear Color values are
83
+ * consumed by the DE. The last 64 bits are used to store Color Discard Enable
84
+ * and Depth Clear Value Valid which are ignored by the DE. A CCS cache line
85
+ * corresponds to an area of 4x1 tiles in the main surface. The main surface
86
+ * pitch is required to be a multiple of 4 tile widths.
87
+ */
88
+#define I915_FORMAT_MOD_4_TILED_MTL_RC_CCS_CC fourcc_mod_code(INTEL, 15)
89
+
90
/*
91
* Tiled, NV12MT, grouped in 64 (pixels) x 32 (lines) -sized macroblocks
92
*
93
diff --git a/include/standard-headers/linux/const.h b/include/standard-headers/linux/const.h
94
index XXXXXXX..XXXXXXX 100644
95
--- a/include/standard-headers/linux/const.h
96
+++ b/include/standard-headers/linux/const.h
97
@@ -XXX,XX +XXX,XX @@
98
#define _BITUL(x)    (_UL(1) << (x))
99
#define _BITULL(x)    (_ULL(1) << (x))
100
101
-#define __ALIGN_KERNEL(x, a)        __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
102
+#define __ALIGN_KERNEL(x, a)        __ALIGN_KERNEL_MASK(x, (__typeof__(x))(a) - 1)
103
#define __ALIGN_KERNEL_MASK(x, mask)    (((x) + (mask)) & ~(mask))
104
105
#define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
106
diff --git a/include/standard-headers/linux/pci_regs.h b/include/standard-headers/linux/pci_regs.h
107
index XXXXXXX..XXXXXXX 100644
108
--- a/include/standard-headers/linux/pci_regs.h
109
+++ b/include/standard-headers/linux/pci_regs.h
110
@@ -XXX,XX +XXX,XX @@
111
#define PCI_EXT_CAP_ID_DVSEC    0x23    /* Designated Vendor-Specific */
112
#define PCI_EXT_CAP_ID_DLF    0x25    /* Data Link Feature */
113
#define PCI_EXT_CAP_ID_PL_16GT    0x26    /* Physical Layer 16.0 GT/s */
114
+#define PCI_EXT_CAP_ID_PL_32GT 0x2A /* Physical Layer 32.0 GT/s */
115
#define PCI_EXT_CAP_ID_DOE    0x2E    /* Data Object Exchange */
116
#define PCI_EXT_CAP_ID_MAX    PCI_EXT_CAP_ID_DOE
117
118
diff --git a/include/standard-headers/linux/vhost_types.h b/include/standard-headers/linux/vhost_types.h
119
index XXXXXXX..XXXXXXX 100644
120
--- a/include/standard-headers/linux/vhost_types.h
121
+++ b/include/standard-headers/linux/vhost_types.h
122
@@ -XXX,XX +XXX,XX @@ struct vhost_vring_addr {
123
    uint64_t log_guest_addr;
124
};
125
126
+struct vhost_worker_state {
127
+    /*
128
+     * For VHOST_NEW_WORKER the kernel will return the new vhost_worker id.
129
+     * For VHOST_FREE_WORKER this must be set to the id of the vhost_worker
130
+     * to free.
131
+     */
132
+    unsigned int worker_id;
133
+};
134
+
135
+struct vhost_vring_worker {
136
+    /* vring index */
137
+    unsigned int index;
138
+    /* The id of the vhost_worker returned from VHOST_NEW_WORKER */
139
+    unsigned int worker_id;
140
+};
141
+
142
/* no alignment requirement */
143
struct vhost_iotlb_msg {
144
    uint64_t iova;
145
diff --git a/include/standard-headers/linux/virtio_blk.h b/include/standard-headers/linux/virtio_blk.h
146
index XXXXXXX..XXXXXXX 100644
147
--- a/include/standard-headers/linux/virtio_blk.h
148
+++ b/include/standard-headers/linux/virtio_blk.h
149
@@ -XXX,XX +XXX,XX @@ struct virtio_blk_config {
150
151
    /* Zoned block device characteristics (if VIRTIO_BLK_F_ZONED) */
152
    struct virtio_blk_zoned_characteristics {
153
-        uint32_t zone_sectors;
154
-        uint32_t max_open_zones;
155
-        uint32_t max_active_zones;
156
-        uint32_t max_append_sectors;
157
-        uint32_t write_granularity;
158
+        __virtio32 zone_sectors;
159
+        __virtio32 max_open_zones;
160
+        __virtio32 max_active_zones;
161
+        __virtio32 max_append_sectors;
162
+        __virtio32 write_granularity;
163
        uint8_t model;
164
        uint8_t unused2[3];
165
    } zoned;
166
@@ -XXX,XX +XXX,XX @@ struct virtio_blk_outhdr {
167
*/
168
struct virtio_blk_zone_descriptor {
169
    /* Zone capacity */
170
-    uint64_t z_cap;
171
+    __virtio64 z_cap;
172
    /* The starting sector of the zone */
173
-    uint64_t z_start;
174
+    __virtio64 z_start;
175
    /* Zone write pointer position in sectors */
176
-    uint64_t z_wp;
177
+    __virtio64 z_wp;
178
    /* Zone type */
179
    uint8_t z_type;
180
    /* Zone state */
181
@@ -XXX,XX +XXX,XX @@ struct virtio_blk_zone_descriptor {
182
};
183
184
struct virtio_blk_zone_report {
185
-    uint64_t nr_zones;
186
+    __virtio64 nr_zones;
187
    uint8_t reserved[56];
188
    struct virtio_blk_zone_descriptor zones[];
189
};
190
diff --git a/include/standard-headers/linux/virtio_config.h b/include/standard-headers/linux/virtio_config.h
191
index XXXXXXX..XXXXXXX 100644
192
--- a/include/standard-headers/linux/virtio_config.h
193
+++ b/include/standard-headers/linux/virtio_config.h
194
@@ -XXX,XX +XXX,XX @@
195
*/
196
#define VIRTIO_F_SR_IOV            37
197
198
+/*
199
+ * This feature indicates that the driver passes extra data (besides
200
+ * identifying the virtqueue) in its device notifications.
201
+ */
202
+#define VIRTIO_F_NOTIFICATION_DATA    38
203
+
204
/*
205
* This feature indicates that the driver can reset a queue individually.
206
*/
207
diff --git a/include/standard-headers/linux/virtio_net.h b/include/standard-headers/linux/virtio_net.h
208
index XXXXXXX..XXXXXXX 100644
209
--- a/include/standard-headers/linux/virtio_net.h
210
+++ b/include/standard-headers/linux/virtio_net.h
211
@@ -XXX,XX +XXX,XX @@
212
#define VIRTIO_NET_F_GUEST_USO6    55    /* Guest can handle USOv6 in. */
213
#define VIRTIO_NET_F_HOST_USO    56    /* Host can handle USO in. */
214
#define VIRTIO_NET_F_HASH_REPORT 57    /* Supports hash report */
215
+#define VIRTIO_NET_F_GUEST_HDRLEN 59    /* Guest provides the exact hdr_len value. */
216
#define VIRTIO_NET_F_RSS     60    /* Supports RSS RX steering */
217
#define VIRTIO_NET_F_RSC_EXT     61    /* extended coalescing info */
218
#define VIRTIO_NET_F_STANDBY     62    /* Act as standby for another device
219
diff --git a/linux-headers/asm-arm64/bitsperlong.h b/linux-headers/asm-arm64/bitsperlong.h
220
index XXXXXXX..XXXXXXX 100644
221
--- a/linux-headers/asm-arm64/bitsperlong.h
222
+++ b/linux-headers/asm-arm64/bitsperlong.h
223
@@ -1,24 +1 @@
224
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
225
-/*
226
- * Copyright (C) 2012 ARM Ltd.
227
- *
228
- * This program is free software; you can redistribute it and/or modify
229
- * it under the terms of the GNU General Public License version 2 as
230
- * published by the Free Software Foundation.
231
- *
232
- * This program is distributed in the hope that it will be useful,
233
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
234
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
235
- * GNU General Public License for more details.
236
- *
237
- * You should have received a copy of the GNU General Public License
238
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
239
- */
240
-#ifndef __ASM_BITSPERLONG_H
241
-#define __ASM_BITSPERLONG_H
242
-
243
-#define __BITS_PER_LONG 64
244
-
245
#include <asm-generic/bitsperlong.h>
246
-
247
-#endif    /* __ASM_BITSPERLONG_H */
248
diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h
249
index XXXXXXX..XXXXXXX 100644
250
--- a/linux-headers/asm-arm64/kvm.h
251
+++ b/linux-headers/asm-arm64/kvm.h
252
@@ -XXX,XX +XXX,XX @@ struct kvm_arm_copy_mte_tags {
253
    __u64 reserved[2];
254
};
255
256
+/*
257
+ * Counter/Timer offset structure. Describe the virtual/physical offset.
258
+ * To be used with KVM_ARM_SET_COUNTER_OFFSET.
259
+ */
260
+struct kvm_arm_counter_offset {
261
+    __u64 counter_offset;
262
+    __u64 reserved;
263
+};
264
+
265
#define KVM_ARM_TAGS_TO_GUEST        0
266
#define KVM_ARM_TAGS_FROM_GUEST        1
267
268
@@ -XXX,XX +XXX,XX @@ enum {
269
    KVM_REG_ARM_VENDOR_HYP_BIT_PTP        = 1,
270
};
271
272
+/* Device Control API on vm fd */
273
+#define KVM_ARM_VM_SMCCC_CTRL        0
274
+#define KVM_ARM_VM_SMCCC_FILTER    0
275
+
276
/* Device Control API: ARM VGIC */
277
#define KVM_DEV_ARM_VGIC_GRP_ADDR    0
278
#define KVM_DEV_ARM_VGIC_GRP_DIST_REGS    1
279
@@ -XXX,XX +XXX,XX @@ enum {
280
#define KVM_ARM_VCPU_TIMER_CTRL        1
281
#define KVM_ARM_VCPU_TIMER_IRQ_VTIMER        0
282
#define KVM_ARM_VCPU_TIMER_IRQ_PTIMER        1
283
+#define KVM_ARM_VCPU_TIMER_IRQ_HVTIMER    2
284
+#define KVM_ARM_VCPU_TIMER_IRQ_HPTIMER    3
285
#define KVM_ARM_VCPU_PVTIME_CTRL    2
286
#define KVM_ARM_VCPU_PVTIME_IPA    0
287
288
@@ -XXX,XX +XXX,XX @@ enum {
289
/* run->fail_entry.hardware_entry_failure_reason codes. */
290
#define KVM_EXIT_FAIL_ENTRY_CPU_UNSUPPORTED    (1ULL << 0)
291
292
+enum kvm_smccc_filter_action {
293
+    KVM_SMCCC_FILTER_HANDLE = 0,
294
+    KVM_SMCCC_FILTER_DENY,
295
+    KVM_SMCCC_FILTER_FWD_TO_USER,
296
+
297
+};
298
+
299
+struct kvm_smccc_filter {
300
+    __u32 base;
301
+    __u32 nr_functions;
302
+    __u8 action;
303
+    __u8 pad[15];
304
+};
305
+
306
+/* arm64-specific KVM_EXIT_HYPERCALL flags */
307
+#define KVM_HYPERCALL_EXIT_SMC        (1U << 0)
308
+#define KVM_HYPERCALL_EXIT_16BIT    (1U << 1)
309
+
310
#endif
311
312
#endif /* __ARM_KVM_H__ */
313
diff --git a/linux-headers/asm-generic/bitsperlong.h b/linux-headers/asm-generic/bitsperlong.h
314
index XXXXXXX..XXXXXXX 100644
315
--- a/linux-headers/asm-generic/bitsperlong.h
316
+++ b/linux-headers/asm-generic/bitsperlong.h
317
@@ -XXX,XX +XXX,XX @@
318
#ifndef __ASM_GENERIC_BITS_PER_LONG
319
#define __ASM_GENERIC_BITS_PER_LONG
320
321
+#ifndef __BITS_PER_LONG
322
+/*
323
+ * In order to keep safe and avoid regression, only unify uapi
324
+ * bitsperlong.h for some archs which are using newer toolchains
325
+ * that have the definitions of __CHAR_BIT__ and __SIZEOF_LONG__.
326
+ * See the following link for more info:
327
+ * https://lore.kernel.org/linux-arch/b9624545-2c80-49a1-ac3c-39264a591f7b@app.fastmail.com/
328
+ */
329
+#if defined(__CHAR_BIT__) && defined(__SIZEOF_LONG__)
330
+#define __BITS_PER_LONG (__CHAR_BIT__ * __SIZEOF_LONG__)
331
+#else
332
/*
333
* There seems to be no way of detecting this automatically from user
334
* space, so 64 bit architectures should override this in their
335
@@ -XXX,XX +XXX,XX @@
336
* both 32 and 64 bit user space must not rely on CONFIG_64BIT
337
* to decide it, but rather check a compiler provided macro.
338
*/
339
-#ifndef __BITS_PER_LONG
340
#define __BITS_PER_LONG 32
341
#endif
342
+#endif
343
344
#endif /* __ASM_GENERIC_BITS_PER_LONG */
345
diff --git a/linux-headers/asm-generic/unistd.h b/linux-headers/asm-generic/unistd.h
346
index XXXXXXX..XXXXXXX 100644
347
--- a/linux-headers/asm-generic/unistd.h
348
+++ b/linux-headers/asm-generic/unistd.h
349
@@ -XXX,XX +XXX,XX @@ __SYSCALL(__NR_io_destroy, sys_io_destroy)
350
__SC_COMP(__NR_io_submit, sys_io_submit, compat_sys_io_submit)
351
#define __NR_io_cancel 3
352
__SYSCALL(__NR_io_cancel, sys_io_cancel)
353
+
354
#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32
355
#define __NR_io_getevents 4
356
__SC_3264(__NR_io_getevents, sys_io_getevents_time32, sys_io_getevents)
357
#endif
358
359
-/* fs/xattr.c */
360
#define __NR_setxattr 5
361
__SYSCALL(__NR_setxattr, sys_setxattr)
362
#define __NR_lsetxattr 6
363
@@ -XXX,XX +XXX,XX @@ __SYSCALL(__NR_removexattr, sys_removexattr)
364
__SYSCALL(__NR_lremovexattr, sys_lremovexattr)
365
#define __NR_fremovexattr 16
366
__SYSCALL(__NR_fremovexattr, sys_fremovexattr)
367
-
368
-/* fs/dcache.c */
369
#define __NR_getcwd 17
370
__SYSCALL(__NR_getcwd, sys_getcwd)
371
-
372
-/* fs/cookies.c */
373
#define __NR_lookup_dcookie 18
374
__SC_COMP(__NR_lookup_dcookie, sys_lookup_dcookie, compat_sys_lookup_dcookie)
375
-
376
-/* fs/eventfd.c */
377
#define __NR_eventfd2 19
378
__SYSCALL(__NR_eventfd2, sys_eventfd2)
379
-
380
-/* fs/eventpoll.c */
381
#define __NR_epoll_create1 20
382
__SYSCALL(__NR_epoll_create1, sys_epoll_create1)
383
#define __NR_epoll_ctl 21
384
__SYSCALL(__NR_epoll_ctl, sys_epoll_ctl)
385
#define __NR_epoll_pwait 22
386
__SC_COMP(__NR_epoll_pwait, sys_epoll_pwait, compat_sys_epoll_pwait)
387
-
388
-/* fs/fcntl.c */
389
#define __NR_dup 23
390
__SYSCALL(__NR_dup, sys_dup)
391
#define __NR_dup3 24
392
__SYSCALL(__NR_dup3, sys_dup3)
393
#define __NR3264_fcntl 25
394
__SC_COMP_3264(__NR3264_fcntl, sys_fcntl64, sys_fcntl, compat_sys_fcntl64)
395
-
396
-/* fs/inotify_user.c */
397
#define __NR_inotify_init1 26
398
__SYSCALL(__NR_inotify_init1, sys_inotify_init1)
399
#define __NR_inotify_add_watch 27
400
__SYSCALL(__NR_inotify_add_watch, sys_inotify_add_watch)
401
#define __NR_inotify_rm_watch 28
402
__SYSCALL(__NR_inotify_rm_watch, sys_inotify_rm_watch)
403
-
404
-/* fs/ioctl.c */
405
#define __NR_ioctl 29
406
__SC_COMP(__NR_ioctl, sys_ioctl, compat_sys_ioctl)
407
-
408
-/* fs/ioprio.c */
409
#define __NR_ioprio_set 30
410
__SYSCALL(__NR_ioprio_set, sys_ioprio_set)
411
#define __NR_ioprio_get 31
412
__SYSCALL(__NR_ioprio_get, sys_ioprio_get)
413
-
414
-/* fs/locks.c */
415
#define __NR_flock 32
416
__SYSCALL(__NR_flock, sys_flock)
417
-
418
-/* fs/namei.c */
419
#define __NR_mknodat 33
420
__SYSCALL(__NR_mknodat, sys_mknodat)
421
#define __NR_mkdirat 34
422
@@ -XXX,XX +XXX,XX @@ __SYSCALL(__NR_unlinkat, sys_unlinkat)
423
__SYSCALL(__NR_symlinkat, sys_symlinkat)
424
#define __NR_linkat 37
425
__SYSCALL(__NR_linkat, sys_linkat)
426
+
427
#ifdef __ARCH_WANT_RENAMEAT
428
/* renameat is superseded with flags by renameat2 */
429
#define __NR_renameat 38
430
__SYSCALL(__NR_renameat, sys_renameat)
431
#endif /* __ARCH_WANT_RENAMEAT */
432
433
-/* fs/namespace.c */
434
#define __NR_umount2 39
435
__SYSCALL(__NR_umount2, sys_umount)
436
#define __NR_mount 40
437
__SYSCALL(__NR_mount, sys_mount)
438
#define __NR_pivot_root 41
439
__SYSCALL(__NR_pivot_root, sys_pivot_root)
440
-
441
-/* fs/nfsctl.c */
442
#define __NR_nfsservctl 42
443
__SYSCALL(__NR_nfsservctl, sys_ni_syscall)
444
-
445
-/* fs/open.c */
446
#define __NR3264_statfs 43
447
__SC_COMP_3264(__NR3264_statfs, sys_statfs64, sys_statfs, \
448
     compat_sys_statfs64)
449
@@ -XXX,XX +XXX,XX @@ __SC_COMP_3264(__NR3264_truncate, sys_truncate64, sys_truncate, \
450
#define __NR3264_ftruncate 46
451
__SC_COMP_3264(__NR3264_ftruncate, sys_ftruncate64, sys_ftruncate, \
452
     compat_sys_ftruncate64)
453
-
454
#define __NR_fallocate 47
455
__SC_COMP(__NR_fallocate, sys_fallocate, compat_sys_fallocate)
456
#define __NR_faccessat 48
457
@@ -XXX,XX +XXX,XX @@ __SYSCALL(__NR_openat, sys_openat)
458
__SYSCALL(__NR_close, sys_close)
459
#define __NR_vhangup 58
460
__SYSCALL(__NR_vhangup, sys_vhangup)
461
-
462
-/* fs/pipe.c */
463
#define __NR_pipe2 59
464
__SYSCALL(__NR_pipe2, sys_pipe2)
465
-
466
-/* fs/quota.c */
467
#define __NR_quotactl 60
468
__SYSCALL(__NR_quotactl, sys_quotactl)
469
-
470
-/* fs/readdir.c */
471
#define __NR_getdents64 61
472
__SYSCALL(__NR_getdents64, sys_getdents64)
473
-
474
-/* fs/read_write.c */
475
#define __NR3264_lseek 62
476
__SC_3264(__NR3264_lseek, sys_llseek, sys_lseek)
477
#define __NR_read 63
478
@@ -XXX,XX +XXX,XX @@ __SC_COMP(__NR_pwrite64, sys_pwrite64, compat_sys_pwrite64)
479
__SC_COMP(__NR_preadv, sys_preadv, compat_sys_preadv)
480
#define __NR_pwritev 70
481
__SC_COMP(__NR_pwritev, sys_pwritev, compat_sys_pwritev)
482
-
483
-/* fs/sendfile.c */
484
#define __NR3264_sendfile 71
485
__SYSCALL(__NR3264_sendfile, sys_sendfile64)
486
487
-/* fs/select.c */
488
#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32
489
#define __NR_pselect6 72
490
__SC_COMP_3264(__NR_pselect6, sys_pselect6_time32, sys_pselect6, compat_sys_pselect6_time32)
491
@@ -XXX,XX +XXX,XX @@ __SC_COMP_3264(__NR_pselect6, sys_pselect6_time32, sys_pselect6, compat_sys_psel
492
__SC_COMP_3264(__NR_ppoll, sys_ppoll_time32, sys_ppoll, compat_sys_ppoll_time32)
493
#endif
494
495
-/* fs/signalfd.c */
496
#define __NR_signalfd4 74
497
__SC_COMP(__NR_signalfd4, sys_signalfd4, compat_sys_signalfd4)
498
-
499
-/* fs/splice.c */
500
#define __NR_vmsplice 75
501
__SYSCALL(__NR_vmsplice, sys_vmsplice)
502
#define __NR_splice 76
503
__SYSCALL(__NR_splice, sys_splice)
504
#define __NR_tee 77
505
__SYSCALL(__NR_tee, sys_tee)
506
-
507
-/* fs/stat.c */
508
#define __NR_readlinkat 78
509
__SYSCALL(__NR_readlinkat, sys_readlinkat)
510
+
511
#if defined(__ARCH_WANT_NEW_STAT) || defined(__ARCH_WANT_STAT64)
512
#define __NR3264_fstatat 79
513
__SC_3264(__NR3264_fstatat, sys_fstatat64, sys_newfstatat)
514
@@ -XXX,XX +XXX,XX @@ __SC_3264(__NR3264_fstatat, sys_fstatat64, sys_newfstatat)
515
__SC_3264(__NR3264_fstat, sys_fstat64, sys_newfstat)
516
#endif
517
518
-/* fs/sync.c */
519
#define __NR_sync 81
520
__SYSCALL(__NR_sync, sys_sync)
521
#define __NR_fsync 82
522
__SYSCALL(__NR_fsync, sys_fsync)
523
#define __NR_fdatasync 83
524
__SYSCALL(__NR_fdatasync, sys_fdatasync)
525
+
526
#ifdef __ARCH_WANT_SYNC_FILE_RANGE2
527
#define __NR_sync_file_range2 84
528
__SC_COMP(__NR_sync_file_range2, sys_sync_file_range2, \
529
@@ -XXX,XX +XXX,XX @@ __SC_COMP(__NR_sync_file_range, sys_sync_file_range, \
530
     compat_sys_sync_file_range)
531
#endif
532
533
-/* fs/timerfd.c */
534
#define __NR_timerfd_create 85
535
__SYSCALL(__NR_timerfd_create, sys_timerfd_create)
536
+
537
#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32
538
#define __NR_timerfd_settime 86
539
__SC_3264(__NR_timerfd_settime, sys_timerfd_settime32, \
540
@@ -XXX,XX +XXX,XX @@ __SC_3264(__NR_timerfd_gettime, sys_timerfd_gettime32, \
541
     sys_timerfd_gettime)
542
#endif
543
544
-/* fs/utimes.c */
545
#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32
546
#define __NR_utimensat 88
547
__SC_3264(__NR_utimensat, sys_utimensat_time32, sys_utimensat)
548
#endif
549
550
-/* kernel/acct.c */
551
#define __NR_acct 89
552
__SYSCALL(__NR_acct, sys_acct)
553
-
554
-/* kernel/capability.c */
555
#define __NR_capget 90
556
__SYSCALL(__NR_capget, sys_capget)
557
#define __NR_capset 91
558
__SYSCALL(__NR_capset, sys_capset)
559
-
560
-/* kernel/exec_domain.c */
561
#define __NR_personality 92
562
__SYSCALL(__NR_personality, sys_personality)
563
-
564
-/* kernel/exit.c */
565
#define __NR_exit 93
566
__SYSCALL(__NR_exit, sys_exit)
567
#define __NR_exit_group 94
568
__SYSCALL(__NR_exit_group, sys_exit_group)
569
#define __NR_waitid 95
570
__SC_COMP(__NR_waitid, sys_waitid, compat_sys_waitid)
571
-
572
-/* kernel/fork.c */
573
#define __NR_set_tid_address 96
574
__SYSCALL(__NR_set_tid_address, sys_set_tid_address)
575
#define __NR_unshare 97
576
__SYSCALL(__NR_unshare, sys_unshare)
577
578
-/* kernel/futex.c */
579
#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32
580
#define __NR_futex 98
581
__SC_3264(__NR_futex, sys_futex_time32, sys_futex)
582
#endif
583
+
584
#define __NR_set_robust_list 99
585
__SC_COMP(__NR_set_robust_list, sys_set_robust_list, \
586
     compat_sys_set_robust_list)
587
@@ -XXX,XX +XXX,XX @@ __SC_COMP(__NR_set_robust_list, sys_set_robust_list, \
588
__SC_COMP(__NR_get_robust_list, sys_get_robust_list, \
589
     compat_sys_get_robust_list)
590
591
-/* kernel/hrtimer.c */
592
#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32
593
#define __NR_nanosleep 101
594
__SC_3264(__NR_nanosleep, sys_nanosleep_time32, sys_nanosleep)
595
#endif
596
597
-/* kernel/itimer.c */
598
#define __NR_getitimer 102
599
__SC_COMP(__NR_getitimer, sys_getitimer, compat_sys_getitimer)
600
#define __NR_setitimer 103
601
__SC_COMP(__NR_setitimer, sys_setitimer, compat_sys_setitimer)
602
-
603
-/* kernel/kexec.c */
604
#define __NR_kexec_load 104
605
__SC_COMP(__NR_kexec_load, sys_kexec_load, compat_sys_kexec_load)
606
-
607
-/* kernel/module.c */
608
#define __NR_init_module 105
609
__SYSCALL(__NR_init_module, sys_init_module)
610
#define __NR_delete_module 106
611
__SYSCALL(__NR_delete_module, sys_delete_module)
612
-
613
-/* kernel/posix-timers.c */
614
#define __NR_timer_create 107
615
__SC_COMP(__NR_timer_create, sys_timer_create, compat_sys_timer_create)
616
+
617
#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32
618
#define __NR_timer_gettime 108
619
__SC_3264(__NR_timer_gettime, sys_timer_gettime32, sys_timer_gettime)
620
#endif
621
+
622
#define __NR_timer_getoverrun 109
623
__SYSCALL(__NR_timer_getoverrun, sys_timer_getoverrun)
624
+
625
#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32
626
#define __NR_timer_settime 110
627
__SC_3264(__NR_timer_settime, sys_timer_settime32, sys_timer_settime)
628
#endif
629
+
630
#define __NR_timer_delete 111
631
__SYSCALL(__NR_timer_delete, sys_timer_delete)
632
+
633
#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32
634
#define __NR_clock_settime 112
635
__SC_3264(__NR_clock_settime, sys_clock_settime32, sys_clock_settime)
636
@@ -XXX,XX +XXX,XX @@ __SC_3264(__NR_clock_nanosleep, sys_clock_nanosleep_time32, \
637
     sys_clock_nanosleep)
638
#endif
639
640
-/* kernel/printk.c */
641
#define __NR_syslog 116
642
__SYSCALL(__NR_syslog, sys_syslog)
643
-
644
-/* kernel/ptrace.c */
645
#define __NR_ptrace 117
646
__SC_COMP(__NR_ptrace, sys_ptrace, compat_sys_ptrace)
647
-
648
-/* kernel/sched/core.c */
649
#define __NR_sched_setparam 118
650
__SYSCALL(__NR_sched_setparam, sys_sched_setparam)
651
#define __NR_sched_setscheduler 119
652
@@ -XXX,XX +XXX,XX @@ __SYSCALL(__NR_sched_yield, sys_sched_yield)
653
__SYSCALL(__NR_sched_get_priority_max, sys_sched_get_priority_max)
654
#define __NR_sched_get_priority_min 126
655
__SYSCALL(__NR_sched_get_priority_min, sys_sched_get_priority_min)
656
+
657
#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32
658
#define __NR_sched_rr_get_interval 127
659
__SC_3264(__NR_sched_rr_get_interval, sys_sched_rr_get_interval_time32, \
660
     sys_sched_rr_get_interval)
661
#endif
662
663
-/* kernel/signal.c */
664
#define __NR_restart_syscall 128
665
__SYSCALL(__NR_restart_syscall, sys_restart_syscall)
666
#define __NR_kill 129
667
@@ -XXX,XX +XXX,XX @@ __SC_COMP(__NR_rt_sigaction, sys_rt_sigaction, compat_sys_rt_sigaction)
668
__SC_COMP(__NR_rt_sigprocmask, sys_rt_sigprocmask, compat_sys_rt_sigprocmask)
669
#define __NR_rt_sigpending 136
670
__SC_COMP(__NR_rt_sigpending, sys_rt_sigpending, compat_sys_rt_sigpending)
671
+
672
#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32
673
#define __NR_rt_sigtimedwait 137
674
__SC_COMP_3264(__NR_rt_sigtimedwait, sys_rt_sigtimedwait_time32, \
675
     sys_rt_sigtimedwait, compat_sys_rt_sigtimedwait_time32)
676
#endif
677
+
678
#define __NR_rt_sigqueueinfo 138
679
__SC_COMP(__NR_rt_sigqueueinfo, sys_rt_sigqueueinfo, \
680
     compat_sys_rt_sigqueueinfo)
681
#define __NR_rt_sigreturn 139
682
__SC_COMP(__NR_rt_sigreturn, sys_rt_sigreturn, compat_sys_rt_sigreturn)
683
-
684
-/* kernel/sys.c */
685
#define __NR_setpriority 140
686
__SYSCALL(__NR_setpriority, sys_setpriority)
687
#define __NR_getpriority 141
688
@@ -XXX,XX +XXX,XX @@ __SYSCALL(__NR_prctl, sys_prctl)
689
#define __NR_getcpu 168
690
__SYSCALL(__NR_getcpu, sys_getcpu)
691
692
-/* kernel/time.c */
693
#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32
694
#define __NR_gettimeofday 169
695
__SC_COMP(__NR_gettimeofday, sys_gettimeofday, compat_sys_gettimeofday)
696
@@ -XXX,XX +XXX,XX @@ __SC_COMP(__NR_settimeofday, sys_settimeofday, compat_sys_settimeofday)
697
__SC_3264(__NR_adjtimex, sys_adjtimex_time32, sys_adjtimex)
698
#endif
699
700
-/* kernel/sys.c */
701
#define __NR_getpid 172
702
__SYSCALL(__NR_getpid, sys_getpid)
703
#define __NR_getppid 173
704
@@ -XXX,XX +XXX,XX @@ __SYSCALL(__NR_getegid, sys_getegid)
705
__SYSCALL(__NR_gettid, sys_gettid)
706
#define __NR_sysinfo 179
707
__SC_COMP(__NR_sysinfo, sys_sysinfo, compat_sys_sysinfo)
708
-
709
-/* ipc/mqueue.c */
710
#define __NR_mq_open 180
711
__SC_COMP(__NR_mq_open, sys_mq_open, compat_sys_mq_open)
712
#define __NR_mq_unlink 181
713
__SYSCALL(__NR_mq_unlink, sys_mq_unlink)
714
+
715
#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32
716
#define __NR_mq_timedsend 182
717
__SC_3264(__NR_mq_timedsend, sys_mq_timedsend_time32, sys_mq_timedsend)
718
@@ -XXX,XX +XXX,XX @@ __SC_3264(__NR_mq_timedsend, sys_mq_timedsend_time32, sys_mq_timedsend)
719
__SC_3264(__NR_mq_timedreceive, sys_mq_timedreceive_time32, \
720
     sys_mq_timedreceive)
721
#endif
722
+
723
#define __NR_mq_notify 184
724
__SC_COMP(__NR_mq_notify, sys_mq_notify, compat_sys_mq_notify)
725
#define __NR_mq_getsetattr 185
726
__SC_COMP(__NR_mq_getsetattr, sys_mq_getsetattr, compat_sys_mq_getsetattr)
727
-
728
-/* ipc/msg.c */
729
#define __NR_msgget 186
730
__SYSCALL(__NR_msgget, sys_msgget)
731
#define __NR_msgctl 187
732
@@ -XXX,XX +XXX,XX @@ __SC_COMP(__NR_msgctl, sys_msgctl, compat_sys_msgctl)
733
__SC_COMP(__NR_msgrcv, sys_msgrcv, compat_sys_msgrcv)
734
#define __NR_msgsnd 189
735
__SC_COMP(__NR_msgsnd, sys_msgsnd, compat_sys_msgsnd)
736
-
737
-/* ipc/sem.c */
738
#define __NR_semget 190
739
__SYSCALL(__NR_semget, sys_semget)
740
#define __NR_semctl 191
741
__SC_COMP(__NR_semctl, sys_semctl, compat_sys_semctl)
742
+
743
#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32
744
#define __NR_semtimedop 192
745
__SC_3264(__NR_semtimedop, sys_semtimedop_time32, sys_semtimedop)
746
#endif
747
+
748
#define __NR_semop 193
749
__SYSCALL(__NR_semop, sys_semop)
750
-
751
-/* ipc/shm.c */
752
#define __NR_shmget 194
753
__SYSCALL(__NR_shmget, sys_shmget)
754
#define __NR_shmctl 195
755
@@ -XXX,XX +XXX,XX @@ __SC_COMP(__NR_shmctl, sys_shmctl, compat_sys_shmctl)
756
__SC_COMP(__NR_shmat, sys_shmat, compat_sys_shmat)
757
#define __NR_shmdt 197
758
__SYSCALL(__NR_shmdt, sys_shmdt)
759
-
760
-/* net/socket.c */
761
#define __NR_socket 198
762
__SYSCALL(__NR_socket, sys_socket)
763
#define __NR_socketpair 199
764
@@ -XXX,XX +XXX,XX @@ __SYSCALL(__NR_shutdown, sys_shutdown)
765
__SC_COMP(__NR_sendmsg, sys_sendmsg, compat_sys_sendmsg)
766
#define __NR_recvmsg 212
767
__SC_COMP(__NR_recvmsg, sys_recvmsg, compat_sys_recvmsg)
768
-
769
-/* mm/filemap.c */
770
#define __NR_readahead 213
771
__SC_COMP(__NR_readahead, sys_readahead, compat_sys_readahead)
772
-
773
-/* mm/nommu.c, also with MMU */
774
#define __NR_brk 214
775
__SYSCALL(__NR_brk, sys_brk)
776
#define __NR_munmap 215
777
__SYSCALL(__NR_munmap, sys_munmap)
778
#define __NR_mremap 216
779
__SYSCALL(__NR_mremap, sys_mremap)
780
-
781
-/* security/keys/keyctl.c */
782
#define __NR_add_key 217
783
__SYSCALL(__NR_add_key, sys_add_key)
784
#define __NR_request_key 218
785
__SYSCALL(__NR_request_key, sys_request_key)
786
#define __NR_keyctl 219
787
__SC_COMP(__NR_keyctl, sys_keyctl, compat_sys_keyctl)
788
-
789
-/* arch/example/kernel/sys_example.c */
790
#define __NR_clone 220
791
__SYSCALL(__NR_clone, sys_clone)
792
#define __NR_execve 221
793
__SC_COMP(__NR_execve, sys_execve, compat_sys_execve)
794
-
795
#define __NR3264_mmap 222
796
__SC_3264(__NR3264_mmap, sys_mmap2, sys_mmap)
797
-/* mm/fadvise.c */
798
#define __NR3264_fadvise64 223
799
__SC_COMP(__NR3264_fadvise64, sys_fadvise64_64, compat_sys_fadvise64_64)
800
801
-/* mm/, CONFIG_MMU only */
802
+/* CONFIG_MMU only */
803
#ifndef __ARCH_NOMMU
804
#define __NR_swapon 224
805
__SYSCALL(__NR_swapon, sys_swapon)
806
@@ -XXX,XX +XXX,XX @@ __SC_COMP(__NR_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo, \
807
__SYSCALL(__NR_perf_event_open, sys_perf_event_open)
808
#define __NR_accept4 242
809
__SYSCALL(__NR_accept4, sys_accept4)
810
+
811
#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32
812
#define __NR_recvmmsg 243
813
__SC_COMP_3264(__NR_recvmmsg, sys_recvmmsg_time32, sys_recvmmsg, compat_sys_recvmmsg_time32)
814
@@ -XXX,XX +XXX,XX @@ __SC_COMP_3264(__NR_recvmmsg, sys_recvmmsg_time32, sys_recvmmsg, compat_sys_recv
815
#define __NR_wait4 260
816
__SC_COMP(__NR_wait4, sys_wait4, compat_sys_wait4)
817
#endif
818
+
819
#define __NR_prlimit64 261
820
__SYSCALL(__NR_prlimit64, sys_prlimit64)
821
#define __NR_fanotify_init 262
822
@@ -XXX,XX +XXX,XX @@ __SYSCALL(__NR_fanotify_mark, sys_fanotify_mark)
823
__SYSCALL(__NR_name_to_handle_at, sys_name_to_handle_at)
824
#define __NR_open_by_handle_at 265
825
__SYSCALL(__NR_open_by_handle_at, sys_open_by_handle_at)
826
+
827
#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32
828
#define __NR_clock_adjtime 266
829
__SC_3264(__NR_clock_adjtime, sys_clock_adjtime32, sys_clock_adjtime)
830
#endif
831
+
832
#define __NR_syncfs 267
833
__SYSCALL(__NR_syncfs, sys_syncfs)
834
#define __NR_setns 268
835
@@ -XXX,XX +XXX,XX @@ __SYSCALL(__NR_pkey_alloc, sys_pkey_alloc)
836
__SYSCALL(__NR_pkey_free, sys_pkey_free)
837
#define __NR_statx 291
838
__SYSCALL(__NR_statx, sys_statx)
839
+
840
#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32
841
#define __NR_io_pgetevents 292
842
__SC_COMP_3264(__NR_io_pgetevents, sys_io_pgetevents_time32, sys_io_pgetevents, compat_sys_io_pgetevents)
843
#endif
844
+
845
#define __NR_rseq 293
846
__SYSCALL(__NR_rseq, sys_rseq)
847
#define __NR_kexec_file_load 294
848
__SYSCALL(__NR_kexec_file_load, sys_kexec_file_load)
849
+
850
/* 295 through 402 are unassigned to sync up with generic numbers, don't use */
851
+
852
#if defined(__SYSCALL_COMPAT) || __BITS_PER_LONG == 32
853
#define __NR_clock_gettime64 403
854
__SYSCALL(__NR_clock_gettime64, sys_clock_gettime)
855
@@ -XXX,XX +XXX,XX @@ __SYSCALL(__NR_fsmount, sys_fsmount)
856
__SYSCALL(__NR_fspick, sys_fspick)
857
#define __NR_pidfd_open 434
858
__SYSCALL(__NR_pidfd_open, sys_pidfd_open)
859
+
860
#ifdef __ARCH_WANT_SYS_CLONE3
861
#define __NR_clone3 435
862
__SYSCALL(__NR_clone3, sys_clone3)
863
#endif
864
+
865
#define __NR_close_range 436
866
__SYSCALL(__NR_close_range, sys_close_range)
867
-
868
#define __NR_openat2 437
869
__SYSCALL(__NR_openat2, sys_openat2)
870
#define __NR_pidfd_getfd 438
871
@@ -XXX,XX +XXX,XX @@ __SC_COMP(__NR_epoll_pwait2, sys_epoll_pwait2, compat_sys_epoll_pwait2)
872
__SYSCALL(__NR_mount_setattr, sys_mount_setattr)
873
#define __NR_quotactl_fd 443
874
__SYSCALL(__NR_quotactl_fd, sys_quotactl_fd)
875
-
876
#define __NR_landlock_create_ruleset 444
877
__SYSCALL(__NR_landlock_create_ruleset, sys_landlock_create_ruleset)
878
#define __NR_landlock_add_rule 445
879
@@ -XXX,XX +XXX,XX @@ __SYSCALL(__NR_landlock_restrict_self, sys_landlock_restrict_self)
880
#define __NR_memfd_secret 447
881
__SYSCALL(__NR_memfd_secret, sys_memfd_secret)
882
#endif
883
+
884
#define __NR_process_mrelease 448
885
__SYSCALL(__NR_process_mrelease, sys_process_mrelease)
886
-
887
#define __NR_futex_waitv 449
888
__SYSCALL(__NR_futex_waitv, sys_futex_waitv)
889
-
890
#define __NR_set_mempolicy_home_node 450
891
__SYSCALL(__NR_set_mempolicy_home_node, sys_set_mempolicy_home_node)
892
893
+#define __NR_cachestat 451
894
+__SYSCALL(__NR_cachestat, sys_cachestat)
895
+
896
#undef __NR_syscalls
897
-#define __NR_syscalls 451
898
+#define __NR_syscalls 452
899
900
/*
901
* 32 bit systems traditionally used different
902
diff --git a/linux-headers/asm-mips/unistd_n32.h b/linux-headers/asm-mips/unistd_n32.h
903
index XXXXXXX..XXXXXXX 100644
904
--- a/linux-headers/asm-mips/unistd_n32.h
905
+++ b/linux-headers/asm-mips/unistd_n32.h
906
@@ -XXX,XX +XXX,XX @@
907
#define __NR_process_mrelease (__NR_Linux + 448)
908
#define __NR_futex_waitv (__NR_Linux + 449)
909
#define __NR_set_mempolicy_home_node (__NR_Linux + 450)
910
+#define __NR_cachestat (__NR_Linux + 451)
911
912
#endif /* _ASM_UNISTD_N32_H */
913
diff --git a/linux-headers/asm-mips/unistd_n64.h b/linux-headers/asm-mips/unistd_n64.h
914
index XXXXXXX..XXXXXXX 100644
915
--- a/linux-headers/asm-mips/unistd_n64.h
916
+++ b/linux-headers/asm-mips/unistd_n64.h
917
@@ -XXX,XX +XXX,XX @@
918
#define __NR_process_mrelease (__NR_Linux + 448)
919
#define __NR_futex_waitv (__NR_Linux + 449)
920
#define __NR_set_mempolicy_home_node (__NR_Linux + 450)
921
+#define __NR_cachestat (__NR_Linux + 451)
922
923
#endif /* _ASM_UNISTD_N64_H */
924
diff --git a/linux-headers/asm-mips/unistd_o32.h b/linux-headers/asm-mips/unistd_o32.h
925
index XXXXXXX..XXXXXXX 100644
926
--- a/linux-headers/asm-mips/unistd_o32.h
927
+++ b/linux-headers/asm-mips/unistd_o32.h
928
@@ -XXX,XX +XXX,XX @@
929
#define __NR_process_mrelease (__NR_Linux + 448)
930
#define __NR_futex_waitv (__NR_Linux + 449)
931
#define __NR_set_mempolicy_home_node (__NR_Linux + 450)
932
+#define __NR_cachestat (__NR_Linux + 451)
933
934
#endif /* _ASM_UNISTD_O32_H */
935
diff --git a/linux-headers/asm-powerpc/unistd_32.h b/linux-headers/asm-powerpc/unistd_32.h
936
index XXXXXXX..XXXXXXX 100644
937
--- a/linux-headers/asm-powerpc/unistd_32.h
938
+++ b/linux-headers/asm-powerpc/unistd_32.h
939
@@ -XXX,XX +XXX,XX @@
940
#define __NR_process_mrelease 448
941
#define __NR_futex_waitv 449
942
#define __NR_set_mempolicy_home_node 450
943
+#define __NR_cachestat 451
944
945
946
#endif /* _ASM_UNISTD_32_H */
947
diff --git a/linux-headers/asm-powerpc/unistd_64.h b/linux-headers/asm-powerpc/unistd_64.h
948
index XXXXXXX..XXXXXXX 100644
949
--- a/linux-headers/asm-powerpc/unistd_64.h
950
+++ b/linux-headers/asm-powerpc/unistd_64.h
951
@@ -XXX,XX +XXX,XX @@
952
#define __NR_process_mrelease 448
953
#define __NR_futex_waitv 449
954
#define __NR_set_mempolicy_home_node 450
955
+#define __NR_cachestat 451
956
957
958
#endif /* _ASM_UNISTD_64_H */
959
diff --git a/linux-headers/asm-riscv/bitsperlong.h b/linux-headers/asm-riscv/bitsperlong.h
960
index XXXXXXX..XXXXXXX 100644
961
--- a/linux-headers/asm-riscv/bitsperlong.h
962
+++ b/linux-headers/asm-riscv/bitsperlong.h
963
@@ -1,14 +1 @@
964
-/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
965
-/*
966
- * Copyright (C) 2012 ARM Ltd.
967
- * Copyright (C) 2015 Regents of the University of California
968
- */
969
-
970
-#ifndef _ASM_RISCV_BITSPERLONG_H
971
-#define _ASM_RISCV_BITSPERLONG_H
972
-
973
-#define __BITS_PER_LONG (__SIZEOF_POINTER__ * 8)
974
-
975
#include <asm-generic/bitsperlong.h>
976
-
977
-#endif /* _ASM_RISCV_BITSPERLONG_H */
978
diff --git a/linux-headers/asm-riscv/kvm.h b/linux-headers/asm-riscv/kvm.h
979
index XXXXXXX..XXXXXXX 100644
980
--- a/linux-headers/asm-riscv/kvm.h
981
+++ b/linux-headers/asm-riscv/kvm.h
982
@@ -XXX,XX +XXX,XX @@
983
#ifndef __ASSEMBLY__
984
985
#include <linux/types.h>
986
+#include <asm/bitsperlong.h>
987
#include <asm/ptrace.h>
988
989
+#define __KVM_HAVE_IRQ_LINE
990
#define __KVM_HAVE_READONLY_MEM
991
992
#define KVM_COALESCED_MMIO_PAGE_OFFSET 1
993
@@ -XXX,XX +XXX,XX @@ struct kvm_riscv_config {
994
    unsigned long mvendorid;
995
    unsigned long marchid;
996
    unsigned long mimpid;
997
+    unsigned long zicboz_block_size;
998
};
999
1000
/* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
1001
@@ -XXX,XX +XXX,XX @@ struct kvm_riscv_core {
1002
#define KVM_RISCV_MODE_S    1
1003
#define KVM_RISCV_MODE_U    0
1004
1005
-/* CSR registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
1006
+/* General CSR registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
1007
struct kvm_riscv_csr {
1008
    unsigned long sstatus;
1009
    unsigned long sie;
1010
@@ -XXX,XX +XXX,XX @@ struct kvm_riscv_csr {
1011
    unsigned long scounteren;
1012
};
1013
1014
+/* AIA CSR registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
1015
+struct kvm_riscv_aia_csr {
1016
+    unsigned long siselect;
1017
+    unsigned long iprio1;
1018
+    unsigned long iprio2;
1019
+    unsigned long sieh;
1020
+    unsigned long siph;
1021
+    unsigned long iprio1h;
1022
+    unsigned long iprio2h;
1023
+};
1024
+
1025
/* TIMER registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
1026
struct kvm_riscv_timer {
1027
    __u64 frequency;
1028
@@ -XXX,XX +XXX,XX @@ enum KVM_RISCV_ISA_EXT_ID {
1029
    KVM_RISCV_ISA_EXT_SVINVAL,
1030
    KVM_RISCV_ISA_EXT_ZIHINTPAUSE,
1031
    KVM_RISCV_ISA_EXT_ZICBOM,
1032
+    KVM_RISCV_ISA_EXT_ZICBOZ,
1033
+    KVM_RISCV_ISA_EXT_ZBB,
1034
+    KVM_RISCV_ISA_EXT_SSAIA,
1035
+    KVM_RISCV_ISA_EXT_V,
1036
+    KVM_RISCV_ISA_EXT_SVNAPOT,
1037
    KVM_RISCV_ISA_EXT_MAX,
1038
};
1039
1040
+/*
1041
+ * SBI extension IDs specific to KVM. This is not the same as the SBI
1042
+ * extension IDs defined by the RISC-V SBI specification.
1043
+ */
1044
+enum KVM_RISCV_SBI_EXT_ID {
1045
+    KVM_RISCV_SBI_EXT_V01 = 0,
1046
+    KVM_RISCV_SBI_EXT_TIME,
1047
+    KVM_RISCV_SBI_EXT_IPI,
1048
+    KVM_RISCV_SBI_EXT_RFENCE,
1049
+    KVM_RISCV_SBI_EXT_SRST,
1050
+    KVM_RISCV_SBI_EXT_HSM,
1051
+    KVM_RISCV_SBI_EXT_PMU,
1052
+    KVM_RISCV_SBI_EXT_EXPERIMENTAL,
1053
+    KVM_RISCV_SBI_EXT_VENDOR,
1054
+    KVM_RISCV_SBI_EXT_MAX,
1055
+};
1056
+
1057
/* Possible states for kvm_riscv_timer */
1058
#define KVM_RISCV_TIMER_STATE_OFF    0
1059
#define KVM_RISCV_TIMER_STATE_ON    1
1060
@@ -XXX,XX +XXX,XX @@ enum KVM_RISCV_ISA_EXT_ID {
1061
/* If you need to interpret the index values, here is the key: */
1062
#define KVM_REG_RISCV_TYPE_MASK        0x00000000FF000000
1063
#define KVM_REG_RISCV_TYPE_SHIFT    24
1064
+#define KVM_REG_RISCV_SUBTYPE_MASK    0x0000000000FF0000
1065
+#define KVM_REG_RISCV_SUBTYPE_SHIFT    16
1066
1067
/* Config registers are mapped as type 1 */
1068
#define KVM_REG_RISCV_CONFIG        (0x01 << KVM_REG_RISCV_TYPE_SHIFT)
1069
@@ -XXX,XX +XXX,XX @@ enum KVM_RISCV_ISA_EXT_ID {
1070
1071
/* Control and status registers are mapped as type 3 */
1072
#define KVM_REG_RISCV_CSR        (0x03 << KVM_REG_RISCV_TYPE_SHIFT)
1073
+#define KVM_REG_RISCV_CSR_GENERAL    (0x0 << KVM_REG_RISCV_SUBTYPE_SHIFT)
1074
+#define KVM_REG_RISCV_CSR_AIA        (0x1 << KVM_REG_RISCV_SUBTYPE_SHIFT)
1075
#define KVM_REG_RISCV_CSR_REG(name)    \
1076
        (offsetof(struct kvm_riscv_csr, name) / sizeof(unsigned long))
1077
+#define KVM_REG_RISCV_CSR_AIA_REG(name)    \
1078
+    (offsetof(struct kvm_riscv_aia_csr, name) / sizeof(unsigned long))
1079
1080
/* Timer registers are mapped as type 4 */
1081
#define KVM_REG_RISCV_TIMER        (0x04 << KVM_REG_RISCV_TYPE_SHIFT)
1082
@@ -XXX,XX +XXX,XX @@ enum KVM_RISCV_ISA_EXT_ID {
1083
/* ISA Extension registers are mapped as type 7 */
1084
#define KVM_REG_RISCV_ISA_EXT        (0x07 << KVM_REG_RISCV_TYPE_SHIFT)
1085
1086
+/* SBI extension registers are mapped as type 8 */
1087
+#define KVM_REG_RISCV_SBI_EXT        (0x08 << KVM_REG_RISCV_TYPE_SHIFT)
1088
+#define KVM_REG_RISCV_SBI_SINGLE    (0x0 << KVM_REG_RISCV_SUBTYPE_SHIFT)
1089
+#define KVM_REG_RISCV_SBI_MULTI_EN    (0x1 << KVM_REG_RISCV_SUBTYPE_SHIFT)
1090
+#define KVM_REG_RISCV_SBI_MULTI_DIS    (0x2 << KVM_REG_RISCV_SUBTYPE_SHIFT)
1091
+#define KVM_REG_RISCV_SBI_MULTI_REG(__ext_id)    \
1092
+        ((__ext_id) / __BITS_PER_LONG)
1093
+#define KVM_REG_RISCV_SBI_MULTI_MASK(__ext_id)    \
1094
+        (1UL << ((__ext_id) % __BITS_PER_LONG))
1095
+#define KVM_REG_RISCV_SBI_MULTI_REG_LAST    \
1096
+        KVM_REG_RISCV_SBI_MULTI_REG(KVM_RISCV_SBI_EXT_MAX - 1)
1097
+
1098
+/* V extension registers are mapped as type 9 */
1099
+#define KVM_REG_RISCV_VECTOR        (0x09 << KVM_REG_RISCV_TYPE_SHIFT)
1100
+#define KVM_REG_RISCV_VECTOR_CSR_REG(name)    \
1101
+        (offsetof(struct __riscv_v_ext_state, name) / sizeof(unsigned long))
1102
+#define KVM_REG_RISCV_VECTOR_REG(n)    \
1103
+        ((n) + sizeof(struct __riscv_v_ext_state) / sizeof(unsigned long))
1104
+
1105
+/* Device Control API: RISC-V AIA */
1106
+#define KVM_DEV_RISCV_APLIC_ALIGN        0x1000
1107
+#define KVM_DEV_RISCV_APLIC_SIZE        0x4000
1108
+#define KVM_DEV_RISCV_APLIC_MAX_HARTS        0x4000
1109
+#define KVM_DEV_RISCV_IMSIC_ALIGN        0x1000
1110
+#define KVM_DEV_RISCV_IMSIC_SIZE        0x1000
1111
+
1112
+#define KVM_DEV_RISCV_AIA_GRP_CONFIG        0
1113
+#define KVM_DEV_RISCV_AIA_CONFIG_MODE        0
1114
+#define KVM_DEV_RISCV_AIA_CONFIG_IDS        1
1115
+#define KVM_DEV_RISCV_AIA_CONFIG_SRCS        2
1116
+#define KVM_DEV_RISCV_AIA_CONFIG_GROUP_BITS    3
1117
+#define KVM_DEV_RISCV_AIA_CONFIG_GROUP_SHIFT    4
1118
+#define KVM_DEV_RISCV_AIA_CONFIG_HART_BITS    5
1119
+#define KVM_DEV_RISCV_AIA_CONFIG_GUEST_BITS    6
1120
+
1121
+/*
1122
+ * Modes of RISC-V AIA device:
1123
+ * 1) EMUL (aka Emulation): Trap-n-emulate IMSIC
1124
+ * 2) HWACCEL (aka HW Acceleration): Virtualize IMSIC using IMSIC guest files
1125
+ * 3) AUTO (aka Automatic): Virtualize IMSIC using IMSIC guest files whenever
1126
+ * available otherwise fallback to trap-n-emulation
1127
+ */
1128
+#define KVM_DEV_RISCV_AIA_MODE_EMUL        0
1129
+#define KVM_DEV_RISCV_AIA_MODE_HWACCEL        1
1130
+#define KVM_DEV_RISCV_AIA_MODE_AUTO        2
1131
+
1132
+#define KVM_DEV_RISCV_AIA_IDS_MIN        63
1133
+#define KVM_DEV_RISCV_AIA_IDS_MAX        2048
1134
+#define KVM_DEV_RISCV_AIA_SRCS_MAX        1024
1135
+#define KVM_DEV_RISCV_AIA_GROUP_BITS_MAX    8
1136
+#define KVM_DEV_RISCV_AIA_GROUP_SHIFT_MIN    24
1137
+#define KVM_DEV_RISCV_AIA_GROUP_SHIFT_MAX    56
1138
+#define KVM_DEV_RISCV_AIA_HART_BITS_MAX        16
1139
+#define KVM_DEV_RISCV_AIA_GUEST_BITS_MAX    8
1140
+
1141
+#define KVM_DEV_RISCV_AIA_GRP_ADDR        1
1142
+#define KVM_DEV_RISCV_AIA_ADDR_APLIC        0
1143
+#define KVM_DEV_RISCV_AIA_ADDR_IMSIC(__vcpu)    (1 + (__vcpu))
1144
+#define KVM_DEV_RISCV_AIA_ADDR_MAX        \
1145
+        (1 + KVM_DEV_RISCV_APLIC_MAX_HARTS)
1146
+
1147
+#define KVM_DEV_RISCV_AIA_GRP_CTRL        2
1148
+#define KVM_DEV_RISCV_AIA_CTRL_INIT        0
1149
+
1150
+/*
1151
+ * The device attribute type contains the memory mapped offset of the
1152
+ * APLIC register (range 0x0000-0x3FFF) and it must be 4-byte aligned.
1153
+ */
1154
+#define KVM_DEV_RISCV_AIA_GRP_APLIC        3
1155
+
1156
+/*
1157
+ * The lower 12-bits of the device attribute type contains the iselect
1158
+ * value of the IMSIC register (range 0x70-0xFF) whereas the higher order
1159
+ * bits contains the VCPU id.
1160
+ */
1161
+#define KVM_DEV_RISCV_AIA_GRP_IMSIC        4
1162
+#define KVM_DEV_RISCV_AIA_IMSIC_ISEL_BITS    12
1163
+#define KVM_DEV_RISCV_AIA_IMSIC_ISEL_MASK    \
1164
+        ((1U << KVM_DEV_RISCV_AIA_IMSIC_ISEL_BITS) - 1)
1165
+#define KVM_DEV_RISCV_AIA_IMSIC_MKATTR(__vcpu, __isel)    \
1166
+        (((__vcpu) << KVM_DEV_RISCV_AIA_IMSIC_ISEL_BITS) | \
1167
+         ((__isel) & KVM_DEV_RISCV_AIA_IMSIC_ISEL_MASK))
1168
+#define KVM_DEV_RISCV_AIA_IMSIC_GET_ISEL(__attr)    \
1169
+        ((__attr) & KVM_DEV_RISCV_AIA_IMSIC_ISEL_MASK)
1170
+#define KVM_DEV_RISCV_AIA_IMSIC_GET_VCPU(__attr)    \
1171
+        ((__attr) >> KVM_DEV_RISCV_AIA_IMSIC_ISEL_BITS)
1172
+
1173
+/* One single KVM irqchip, ie. the AIA */
1174
+#define KVM_NR_IRQCHIPS            1
1175
+
1176
#endif
1177
1178
#endif /* __LINUX_KVM_RISCV_H */
1179
diff --git a/linux-headers/asm-riscv/unistd.h b/linux-headers/asm-riscv/unistd.h
1180
index XXXXXXX..XXXXXXX 100644
1181
--- a/linux-headers/asm-riscv/unistd.h
1182
+++ b/linux-headers/asm-riscv/unistd.h
1183
@@ -XXX,XX +XXX,XX @@
1184
#define __NR_riscv_flush_icache (__NR_arch_specific_syscall + 15)
1185
#endif
1186
__SYSCALL(__NR_riscv_flush_icache, sys_riscv_flush_icache)
1187
+
1188
+/*
1189
+ * Allows userspace to query the kernel for CPU architecture and
1190
+ * microarchitecture details across a given set of CPUs.
1191
+ */
1192
+#ifndef __NR_riscv_hwprobe
1193
+#define __NR_riscv_hwprobe (__NR_arch_specific_syscall + 14)
1194
+#endif
1195
+__SYSCALL(__NR_riscv_hwprobe, sys_riscv_hwprobe)
1196
diff --git a/linux-headers/asm-s390/unistd_32.h b/linux-headers/asm-s390/unistd_32.h
1197
index XXXXXXX..XXXXXXX 100644
1198
--- a/linux-headers/asm-s390/unistd_32.h
1199
+++ b/linux-headers/asm-s390/unistd_32.h
1200
@@ -XXX,XX +XXX,XX @@
1201
#define __NR_landlock_create_ruleset 444
1202
#define __NR_landlock_add_rule 445
1203
#define __NR_landlock_restrict_self 446
1204
+#define __NR_memfd_secret 447
1205
#define __NR_process_mrelease 448
1206
#define __NR_futex_waitv 449
1207
#define __NR_set_mempolicy_home_node 450
1208
+#define __NR_cachestat 451
1209
1210
#endif /* _ASM_S390_UNISTD_32_H */
1211
diff --git a/linux-headers/asm-s390/unistd_64.h b/linux-headers/asm-s390/unistd_64.h
1212
index XXXXXXX..XXXXXXX 100644
1213
--- a/linux-headers/asm-s390/unistd_64.h
1214
+++ b/linux-headers/asm-s390/unistd_64.h
1215
@@ -XXX,XX +XXX,XX @@
1216
#define __NR_landlock_create_ruleset 444
1217
#define __NR_landlock_add_rule 445
1218
#define __NR_landlock_restrict_self 446
1219
+#define __NR_memfd_secret 447
1220
#define __NR_process_mrelease 448
1221
#define __NR_futex_waitv 449
1222
#define __NR_set_mempolicy_home_node 450
1223
+#define __NR_cachestat 451
1224
1225
#endif /* _ASM_S390_UNISTD_64_H */
1226
diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h
1227
index XXXXXXX..XXXXXXX 100644
1228
--- a/linux-headers/asm-x86/kvm.h
1229
+++ b/linux-headers/asm-x86/kvm.h
1230
@@ -XXX,XX +XXX,XX @@ struct kvm_pmu_event_filter {
1231
#define KVM_VCPU_TSC_CTRL 0 /* control group for the timestamp counter (TSC) */
1232
#define KVM_VCPU_TSC_OFFSET 0 /* attribute for the TSC offset */
1233
1234
+/* x86-specific KVM_EXIT_HYPERCALL flags. */
1235
+#define KVM_EXIT_HYPERCALL_LONG_MODE    BIT(0)
1236
+
1237
#endif /* _ASM_X86_KVM_H */
1238
diff --git a/linux-headers/asm-x86/unistd_32.h b/linux-headers/asm-x86/unistd_32.h
1239
index XXXXXXX..XXXXXXX 100644
1240
--- a/linux-headers/asm-x86/unistd_32.h
1241
+++ b/linux-headers/asm-x86/unistd_32.h
1242
@@ -XXX,XX +XXX,XX @@
1243
#define __NR_process_mrelease 448
1244
#define __NR_futex_waitv 449
1245
#define __NR_set_mempolicy_home_node 450
1246
+#define __NR_cachestat 451
1247
1248
1249
#endif /* _ASM_UNISTD_32_H */
1250
diff --git a/linux-headers/asm-x86/unistd_64.h b/linux-headers/asm-x86/unistd_64.h
1251
index XXXXXXX..XXXXXXX 100644
1252
--- a/linux-headers/asm-x86/unistd_64.h
1253
+++ b/linux-headers/asm-x86/unistd_64.h
1254
@@ -XXX,XX +XXX,XX @@
1255
#define __NR_process_mrelease 448
1256
#define __NR_futex_waitv 449
1257
#define __NR_set_mempolicy_home_node 450
1258
+#define __NR_cachestat 451
1259
1260
1261
#endif /* _ASM_UNISTD_64_H */
1262
diff --git a/linux-headers/asm-x86/unistd_x32.h b/linux-headers/asm-x86/unistd_x32.h
1263
index XXXXXXX..XXXXXXX 100644
1264
--- a/linux-headers/asm-x86/unistd_x32.h
1265
+++ b/linux-headers/asm-x86/unistd_x32.h
1266
@@ -XXX,XX +XXX,XX @@
1267
#define __NR_process_mrelease (__X32_SYSCALL_BIT + 448)
1268
#define __NR_futex_waitv (__X32_SYSCALL_BIT + 449)
1269
#define __NR_set_mempolicy_home_node (__X32_SYSCALL_BIT + 450)
1270
+#define __NR_cachestat (__X32_SYSCALL_BIT + 451)
1271
#define __NR_rt_sigaction (__X32_SYSCALL_BIT + 512)
1272
#define __NR_rt_sigreturn (__X32_SYSCALL_BIT + 513)
1273
#define __NR_ioctl (__X32_SYSCALL_BIT + 514)
1274
diff --git a/linux-headers/linux/const.h b/linux-headers/linux/const.h
1275
index XXXXXXX..XXXXXXX 100644
1276
--- a/linux-headers/linux/const.h
1277
+++ b/linux-headers/linux/const.h
1278
@@ -XXX,XX +XXX,XX @@
1279
#define _BITUL(x)    (_UL(1) << (x))
1280
#define _BITULL(x)    (_ULL(1) << (x))
1281
1282
-#define __ALIGN_KERNEL(x, a)        __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
1283
+#define __ALIGN_KERNEL(x, a)        __ALIGN_KERNEL_MASK(x, (__typeof__(x))(a) - 1)
1284
#define __ALIGN_KERNEL_MASK(x, mask)    (((x) + (mask)) & ~(mask))
1285
1286
#define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
1287
diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
1288
index XXXXXXX..XXXXXXX 100644
1289
--- a/linux-headers/linux/kvm.h
1290
+++ b/linux-headers/linux/kvm.h
1291
@@ -XXX,XX +XXX,XX @@ struct kvm_run {
1292
            __u64 nr;
1293
            __u64 args[6];
1294
            __u64 ret;
1295
-            __u32 longmode;
1296
-            __u32 pad;
1297
+
1298
+            union {
1299
+                __u32 longmode;
1300
+                __u64 flags;
1301
+            };
1302
        } hypercall;
1303
        /* KVM_EXIT_TPR_ACCESS */
1304
        struct {
1305
@@ -XXX,XX +XXX,XX @@ struct kvm_ppc_resize_hpt {
1306
#define KVM_CAP_S390_PROTECTED_ASYNC_DISABLE 224
1307
#define KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 225
1308
#define KVM_CAP_PMU_EVENT_MASKED_EVENTS 226
1309
+#define KVM_CAP_COUNTER_OFFSET 227
1310
+#define KVM_CAP_ARM_EAGER_SPLIT_CHUNK_SIZE 228
1311
+#define KVM_CAP_ARM_SUPPORTED_BLOCK_SIZES 229
1312
1313
#ifdef KVM_CAP_IRQ_ROUTING
1314
1315
@@ -XXX,XX +XXX,XX @@ enum kvm_device_type {
1316
#define KVM_DEV_TYPE_XIVE        KVM_DEV_TYPE_XIVE
1317
    KVM_DEV_TYPE_ARM_PV_TIME,
1318
#define KVM_DEV_TYPE_ARM_PV_TIME    KVM_DEV_TYPE_ARM_PV_TIME
1319
+    KVM_DEV_TYPE_RISCV_AIA,
1320
+#define KVM_DEV_TYPE_RISCV_AIA        KVM_DEV_TYPE_RISCV_AIA
1321
    KVM_DEV_TYPE_MAX,
1322
};
1323
1324
@@ -XXX,XX +XXX,XX @@ struct kvm_vfio_spapr_tce {
1325
#define KVM_CREATE_VCPU _IO(KVMIO, 0x41)
1326
#define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log)
1327
#define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44)
1328
-#define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45)
1329
+#define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45) /* deprecated */
1330
#define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, \
1331
                    struct kvm_userspace_memory_region)
1332
#define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47)
1333
@@ -XXX,XX +XXX,XX @@ struct kvm_s390_ucas_mapping {
1334
#define KVM_SET_PMU_EVENT_FILTER _IOW(KVMIO, 0xb2, struct kvm_pmu_event_filter)
1335
#define KVM_PPC_SVM_OFF         _IO(KVMIO, 0xb3)
1336
#define KVM_ARM_MTE_COPY_TAGS     _IOR(KVMIO, 0xb4, struct kvm_arm_copy_mte_tags)
1337
+/* Available with KVM_CAP_COUNTER_OFFSET */
1338
+#define KVM_ARM_SET_COUNTER_OFFSET _IOW(KVMIO, 0xb5, struct kvm_arm_counter_offset)
1339
1340
/* ioctl for vm fd */
1341
#define KVM_CREATE_DEVICE     _IOWR(KVMIO, 0xe0, struct kvm_create_device)
1342
@@ -XXX,XX +XXX,XX @@ struct kvm_s390_ucas_mapping {
1343
#define KVM_GET_DEBUGREGS _IOR(KVMIO, 0xa1, struct kvm_debugregs)
1344
#define KVM_SET_DEBUGREGS _IOW(KVMIO, 0xa2, struct kvm_debugregs)
1345
/*
1346
- * vcpu version available with KVM_ENABLE_CAP
1347
+ * vcpu version available with KVM_CAP_ENABLE_CAP
1348
* vm version available with KVM_CAP_ENABLE_CAP_VM
1349
*/
1350
#define KVM_ENABLE_CAP _IOW(KVMIO, 0xa3, struct kvm_enable_cap)
1351
diff --git a/linux-headers/linux/mman.h b/linux-headers/linux/mman.h
1352
index XXXXXXX..XXXXXXX 100644
1353
--- a/linux-headers/linux/mman.h
1354
+++ b/linux-headers/linux/mman.h
1355
@@ -XXX,XX +XXX,XX @@
1356
1357
#include <asm/mman.h>
1358
#include <asm-generic/hugetlb_encode.h>
1359
+#include <linux/types.h>
1360
1361
#define MREMAP_MAYMOVE        1
1362
#define MREMAP_FIXED        2
1363
@@ -XXX,XX +XXX,XX @@
1364
#define MAP_HUGE_2GB    HUGETLB_FLAG_ENCODE_2GB
1365
#define MAP_HUGE_16GB    HUGETLB_FLAG_ENCODE_16GB
1366
1367
+struct cachestat_range {
1368
+    __u64 off;
1369
+    __u64 len;
1370
+};
1371
+
1372
+struct cachestat {
1373
+    __u64 nr_cache;
1374
+    __u64 nr_dirty;
1375
+    __u64 nr_writeback;
1376
+    __u64 nr_evicted;
1377
+    __u64 nr_recently_evicted;
1378
+};
1379
+
1380
#endif /* _LINUX_MMAN_H */
1381
diff --git a/linux-headers/linux/psp-sev.h b/linux-headers/linux/psp-sev.h
1382
index XXXXXXX..XXXXXXX 100644
1383
--- a/linux-headers/linux/psp-sev.h
1384
+++ b/linux-headers/linux/psp-sev.h
1385
@@ -XXX,XX +XXX,XX @@ enum {
1386
* SEV Firmware status code
1387
*/
1388
typedef enum {
1389
+    /*
1390
+     * This error code is not in the SEV spec. Its purpose is to convey that
1391
+     * there was an error that prevented the SEV firmware from being called.
1392
+     * The SEV API error codes are 16 bits, so the -1 value will not overlap
1393
+     * with possible values from the specification.
1394
+     */
1395
+    SEV_RET_NO_FW_CALL = -1,
1396
    SEV_RET_SUCCESS = 0,
1397
    SEV_RET_INVALID_PLATFORM_STATE,
1398
    SEV_RET_INVALID_GUEST_STATE,
1399
diff --git a/linux-headers/linux/userfaultfd.h b/linux-headers/linux/userfaultfd.h
1400
index XXXXXXX..XXXXXXX 100644
1401
--- a/linux-headers/linux/userfaultfd.h
1402
+++ b/linux-headers/linux/userfaultfd.h
1403
@@ -XXX,XX +XXX,XX @@
1404
             UFFD_FEATURE_MINOR_HUGETLBFS |    \
1405
             UFFD_FEATURE_MINOR_SHMEM |        \
1406
             UFFD_FEATURE_EXACT_ADDRESS |        \
1407
-             UFFD_FEATURE_WP_HUGETLBFS_SHMEM)
1408
+             UFFD_FEATURE_WP_HUGETLBFS_SHMEM |    \
1409
+             UFFD_FEATURE_WP_UNPOPULATED)
1410
#define UFFD_API_IOCTLS                \
1411
    ((__u64)1 << _UFFDIO_REGISTER |        \
1412
     (__u64)1 << _UFFDIO_UNREGISTER |    \
1413
@@ -XXX,XX +XXX,XX @@ struct uffdio_api {
1414
     *
1415
     * UFFD_FEATURE_WP_HUGETLBFS_SHMEM indicates that userfaultfd
1416
     * write-protection mode is supported on both shmem and hugetlbfs.
1417
+     *
1418
+     * UFFD_FEATURE_WP_UNPOPULATED indicates that userfaultfd
1419
+     * write-protection mode will always apply to unpopulated pages
1420
+     * (i.e. empty ptes). This will be the default behavior for shmem
1421
+     * & hugetlbfs, so this flag only affects anonymous memory behavior
1422
+     * when userfault write-protection mode is registered.
1423
     */
1424
#define UFFD_FEATURE_PAGEFAULT_FLAG_WP        (1<<0)
1425
#define UFFD_FEATURE_EVENT_FORK            (1<<1)
1426
@@ -XXX,XX +XXX,XX @@ struct uffdio_api {
1427
#define UFFD_FEATURE_MINOR_SHMEM        (1<<10)
1428
#define UFFD_FEATURE_EXACT_ADDRESS        (1<<11)
1429
#define UFFD_FEATURE_WP_HUGETLBFS_SHMEM        (1<<12)
1430
+#define UFFD_FEATURE_WP_UNPOPULATED        (1<<13)
1431
    __u64 features;
1432
1433
    __u64 ioctls;
1434
@@ -XXX,XX +XXX,XX @@ struct uffdio_writeprotect {
1435
struct uffdio_continue {
1436
    struct uffdio_range range;
1437
#define UFFDIO_CONTINUE_MODE_DONTWAKE        ((__u64)1<<0)
1438
+    /*
1439
+     * UFFDIO_CONTINUE_MODE_WP will map the page write protected on
1440
+     * the fly. UFFDIO_CONTINUE_MODE_WP is available only if the
1441
+     * write protected ioctl is implemented for the range
1442
+     * according to the uffdio_register.ioctls.
1443
+     */
1444
+#define UFFDIO_CONTINUE_MODE_WP            ((__u64)1<<1)
1445
    __u64 mode;
1446
1447
    /*
1448
diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h
1449
index XXXXXXX..XXXXXXX 100644
1450
--- a/linux-headers/linux/vfio.h
1451
+++ b/linux-headers/linux/vfio.h
1452
@@ -XXX,XX +XXX,XX @@ struct vfio_device_info {
1453
#define VFIO_DEVICE_FLAGS_AP    (1 << 5)    /* vfio-ap device */
1454
#define VFIO_DEVICE_FLAGS_FSL_MC (1 << 6)    /* vfio-fsl-mc device */
1455
#define VFIO_DEVICE_FLAGS_CAPS    (1 << 7)    /* Info supports caps */
1456
+#define VFIO_DEVICE_FLAGS_CDX    (1 << 8)    /* vfio-cdx device */
1457
    __u32    num_regions;    /* Max region index + 1 */
1458
    __u32    num_irqs;    /* Max IRQ index + 1 */
1459
    __u32 cap_offset;    /* Offset within info struct of first cap */
1460
@@ -XXX,XX +XXX,XX @@ struct vfio_device_info {
1461
#define VFIO_DEVICE_INFO_CAP_ZPCI_UTIL        3
1462
#define VFIO_DEVICE_INFO_CAP_ZPCI_PFIP        4
1463
1464
+/*
1465
+ * The following VFIO_DEVICE_INFO capability reports support for PCIe AtomicOp
1466
+ * completion to the root bus with supported widths provided via flags.
1467
+ */
1468
+#define VFIO_DEVICE_INFO_CAP_PCI_ATOMIC_COMP    5
1469
+struct vfio_device_info_cap_pci_atomic_comp {
1470
+    struct vfio_info_cap_header header;
1471
+    __u32 flags;
1472
+#define VFIO_PCI_ATOMIC_COMP32    (1 << 0)
1473
+#define VFIO_PCI_ATOMIC_COMP64    (1 << 1)
1474
+#define VFIO_PCI_ATOMIC_COMP128    (1 << 2)
1475
+    __u32 reserved;
1476
+};
1477
+
1478
/**
1479
* VFIO_DEVICE_GET_REGION_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 8,
1480
*                 struct vfio_region_info)
1481
@@ -XXX,XX +XXX,XX @@ struct vfio_region_info_cap_nvlink2_lnkspd {
1482
* then add and unmask vectors, it's up to userspace to make the decision
1483
* whether to allocate the maximum supported number of vectors or tear
1484
* down setup and incrementally increase the vectors as each is enabled.
1485
+ * Absence of the NORESIZE flag indicates that vectors can be enabled
1486
+ * and disabled dynamically without impacting other vectors within the
1487
+ * index.
1488
*/
1489
struct vfio_irq_info {
1490
    __u32    argsz;
1491
@@ -XXX,XX +XXX,XX @@ enum {
1492
    VFIO_CCW_NUM_IRQS
1493
};
1494
1495
+/*
1496
+ * The vfio-ap bus driver makes use of the following IRQ index mapping.
1497
+ * Unimplemented IRQ types return a count of zero.
1498
+ */
1499
+enum {
1500
+    VFIO_AP_REQ_IRQ_INDEX,
1501
+    VFIO_AP_NUM_IRQS
1502
+};
1503
+
1504
/**
1505
* VFIO_DEVICE_GET_PCI_HOT_RESET_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 12,
1506
*                     struct vfio_pci_hot_reset_info)
1507
diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h
1508
index XXXXXXX..XXXXXXX 100644
1509
--- a/linux-headers/linux/vhost.h
1510
+++ b/linux-headers/linux/vhost.h
1511
@@ -XXX,XX +XXX,XX @@
1512
#define VHOST_SET_LOG_BASE _IOW(VHOST_VIRTIO, 0x04, __u64)
1513
/* Specify an eventfd file descriptor to signal on log write. */
1514
#define VHOST_SET_LOG_FD _IOW(VHOST_VIRTIO, 0x07, int)
1515
+/* By default, a device gets one vhost_worker that its virtqueues share. This
1516
+ * command allows the owner of the device to create an additional vhost_worker
1517
+ * for the device. It can later be bound to 1 or more of its virtqueues using
1518
+ * the VHOST_ATTACH_VRING_WORKER command.
1519
+ *
1520
+ * This must be called after VHOST_SET_OWNER and the caller must be the owner
1521
+ * of the device. The new thread will inherit caller's cgroups and namespaces,
1522
+ * and will share the caller's memory space. The new thread will also be
1523
+ * counted against the caller's RLIMIT_NPROC value.
1524
+ *
1525
+ * The worker's ID used in other commands will be returned in
1526
+ * vhost_worker_state.
1527
+ */
1528
+#define VHOST_NEW_WORKER _IOR(VHOST_VIRTIO, 0x8, struct vhost_worker_state)
1529
+/* Free a worker created with VHOST_NEW_WORKER if it's not attached to any
1530
+ * virtqueue. If userspace is not able to call this for workers its created,
1531
+ * the kernel will free all the device's workers when the device is closed.
1532
+ */
1533
+#define VHOST_FREE_WORKER _IOW(VHOST_VIRTIO, 0x9, struct vhost_worker_state)
1534
1535
/* Ring setup. */
1536
/* Set number of descriptors in ring. This parameter can not
1537
@@ -XXX,XX +XXX,XX @@
1538
#define VHOST_VRING_BIG_ENDIAN 1
1539
#define VHOST_SET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x13, struct vhost_vring_state)
1540
#define VHOST_GET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x14, struct vhost_vring_state)
1541
+/* Attach a vhost_worker created with VHOST_NEW_WORKER to one of the device's
1542
+ * virtqueues.
1543
+ *
1544
+ * This will replace the virtqueue's existing worker. If the replaced worker
1545
+ * is no longer attached to any virtqueues, it can be freed with
1546
+ * VHOST_FREE_WORKER.
1547
+ */
1548
+#define VHOST_ATTACH_VRING_WORKER _IOW(VHOST_VIRTIO, 0x15,        \
1549
+                 struct vhost_vring_worker)
1550
+/* Return the vring worker's ID */
1551
+#define VHOST_GET_VRING_WORKER _IOWR(VHOST_VIRTIO, 0x16,        \
1552
+                 struct vhost_vring_worker)
1553
1554
/* The following ioctls use eventfd file descriptors to signal and poll
1555
* for events. */
1556
--
1557
2.41.0
1558
1559
diff view generated by jsdifflib
Deleted patch
1
From: Tony Krowiak <akrowiak@linux.ibm.com>
2
1
3
Let's wire up the device request notifier interface to handle device unplug
4
requests for AP.
5
6
Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com>
7
Link: https://lore.kernel.org/qemu-devel/20230530225544.280031-1-akrowiak@linux.ibm.com/
8
Signed-off-by: Cédric Le Goater <clg@redhat.com>
9
---
10
hw/vfio/ap.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++
11
1 file changed, 113 insertions(+)
12
13
diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/vfio/ap.c
16
+++ b/hw/vfio/ap.c
17
@@ -XXX,XX +XXX,XX @@
18
#include "hw/vfio/vfio-common.h"
19
#include "hw/s390x/ap-device.h"
20
#include "qemu/error-report.h"
21
+#include "qemu/event_notifier.h"
22
+#include "qemu/main-loop.h"
23
#include "qemu/module.h"
24
#include "qemu/option.h"
25
#include "qemu/config-file.h"
26
@@ -XXX,XX +XXX,XX @@
27
struct VFIOAPDevice {
28
APDevice apdev;
29
VFIODevice vdev;
30
+ EventNotifier req_notifier;
31
};
32
33
OBJECT_DECLARE_SIMPLE_TYPE(VFIOAPDevice, VFIO_AP_DEVICE)
34
@@ -XXX,XX +XXX,XX @@ static VFIOGroup *vfio_ap_get_group(VFIOAPDevice *vapdev, Error **errp)
35
return vfio_get_group(groupid, &address_space_memory, errp);
36
}
37
38
+static void vfio_ap_req_notifier_handler(void *opaque)
39
+{
40
+ VFIOAPDevice *vapdev = opaque;
41
+ Error *err = NULL;
42
+
43
+ if (!event_notifier_test_and_clear(&vapdev->req_notifier)) {
44
+ return;
45
+ }
46
+
47
+ qdev_unplug(DEVICE(vapdev), &err);
48
+
49
+ if (err) {
50
+ warn_reportf_err(err, VFIO_MSG_PREFIX, vapdev->vdev.name);
51
+ }
52
+}
53
+
54
+static void vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,
55
+ unsigned int irq, Error **errp)
56
+{
57
+ int fd;
58
+ size_t argsz;
59
+ IOHandler *fd_read;
60
+ EventNotifier *notifier;
61
+ struct vfio_irq_info *irq_info;
62
+ VFIODevice *vdev = &vapdev->vdev;
63
+
64
+ switch (irq) {
65
+ case VFIO_AP_REQ_IRQ_INDEX:
66
+ notifier = &vapdev->req_notifier;
67
+ fd_read = vfio_ap_req_notifier_handler;
68
+ break;
69
+ default:
70
+ error_setg(errp, "vfio: Unsupported device irq(%d)", irq);
71
+ return;
72
+ }
73
+
74
+ if (vdev->num_irqs < irq + 1) {
75
+ error_setg(errp, "vfio: IRQ %u not available (number of irqs %u)",
76
+ irq, vdev->num_irqs);
77
+ return;
78
+ }
79
+
80
+ argsz = sizeof(*irq_info);
81
+ irq_info = g_malloc0(argsz);
82
+ irq_info->index = irq;
83
+ irq_info->argsz = argsz;
84
+
85
+ if (ioctl(vdev->fd, VFIO_DEVICE_GET_IRQ_INFO,
86
+ irq_info) < 0 || irq_info->count < 1) {
87
+ error_setg_errno(errp, errno, "vfio: Error getting irq info");
88
+ goto out_free_info;
89
+ }
90
+
91
+ if (event_notifier_init(notifier, 0)) {
92
+ error_setg_errno(errp, errno,
93
+ "vfio: Unable to init event notifier for irq (%d)",
94
+ irq);
95
+ goto out_free_info;
96
+ }
97
+
98
+ fd = event_notifier_get_fd(notifier);
99
+ qemu_set_fd_handler(fd, fd_read, NULL, vapdev);
100
+
101
+ if (vfio_set_irq_signaling(vdev, irq, 0, VFIO_IRQ_SET_ACTION_TRIGGER, fd,
102
+ errp)) {
103
+ qemu_set_fd_handler(fd, NULL, NULL, vapdev);
104
+ event_notifier_cleanup(notifier);
105
+ }
106
+
107
+out_free_info:
108
+ g_free(irq_info);
109
+
110
+}
111
+
112
+static void vfio_ap_unregister_irq_notifier(VFIOAPDevice *vapdev,
113
+ unsigned int irq)
114
+{
115
+ Error *err = NULL;
116
+ EventNotifier *notifier;
117
+
118
+ switch (irq) {
119
+ case VFIO_AP_REQ_IRQ_INDEX:
120
+ notifier = &vapdev->req_notifier;
121
+ break;
122
+ default:
123
+ error_report("vfio: Unsupported device irq(%d)", irq);
124
+ return;
125
+ }
126
+
127
+ if (vfio_set_irq_signaling(&vapdev->vdev, irq, 0,
128
+ VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) {
129
+ warn_reportf_err(err, VFIO_MSG_PREFIX, vapdev->vdev.name);
130
+ }
131
+
132
+ qemu_set_fd_handler(event_notifier_get_fd(notifier),
133
+ NULL, NULL, vapdev);
134
+ event_notifier_cleanup(notifier);
135
+}
136
+
137
static void vfio_ap_realize(DeviceState *dev, Error **errp)
138
{
139
int ret;
140
char *mdevid;
141
+ Error *err = NULL;
142
VFIOGroup *vfio_group;
143
APDevice *apdev = AP_DEVICE(dev);
144
VFIOAPDevice *vapdev = VFIO_AP_DEVICE(apdev);
145
@@ -XXX,XX +XXX,XX @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)
146
goto out_get_dev_err;
147
}
148
149
+ vfio_ap_register_irq_notifier(vapdev, VFIO_AP_REQ_IRQ_INDEX, &err);
150
+ if (err) {
151
+ /*
152
+ * Report this error, but do not make it a failing condition.
153
+ * Lack of this IRQ in the host does not prevent normal operation.
154
+ */
155
+ error_report_err(err);
156
+ }
157
+
158
return;
159
160
out_get_dev_err:
161
@@ -XXX,XX +XXX,XX @@ static void vfio_ap_unrealize(DeviceState *dev)
162
VFIOAPDevice *vapdev = VFIO_AP_DEVICE(apdev);
163
VFIOGroup *group = vapdev->vdev.group;
164
165
+ vfio_ap_unregister_irq_notifier(vapdev, VFIO_AP_REQ_IRQ_INDEX);
166
vfio_ap_put_device(vapdev);
167
vfio_put_group(group);
168
}
169
--
170
2.41.0
171
172
diff view generated by jsdifflib
Deleted patch
1
From: Alex Williamson <alex.williamson@redhat.com>
2
1
3
Report the PCIe capability version for a device
4
5
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
6
Reviewed-by: Cédric Le Goater <clg@redhat.com>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Tested-by: Robin Voetter <robin@streamhpc.com>
9
Signed-off-by: Cédric Le Goater <clg@redhat.com>
10
---
11
include/hw/pci/pcie.h | 1 +
12
hw/pci/pcie.c | 7 +++++++
13
2 files changed, 8 insertions(+)
14
15
diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h
16
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/pci/pcie.h
18
+++ b/include/hw/pci/pcie.h
19
@@ -XXX,XX +XXX,XX @@ void pcie_cap_exit(PCIDevice *dev);
20
int pcie_endpoint_cap_v1_init(PCIDevice *dev, uint8_t offset);
21
void pcie_cap_v1_exit(PCIDevice *dev);
22
uint8_t pcie_cap_get_type(const PCIDevice *dev);
23
+uint8_t pcie_cap_get_version(const PCIDevice *dev);
24
void pcie_cap_flags_set_vector(PCIDevice *dev, uint8_t vector);
25
uint8_t pcie_cap_flags_get_vector(PCIDevice *dev);
26
27
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
28
index XXXXXXX..XXXXXXX 100644
29
--- a/hw/pci/pcie.c
30
+++ b/hw/pci/pcie.c
31
@@ -XXX,XX +XXX,XX @@ uint8_t pcie_cap_get_type(const PCIDevice *dev)
32
PCI_EXP_FLAGS_TYPE) >> PCI_EXP_FLAGS_TYPE_SHIFT;
33
}
34
35
+uint8_t pcie_cap_get_version(const PCIDevice *dev)
36
+{
37
+ uint32_t pos = dev->exp.exp_cap;
38
+ assert(pos > 0);
39
+ return pci_get_word(dev->config + pos + PCI_EXP_FLAGS) & PCI_EXP_FLAGS_VERS;
40
+}
41
+
42
/* MSI/MSI-X */
43
/* pci express interrupt message number */
44
/* 7.8.2 PCI Express Capabilities Register: Interrupt Message Number */
45
--
46
2.41.0
47
48
diff view generated by jsdifflib
Deleted patch
1
From: Alex Williamson <alex.williamson@redhat.com>
2
1
3
Dynamically enable Atomic Ops completer support around realize/exit of
4
vfio-pci devices reporting host support for these accesses and adhering
5
to a minimal configuration standard. While the Atomic Ops completer
6
bits in the root port device capabilities2 register are read-only, the
7
PCIe spec does allow RO bits to change to reflect hardware state. We
8
take advantage of that here around the realize and exit functions of
9
the vfio-pci device.
10
11
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
12
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
13
Reviewed-by: Robin Voetter <robin@streamhpc.com>
14
Tested-by: Robin Voetter <robin@streamhpc.com>
15
Signed-off-by: Cédric Le Goater <clg@redhat.com>
16
---
17
hw/vfio/pci.h | 1 +
18
hw/vfio/pci.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++
19
2 files changed, 79 insertions(+)
20
21
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
22
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/vfio/pci.h
24
+++ b/hw/vfio/pci.h
25
@@ -XXX,XX +XXX,XX @@ struct VFIOPCIDevice {
26
bool no_vfio_ioeventfd;
27
bool enable_ramfb;
28
bool defer_kvm_irq_routing;
29
+ bool clear_parent_atomics_on_exit;
30
VFIODisplay *dpy;
31
Notifier irqchip_change_notifier;
32
};
33
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/hw/vfio/pci.c
36
+++ b/hw/vfio/pci.c
37
@@ -XXX,XX +XXX,XX @@ static void vfio_add_emulated_long(VFIOPCIDevice *vdev, int pos,
38
vfio_set_long_bits(vdev->emulated_config_bits + pos, mask, mask);
39
}
40
41
+static void vfio_pci_enable_rp_atomics(VFIOPCIDevice *vdev)
42
+{
43
+ struct vfio_device_info_cap_pci_atomic_comp *cap;
44
+ g_autofree struct vfio_device_info *info = NULL;
45
+ PCIBus *bus = pci_get_bus(&vdev->pdev);
46
+ PCIDevice *parent = bus->parent_dev;
47
+ struct vfio_info_cap_header *hdr;
48
+ uint32_t mask = 0;
49
+ uint8_t *pos;
50
+
51
+ /*
52
+ * PCIe Atomic Ops completer support is only added automatically for single
53
+ * function devices downstream of a root port supporting DEVCAP2. Support
54
+ * is added during realize and, if added, removed during device exit. The
55
+ * single function requirement avoids conflicting requirements should a
56
+ * slot be composed of multiple devices with differing capabilities.
57
+ */
58
+ if (pci_bus_is_root(bus) || !parent || !parent->exp.exp_cap ||
59
+ pcie_cap_get_type(parent) != PCI_EXP_TYPE_ROOT_PORT ||
60
+ pcie_cap_get_version(parent) != PCI_EXP_FLAGS_VER2 ||
61
+ vdev->pdev.devfn ||
62
+ vdev->pdev.cap_present & QEMU_PCI_CAP_MULTIFUNCTION) {
63
+ return;
64
+ }
65
+
66
+ pos = parent->config + parent->exp.exp_cap + PCI_EXP_DEVCAP2;
67
+
68
+ /* Abort if there'a already an Atomic Ops configuration on the root port */
69
+ if (pci_get_long(pos) & (PCI_EXP_DEVCAP2_ATOMIC_COMP32 |
70
+ PCI_EXP_DEVCAP2_ATOMIC_COMP64 |
71
+ PCI_EXP_DEVCAP2_ATOMIC_COMP128)) {
72
+ return;
73
+ }
74
+
75
+ info = vfio_get_device_info(vdev->vbasedev.fd);
76
+ if (!info) {
77
+ return;
78
+ }
79
+
80
+ hdr = vfio_get_device_info_cap(info, VFIO_DEVICE_INFO_CAP_PCI_ATOMIC_COMP);
81
+ if (!hdr) {
82
+ return;
83
+ }
84
+
85
+ cap = (void *)hdr;
86
+ if (cap->flags & VFIO_PCI_ATOMIC_COMP32) {
87
+ mask |= PCI_EXP_DEVCAP2_ATOMIC_COMP32;
88
+ }
89
+ if (cap->flags & VFIO_PCI_ATOMIC_COMP64) {
90
+ mask |= PCI_EXP_DEVCAP2_ATOMIC_COMP64;
91
+ }
92
+ if (cap->flags & VFIO_PCI_ATOMIC_COMP128) {
93
+ mask |= PCI_EXP_DEVCAP2_ATOMIC_COMP128;
94
+ }
95
+
96
+ if (!mask) {
97
+ return;
98
+ }
99
+
100
+ pci_long_test_and_set_mask(pos, mask);
101
+ vdev->clear_parent_atomics_on_exit = true;
102
+}
103
+
104
+static void vfio_pci_disable_rp_atomics(VFIOPCIDevice *vdev)
105
+{
106
+ if (vdev->clear_parent_atomics_on_exit) {
107
+ PCIDevice *parent = pci_get_bus(&vdev->pdev)->parent_dev;
108
+ uint8_t *pos = parent->config + parent->exp.exp_cap + PCI_EXP_DEVCAP2;
109
+
110
+ pci_long_test_and_clear_mask(pos, PCI_EXP_DEVCAP2_ATOMIC_COMP32 |
111
+ PCI_EXP_DEVCAP2_ATOMIC_COMP64 |
112
+ PCI_EXP_DEVCAP2_ATOMIC_COMP128);
113
+ }
114
+}
115
+
116
static int vfio_setup_pcie_cap(VFIOPCIDevice *vdev, int pos, uint8_t size,
117
Error **errp)
118
{
119
@@ -XXX,XX +XXX,XX @@ static int vfio_setup_pcie_cap(VFIOPCIDevice *vdev, int pos, uint8_t size,
120
QEMU_PCI_EXP_LNKCAP_MLS(QEMU_PCI_EXP_LNK_2_5GT), ~0);
121
vfio_add_emulated_word(vdev, pos + PCI_EXP_LNKCTL, 0, ~0);
122
}
123
+
124
+ vfio_pci_enable_rp_atomics(vdev);
125
}
126
127
/*
128
@@ -XXX,XX +XXX,XX @@ static void vfio_exitfn(PCIDevice *pdev)
129
timer_free(vdev->intx.mmap_timer);
130
}
131
vfio_teardown_msi(vdev);
132
+ vfio_pci_disable_rp_atomics(vdev);
133
vfio_bars_exit(vdev);
134
vfio_migration_exit(&vdev->vbasedev);
135
}
136
--
137
2.41.0
138
139
diff view generated by jsdifflib