From patchwork Fri Apr 5 09:33:57 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: 10887079 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 8418D922 for ; Fri, 5 Apr 2019 09:36:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E5EA28A53 for ; Fri, 5 Apr 2019 09:36:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62E0028B0C; Fri, 5 Apr 2019 09:36:08 +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 EB9E828A53 for ; Fri, 5 Apr 2019 09:36:07 +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 1hCLEa-0007ei-AR; Fri, 05 Apr 2019 09:34:04 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hCLEZ-0007ed-9R for xen-devel@lists.xenproject.org; Fri, 05 Apr 2019 09:34:03 +0000 X-Inumbo-ID: f1794403-5785-11e9-92d7-bc764e045a96 Received: from mx01.bbu.dsd.mx.bitdefender.com (unknown [91.199.104.161]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id f1794403-5785-11e9-92d7-bc764e045a96; Fri, 05 Apr 2019 09:34:01 +0000 (UTC) Received: from smtp.bitdefender.com (smtp01.buh.bitdefender.com [10.17.80.75]) by mx01.bbu.dsd.mx.bitdefender.com (Postfix) with ESMTPS id 25175307503D; Fri, 5 Apr 2019 12:34:00 +0300 (EEST) Received: from bitdefender.com (unknown [195.189.155.70]) by smtp.bitdefender.com (Postfix) with ESMTPSA id 0F47E306E477; Fri, 5 Apr 2019 12:34:00 +0300 (EEST) From: Petre Pircalabu To: xen-devel@lists.xenproject.org Date: Fri, 5 Apr 2019 12:33:57 +0300 Message-Id: <06086a6f2400b372993d03ece48e65bfbe88134e.1554456553.git.ppircalabu@bitdefender.com> X-Mailer: git-send-email 2.7.4 Subject: [Xen-devel] [PATCH] vm_event: Fix XEN_VM_EVENT_RESUME domctl 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 , Razvan Cojocaru MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Make XEN_VM_EVENT_RESUME return 0 in case of success, instead of -EINVAL. Remove vm_event_resume form vm_event.h header and set the function's visibility to static as is used only in vm_event.c. Move the vm_event_check_ring test inside vm_event_resume in order to simplify the code. Signed-off-by: Petre Pircalabu Acked-by: Razvan Cojocaru --- xen/common/vm_event.c | 37 ++++++++++++------------------------- xen/include/xen/vm_event.h | 2 -- 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index 19c983c..746b040 100644 --- a/xen/common/vm_event.c +++ b/xen/common/vm_event.c @@ -366,7 +366,7 @@ int vm_event_get_response(struct domain *d, struct vm_event_domain *ved, * Note: responses are handled the same way regardless of which ring they * arrive on. */ -void vm_event_resume(struct domain *d, struct vm_event_domain *ved) +static int vm_event_resume(struct domain *d, struct vm_event_domain *ved) { vm_event_response_t rsp; @@ -380,6 +380,9 @@ void vm_event_resume(struct domain *d, struct vm_event_domain *ved) */ ASSERT(d != current->domain); + if ( unlikely(!vm_event_check_ring(ved)) ) + return -ENODEV; + /* Pull all responses off the ring. */ while ( vm_event_get_response(d, ved, &rsp) ) { @@ -443,6 +446,8 @@ void vm_event_resume(struct domain *d, struct vm_event_domain *ved) vm_event_vcpu_unpause(v); } } + + return 0; } void vm_event_cancel_slot(struct domain *d, struct vm_event_domain *ved) @@ -529,30 +534,21 @@ int __vm_event_claim_slot(struct domain *d, struct vm_event_domain *ved, /* Registered with Xen-bound event channel for incoming notifications. */ static void mem_paging_notification(struct vcpu *v, unsigned int port) { - struct domain *domain = v->domain; - - if ( likely(vm_event_check_ring(domain->vm_event_paging)) ) - vm_event_resume(domain, domain->vm_event_paging); + (void)vm_event_resume(v->domain, v->domain->vm_event_paging); } #endif /* Registered with Xen-bound event channel for incoming notifications. */ static void monitor_notification(struct vcpu *v, unsigned int port) { - struct domain *domain = v->domain; - - if ( likely(vm_event_check_ring(domain->vm_event_monitor)) ) - vm_event_resume(domain, domain->vm_event_monitor); + (void)vm_event_resume(v->domain, v->domain->vm_event_monitor); } #ifdef CONFIG_HAS_MEM_SHARING /* Registered with Xen-bound event channel for incoming notifications. */ static void mem_sharing_notification(struct vcpu *v, unsigned int port) { - struct domain *domain = v->domain; - - if ( likely(vm_event_check_ring(domain->vm_event_share)) ) - vm_event_resume(domain, domain->vm_event_share); + (void)vm_event_resume(v->domain, v->domain->vm_event_share); } #endif @@ -676,10 +672,7 @@ int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec, break; case XEN_VM_EVENT_RESUME: - if ( vm_event_check_ring(d->vm_event_paging) ) - vm_event_resume(d, d->vm_event_paging); - else - rc = -ENODEV; + rc = vm_event_resume(d, d->vm_event_paging); break; default: @@ -717,10 +710,7 @@ int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec, break; case XEN_VM_EVENT_RESUME: - if ( vm_event_check_ring(d->vm_event_monitor) ) - vm_event_resume(d, d->vm_event_monitor); - else - rc = -ENODEV; + rc = vm_event_resume(d, d->vm_event_monitor); break; default: @@ -764,10 +754,7 @@ int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec, break; case XEN_VM_EVENT_RESUME: - if ( vm_event_check_ring(d->vm_event_share) ) - vm_event_resume(d, d->vm_event_share); - else - rc = -ENODEV; + rc = vm_event_resume(d, d->vm_event_share); break; default: diff --git a/xen/include/xen/vm_event.h b/xen/include/xen/vm_event.h index 5302ee5..53af2d5 100644 --- a/xen/include/xen/vm_event.h +++ b/xen/include/xen/vm_event.h @@ -67,8 +67,6 @@ void vm_event_put_request(struct domain *d, struct vm_event_domain *ved, int vm_event_get_response(struct domain *d, struct vm_event_domain *ved, vm_event_response_t *rsp); -void vm_event_resume(struct domain *d, struct vm_event_domain *ved); - int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec, XEN_GUEST_HANDLE_PARAM(void) u_domctl);