113 lines
3.3 KiB
Diff
113 lines
3.3 KiB
Diff
|
changeset: 24106:2af5bfbc9fde
|
||
|
user: Olaf Hering <olaf@aepfle.de>
|
||
|
date: Tue Nov 08 19:35:42 2011 +0000
|
||
|
files: xen/arch/x86/mm/mem_event.c
|
||
|
description:
|
||
|
mem_event: check capabilities only once
|
||
|
|
||
|
It is not required to check the system capabilities during every domctl.
|
||
|
Rearrange the code to check them only once.
|
||
|
|
||
|
Signed-off-by: Olaf Hering <olaf@aepfle.de>
|
||
|
Committed-by: Keir Fraser <keir@xen.org>
|
||
|
|
||
|
|
||
|
---
|
||
|
xen/arch/x86/mm/mem_event.c | 54 ++++++++++++++++++++++++--------------------
|
||
|
1 file changed, 30 insertions(+), 24 deletions(-)
|
||
|
|
||
|
Index: xen-4.1.2-testing/xen/arch/x86/mm/mem_event.c
|
||
|
===================================================================
|
||
|
--- xen-4.1.2-testing.orig/xen/arch/x86/mm/mem_event.c
|
||
|
+++ xen-4.1.2-testing/xen/arch/x86/mm/mem_event.c
|
||
|
@@ -253,32 +253,35 @@ int mem_event_domctl(struct domain *d, x
|
||
|
case XEN_DOMCTL_MEM_EVENT_OP_PAGING:
|
||
|
{
|
||
|
struct mem_event_domain *med = &d->mem_paging;
|
||
|
- struct p2m_domain *p2m = p2m_get_hostp2m(d);
|
||
|
- rc = -ENODEV;
|
||
|
- /* Only HAP is supported */
|
||
|
- if ( !hap_enabled(d) )
|
||
|
- break;
|
||
|
-
|
||
|
- /* Currently only EPT is supported */
|
||
|
- if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL )
|
||
|
- break;
|
||
|
-
|
||
|
- rc = -EXDEV;
|
||
|
- /* Disallow paging in a PoD guest */
|
||
|
- if ( p2m->pod.entry_count )
|
||
|
- break;
|
||
|
+ rc = -EINVAL;
|
||
|
|
||
|
switch( mec->op )
|
||
|
{
|
||
|
case XEN_DOMCTL_MEM_EVENT_OP_PAGING_ENABLE:
|
||
|
{
|
||
|
+ struct p2m_domain *p2m = p2m_get_hostp2m(d);
|
||
|
+ rc = -ENODEV;
|
||
|
+ /* Only HAP is supported */
|
||
|
+ if ( !hap_enabled(d) )
|
||
|
+ break;
|
||
|
+
|
||
|
+ /* Currently only EPT is supported */
|
||
|
+ if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL )
|
||
|
+ break;
|
||
|
+
|
||
|
+ rc = -EXDEV;
|
||
|
+ /* Disallow paging in a PoD guest */
|
||
|
+ if ( p2m->pod.entry_count )
|
||
|
+ break;
|
||
|
+
|
||
|
rc = mem_event_enable(d, mec, med);
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case XEN_DOMCTL_MEM_EVENT_OP_PAGING_DISABLE:
|
||
|
{
|
||
|
- rc = mem_event_disable(med);
|
||
|
+ if ( med->ring_page )
|
||
|
+ rc = mem_event_disable(med);
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
@@ -295,26 +298,29 @@ int mem_event_domctl(struct domain *d, x
|
||
|
case XEN_DOMCTL_MEM_EVENT_OP_ACCESS:
|
||
|
{
|
||
|
struct mem_event_domain *med = &d->mem_access;
|
||
|
- rc = -ENODEV;
|
||
|
- /* Only HAP is supported */
|
||
|
- if ( !hap_enabled(d) )
|
||
|
- break;
|
||
|
-
|
||
|
- /* Currently only EPT is supported */
|
||
|
- if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL )
|
||
|
- break;
|
||
|
+ rc = -EINVAL;
|
||
|
|
||
|
switch( mec->op )
|
||
|
{
|
||
|
case XEN_DOMCTL_MEM_EVENT_OP_ACCESS_ENABLE:
|
||
|
{
|
||
|
+ rc = -ENODEV;
|
||
|
+ /* Only HAP is supported */
|
||
|
+ if ( !hap_enabled(d) )
|
||
|
+ break;
|
||
|
+
|
||
|
+ /* Currently only EPT is supported */
|
||
|
+ if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL )
|
||
|
+ break;
|
||
|
+
|
||
|
rc = mem_event_enable(d, mec, med);
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case XEN_DOMCTL_MEM_EVENT_OP_ACCESS_DISABLE:
|
||
|
{
|
||
|
- rc = mem_event_disable(&d->mem_access);
|
||
|
+ if ( med->ring_page )
|
||
|
+ rc = mem_event_disable(&d->mem_access);
|
||
|
}
|
||
|
break;
|
||
|
|