Commit a11d712
KVM: selftests: guest_memfd mmap() test when mmap is supported
Expand the guest_memfd selftests to comprehensively test host userspace
mmap functionality for guest_memfd-backed memory when supported by the
VM type.
Introduce new test cases to verify the following:
* Successful mmap operations: Ensure that MAP_SHARED mappings succeed
when guest_memfd mmap is enabled.
* Data integrity: Validate that data written to the mmap'd region is
correctly persistent and readable.
* fallocate interaction: Test that fallocate(FALLOC_FL_PUNCH_HOLE)
correctly zeros out mapped pages.
* Out-of-bounds access: Verify that accessing memory beyond the
guest_memfd's size correctly triggers a SIGBUS signal.
* Unsupported mmap: Confirm that mmap attempts fail as expected when
guest_memfd mmap support is not enabled for the specific guest_memfd
instance or VM type.
* Flag validity: Introduce test_vm_type_gmem_flag_validity() to
systematically test that only allowed guest_memfd creation flags are
accepted for different VM types (e.g., GUEST_MEMFD_FLAG_MMAP for
default VMs, no flags for CoCo VMs).
The existing tests for guest_memfd creation (multiple instances, invalid
sizes), file read/write, file size, and invalid punch hole operations
are integrated into the new test_with_type() framework to allow testing
across different VM types.
Cc: James Houghton <[email protected]>
Cc: Gavin Shan <[email protected]>
Cc: Shivank Garg <[email protected]>
Co-developed-by: Ackerley Tng <[email protected]>
Signed-off-by: Ackerley Tng <[email protected]>
Signed-off-by: Fuad Tabba <[email protected]>
Co-developed-by: Sean Christopherson <[email protected]>
Signed-off-by: Sean Christopherson <[email protected]>
Message-ID: <[email protected]>
[Fix default vm_types to use BIT() - Paolo]
Signed-off-by: Paolo Bonzini <[email protected]>1 parent 692f6ec commit a11d712
1 file changed
+139
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
37 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
38 | 108 | | |
39 | 109 | | |
40 | 110 | | |
41 | 111 | | |
42 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
43 | 116 | | |
44 | 117 | | |
45 | 118 | | |
| |||
120 | 193 | | |
121 | 194 | | |
122 | 195 | | |
123 | | - | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
124 | 199 | | |
125 | | - | |
126 | | - | |
127 | 200 | | |
128 | 201 | | |
129 | 202 | | |
130 | 203 | | |
131 | | - | |
132 | | - | |
| 204 | + | |
| 205 | + | |
133 | 206 | | |
134 | 207 | | |
135 | 208 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | 209 | | |
144 | 210 | | |
145 | 211 | | |
| |||
171 | 237 | | |
172 | 238 | | |
173 | 239 | | |
174 | | - | |
| 240 | + | |
175 | 241 | | |
176 | | - | |
177 | | - | |
| 242 | + | |
| 243 | + | |
178 | 244 | | |
179 | | - | |
180 | 245 | | |
181 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
182 | 268 | | |
183 | 269 | | |
184 | 270 | | |
185 | 271 | | |
186 | | - | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
187 | 276 | | |
188 | | - | |
189 | 277 | | |
| 278 | + | |
190 | 279 | | |
191 | | - | |
| 280 | + | |
192 | 281 | | |
193 | 282 | | |
194 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
195 | 291 | | |
196 | 292 | | |
197 | 293 | | |
198 | 294 | | |
| 295 | + | |
| 296 | + | |
199 | 297 | | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
200 | 317 | | |
0 commit comments