From patchwork Thu Sep 14 12:58:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9953109 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 105C960317 for ; Thu, 14 Sep 2017 13:31:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0ADE128CD3 for ; Thu, 14 Sep 2017 13:31:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F21F728E1A; Thu, 14 Sep 2017 13:31:10 +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 795A428CD3 for ; Thu, 14 Sep 2017 13:31:10 +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 1dsUCY-0008Gt-Pc; Thu, 14 Sep 2017 13:29:06 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsUCX-0008Ea-Bf for xen-devel@lists.xenproject.org; Thu, 14 Sep 2017 13:29:05 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id A1/34-03616-0248AB95; Thu, 14 Sep 2017 13:29:04 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeJIrShJLcpLzFFi42JxWrrBXle+ZVe kwYbJshbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bp54/YC85JVlz4xt7A+F+4i5GTQ0LAX+Jw zxNGEJtNQFniZ2cvG4gtIqAn0XTgOVCci4NZYA6jxNS5XUAOB4ewQIDE4k0JIDUsAqoSv/5tZ wYJ8wpYSlya6QUxUl5iV9tFVhCbEyjc9eElE4gtJGAh0XtpPzuErSDRMf0YWJxXQFDi5MwnLC A2s4CExMEXL5gnMPLOQpKahSS1gJFpFaNGcWpRWWqRrqGZXlJRZnpGSW5iZo6uoYGZXm5qcXF iempOYlKxXnJ+7iZGYOAwAMEOxvsbAw4xSnIwKYny7tXdGSnEl5SfUpmRWJwRX1Sak1p8iFGG g0NJgvds065IIcGi1PTUirTMHGAIw6QlOHiURHjvg6R5iwsSc4sz0yFSpxh1OTpu3v3DJMSSl 5+XKiXOq90MVCQAUpRRmgc3AhZPlxhlpYR5GYGOEuIpSC3KzSxBlX/FKM7BqCTMexlkFU9mXg ncpldARzABHXHm9A6QI0oSEVJSDYziRjdWH/IMLZnss6F6tXv/Fet1bmWPH/fL1oTUPw1U77v IFcadnSf/9LPlRV/miuiQbVf77StWKmguXH7YNMG9t0NrY6Gxx93Z7ip1zaFbfyXO3lj5a6de X/+tyFPhDde3TNBotUlprLNIPnFi8ym2m4de/lux3Durf625nkGw+BqfiuYnq5VYijMSDbWYi 4oTAXHG3DmiAgAA X-Env-Sender: prvs=423b67c62=wei.liu2@citrix.com X-Msg-Ref: server-13.tower-27.messagelabs.com!1505395741!107245321!1 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.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 15025 invoked from network); 14 Sep 2017 13:29:03 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-13.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 14 Sep 2017 13:29:03 -0000 X-IronPort-AV: E=Sophos;i="5.42,393,1500940800"; d="scan'208";a="447841026" From: Wei Liu To: Xen-devel Date: Thu, 14 Sep 2017 13:58:40 +0100 Message-ID: <20170914125852.22129-12-wei.liu2@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170914125852.22129-1-wei.liu2@citrix.com> References: <20170914125852.22129-1-wei.liu2@citrix.com> MIME-Version: 1.0 Cc: George Dunlap , Andrew Cooper , Wei Liu , Jan Beulich Subject: [Xen-devel] [PATCH v5 11/23] x86/mm: move compat descriptor table manipulation code 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 Move them alongside the non-compat variants. Change u{32,64} to uint{32,64}_t while moving. Signed-off-by: Wei Liu Acked-by: Jan Beulich --- xen/arch/x86/pv/descriptor-tables.c | 40 +++++++++++++++++++++++++++++++++++++ xen/arch/x86/x86_64/compat/mm.c | 39 ------------------------------------ 2 files changed, 40 insertions(+), 39 deletions(-) diff --git a/xen/arch/x86/pv/descriptor-tables.c b/xen/arch/x86/pv/descriptor-tables.c index 04fb37f2ce..52ffaa88d8 100644 --- a/xen/arch/x86/pv/descriptor-tables.c +++ b/xen/arch/x86/pv/descriptor-tables.c @@ -181,6 +181,46 @@ long do_update_descriptor(uint64_t pa, uint64_t desc) return ret; } +int compat_set_gdt(XEN_GUEST_HANDLE_PARAM(uint) frame_list, unsigned int entries) +{ + unsigned int i, nr_pages = (entries + 511) / 512; + unsigned long frames[16]; + long ret; + + /* Rechecked in set_gdt, but ensures a sane limit for copy_from_user(). */ + if ( entries > FIRST_RESERVED_GDT_ENTRY ) + return -EINVAL; + + if ( !guest_handle_okay(frame_list, nr_pages) ) + return -EFAULT; + + for ( i = 0; i < nr_pages; ++i ) + { + unsigned int frame; + + if ( __copy_from_guest(&frame, frame_list, 1) ) + return -EFAULT; + frames[i] = frame; + guest_handle_add_offset(frame_list, 1); + } + + domain_lock(current->domain); + + if ( (ret = pv_set_gdt(current, frames, entries)) == 0 ) + flush_tlb_local(); + + domain_unlock(current->domain); + + return ret; +} + +int compat_update_descriptor(uint32_t pa_lo, uint32_t pa_hi, + uint32_t desc_lo, uint32_t desc_hi) +{ + return do_update_descriptor(pa_lo | ((uint64_t)pa_hi << 32), + desc_lo | ((uint64_t)desc_hi << 32)); +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/x86_64/compat/mm.c b/xen/arch/x86/x86_64/compat/mm.c index 16ea2a80df..c2aa6f2fdb 100644 --- a/xen/arch/x86/x86_64/compat/mm.c +++ b/xen/arch/x86/x86_64/compat/mm.c @@ -8,45 +8,6 @@ #include -int compat_set_gdt(XEN_GUEST_HANDLE_PARAM(uint) frame_list, unsigned int entries) -{ - unsigned int i, nr_pages = (entries + 511) / 512; - unsigned long frames[16]; - long ret; - - /* Rechecked in set_gdt, but ensures a sane limit for copy_from_user(). */ - if ( entries > FIRST_RESERVED_GDT_ENTRY ) - return -EINVAL; - - if ( !guest_handle_okay(frame_list, nr_pages) ) - return -EFAULT; - - for ( i = 0; i < nr_pages; ++i ) - { - unsigned int frame; - - if ( __copy_from_guest(&frame, frame_list, 1) ) - return -EFAULT; - frames[i] = frame; - guest_handle_add_offset(frame_list, 1); - } - - domain_lock(current->domain); - - if ( (ret = pv_set_gdt(current, frames, entries)) == 0 ) - flush_tlb_local(); - - domain_unlock(current->domain); - - return ret; -} - -int compat_update_descriptor(u32 pa_lo, u32 pa_hi, u32 desc_lo, u32 desc_hi) -{ - return do_update_descriptor(pa_lo | ((u64)pa_hi << 32), - desc_lo | ((u64)desc_hi << 32)); -} - int compat_arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) { struct compat_machphys_mfn_list xmml;