From patchwork Thu Jun 8 17:11:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9776075 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 5129C60350 for ; Thu, 8 Jun 2017 17:14:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36E8423B24 for ; Thu, 8 Jun 2017 17:14:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A81B27165; Thu, 8 Jun 2017 17:14:23 +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 BC1E728438 for ; Thu, 8 Jun 2017 17:14:22 +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 1dJ0yi-0004ra-IV; Thu, 08 Jun 2017 17:12:12 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dJ0yg-0004qo-NL for xen-devel@lists.xenproject.org; Thu, 08 Jun 2017 17:12:10 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 50/80-11537-96589395; Thu, 08 Jun 2017 17:12:09 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphkeJIrShJLcpLzFFi42JxWrohUjez1TL S4OUOcYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPzhzOMBaukK2ac+MzewNgh0sXIySEh4C+x r2ELK4jNJqAs8bOzlw3EFhHQk2g68JwRxGYWyJPo/PiRHcQWFnCWOPLhDVicRUBFYtPhbrBeX gELid2PetghZspL7Gq7CBbnFLCUWPJ5OnMXIweHEFBN784EkLCQgIJEx/RjTBCtghInZz5hgV glIXHwxQvmCYy8s5CkZiFJLWBkWsWoUZxaVJZapGtorpdUlJmeUZKbmJmja2hgrJebWlycmJ6 ak5hUrJecn7uJERg6DECwg/Hlac9DjJIcTEqivIrAkBLiS8pPqcxILM6ILyrNSS0+xCjDwaEk wfu5GSgnWJSanlqRlpkDDGKYtAQHj5II79oGoDRvcUFibnFmOkTqFKOilDjvGZA+AZBERmkeX Bssci4xykoJ8zICHSLEU5BalJtZgir/ilGcg1FJmDe5BWgKT2ZeCdz0V0CLmYAWL3lnAbK4JB EhJdXAuKsskX9N0+tlSyUlTlvelC8vfN/Ax5nzP+fuhbvTLzVnJxVZfKn6FN3wUfbEh2SeSOa nPN5S0/ju506q3Pa8OdfV/EnHV/dYj2PzVFSKpW90H8no6ldz2zq//3281pJ/CrNmzXjQvUpY yNtql1nLYgcmX/53ypJVLF8XOP2K+Vposeq9UttZJZbijERDLeai4kQASMU2j5cCAAA= X-Env-Sender: prvs=3259bf657=wei.liu2@citrix.com X-Msg-Ref: server-6.tower-31.messagelabs.com!1496941927!66198067!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28634 invoked from network); 8 Jun 2017 17:12:09 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-6.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 8 Jun 2017 17:12:09 -0000 X-IronPort-AV: E=Sophos;i="5.39,315,1493683200"; d="scan'208";a="427128897" From: Wei Liu To: Xen-devel Date: Thu, 8 Jun 2017 18:11:43 +0100 Message-ID: <20170608171203.20416-8-wei.liu2@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170608171203.20416-1-wei.liu2@citrix.com> References: <20170608171203.20416-1-wei.liu2@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Wei Liu , Jan Beulich Subject: [Xen-devel] [PATCH v4 07/27] x86: move do_set_trap_table to pv/traps.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 Signed-off-by: Wei Liu --- xen/arch/x86/pv/traps.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ xen/arch/x86/traps.c | 49 ---------------------------------------------- 2 files changed, 52 insertions(+), 49 deletions(-) diff --git a/xen/arch/x86/pv/traps.c b/xen/arch/x86/pv/traps.c index 51125a8d86..6e69f2ad58 100644 --- a/xen/arch/x86/pv/traps.c +++ b/xen/arch/x86/pv/traps.c @@ -19,7 +19,10 @@ * Copyright (c) 2017 Citrix Systems Ltd. */ +#include +#include #include +#include #include @@ -31,6 +34,55 @@ void do_entry_int82(struct cpu_user_regs *regs) pv_hypercall(regs); } +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 b5642b0f9a..440aad182b 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -2126,55 +2126,6 @@ int send_guest_trap(struct domain *d, uint16_t vcpuid, unsigned int trap_nr) } -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);