From patchwork Wed May 4 14:51:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamas K Lengyel X-Patchwork-Id: 9015541 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A0C76BF29F for ; Wed, 4 May 2016 14:53:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D1BAE203B4 for ; Wed, 4 May 2016 14:53:46 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 9A181203AE for ; Wed, 4 May 2016 14:53:45 +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 1axy9D-00037p-T5; Wed, 04 May 2016 14:51:31 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1axy9C-000377-Bp for xen-devel@lists.xenproject.org; Wed, 04 May 2016 14:51:30 +0000 Received: from [85.158.139.211] by server-12.bemta-5.messagelabs.com id 27/08-02669-17C0A275; Wed, 04 May 2016 14:51:29 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrAIsWRWlGSWpSXmKPExsVyMfT+St1CHq1 wgxtqFt+3TGZyYPQ4/OEKSwBjFGtmXlJ+RQJrxoRbS5gKdlhV9E+/wdbAOE2/i5GLQ0hgJqPE /Y/LmUEcCYF+VomOdVeBHE4gJ0bi7d7t7BB2rcSjtSfBbCEBDYnbNxvZIbonMkmcaF0F1sAmo C3R9noXK4gtIqAkcW/VZCaQImaBn4wSN/+dZgNJCAt4STTN28AEYrMIqErs3HoTrJlXwFni56 W5UNvkJC5PfwBWzyngItF0oJkNYrOzxK65T5gnMPIvYGRYxahRnFpUllqka2igl1SUmZ5Rkpu YmQPkmerlphYXJ6an5iQmFesl5+duYgSGEAMQ7GBcM9X5EKMkB5OSKO+qL5rhQnxJ+SmVGYnF GfFFpTmpxYcYZTg4lCR4Z3FrhQsJFqWmp1akZeYAgxkmLcHBoyTC2wyS5i0uSMwtzkyHSJ1it OTY8vvaWiaOY3NvAMltU++tZRJiycvPS5US5+0DaRAAacgozYMbB4u4S4yyUsK8jEAHCvEUpB blZpagyr9iFOdgVBLmnQ0yhSczrwRu6yugg5iADno/VxPkoJJEhJRUA6OrU+dpj1MTHOTYRV8 USP9R8C/pXlB+c9byk9asB2dYbNnY4vy/+d3nKrmEG9Z3SxcxTTygIpuybc+pZTzNYpOKOXQc Tvpp73n6Z42x1sKjnA6XhJ8wPpivW1K399Cfxz7pm4U9jlfLXT33Ri9eQGrNnKdHmp2cn+gv5 2yYLCts+cYiyaw1bLsSS3FGoqEWc1FxIgAcCj/dswIAAA== X-Env-Sender: tamas.k.lengyel@gmail.com X-Msg-Ref: server-12.tower-206.messagelabs.com!1462373488!1529123!1 X-Originating-IP: [209.85.223.169] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27229 invoked from network); 4 May 2016 14:51:28 -0000 Received: from mail-io0-f169.google.com (HELO mail-io0-f169.google.com) (209.85.223.169) by server-12.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 4 May 2016 14:51:28 -0000 Received: by mail-io0-f169.google.com with SMTP id f89so56231734ioi.0 for ; Wed, 04 May 2016 07:51:28 -0700 (PDT) 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:in-reply-to :references; bh=0n0619AYP91VHV0v21A/gwJIk68Bk6MNEXKQ54E0cjQ=; b=mT+8BmP6k3OdKPVolBYQn7hU4O7U4odbVUnpErkkE7AQB4GQJtf/HnDaQ521vJ74Z8 qd1pzMyqQY6eAinZgNc/ZKSRMEC1OU/htXVix4171xKAN+O6CArQlFIAMC1MXAjvN5tJ hP9LDxvlTiwFMKOK4PPhUJajwmi4n88O+L4ywKv/JdLS5uozciY9z7J7r1NaIPIMC6yX V1bGsw9bHelaHde/R15mCz8jlDHFeA+pmA27QhWr37b7ZhYHAbHbf8PWcKXmpMSjQRjM iLipZzbRmcQzl1mlIadi11ILcg5E4/SFu8NkuY0YSQ/MwcbiwhFsJPaDdlR+TnFxHGJK BsTQ== X-Gm-Message-State: AOPr4FUoW0QR/DO6sEV03r9fwMGlA6Tpr6sVX4y4HM1a8E4IoeM5ekxiEUk+L3PLM4/GsA== X-Received: by 10.107.141.201 with SMTP id p192mr11790754iod.173.1462373487724; Wed, 04 May 2016 07:51:27 -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 u187sm1563597iod.3.2016.05.04.07.51.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 May 2016 07:51:26 -0700 (PDT) From: Tamas K Lengyel To: xen-devel@lists.xenproject.org Date: Wed, 4 May 2016 08:51:13 -0600 Message-Id: <1462373480-20206-2-git-send-email-tamas@tklengyel.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1462373480-20206-1-git-send-email-tamas@tklengyel.com> References: <1462373480-20206-1-git-send-email-tamas@tklengyel.com> Cc: Tamas K Lengyel , Razvan Cojocaru , Andrew Cooper , Julien Grall , Stefano Stabellini , Jan Beulich Subject: [Xen-devel] [PATCH v3 2/9] monitor: Don't call vm_event_fill_regs from common 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The prototype of vm_event_fill_regs will differ on x86 and ARM so in this patch we move components from common to arch-specific that use this function. As part of this patch we rename and relocate vm_event_monitor_guest_request as monitor_guest_request from vm_event to monitor. Signed-off-by: Tamas K Lengyel Acked-by: Razvan Cojocaru --- Cc: Stefano Stabellini Cc: Julien Grall Cc: Jan Beulich Cc: Andrew Cooper Cc: Razvan Cojocaru --- xen/arch/arm/Makefile | 1 + xen/arch/arm/hvm.c | 4 ++-- xen/arch/arm/monitor.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++ xen/arch/x86/hvm/event.c | 3 +++ xen/arch/x86/hvm/hvm.c | 3 ++- xen/arch/x86/monitor.c | 18 +++++++++++++++++ xen/common/vm_event.c | 17 ---------------- xen/include/xen/monitor.h | 1 + xen/include/xen/vm_event.h | 2 -- 9 files changed, 75 insertions(+), 22 deletions(-) create mode 100644 xen/arch/arm/monitor.c diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 0328b50..6e3dcff 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -40,6 +40,7 @@ obj-y += device.o obj-y += decode.o obj-y += processor.o obj-y += smc.o +obj-y += monitor.o #obj-bin-y += ....o diff --git a/xen/arch/arm/hvm.c b/xen/arch/arm/hvm.c index c01123a..d999bde 100644 --- a/xen/arch/arm/hvm.c +++ b/xen/arch/arm/hvm.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include @@ -75,7 +75,7 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg) case HVMOP_guest_request_vm_event: if ( guest_handle_is_null(arg) ) - vm_event_monitor_guest_request(); + monitor_guest_request(); else rc = -EINVAL; break; diff --git a/xen/arch/arm/monitor.c b/xen/arch/arm/monitor.c new file mode 100644 index 0000000..f957257 --- /dev/null +++ b/xen/arch/arm/monitor.c @@ -0,0 +1,48 @@ +/* + * arch/arm/monitor.c + * + * Arch-specific monitor_op domctl handler. + * + * 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 + * modify it under the terms of the GNU General Public + * License v2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; If not, see . + */ + +#include +#include + +void monitor_guest_request(void) +{ + struct vcpu *curr = current; + struct domain *d = curr->domain; + + if ( d->monitor.guest_request_enabled ) + { + vm_event_request_t req = { + .reason = VM_EVENT_REASON_GUEST_REQUEST, + .vcpu_id = curr->vcpu_id, + }; + + vm_event_monitor_traps(curr, d->monitor.guest_request_sync, &req); + } +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/x86/hvm/event.c b/xen/arch/x86/hvm/event.c index 56c5514..73d0a26 100644 --- a/xen/arch/x86/hvm/event.c +++ b/xen/arch/x86/hvm/event.c @@ -47,6 +47,7 @@ bool_t hvm_event_cr(unsigned int index, unsigned long value, unsigned long old) .u.write_ctrlreg.old_value = old }; + vm_event_fill_regs(&req); vm_event_monitor_traps(curr, sync, &req); return 1; } @@ -68,6 +69,7 @@ void hvm_event_msr(unsigned int msr, uint64_t value) .u.mov_to_msr.value = value, }; + vm_event_fill_regs(&req); vm_event_monitor_traps(curr, 1, &req); } } @@ -115,6 +117,7 @@ int hvm_event_breakpoint(unsigned long rip, } req.vcpu_id = curr->vcpu_id; + vm_event_fill_regs(&req); return vm_event_monitor_traps(curr, 1, &req); } diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 8cb6e9e..5d740f7 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -5695,7 +5696,7 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg) case HVMOP_guest_request_vm_event: if ( guest_handle_is_null(arg) ) - vm_event_monitor_guest_request(); + monitor_guest_request(); else rc = -EINVAL; break; diff --git a/xen/arch/x86/monitor.c b/xen/arch/x86/monitor.c index 621f91a..8598049 100644 --- a/xen/arch/x86/monitor.c +++ b/xen/arch/x86/monitor.c @@ -20,6 +20,7 @@ */ #include +#include #include int arch_monitor_domctl_event(struct domain *d, @@ -136,6 +137,23 @@ int arch_monitor_domctl_event(struct domain *d, return 0; } +void monitor_guest_request(void) +{ + struct vcpu *curr = current; + struct domain *d = curr->domain; + + if ( d->monitor.guest_request_enabled ) + { + vm_event_request_t req = { + .reason = VM_EVENT_REASON_GUEST_REQUEST, + .vcpu_id = curr->vcpu_id, + }; + + vm_event_fill_regs(&req); + vm_event_monitor_traps(curr, d->monitor.guest_request_sync, &req); + } +} + /* * Local variables: * mode: C diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index 2906407..31a8830 100644 --- a/xen/common/vm_event.c +++ b/xen/common/vm_event.c @@ -818,28 +818,11 @@ int vm_event_monitor_traps(struct vcpu *v, uint8_t sync, req->altp2m_idx = altp2m_vcpu_idx(v); } - vm_event_fill_regs(req); vm_event_put_request(d, &d->vm_event->monitor, req); return 1; } -void vm_event_monitor_guest_request(void) -{ - struct vcpu *curr = current; - struct domain *d = curr->domain; - - if ( d->monitor.guest_request_enabled ) - { - vm_event_request_t req = { - .reason = VM_EVENT_REASON_GUEST_REQUEST, - .vcpu_id = curr->vcpu_id, - }; - - vm_event_monitor_traps(curr, d->monitor.guest_request_sync, &req); - } -} - /* * Local variables: * mode: C diff --git a/xen/include/xen/monitor.h b/xen/include/xen/monitor.h index 7015e6d..204d5cc 100644 --- a/xen/include/xen/monitor.h +++ b/xen/include/xen/monitor.h @@ -26,5 +26,6 @@ struct domain; struct xen_domctl_monitor_op; int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *op); +void monitor_guest_request(void); #endif /* __XEN_MONITOR_H__ */ diff --git a/xen/include/xen/vm_event.h b/xen/include/xen/vm_event.h index beda9fe..89e6243 100644 --- a/xen/include/xen/vm_event.h +++ b/xen/include/xen/vm_event.h @@ -81,8 +81,6 @@ void vm_event_vcpu_unpause(struct vcpu *v); int vm_event_monitor_traps(struct vcpu *v, uint8_t sync, vm_event_request_t *req); -void vm_event_monitor_guest_request(void); - #endif /* __VM_EVENT_H__ */