aboutsummaryrefslogtreecommitdiffstats
path: root/include/xen
diff options
context:
space:
mode:
Diffstat (limited to 'include/xen')
-rw-r--r--include/xen/events.h7
-rw-r--r--include/xen/grant_table.h4
-rw-r--r--include/xen/hvm.h30
-rw-r--r--include/xen/interface/features.h6
-rw-r--r--include/xen/interface/grant_table.h1
-rw-r--r--include/xen/interface/hvm/hvm_op.h46
-rw-r--r--include/xen/interface/hvm/params.h95
-rw-r--r--include/xen/interface/memory.h50
-rw-r--r--include/xen/platform_pci.h49
-rw-r--r--include/xen/swiotlb-xen.h65
-rw-r--r--include/xen/xen-ops.h9
11 files changed, 362 insertions, 0 deletions
diff --git a/include/xen/events.h b/include/xen/events.h
index e68d59a90ca8..a15d93262e30 100644
--- a/include/xen/events.h
+++ b/include/xen/events.h
@@ -56,4 +56,11 @@ void xen_poll_irq(int irq);
56/* Determine the IRQ which is bound to an event channel */ 56/* Determine the IRQ which is bound to an event channel */
57unsigned irq_from_evtchn(unsigned int evtchn); 57unsigned irq_from_evtchn(unsigned int evtchn);
58 58
59/* Xen HVM evtchn vector callback */
60extern void xen_hvm_callback_vector(void);
61extern int xen_have_vector_callback;
62int xen_set_callback_via(uint64_t via);
63void xen_evtchn_do_upcall(struct pt_regs *regs);
64void xen_hvm_evtchn_do_upcall(void);
65
59#endif /* _XEN_EVENTS_H */ 66#endif /* _XEN_EVENTS_H */
diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h
index a40f1cd91be1..9a731706a016 100644
--- a/include/xen/grant_table.h
+++ b/include/xen/grant_table.h
@@ -51,6 +51,7 @@ struct gnttab_free_callback {
51 u16 count; 51 u16 count;
52}; 52};
53 53
54int gnttab_init(void);
54int gnttab_suspend(void); 55int gnttab_suspend(void);
55int gnttab_resume(void); 56int gnttab_resume(void);
56 57
@@ -112,6 +113,9 @@ int arch_gnttab_map_shared(unsigned long *frames, unsigned long nr_gframes,
112void arch_gnttab_unmap_shared(struct grant_entry *shared, 113void arch_gnttab_unmap_shared(struct grant_entry *shared,
113 unsigned long nr_gframes); 114 unsigned long nr_gframes);
114 115
116extern unsigned long xen_hvm_resume_frames;
117unsigned int gnttab_max_grant_frames(void);
118
115#define gnttab_map_vaddr(map) ((void *)(map.host_virt_addr)) 119#define gnttab_map_vaddr(map) ((void *)(map.host_virt_addr))
116 120
117#endif /* __ASM_GNTTAB_H__ */ 121#endif /* __ASM_GNTTAB_H__ */
diff --git a/include/xen/hvm.h b/include/xen/hvm.h
new file mode 100644
index 000000000000..b193fa2f9fdd
--- /dev/null
+++ b/include/xen/hvm.h
@@ -0,0 +1,30 @@
1/* Simple wrappers around HVM functions */
2#ifndef XEN_HVM_H__
3#define XEN_HVM_H__
4
5#include <xen/interface/hvm/params.h>
6#include <asm/xen/hypercall.h>
7
8static inline int hvm_get_parameter(int idx, uint64_t *value)
9{
10 struct xen_hvm_param xhv;
11 int r;
12
13 xhv.domid = DOMID_SELF;
14 xhv.index = idx;
15 r = HYPERVISOR_hvm_op(HVMOP_get_param, &xhv);
16 if (r < 0) {
17 printk(KERN_ERR "Cannot get hvm parameter %d: %d!\n",
18 idx, r);
19 return r;
20 }
21 *value = xhv.value;
22 return r;
23}
24
25#define HVM_CALLBACK_VIA_TYPE_VECTOR 0x2
26#define HVM_CALLBACK_VIA_TYPE_SHIFT 56
27#define HVM_CALLBACK_VECTOR(x) (((uint64_t)HVM_CALLBACK_VIA_TYPE_VECTOR)<<\
28 HVM_CALLBACK_VIA_TYPE_SHIFT | (x))
29
30#endif /* XEN_HVM_H__ */
diff --git a/include/xen/interface/features.h b/include/xen/interface/features.h
index f51b6413b054..70d2563ab166 100644
--- a/include/xen/interface/features.h
+++ b/include/xen/interface/features.h
@@ -41,6 +41,12 @@
41/* x86: Does this Xen host support the MMU_PT_UPDATE_PRESERVE_AD hypercall? */ 41/* x86: Does this Xen host support the MMU_PT_UPDATE_PRESERVE_AD hypercall? */
42#define XENFEAT_mmu_pt_update_preserve_ad 5 42#define XENFEAT_mmu_pt_update_preserve_ad 5
43 43
44/* x86: Does this Xen host support the HVM callback vector type? */
45#define XENFEAT_hvm_callback_vector 8
46
47/* x86: pvclock algorithm is safe to use on HVM */
48#define XENFEAT_hvm_safe_pvclock 9
49
44#define XENFEAT_NR_SUBMAPS 1 50#define XENFEAT_NR_SUBMAPS 1
45 51
46#endif /* __XEN_PUBLIC_FEATURES_H__ */ 52#endif /* __XEN_PUBLIC_FEATURES_H__ */
diff --git a/include/xen/interface/grant_table.h b/include/xen/interface/grant_table.h
index 39da93c21de0..39e571796e32 100644
--- a/include/xen/interface/grant_table.h
+++ b/include/xen/interface/grant_table.h
@@ -28,6 +28,7 @@
28#ifndef __XEN_PUBLIC_GRANT_TABLE_H__ 28#ifndef __XEN_PUBLIC_GRANT_TABLE_H__
29#define __XEN_PUBLIC_GRANT_TABLE_H__ 29#define __XEN_PUBLIC_GRANT_TABLE_H__
30 30
31#include <xen/interface/xen.h>
31 32
32/*********************************** 33/***********************************
33 * GRANT TABLE REPRESENTATION 34 * GRANT TABLE REPRESENTATION
diff --git a/include/xen/interface/hvm/hvm_op.h b/include/xen/interface/hvm/hvm_op.h
new file mode 100644
index 000000000000..a4827f46ee97
--- /dev/null
+++ b/include/xen/interface/hvm/hvm_op.h
@@ -0,0 +1,46 @@
1/*
2 * Permission is hereby granted, free of charge, to any person obtaining a copy
3 * of this software and associated documentation files (the "Software"), to
4 * deal in the Software without restriction, including without limitation the
5 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
6 * sell copies of the Software, and to permit persons to whom the Software is
7 * furnished to do so, subject to the following conditions:
8 *
9 * The above copyright notice and this permission notice shall be included in
10 * all copies or substantial portions of the Software.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 * DEALINGS IN THE SOFTWARE.
19 */
20
21#ifndef __XEN_PUBLIC_HVM_HVM_OP_H__
22#define __XEN_PUBLIC_HVM_HVM_OP_H__
23
24/* Get/set subcommands: the second argument of the hypercall is a
25 * pointer to a xen_hvm_param struct. */
26#define HVMOP_set_param 0
27#define HVMOP_get_param 1
28struct xen_hvm_param {
29 domid_t domid; /* IN */
30 uint32_t index; /* IN */
31 uint64_t value; /* IN/OUT */
32};
33DEFINE_GUEST_HANDLE_STRUCT(xen_hvm_param);
34
35/* Hint from PV drivers for pagetable destruction. */
36#define HVMOP_pagetable_dying 9
37struct xen_hvm_pagetable_dying {
38 /* Domain with a pagetable about to be destroyed. */
39 domid_t domid;
40 /* guest physical address of the toplevel pagetable dying */
41 aligned_u64 gpa;
42};
43typedef struct xen_hvm_pagetable_dying xen_hvm_pagetable_dying_t;
44DEFINE_GUEST_HANDLE_STRUCT(xen_hvm_pagetable_dying_t);
45
46#endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */
diff --git a/include/xen/interface/hvm/params.h b/include/xen/interface/hvm/params.h
new file mode 100644
index 000000000000..1888d8c157e6
--- /dev/null
+++ b/include/xen/interface/hvm/params.h
@@ -0,0 +1,95 @@
1/*
2 * Permission is hereby granted, free of charge, to any person obtaining a copy
3 * of this software and associated documentation files (the "Software"), to
4 * deal in the Software without restriction, including without limitation the
5 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
6 * sell copies of the Software, and to permit persons to whom the Software is
7 * furnished to do so, subject to the following conditions:
8 *
9 * The above copyright notice and this permission notice shall be included in
10 * all copies or substantial portions of the Software.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 * DEALINGS IN THE SOFTWARE.
19 */
20
21#ifndef __XEN_PUBLIC_HVM_PARAMS_H__
22#define __XEN_PUBLIC_HVM_PARAMS_H__
23
24#include "hvm_op.h"
25
26/*
27 * Parameter space for HVMOP_{set,get}_param.
28 */
29
30/*
31 * How should CPU0 event-channel notifications be delivered?
32 * val[63:56] == 0: val[55:0] is a delivery GSI (Global System Interrupt).
33 * val[63:56] == 1: val[55:0] is a delivery PCI INTx line, as follows:
34 * Domain = val[47:32], Bus = val[31:16],
35 * DevFn = val[15: 8], IntX = val[ 1: 0]
36 * val[63:56] == 2: val[7:0] is a vector number.
37 * If val == 0 then CPU0 event-channel notifications are not delivered.
38 */
39#define HVM_PARAM_CALLBACK_IRQ 0
40
41#define HVM_PARAM_STORE_PFN 1
42#define HVM_PARAM_STORE_EVTCHN 2
43
44#define HVM_PARAM_PAE_ENABLED 4
45
46#define HVM_PARAM_IOREQ_PFN 5
47
48#define HVM_PARAM_BUFIOREQ_PFN 6
49
50/*
51 * Set mode for virtual timers (currently x86 only):
52 * delay_for_missed_ticks (default):
53 * Do not advance a vcpu's time beyond the correct delivery time for
54 * interrupts that have been missed due to preemption. Deliver missed
55 * interrupts when the vcpu is rescheduled and advance the vcpu's virtual
56 * time stepwise for each one.
57 * no_delay_for_missed_ticks:
58 * As above, missed interrupts are delivered, but guest time always tracks
59 * wallclock (i.e., real) time while doing so.
60 * no_missed_ticks_pending:
61 * No missed interrupts are held pending. Instead, to ensure ticks are
62 * delivered at some non-zero rate, if we detect missed ticks then the
63 * internal tick alarm is not disabled if the VCPU is preempted during the
64 * next tick period.
65 * one_missed_tick_pending:
66 * Missed interrupts are collapsed together and delivered as one 'late tick'.
67 * Guest time always tracks wallclock (i.e., real) time.
68 */
69#define HVM_PARAM_TIMER_MODE 10
70#define HVMPTM_delay_for_missed_ticks 0
71#define HVMPTM_no_delay_for_missed_ticks 1
72#define HVMPTM_no_missed_ticks_pending 2
73#define HVMPTM_one_missed_tick_pending 3
74
75/* Boolean: Enable virtual HPET (high-precision event timer)? (x86-only) */
76#define HVM_PARAM_HPET_ENABLED 11
77
78/* Identity-map page directory used by Intel EPT when CR0.PG=0. */
79#define HVM_PARAM_IDENT_PT 12
80
81/* Device Model domain, defaults to 0. */
82#define HVM_PARAM_DM_DOMAIN 13
83
84/* ACPI S state: currently support S0 and S3 on x86. */
85#define HVM_PARAM_ACPI_S_STATE 14
86
87/* TSS used on Intel when CR0.PE=0. */
88#define HVM_PARAM_VM86_TSS 15
89
90/* Boolean: Enable aligning all periodic vpts to reduce interrupts */
91#define HVM_PARAM_VPT_ALIGN 16
92
93#define HVM_NR_PARAMS 17
94
95#endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */
diff --git a/include/xen/interface/memory.h b/include/xen/interface/memory.h
index af36ead16817..d3938d3e71f8 100644
--- a/include/xen/interface/memory.h
+++ b/include/xen/interface/memory.h
@@ -9,6 +9,8 @@
9#ifndef __XEN_PUBLIC_MEMORY_H__ 9#ifndef __XEN_PUBLIC_MEMORY_H__
10#define __XEN_PUBLIC_MEMORY_H__ 10#define __XEN_PUBLIC_MEMORY_H__
11 11
12#include <linux/spinlock.h>
13
12/* 14/*
13 * Increase or decrease the specified domain's memory reservation. Returns a 15 * Increase or decrease the specified domain's memory reservation. Returns a
14 * -ve errcode on failure, or the # extents successfully allocated or freed. 16 * -ve errcode on failure, or the # extents successfully allocated or freed.
@@ -53,6 +55,48 @@ struct xen_memory_reservation {
53DEFINE_GUEST_HANDLE_STRUCT(xen_memory_reservation); 55DEFINE_GUEST_HANDLE_STRUCT(xen_memory_reservation);
54 56
55/* 57/*
58 * An atomic exchange of memory pages. If return code is zero then
59 * @out.extent_list provides GMFNs of the newly-allocated memory.
60 * Returns zero on complete success, otherwise a negative error code.
61 * On complete success then always @nr_exchanged == @in.nr_extents.
62 * On partial success @nr_exchanged indicates how much work was done.
63 */
64#define XENMEM_exchange 11
65struct xen_memory_exchange {
66 /*
67 * [IN] Details of memory extents to be exchanged (GMFN bases).
68 * Note that @in.address_bits is ignored and unused.
69 */
70 struct xen_memory_reservation in;
71
72 /*
73 * [IN/OUT] Details of new memory extents.
74 * We require that:
75 * 1. @in.domid == @out.domid
76 * 2. @in.nr_extents << @in.extent_order ==
77 * @out.nr_extents << @out.extent_order
78 * 3. @in.extent_start and @out.extent_start lists must not overlap
79 * 4. @out.extent_start lists GPFN bases to be populated
80 * 5. @out.extent_start is overwritten with allocated GMFN bases
81 */
82 struct xen_memory_reservation out;
83
84 /*
85 * [OUT] Number of input extents that were successfully exchanged:
86 * 1. The first @nr_exchanged input extents were successfully
87 * deallocated.
88 * 2. The corresponding first entries in the output extent list correctly
89 * indicate the GMFNs that were successfully exchanged.
90 * 3. All other input and output extents are untouched.
91 * 4. If not all input exents are exchanged then the return code of this
92 * command will be non-zero.
93 * 5. THIS FIELD MUST BE INITIALISED TO ZERO BY THE CALLER!
94 */
95 unsigned long nr_exchanged;
96};
97
98DEFINE_GUEST_HANDLE_STRUCT(xen_memory_exchange);
99/*
56 * Returns the maximum machine frame number of mapped RAM in this system. 100 * Returns the maximum machine frame number of mapped RAM in this system.
57 * This command always succeeds (it never returns an error code). 101 * This command always succeeds (it never returns an error code).
58 * arg == NULL. 102 * arg == NULL.
@@ -142,4 +186,10 @@ struct xen_translate_gpfn_list {
142}; 186};
143DEFINE_GUEST_HANDLE_STRUCT(xen_translate_gpfn_list); 187DEFINE_GUEST_HANDLE_STRUCT(xen_translate_gpfn_list);
144 188
189
190/*
191 * Prevent the balloon driver from changing the memory reservation
192 * during a driver critical region.
193 */
194extern spinlock_t xen_reservation_lock;
145#endif /* __XEN_PUBLIC_MEMORY_H__ */ 195#endif /* __XEN_PUBLIC_MEMORY_H__ */
diff --git a/include/xen/platform_pci.h b/include/xen/platform_pci.h
new file mode 100644
index 000000000000..ce9d671c636c
--- /dev/null
+++ b/include/xen/platform_pci.h
@@ -0,0 +1,49 @@
1#ifndef _XEN_PLATFORM_PCI_H
2#define _XEN_PLATFORM_PCI_H
3
4#define XEN_IOPORT_MAGIC_VAL 0x49d2
5#define XEN_IOPORT_LINUX_PRODNUM 0x0003
6#define XEN_IOPORT_LINUX_DRVVER 0x0001
7
8#define XEN_IOPORT_BASE 0x10
9
10#define XEN_IOPORT_PLATFLAGS (XEN_IOPORT_BASE + 0) /* 1 byte access (R/W) */
11#define XEN_IOPORT_MAGIC (XEN_IOPORT_BASE + 0) /* 2 byte access (R) */
12#define XEN_IOPORT_UNPLUG (XEN_IOPORT_BASE + 0) /* 2 byte access (W) */
13#define XEN_IOPORT_DRVVER (XEN_IOPORT_BASE + 0) /* 4 byte access (W) */
14
15#define XEN_IOPORT_SYSLOG (XEN_IOPORT_BASE + 2) /* 1 byte access (W) */
16#define XEN_IOPORT_PROTOVER (XEN_IOPORT_BASE + 2) /* 1 byte access (R) */
17#define XEN_IOPORT_PRODNUM (XEN_IOPORT_BASE + 2) /* 2 byte access (W) */
18
19#define XEN_UNPLUG_ALL_IDE_DISKS 1
20#define XEN_UNPLUG_ALL_NICS 2
21#define XEN_UNPLUG_AUX_IDE_DISKS 4
22#define XEN_UNPLUG_ALL 7
23#define XEN_UNPLUG_IGNORE 8
24
25static inline int xen_must_unplug_nics(void) {
26#if (defined(CONFIG_XEN_NETDEV_FRONTEND) || \
27 defined(CONFIG_XEN_NETDEV_FRONTEND_MODULE)) && \
28 (defined(CONFIG_XEN_PLATFORM_PCI) || \
29 defined(CONFIG_XEN_PLATFORM_PCI_MODULE))
30 return 1;
31#else
32 return 0;
33#endif
34}
35
36static inline int xen_must_unplug_disks(void) {
37#if (defined(CONFIG_XEN_BLKDEV_FRONTEND) || \
38 defined(CONFIG_XEN_BLKDEV_FRONTEND_MODULE)) && \
39 (defined(CONFIG_XEN_PLATFORM_PCI) || \
40 defined(CONFIG_XEN_PLATFORM_PCI_MODULE))
41 return 1;
42#else
43 return 0;
44#endif
45}
46
47extern int xen_platform_pci_unplug;
48
49#endif /* _XEN_PLATFORM_PCI_H */
diff --git a/include/xen/swiotlb-xen.h b/include/xen/swiotlb-xen.h
new file mode 100644
index 000000000000..2ea2fdc79c16
--- /dev/null
+++ b/include/xen/swiotlb-xen.h
@@ -0,0 +1,65 @@
1#ifndef __LINUX_SWIOTLB_XEN_H
2#define __LINUX_SWIOTLB_XEN_H
3
4#include <linux/swiotlb.h>
5
6extern void xen_swiotlb_init(int verbose);
7
8extern void
9*xen_swiotlb_alloc_coherent(struct device *hwdev, size_t size,
10 dma_addr_t *dma_handle, gfp_t flags);
11
12extern void
13xen_swiotlb_free_coherent(struct device *hwdev, size_t size,
14 void *vaddr, dma_addr_t dma_handle);
15
16extern dma_addr_t xen_swiotlb_map_page(struct device *dev, struct page *page,
17 unsigned long offset, size_t size,
18 enum dma_data_direction dir,
19 struct dma_attrs *attrs);
20
21extern void xen_swiotlb_unmap_page(struct device *hwdev, dma_addr_t dev_addr,
22 size_t size, enum dma_data_direction dir,
23 struct dma_attrs *attrs);
24/*
25extern int
26xen_swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nents,
27 enum dma_data_direction dir);
28
29extern void
30xen_swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
31 enum dma_data_direction dir);
32*/
33extern int
34xen_swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl,
35 int nelems, enum dma_data_direction dir,
36 struct dma_attrs *attrs);
37
38extern void
39xen_swiotlb_unmap_sg_attrs(struct device *hwdev, struct scatterlist *sgl,
40 int nelems, enum dma_data_direction dir,
41 struct dma_attrs *attrs);
42
43extern void
44xen_swiotlb_sync_single_for_cpu(struct device *hwdev, dma_addr_t dev_addr,
45 size_t size, enum dma_data_direction dir);
46
47extern void
48xen_swiotlb_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg,
49 int nelems, enum dma_data_direction dir);
50
51extern void
52xen_swiotlb_sync_single_for_device(struct device *hwdev, dma_addr_t dev_addr,
53 size_t size, enum dma_data_direction dir);
54
55extern void
56xen_swiotlb_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
57 int nelems, enum dma_data_direction dir);
58
59extern int
60xen_swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr);
61
62extern int
63xen_swiotlb_dma_supported(struct device *hwdev, u64 mask);
64
65#endif /* __LINUX_SWIOTLB_XEN_H */
diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h
index 883a21bba24b..351f4051f6d8 100644
--- a/include/xen/xen-ops.h
+++ b/include/xen/xen-ops.h
@@ -7,6 +7,7 @@ DECLARE_PER_CPU(struct vcpu_info *, xen_vcpu);
7 7
8void xen_pre_suspend(void); 8void xen_pre_suspend(void);
9void xen_post_suspend(int suspend_cancelled); 9void xen_post_suspend(int suspend_cancelled);
10void xen_hvm_post_suspend(int suspend_cancelled);
10 11
11void xen_mm_pin_all(void); 12void xen_mm_pin_all(void);
12void xen_mm_unpin_all(void); 13void xen_mm_unpin_all(void);
@@ -14,4 +15,12 @@ void xen_mm_unpin_all(void);
14void xen_timer_resume(void); 15void xen_timer_resume(void);
15void xen_arch_resume(void); 16void xen_arch_resume(void);
16 17
18int xen_setup_shutdown_event(void);
19
20extern unsigned long *xen_contiguous_bitmap;
21int xen_create_contiguous_region(unsigned long vstart, unsigned int order,
22 unsigned int address_bits);
23
24void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order);
25
17#endif /* INCLUDE_XEN_OPS_H */ 26#endif /* INCLUDE_XEN_OPS_H */