xref: /openbmc/qemu/target/i386/kvm/xen-compat.h (revision 2f95279a)
1 /*
2  * Xen HVM emulation support in KVM
3  *
4  * Copyright © 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5  *
6  * This work is licensed under the terms of the GNU GPL, version 2 or later.
7  * See the COPYING file in the top-level directory.
8  *
9  */
10 
11 #ifndef QEMU_I386_KVM_XEN_COMPAT_H
12 #define QEMU_I386_KVM_XEN_COMPAT_H
13 
14 #include "hw/xen/interface/memory.h"
15 
16 typedef uint32_t compat_pfn_t;
17 typedef uint32_t compat_ulong_t;
18 typedef uint32_t compat_ptr_t;
19 
20 #define __DEFINE_COMPAT_HANDLE(name, type)      \
21     typedef struct {                            \
22         compat_ptr_t c;                         \
23         type *_[0] __attribute__((packed));   \
24     } __compat_handle_ ## name;                 \
25 
26 #define DEFINE_COMPAT_HANDLE(name) __DEFINE_COMPAT_HANDLE(name, name)
27 #define COMPAT_HANDLE(name) __compat_handle_ ## name
28 
29 DEFINE_COMPAT_HANDLE(compat_pfn_t);
30 DEFINE_COMPAT_HANDLE(compat_ulong_t);
31 DEFINE_COMPAT_HANDLE(int);
32 
33 struct compat_xen_add_to_physmap {
34     domid_t domid;
35     uint16_t size;
36     unsigned int space;
37     compat_ulong_t idx;
38     compat_pfn_t gpfn;
39 };
40 
41 struct compat_xen_add_to_physmap_batch {
42     domid_t domid;
43     uint16_t space;
44     uint16_t size;
45     uint16_t extra;
46     COMPAT_HANDLE(compat_ulong_t) idxs;
47     COMPAT_HANDLE(compat_pfn_t) gpfns;
48     COMPAT_HANDLE(int) errs;
49 };
50 
51 struct compat_physdev_map_pirq {
52     domid_t domid;
53     uint16_t pad;
54     /* IN */
55     int type;
56     /* IN (ignored for ..._MULTI_MSI) */
57     int index;
58     /* IN or OUT */
59     int pirq;
60     /* IN - high 16 bits hold segment for ..._MSI_SEG and ..._MULTI_MSI */
61     int bus;
62     /* IN */
63     int devfn;
64     /* IN (also OUT for ..._MULTI_MSI) */
65     int entry_nr;
66     /* IN */
67     uint64_t table_base;
68 } __attribute__((packed));
69 
70 #endif /* QEMU_I386_XEN_COMPAT_H */
71