From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tamas K Lengyel Subject: [PATCH v4 07/16] xen/mem_event: Abstract architecture specific sanity checks Date: Fri, 5 Sep 2014 10:58:35 +0200 Message-ID: <1409907524-12509-8-git-send-email-tklengyel@sec.in.tum.de> References: <1409907524-12509-1-git-send-email-tklengyel@sec.in.tum.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1409907524-12509-1-git-send-email-tklengyel@sec.in.tum.de> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: ian.campbell@citrix.com, tim@xen.org, julien.grall@linaro.org, ian.jackson@eu.citrix.com, stefano.stabellini@citrix.com, andres@lagarcavilla.org, jbeulich@suse.com, dgdegra@tycho.nsa.gov, Tamas K Lengyel List-Id: xen-devel@lists.xenproject.org Move architecture specific sanity checks into its own function which is called when enabling mem_event. Signed-off-by: Tamas K Lengyel --- v4: Style fix. v2: Move sanity check function into architecture specific p2m.h --- xen/common/mem_event.c | 7 +------ xen/include/asm-x86/p2m.h | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/xen/common/mem_event.c b/xen/common/mem_event.c index b31bb9d..fbbed43 100644 --- a/xen/common/mem_event.c +++ b/xen/common/mem_event.c @@ -594,12 +594,7 @@ int mem_event_domctl(struct domain *d, xen_domctl_mem_event_op_t *mec, 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 ( !cpu_has_vmx ) + if ( !p2m_mem_event_sanity_check(d) ) break; rc = mem_event_enable(d, mec, med, _VPF_mem_access, diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index ae755bc..14be50f 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -611,6 +611,20 @@ long p2m_set_mem_access(struct domain *d, unsigned long start_pfn, uint32_t nr, int p2m_get_mem_access(struct domain *d, unsigned long pfn, xenmem_access_t *access); +/* Sanity check for mem_event hardware support */ +static inline bool_t p2m_mem_event_sanity_check(struct domain *d) +{ + /* Only HAP is supported */ + if ( !hap_enabled(d) ) + return 0; + + /* Currently only EPT is supported */ + if ( !cpu_has_vmx ) + return 0; + + return 1; +} + /* * Internal functions, only called by other p2m code */ -- 2.1.0