xref: /openbmc/qemu/target/i386/kvm/xen-compat.h (revision c61d1a066cb6cf90662c82d0e35660fc0ccacbaf)
1fb0fd2ceSJoao Martins /*
2fb0fd2ceSJoao Martins  * Xen HVM emulation support in KVM
3fb0fd2ceSJoao Martins  *
4fb0fd2ceSJoao Martins  * Copyright © 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5fb0fd2ceSJoao Martins  *
6fb0fd2ceSJoao Martins  * This work is licensed under the terms of the GNU GPL, version 2 or later.
7fb0fd2ceSJoao Martins  * See the COPYING file in the top-level directory.
8fb0fd2ceSJoao Martins  *
9fb0fd2ceSJoao Martins  */
10fb0fd2ceSJoao Martins 
11fb0fd2ceSJoao Martins #ifndef QEMU_I386_KVM_XEN_COMPAT_H
12fb0fd2ceSJoao Martins #define QEMU_I386_KVM_XEN_COMPAT_H
13fb0fd2ceSJoao Martins 
14fb0fd2ceSJoao Martins #include "hw/xen/interface/memory.h"
15fb0fd2ceSJoao Martins 
16fb0fd2ceSJoao Martins typedef uint32_t compat_pfn_t;
17fb0fd2ceSJoao Martins typedef uint32_t compat_ulong_t;
18782a7960SDavid Woodhouse typedef uint32_t compat_ptr_t;
19782a7960SDavid Woodhouse 
20782a7960SDavid Woodhouse #define __DEFINE_COMPAT_HANDLE(name, type)      \
21782a7960SDavid Woodhouse     typedef struct {                            \
22782a7960SDavid Woodhouse         compat_ptr_t c;                         \
23782a7960SDavid Woodhouse         type *_[0] __attribute__((packed));   \
24782a7960SDavid Woodhouse     } __compat_handle_ ## name;                 \
25782a7960SDavid Woodhouse 
26782a7960SDavid Woodhouse #define DEFINE_COMPAT_HANDLE(name) __DEFINE_COMPAT_HANDLE(name, name)
27782a7960SDavid Woodhouse #define COMPAT_HANDLE(name) __compat_handle_ ## name
28782a7960SDavid Woodhouse 
29782a7960SDavid Woodhouse DEFINE_COMPAT_HANDLE(compat_pfn_t);
30782a7960SDavid Woodhouse DEFINE_COMPAT_HANDLE(compat_ulong_t);
31782a7960SDavid Woodhouse DEFINE_COMPAT_HANDLE(int);
32fb0fd2ceSJoao Martins 
33fb0fd2ceSJoao Martins struct compat_xen_add_to_physmap {
34fb0fd2ceSJoao Martins     domid_t domid;
35fb0fd2ceSJoao Martins     uint16_t size;
36fb0fd2ceSJoao Martins     unsigned int space;
37fb0fd2ceSJoao Martins     compat_ulong_t idx;
38fb0fd2ceSJoao Martins     compat_pfn_t gpfn;
39fb0fd2ceSJoao Martins };
40fb0fd2ceSJoao Martins 
41782a7960SDavid Woodhouse struct compat_xen_add_to_physmap_batch {
42782a7960SDavid Woodhouse     domid_t domid;
43782a7960SDavid Woodhouse     uint16_t space;
44782a7960SDavid Woodhouse     uint16_t size;
45782a7960SDavid Woodhouse     uint16_t extra;
46782a7960SDavid Woodhouse     COMPAT_HANDLE(compat_ulong_t) idxs;
47782a7960SDavid Woodhouse     COMPAT_HANDLE(compat_pfn_t) gpfns;
48782a7960SDavid Woodhouse     COMPAT_HANDLE(int) errs;
49782a7960SDavid Woodhouse };
50782a7960SDavid Woodhouse 
51*799c2354SDavid Woodhouse struct compat_physdev_map_pirq {
52*799c2354SDavid Woodhouse     domid_t domid;
53*799c2354SDavid Woodhouse     uint16_t pad;
54*799c2354SDavid Woodhouse     /* IN */
55*799c2354SDavid Woodhouse     int type;
56*799c2354SDavid Woodhouse     /* IN (ignored for ..._MULTI_MSI) */
57*799c2354SDavid Woodhouse     int index;
58*799c2354SDavid Woodhouse     /* IN or OUT */
59*799c2354SDavid Woodhouse     int pirq;
60*799c2354SDavid Woodhouse     /* IN - high 16 bits hold segment for ..._MSI_SEG and ..._MULTI_MSI */
61*799c2354SDavid Woodhouse     int bus;
62*799c2354SDavid Woodhouse     /* IN */
63*799c2354SDavid Woodhouse     int devfn;
64*799c2354SDavid Woodhouse     /* IN (also OUT for ..._MULTI_MSI) */
65*799c2354SDavid Woodhouse     int entry_nr;
66*799c2354SDavid Woodhouse     /* IN */
67*799c2354SDavid Woodhouse     uint64_t table_base;
68*799c2354SDavid Woodhouse } __attribute__((packed));
69*799c2354SDavid Woodhouse 
70fb0fd2ceSJoao Martins #endif /* QEMU_I386_XEN_COMPAT_H */
71