From patchwork Mon Jun 26 16:28:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9810061 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 B198960209 for ; Mon, 26 Jun 2017 16:31:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE7FC280FC for ; Mon, 26 Jun 2017 16:31:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3031285C9; Mon, 26 Jun 2017 16:31:37 +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.2 required=2.0 tests=BAYES_00, 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 AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 462FF280FC for ; Mon, 26 Jun 2017 16:31:37 +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 1dPWt5-0005Cc-R6; Mon, 26 Jun 2017 16:29:19 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dPWt4-00059F-ID for xen-devel@lists.xenproject.org; Mon, 26 Jun 2017 16:29:18 +0000 Received: from [85.158.137.68] by server-6.bemta-3.messagelabs.com id 8F/AA-19409-E5631595; Mon, 26 Jun 2017 16:29:18 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeJIrShJLcpLzFFi42JxWrrBXjfaLDD S4OkXVovvWyYzOTB6HP5whSWAMYo1My8pvyKBNeNU12vGgk6ZigNbfRoYr4h0MXJySAj4S5xY +5QNxGYTUJb42dkLZosI6Ek0HXjOCGIzC+RJnF29iBXEFhZwk5h6bj1LFyMHB4uAqsTtTdYgY V4BM4kFa1cxQYyUl9jVdhGsnFPAXKJh9XQwWwioZldvHxuErSDRMf0YE0SvoMTJmU9YIFZJSB x88YJ5AiPvLCSpWUhSCxiZVjFqFKcWlaUW6Roa6yUVZaZnlOQmZuboGhoY6+WmFhcnpqfmJCY V6yXn525iBAYOAxDsYNy23fMQoyQHk5IoL8eTgEghvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErze poGRQoJFqempFWmZOcAQhklLcPAoifB2aQKleYsLEnOLM9MhUqcYdTkW9Gz4wiTEkpeflyolz msDMkMApCijNA9uBCyeLjHKSgnzMgIdJcRTkFqUm1mCKv+KUZyDUUmY1xNkCk9mXgncpldARz ABHcEyLwDkiJJEhJRUAyPXEoMfX26dXst0UfucVlNl1jdvbiNNI511CbYSt7Ykvp3y6sV5/kW dNlIL287f37KDwa1SrNpNpLz8x++ZbG1CPbE2s/dEvLcN+8IZZlvx8nzv5TuMV7+L3vXj5YuI OS0iKW3i9eNv5scYKWnDLxrWldxMgmu4zmUZmBduSv9o9X3F13XL9ymxFGckGmoxFxUnAgCXD T/BogIAAA== X-Env-Sender: prvs=343741041=wei.liu2@citrix.com X-Msg-Ref: server-16.tower-31.messagelabs.com!1498494551!99840466!2 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8552 invoked from network); 26 Jun 2017 16:29:14 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-16.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 26 Jun 2017 16:29:14 -0000 X-IronPort-AV: E=Sophos;i="5.39,396,1493683200"; d="scan'208";a="437865421" From: Wei Liu To: Xen-devel Date: Mon, 26 Jun 2017 17:28:32 +0100 Message-ID: <20170626162842.482-4-wei.liu2@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170626162842.482-1-wei.liu2@citrix.com> References: <20170626162842.482-1-wei.liu2@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Wei Liu , Jan Beulich Subject: [Xen-devel] [PATCH v5 03/13] x86: move do_set_trap_table to pv/callback.c 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP That hypercall is used to set guest callbacks for traps. Signed-off-by: Wei Liu Reviewed-by: Andrew Cooper --- xen/arch/x86/pv/callback.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++ xen/arch/x86/traps.c | 50 ---------------------------------------------- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/xen/arch/x86/pv/callback.c b/xen/arch/x86/pv/callback.c index d811f48110..0d7641df43 100644 --- a/xen/arch/x86/pv/callback.c +++ b/xen/arch/x86/pv/callback.c @@ -16,6 +16,7 @@ * License along with this program; If not, see . */ +#include #include #include #include @@ -314,6 +315,55 @@ long compat_set_callbacks(unsigned long event_selector, return 0; } +long do_set_trap_table(XEN_GUEST_HANDLE_PARAM(const_trap_info_t) traps) +{ + struct trap_info cur; + struct vcpu *curr = current; + struct trap_info *dst = curr->arch.pv_vcpu.trap_ctxt; + long rc = 0; + + /* If no table is presented then clear the entire virtual IDT. */ + if ( guest_handle_is_null(traps) ) + { + memset(dst, 0, NR_VECTORS * sizeof(*dst)); + init_int80_direct_trap(curr); + return 0; + } + + for ( ; ; ) + { + if ( copy_from_guest(&cur, traps, 1) ) + { + rc = -EFAULT; + break; + } + + if ( cur.address == 0 ) + break; + + if ( !is_canonical_address(cur.address) ) + return -EINVAL; + + fixup_guest_code_selector(curr->domain, cur.cs); + + memcpy(&dst[cur.vector], &cur, sizeof(cur)); + + if ( cur.vector == 0x80 ) + init_int80_direct_trap(curr); + + guest_handle_add_offset(traps, 1); + + if ( hypercall_preempt_check() ) + { + rc = hypercall_create_continuation( + __HYPERVISOR_set_trap_table, "h", traps); + break; + } + } + + return rc; +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 8caa9255ed..c43f3f1095 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -2073,56 +2073,6 @@ int send_guest_trap(struct domain *d, uint16_t vcpuid, unsigned int trap_nr) return -EIO; } - -long do_set_trap_table(XEN_GUEST_HANDLE_PARAM(const_trap_info_t) traps) -{ - struct trap_info cur; - struct vcpu *curr = current; - struct trap_info *dst = curr->arch.pv_vcpu.trap_ctxt; - long rc = 0; - - /* If no table is presented then clear the entire virtual IDT. */ - if ( guest_handle_is_null(traps) ) - { - memset(dst, 0, NR_VECTORS * sizeof(*dst)); - init_int80_direct_trap(curr); - return 0; - } - - for ( ; ; ) - { - if ( copy_from_guest(&cur, traps, 1) ) - { - rc = -EFAULT; - break; - } - - if ( cur.address == 0 ) - break; - - if ( !is_canonical_address(cur.address) ) - return -EINVAL; - - fixup_guest_code_selector(curr->domain, cur.cs); - - memcpy(&dst[cur.vector], &cur, sizeof(cur)); - - if ( cur.vector == 0x80 ) - init_int80_direct_trap(curr); - - guest_handle_add_offset(traps, 1); - - if ( hypercall_preempt_check() ) - { - rc = hypercall_create_continuation( - __HYPERVISOR_set_trap_table, "h", traps); - break; - } - } - - return rc; -} - void activate_debugregs(const struct vcpu *curr) { ASSERT(curr == current);