From patchwork Tue Jan 17 20:07:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Goldstein X-Patchwork-Id: 9521837 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 880E060244 for ; Tue, 17 Jan 2017 20:10:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69AEF2858D for ; Tue, 17 Jan 2017 20:10:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5CCFE285AE; Tue, 17 Jan 2017 20:10:13 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID 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 3BCF02858D for ; Tue, 17 Jan 2017 20:10:12 +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 1cTa39-0004LU-Ay; Tue, 17 Jan 2017 20:08:11 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cTa37-0004IQ-8Q for xen-devel@lists.xen.org; Tue, 17 Jan 2017 20:08:09 +0000 Received: from [85.158.137.68] by server-5.bemta-3.messagelabs.com id 52/66-19998-8A97E785; Tue, 17 Jan 2017 20:08:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrPIsWRWlGSWpSXmKPExsVyMXThYd3llXU RBjMXaVss+biYxYHR4+ju30wBjFGsmXlJ+RUJrBkvpi1gK7ghX7FjzUfWBsY74l2MXBxCAhMZ JZbNamDqYuTkYBHYzyzR31gIkpAQWMYqceDrZkaQhIRAjMSGKx1QdoVE16JXbCC2kICCxO8Jh 5ggJi1nkujq2MoOkmAT0JB48msGWJGIgLTEtc+XGUGKmAV2M0ks6b7MApIQFvCTOLTuFDPEal WJEzdvgp3BKxAnMe3WVTaIbfISC88fAYtzCqRKPPv8gxlic4rEg7dvGHGJT2AUWsDIsIpRozi 1qCy1SNfQWC+pKDM9oyQ3MTNH19DAWC83tbg4MT01JzGpWC85P3cTIzAYGYBgB+O27Z6HGCU5 mJREeTse10YI8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuBtq6iLEBIsSk1PrUjLzAHGBUxagoNHS YR3Nkiat7ggMbc4Mx0idYrRmKOn6/RLJo49uy6/ZBJiycvPS5US5w0FKRUAKc0ozYMbBIvXS4 yyUsK8jECnCfEUpBblZpagyr9iFOdgVBLmnQUyhSczrwRu3yugU5iATrmuUw1ySkkiQkqqgfH 83WSuA64+H9reXkx6Ecch6/pqirjgkffvAjfO9OINmKomxLSfu+ahzM1lTX9suK5wGNYLlScf jBOJXNL8Rv5Y7ZYrr37WbcyOuJjY+FvG6lyW5uVmQ/apXDd2Vd8KFllyaGNkwPbNh29yfnEvO T+PLdKvYmbS1g8Bz/nz+jpvnyq7kLZfQF+JpTgj0VCLuag4EQDFRtMI0gIAAA== X-Env-Sender: cardoe@cardoe.com X-Msg-Ref: server-2.tower-31.messagelabs.com!1484683686!69382367!1 X-Originating-IP: [209.85.161.195] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19602 invoked from network); 17 Jan 2017 20:08:07 -0000 Received: from mail-yw0-f195.google.com (HELO mail-yw0-f195.google.com) (209.85.161.195) by server-2.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jan 2017 20:08:07 -0000 Received: by mail-yw0-f195.google.com with SMTP id u68so5465330ywg.0 for ; Tue, 17 Jan 2017 12:08:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cardoe.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=vowgOJw01GiZJvsu9JR0SewkA33f0k6QhzMGgbDcvRQ=; b=NaoWqwJPqVsEicM+fliqKpf/oD2uh+O+7vYCL1KhtQd10aaV4tKimpjPonA1b4rMBz gJKsk8EhCKUPckt98WPBqJuZhZcpKJmq+Dy1ZgwxEzjcMH3K/icbjnDMRv3e865zxlwu i4QZdhX+8YZVeGk4nPnT2LgkrIQCGoJqt48Kk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=vowgOJw01GiZJvsu9JR0SewkA33f0k6QhzMGgbDcvRQ=; b=F5jvvdfdIMtLD5NWKJ4cVGZfoVHohisV1xsyLVKYcx4FOipiwxaAjseQfZuLzp1sOz YkjWqz/fGRgpu+KObUZerpyMjMQUDjKtJAwflg4rkq3H7e1HE/TvEnuCjmYGhltWZS0N 9AiqyDcc1GsWVMDI58xu2xiNmO4F8GFHHs03MlhupP1UDiMin7CZu5eeSX69x5GZvbto wKaYZ4GVdiqocHKUjeWR3Q24oco9GyOon8G4JMOuJkVdmobqi2Wm2R4LJSq7FQzcKzeG K1+k0ahw1KhLhuMV8zLDAi7j2vQchUsospH0eMbQQCoL982nYN071FkuZjwFoS74Vv/Y DwMA== X-Gm-Message-State: AIkVDXKz97UHfXkxiscQSvx+vu+/DtPi35FcBEjgB2gtEZL4gFUHaXppDN0cEH0Sg7C4/w== X-Received: by 10.13.215.8 with SMTP id z8mr17463515ywd.150.1484683686280; Tue, 17 Jan 2017 12:08:06 -0800 (PST) Received: from swanson.attlocal.net (104-179-196-18.lightspeed.brhmal.sbcglobal.net. [104.179.196.18]) by smtp.gmail.com with ESMTPSA id o5sm11798104ywj.4.2017.01.17.12.08.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Jan 2017 12:08:05 -0800 (PST) From: Doug Goldstein To: xen-devel@lists.xen.org Date: Tue, 17 Jan 2017 14:07:48 -0600 Message-Id: <36d62ca62e1344d17b17b1979a627bb304e82396.1484683034.git-series.cardoe@cardoe.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: References: In-Reply-To: References: Cc: jgross@suse.com, sstabellini@kernel.org, konrad.wilk@oracle.com, Andrew Cooper , Doug Goldstein , pgnet.dev@gmail.com, ning.sun@intel.com, julien.grall@arm.com, Jan Beulich , qiaowei.ren@intel.com, gang.wei@intel.com, fu.wei@linaro.org Subject: [Xen-devel] [PATCH v3 5/5] fix: add multiboot2 protocol support for EFI platforms 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This should be squashed into the 4/4 patch 'x86: add multiboot2 protocol support for EFI platforms'. - fix incorrect assembly (identified by Andrew Cooper) - fix issue where the trampoline size was left as 0 and the way the memory is allocated for the trampolines we would go to the end of an available section and then subtract off the size to decide where to place it. The end result was that we would always copy the trampolines and the 32-bit stack into some form of reserved memory after the conventional region we wanted to put things into. On some systems this did not manifest as a crash while on others it did. Reworked the changes to always reserve 64kb for both the stack and the size of the trampolines. Signed-off-by: Doug Goldstein Reviewed-by: Doug Goldstein --- Doug v3 - drop ASSERTs since they are runtime only without any output. This should be completely mitigated by using max() and ensuring we have a sane value. (found by Jan Beulich) - removed extra_mem variable that was incorrectly left behind. (found by Jan Beulich) - fix comment around the "start of stack" (found by Jan Beulich) Doug v2 - new in this version to help show what's changed --- --- xen/arch/x86/boot/head.S | 1 + xen/arch/x86/efi/efi-boot.h | 9 +++++---- xen/arch/x86/efi/stub.c | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index ac93df0..d288959 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -519,6 +519,7 @@ trampoline_setup: 1: /* Switch to low-memory stack. */ mov sym_phys(trampoline_phys),%edi + /* The stack base is 64kb after the location of trampoline_phys */ lea 0x10000(%edi),%esp lea trampoline_boot_cpu_entry-trampoline_start(%edi),%eax pushl $BOOT_CS32 diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index dc857d8..a73134c 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -146,8 +146,6 @@ static void __init efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable, { struct e820entry *e; unsigned int i; - /* Check for extra mem for mbi data if Xen is loaded via multiboot2 protocol. */ - UINTN extra_mem = efi_enabled(EFI_LOADER) ? 0 : (64 << 10); /* Populate E820 table and check trampoline area availability. */ e = e820map - 1; @@ -170,8 +168,7 @@ static void __init efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable, /* fall through */ case EfiConventionalMemory: if ( !trampoline_phys && desc->PhysicalStart + len <= 0x100000 && - len >= cfg.size + extra_mem && - desc->PhysicalStart + len > cfg.addr ) + len >= cfg.size && desc->PhysicalStart + len > cfg.addr ) cfg.addr = (desc->PhysicalStart + len - cfg.size) & PAGE_MASK; /* fall through */ case EfiLoaderCode: @@ -686,6 +683,10 @@ paddr_t __init efi_multiboot2(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTa setup_efi_pci(); efi_variables(); + /* This is the maximum size of our trampoline + our low memory stack */ + cfg.size = max_t(UINTN, 64 << 10, + (trampoline_end - trampoline_start) + 4096); + if ( gop ) efi_set_gop_mode(gop, gop_mode); diff --git a/xen/arch/x86/efi/stub.c b/xen/arch/x86/efi/stub.c index 6ea6aa1..b81adc0 100644 --- a/xen/arch/x86/efi/stub.c +++ b/xen/arch/x86/efi/stub.c @@ -33,7 +33,7 @@ paddr_t __init noreturn efi_multiboot2(EFI_HANDLE ImageHandle, * not be directly supported by C compiler. */ asm volatile( - " call %2 \n" + " call *%2 \n" "0: hlt \n" " jmp 0b \n" : "+c" (StdErr), "+d" (err) : "g" (StdErr->OutputString)