Skip to content

Commit

Permalink
Merge branch 'xenarm-for-linus' of git://xenbits.xen.org/people/sstab…
Browse files Browse the repository at this point in the history
…ellini/linux-pvhvm into stable/for-linus-3.7

* 'xenarm-for-linus' of git://xenbits.xen.org/people/sstabellini/linux-pvhvm:
  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
  arm: initial Xen support

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
  • Loading branch information
Konrad Rzeszutek Wilk committed Sep 26, 2012
2 parents c341ca4 + bbd6eb2 commit ae1659e
Show file tree
Hide file tree
Showing 35 changed files with 783 additions and 18 deletions.
25 changes: 25 additions & 0 deletions Documentation/devicetree/bindings/arm/xen.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
* Xen hypervisor device tree bindings

Xen ARM virtual platforms shall have a top-level "hypervisor" node with
the following properties:

- compatible:
compatible = "xen,xen-<version>", "xen,xen";
where <version> is the version of the Xen ABI of the platform.

- reg: specifies the base physical address and size of a region in
memory where the grant table should be mapped to, using an
HYPERVISOR_memory_op hypercall. The memory region is large enough to map
the whole grant table (it is larger or equal to gnttab_max_grant_frames()).

- interrupts: the interrupt used by Xen to inject event notifications.
A GIC node is also required.


