From patchwork Mon Sep 8 03:53:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 36937 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f197.google.com (mail-ig0-f197.google.com [209.85.213.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 19AA820F2E for ; Mon, 8 Sep 2014 03:56:20 +0000 (UTC) Received: by mail-ig0-f197.google.com with SMTP id r2sf68841770igi.4 for ; Sun, 07 Sep 2014 20:56:19 -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=4uBx7Zr4SVaPt3MGhnf0WvzaiwMXrbC5SV+3TfIERPw=; b=F9SBoSc88VrKxEcvhoxC/yPF6ElcEwvnN7fdGWUCQ7Hr35MWMVQLXDt9ZToWhN0HTI w3u9tem+8QtpTzjDP8ruDR3rEZ5gASvwtmgD8SYv1mwHK5OEzzAvWD9f4h5jjtY5XCYS 7+yu/LmYB5cptEuB1u/DO47VFBc6CqIvAz39/IgcnCKNqJXL1k8PPBR+wTy9Z9zfOREI bYVBHvHHTOES8Xng7qpCLv6awkRuzbVc+73bJrgNrn/fRHSaixnOLeDKbl/jvQd57cjo QcN6pAPtMBN/b0ejXSCU2pZKuq284tZ6mH6eqMQtLkDb0EVHBenvnNjnn/W0QTC6Aki4 j5Uw== X-Gm-Message-State: ALoCoQn1QEd1N8D0enA5EjylOzquvNnBSmvhqvecBGWJ7scp7T7ya0oFLveJOx3ondtFqimgxXut X-Received: by 10.42.119.82 with SMTP id a18mr16465811icr.19.1410148579663; Sun, 07 Sep 2014 20:56:19 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.29.194 with SMTP id b60ls466427qgb.3.gmail; Sun, 07 Sep 2014 20:56:19 -0700 (PDT) X-Received: by 10.52.160.10 with SMTP id xg10mr19589031vdb.1.1410148579590; Sun, 07 Sep 2014 20:56:19 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id ry3si3514027vcb.27.2014.09.07.20.56.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 07 Sep 2014 20:56:19 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id le20so838567vcb.4 for ; Sun, 07 Sep 2014 20:56:19 -0700 (PDT) X-Received: by 10.220.168.74 with SMTP id t10mr4378814vcy.35.1410148579488; Sun, 07 Sep 2014 20:56:19 -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.221.45.67 with SMTP id uj3csp76461vcb; Sun, 7 Sep 2014 20:56:19 -0700 (PDT) X-Received: by 10.140.42.17 with SMTP id b17mr25943322qga.52.1410148578290; Sun, 07 Sep 2014 20:56:18 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id 49si9699782qgh.91.2014.09.07.20.56.17 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 07 Sep 2014 20:56:18 -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 1XQq2E-00071N-J5; Mon, 08 Sep 2014 03:54:34 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XQq2D-00070O-Fo for xen-devel@lists.xen.org; Mon, 08 Sep 2014 03:54:33 +0000 Received: from [193.109.254.147:63986] by server-4.bemta-14.messagelabs.com id CA/82-01677-8782D045; Mon, 08 Sep 2014 03:54:32 +0000 X-Env-Sender: roy.franz@linaro.org X-Msg-Ref: server-4.tower-27.messagelabs.com!1410148470!14045960!1 X-Originating-IP: [209.85.220.48] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 9015 invoked from network); 8 Sep 2014 03:54:31 -0000 Received: from mail-pa0-f48.google.com (HELO mail-pa0-f48.google.com) (209.85.220.48) by server-4.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 8 Sep 2014 03:54:31 -0000 Received: by mail-pa0-f48.google.com with SMTP id hz1so4795802pad.35 for ; Sun, 07 Sep 2014 20:54:30 -0700 (PDT) X-Received: by 10.68.228.37 with SMTP id sf5mr873295pbc.154.1410148470123; Sun, 07 Sep 2014 20:54:30 -0700 (PDT) Received: from rfranz-i7.local (c-24-10-97-91.hsd1.ca.comcast.net. [24.10.97.91]) by mx.google.com with ESMTPSA id qy1sm7524053pbc.27.2014.09.07.20.54.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Sep 2014 20:54:29 -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: Sun, 7 Sep 2014 20:53:57 -0700 Message-Id: <1410148441-18684-12-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1410148441-18684-1-git-send-email-roy.franz@linaro.org> References: <1410148441-18684-1-git-send-email-roy.franz@linaro.org> Cc: Roy Franz , fu.wei@linaro.org, linaro-uefi@lists.linaro.org Subject: [Xen-devel] [PATCH V3 11/15] 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.220.173 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 --- xen/common/efi/boot.c | 18 ++++-------------- xen/include/asm-x86/efi-boot.h | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 013597b..1630dde 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -192,11 +192,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 */ } @@ -592,12 +592,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.w); @@ -794,12 +789,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(); efi_arch_runtime_setup(SystemTable); diff --git a/xen/include/asm-x86/efi-boot.h b/xen/include/asm-x86/efi-boot.h index f5b7dcd..d7c6abc 100644 --- a/xen/include/asm-x86/efi-boot.h +++ b/xen/include/asm-x86/efi-boot.h @@ -982,6 +982,14 @@ static void __init efi_arch_handle_module(struct file *file, char *name, ++mbi.mods_count; } +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_smbios(void) { if (efi.smbios != EFI_INVALID_TABLE_ADDR) @@ -1035,3 +1043,18 @@ static void __init efi_arch_runtime_setup(EFI_SYSTEM_TABLE *SystemTable) PrintStr(newline); } } +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; +}