From patchwork Fri Sep 26 04:42:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 37938 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 39723202DB for ; Fri, 26 Sep 2014 04:44:33 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id b57sf5598543eek.10 for ; Thu, 25 Sep 2014 21:44:32 -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=XyhEgT43bnPDsbGoWkDSukAqdg2WjrOHc5ZOHct/gJU=; b=hqP3by+HMMBDdIQaNzz+40FgDvAEVRrzooqbXVJJuAsq7yancc4+RAj+JE5FnXGaoM ZMol7uyoF/yYDk+At4/K5+Pa7HSxFN2S0nBmq8gW/9Dwc4VWmZv9q/vBnq6qYItkUFrK Vv//djkYSmPg1PxsYj4zd/T6oR8If7x4drYYO6HrQYk0EmpoI7gaYQzJnkhts/uBbHAM YFGvJ86frW+i6inZq1rsK86hykZCKVWjq7BTBmZnKBr/MFnp4NadFsfNcz0Z0AbRnuPQ HWw9PKyMWItuYawC2nkbk/BXWeTOHfOVfgW9l/eg9yXFwqcGRidhPiSo50kcM2KL8I2d sV+Q== X-Gm-Message-State: ALoCoQkIDf+kjp3bxIPj/xIDNyO2C369Pw/kLwHz5tagxMuZS4biA2LFE4HA42+QcLRwpNnLOnHf X-Received: by 10.112.146.2 with SMTP id sy2mr44743lbb.14.1411706672118; Thu, 25 Sep 2014 21:44:32 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.115.138 with SMTP id jo10ls315822lab.56.gmail; Thu, 25 Sep 2014 21:44:31 -0700 (PDT) X-Received: by 10.152.21.168 with SMTP id w8mr17912830lae.59.1411706671845; Thu, 25 Sep 2014 21:44:31 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com [209.85.215.50]) by mx.google.com with ESMTPS id n3si5606432lae.22.2014.09.25.21.44.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 25 Sep 2014 21:44:31 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by mail-la0-f50.google.com with SMTP id el20so2151124lab.9 for ; Thu, 25 Sep 2014 21:44:31 -0700 (PDT) X-Received: by 10.112.4.33 with SMTP id h1mr16342223lbh.67.1411706671076; Thu, 25 Sep 2014 21:44:31 -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 of9csp2522lbb; Thu, 25 Sep 2014 21:44:30 -0700 (PDT) X-Received: by 10.221.64.2 with SMTP id xg2mr12068621vcb.18.1411706669659; Thu, 25 Sep 2014 21:44:29 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id k10si2007398vdb.46.2014.09.25.21.44.29 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 25 Sep 2014 21:44:29 -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 1XXNMO-00050X-8w; Fri, 26 Sep 2014 04:42:24 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XXNMN-00050K-Am for xen-devel@lists.xen.org; Fri, 26 Sep 2014 04:42:23 +0000 Received: from [85.158.137.68:18225] by server-7.bemta-3.messagelabs.com id C2/1D-01084-EAEE4245; Fri, 26 Sep 2014 04:42:22 +0000 X-Env-Sender: roy.franz@linaro.org X-Msg-Ref: server-5.tower-31.messagelabs.com!1411706539!12169058!1 X-Originating-IP: [209.85.220.44] 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 19170 invoked from network); 26 Sep 2014 04:42:21 -0000 Received: from mail-pa0-f44.google.com (HELO mail-pa0-f44.google.com) (209.85.220.44) by server-5.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 26 Sep 2014 04:42:21 -0000 Received: by mail-pa0-f44.google.com with SMTP id eu11so11581824pac.3 for ; Thu, 25 Sep 2014 21:42:19 -0700 (PDT) X-Received: by 10.66.66.229 with SMTP id i5mr25619237pat.131.1411706539343; Thu, 25 Sep 2014 21:42:19 -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 tv4sm3654788pab.28.2014.09.25.21.42.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Sep 2014 21:42:18 -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: Thu, 25 Sep 2014 21:42:07 -0700 Message-Id: <1411706529-8765-3-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1411706529-8765-1-git-send-email-roy.franz@linaro.org> References: <1411706529-8765-1-git-send-email-roy.franz@linaro.org> Cc: Roy Franz , fu.wei@linaro.org Subject: [Xen-devel] [PATCH for-4.5 V8 2/4] 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.50 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 16d58cc..9c9cdaf 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -597,3 +597,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 301c0be..7446a26 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -212,11 +212,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 */ } @@ -713,12 +713,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); @@ -964,12 +959,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 )