1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#include <linux/module.h>
24#include <linux/vmalloc.h>
25#include <linux/slab.h>
26#include <linux/mm.h>
27
28#include <xen/interface/xen.h>
29#include <xen/interface/memory.h>
30#include <xen/grant_table.h>
31
32#include <asm/xen/hypervisor.h>
33
34
35
36
37
38
39int arch_gnttab_map_shared(unsigned long *frames, unsigned long nr_gframes,
40 unsigned long max_nr_gframes,
41 struct grant_entry **__shared)
42{
43 *__shared = __va(frames[0] << PAGE_SHIFT);
44 return 0;
45}
46
47void arch_gnttab_unmap_shared(struct grant_entry *shared,
48 unsigned long nr_gframes)
49{
50
51}
52
53static void
54gnttab_map_grant_ref_pre(struct gnttab_map_grant_ref *uop)
55{
56 uint32_t flags;
57
58 flags = uop->flags;
59
60 if (flags & GNTMAP_host_map) {
61 if (flags & GNTMAP_application_map) {
62 printk(KERN_DEBUG
63 "GNTMAP_application_map is not supported yet: "
64 "flags 0x%x\n", flags);
65 BUG();
66 }
67 if (flags & GNTMAP_contains_pte) {
68 printk(KERN_DEBUG
69 "GNTMAP_contains_pte is not supported yet: "
70 "flags 0x%x\n", flags);
71 BUG();
72 }
73 } else if (flags & GNTMAP_device_map) {
74 printk("GNTMAP_device_map is not supported yet 0x%x\n", flags);
75 BUG();
76 } else {
77 BUG();
78 }
79}
80
81int
82HYPERVISOR_grant_table_op(unsigned int cmd, void *uop, unsigned int count)
83{
84 if (cmd == GNTTABOP_map_grant_ref) {
85 unsigned int i;
86 for (i = 0; i < count; i++) {
87 gnttab_map_grant_ref_pre(
88 (struct gnttab_map_grant_ref *)uop + i);
89 }
90 }
91 return xencomm_hypercall_grant_table_op(cmd, uop, count);
92}
93
94EXPORT_SYMBOL(HYPERVISOR_grant_table_op);
95