From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tamas K Lengyel Subject: [PATCH v4 02/16] xen: Relocate p2m_mem_access_resume to mem_access common Date: Fri, 5 Sep 2014 10:58:30 +0200 Message-ID: <1409907524-12509-3-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 The p2m_mem_access resume function is not p2m specific and could be shared across ARM/x86. Signed-off-by: Tamas K Lengyel --- xen/arch/x86/mm/p2m.c | 24 ------------------------ xen/common/mem_access.c | 26 +++++++++++++++++++++++++- xen/common/mem_event.c | 2 +- xen/include/asm-x86/p2m.h | 2 -- xen/include/xen/mem_access.h | 3 +++ 5 files changed, 29 insertions(+), 28 deletions(-) diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index ac30e9c..e6dea90 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -1423,30 +1423,6 @@ bool_t p2m_mem_access_check(paddr_t gpa, unsigned long gla, return (p2ma == p2m_access_n2rwx); } -void p2m_mem_access_resume(struct domain *d) -{ - mem_event_response_t rsp; - - /* Pull all responses off the ring */ - while( mem_event_get_response(d, &d->mem_event->access, &rsp) ) - { - struct vcpu *v; - - if ( rsp.flags & MEM_EVENT_FLAG_DUMMY ) - continue; - - /* Validate the vcpu_id in the response. */ - if ( (rsp.vcpu_id >= d->max_vcpus) || !d->vcpu[rsp.vcpu_id] ) - continue; - - v = d->vcpu[rsp.vcpu_id]; - - /* Unpause domain */ - if ( rsp.flags & MEM_EVENT_FLAG_VCPU_PAUSED ) - mem_event_vcpu_unpause(v); - } -} - /* Set access type for a region of pfns. * If start_pfn == -1ul, sets the default access type */ long p2m_set_mem_access(struct domain *d, unsigned long pfn, uint32_t nr, diff --git a/xen/common/mem_access.c b/xen/common/mem_access.c index 07161a2..da5f363 100644 --- a/xen/common/mem_access.c +++ b/xen/common/mem_access.c @@ -29,6 +29,30 @@ #include #include +void mem_access_resume(struct domain *d) +{ + mem_event_response_t rsp; + + /* Pull all responses off the ring */ + while( mem_event_get_response(d, &d->mem_event->access, &rsp) ) + { + struct vcpu *v; + + if ( rsp.flags & MEM_EVENT_FLAG_DUMMY ) + continue; + + /* Validate the vcpu_id in the response. */ + if ( (rsp.vcpu_id >= d->max_vcpus) || !d->vcpu[rsp.vcpu_id] ) + continue; + + v = d->vcpu[rsp.vcpu_id]; + + /* Unpause domain */ + if ( rsp.flags & MEM_EVENT_FLAG_VCPU_PAUSED ) + mem_event_vcpu_unpause(v); + } +} + int mem_access_memop(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(xen_mem_access_op_t) arg) { @@ -58,7 +82,7 @@ int mem_access_memop(unsigned long cmd, switch ( mao.op ) { case XENMEM_access_op_resume: - p2m_mem_access_resume(d); + mem_access_resume(d); rc = 0; break; diff --git a/xen/common/mem_event.c b/xen/common/mem_event.c index b4a23fd..abafd23 100644 --- a/xen/common/mem_event.c +++ b/xen/common/mem_event.c @@ -430,7 +430,7 @@ static void mem_paging_notification(struct vcpu *v, unsigned int port) 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); + mem_access_resume(v->domain); } /* Registered with Xen-bound event channel for incoming notifications. */ diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index 3975e32..ae755bc 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -600,8 +600,6 @@ void p2m_mem_paging_resume(struct domain *d); bool_t p2m_mem_access_check(paddr_t gpa, unsigned long gla, struct npfec npfec, mem_event_request_t **req_ptr); -/* Resumes the running of the VCPU, restarting the last instruction */ -void p2m_mem_access_resume(struct domain *d); /* Set access type for a region of pfns. * If start_pfn == -1ul, sets the default access type */ diff --git a/xen/include/xen/mem_access.h b/xen/include/xen/mem_access.h index 19d1a2d..a58a41c 100644 --- a/xen/include/xen/mem_access.h +++ b/xen/include/xen/mem_access.h @@ -30,6 +30,7 @@ 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); +void mem_access_resume(struct domain *d); #else @@ -46,6 +47,8 @@ int mem_access_send_req(struct domain *d, mem_event_request_t *req) return -ENOSYS; } +static inline void mem_access_resume(struct domain *d) {} + #endif /* HAS_MEM_ACCESS */ #endif /* _XEN_ASM_MEM_ACCESS_H */ -- 2.1.0