From patchwork Mon Jan 16 14:15:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Goldstein X-Patchwork-Id: 9518925 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 50984601C3 for ; Mon, 16 Jan 2017 14:18:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31C4D28495 for ; Mon, 16 Jan 2017 14:18:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 265B1284EC; Mon, 16 Jan 2017 14:18:06 +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 B814F28497 for ; Mon, 16 Jan 2017 14:18:05 +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 1cT84q-0001ZN-32; Mon, 16 Jan 2017 14:16:04 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cT84o-0001XG-6z for xen-devel@lists.xen.org; Mon, 16 Jan 2017 14:16:02 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id E2/E9-22326-1A5DC785; Mon, 16 Jan 2017 14:16:01 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrLIsWRWlGSWpSXmKPExsVyMXThYd0FV2s iDOYc0LBY8nExiwOjx9Hdv5kCGKNYM/OS8isSWDPmXFrEWHBNqmLLsbdsDYy/hbsYuTiEBCYy Slye+pYZxGER2M8sMfV2JxuIIyGwjFWip2UiUxcjJ5ATI7F2RTcbhF0h0dy2EiwuJKAg8XvCI Sh7OZNE+84UEJtNQEPiya8ZYPUiAtIS1z5fZgQZyiywm0liSfdlFpCEsICfxMTuh+wgNouAqs TPp+fB4rwCcRKbzvyAWiwvsfD8ETCbUyBV4vaszaxdjBxAy1Ik3i/0xSE8gVFoASPDKkaN4tS istQiXSMTvaSizPSMktzEzBxdQwMzvdzU4uLE9NScxKRiveT83E2MwEBkAIIdjCvXBR5ilORg UhLlPaZTHSHEl5SfUpmRWJwRX1Sak1p8iFGGg0NJgpf9Sk2EkGBRanpqRVpmDjAmYNISHDxKI ry8IGne4oLE3OLMdIjUKUZjjp6u0y+ZOPbsuvySSYglLz8vVUqc995loFIBkNKM0jy4QbBYvc QoKyXMywh0mhBPQWpRbmYJqvwrRnEORiVh3nKQhTyZeSVw+14BncIEdMp1kC94i0sSEVJSDYx aW+/cnP7w5IRCr99phzW6xHY7SXwpm8TmfVz+Y9X/vkdvOAIbkns69tyaPzP8dMTHuoJprR/6 l8is3rxtWu31E6EHg3q1ryd4T74mxj/BL4Tnf+nVdY5J3jXuRjcmBj28rX9+zo//2qwiV9plH Jc0H1n7KcxIfBkzG1P57LX6BkVqF20KnSWUWIozEg21mIuKEwEJbSYy0AIAAA== X-Env-Sender: cardoe@cardoe.com X-Msg-Ref: server-16.tower-21.messagelabs.com!1484576159!48413500!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 26450 invoked from network); 16 Jan 2017 14:16:00 -0000 Received: from mail-yw0-f195.google.com (HELO mail-yw0-f195.google.com) (209.85.161.195) by server-16.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 16 Jan 2017 14:16:00 -0000 Received: by mail-yw0-f195.google.com with SMTP id u68so1383608ywg.0 for ; Mon, 16 Jan 2017 06:16:00 -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=Ka8FJKoIRISSTltGDPAOQVkZd/Vuyll8oW/z/IiJ164=; b=hbe5kgTmWdof7VJXCwN6sRt6dghg6nCGGHTIatNk3CJDVwTSbJLO6JOMwIslI2YfyV 6FAtsyeF3lZM8RB5unwthC319ZFTrPYJ5MqeVzi00Zq0isTnxw/HkZyQW5zk59jQj18E cue8aRtAnak8hymbbuAAxZVKo3wr39w6tYRGw= 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=Ka8FJKoIRISSTltGDPAOQVkZd/Vuyll8oW/z/IiJ164=; b=Gi7Bo7p3R/+e6HSLKEaBI6eeWSv7/IKcfhEBoAsB/2ZZwtepSmQMZkrQCKTFn7EGkH slXMnhkHRjOB/NP4xPRjQXJRXfDDUIuNArUkXgyrmUS7LFiClDLOGdAdKiojC8DbRpZr cenwM5pm/oepiV0ovSstYASzWKX9o8fg+q01LNTjFXiFYl6uNEue5ZoKLmcUN3HwGV6M OlqaK1BlAZ4XLete0aEZDcNNKyWjJOLJBsKCNgDG7slDy3II04t8KfuHp8lzOvYD0qhj nPg08oUUayxyctE80apIYDNGHE8DW4tXWUag6BzugaZ/5DKXHg5PsUbjItarP4wojo1C lgfg== X-Gm-Message-State: AIkVDXI4UytHTDM5zBQLacAq//j6p9KNtq5PChHtCMuAvu2lpDa4QwfghxuHOozMJTmbXg== X-Received: by 10.13.249.7 with SMTP id j7mr25528983ywf.279.1484576158103; Mon, 16 Jan 2017 06:15:58 -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 v1sm9778441ywc.17.2017.01.16.06.15.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Jan 2017 06:15:57 -0800 (PST) From: Doug Goldstein To: xen-devel@lists.xen.org Date: Mon, 16 Jan 2017 08:15:12 -0600 Message-Id: <7e5f86980eb39a34ce9c03979a33112f53500b5d.1484576056.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 v2 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. Added an ASSERT to make sure we never blow through this size. Signed-off-by: Doug Goldstein Reviewed-by: Doug Goldstein --- 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, 9 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index ac93df0..876a6b1 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 starts 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..af97fb9 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -170,9 +170,10 @@ 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 ) { + ASSERT(cfg.size > 0); cfg.addr = (desc->PhysicalStart + len - cfg.size) & PAGE_MASK; + } /* fall through */ case EfiLoaderCode: case EfiLoaderData: @@ -686,6 +687,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 = 64 << 10; + ASSERT(cfg.size >= ((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)