mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
relocate mem_access and mem_event into common
In preparation to add support for ARM LPAE mem_event, relocate mem_access,
mem_event and auxiliary functions into common Xen code.
This patch makes no functional changes to the X86 side, for ARM mem_event
and mem_access functions are just defined as placeholder stubs, and are
actually enabled later in the series.
Edits that are only header path adjustments:
xen/arch/x86/domctl.c
xen/arch/x86/mm/hap/nested_ept.c
xen/arch/x86/mm/hap/nested_hap.c
xen/arch/x86/mm/mem_paging.c
xen/arch/x86/mm/mem_sharing.c
xen/arch/x86/mm/p2m-pod.c
xen/arch/x86/mm/p2m-pt.c
xen/arch/x86/mm/p2m.c
xen/arch/x86/x86_64/compat/mm.c
xen/arch/x86/x86_64/mm.c
Makefile adjustments for new/removed code:
xen/common/Makefile
xen/arch/x86/mm/Makefile
Relocated prepare_ring_for_helper and destroy_ring_for_helper functions:
xen/include/xen/mm.h
xen/common/memory.c
xen/include/asm-x86/hvm/hvm.h
xen/arch/x86/hvm/hvm.c
Code movement of mem_event and mem_access:
xen/arch/x86/mm/mem_access.c -> xen/common/mem_access.c
xen/arch/x86/mm/mem_event.c -> xen/common/mem_event.c
xen/include/asm-x86/mem_access.h -> xen/include/xen/mem_access.h
xen/include/asm-x86/mem_event.h -> xen/include/xen/mem_event.h
Signed-off-by: Tamas K Lengyel <tklengyel@sec.in.tum.de>
Acked-by: Tim Deegan <tim@xen.org>
This commit is contained in:
1 parent
2c141a997f
commit
aa673e9fa0
28 files changed
+244
-112
No files matched your search
@@ -338,6 +338,12 @@ F: xen/arch/x86/mm/mem_sharing.c
|
||||
F: xen/arch/x86/mm/mem_paging.c
|
||||
F: tools/memshr
|
||||
|
||||
MEMORY EVENT AND ACCESS
|
||||
M: Tim Deegan <tim@xen.org>
|
||||
S: Supported
|
||||
F: xen/common/mem_event.c
|
||||
F: xen/common/mem_access.c
|
||||
|
||||
XENTRACE
|
||||
M: George Dunlap <george.dunlap@eu.citrix.com>
|
||||
S: Supported
|
||||
|
||||
@@ -6,6 +6,10 @@ CONFIG_HVM := y
|
||||
CONFIG_MIGRATE := y
|
||||
CONFIG_XCUTILS := y
|
||||
|
||||
HAS_MEM_ACCESS := y
|
||||
HAS_MEM_PAGING := y
|
||||
HAS_MEM_SHARING := y
|
||||
|
||||
CFLAGS += -m32 -march=i686
|
||||
|
||||
# Use only if calling $(LD) directly.
|
||||
|
||||
@@ -7,6 +7,10 @@ CONFIG_HVM := y
|
||||
CONFIG_MIGRATE := y
|
||||
CONFIG_XCUTILS := y
|
||||
|
||||
HAS_MEM_ACCESS := y
|
||||
HAS_MEM_PAGING := y
|
||||
HAS_MEM_SHARING := y
|
||||
|
||||
CONFIG_XEN_INSTALL_SUFFIX := .gz
|
||||
|
||||
CFLAGS += -m64
|
||||
|
||||
@@ -57,6 +57,9 @@ CFLAGS-$(HAS_ACPI) += -DHAS_ACPI
|
||||
CFLAGS-$(HAS_GDBSX) += -DHAS_GDBSX
|
||||
CFLAGS-$(HAS_PASSTHROUGH) += -DHAS_PASSTHROUGH
|
||||
CFLAGS-$(HAS_DEVICE_TREE) += -DHAS_DEVICE_TREE
|
||||
CFLAGS-$(HAS_MEM_ACCESS) += -DHAS_MEM_ACCESS
|
||||
CFLAGS-$(HAS_MEM_PAGING) += -DHAS_MEM_PAGING
|
||||
CFLAGS-$(HAS_MEM_SHARING) += -DHAS_MEM_SHARING
|
||||
CFLAGS-$(HAS_PCI) += -DHAS_PCI
|
||||
CFLAGS-$(HAS_IOPORTS) += -DHAS_IOPORTS
|
||||
CFLAGS-$(HAS_PDX) += -DHAS_PDX
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <xen/hypercall.h> /* for arch_do_domctl */
|
||||
#include <xsm/xsm.h>
|
||||
#include <xen/iommu.h>
|
||||
#include <asm/mem_event.h>
|
||||
#include <xen/mem_event.h>
|
||||
#include <public/mem_event.h>
|
||||
#include <asm/mem_sharing.h>
|
||||
#include <asm/xstate.h>
|
||||
|
||||
+3
-60
@@ -35,6 +35,9 @@
|
||||
#include <xen/paging.h>
|
||||
#include <xen/cpu.h>
|
||||
#include <xen/wait.h>
|
||||
#include <xen/mem_event.h>
|
||||
#include <xen/mem_access.h>
|
||||
#include <xen/rangeset.h>
|
||||
#include <asm/shadow.h>
|
||||
#include <asm/hap.h>
|
||||
#include <asm/current.h>
|
||||
@@ -63,10 +66,7 @@
|
||||
#include <public/hvm/ioreq.h>
|
||||
#include <public/version.h>
|
||||
#include <public/memory.h>
|
||||
#include <asm/mem_event.h>
|
||||
#include <asm/mem_access.h>
|
||||
#include <public/mem_event.h>
|
||||
#include <xen/rangeset.h>
|
||||
#include <public/arch-x86/cpuid.h>
|
||||
|
||||
bool_t __read_mostly hvm_enabled;
|
||||
@@ -489,19 +489,6 @@ static void hvm_free_ioreq_gmfn(struct domain *d, unsigned long gmfn)
|
||||
clear_bit(i, &d->arch.hvm_domain.ioreq_gmfn.mask);
|
||||
}
|
||||
|
||||
void destroy_ring_for_helper(
|
||||
void **_va, struct page_info *page)
|
||||
{
|
||||
void *va = *_va;
|
||||
|
||||
if ( va != NULL )
|
||||
{
|
||||
unmap_domain_page_global(va);
|
||||
put_page_and_type(page);
|
||||
*_va = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void hvm_unmap_ioreq_page(struct hvm_ioreq_server *s, bool_t buf)
|
||||
{
|
||||
struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq;
|
||||
@@ -509,50 +496,6 @@ static void hvm_unmap_ioreq_page(struct hvm_ioreq_server *s, bool_t buf)
|
||||
destroy_ring_for_helper(&iorp->va, iorp->page);
|
||||
}
|
||||
|
||||
int prepare_ring_for_helper(
|
||||
struct domain *d, unsigned long gmfn, struct page_info **_page,
|
||||
void **_va)
|
||||
{
|
||||
struct page_info *page;
|
||||
p2m_type_t p2mt;
|
||||
void *va;
|
||||
|
||||
page = get_page_from_gfn(d, gmfn, &p2mt, P2M_UNSHARE);
|
||||
if ( p2m_is_paging(p2mt) )
|
||||
{
|
||||
if ( page )
|
||||
put_page(page);
|
||||
p2m_mem_paging_populate(d, gmfn);
|
||||
return -ENOENT;
|
||||
}
|
||||
if ( p2m_is_shared(p2mt) )
|
||||
{
|
||||
if ( page )
|
||||
put_page(page);
|
||||
return -ENOENT;
|
||||
}
|
||||
if ( !page )
|
||||
return -EINVAL;
|
||||
|
||||
if ( !get_page_type(page, PGT_writable_page) )
|
||||
{
|
||||
put_page(page);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
va = __map_domain_page_global(page);
|
||||
if ( va == NULL )
|
||||
{
|
||||
put_page_and_type(page);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
*_va = va;
|
||||
*_page = page;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hvm_map_ioreq_page(
|
||||
struct hvm_ioreq_server *s, bool_t buf, unsigned long gmfn)
|
||||
{
|
||||
|
||||
@@ -22,6 +22,10 @@
|
||||
#include <xen/lib.h>
|
||||
#include <xen/errno.h>
|
||||
#include <xen/domain_page.h>
|
||||
#include <xen/event.h>
|
||||
#include <xen/kernel.h>
|
||||
#include <xen/keyhandler.h>
|
||||
#include <xen/mem_event.h>
|
||||
#include <asm/current.h>
|
||||
#include <asm/cpufeature.h>
|
||||
#include <asm/processor.h>
|
||||
@@ -34,12 +38,8 @@
|
||||
#include <asm/hvm/vmx/vvmx.h>
|
||||
#include <asm/hvm/vmx/vmcs.h>
|
||||
#include <asm/flushtlb.h>
|
||||
#include <xen/event.h>
|
||||
#include <xen/kernel.h>
|
||||
#include <xen/keyhandler.h>
|
||||
#include <asm/shadow.h>
|
||||
#include <asm/tboot.h>
|
||||
#include <asm/mem_event.h>
|
||||
|
||||
static bool_t __read_mostly opt_vpid_enabled = 1;
|
||||
boolean_param("vpid", opt_vpid_enabled);
|
||||
|
||||
@@ -6,10 +6,8 @@ obj-y += p2m.o p2m-pt.o p2m-ept.o p2m-pod.o
|
||||
obj-y += guest_walk_2.o
|
||||
obj-y += guest_walk_3.o
|
||||
obj-$(x86_64) += guest_walk_4.o
|
||||
obj-$(x86_64) += mem_event.o
|
||||
obj-$(x86_64) += mem_paging.o
|
||||
obj-$(x86_64) += mem_sharing.o
|
||||
obj-$(x86_64) += mem_access.o
|
||||
|
||||
guest_walk_%.o: guest_walk.c Makefile
|
||||
$(CC) $(CFLAGS) -DGUEST_PAGING_LEVELS=$* -c $< -o $@
|
||||
@@ -17,14 +17,14 @@
|
||||
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
* Place - Suite 330, Boston, MA 02111-1307 USA.
|
||||
*/
|
||||
#include <xen/mem_event.h>
|
||||
#include <xen/event.h>
|
||||
#include <public/mem_event.h>
|
||||
#include <asm/domain.h>
|
||||
#include <asm/page.h>
|
||||
#include <asm/paging.h>
|
||||
#include <asm/p2m.h>
|
||||
#include <asm/mem_event.h>
|
||||
#include <public/mem_event.h>
|
||||
#include <asm/mem_sharing.h>
|
||||
#include <xen/event.h>
|
||||
#include <asm/hap.h>
|
||||
#include <asm/hvm/support.h>
|
||||
|
||||
|
||||
@@ -19,14 +19,14 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <xen/mem_event.h>
|
||||
#include <xen/event.h>
|
||||
#include <public/mem_event.h>
|
||||
#include <asm/domain.h>
|
||||
#include <asm/page.h>
|
||||
#include <asm/paging.h>
|
||||
#include <asm/p2m.h>
|
||||
#include <asm/mem_event.h>
|
||||
#include <public/mem_event.h>
|
||||
#include <asm/mem_sharing.h>
|
||||
#include <xen/event.h>
|
||||
#include <asm/hap.h>
|
||||
#include <asm/hvm/support.h>
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
|
||||
#include <asm/p2m.h>
|
||||
#include <asm/mem_event.h>
|
||||
#include <xen/mem_event.h>
|
||||
|
||||
|
||||
int mem_paging_memop(struct domain *d, xen_mem_event_op_t *mec)
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
#include <xen/mm.h>
|
||||
#include <xen/grant_table.h>
|
||||
#include <xen/sched.h>
|
||||
#include <xen/rcupdate.h>
|
||||
#include <xen/mem_event.h>
|
||||
#include <asm/page.h>
|
||||
#include <asm/string.h>
|
||||
#include <asm/p2m.h>
|
||||
#include <asm/mem_event.h>
|
||||
#include <asm/atomic.h>
|
||||
#include <xen/rcupdate.h>
|
||||
#include <asm/event.h>
|
||||
#include <xsm/xsm.h>
|
||||
|
||||
|
||||
@@ -20,16 +20,16 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <xen/iommu.h>
|
||||
#include <xen/mem_event.h>
|
||||
#include <xen/event.h>
|
||||
#include <public/mem_event.h>
|
||||
#include <asm/domain.h>
|
||||
#include <asm/page.h>
|
||||
#include <asm/paging.h>
|
||||
#include <asm/p2m.h>
|
||||
#include <asm/hvm/vmx/vmx.h> /* ept_p2m_init() */
|
||||
#include <xen/iommu.h>
|
||||
#include <asm/mem_event.h>
|
||||
#include <public/mem_event.h>
|
||||
#include <asm/mem_sharing.h>
|
||||
#include <xen/event.h>
|
||||
#include <asm/hvm/nestedhvm.h>
|
||||
#include <asm/hvm/svm/amd-iommu-proto.h>
|
||||
|
||||
|
||||
@@ -25,16 +25,16 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <xen/iommu.h>
|
||||
#include <xen/mem_event.h>
|
||||
#include <xen/event.h>
|
||||
#include <xen/trace.h>
|
||||
#include <public/mem_event.h>
|
||||
#include <asm/domain.h>
|
||||
#include <asm/page.h>
|
||||
#include <asm/paging.h>
|
||||
#include <asm/p2m.h>
|
||||
#include <xen/iommu.h>
|
||||
#include <asm/mem_event.h>
|
||||
#include <public/mem_event.h>
|
||||
#include <asm/mem_sharing.h>
|
||||
#include <xen/event.h>
|
||||
#include <xen/trace.h>
|
||||
#include <asm/hvm/nestedhvm.h>
|
||||
#include <asm/hvm/svm/amd-iommu-proto.h>
|
||||
|
||||
|
||||
@@ -24,16 +24,16 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <xen/iommu.h>
|
||||
#include <xen/mem_event.h>
|
||||
#include <xen/event.h>
|
||||
#include <public/mem_event.h>
|
||||
#include <asm/domain.h>
|
||||
#include <asm/page.h>
|
||||
#include <asm/paging.h>
|
||||
#include <asm/p2m.h>
|
||||
#include <asm/hvm/vmx/vmx.h> /* ept_p2m_init() */
|
||||
#include <xen/iommu.h>
|
||||
#include <asm/mem_event.h>
|
||||
#include <public/mem_event.h>
|
||||
#include <asm/mem_sharing.h>
|
||||
#include <xen/event.h>
|
||||
#include <asm/hvm/nestedhvm.h>
|
||||
#include <asm/hvm/svm/amd-iommu-proto.h>
|
||||
#include <xsm/xsm.h>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include <xen/event.h>
|
||||
#include <xen/mem_event.h>
|
||||
#include <xen/mem_access.h>
|
||||
#include <xen/multicall.h>
|
||||
#include <compat/memory.h>
|
||||
#include <compat/xen.h>
|
||||
#include <asm/mem_event.h>
|
||||
#include <asm/mem_sharing.h>
|
||||
#include <asm/mem_access.h>
|
||||
|
||||
int compat_set_gdt(XEN_GUEST_HANDLE_PARAM(uint) frame_list, unsigned int entries)
|
||||
{
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include <xen/nodemask.h>
|
||||
#include <xen/guest_access.h>
|
||||
#include <xen/hypercall.h>
|
||||
#include <xen/mem_event.h>
|
||||
#include <xen/mem_access.h>
|
||||
#include <asm/current.h>
|
||||
#include <asm/asm_defns.h>
|
||||
#include <asm/page.h>
|
||||
@@ -35,9 +37,7 @@
|
||||
#include <asm/msr.h>
|
||||
#include <asm/setup.h>
|
||||
#include <asm/numa.h>
|
||||
#include <asm/mem_event.h>
|
||||
#include <asm/mem_sharing.h>
|
||||
#include <asm/mem_access.h>
|
||||
#include <public/memory.h>
|
||||
|
||||
unsigned int __read_mostly m2p_compat_vstart = __HYPERVISOR_COMPAT_VIRT_START;
|
||||
|
||||
@@ -53,6 +53,8 @@ obj-y += radix-tree.o
|
||||
obj-y += rbtree.o
|
||||
obj-y += lzo.o
|
||||
obj-$(HAS_PDX) += pdx.o
|
||||
obj-$(HAS_MEM_ACCESS) += mem_access.o
|
||||
obj-$(HAS_MEM_ACCESS) += mem_event.o
|
||||
|
||||
obj-bin-$(CONFIG_X86) += $(foreach n,decompress bunzip2 unxz unlzma unlzo unlz4 earlycpio,$(n).init.o)
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <xen/domain.h>
|
||||
#include <xen/mm.h>
|
||||
#include <xen/event.h>
|
||||
#include <xen/mem_event.h>
|
||||
#include <xen/time.h>
|
||||
#include <xen/console.h>
|
||||
#include <xen/softirq.h>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/******************************************************************************
|
||||
* arch/x86/mm/mem_access.c
|
||||
* mem_access.c
|
||||
*
|
||||
* Memory access support.
|
||||
*
|
||||
@@ -24,11 +24,11 @@
|
||||
#include <xen/sched.h>
|
||||
#include <xen/guest_access.h>
|
||||
#include <xen/hypercall.h>
|
||||
#include <xen/mem_event.h>
|
||||
#include <public/memory.h>
|
||||
#include <asm/p2m.h>
|
||||
#include <asm/mem_event.h>
|
||||
#include <xsm/xsm.h>
|
||||
|
||||
|
||||
int mem_access_memop(unsigned long cmd,
|
||||
XEN_GUEST_HANDLE_PARAM(xen_mem_access_op_t) arg)
|
||||
{
|
||||
@@ -121,7 +121,7 @@ int mem_access_send_req(struct domain *d, mem_event_request_t *req)
|
||||
mem_event_put_request(d, &d->mem_event->access, req);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
@@ -1,5 +1,5 @@
|
||||
/******************************************************************************
|
||||
* arch/x86/mm/mem_event.c
|
||||
* mem_event.c
|
||||
*
|
||||
* Memory event support.
|
||||
*
|
||||
@@ -21,14 +21,21 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <asm/domain.h>
|
||||
#include <xen/sched.h>
|
||||
#include <xen/event.h>
|
||||
#include <xen/wait.h>
|
||||
#include <xen/mem_event.h>
|
||||
#include <xen/mem_access.h>
|
||||
#include <asm/p2m.h>
|
||||
#include <asm/mem_event.h>
|
||||
|
||||
#ifdef HAS_MEM_PAGING
|
||||
#include <asm/mem_paging.h>
|
||||
#include <asm/mem_access.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAS_MEM_SHARING
|
||||
#include <asm/mem_sharing.h>
|
||||
#endif
|
||||
|
||||
#include <xsm/xsm.h>
|
||||
|
||||
/* for public/io/ring.h macros */
|
||||
@@ -419,26 +426,32 @@ int __mem_event_claim_slot(struct domain *d, struct mem_event_domain *med,
|
||||
return mem_event_grab_slot(med, (current->domain != d));
|
||||
}
|
||||
|
||||
#ifdef HAS_MEM_PAGING
|
||||
/* Registered with Xen-bound event channel for incoming notifications. */
|
||||
static void mem_paging_notification(struct vcpu *v, unsigned int port)
|
||||
{
|
||||
if ( likely(v->domain->mem_event->paging.ring_page != NULL) )
|
||||
p2m_mem_paging_resume(v->domain);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAS_MEM_ACCESS
|
||||
/* Registered with Xen-bound event channel for incoming notifications. */
|
||||
static void mem_access_notification(struct vcpu *v, unsigned int port)
|
||||
{
|
||||
if ( likely(v->domain->mem_event->access.ring_page != NULL) )
|
||||
p2m_mem_access_resume(v->domain);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAS_MEM_SHARING
|
||||
/* Registered with Xen-bound event channel for incoming notifications. */
|
||||
static void mem_sharing_notification(struct vcpu *v, unsigned int port)
|
||||
{
|
||||
if ( likely(v->domain->mem_event->share.ring_page != NULL) )
|
||||
mem_sharing_sharing_resume(v->domain);
|
||||
}
|
||||
#endif
|
||||
|
||||
int do_mem_event_op(int op, uint32_t domain, void *arg)
|
||||
{
|
||||
@@ -455,12 +468,16 @@ int do_mem_event_op(int op, uint32_t domain, void *arg)
|
||||
|
||||
switch (op)
|
||||
{
|
||||
#ifdef HAS_MEM_PAGING
|
||||
case XENMEM_paging_op:
|
||||
ret = mem_paging_memop(d, (xen_mem_event_op_t *) arg);
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAS_MEM_SHARING
|
||||
case XENMEM_sharing_op:
|
||||
ret = mem_sharing_memop(d, (xen_mem_sharing_op_t *) arg);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
ret = -ENOSYS;
|
||||
}
|
||||
@@ -473,6 +490,7 @@ int do_mem_event_op(int op, uint32_t domain, void *arg)
|
||||
/* Clean up on domain destruction */
|
||||
void mem_event_cleanup(struct domain *d)
|
||||
{
|
||||
#ifdef HAS_MEM_PAGING
|
||||
if ( d->mem_event->paging.ring_page ) {
|
||||
/* Destroying the wait queue head means waking up all
|
||||
* queued vcpus. This will drain the list, allowing
|
||||
@@ -484,14 +502,19 @@ void mem_event_cleanup(struct domain *d)
|
||||
destroy_waitqueue_head(&d->mem_event->paging.wq);
|
||||
(void)mem_event_disable(d, &d->mem_event->paging);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAS_MEM_ACCESS
|
||||
if ( d->mem_event->access.ring_page ) {
|
||||
destroy_waitqueue_head(&d->mem_event->access.wq);
|
||||
(void)mem_event_disable(d, &d->mem_event->access);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAS_MEM_SHARING
|
||||
if ( d->mem_event->share.ring_page ) {
|
||||
destroy_waitqueue_head(&d->mem_event->share.wq);
|
||||
(void)mem_event_disable(d, &d->mem_event->share);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int mem_event_domctl(struct domain *d, xen_domctl_mem_event_op_t *mec,
|
||||
@@ -528,6 +551,7 @@ int mem_event_domctl(struct domain *d, xen_domctl_mem_event_op_t *mec,
|
||||
|
||||
switch ( mec->mode )
|
||||
{
|
||||
#ifdef HAS_MEM_PAGING
|
||||
case XEN_DOMCTL_MEM_EVENT_OP_PAGING:
|
||||
{
|
||||
struct mem_event_domain *med = &d->mem_event->paging;
|
||||
@@ -578,7 +602,9 @@ int mem_event_domctl(struct domain *d, xen_domctl_mem_event_op_t *mec,
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef HAS_MEM_ACCESS
|
||||
case XEN_DOMCTL_MEM_EVENT_OP_ACCESS:
|
||||
{
|
||||
struct mem_event_domain *med = &d->mem_event->access;
|
||||
@@ -627,7 +653,9 @@ int mem_event_domctl(struct domain *d, xen_domctl_mem_event_op_t *mec,
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef HAS_MEM_SHARING
|
||||
case XEN_DOMCTL_MEM_EVENT_OP_SHARING:
|
||||
{
|
||||
struct mem_event_domain *med = &d->mem_event->share;
|
||||
@@ -666,6 +694,7 @@ int mem_event_domctl(struct domain *d, xen_domctl_mem_event_op_t *mec,
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
rc = -ENOSYS;
|
||||
@@ -1104,6 +1104,69 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
|
||||
return rc;
|
||||
}
|
||||
|
||||
void destroy_ring_for_helper(
|
||||
void **_va, struct page_info *page)
|
||||
{
|
||||
void *va = *_va;
|
||||
|
||||
if ( va != NULL )
|
||||
{
|
||||
unmap_domain_page_global(va);
|
||||
put_page_and_type(page);
|
||||
*_va = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int prepare_ring_for_helper(
|
||||
struct domain *d, unsigned long gmfn, struct page_info **_page,
|
||||
void **_va)
|
||||
{
|
||||
struct page_info *page;
|
||||
p2m_type_t p2mt;
|
||||
void *va;
|
||||
|
||||
page = get_page_from_gfn(d, gmfn, &p2mt, P2M_UNSHARE);
|
||||
|
||||
#ifdef HAS_MEM_PAGING
|
||||
if ( p2m_is_paging(p2mt) )
|
||||
{
|
||||
if ( page )
|
||||
put_page(page);
|
||||
p2m_mem_paging_populate(d, gmfn);
|
||||
return -ENOENT;
|
||||
}
|
||||
#endif
|
||||
#ifdef HAS_MEM_SHARING
|
||||
if ( p2m_is_shared(p2mt) )
|
||||
{
|
||||
if ( page )
|
||||
put_page(page);
|
||||
return -ENOENT;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( !page )
|
||||
return -EINVAL;
|
||||
|
||||
if ( !get_page_type(page, PGT_writable_page) )
|
||||
{
|
||||
put_page(page);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
va = __map_domain_page_global(page);
|
||||
if ( va == NULL )
|
||||
{
|
||||
put_page_and_type(page);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
*_va = va;
|
||||
*_page = page;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* mode: C
|
||||
|
||||
@@ -300,7 +300,6 @@ struct page_info *get_page_from_gva(struct domain *d, vaddr_t va,
|
||||
})
|
||||
|
||||
static inline void put_gfn(struct domain *d, unsigned long gfn) {}
|
||||
static inline void mem_event_cleanup(struct domain *d) {}
|
||||
static inline int relinquish_shared_pages(struct domain *d)
|
||||
{
|
||||
return 0;
|
||||
|
||||
@@ -228,12 +228,6 @@ int hvm_vcpu_cacheattr_init(struct vcpu *v);
|
||||
void hvm_vcpu_cacheattr_destroy(struct vcpu *v);
|
||||
void hvm_vcpu_reset_state(struct vcpu *v, uint16_t cs, uint16_t ip);
|
||||
|
||||
/* Prepare/destroy a ring for a dom0 helper. Helper with talk
|
||||
* with Xen on behalf of this hvm domain. */
|
||||
int prepare_ring_for_helper(struct domain *d, unsigned long gmfn,
|
||||
struct page_info **_page, void **_va);
|
||||
void destroy_ring_for_helper(void **_va, struct page_info *page);
|
||||
|
||||
bool_t hvm_send_assist_req(ioreq_t *p);
|
||||
void hvm_broadcast_assist_req(ioreq_t *p);
|
||||
|
||||
|
||||
@@ -609,8 +609,6 @@ unsigned int domain_clamp_alloc_bitsize(struct domain *d, unsigned int bits);
|
||||
|
||||
unsigned long domain_get_maximum_gpfn(struct domain *d);
|
||||
|
||||
void mem_event_cleanup(struct domain *d);
|
||||
|
||||
extern struct domain *dom_xen, *dom_io, *dom_cow; /* for vmcoreinfo */
|
||||
|
||||
/* Definition of an mm lock: spinlock with extra fields for debugging */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/******************************************************************************
|
||||
* include/asm-x86/mem_access.h
|
||||
* mem_access.h
|
||||
*
|
||||
* Memory access support.
|
||||
*
|
||||
@@ -23,10 +23,31 @@
|
||||
#ifndef _XEN_ASM_MEM_ACCESS_H
|
||||
#define _XEN_ASM_MEM_ACCESS_H
|
||||
|
||||
#include <public/memory.h>
|
||||
|
||||
#ifdef HAS_MEM_ACCESS
|
||||
|
||||
int mem_access_memop(unsigned long cmd,
|
||||
XEN_GUEST_HANDLE_PARAM(xen_mem_access_op_t) arg);
|
||||
int mem_access_send_req(struct domain *d, mem_event_request_t *req);
|
||||
|
||||
#else
|
||||
|
||||
static inline
|
||||
int mem_access_memop(unsigned long cmd,
|
||||
XEN_GUEST_HANDLE_PARAM(xen_mem_access_op_t) arg)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline
|
||||
int mem_access_send_req(struct domain *d, mem_event_request_t *req)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
#endif /* HAS_MEM_ACCESS */
|
||||
|
||||
#endif /* _XEN_ASM_MEM_ACCESS_H */
|
||||
|
||||
/*
|
||||
@@ -1,5 +1,5 @@
|
||||
/******************************************************************************
|
||||
* include/asm-x86/mem_event.h
|
||||
* mem_event.h
|
||||
*
|
||||
* Common interface for memory event support.
|
||||
*
|
||||
@@ -24,6 +24,13 @@
|
||||
#ifndef __MEM_EVENT_H__
|
||||
#define __MEM_EVENT_H__
|
||||
|
||||
#include <xen/sched.h>
|
||||
|
||||
#ifdef HAS_MEM_ACCESS
|
||||
|
||||
/* Clean up on domain destruction */
|
||||
void mem_event_cleanup(struct domain *d);
|
||||
|
||||
/* Returns whether a ring has been set up */
|
||||
bool_t mem_event_check_ring(struct mem_event_domain *med);
|
||||
|
||||
@@ -69,6 +76,60 @@ int mem_event_domctl(struct domain *d, xen_domctl_mem_event_op_t *mec,
|
||||
void mem_event_vcpu_pause(struct vcpu *v);
|
||||
void mem_event_vcpu_unpause(struct vcpu *v);
|
||||
|
||||
#else
|
||||
|
||||
static inline void mem_event_cleanup(struct domain *d) {}
|
||||
|
||||
static inline bool_t mem_event_check_ring(struct mem_event_domain *med)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int mem_event_claim_slot(struct domain *d,
|
||||
struct mem_event_domain *med)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int mem_event_claim_slot_nosleep(struct domain *d,
|
||||
struct mem_event_domain *med)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline
|
||||
void mem_event_cancel_slot(struct domain *d, struct mem_event_domain *med)
|
||||
{}
|
||||
|
||||
static inline
|
||||
void mem_event_put_request(struct domain *d, struct mem_event_domain *med,
|
||||
mem_event_request_t *req)
|
||||
{}
|
||||
|
||||
static inline
|
||||
int mem_event_get_response(struct domain *d, struct mem_event_domain *med,
|
||||
mem_event_response_t *rsp)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int do_mem_event_op(int op, uint32_t domain, void *arg)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline
|
||||
int mem_event_domctl(struct domain *d, xen_domctl_mem_event_op_t *mec,
|
||||
XEN_GUEST_HANDLE_PARAM(void) u_domctl)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline void mem_event_vcpu_pause(struct vcpu *v) {}
|
||||
static inline void mem_event_vcpu_unpause(struct vcpu *v) {}
|
||||
|
||||
#endif /* HAS_MEM_ACCESS */
|
||||
|
||||
#endif /* __MEM_EVENT_H__ */
|
||||
|
||||
|
||||
@@ -371,4 +371,10 @@ int guest_remove_page(struct domain *d, unsigned long gmfn);
|
||||
/* TRUE if the whole page at @mfn is of the requested RAM type(s) above. */
|
||||
int page_is_ram_type(unsigned long mfn, unsigned long mem_type);
|
||||
|
||||
/* Prepare/destroy a ring for a dom0 helper. Helper with talk
|
||||
* with Xen on behalf of this domain. */
|
||||
int prepare_ring_for_helper(struct domain *d, unsigned long gmfn,
|
||||
struct page_info **_page, void **_va);
|
||||
void destroy_ring_for_helper(void **_va, struct page_info *page);
|
||||
|
||||
#endif /* __XEN_MM_H__ */
|
||||