From patchwork Wed Sep 24 05:03:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 37779 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4DBA620792 for ; Wed, 24 Sep 2014 05:05:04 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id mc6sf201599lab.11 for ; Tue, 23 Sep 2014 22:05:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :list-archive:content-type:content-transfer-encoding; bh=KAa6PY2UwtGzCwlTc+PnaryXJXYVyDpvTW0mdjtzRbM=; b=W7ovGNkxBWXMr9toGxVKLFnayJSN7waQ3Mlvqy+rTDupH2SbdeZ3nTpXj3A+hq/0D6 MTnfF/8Dytu3tTQLuwqWgMpzvIqOswz/imOf8axSAklX29dGoFU+vf4mUPNpsQ42kV1K Bsh2oaa3laNaJx35YvdD6qbvPt1tWteJWJCyu4i+6y4s0ftqOAc01HpXDtPG/o0FKOh4 COtvSadAqxUY4gzQSAFN2vg7fQomGtHMru5uP3eo5x2snIrSA0Zv4HFOOeaMURNsMmbP LscOTXi+Aw9V0QtUBlqobG+fUm7KTElj/HK6HaUiS07xHieclpDSv8VpTBnKTzozCZ4K jlyQ== X-Gm-Message-State: ALoCoQm0OpnAFAtFwxrsauKj374mF/mAz5FOZc/UwsE8bqN5B9YPFo0O3XAgUDIRc3xVNykdbT4+ X-Received: by 10.194.121.72 with SMTP id li8mr618604wjb.1.1411535103081; Tue, 23 Sep 2014 22:05:03 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.8 with SMTP id bc8ls109382lab.86.gmail; Tue, 23 Sep 2014 22:05:02 -0700 (PDT) X-Received: by 10.152.29.129 with SMTP id k1mr3728890lah.81.1411535102752; Tue, 23 Sep 2014 22:05:02 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com [209.85.215.44]) by mx.google.com with ESMTPS id az15si21319313lab.35.2014.09.23.22.05.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 23 Sep 2014 22:05:02 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id q1so9942608lam.17 for ; Tue, 23 Sep 2014 22:05:02 -0700 (PDT) X-Received: by 10.152.5.168 with SMTP id t8mr3699144lat.67.1411535102635; Tue, 23 Sep 2014 22:05:02 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp526203lbb; Tue, 23 Sep 2014 22:05:01 -0700 (PDT) X-Received: by 10.52.103.49 with SMTP id ft17mr2970192vdb.75.1411535101191; Tue, 23 Sep 2014 22:05:01 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id l2si5298778vdi.4.2014.09.23.22.05.00 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 23 Sep 2014 22:05:01 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XWejx-0006N0-Gx; Wed, 24 Sep 2014 05:03:45 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XWejw-0006L8-3H for xen-devel@lists.xen.org; Wed, 24 Sep 2014 05:03:44 +0000 Received: from [85.158.139.211:9961] by server-10.bemta-5.messagelabs.com id BF/2B-19806-FA052245; Wed, 24 Sep 2014 05:03:43 +0000 X-Env-Sender: roy.franz@linaro.org X-Msg-Ref: server-13.tower-206.messagelabs.com!1411535021!11691749!1 X-Originating-IP: [209.85.213.182] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.12.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28641 invoked from network); 24 Sep 2014 05:03:42 -0000 Received: from mail-ig0-f182.google.com (HELO mail-ig0-f182.google.com) (209.85.213.182) by server-13.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 24 Sep 2014 05:03:42 -0000 Received: by mail-ig0-f182.google.com with SMTP id hn15so5881844igb.3 for ; Tue, 23 Sep 2014 22:03:40 -0700 (PDT) X-Received: by 10.50.164.202 with SMTP id ys10mr9444363igb.6.1411535020929; Tue, 23 Sep 2014 22:03:40 -0700 (PDT) Received: from rfranz-v430.caveonetworks.com (64.2.3.195.ptr.us.xo.net. [64.2.3.195]) by mx.google.com with ESMTPSA id ig9sm3477662igb.13.2014.09.23.22.03.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Sep 2014 22:03:40 -0700 (PDT) From: Roy Franz To: xen-devel@lists.xen.org, ian.campbell@citrix.com, stefano.stabellini@citrix.com, tim@xen.org, jbeulich@suse.com, keir@xen.org Date: Tue, 23 Sep 2014 22:03:09 -0700 Message-Id: <1411534992-27443-12-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1411534992-27443-1-git-send-email-roy.franz@linaro.org> References: <1411534992-27443-1-git-send-email-roy.franz@linaro.org> Cc: Roy Franz , fu.wei@linaro.org Subject: [Xen-devel] [PATCH for-4.5 V6 11/14] Add several misc. arch functions for EFI boot code. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: roy.franz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: Add efi_arch_blexit() for arch specific cleanup on error exit, efi_arch_load_addr_check() to do the arch specific verifications of where the UEFI firmware loaded Xen, and efi_arch_cpu() for probing CPU features. Signed-off-by: Roy Franz Acked-by: Jan Beulich --- xen/arch/x86/efi/efi-boot.h | 25 +++++++++++++++++++++++++ xen/common/efi/boot.c | 18 ++++-------------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index ee43cc4..e2c9e87 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -594,3 +594,28 @@ static void __init efi_arch_handle_module(struct file *file, const CHAR16 *name, ++mbi.mods_count; efi_bs->FreePool(ptr); } + +static void __init efi_arch_cpu(void) +{ + if ( cpuid_eax(0x80000000) > 0x80000000 ) + { + cpuid_ext_features = cpuid_edx(0x80000001); + boot_cpu_data.x86_capability[1] = cpuid_ext_features; + } +} + +static void __init efi_arch_blexit(void) +{ + if ( ucode.addr ) + efi_bs->FreePages(ucode.addr, PFN_UP(ucode.size)); +} + +static void __init efi_arch_load_addr_check(EFI_LOADED_IMAGE *loaded_image) +{ + xen_phys_start = (UINTN)loaded_image->ImageBase; + if ( (xen_phys_start + loaded_image->ImageSize - 1) >> 32 ) + blexit(L"Xen must be loaded below 4Gb."); + if ( xen_phys_start & ((1 << L2_PAGETABLE_SHIFT) - 1) ) + blexit(L"Xen must be loaded at a 2Mb boundary."); + trampoline_xen_phys_start = xen_phys_start; +} diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 4e579c6..4352b48 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -209,11 +209,11 @@ static void __init noreturn blexit(const CHAR16 *str) efi_bs->FreePages(kernel.addr, PFN_UP(kernel.size)); if ( ramdisk.addr ) efi_bs->FreePages(ramdisk.addr, PFN_UP(ramdisk.size)); - if ( ucode.addr ) - efi_bs->FreePages(ucode.addr, PFN_UP(ucode.size)); if ( xsm.addr ) efi_bs->FreePages(xsm.addr, PFN_UP(xsm.size)); + efi_arch_blexit(); + efi_bs->Exit(efi_ih, EFI_SUCCESS, 0, NULL); unreachable(); /* not reached */ } @@ -709,12 +709,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) if ( status != EFI_SUCCESS ) PrintErrMesg(L"No Loaded Image Protocol", status); - xen_phys_start = (UINTN)loaded_image->ImageBase; - if ( (xen_phys_start + loaded_image->ImageSize - 1) >> 32 ) - blexit(L"Xen must be loaded below 4Gb."); - if ( xen_phys_start & ((1 << L2_PAGETABLE_SHIFT) - 1) ) - blexit(L"Xen must be loaded at a 2Mb boundary."); - trampoline_xen_phys_start = xen_phys_start; + efi_arch_load_addr_check(loaded_image); /* Get the file system interface. */ dir_handle = get_parent_handle(loaded_image, &file_name); @@ -962,12 +957,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) efi_arch_edd(); /* XXX Collect EDID info. */ - - if ( cpuid_eax(0x80000000) > 0x80000000 ) - { - cpuid_ext_features = cpuid_edx(0x80000001); - boot_cpu_data.x86_capability[1] = cpuid_ext_features; - } + efi_arch_cpu(); /* Obtain basic table pointers. */ for ( i = 0; i < efi_num_ct; ++i )