Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

xen: update grant_table.h

Update include/xen/interface/grant_table.h to its newest version.

This allows to drop some private definitions in grant-table.c and
include/xen/grant_table.h.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Juergen Gross <jgross@suse.com>

+103 -68
+3 -5
drivers/xen/grant-table.c
··· 66 66 67 67 #include <asm/sync_bitops.h> 68 68 69 - /* External tools reserve first few grant table entries. */ 70 - #define NR_RESERVED_ENTRIES 8 71 69 #define GNTTAB_LIST_END 0xffffffff 72 70 73 71 static grant_ref_t **gnttab_list; ··· 1463 1465 nr_init_grefs = nr_grant_frames * 1464 1466 gnttab_interface->grefs_per_grant_frame; 1465 1467 1466 - for (i = NR_RESERVED_ENTRIES; i < nr_init_grefs - 1; i++) 1468 + for (i = GNTTAB_NR_RESERVED_ENTRIES; i < nr_init_grefs - 1; i++) 1467 1469 gnttab_entry(i) = i + 1; 1468 1470 1469 1471 gnttab_entry(nr_init_grefs - 1) = GNTTAB_LIST_END; 1470 - gnttab_free_count = nr_init_grefs - NR_RESERVED_ENTRIES; 1471 - gnttab_free_head = NR_RESERVED_ENTRIES; 1472 + gnttab_free_count = nr_init_grefs - GNTTAB_NR_RESERVED_ENTRIES; 1473 + gnttab_free_head = GNTTAB_NR_RESERVED_ENTRIES; 1472 1474 1473 1475 printk("Grant table initialized\n"); 1474 1476 return 0;
-2
include/xen/grant_table.h
··· 57 57 #define INVALID_GRANT_REF ((grant_ref_t)-1) 58 58 #define INVALID_GRANT_HANDLE ((grant_handle_t)-1) 59 59 60 - #define GNTTAB_RESERVED_XENSTORE 1 61 - 62 60 /* NR_GRANT_FRAMES must be less than or equal to that configured in Xen */ 63 61 #define NR_GRANT_FRAMES 4 64 62
+100 -61
include/xen/interface/grant_table.h
··· 19 19 20 20 /* Some rough guidelines on accessing and updating grant-table entries 21 21 * in a concurrency-safe manner. For more information, Linux contains a 22 - * reference implementation for guest OSes (arch/xen/kernel/grant_table.c). 22 + * reference implementation for guest OSes (drivers/xen/grant_table.c, see 23 + * http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=drivers/xen/grant-table.c;hb=HEAD 23 24 * 24 25 * NB. WMB is a no-op on current-generation x86 processors. However, a 25 26 * compiler barrier will still be required. ··· 81 80 */ 82 81 83 82 /* 84 - * Version 1 of the grant table entry structure is maintained purely 85 - * for backwards compatibility. New guests should use version 2. 83 + * Version 1 of the grant table entry structure is maintained largely for 84 + * backwards compatibility. New guests are recommended to support using 85 + * version 2 to overcome version 1 limitations, but to default to version 1. 86 86 */ 87 87 struct grant_entry_v1 { 88 88 /* GTF_xxx: various type and flag information. [XEN,GST] */ ··· 91 89 /* The domain being granted foreign privileges. [GST] */ 92 90 domid_t domid; 93 91 /* 94 - * GTF_permit_access: Frame that @domid is allowed to map and access. [GST] 95 - * GTF_accept_transfer: Frame whose ownership transferred by @domid. [XEN] 92 + * GTF_permit_access: GFN that @domid is allowed to map and access. [GST] 93 + * GTF_accept_transfer: GFN that @domid is allowed to transfer into. [GST] 94 + * GTF_transfer_completed: MFN whose ownership transferred by @domid 95 + * (non-translated guests only). [XEN] 96 96 */ 97 97 uint32_t frame; 98 98 }; 99 + 100 + /* The first few grant table entries will be preserved across grant table 101 + * version changes and may be pre-populated at domain creation by tools. 102 + */ 103 + #define GNTTAB_NR_RESERVED_ENTRIES 8 104 + #define GNTTAB_RESERVED_CONSOLE 0 105 + #define GNTTAB_RESERVED_XENSTORE 1 99 106 100 107 /* 101 108 * Type of grant entry. ··· 122 111 #define GTF_type_mask (3U<<0) 123 112 124 113 /* 125 - * Subflags for GTF_permit_access. 114 + * Subflags for GTF_permit_access and GTF_transitive. 126 115 * GTF_readonly: Restrict @domid to read-only mappings and accesses. [GST] 127 116 * GTF_reading: Grant entry is currently mapped for reading by @domid. [XEN] 128 117 * GTF_writing: Grant entry is currently mapped for writing by @domid. [XEN] 118 + * Further subflags for GTF_permit_access only. 119 + * GTF_PAT, GTF_PWT, GTF_PCD: (x86) cache attribute flags to be used for 120 + * mappings of the grant [GST] 129 121 * GTF_sub_page: Grant access to only a subrange of the page. @domid 130 122 * will only be allowed to copy from the grant, and not 131 123 * map it. [GST] ··· 139 125 #define GTF_reading (1U<<_GTF_reading) 140 126 #define _GTF_writing (4) 141 127 #define GTF_writing (1U<<_GTF_writing) 128 + #define _GTF_PWT (5) 129 + #define GTF_PWT (1U<<_GTF_PWT) 130 + #define _GTF_PCD (6) 131 + #define GTF_PCD (1U<<_GTF_PCD) 132 + #define _GTF_PAT (7) 133 + #define GTF_PAT (1U<<_GTF_PAT) 142 134 #define _GTF_sub_page (8) 143 135 #define GTF_sub_page (1U<<_GTF_sub_page) 144 136 ··· 184 164 }; 185 165 186 166 /* 187 - * Version 2 of the grant entry structure, here is a union because three 188 - * different types are suppotted: full_page, sub_page and transitive. 167 + * Version 2 of the grant entry structure. 189 168 */ 190 169 union grant_entry_v2 { 191 170 struct grant_entry_header hdr; ··· 199 180 * field of the same name in the V1 entry structure. 200 181 */ 201 182 struct { 202 - struct grant_entry_header hdr; 203 - uint32_t pad0; 204 - uint64_t frame; 183 + struct grant_entry_header hdr; 184 + uint32_t pad0; 185 + uint64_t frame; 205 186 } full_page; 206 187 207 188 /* ··· 210 191 * in frame @frame. 211 192 */ 212 193 struct { 213 - struct grant_entry_header hdr; 214 - uint16_t page_off; 215 - uint16_t length; 216 - uint64_t frame; 194 + struct grant_entry_header hdr; 195 + uint16_t page_off; 196 + uint16_t length; 197 + uint64_t frame; 217 198 } sub_page; 218 199 219 200 /* ··· 221 202 * grant @gref in domain @trans_domid, as if it was the local 222 203 * domain. Obviously, the transitive access must be compatible 223 204 * with the original grant. 205 + * 206 + * The current version of Xen does not allow transitive grants 207 + * to be mapped. 224 208 */ 225 209 struct { 226 - struct grant_entry_header hdr; 227 - domid_t trans_domid; 228 - uint16_t pad0; 229 - grant_ref_t gref; 210 + struct grant_entry_header hdr; 211 + domid_t trans_domid; 212 + uint16_t pad0; 213 + grant_ref_t gref; 230 214 } transitive; 231 215 232 216 uint32_t __spacer[4]; /* Pad to a power of two */ ··· 241 219 * GRANT TABLE QUERIES AND USES 242 220 */ 243 221 222 + #define GNTTABOP_map_grant_ref 0 223 + #define GNTTABOP_unmap_grant_ref 1 224 + #define GNTTABOP_setup_table 2 225 + #define GNTTABOP_dump_table 3 226 + #define GNTTABOP_transfer 4 227 + #define GNTTABOP_copy 5 228 + #define GNTTABOP_query_size 6 229 + #define GNTTABOP_unmap_and_replace 7 230 + #define GNTTABOP_set_version 8 231 + #define GNTTABOP_get_status_frames 9 232 + #define GNTTABOP_get_version 10 233 + #define GNTTABOP_swap_grant_ref 11 234 + #define GNTTABOP_cache_flush 12 235 + /* ` } */ 236 + 244 237 /* 245 238 * Handle to track a mapping created via a grant reference. 246 239 */ ··· 264 227 /* 265 228 * GNTTABOP_map_grant_ref: Map the grant entry (<dom>,<ref>) for access 266 229 * by devices and/or host CPUs. If successful, <handle> is a tracking number 267 - * that must be presented later to destroy the mapping(s). On error, <handle> 230 + * that must be presented later to destroy the mapping(s). On error, <status> 268 231 * is a negative status code. 269 232 * NOTES: 270 233 * 1. If GNTMAP_device_map is specified then <dev_bus_addr> is the address ··· 278 241 * host mapping is destroyed by other means then it is *NOT* guaranteed 279 242 * to be accounted to the correct grant reference! 280 243 */ 281 - #define GNTTABOP_map_grant_ref 0 282 244 struct gnttab_map_grant_ref { 283 245 /* IN parameters. */ 284 246 uint64_t host_addr; ··· 302 266 * 3. After executing a batch of unmaps, it is guaranteed that no stale 303 267 * mappings will remain in the device or host TLBs. 304 268 */ 305 - #define GNTTABOP_unmap_grant_ref 1 306 269 struct gnttab_unmap_grant_ref { 307 270 /* IN parameters. */ 308 271 uint64_t host_addr; ··· 321 286 * 2. Only a sufficiently-privileged domain may specify <dom> != DOMID_SELF. 322 287 * 3. Xen may not support more than a single grant-table page per domain. 323 288 */ 324 - #define GNTTABOP_setup_table 2 325 289 struct gnttab_setup_table { 326 290 /* IN parameters. */ 327 291 domid_t dom; ··· 335 301 * GNTTABOP_dump_table: Dump the contents of the grant table to the 336 302 * xen console. Debugging use only. 337 303 */ 338 - #define GNTTABOP_dump_table 3 339 304 struct gnttab_dump_table { 340 305 /* IN parameters. */ 341 306 domid_t dom; ··· 344 311 DEFINE_GUEST_HANDLE_STRUCT(gnttab_dump_table); 345 312 346 313 /* 347 - * GNTTABOP_transfer_grant_ref: Transfer <frame> to a foreign domain. The 348 - * foreign domain has previously registered its interest in the transfer via 349 - * <domid, ref>. 314 + * GNTTABOP_transfer: Transfer <frame> to a foreign domain. The foreign domain 315 + * has previously registered its interest in the transfer via <domid, ref>. 350 316 * 351 317 * Note that, even if the transfer fails, the specified page no longer belongs 352 318 * to the calling domain *unless* the error is GNTST_bad_page. 319 + * 320 + * Note further that only PV guests can use this operation. 353 321 */ 354 - #define GNTTABOP_transfer 4 355 322 struct gnttab_transfer { 356 323 /* IN parameters. */ 357 - xen_pfn_t mfn; 324 + xen_pfn_t mfn; 358 325 domid_t domid; 359 326 grant_ref_t ref; 360 327 /* OUT parameters. */ ··· 385 352 #define _GNTCOPY_dest_gref (1) 386 353 #define GNTCOPY_dest_gref (1<<_GNTCOPY_dest_gref) 387 354 388 - #define GNTTABOP_copy 5 389 355 struct gnttab_copy { 390 - /* IN parameters. */ 391 - struct { 392 - union { 393 - grant_ref_t ref; 394 - xen_pfn_t gmfn; 395 - } u; 396 - domid_t domid; 397 - uint16_t offset; 398 - } source, dest; 399 - uint16_t len; 400 - uint16_t flags; /* GNTCOPY_* */ 401 - /* OUT parameters. */ 402 - int16_t status; 356 + /* IN parameters. */ 357 + struct gnttab_copy_ptr { 358 + union { 359 + grant_ref_t ref; 360 + xen_pfn_t gmfn; 361 + } u; 362 + domid_t domid; 363 + uint16_t offset; 364 + } source, dest; 365 + uint16_t len; 366 + uint16_t flags; /* GNTCOPY_* */ 367 + /* OUT parameters. */ 368 + int16_t status; 403 369 }; 404 370 DEFINE_GUEST_HANDLE_STRUCT(gnttab_copy); 405 371 ··· 409 377 * 1. <dom> may be specified as DOMID_SELF. 410 378 * 2. Only a sufficiently-privileged domain may specify <dom> != DOMID_SELF. 411 379 */ 412 - #define GNTTABOP_query_size 6 413 380 struct gnttab_query_size { 414 381 /* IN parameters. */ 415 382 domid_t dom; ··· 430 399 * 2. After executing a batch of unmaps, it is guaranteed that no stale 431 400 * mappings will remain in the device or host TLBs. 432 401 */ 433 - #define GNTTABOP_unmap_and_replace 7 434 402 struct gnttab_unmap_and_replace { 435 403 /* IN parameters. */ 436 404 uint64_t host_addr; ··· 442 412 443 413 /* 444 414 * GNTTABOP_set_version: Request a particular version of the grant 445 - * table shared table structure. This operation can only be performed 446 - * once in any given domain. It must be performed before any grants 447 - * are activated; otherwise, the domain will be stuck with version 1. 448 - * The only defined versions are 1 and 2. 415 + * table shared table structure. This operation may be used to toggle 416 + * between different versions, but must be performed while no grants 417 + * are active. The only defined versions are 1 and 2. 449 418 */ 450 - #define GNTTABOP_set_version 8 451 419 struct gnttab_set_version { 452 - /* IN parameters */ 420 + /* IN/OUT parameters */ 453 421 uint32_t version; 454 422 }; 455 423 DEFINE_GUEST_HANDLE_STRUCT(gnttab_set_version); ··· 464 436 * 1. <dom> may be specified as DOMID_SELF. 465 437 * 2. Only a sufficiently-privileged domain may specify <dom> != DOMID_SELF. 466 438 */ 467 - #define GNTTABOP_get_status_frames 9 468 439 struct gnttab_get_status_frames { 469 440 /* IN parameters. */ 470 441 uint32_t nr_frames; ··· 478 451 * GNTTABOP_get_version: Get the grant table version which is in 479 452 * effect for domain <dom>. 480 453 */ 481 - #define GNTTABOP_get_version 10 482 454 struct gnttab_get_version { 483 455 /* IN parameters */ 484 456 domid_t dom; ··· 488 462 DEFINE_GUEST_HANDLE_STRUCT(gnttab_get_version); 489 463 490 464 /* 465 + * GNTTABOP_swap_grant_ref: Swap the contents of two grant entries. 466 + */ 467 + struct gnttab_swap_grant_ref { 468 + /* IN parameters */ 469 + grant_ref_t ref_a; 470 + grant_ref_t ref_b; 471 + /* OUT parameters */ 472 + int16_t status; /* GNTST_* */ 473 + }; 474 + DEFINE_GUEST_HANDLE_STRUCT(gnttab_swap_grant_ref); 475 + 476 + /* 491 477 * Issue one or more cache maintenance operations on a portion of a 492 478 * page granted to the calling domain by a foreign domain. 493 479 */ 494 - #define GNTTABOP_cache_flush 12 495 480 struct gnttab_cache_flush { 496 481 union { 497 482 uint64_t dev_bus_addr; 498 483 grant_ref_t ref; 499 484 } a; 500 - uint16_t offset; /* offset from start of grant */ 501 - uint16_t length; /* size within the grant */ 502 - #define GNTTAB_CACHE_CLEAN (1<<0) 503 - #define GNTTAB_CACHE_INVAL (1<<1) 504 - #define GNTTAB_CACHE_SOURCE_GREF (1<<31) 485 + uint16_t offset; /* offset from start of grant */ 486 + uint16_t length; /* size within the grant */ 487 + #define GNTTAB_CACHE_CLEAN (1u<<0) 488 + #define GNTTAB_CACHE_INVAL (1u<<1) 489 + #define GNTTAB_CACHE_SOURCE_GREF (1u<<31) 505 490 uint32_t op; 506 491 }; 507 492 DEFINE_GUEST_HANDLE_STRUCT(gnttab_cache_flush); 508 493 509 494 /* 510 - * Bitfield values for update_pin_status.flags. 495 + * Bitfield values for gnttab_map_grant_ref.flags. 511 496 */ 512 497 /* Map the grant entry for access by I/O devices. */ 513 498 #define _GNTMAP_device_map (0) ··· 568 531 #define GNTST_bad_copy_arg (-10) /* copy arguments cross page boundary. */ 569 532 #define GNTST_address_too_big (-11) /* transfer page address too large. */ 570 533 #define GNTST_eagain (-12) /* Operation not done; try again. */ 534 + #define GNTST_no_space (-13) /* Out of space (handles etc). */ 571 535 572 536 #define GNTTABOP_error_msgs { \ 573 537 "okay", \ ··· 583 545 "bad page", \ 584 546 "copy arguments cross page boundary", \ 585 547 "page address size too large", \ 586 - "operation not done; try again" \ 548 + "operation not done; try again", \ 549 + "out of space", \ 587 550 } 588 551 589 552 #endif /* __XEN_PUBLIC_GRANT_TABLE_H__ */