From patchwork Tue Jul 16 17:06:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Ovidiu PIRCALABU X-Patchwork-Id: 11046519 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0C5D96C5 for ; Tue, 16 Jul 2019 17:08:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E893428681 for ; Tue, 16 Jul 2019 17:08:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DCF7B28686; Tue, 16 Jul 2019 17:08:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 398BD28681 for ; Tue, 16 Jul 2019 17:08:10 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hnQuM-0005nZ-Ra; Tue, 16 Jul 2019 17:06:30 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hnQuL-0005n7-93 for xen-devel@lists.xenproject.org; Tue, 16 Jul 2019 17:06:29 +0000 X-Inumbo-ID: 0bcbf44b-a7ec-11e9-8980-bc764e045a96 Received: from mx01.bbu.dsd.mx.bitdefender.com (unknown [91.199.104.161]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 0bcbf44b-a7ec-11e9-8980-bc764e045a96; Tue, 16 Jul 2019 17:06:27 +0000 (UTC) Received: from smtp.bitdefender.com (smtp02.buh.bitdefender.net [10.17.80.76]) by mx01.bbu.dsd.mx.bitdefender.com (Postfix) with ESMTPS id C127A30644BA; Tue, 16 Jul 2019 20:06:25 +0300 (EEST) Received: from bitdefender.com (unknown [195.189.155.70]) by smtp.bitdefender.com (Postfix) with ESMTPSA id B33A5305B7B3; Tue, 16 Jul 2019 20:06:25 +0300 (EEST) From: Petre Pircalabu To: xen-devel@lists.xenproject.org Date: Tue, 16 Jul 2019 20:06:16 +0300 Message-Id: <05d37a1cb32ed76fe728f5ebb296aca55455b56a.1563293545.git.ppircalabu@bitdefender.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Subject: [Xen-devel] [PATCH v2 02/10] vm_event: Remove "ring" suffix from vm_event_check_ring X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Petre Pircalabu , Tamas K Lengyel , Wei Liu , Razvan Cojocaru , George Dunlap , Andrew Cooper , Julien Grall , Stefano Stabellini , Jan Beulich , Alexandru Isaila , Volodymyr Babchuk , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Decouple implementation from interface to allow vm_event_check to be used regardless of the vm_event underlying implementation. Signed-off-by: Petre Pircalabu Acked-by: Andrew Cooper Acked-by: Tamas K Lengyel Reviewed-by: Alexandru Isaila --- xen/arch/arm/mem_access.c | 2 +- xen/arch/x86/mm/mem_access.c | 4 ++-- xen/arch/x86/mm/mem_paging.c | 2 +- xen/common/mem_access.c | 2 +- xen/common/vm_event.c | 24 ++++++++++++------------ xen/drivers/passthrough/pci.c | 2 +- xen/include/xen/vm_event.h | 4 ++-- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/xen/arch/arm/mem_access.c b/xen/arch/arm/mem_access.c index 3e36202..d54760b 100644 --- a/xen/arch/arm/mem_access.c +++ b/xen/arch/arm/mem_access.c @@ -290,7 +290,7 @@ bool p2m_mem_access_check(paddr_t gpa, vaddr_t gla, const struct npfec npfec) } /* Otherwise, check if there is a vm_event monitor subscriber */ - if ( !vm_event_check_ring(v->domain->vm_event_monitor) ) + if ( !vm_event_check(v->domain->vm_event_monitor) ) { /* No listener */ if ( p2m->access_required ) diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c index 0144f92..640352e 100644 --- a/xen/arch/x86/mm/mem_access.c +++ b/xen/arch/x86/mm/mem_access.c @@ -182,7 +182,7 @@ bool p2m_mem_access_check(paddr_t gpa, unsigned long gla, gfn_unlock(p2m, gfn, 0); /* Otherwise, check if there is a memory event listener, and send the message along */ - if ( !vm_event_check_ring(d->vm_event_monitor) || !req_ptr ) + if ( !vm_event_check(d->vm_event_monitor) || !req_ptr ) { /* No listener */ if ( p2m->access_required ) @@ -210,7 +210,7 @@ bool p2m_mem_access_check(paddr_t gpa, unsigned long gla, return true; } } - if ( vm_event_check_ring(d->vm_event_monitor) && + if ( vm_event_check(d->vm_event_monitor) && d->arch.monitor.inguest_pagefault_disabled && npfec.kind != npfec_kind_with_gla ) /* don't send a mem_event */ { diff --git a/xen/arch/x86/mm/mem_paging.c b/xen/arch/x86/mm/mem_paging.c index 54a94fa..dc2a59a 100644 --- a/xen/arch/x86/mm/mem_paging.c +++ b/xen/arch/x86/mm/mem_paging.c @@ -44,7 +44,7 @@ int mem_paging_memop(XEN_GUEST_HANDLE_PARAM(xen_mem_paging_op_t) arg) goto out; rc = -ENODEV; - if ( unlikely(!vm_event_check_ring(d->vm_event_paging)) ) + if ( unlikely(!vm_event_check(d->vm_event_paging)) ) goto out; switch( mpo.op ) diff --git a/xen/common/mem_access.c b/xen/common/mem_access.c index 010e6f8..51e4e2b 100644 --- a/xen/common/mem_access.c +++ b/xen/common/mem_access.c @@ -52,7 +52,7 @@ int mem_access_memop(unsigned long cmd, goto out; rc = -ENODEV; - if ( unlikely(!vm_event_check_ring(d->vm_event_monitor)) ) + if ( unlikely(!vm_event_check(d->vm_event_monitor)) ) goto out; switch ( mao.op ) diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index 56b506a..515a917 100644 --- a/xen/common/vm_event.c +++ b/xen/common/vm_event.c @@ -179,7 +179,7 @@ static int vm_event_disable(struct domain *d, struct vm_event_domain **p_ved) { struct vm_event_domain *ved = *p_ved; - if ( vm_event_check_ring(ved) ) + if ( vm_event_check(ved) ) { struct vcpu *v; @@ -259,7 +259,7 @@ void vm_event_put_request(struct domain *d, RING_IDX req_prod; struct vcpu *curr = current; - if( !vm_event_check_ring(ved) ) + if( !vm_event_check(ved) ) return; if ( curr->domain != d ) @@ -362,7 +362,7 @@ static int vm_event_resume(struct domain *d, struct vm_event_domain *ved) */ ASSERT(d != current->domain); - if ( unlikely(!vm_event_check_ring(ved)) ) + if ( unlikely(!vm_event_check(ved)) ) return -ENODEV; /* Pull all responses off the ring. */ @@ -433,7 +433,7 @@ static int vm_event_resume(struct domain *d, struct vm_event_domain *ved) void vm_event_cancel_slot(struct domain *d, struct vm_event_domain *ved) { - if( !vm_event_check_ring(ved) ) + if( !vm_event_check(ved) ) return; spin_lock(&ved->lock); @@ -488,7 +488,7 @@ static int vm_event_wait_slot(struct vm_event_domain *ved) return rc; } -bool vm_event_check_ring(struct vm_event_domain *ved) +bool vm_event_check(struct vm_event_domain *ved) { return ved && ved->ring_page; } @@ -508,7 +508,7 @@ bool vm_event_check_ring(struct vm_event_domain *ved) int __vm_event_claim_slot(struct domain *d, struct vm_event_domain *ved, bool allow_sleep) { - if ( !vm_event_check_ring(ved) ) + if ( !vm_event_check(ved) ) return -EOPNOTSUPP; if ( (current->domain == d) && allow_sleep ) @@ -543,7 +543,7 @@ static void mem_sharing_notification(struct vcpu *v, unsigned int port) void vm_event_cleanup(struct domain *d) { #ifdef CONFIG_HAS_MEM_PAGING - if ( vm_event_check_ring(d->vm_event_paging) ) + if ( vm_event_check(d->vm_event_paging) ) { /* Destroying the wait queue head means waking up all * queued vcpus. This will drain the list, allowing @@ -556,13 +556,13 @@ void vm_event_cleanup(struct domain *d) (void)vm_event_disable(d, &d->vm_event_paging); } #endif - if ( vm_event_check_ring(d->vm_event_monitor) ) + if ( vm_event_check(d->vm_event_monitor) ) { destroy_waitqueue_head(&d->vm_event_monitor->wq); (void)vm_event_disable(d, &d->vm_event_monitor); } #ifdef CONFIG_HAS_MEM_SHARING - if ( vm_event_check_ring(d->vm_event_share) ) + if ( vm_event_check(d->vm_event_share) ) { destroy_waitqueue_head(&d->vm_event_share->wq); (void)vm_event_disable(d, &d->vm_event_share); @@ -646,7 +646,7 @@ int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec) break; case XEN_VM_EVENT_DISABLE: - if ( vm_event_check_ring(d->vm_event_paging) ) + if ( vm_event_check(d->vm_event_paging) ) { domain_pause(d); rc = vm_event_disable(d, &d->vm_event_paging); @@ -683,7 +683,7 @@ int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec) break; case XEN_VM_EVENT_DISABLE: - if ( vm_event_check_ring(d->vm_event_monitor) ) + if ( vm_event_check(d->vm_event_monitor) ) { domain_pause(d); rc = vm_event_disable(d, &d->vm_event_monitor); @@ -728,7 +728,7 @@ int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec) break; case XEN_VM_EVENT_DISABLE: - if ( vm_event_check_ring(d->vm_event_share) ) + if ( vm_event_check(d->vm_event_share) ) { domain_pause(d); rc = vm_event_disable(d, &d->vm_event_share); diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index e886894..eec7686 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -1451,7 +1451,7 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag) /* Prevent device assign if mem paging or mem sharing have been * enabled for this domain */ if ( unlikely(d->arch.hvm.mem_sharing_enabled || - vm_event_check_ring(d->vm_event_paging) || + vm_event_check(d->vm_event_paging) || p2m_get_hostp2m(d)->global_logdirty) ) return -EXDEV; diff --git a/xen/include/xen/vm_event.h b/xen/include/xen/vm_event.h index 3cc2b20..381be0b 100644 --- a/xen/include/xen/vm_event.h +++ b/xen/include/xen/vm_event.h @@ -29,8 +29,8 @@ /* Clean up on domain destruction */ void vm_event_cleanup(struct domain *d); -/* Returns whether a ring has been set up */ -bool vm_event_check_ring(struct vm_event_domain *ved); +/* Returns whether the VM event domain has been set up */ +bool vm_event_check(struct vm_event_domain *ved); /* Returns 0 on success, -ENOSYS if there is no ring, -EBUSY if there is no * available space and the caller is a foreign domain. If the guest itself