Example (assuming #address-cells = <2> and #size-cells = <2>):

hypervisor {
compatible = "xen,xen-4.3", "xen,xen";
reg = <0 0xb0000000 0 0x20000>;
interrupts = <1 15 0xf08>;
};
7 changes: 7 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -7752,6 +7752,13 @@ F: drivers/xen/
F: arch/x86/include/asm/xen/
F: include/xen/

XEN HYPERVISOR ARM
M: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
L: xen-devel@lists.xensource.com (moderated for non-subscribers)
S: Supported
F: arch/arm/xen/
F: arch/arm/include/asm/xen/

XEN NETWORK BACKEND DRIVER
M: Ian Campbell <ian.campbell@citrix.com>
L: xen-devel@lists.xensource.com (moderated for non-subscribers)
Expand Down
10 changes: 10 additions & 0 deletions arch/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1897,6 +1897,16 @@ config DEPRECATED_PARAM_STRUCT
This was deprecated in 2001 and announced to live on for 5 years.
Some old boot loaders still use this way.

config XEN_DOM0
def_bool y
depends on XEN

config XEN
bool "Xen guest support on ARM (EXPERIMENTAL)"
depends on EXPERIMENTAL && ARM && OF
help
Say Y if you want to run Linux in a Virtual Machine on Xen on ARM.

endmenu

menu "Boot options"
Expand Down
1 change: 1 addition & 0 deletions arch/arm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ endif
core-$(CONFIG_FPE_NWFPE) += arch/arm/nwfpe/
core-$(CONFIG_FPE_FASTFPE) += $(FASTFPE_OBJ)
core-$(CONFIG_VFP) += arch/arm/vfp/
core-$(CONFIG_XEN) += arch/arm/xen/

# If we have a machine-specific directory, then include it in the build.
core-y += arch/arm/kernel/ arch/arm/mm/ arch/arm/common/
Expand Down
68 changes: 68 additions & 0 deletions arch/arm/boot/dts/xenvm-4.2.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Xen Virtual Machine for unprivileged guests
*
* Based on ARM Ltd. Versatile Express CoreTile Express (single CPU)
* Cortex-A15 MPCore (V2P-CA15)
*
*/

/dts-v1/;

/ {
model = "XENVM-4.2";
compatible = "xen,xenvm-4.2", "xen,xenvm";
interrupt-parent = <&gic>;
#address-cells = <2>;
#size-cells = <2>;

chosen {
/* this field is going to be adjusted by the hypervisor */
bootargs = "console=hvc0 root=/dev/xvda";
};

cpus {
#address-cells = <1>;
#size-cells = <0>;

cpu@0 {
device_type = "cpu";
compatible = "arm,cortex-a15";
reg = <0>;
};
};

memory@80000000 {
device_type = "memory";
/* this field is going to be adjusted by the hypervisor */
reg = <0 0x80000000 0 0x08000000>;
};

gic: interrupt-controller@2c001000 {
compatible = "arm,cortex-a15-gic", "arm,cortex-a9-gic";
#interrupt-cells = <3>;
#address-cells = <0>;
interrupt-controller;
reg = <0 0x2c001000 0 0x1000>,
<0 0x2c002000 0 0x100>;
};

timer {
compatible = "arm,armv7-timer";
interrupts = <1 13 0xf08>,
<1 14 0xf08>,
<1 11 0xf08>,
<1 10 0xf08>;
};

hypervisor {
compatible = "xen,xen-4.2", "xen,xen";
/* this field is going to be adjusted by the hypervisor */
reg = <0 0xb0000000 0 0x20000>;
/* this field is going to be adjusted by the hypervisor */
interrupts = <1 15 0xf08>;
};

motherboard {
arm,v2m-memory-map = "rs1";
};
};
6 changes: 6 additions & 0 deletions arch/arm/include/asm/hypervisor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef _ASM_ARM_HYPERVISOR_H
#define _ASM_ARM_HYPERVISOR_H

#include <asm/xen/hypervisor.h>

#endif
27 changes: 27 additions & 0 deletions arch/arm/include/asm/sync_bitops.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef __ASM_SYNC_BITOPS_H__
#define __ASM_SYNC_BITOPS_H__

#include <asm/bitops.h>
#include <asm/system.h>

/* sync_bitops functions are equivalent to the SMP implementation of the
* original functions, independently from CONFIG_SMP being defined.
*
* We need them because _set_bit etc are not SMP safe if !CONFIG_SMP. But
* under Xen you might be communicating with a completely external entity
* who might be on another CPU (e.g. two uniprocessor guests communicating
* via event channels and grant tables). So we need a variant of the bit
* ops which are SMP safe even on a UP kernel.
*/

#define sync_set_bit(nr, p) _set_bit(nr, p)
#define sync_clear_bit(nr, p) _clear_bit(nr, p)
#define sync_change_bit(nr, p) _change_bit(nr, p)
#define sync_test_and_set_bit(nr, p) _test_and_set_bit(nr, p)
#define sync_test_and_clear_bit(nr, p) _test_and_clear_bit(nr, p)
#define sync_test_and_change_bit(nr, p) _test_and_change_bit(nr, p)
#define sync_test_bit(nr, addr) test_bit(nr, addr)
#define sync_cmpxchg cmpxchg


#endif
18 changes: 18 additions & 0 deletions arch/arm/include/asm/xen/events.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef _ASM_ARM_XEN_EVENTS_H
#define _ASM_ARM_XEN_EVENTS_H

#include <asm/ptrace.h>

enum ipi_vector {
XEN_PLACEHOLDER_VECTOR,

/* Xen IPIs go here */
XEN_NR_IPIS,
};

static inline int xen_irqs_disabled(struct pt_regs *regs)
{
return raw_irqs_disabled_flags(regs->ARM_cpsr);
}

#endif /* _ASM_ARM_XEN_EVENTS_H */
69 changes: 69 additions & 0 deletions arch/arm/include/asm/xen/hypercall.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/******************************************************************************
* hypercall.h
*
* Linux-specific hypervisor handling.
*
* Stefano Stabellini <stefano.stabellini@eu.citrix.com>, Citrix, 2012
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation; or, when distributed
* separately from the Linux kernel or incorporated into other
* software packages, subject to the following license:
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this source file (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy, modify,
* merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/

#ifndef _ASM_ARM_XEN_HYPERCALL_H
#define _ASM_ARM_XEN_HYPERCALL_H

#include <xen/interface/xen.h>

long privcmd_call(unsigned call, unsigned long a1,
unsigned long a2, unsigned long a3,
unsigned long a4, unsigned long a5);
int HYPERVISOR_xen_version(int cmd, void *arg);
int HYPERVISOR_console_io(int cmd, int count, char *str);
int HYPERVISOR_grant_table_op(unsigned int cmd, void *uop, unsigned int count);
int HYPERVISOR_sched_op(int cmd, void *arg);
int HYPERVISOR_event_channel_op(int cmd, void *arg);
unsigned long HYPERVISOR_hvm_op(int op, void *arg);
int HYPERVISOR_memory_op(unsigned int cmd, void *arg);
int HYPERVISOR_physdev_op(int cmd, void *arg);

static inline void
MULTI_update_va_mapping(struct multicall_entry *mcl, unsigned long va,
unsigned int new_val, unsigned long flags)
{
BUG();
}

static inline void
MULTI_mmu_update(struct multicall_entry *mcl, struct mmu_update *req,
int count, int *success_count, domid_t domid)
{
BUG();
}

static inline int
HYPERVISOR_multicall(void *call_list, int nr_calls)
{
BUG();
}
#endif /* _ASM_ARM_XEN_HYPERCALL_H */
19 changes: 19 additions & 0 deletions arch/arm/include/asm/xen/hypervisor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef _ASM_ARM_XEN_HYPERVISOR_H
#define _ASM_ARM_XEN_HYPERVISOR_H

extern struct shared_info *HYPERVISOR_shared_info;
extern struct start_info *xen_start_info;

/* Lazy mode for batching updates / context switch */
enum paravirt_lazy_mode {
PARAVIRT_LAZY_NONE,
PARAVIRT_LAZY_MMU,
PARAVIRT_LAZY_CPU,
};

static inline enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
{
return PARAVIRT_LAZY_NONE;
}

#endif /* _ASM_ARM_XEN_HYPERVISOR_H */
73 changes: 73 additions & 0 deletions arch/arm/include/asm/xen/interface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/******************************************************************************
* Guest OS interface to ARM Xen.
*
* Stefano Stabellini <stefano.stabellini@eu.citrix.com>, Citrix, 2012
*/

#ifndef _ASM_ARM_XEN_INTERFACE_H
#define _ASM_ARM_XEN_INTERFACE_H

#include <linux/types.h>

#define uint64_aligned_t uint64_t __attribute__((aligned(8)))

#define __DEFINE_GUEST_HANDLE(name, type) \
typedef struct { union { type *p; uint64_aligned_t q; }; } \
__guest_handle_ ## name

#define DEFINE_GUEST_HANDLE_STRUCT(name) \
__DEFINE_GUEST_HANDLE(name, struct name)
#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
#define GUEST_HANDLE(name) __guest_handle_ ## name

#define set_xen_guest_handle(hnd, val) \
do { \
if (sizeof(hnd) == 8) \
*(uint64_t *)&(hnd) = 0; \
(hnd).p = val; \
} while (0)

#ifndef __ASSEMBLY__
/* Explicitly size integers that represent pfns in the interface with
* Xen so that we can have one ABI that works for 32 and 64 bit guests. */
typedef uint64_t xen_pfn_t;
typedef uint64_t xen_ulong_t;
/* Guest handles for primitive C types. */
__DEFINE_GUEST_HANDLE(uchar, unsigned char);
__DEFINE_GUEST_HANDLE(uint, unsigned int);
__DEFINE_GUEST_HANDLE(ulong, unsigned long);
DEFINE_GUEST_HANDLE(char);
DEFINE_GUEST_HANDLE(int);
DEFINE_GUEST_HANDLE(long);
DEFINE_GUEST_HANDLE(void);
DEFINE_GUEST_HANDLE(uint64_t);
DEFINE_GUEST_HANDLE(uint32_t);
DEFINE_GUEST_HANDLE(xen_pfn_t);

/* Maximum number of virtual CPUs in multi-processor guests. */
#define MAX_VIRT_CPUS 1

struct arch_vcpu_info { };
struct arch_shared_info { };

/* TODO: Move pvclock definitions some place arch independent */
struct pvclock_vcpu_time_info {
u32 version;
u32 pad0;
u64 tsc_timestamp;
u64 system_time;
u32 tsc_to_system_mul;
s8 tsc_shift;
u8 flags;
u8 pad[2];
} __attribute__((__packed__)); /* 32 bytes */

/* It is OK to have a 12 bytes struct with no padding because it is packed */
struct pvclock_wall_clock {
u32 version;
u32 sec;
u32 nsec;
} __attribute__((__packed__));
#endif

#endif /* _ASM_ARM_XEN_INTERFACE_H */
Loading

0 comments on commit ae1659e

Please sign in to comment.