aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-06 18:13:01 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-06 18:13:01 -0400
commitf1c6872e4980bc4078cfaead05f892b3d78dea64 (patch)
tree24c18bb07714109296638b3193b35bdcc4098f7c /arch/arm/include
parent5f3d2f2e1a63679cf1c4a4210f2f1cc2f335bef6 (diff)
parent4ed5978bdd99114db7773cb3d78f2998bd17f694 (diff)
Merge tag 'stable/for-linus-3.7-arm-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen
Pull ADM Xen support from Konrad Rzeszutek Wilk: Features: * Allow a Linux guest to boot as initial domain and as normal guests on Xen on ARM (specifically ARMv7 with virtualized extensions). PV console, block and network frontend/backends are working. Bug-fixes: * Fix compile linux-next fallout. * Fix PVHVM bootup crashing. The Xen-unstable hypervisor (so will be 4.3 in a ~6 months), supports ARMv7 platforms. The goal in implementing this architecture is to exploit the hardware as much as possible. That means use as little as possible of PV operations (so no PV MMU) - and use existing PV drivers for I/Os (network, block, console, etc). This is similar to how PVHVM guests operate in X86 platform nowadays - except that on ARM there is no need for QEMU. The end result is that we share a lot of the generic Xen drivers and infrastructure. Details on how to compile/boot/etc are available at this Wiki: http://wiki.xen.org/wiki/Xen_ARMv7_with_Virtualization_Extensions and this blog has links to a technical discussion/presentations on the overall architecture: http://blog.xen.org/index.php/2012/09/21/xensummit-sessions-new-pvh-virtualisation-mode-for-arm-cortex-a15arm-servers-and-x86/ * tag 'stable/for-linus-3.7-arm-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen: (21 commits) xen/xen_initial_domain: check that xen_start_info is initialized xen: mark xen_init_IRQ __init xen/Makefile: fix dom-y build arm: introduce a DTS for Xen unprivileged virtual machines MAINTAINERS: add myself as Xen ARM maintainer xen/arm: compile netback xen/arm: compile blkfront and blkback xen/arm: implement alloc/free_xenballooned_pages with alloc_pages/kfree xen/arm: receive Xen events on ARM xen/arm: initialize grant_table on ARM xen/arm: get privilege status xen/arm: introduce CONFIG_XEN on ARM xen: do not compile manage, balloon, pci, acpi, pcpu and cpu_hotplug on ARM xen/arm: Introduce xen_ulong_t for unsigned long xen/arm: Xen detection and shared_info page mapping docs: Xen ARM DT bindings xen/arm: empty implementation of grant_table arch specific functions xen/arm: sync_bitops xen/arm: page.h definitions xen/arm: hypercalls ...
Diffstat (limited to 'arch/arm/include')
-rw-r--r--arch/arm/include/asm/hypervisor.h6
-rw-r--r--arch/arm/include/asm/sync_bitops.h27
-rw-r--r--arch/arm/include/asm/xen/events.h18
-rw-r--r--arch/arm/include/asm/xen/hypercall.h69
-rw-r--r--arch/arm/include/asm/xen/hypervisor.h19
-rw-r--r--arch/arm/include/asm/xen/interface.h73
-rw-r--r--arch/arm/include/asm/xen/page.h82
7 files changed, 294 insertions, 0 deletions
diff --git a/arch/arm/include/asm/hypervisor.h b/arch/arm/include/asm/hypervisor.h
new file mode 100644
index 000000000000..b90d9e523d6f
--- /dev/null
+++ b/arch/arm/include/asm/hypervisor.h
@@ -0,0 +1,6 @@
1#ifndef _ASM_ARM_HYPERVISOR_H
2#define _ASM_ARM_HYPERVISOR_H
3
4#include <asm/xen/hypervisor.h>
5
6#endif
diff --git a/arch/arm/include/asm/sync_bitops.h b/arch/arm/include/asm/sync_bitops.h
new file mode 100644
index 000000000000..63479eecbf76
--- /dev/null
+++ b/arch/arm/include/asm/sync_bitops.h
@@ -0,0 +1,27 @@
1#ifndef __ASM_SYNC_BITOPS_H__
2#define __ASM_SYNC_BITOPS_H__
3
4#include <asm/bitops.h>
5#include <asm/system.h>
6
7/* sync_bitops functions are equivalent to the SMP implementation of the
8 * original functions, independently from CONFIG_SMP being defined.
9 *
10 * We need them because _set_bit etc are not SMP safe if !CONFIG_SMP. But
11 * under Xen you might be communicating with a completely external entity
12 * who might be on another CPU (e.g. two uniprocessor guests communicating
13 * via event channels and grant tables). So we need a variant of the bit
14 * ops which are SMP safe even on a UP kernel.
15 */
16
17#define sync_set_bit(nr, p) _set_bit(nr, p)
18#define sync_clear_bit(nr, p) _clear_bit(nr, p)
19#define sync_change_bit(nr, p) _change_bit(nr, p)
20#define sync_test_and_set_bit(nr, p) _test_and_set_bit(nr, p)
21#define sync_test_and_clear_bit(nr, p) _test_and_clear_bit(nr, p)
22#define sync_test_and_change_bit(nr, p) _test_and_change_bit(nr, p)
23#define sync_test_bit(nr, addr) test_bit(nr, addr)
24#define sync_cmpxchg cmpxchg
25
26
27#endif
diff --git a/arch/arm/include/asm/xen/events.h b/arch/arm/include/asm/xen/events.h
new file mode 100644
index 000000000000..94b4e9020b02
--- /dev/null
+++ b/arch/arm/include/asm/xen/events.h
@@ -0,0 +1,18 @@
1#ifndef _ASM_ARM_XEN_EVENTS_H
2#define _ASM_ARM_XEN_EVENTS_H
3
4#include <asm/ptrace.h>
5
6enum ipi_vector {
7 XEN_PLACEHOLDER_VECTOR,
8
9 /* Xen IPIs go here */
10 XEN_NR_IPIS,
11};
12
13static inline int xen_irqs_disabled(struct pt_regs *regs)
14{
15 return raw_irqs_disabled_flags(regs->ARM_cpsr);
16}
17
18#endif /* _ASM_ARM_XEN_EVENTS_H */
diff --git a/arch/arm/include/asm/xen/hypercall.h b/arch/arm/include/asm/xen/hypercall.h
new file mode 100644
index 000000000000..8a823253d775
--- /dev/null
+++ b/arch/arm/include/asm/xen/hypercall.h
@@ -0,0 +1,69 @@
1/******************************************************************************
2 * hypercall.h
3 *
4 * Linux-specific hypervisor handling.
5 *
6 * Stefano Stabellini <stefano.stabellini@eu.citrix.com>, Citrix, 2012
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 _ASM_ARM_XEN_HYPERCALL_H
34#define _ASM_ARM_XEN_HYPERCALL_H
35
36#include <xen/interface/xen.h>
37
38long privcmd_call(unsigned call, unsigned long a1,
39 unsigned long a2, unsigned long a3,
40 unsigned long a4, unsigned long a5);
41int HYPERVISOR_xen_version(int cmd, void *arg);
42int HYPERVISOR_console_io(int cmd, int count, char *str);
43int HYPERVISOR_grant_table_op(unsigned int cmd, void *uop, unsigned int count);
44int HYPERVISOR_sched_op(int cmd, void *arg);
45int HYPERVISOR_event_channel_op(int cmd, void *arg);
46unsigned long HYPERVISOR_hvm_op(int op, void *arg);
47int HYPERVISOR_memory_op(unsigned int cmd, void *arg);
48int HYPERVISOR_physdev_op(int cmd, void *arg);
49
50static inline void
51MULTI_update_va_mapping(struct multicall_entry *mcl, unsigned long va,
52 unsigned int new_val, unsigned long flags)
53{
54 BUG();
55}
56
57static inline void
58MULTI_mmu_update(struct multicall_entry *mcl, struct mmu_update *req,
59 int count, int *success_count, domid_t domid)
60{
61 BUG();
62}
63
64static inline int
65HYPERVISOR_multicall(void *call_list, int nr_calls)
66{
67 BUG();
68}
69#endif /* _ASM_ARM_XEN_HYPERCALL_H */
diff --git a/arch/arm/include/asm/xen/hypervisor.h b/arch/arm/include/asm/xen/hypervisor.h
new file mode 100644
index 000000000000..d7ab99a0c9eb
--- /dev/null
+++ b/arch/arm/include/asm/xen/hypervisor.h
@@ -0,0 +1,19 @@
1#ifndef _ASM_ARM_XEN_HYPERVISOR_H
2#define _ASM_ARM_XEN_HYPERVISOR_H
3
4extern struct shared_info *HYPERVISOR_shared_info;
5extern struct start_info *xen_start_info;
6
7/* Lazy mode for batching updates / context switch */
8enum paravirt_lazy_mode {
9 PARAVIRT_LAZY_NONE,
10 PARAVIRT_LAZY_MMU,
11 PARAVIRT_LAZY_CPU,
12};
13
14static inline enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
15{
16 return PARAVIRT_LAZY_NONE;
17}
18
19#endif /* _ASM_ARM_XEN_HYPERVISOR_H */
diff --git a/arch/arm/include/asm/xen/interface.h b/arch/arm/include/asm/xen/interface.h
new file mode 100644
index 000000000000..ae05e56dd17d
--- /dev/null
+++ b/arch/arm/include/asm/xen/interface.h
@@ -0,0 +1,73 @@
1/******************************************************************************
2 * Guest OS interface to ARM Xen.
3 *
4 * Stefano Stabellini <stefano.stabellini@eu.citrix.com>, Citrix, 2012
5 */
6
7#ifndef _ASM_ARM_XEN_INTERFACE_H
8#define _ASM_ARM_XEN_INTERFACE_H
9
10#include <linux/types.h>
11
12#define uint64_aligned_t uint64_t __attribute__((aligned(8)))
13
14#define __DEFINE_GUEST_HANDLE(name, type) \
15 typedef struct { union { type *p; uint64_aligned_t q; }; } \
16 __guest_handle_ ## name
17
18#define DEFINE_GUEST_HANDLE_STRUCT(name) \
19 __DEFINE_GUEST_HANDLE(name, struct name)
20#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
21#define GUEST_HANDLE(name) __guest_handle_ ## name
22
23#define set_xen_guest_handle(hnd, val) \
24 do { \
25 if (sizeof(hnd) == 8) \
26 *(uint64_t *)&(hnd) = 0; \
27 (hnd).p = val; \
28 } while (0)
29
30#ifndef __ASSEMBLY__
31/* Explicitly size integers that represent pfns in the interface with
32 * Xen so that we can have one ABI that works for 32 and 64 bit guests. */
33typedef uint64_t xen_pfn_t;
34typedef uint64_t xen_ulong_t;
35/* Guest handles for primitive C types. */
36__DEFINE_GUEST_HANDLE(uchar, unsigned char);
37__DEFINE_GUEST_HANDLE(uint, unsigned int);
38__DEFINE_GUEST_HANDLE(ulong, unsigned long);
39DEFINE_GUEST_HANDLE(char);
40DEFINE_GUEST_HANDLE(int);
41DEFINE_GUEST_HANDLE(long);
42DEFINE_GUEST_HANDLE(void);
43DEFINE_GUEST_HANDLE(uint64_t);
44DEFINE_GUEST_HANDLE(uint32_t);
45DEFINE_GUEST_HANDLE(xen_pfn_t);
46
47/* Maximum number of virtual CPUs in multi-processor guests. */
48#define MAX_VIRT_CPUS 1
49
50struct arch_vcpu_info { };
51struct arch_shared_info { };
52
53/* TODO: Move pvclock definitions some place arch independent */
54struct pvclock_vcpu_time_info {
55 u32 version;
56 u32 pad0;
57 u64 tsc_timestamp;
58 u64 system_time;
59 u32 tsc_to_system_mul;
60 s8 tsc_shift;
61 u8 flags;
62 u8 pad[2];
63} __attribute__((__packed__)); /* 32 bytes */
64
65/* It is OK to have a 12 bytes struct with no padding because it is packed */
66struct pvclock_wall_clock {
67 u32 version;
68 u32 sec;
69 u32 nsec;
70} __attribute__((__packed__));
71#endif
72
73#endif /* _ASM_ARM_XEN_INTERFACE_H */
diff --git a/arch/arm/include/asm/xen/page.h b/arch/arm/include/asm/xen/page.h
new file mode 100644
index 000000000000..174202318dff
--- /dev/null
+++ b/arch/arm/include/asm/xen/page.h
@@ -0,0 +1,82 @@
1#ifndef _ASM_ARM_XEN_PAGE_H
2#define _ASM_ARM_XEN_PAGE_H
3
4#include <asm/page.h>
5#include <asm/pgtable.h>
6
7#include <linux/pfn.h>
8#include <linux/types.h>
9
10#include <xen/interface/grant_table.h>
11
12#define pfn_to_mfn(pfn) (pfn)
13#define phys_to_machine_mapping_valid (1)
14#define mfn_to_pfn(mfn) (mfn)
15#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
16
17#define pte_mfn pte_pfn
18#define mfn_pte pfn_pte
19
20/* Xen machine address */
21typedef struct xmaddr {
22 phys_addr_t maddr;
23} xmaddr_t;
24
25/* Xen pseudo-physical address */
26typedef struct xpaddr {
27 phys_addr_t paddr;
28} xpaddr_t;
29
30#define XMADDR(x) ((xmaddr_t) { .maddr = (x) })
31#define XPADDR(x) ((xpaddr_t) { .paddr = (x) })
32
33static inline xmaddr_t phys_to_machine(xpaddr_t phys)
34{
35 unsigned offset = phys.paddr & ~PAGE_MASK;
36 return XMADDR(PFN_PHYS(pfn_to_mfn(PFN_DOWN(phys.paddr))) | offset);
37}
38
39static inline xpaddr_t machine_to_phys(xmaddr_t machine)
40{
41 unsigned offset = machine.maddr & ~PAGE_MASK;
42 return XPADDR(PFN_PHYS(mfn_to_pfn(PFN_DOWN(machine.maddr))) | offset);
43}
44/* VIRT <-> MACHINE conversion */
45#define virt_to_machine(v) (phys_to_machine(XPADDR(__pa(v))))
46#define virt_to_pfn(v) (PFN_DOWN(__pa(v)))
47#define virt_to_mfn(v) (pfn_to_mfn(virt_to_pfn(v)))
48#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
49
50static inline xmaddr_t arbitrary_virt_to_machine(void *vaddr)
51{
52 /* TODO: assuming it is mapped in the kernel 1:1 */
53 return virt_to_machine(vaddr);
54}
55
56/* TODO: this shouldn't be here but it is because the frontend drivers
57 * are using it (its rolled in headers) even though we won't hit the code path.
58 * So for right now just punt with this.
59 */
60static inline pte_t *lookup_address(unsigned long address, unsigned int *level)
61{
62 BUG();
63 return NULL;
64}
65
66static inline int m2p_add_override(unsigned long mfn, struct page *page,
67 struct gnttab_map_grant_ref *kmap_op)
68{
69 return 0;
70}
71
72static inline int m2p_remove_override(struct page *page, bool clear_pte)
73{
74 return 0;
75}
76
77static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
78{
79 BUG();
80 return false;
81}
82#endif /* _ASM_ARM_XEN_PAGE_H */