From patchwork Thu Jun 8 17:12:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9776097 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 73C976034B for ; Thu, 8 Jun 2017 17:18:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 576DD2841C for ; Thu, 8 Jun 2017 17:18:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4BA6528438; Thu, 8 Jun 2017 17:18:32 +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 AE6D72841C for ; Thu, 8 Jun 2017 17:18:31 +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 1dJ12x-0006EH-P6; Thu, 08 Jun 2017 17:16:35 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dJ12w-0006B4-0x for xen-devel@lists.xenproject.org; Thu, 08 Jun 2017 17:16:34 +0000 Received: from [193.109.254.147] by server-5.bemta-6.messagelabs.com id A6/A0-03371-17689395; Thu, 08 Jun 2017 17:16:33 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmkeJIrShJLcpLzFFi42JxWrrBXrewzTL S4MZxZovvWyYzOTB6HP5whSWAMYo1My8pvyKBNeP++TdsBRM1Kw6efcPSwHhQpouRk0NCwF/i fv90FhCbTUBZ4mdnLxuILSKgJ9F04DkjiM0skCfR+fEjO4gtLBAhca5xJxOIzSKgIrHnRg9Yn FfAUuL8xresEDPlJXa1XQSzOYHiSz5PZ+5i5OAQErCQ6N2ZABIWElCQ6Jh+jAmiVVDi5MwnLB CrJCQOvnjBPIGRdxaS1CwkqQWMTKsY1YtTi8pSi3RN9JKKMtMzSnITM3N0DQ3M9HJTi4sT01N zEpOK9ZLzczcxAgOHAQh2MHZf9j/EKMnBpCTKq9hqGSnEl5SfUpmRWJwRX1Sak1p8iFGGg0NJ gtcbJCdYlJqeWpGWmQMMYZi0BAePkgjv2gagNG9xQWJucWY6ROoUo6KUOK8tSJ8ASCKjNA+uD RY3lxhlpYR5GYEOEeIpSC3KzSxBlX/FKM7BqCTMKwoyhSczrwRu+iugxUxAi5e8swBZXJKIkJ JqYFy8Up/1+L2jFduYMkzX85q9TNkz3dN01U23iEUP1xaVCAvcreg6d3bjxmUvV3b1phckyVr N2+e572yFec6ms9WTVarcZ//9fffeGU7VM/wiPkfW++yqz9938jHf/4DL60J+Ok8LW/qjJNIg 49q7Py6PQuUOWf6wSFc+xHjMp9/oJMuGv4Vn3HYpsRRnJBpqMRcVJwIA6Cv/jpYCAAA= X-Env-Sender: prvs=3259bf657=wei.liu2@citrix.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1496942179!94330782!6 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 25892 invoked from network); 8 Jun 2017 17:16:32 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-14.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 8 Jun 2017 17:16:32 -0000 X-IronPort-AV: E=Sophos;i="5.39,315,1493683200"; d="scan'208";a="435687706" From: Wei Liu To: Xen-devel Date: Thu, 8 Jun 2017 18:12:00 +0100 Message-ID: <20170608171203.20416-25-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 24/27] x86: move compat_show_guest_statck near its non-compat variant 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 And make it static, remove the declaration in header. Signed-off-by: Wei Liu Reviewed-by: Andrew Cooper --- xen/arch/x86/traps.c | 64 ++++++++++++++++++++++++++++++++++++++ xen/arch/x86/x86_64/compat/traps.c | 63 ------------------------------------- xen/include/asm-x86/processor.h | 3 -- 3 files changed, 64 insertions(+), 66 deletions(-) diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 287503cd56..0cedd5159b 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -186,6 +186,70 @@ static void show_code(const struct cpu_user_regs *regs) printk("\n"); } +static void compat_show_guest_stack(struct vcpu *v, + const struct cpu_user_regs *regs, + int debug_stack_lines) +{ + unsigned int i, *stack, addr, mask = STACK_SIZE; + + stack = (unsigned int *)(unsigned long)regs->esp; + printk("Guest stack trace from esp=%08lx:\n ", (unsigned long)stack); + + if ( !__compat_access_ok(v->domain, stack, sizeof(*stack)) ) + { + printk("Guest-inaccessible memory.\n"); + return; + } + + if ( v != current ) + { + struct vcpu *vcpu; + unsigned long mfn; + + ASSERT(guest_kernel_mode(v, regs)); + mfn = read_cr3() >> PAGE_SHIFT; + for_each_vcpu( v->domain, vcpu ) + if ( pagetable_get_pfn(vcpu->arch.guest_table) == mfn ) + break; + if ( !vcpu ) + { + stack = do_page_walk(v, (unsigned long)stack); + if ( (unsigned long)stack < PAGE_SIZE ) + { + printk("Inaccessible guest memory.\n"); + return; + } + mask = PAGE_SIZE; + } + } + + for ( i = 0; i < debug_stack_lines * 8; i++ ) + { + if ( (((long)stack - 1) ^ ((long)(stack + 1) - 1)) & mask ) + break; + if ( __get_user(addr, stack) ) + { + if ( i != 0 ) + printk("\n "); + printk("Fault while accessing guest memory."); + i = 1; + break; + } + if ( (i != 0) && ((i % 8) == 0) ) + printk("\n "); + printk(" %08x", addr); + stack++; + } + if ( mask == PAGE_SIZE ) + { + BUILD_BUG_ON(PAGE_SIZE == STACK_SIZE); + unmap_domain_page(stack); + } + if ( i == 0 ) + printk("Stack empty."); + printk("\n"); +} + static void show_guest_stack(struct vcpu *v, const struct cpu_user_regs *regs) { int i; diff --git a/xen/arch/x86/x86_64/compat/traps.c b/xen/arch/x86/x86_64/compat/traps.c index 6e146a62a7..18cd2c017c 100644 --- a/xen/arch/x86/x86_64/compat/traps.c +++ b/xen/arch/x86/x86_64/compat/traps.c @@ -3,69 +3,6 @@ #include #include -void compat_show_guest_stack(struct vcpu *v, const struct cpu_user_regs *regs, - int debug_stack_lines) -{ - unsigned int i, *stack, addr, mask = STACK_SIZE; - - stack = (unsigned int *)(unsigned long)regs->esp; - printk("Guest stack trace from esp=%08lx:\n ", (unsigned long)stack); - - if ( !__compat_access_ok(v->domain, stack, sizeof(*stack)) ) - { - printk("Guest-inaccessible memory.\n"); - return; - } - - if ( v != current ) - { - struct vcpu *vcpu; - unsigned long mfn; - - ASSERT(guest_kernel_mode(v, regs)); - mfn = read_cr3() >> PAGE_SHIFT; - for_each_vcpu( v->domain, vcpu ) - if ( pagetable_get_pfn(vcpu->arch.guest_table) == mfn ) - break; - if ( !vcpu ) - { - stack = do_page_walk(v, (unsigned long)stack); - if ( (unsigned long)stack < PAGE_SIZE ) - { - printk("Inaccessible guest memory.\n"); - return; - } - mask = PAGE_SIZE; - } - } - - for ( i = 0; i < debug_stack_lines * 8; i++ ) - { - if ( (((long)stack - 1) ^ ((long)(stack + 1) - 1)) & mask ) - break; - if ( __get_user(addr, stack) ) - { - if ( i != 0 ) - printk("\n "); - printk("Fault while accessing guest memory."); - i = 1; - break; - } - if ( (i != 0) && ((i % 8) == 0) ) - printk("\n "); - printk(" %08x", addr); - stack++; - } - if ( mask == PAGE_SIZE ) - { - BUILD_BUG_ON(PAGE_SIZE == STACK_SIZE); - unmap_domain_page(stack); - } - if ( i == 0 ) - printk("Stack empty."); - printk("\n"); -} - /* * Local variables: * mode: C diff --git a/xen/include/asm-x86/processor.h b/xen/include/asm-x86/processor.h index 6a335d3a61..5bf56b45e1 100644 --- a/xen/include/asm-x86/processor.h +++ b/xen/include/asm-x86/processor.h @@ -480,9 +480,6 @@ void show_execution_state(const struct cpu_user_regs *regs); void show_page_walk(unsigned long addr); void noreturn fatal_trap(const struct cpu_user_regs *regs, bool_t show_remote); -void compat_show_guest_stack(struct vcpu *v, - const struct cpu_user_regs *regs, int lines); - extern void mtrr_ap_init(void); extern void mtrr_bp_init(void);