From patchwork Fri Aug 9 15:01:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 11086725 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2A0A01399 for ; Fri, 9 Aug 2019 15:02:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14EAB1FF83 for ; Fri, 9 Aug 2019 15:02:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 092C11FFE5; Fri, 9 Aug 2019 15:02:47 +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=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 861731FFD9 for ; Fri, 9 Aug 2019 15:02:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hw6Os-0002sX-6m; Fri, 09 Aug 2019 15:01:50 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hw6Oq-0002rS-5W for xen-devel@lists.xenproject.org; Fri, 09 Aug 2019 15:01:48 +0000 X-Inumbo-ID: 9b2503ea-bab6-11e9-8980-bc764e045a96 Received: from merlin.infradead.org (unknown [2001:8b0:10b:1231::1]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 9b2503ea-bab6-11e9-8980-bc764e045a96; Fri, 09 Aug 2019 15:01:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Mime-Version:Content-Type:References: In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=2ylRDBo5Wm9hu5UIGGEIPr3Pa2sK3yJqJMTvJtMFJxM=; b=nuDoPZx+IW28GMdz6nX8tjcAi vpodlAu1wz2h94euHCoEMjnF/g10+zyASkfRINGhIf4DGMOv8sqYLa5+rai5UAkKqDJMAurmhHX0N kLUYK3buH1JQse3SLiB6JCl8LR+ZmuNkBTLn2LXNaGJJ+DK2c+FbkdvaLRti0gGv2XZAniwN1aZb+ 99W9EIv35bT5HJu1NFL7y4xyQ9v4t43BZPKl4+QgzYaBj3Yy1CC/7qJKRXI4qahsyXCZMY636yAW9 JudX8LZOg7E3YL4hbevO3cywD6hcqpCGQyMv7vR9s5LFw/tkDrHjTS1/HNDm7GA69egJWrLksbtq7 wwFpqHqAQ==; Received: from [2001:8b0:10b:1:4a2a:e3ff:fe14:8625] (helo=u3832b3a9db3152.ant.amazon.com) by merlin.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hw6On-0007ia-CK; Fri, 09 Aug 2019 15:01:45 +0000 Message-ID: <3fd9c77f1f92cec35af8691443b5ccd13dde023a.camel@infradead.org> From: David Woodhouse To: xen-devel Date: Fri, 09 Aug 2019 16:01:44 +0100 In-Reply-To: References: X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by merlin.infradead.org. See http://www.infradead.org/rpr.html Subject: [Xen-devel] [PATCH v2 1/6] x86/boot: Remove gratuitous call back into low-memory code X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , Roger Pau =?iso-8859-1?q?Monn=E9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: David Woodhouse We appear to have implemented a memcpy() in the low-memory trampoline which we then call into from __start_xen(), for no adequately defined reason. Kill it with fire. Signed-off-by: David Woodhouse Acked-by: Andrew Cooper --- v2: Minor fixups from Andrew. xen/arch/x86/boot/mem.S | 27 +++++---------------------- xen/arch/x86/setup.c | 10 ++++++++++ xen/include/asm-x86/e820.h | 5 ++--- 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/xen/arch/x86/boot/mem.S b/xen/arch/x86/boot/mem.S index c6a9bd4d3b..2d61d28835 100644 --- a/xen/arch/x86/boot/mem.S +++ b/xen/arch/x86/boot/mem.S @@ -7,7 +7,7 @@ get_memory_map: .Lmeme820: xorl %ebx, %ebx # continuation counter - movw $bootsym(e820map), %di # point into the whitelist + movw $bootsym(bios_e820map), %di # point into the whitelist # so we can have the bios # directly write into it. @@ -22,8 +22,8 @@ get_memory_map: cmpl $SMAP,%eax # check the return is `SMAP' jne .Lmem88 - incw bootsym(e820nr) - cmpw $E820_BIOS_MAX,bootsym(e820nr) # up to this many entries + incw bootsym(bios_e820nr) + cmpw $E820_BIOS_MAX,bootsym(bios_e820nr) # up to this many entries jae .Lmem88 movw %di,%ax @@ -66,27 +66,10 @@ get_memory_map: ret -/* - * Copy E820 map obtained from BIOS to a buffer allocated by Xen. - * Input: %rdi: target address of e820 entry array - * %esi: maximum number of entries to copy - * Output: %eax: number of entries copied - */ - .code64 -ENTRY(e820map_copy) - mov %esi, %eax - lea e820map(%rip), %rsi - mov e820nr(%rip), %ecx - cmp %ecx, %eax - cmova %ecx, %eax # number of entries to move - imul $5, %eax, %ecx - rep movsl # do the move - ret - .align 4 -e820map: +GLOBAL(bios_e820map) .fill E820_BIOS_MAX*20,1,0 -e820nr: +GLOBAL(bios_e820nr) .long 0 GLOBAL(lowmem_kb) .long 0 diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index d2011910fa..decea2e77a 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -672,6 +672,16 @@ static char * __init cmdline_cook(char *p, const char *loader_name) return p; } +static unsigned int __init copy_bios_e820(struct e820entry *map, unsigned int limit) +{ + unsigned int n = min(bootsym(bios_e820nr), limit); + + if ( n ) + memcpy(map, bootsym(bios_e820map), sizeof(*map) * n); + + return n; +} + void __init noreturn __start_xen(unsigned long mbi_p) { char *memmap_type = NULL; diff --git a/xen/include/asm-x86/e820.h b/xen/include/asm-x86/e820.h index ee317b17aa..52916fb75d 100644 --- a/xen/include/asm-x86/e820.h +++ b/xen/include/asm-x86/e820.h @@ -37,8 +37,7 @@ extern struct e820map e820_raw; /* These symbols live in the boot trampoline. */ extern unsigned int lowmem_kb, highmem_kb; -unsigned int e820map_copy(struct e820entry *map, unsigned int limit); - -#define copy_bios_e820 bootsym(e820map_copy) +extern struct e820map bios_e820map[]; +extern unsigned int bios_e820nr; #endif /*__E820_HEADER*/