aboutsummaryrefslogtreecommitdiff
path: root/sys/x86/xen
diff options
context:
space:
mode:
authorRoger Pau Monné <royger@FreeBSD.org>2014-03-11 10:24:13 +0000
committerRoger Pau Monné <royger@FreeBSD.org>2014-03-11 10:24:13 +0000
commit4d30a3fb95b7a39999191a179db23de4715c5029 (patch)
tree321190d6e7f2a3801f2989218ddc460bf9a4c1f9 /sys/x86/xen
parent1e69553ed1dea6b8cb6c97a49a72e811f9bd7cde (diff)
downloadsrc-4d30a3fb95b7a39999191a179db23de4715c5029.tar.gz
src-4d30a3fb95b7a39999191a179db23de4715c5029.zip
xen: use the same hypercall mechanism for XEN and XENHVM
Currently XEN (PV) and XENHVM (PVHVM) ports use different ways to issue hypercalls, unify this by filling the hypercall_page under HVM also. Approved by: gibbs Sponsored by: Citrix Systems R&D amd64/include/xen/hypercall.h: - Unify Xen hypercall code by always using the PV way. i386/i386/locore.s: - Define hypercall_page on i386 XENHVM. x86/xen/hvm.c: - Fill hypercall_page on XENHVM kernels using the HVM method (only when running as an HVM guest).
Notes
Notes: svn path=/head/; revision=263010
Diffstat (limited to 'sys/x86/xen')
-rw-r--r--sys/x86/xen/hvm.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/sys/x86/xen/hvm.c b/sys/x86/xen/hvm.c
index 6977d561088c..cb895e566550 100644
--- a/sys/x86/xen/hvm.c
+++ b/sys/x86/xen/hvm.c
@@ -147,7 +147,7 @@ DPCPU_DEFINE(xen_intr_handle_t, ipi_handle[nitems(xen_ipis)]);
/*------------------ Hypervisor Access Shared Memory Regions -----------------*/
/** Hypercall table accessed via HYPERVISOR_*_op() methods. */
-char *hypercall_stubs;
+extern char *hypercall_page;
shared_info_t *HYPERVISOR_shared_info;
start_info_t *HYPERVISOR_start_info;
@@ -386,16 +386,21 @@ xen_hvm_cpuid_base(void)
* Allocate and fill in the hypcall page.
*/
static int
-xen_hvm_init_hypercall_stubs(void)
+xen_hvm_init_hypercall_stubs(enum xen_hvm_init_type init_type)
{
uint32_t base, regs[4];
int i;
+ if (xen_pv_domain()) {
+ /* hypercall page is already set in the PV case */
+ return (0);
+ }
+
base = xen_hvm_cpuid_base();
if (base == 0)
return (ENXIO);
- if (hypercall_stubs == NULL) {
+ if (init_type == XEN_HVM_INIT_COLD) {
do_cpuid(base + 1, regs);
printf("XEN: Hypervisor version %d.%d detected.\n",
regs[0] >> 16, regs[0] & 0xffff);
@@ -405,18 +410,9 @@ xen_hvm_init_hypercall_stubs(void)
* Find the hypercall pages.
*/
do_cpuid(base + 2, regs);
-
- if (hypercall_stubs == NULL) {
- size_t call_region_size;
-
- call_region_size = regs[0] * PAGE_SIZE;
- hypercall_stubs = malloc(call_region_size, M_XENHVM, M_NOWAIT);
- if (hypercall_stubs == NULL)
- panic("Unable to allocate Xen hypercall region");
- }
for (i = 0; i < regs[0]; i++)
- wrmsr(regs[1], vtophys(hypercall_stubs + i * PAGE_SIZE) + i);
+ wrmsr(regs[1], vtophys(&hypercall_page + i * PAGE_SIZE) + i);
return (0);
}
@@ -519,7 +515,7 @@ xen_hvm_init(enum xen_hvm_init_type init_type)
if (init_type == XEN_HVM_INIT_CANCELLED_SUSPEND)
return;
- error = xen_hvm_init_hypercall_stubs();
+ error = xen_hvm_init_hypercall_stubs(init_type);
switch (init_type) {
case XEN_HVM_INIT_COLD: