diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-10 13:09:59 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-10 13:09:59 -0500 |
| commit | 90160371b3a3e67ef78d68210a94dd30664a703d (patch) | |
| tree | 2841ea811be129133cf9b83d9c3badd96e7ffab4 /include/xen | |
| parent | ae5cfc0546ca2698b9dcddf72accbd70e57590a0 (diff) | |
| parent | 6c254de16a1d14c1ac931d3aa08dc88ac9fc582b (diff) | |
Merge branch 'stable/for-linus-3.3' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen
* 'stable/for-linus-3.3' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen: (37 commits)
xen/pciback: Expand the warning message to include domain id.
xen/pciback: Fix "device has been assigned to X domain!" warning
xen/pciback: Move the PCI_DEV_FLAGS_ASSIGNED ops to the "[un|]bind"
xen/xenbus: don't reimplement kvasprintf via a fixed size buffer
xenbus: maximum buffer size is XENSTORE_PAYLOAD_MAX
xen/xenbus: Reject replies with payload > XENSTORE_PAYLOAD_MAX.
Xen: consolidate and simplify struct xenbus_driver instantiation
xen-gntalloc: introduce missing kfree
xen/xenbus: Fix compile error - missing header for xen_initial_domain()
xen/netback: Enable netback on HVM guests
xen/grant-table: Support mappings required by blkback
xenbus: Use grant-table wrapper functions
xenbus: Support HVM backends
xen/xenbus-frontend: Fix compile error with randconfig
xen/xenbus-frontend: Make error message more clear
xen/privcmd: Remove unused support for arch specific privcmp mmap
xen: Add xenbus_backend device
xen: Add xenbus device driver
xen: Add privcmd device driver
xen/gntalloc: fix reference counts on multi-page mappings
...
Diffstat (limited to 'include/xen')
| -rw-r--r-- | include/xen/events.h | 7 | ||||
| -rw-r--r-- | include/xen/grant_table.h | 37 | ||||
| -rw-r--r-- | include/xen/interface/grant_table.h | 167 | ||||
| -rw-r--r-- | include/xen/interface/io/xs_wire.h | 3 | ||||
| -rw-r--r-- | include/xen/interface/xen.h | 2 | ||||
| -rw-r--r-- | include/xen/xenbus.h | 31 | ||||
| -rw-r--r-- | include/xen/xenbus_dev.h | 41 |
7 files changed, 256 insertions, 32 deletions
diff --git a/include/xen/events.h b/include/xen/events.h index d287997d3eab..0f773708e02c 100644 --- a/include/xen/events.h +++ b/include/xen/events.h | |||
| @@ -37,6 +37,13 @@ int bind_interdomain_evtchn_to_irqhandler(unsigned int remote_domain, | |||
| 37 | */ | 37 | */ |
| 38 | void unbind_from_irqhandler(unsigned int irq, void *dev_id); | 38 | void unbind_from_irqhandler(unsigned int irq, void *dev_id); |
| 39 | 39 | ||
| 40 | /* | ||
| 41 | * Allow extra references to event channels exposed to userspace by evtchn | ||
| 42 | */ | ||
| 43 | int evtchn_make_refcounted(unsigned int evtchn); | ||
| 44 | int evtchn_get(unsigned int evtchn); | ||
| 45 | void evtchn_put(unsigned int evtchn); | ||
| 46 | |||
| 40 | void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector); | 47 | void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector); |
| 41 | int resend_irq_on_evtchn(unsigned int irq); | 48 | int resend_irq_on_evtchn(unsigned int irq); |
| 42 | void rebind_evtchn_irq(int evtchn, int irq); | 49 | void rebind_evtchn_irq(int evtchn, int irq); |
diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h index 11e2dfce42f8..15f8a00ff003 100644 --- a/include/xen/grant_table.h +++ b/include/xen/grant_table.h | |||
| @@ -62,6 +62,24 @@ int gnttab_resume(void); | |||
| 62 | 62 | ||
| 63 | int gnttab_grant_foreign_access(domid_t domid, unsigned long frame, | 63 | int gnttab_grant_foreign_access(domid_t domid, unsigned long frame, |
| 64 | int readonly); | 64 | int readonly); |
| 65 | int gnttab_grant_foreign_access_subpage(domid_t domid, unsigned long frame, | ||
| 66 | int flags, unsigned page_off, | ||
| 67 | unsigned length); | ||
| 68 | int gnttab_grant_foreign_access_trans(domid_t domid, int flags, | ||
| 69 | domid_t trans_domid, | ||
| 70 | grant_ref_t trans_gref); | ||
| 71 | |||
| 72 | /* | ||
| 73 | * Are sub-page grants available on this version of Xen? Returns true if they | ||
| 74 | * are, and false if they're not. | ||
| 75 | */ | ||
| 76 | bool gnttab_subpage_grants_available(void); | ||
| 77 | |||
| 78 | /* | ||
| 79 | * Are transitive grants available on this version of Xen? Returns true if they | ||
| 80 | * are, and false if they're not. | ||
| 81 | */ | ||
| 82 | bool gnttab_trans_grants_available(void); | ||
| 65 | 83 | ||
| 66 | /* | 84 | /* |
| 67 | * End access through the given grant reference, iff the grant entry is no | 85 | * End access through the given grant reference, iff the grant entry is no |
| @@ -108,6 +126,13 @@ void gnttab_cancel_free_callback(struct gnttab_free_callback *callback); | |||
| 108 | 126 | ||
| 109 | void gnttab_grant_foreign_access_ref(grant_ref_t ref, domid_t domid, | 127 | void gnttab_grant_foreign_access_ref(grant_ref_t ref, domid_t domid, |
| 110 | unsigned long frame, int readonly); | 128 | unsigned long frame, int readonly); |
| 129 | int gnttab_grant_foreign_access_subpage_ref(grant_ref_t ref, domid_t domid, | ||
| 130 | unsigned long frame, int flags, | ||
| 131 | unsigned page_off, | ||
| 132 | unsigned length); | ||
| 133 | int gnttab_grant_foreign_access_trans_ref(grant_ref_t ref, domid_t domid, | ||
| 134 | int flags, domid_t trans_domid, | ||
| 135 | grant_ref_t trans_gref); | ||
| 111 | 136 | ||
| 112 | void gnttab_grant_foreign_transfer_ref(grant_ref_t, domid_t domid, | 137 | void gnttab_grant_foreign_transfer_ref(grant_ref_t, domid_t domid, |
| 113 | unsigned long pfn); | 138 | unsigned long pfn); |
| @@ -145,9 +170,11 @@ gnttab_set_unmap_op(struct gnttab_unmap_grant_ref *unmap, phys_addr_t addr, | |||
| 145 | 170 | ||
| 146 | int arch_gnttab_map_shared(unsigned long *frames, unsigned long nr_gframes, | 171 | int arch_gnttab_map_shared(unsigned long *frames, unsigned long nr_gframes, |
| 147 | unsigned long max_nr_gframes, | 172 | unsigned long max_nr_gframes, |
| 148 | struct grant_entry **__shared); | 173 | void **__shared); |
| 149 | void arch_gnttab_unmap_shared(struct grant_entry *shared, | 174 | int arch_gnttab_map_status(uint64_t *frames, unsigned long nr_gframes, |
| 150 | unsigned long nr_gframes); | 175 | unsigned long max_nr_gframes, |
| 176 | grant_status_t **__shared); | ||
| 177 | void arch_gnttab_unmap(void *shared, unsigned long nr_gframes); | ||
| 151 | 178 | ||
| 152 | extern unsigned long xen_hvm_resume_frames; | 179 | extern unsigned long xen_hvm_resume_frames; |
| 153 | unsigned int gnttab_max_grant_frames(void); | 180 | unsigned int gnttab_max_grant_frames(void); |
| @@ -155,9 +182,9 @@ unsigned int gnttab_max_grant_frames(void); | |||
| 155 | #define gnttab_map_vaddr(map) ((void *)(map.host_virt_addr)) | 182 | #define gnttab_map_vaddr(map) ((void *)(map.host_virt_addr)) |
| 156 | 183 | ||
| 157 | int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, | 184 | int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, |
| 158 | struct gnttab_map_grant_ref *kmap_ops, | 185 | struct gnttab_map_grant_ref *kmap_ops, |
| 159 | struct page **pages, unsigned int count); | 186 | struct page **pages, unsigned int count); |
| 160 | int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops, | 187 | int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops, |
| 161 | struct page **pages, unsigned int count); | 188 | struct page **pages, unsigned int count, bool clear_pte); |
| 162 | 189 | ||
| 163 | #endif /* __ASM_GNTTAB_H__ */ | 190 | #endif /* __ASM_GNTTAB_H__ */ |
diff --git a/include/xen/interface/grant_table.h b/include/xen/interface/grant_table.h index 39e571796e32..a17d84433e6a 100644 --- a/include/xen/interface/grant_table.h +++ b/include/xen/interface/grant_table.h | |||
| @@ -85,12 +85,22 @@ | |||
| 85 | */ | 85 | */ |
| 86 | 86 | ||
| 87 | /* | 87 | /* |
| 88 | * Reference to a grant entry in a specified domain's grant table. | ||
| 89 | */ | ||
| 90 | typedef uint32_t grant_ref_t; | ||
| 91 | |||
| 92 | /* | ||
| 88 | * A grant table comprises a packed array of grant entries in one or more | 93 | * A grant table comprises a packed array of grant entries in one or more |
| 89 | * page frames shared between Xen and a guest. | 94 | * page frames shared between Xen and a guest. |
| 90 | * [XEN]: This field is written by Xen and read by the sharing guest. | 95 | * [XEN]: This field is written by Xen and read by the sharing guest. |
| 91 | * [GST]: This field is written by the guest and read by Xen. | 96 | * [GST]: This field is written by the guest and read by Xen. |
| 92 | */ | 97 | */ |
| 93 | struct grant_entry { | 98 | |
| 99 | /* | ||
| 100 | * Version 1 of the grant table entry structure is maintained purely | ||
| 101 | * for backwards compatibility. New guests should use version 2. | ||
| 102 | */ | ||
| 103 | struct grant_entry_v1 { | ||
| 94 | /* GTF_xxx: various type and flag information. [XEN,GST] */ | 104 | /* GTF_xxx: various type and flag information. [XEN,GST] */ |
| 95 | uint16_t flags; | 105 | uint16_t flags; |
| 96 | /* The domain being granted foreign privileges. [GST] */ | 106 | /* The domain being granted foreign privileges. [GST] */ |
| @@ -108,10 +118,13 @@ struct grant_entry { | |||
| 108 | * GTF_permit_access: Allow @domid to map/access @frame. | 118 | * GTF_permit_access: Allow @domid to map/access @frame. |
| 109 | * GTF_accept_transfer: Allow @domid to transfer ownership of one page frame | 119 | * GTF_accept_transfer: Allow @domid to transfer ownership of one page frame |
| 110 | * to this guest. Xen writes the page number to @frame. | 120 | * to this guest. Xen writes the page number to @frame. |
| 121 | * GTF_transitive: Allow @domid to transitively access a subrange of | ||
| 122 | * @trans_grant in @trans_domid. No mappings are allowed. | ||
| 111 | */ | 123 | */ |
| 112 | #define GTF_invalid (0U<<0) | 124 | #define GTF_invalid (0U<<0) |
| 113 | #define GTF_permit_access (1U<<0) | 125 | #define GTF_permit_access (1U<<0) |
| 114 | #define GTF_accept_transfer (2U<<0) | 126 | #define GTF_accept_transfer (2U<<0) |
| 127 | #define GTF_transitive (3U<<0) | ||
| 115 | #define GTF_type_mask (3U<<0) | 128 | #define GTF_type_mask (3U<<0) |
| 116 | 129 | ||
| 117 | /* | 130 | /* |
| @@ -119,6 +132,9 @@ struct grant_entry { | |||
| 119 | * GTF_readonly: Restrict @domid to read-only mappings and accesses. [GST] | 132 | * GTF_readonly: Restrict @domid to read-only mappings and accesses. [GST] |
| 120 | * GTF_reading: Grant entry is currently mapped for reading by @domid. [XEN] | 133 | * GTF_reading: Grant entry is currently mapped for reading by @domid. [XEN] |
| 121 | * GTF_writing: Grant entry is currently mapped for writing by @domid. [XEN] | 134 | * GTF_writing: Grant entry is currently mapped for writing by @domid. [XEN] |
| 135 | * GTF_sub_page: Grant access to only a subrange of the page. @domid | ||
| 136 | * will only be allowed to copy from the grant, and not | ||
| 137 | * map it. [GST] | ||
| 122 | */ | 138 | */ |
| 123 | #define _GTF_readonly (2) | 139 | #define _GTF_readonly (2) |
| 124 | #define GTF_readonly (1U<<_GTF_readonly) | 140 | #define GTF_readonly (1U<<_GTF_readonly) |
| @@ -126,6 +142,8 @@ struct grant_entry { | |||
| 126 | #define GTF_reading (1U<<_GTF_reading) | 142 | #define GTF_reading (1U<<_GTF_reading) |
| 127 | #define _GTF_writing (4) | 143 | #define _GTF_writing (4) |
| 128 | #define GTF_writing (1U<<_GTF_writing) | 144 | #define GTF_writing (1U<<_GTF_writing) |
| 145 | #define _GTF_sub_page (8) | ||
| 146 | #define GTF_sub_page (1U<<_GTF_sub_page) | ||
| 129 | 147 | ||
| 130 | /* | 148 | /* |
| 131 | * Subflags for GTF_accept_transfer: | 149 | * Subflags for GTF_accept_transfer: |
| @@ -142,15 +160,81 @@ struct grant_entry { | |||
| 142 | #define _GTF_transfer_completed (3) | 160 | #define _GTF_transfer_completed (3) |
| 143 | #define GTF_transfer_completed (1U<<_GTF_transfer_completed) | 161 | #define GTF_transfer_completed (1U<<_GTF_transfer_completed) |
| 144 | 162 | ||
| 163 | /* | ||
| 164 | * Version 2 grant table entries. These fulfil the same role as | ||
| 165 | * version 1 entries, but can represent more complicated operations. | ||
| 166 | * Any given domain will have either a version 1 or a version 2 table, | ||
| 167 | * and every entry in the table will be the same version. | ||
| 168 | * | ||
| 169 | * The interface by which domains use grant references does not depend | ||
| 170 | * on the grant table version in use by the other domain. | ||
| 171 | */ | ||
| 145 | 172 | ||
| 146 | /*********************************** | 173 | /* |
| 147 | * GRANT TABLE QUERIES AND USES | 174 | * Version 1 and version 2 grant entries share a common prefix. The |
| 175 | * fields of the prefix are documented as part of struct | ||
| 176 | * grant_entry_v1. | ||
| 148 | */ | 177 | */ |
| 178 | struct grant_entry_header { | ||
| 179 | uint16_t flags; | ||
| 180 | domid_t domid; | ||
| 181 | }; | ||
| 149 | 182 | ||
| 150 | /* | 183 | /* |
| 151 | * Reference to a grant entry in a specified domain's grant table. | 184 | * Version 2 of the grant entry structure, here is an union because three |
| 185 | * different types are suppotted: full_page, sub_page and transitive. | ||
| 186 | */ | ||
| 187 | union grant_entry_v2 { | ||
| 188 | struct grant_entry_header hdr; | ||
| 189 | |||
| 190 | /* | ||
| 191 | * This member is used for V1-style full page grants, where either: | ||
| 192 | * | ||
| 193 | * -- hdr.type is GTF_accept_transfer, or | ||
| 194 | * -- hdr.type is GTF_permit_access and GTF_sub_page is not set. | ||
| 195 | * | ||
| 196 | * In that case, the frame field has the same semantics as the | ||
| 197 | * field of the same name in the V1 entry structure. | ||
| 198 | */ | ||
| 199 | struct { | ||
| 200 | struct grant_entry_header hdr; | ||
| 201 | uint32_t pad0; | ||
| 202 | uint64_t frame; | ||
| 203 | } full_page; | ||
| 204 | |||
| 205 | /* | ||
| 206 | * If the grant type is GTF_grant_access and GTF_sub_page is set, | ||
| 207 | * @domid is allowed to access bytes [@page_off,@page_off+@length) | ||
| 208 | * in frame @frame. | ||
| 209 | */ | ||
| 210 | struct { | ||
| 211 | struct grant_entry_header hdr; | ||
| 212 | uint16_t page_off; | ||
| 213 | uint16_t length; | ||
| 214 | uint64_t frame; | ||
| 215 | } sub_page; | ||
| 216 | |||
| 217 | /* | ||
| 218 | * If the grant is GTF_transitive, @domid is allowed to use the | ||
| 219 | * grant @gref in domain @trans_domid, as if it was the local | ||
| 220 | * domain. Obviously, the transitive access must be compatible | ||
| 221 | * with the original grant. | ||
| 222 | */ | ||
| 223 | struct { | ||
| 224 | struct grant_entry_header hdr; | ||
| 225 | domid_t trans_domid; | ||
| 226 | uint16_t pad0; | ||
| 227 | grant_ref_t gref; | ||
| 228 | } transitive; | ||
| 229 | |||
| 230 | uint32_t __spacer[4]; /* Pad to a power of two */ | ||
| 231 | }; | ||
| 232 | |||
| 233 | typedef uint16_t grant_status_t; | ||
| 234 | |||
| 235 | /*********************************** | ||
| 236 | * GRANT TABLE QUERIES AND USES | ||
| 152 | */ | 237 | */ |
| 153 | typedef uint32_t grant_ref_t; | ||
| 154 | 238 | ||
| 155 | /* | 239 | /* |
| 156 | * Handle to track a mapping created via a grant reference. | 240 | * Handle to track a mapping created via a grant reference. |
| @@ -322,6 +406,79 @@ struct gnttab_query_size { | |||
| 322 | DEFINE_GUEST_HANDLE_STRUCT(gnttab_query_size); | 406 | DEFINE_GUEST_HANDLE_STRUCT(gnttab_query_size); |
| 323 | 407 | ||
| 324 | /* | 408 | /* |
| 409 | * GNTTABOP_unmap_and_replace: Destroy one or more grant-reference mappings | ||
| 410 | * tracked by <handle> but atomically replace the page table entry with one | ||
| 411 | * pointing to the machine address under <new_addr>. <new_addr> will be | ||
| 412 | * redirected to the null entry. | ||
| 413 | * NOTES: | ||
| 414 | * 1. The call may fail in an undefined manner if either mapping is not | ||
| 415 | * tracked by <handle>. | ||
| 416 | * 2. After executing a batch of unmaps, it is guaranteed that no stale | ||
| 417 | * mappings will remain in the device or host TLBs. | ||
| 418 | */ | ||
| 419 | #define GNTTABOP_unmap_and_replace 7 | ||
| 420 | struct gnttab_unmap_and_replace { | ||
| 421 | /* IN parameters. */ | ||
| 422 | uint64_t host_addr; | ||
| 423 | uint64_t new_addr; | ||
| 424 | grant_handle_t handle; | ||
| 425 | /* OUT parameters. */ | ||
| 426 | int16_t status; /* GNTST_* */ | ||
| 427 | }; | ||
| 428 | DEFINE_GUEST_HANDLE_STRUCT(gnttab_unmap_and_replace); | ||
| 429 | |||
| 430 | /* | ||
| 431 | * GNTTABOP_set_version: Request a particular version of the grant | ||
| 432 | * table shared table structure. This operation can only be performed | ||
| 433 | * once in any given domain. It must be performed before any grants | ||
| 434 | * are activated; otherwise, the domain will be stuck with version 1. | ||
| 435 | * The only defined versions are 1 and 2. | ||
| 436 | */ | ||
| 437 | #define GNTTABOP_set_version 8 | ||
| 438 | struct gnttab_set_version { | ||
| 439 | /* IN parameters */ | ||
| 440 | uint32_t version; | ||
| 441 | }; | ||
| 442 | DEFINE_GUEST_HANDLE_STRUCT(gnttab_set_version); | ||
| 443 | |||
| 444 | /* | ||
| 445 | * GNTTABOP_get_status_frames: Get the list of frames used to store grant | ||
| 446 | * status for <dom>. In grant format version 2, the status is separated | ||
| 447 | * from the other shared grant fields to allow more efficient synchronization | ||
| 448 | * using barriers instead of atomic cmpexch operations. | ||
| 449 | * <nr_frames> specify the size of vector <frame_list>. | ||
| 450 | * The frame addresses are returned in the <frame_list>. | ||
| 451 | * Only <nr_frames> addresses are returned, even if the table is larger. | ||
| 452 | * NOTES: | ||
| 453 | * 1. <dom> may be specified as DOMID_SELF. | ||
| 454 | * 2. Only a sufficiently-privileged domain may specify <dom> != DOMID_SELF. | ||
| 455 | */ | ||
| 456 | #define GNTTABOP_get_status_frames 9 | ||
| 457 | struct gnttab_get_status_frames { | ||
| 458 | /* IN parameters. */ | ||
| 459 | uint32_t nr_frames; | ||
| 460 | domid_t dom; | ||
| 461 | /* OUT parameters. */ | ||
| 462 | int16_t status; /* GNTST_* */ | ||
| 463 | GUEST_HANDLE(uint64_t) frame_list; | ||
| 464 | }; | ||
| 465 | DEFINE_GUEST_HANDLE_STRUCT(gnttab_get_status_frames); | ||
| 466 | |||
| 467 | /* | ||
| 468 | * GNTTABOP_get_version: Get the grant table version which is in | ||
| 469 | * effect for domain <dom>. | ||
| 470 | */ | ||
| 471 | #define GNTTABOP_get_version 10 | ||
| 472 | struct gnttab_get_version { | ||
| 473 | /* IN parameters */ | ||
| 474 | domid_t dom; | ||
| 475 | uint16_t pad; | ||
| 476 | /* OUT parameters */ | ||
| 477 | uint32_t version; | ||
| 478 | }; | ||
| 479 | DEFINE_GUEST_HANDLE_STRUCT(gnttab_get_version); | ||
| 480 | |||
| 481 | /* | ||
| 325 | * Bitfield values for update_pin_status.flags. | 482 | * Bitfield values for update_pin_status.flags. |
| 326 | */ | 483 | */ |
| 327 | /* Map the grant entry for access by I/O devices. */ | 484 | /* Map the grant entry for access by I/O devices. */ |
diff --git a/include/xen/interface/io/xs_wire.h b/include/xen/interface/io/xs_wire.h index f6f07aa35af5..7cdfca24eafb 100644 --- a/include/xen/interface/io/xs_wire.h +++ b/include/xen/interface/io/xs_wire.h | |||
| @@ -87,4 +87,7 @@ struct xenstore_domain_interface { | |||
| 87 | XENSTORE_RING_IDX rsp_cons, rsp_prod; | 87 | XENSTORE_RING_IDX rsp_cons, rsp_prod; |
| 88 | }; | 88 | }; |
| 89 | 89 | ||
| 90 | /* Violating this is very bad. See docs/misc/xenstore.txt. */ | ||
| 91 | #define XENSTORE_PAYLOAD_MAX 4096 | ||
| 92 | |||
| 90 | #endif /* _XS_WIRE_H */ | 93 | #endif /* _XS_WIRE_H */ |
diff --git a/include/xen/interface/xen.h b/include/xen/interface/xen.h index 6a6e91449347..a890804945e3 100644 --- a/include/xen/interface/xen.h +++ b/include/xen/interface/xen.h | |||
| @@ -523,6 +523,8 @@ struct tmem_op { | |||
| 523 | } u; | 523 | } u; |
| 524 | }; | 524 | }; |
| 525 | 525 | ||
| 526 | DEFINE_GUEST_HANDLE(u64); | ||
| 527 | |||
| 526 | #else /* __ASSEMBLY__ */ | 528 | #else /* __ASSEMBLY__ */ |
| 527 | 529 | ||
| 528 | /* In assembly code we cannot use C numeric constant suffixes. */ | 530 | /* In assembly code we cannot use C numeric constant suffixes. */ |
diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h index b1b6676c1c43..e8c599b237c2 100644 --- a/include/xen/xenbus.h +++ b/include/xen/xenbus.h | |||
| @@ -85,8 +85,6 @@ struct xenbus_device_id | |||
| 85 | 85 | ||
| 86 | /* A xenbus driver. */ | 86 | /* A xenbus driver. */ |
| 87 | struct xenbus_driver { | 87 | struct xenbus_driver { |
| 88 | char *name; | ||
| 89 | struct module *owner; | ||
| 90 | const struct xenbus_device_id *ids; | 88 | const struct xenbus_device_id *ids; |
| 91 | int (*probe)(struct xenbus_device *dev, | 89 | int (*probe)(struct xenbus_device *dev, |
| 92 | const struct xenbus_device_id *id); | 90 | const struct xenbus_device_id *id); |
| @@ -101,31 +99,20 @@ struct xenbus_driver { | |||
| 101 | int (*is_ready)(struct xenbus_device *dev); | 99 | int (*is_ready)(struct xenbus_device *dev); |
| 102 | }; | 100 | }; |
| 103 | 101 | ||
| 104 | static inline struct xenbus_driver *to_xenbus_driver(struct device_driver *drv) | 102 | #define DEFINE_XENBUS_DRIVER(var, drvname, methods...) \ |
| 105 | { | 103 | struct xenbus_driver var ## _driver = { \ |
| 106 | return container_of(drv, struct xenbus_driver, driver); | 104 | .driver.name = drvname + 0 ?: var ## _ids->devicetype, \ |
| 105 | .driver.owner = THIS_MODULE, \ | ||
| 106 | .ids = var ## _ids, ## methods \ | ||
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | int __must_check __xenbus_register_frontend(struct xenbus_driver *drv, | 109 | static inline struct xenbus_driver *to_xenbus_driver(struct device_driver *drv) |
| 110 | struct module *owner, | ||
| 111 | const char *mod_name); | ||
| 112 | |||
| 113 | static inline int __must_check | ||
| 114 | xenbus_register_frontend(struct xenbus_driver *drv) | ||
| 115 | { | 110 | { |
| 116 | WARN_ON(drv->owner != THIS_MODULE); | 111 | return container_of(drv, struct xenbus_driver, driver); |
| 117 | return __xenbus_register_frontend(drv, THIS_MODULE, KBUILD_MODNAME); | ||
| 118 | } | 112 | } |
| 119 | 113 | ||
| 120 | int __must_check __xenbus_register_backend(struct xenbus_driver *drv, | 114 | int __must_check xenbus_register_frontend(struct xenbus_driver *); |
| 121 | struct module *owner, | 115 | int __must_check xenbus_register_backend(struct xenbus_driver *); |
| 122 | const char *mod_name); | ||
| 123 | static inline int __must_check | ||
| 124 | xenbus_register_backend(struct xenbus_driver *drv) | ||
| 125 | { | ||
| 126 | WARN_ON(drv->owner != THIS_MODULE); | ||
| 127 | return __xenbus_register_backend(drv, THIS_MODULE, KBUILD_MODNAME); | ||
| 128 | } | ||
| 129 | 116 | ||
| 130 | void xenbus_unregister_driver(struct xenbus_driver *drv); | 117 | void xenbus_unregister_driver(struct xenbus_driver *drv); |
| 131 | 118 | ||
diff --git a/include/xen/xenbus_dev.h b/include/xen/xenbus_dev.h new file mode 100644 index 000000000000..ac5f0fe47ed9 --- /dev/null +++ b/include/xen/xenbus_dev.h | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | /****************************************************************************** | ||
| 2 | * evtchn.h | ||
| 3 | * | ||
| 4 | * Interface to /dev/xen/xenbus_backend. | ||
| 5 | * | ||
| 6 | * Copyright (c) 2011 Bastian Blank <waldi@debian.org> | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or | ||
| 9 | * modify it under the terms of the GNU General Public License version 2 | ||
| 10 | * as published by the Free Software Foundation; or, when distributed | ||
| 11 | * separately from the Linux kernel or incorporated into other | ||
| 12 | * software packages, subject to the following license: | ||
| 13 | * | ||
| 14 | * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 15 | * of this source file (the "Software"), to deal in the Software without | ||
| 16 | * restriction, including without limitation the rights to use, copy, modify, | ||
| 17 | * merge, publish, distribute, sublicense, and/or sell copies of the Software, | ||
| 18 | * and to permit persons to whom the Software is furnished to do so, subject to | ||
| 19 | * the following conditions: | ||
| 20 | * | ||
| 21 | * The above copyright notice and this permission notice shall be included in | ||
| 22 | * all copies or substantial portions of the Software. | ||
| 23 | * | ||
| 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
| 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
| 30 | * IN THE SOFTWARE. | ||
| 31 | */ | ||
| 32 | |||
| 33 | #ifndef __LINUX_XEN_XENBUS_DEV_H__ | ||
| 34 | #define __LINUX_XEN_XENBUS_DEV_H__ | ||
| 35 | |||
| 36 | #include <linux/ioctl.h> | ||
| 37 | |||
| 38 | #define IOCTL_XENBUS_BACKEND_EVTCHN \ | ||
| 39 | _IOC(_IOC_NONE, 'B', 0, 0) | ||
| 40 | |||
| 41 | #endif /* __LINUX_XEN_XENBUS_DEV_H__ */ | ||
