From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tamas K Lengyel Subject: [PATCH RFC v2 04/12] xen/mem_event: Abstract architecture specific sanity checks Date: Wed, 27 Aug 2014 16:06:32 +0200 Message-ID: <1409148400-14810-5-git-send-email-tklengyel@sec.in.tum.de> References: <1409148400-14810-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: <1409148400-14810-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, 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 --- xen/common/mem_event.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/xen/common/mem_event.c b/xen/common/mem_event.c index 8be32e1..8bf0cf1 100644 --- a/xen/common/mem_event.c +++ b/xen/common/mem_event.c @@ -424,6 +424,19 @@ int __mem_event_claim_slot(struct domain *d, struct mem_event_domain *med, return mem_event_grab_slot(med, (current->domain != d)); } +static inline bool_t 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; +} + /* Registered with Xen-bound event channel for incoming notifications. */ static void mem_paging_notification(struct vcpu *v, unsigned int port) { @@ -558,6 +571,7 @@ int mem_event_domctl(struct domain *d, xen_domctl_mem_event_op_t *mec, rc = -EMLINK; if ( unlikely(need_iommu(d)) ) break; + } rc = -EXDEV; /* Disallow paging in a PoD guest */ @@ -593,14 +607,11 @@ 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 ( !mem_event_sanity_check(d) ) + { + rc = -ENODEV; break; + } rc = mem_event_enable(d, mec, med, _VPF_mem_access, HVM_PARAM_ACCESS_RING_PFN, -- 2.1.0.rc1