From patchwork Thu Jun 8 17:11:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9776077 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 A00A960350 for ; Thu, 8 Jun 2017 17:14:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 868C423B24 for ; Thu, 8 Jun 2017 17:14:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B08A28438; Thu, 8 Jun 2017 17:14:26 +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 1491C23B24 for ; Thu, 8 Jun 2017 17:14:26 +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-0004rs-PQ; 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-0004qv-UO for xen-devel@lists.xenproject.org; Thu, 08 Jun 2017 17:12:11 +0000 Received: from [85.158.137.68] by server-2.bemta-3.messagelabs.com id 3F/9E-26106-A6589395; Thu, 08 Jun 2017 17:12:10 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprAIsWRWlGSWpSXmKPExsXitHRDpG5mq2W kwdT7chbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bGS4fZC74pVLRseM/YwHhFsouRk0NCwF/i yboFbCA2m4CyxM/OXjBbREBPounAc0YQm1kgT6Lz40d2EFtYIEDi66kXYDUsAioS+5t3M4PYv AIWEqv/7WOFmCkvsavtIpjNKWApseTzdKAaDg4hoJrenQkgYSEBBYmO6ceYIFoFJU7OfMICsU pC4uCLF8wTGHlnIUnNQpJawMi0ilGjOLWoLLVI19BEL6koMz2jJDcxM0fX0MBYLze1uDgxPTU nMalYLzk/dxMjMHQYgGAH44rtnocYJTmYlER5FQUsI4X4kvJTKjMSizPii0pzUosPMcpwcChJ 8OY3A+UEi1LTUyvSMnOAQQyTluDgURLhXdsAlOYtLkjMLc5Mh0idYtTlWNCz4QuTEEtefl6ql DhvQAtQkQBIUUZpHtwIWERdYpSVEuZlBDpKiKcgtSg3swRV/hWjOAejkjCvMcglPJl5JXCbXg EdwQR0xJJ3FiBHlCQipKQaGNdmrzyvuznkUzerwjm+uAvqTDxXj35gqdlkPiUsLFXv+/UrH10 n6F+u1lwaO0Xs6Gmrb49VCpzyLVhmirk7nfR8ktIZ7H8twfRZuLTp+hdlFy7GF510zNNZofni 2fH2nc6mx093CTxKUp5i7rBzPpuhUm79f43Hj+qaONrF0s9M/D3bLvyonhJLcUaioRZzUXEiA GJVF1ajAgAA X-Env-Sender: prvs=3259bf657=wei.liu2@citrix.com X-Msg-Ref: server-2.tower-31.messagelabs.com!1496941926!93062974!2 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 39488 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-2.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="427128898" From: Wei Liu To: Xen-devel Date: Thu, 8 Jun 2017 18:11:44 +0100 Message-ID: <20170608171203.20416-9-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 08/27] x86: move some misc PV hypercalls to misc-hypercalls.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 Reviewed-by: Andrew Cooper --- xen/arch/x86/pv/Makefile | 1 + xen/arch/x86/pv/misc-hypercalls.c | 78 +++++++++++++++++++++++++++++++++++++++ xen/arch/x86/traps.c | 44 ---------------------- 3 files changed, 79 insertions(+), 44 deletions(-) create mode 100644 xen/arch/x86/pv/misc-hypercalls.c diff --git a/xen/arch/x86/pv/Makefile b/xen/arch/x86/pv/Makefile index 42ca64dc9e..939ea60bea 100644 --- a/xen/arch/x86/pv/Makefile +++ b/xen/arch/x86/pv/Makefile @@ -8,3 +8,4 @@ obj-y += emul-gate-op.o obj-y += emul-inv-op.o obj-y += emul-priv-op.o obj-bin-y += gpr_switch.o +obj-y += misc-hypercalls.o diff --git a/xen/arch/x86/pv/misc-hypercalls.c b/xen/arch/x86/pv/misc-hypercalls.c new file mode 100644 index 0000000000..5862130697 --- /dev/null +++ b/xen/arch/x86/pv/misc-hypercalls.c @@ -0,0 +1,78 @@ +/****************************************************************************** + * arch/x86/pv/misc-hypercalls.c + * + * Misc hypercall handlers + * + * Modifications to Linux original are copyright (c) 2002-2004, K A Fraser + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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 + +long do_set_debugreg(int reg, unsigned long value) +{ + return set_debugreg(current, reg, value); +} + +unsigned long do_get_debugreg(int reg) +{ + struct vcpu *curr = current; + + switch ( reg ) + { + case 0 ... 3: + case 6: + return curr->arch.debugreg[reg]; + case 7: + return (curr->arch.debugreg[7] | + curr->arch.debugreg[5]); + case 4 ... 5: + return ((curr->arch.pv_vcpu.ctrlreg[4] & X86_CR4_DE) ? + curr->arch.debugreg[reg + 2] : 0); + } + + return -EINVAL; +} + +long do_fpu_taskswitch(int set) +{ + struct vcpu *v = current; + + if ( set ) + { + v->arch.pv_vcpu.ctrlreg[0] |= X86_CR0_TS; + stts(); + } + else + { + v->arch.pv_vcpu.ctrlreg[0] &= ~X86_CR0_TS; + if ( v->fpu_dirtied ) + clts(); + } + + return 0; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 440aad182b..6923c2ef01 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -1488,25 +1488,6 @@ void __init do_early_page_fault(struct cpu_user_regs *regs) } } -long do_fpu_taskswitch(int set) -{ - struct vcpu *v = current; - - if ( set ) - { - v->arch.pv_vcpu.ctrlreg[0] |= X86_CR0_TS; - stts(); - } - else - { - v->arch.pv_vcpu.ctrlreg[0] &= ~X86_CR0_TS; - if ( v->fpu_dirtied ) - clts(); - } - - return 0; -} - void do_general_protection(struct cpu_user_regs *regs) { struct vcpu *v = current; @@ -2249,31 +2230,6 @@ long set_debugreg(struct vcpu *v, unsigned int reg, unsigned long value) return 0; } -long do_set_debugreg(int reg, unsigned long value) -{ - return set_debugreg(current, reg, value); -} - -unsigned long do_get_debugreg(int reg) -{ - struct vcpu *curr = current; - - switch ( reg ) - { - case 0 ... 3: - case 6: - return curr->arch.debugreg[reg]; - case 7: - return (curr->arch.debugreg[7] | - curr->arch.debugreg[5]); - case 4 ... 5: - return ((curr->arch.pv_vcpu.ctrlreg[4] & X86_CR4_DE) ? - curr->arch.debugreg[reg + 2] : 0); - } - - return -EINVAL; -} - void asm_domain_crash_synchronous(unsigned long addr) { /*