From patchwork Tue Jul 5 18:37:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamas Lengyel X-Patchwork-Id: 9215079 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2000860752 for ; Tue, 5 Jul 2016 18:40:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1523028119 for ; Tue, 5 Jul 2016 18:40:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 09C1528179; Tue, 5 Jul 2016 18:40:22 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 769CE28119 for ; Tue, 5 Jul 2016 18:40:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKVEM-00015h-Co; Tue, 05 Jul 2016 18:37:58 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKVEL-00015a-8S for xen-devel@lists.xenproject.org; Tue, 05 Jul 2016 18:37:57 +0000 Received: from [85.158.139.211] by server-15.bemta-5.messagelabs.com id 2A/0D-17282-48EFB775; Tue, 05 Jul 2016 18:37:56 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprGIsWRWlGSWpSXmKPExsVyMfSas27Lv+p wg9/vGC2+b5nM5MDocfjDFZYAxijWzLyk/IoE1ow5jU3sBb8MK65/6GBuYNyq3sXIxSEkMI1R 4uuyQ6wgDovAGxaJFQcbWEAcCYF3LBJbF25j6mLkBHJiJK4tuM8CYVdJTFvfyQpiCwloShzcc IYZYtQkJoltbx6BJdgEjCSuXu1hA7FFBJQk7q2azARSxCywhlGid1IrI0hCWMBbYtnHDWBTWQ RUJQ5/fM4MYvMKeEpsnnOfFWKbnMTl6Q/YJjDyLWBkWMWoUZxaVJZapGtkqZdUlJmeUZKbmJm ja2hgqpebWlycmJ6ak5hUrJecn7uJERgu9QwMjDsYL2/xO8QoycGkJMrL8q06XIgvKT+lMiOx OCO+qDQntfgQowwHh5IE748/QDnBotT01Iq0zBxg4MKkJTh4lER4A/8CpXmLCxJzizPTIVKnG C05tvy+tpaJ49jcG0By29R7a5mEWPLy81KlxHnlQRoEQBoySvPgxsGi6xKjrJQwLyMDA4MQT0 FqUW5mCar8K0ZxDkYlYV5tkCk8mXklcFtfAR3EBHTQTxewg0oSEVJSDYyJAQy3zgor2ien3Zq 4ZUOvrOaZ4hdC874o3NVYteLb8VkHUmsfifxyyuhcu+B7veudkGsB6xReWkZW73oY+2F7UWNJ n8C6Bz7ZhTPcA75fPDn/o/nxhV/nL2uKWbjg8c2w39d/mrx4vpLlWuCML+92z4r5fTNs++6YP 4+2HVsfppIkGRq25f+HHUosxRmJhlrMRcWJANYJXN+pAgAA X-Env-Sender: tamas.lengyel@zentific.com X-Msg-Ref: server-7.tower-206.messagelabs.com!1467743875!48441443!1 X-Originating-IP: [209.85.214.67] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 23410 invoked from network); 5 Jul 2016 18:37:55 -0000 Received: from mail-it0-f67.google.com (HELO mail-it0-f67.google.com) (209.85.214.67) by server-7.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 5 Jul 2016 18:37:55 -0000 Received: by mail-it0-f67.google.com with SMTP id g4so7589681ith.2 for ; Tue, 05 Jul 2016 11:37:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zentific-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=n/5Ji7+05+Pjb7PMpPdU+J7zXldjDTcctzlw+xknaTw=; b=w8WQxbhAZyKp6ZNCvNkWBAaY+jSxRm1Kvejwfn7NY7+Z+4djkLGlQ+NKLuZVAsoduk p8I+kuQ/Y8PiDZJaPlM6lCZIWikXx2vRRGOE/9S4yZboYqBMh7N9GcXJPWNWUF24z0Fg d9/UpGgRGa7hx9dJkthiwbqaopJYD7qYja837qOcEtRBVFOkmXPFd4znxSyYP6q/3buw j+s5CKo9XLy7NXfME2G12J2MSon9ichq/O87ogrpN4d3dzOjzrbcPWtULLC024+pHJVK Rz/HG5DuUVOdq9HykdV0aUvDr24RKUIxHGoBzX5oG+Hq1GLfzcs4dcthwByQaQ2s5A2I jYcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=n/5Ji7+05+Pjb7PMpPdU+J7zXldjDTcctzlw+xknaTw=; b=fhOjpE5W3VS7xWfeaPyrZCz4DSQlX0s4nIWBFETArqhvqSYD7pMz8EoKTQHh2pajPk uFihqq7oAynOXDcX8ktX+4mfHQ4DV6+Xth/4wseWryoiIfLduMJgbe8vKEAtHuci2j2H ZYWwESJHDxm6eu6GRAcXX+YMJOsDLliqHcub9+BOP8w/6l8YycitGX74NDZANIOvR8sn xFCd2+8aM0CBkn4cExT5x72MaW5jp4l++9CS/tJPn1XcxqHC7AngZNxaDxi7YO4JqK00 prqCmH5/FcflzwXtcwtUNMFhV02WtyLdyAOSq1pdkriUe7VlipgM/N2gOmjbDrOaK6KQ crKw== X-Gm-Message-State: ALyK8tKzqNjt0JfMA39TbRY987Tqup3+tfvbgN1uCyoReLAqbZ9RNtpFRg7/vQn2Nr1K6A== X-Received: by 10.36.219.214 with SMTP id c205mr2995236itg.21.1467743874693; Tue, 05 Jul 2016 11:37:54 -0700 (PDT) Received: from l1.lan (c-73-14-35-59.hsd1.co.comcast.net. [73.14.35.59]) by smtp.gmail.com with ESMTPSA id o133sm2083760ioo.10.2016.07.05.11.37.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jul 2016 11:37:54 -0700 (PDT) From: Tamas K Lengyel To: xen-devel@lists.xenproject.org Date: Tue, 5 Jul 2016 12:37:46 -0600 Message-Id: <1467743871-9644-1-git-send-email-tamas.lengyel@zentific.com> X-Mailer: git-send-email 2.8.1 Cc: Tamas K Lengyel , Razvan Cojocaru , Jan Beulich , Andrew Cooper Subject: [Xen-devel] [PATCH v8 1/6] monitor: rename and relocate vm_event_monitor_traps X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The function vm_event_monitor_traps actually belongs in the monitor subsystem. As part of this patch we fix the sync input's type to bool_t to match how the callers use it. Signed-off-by: Tamas K Lengyel Acked-by: Razvan Cojocaru --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Razvan Cojocaru --- xen/arch/x86/hvm/monitor.c | 7 ++++--- xen/common/monitor.c | 44 +++++++++++++++++++++++++++++++++++++++++++- xen/common/vm_event.c | 45 --------------------------------------------- xen/include/xen/monitor.h | 6 +++++- xen/include/xen/vm_event.h | 6 ------ 5 files changed, 52 insertions(+), 56 deletions(-) diff --git a/xen/arch/x86/hvm/monitor.c b/xen/arch/x86/hvm/monitor.c index bbe5952..fb493bb 100644 --- a/xen/arch/x86/hvm/monitor.c +++ b/xen/arch/x86/hvm/monitor.c @@ -23,6 +23,7 @@ */ #include +#include #include #include #include @@ -48,7 +49,7 @@ bool_t hvm_monitor_cr(unsigned int index, unsigned long value, unsigned long old .u.write_ctrlreg.old_value = old }; - if ( vm_event_monitor_traps(curr, sync, &req) >= 0 ) + if ( monitor_traps(curr, sync, &req) >= 0 ) return 1; } @@ -68,7 +69,7 @@ void hvm_monitor_msr(unsigned int msr, uint64_t value) .u.mov_to_msr.value = value, }; - vm_event_monitor_traps(curr, 1, &req); + monitor_traps(curr, 1, &req); } } @@ -131,7 +132,7 @@ int hvm_monitor_debug(unsigned long rip, enum hvm_monitor_debug_type type, req.vcpu_id = curr->vcpu_id; - return vm_event_monitor_traps(curr, sync, &req); + return monitor_traps(curr, sync, &req); } /* diff --git a/xen/common/monitor.c b/xen/common/monitor.c index 436214a..5fce61e 100644 --- a/xen/common/monitor.c +++ b/xen/common/monitor.c @@ -19,12 +19,15 @@ * License along with this program; If not, see . */ +#include #include #include #include #include #include +#include #include +#include int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *mop) { @@ -85,6 +88,45 @@ int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *mop) return 0; } +int monitor_traps(struct vcpu *v, bool_t sync, vm_event_request_t *req) +{ + int rc; + struct domain *d = v->domain; + + rc = vm_event_claim_slot(d, &d->vm_event->monitor); + switch ( rc ) + { + case 0: + break; + case -ENOSYS: + /* + * If there was no ring to handle the event, then + * simply continue executing normally. + */ + return 0; + default: + return rc; + }; + + if ( sync ) + { + req->flags |= VM_EVENT_FLAG_VCPU_PAUSED; + vm_event_vcpu_pause(v); + rc = 1; + } + + if ( altp2m_active(d) ) + { + req->flags |= VM_EVENT_FLAG_ALTERNATE_P2M; + req->altp2m_idx = altp2m_vcpu_idx(v); + } + + vm_event_fill_regs(req); + vm_event_put_request(d, &d->vm_event->monitor, req); + + return rc; +} + void monitor_guest_request(void) { struct vcpu *curr = current; @@ -97,7 +139,7 @@ void monitor_guest_request(void) .vcpu_id = curr->vcpu_id, }; - vm_event_monitor_traps(curr, d->monitor.guest_request_sync, &req); + monitor_traps(curr, d->monitor.guest_request_sync, &req); } } diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index 17d2716..22bbfc1 100644 --- a/xen/common/vm_event.c +++ b/xen/common/vm_event.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -789,50 +788,6 @@ void vm_event_vcpu_unpause(struct vcpu *v) } /* - * Monitor vm-events - */ - -int vm_event_monitor_traps(struct vcpu *v, uint8_t sync, - vm_event_request_t *req) -{ - int rc; - struct domain *d = v->domain; - - rc = vm_event_claim_slot(d, &d->vm_event->monitor); - switch ( rc ) - { - case 0: - break; - case -ENOSYS: - /* - * If there was no ring to handle the event, then - * simply continue executing normally. - */ - return 0; - default: - return rc; - }; - - if ( sync ) - { - req->flags |= VM_EVENT_FLAG_VCPU_PAUSED; - vm_event_vcpu_pause(v); - rc = 1; - } - - if ( altp2m_active(d) ) - { - req->flags |= VM_EVENT_FLAG_ALTERNATE_P2M; - req->altp2m_idx = altp2m_vcpu_idx(v); - } - - vm_event_fill_regs(req); - vm_event_put_request(d, &d->vm_event->monitor, req); - - return rc; -} - -/* * Local variables: * mode: C * c-file-style: "BSD" diff --git a/xen/include/xen/monitor.h b/xen/include/xen/monitor.h index 204d5cc..2171d04 100644 --- a/xen/include/xen/monitor.h +++ b/xen/include/xen/monitor.h @@ -3,7 +3,7 @@ * * Common monitor_op domctl handler. * - * Copyright (c) 2015 Tamas K Lengyel (tamas@tklengyel.com) + * Copyright (c) 2015-2016 Tamas K Lengyel (tamas@tklengyel.com) * Copyright (c) 2016, Bitdefender S.R.L. * * This program is free software; you can redistribute it and/or @@ -22,10 +22,14 @@ #ifndef __XEN_MONITOR_H__ #define __XEN_MONITOR_H__ +#include + struct domain; struct xen_domctl_monitor_op; int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *op); void monitor_guest_request(void); +int monitor_traps(struct vcpu *v, bool_t sync, vm_event_request_t *req); + #endif /* __XEN_MONITOR_H__ */ diff --git a/xen/include/xen/vm_event.h b/xen/include/xen/vm_event.h index 89e6243..42bd9f6 100644 --- a/xen/include/xen/vm_event.h +++ b/xen/include/xen/vm_event.h @@ -75,12 +75,6 @@ int vm_event_domctl(struct domain *d, xen_domctl_vm_event_op_t *vec, void vm_event_vcpu_pause(struct vcpu *v); void vm_event_vcpu_unpause(struct vcpu *v); -/* - * Monitor vm-events - */ -int vm_event_monitor_traps(struct vcpu *v, uint8_t sync, - vm_event_request_t *req); - #endif /* __VM_EVENT_H__ */