From patchwork Thu Sep 25 01:42:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 37883 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f197.google.com (mail-we0-f197.google.com [74.125.82.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8B1C7204FF for ; Thu, 25 Sep 2014 01:44:54 +0000 (UTC) Received: by mail-we0-f197.google.com with SMTP id p10sf3365493wes.8 for ; Wed, 24 Sep 2014 18:44:53 -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=nC/Z+4pLzxKdhxQ7wo3KMXc4qQszu3XSMVeOactLhEA=; b=VNnGkaOz1fWDSo3Utu0mu4c2HPHG1K8iC0/jH5GHhMtMDyvdYYzAdIk2g5Iv0JXN5M ZZEjgT1k65w4GxHTmJKrlrve/E6MVZGqT8MO9pBEvtwdvihOEcvBP0w4OrxU5inpVQPX EwQZMINHejtGh7q99WvjtDhOEkZVX0LpGrlJJzphJLgeWuxHRbL/yr41RWfUehE22zWI 1lTeySh8xp/OIygk8MQC2hnjIa5/8zizueBpCZrwUb4KJPkVjIcM57qKXH1uZqXtp/Zo HI7IaxiBPDwWE8j+WSctIuVAiSW5FedMhTCkH9l/p+K0PxMsPKWT/oo1T7isOARYQXIc cpiA== X-Gm-Message-State: ALoCoQmRaZWrT8CaKMwyArQp3SUrpPUU9oRXOijnUGbYPPq5TgBsIqF5ZsA6YqlqZJJjAJaTp1hX X-Received: by 10.180.24.225 with SMTP id x1mr2036180wif.2.1411609493715; Wed, 24 Sep 2014 18:44:53 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.97 with SMTP id r1ls213039lar.84.gmail; Wed, 24 Sep 2014 18:44:53 -0700 (PDT) X-Received: by 10.112.158.170 with SMTP id wv10mr9421921lbb.66.1411609493531; Wed, 24 Sep 2014 18:44:53 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com [209.85.217.175]) by mx.google.com with ESMTPS id xt8si995523lab.44.2014.09.24.18.44.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 24 Sep 2014 18:44:53 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by mail-lb0-f175.google.com with SMTP id w7so5985993lbi.6 for ; Wed, 24 Sep 2014 18:44:53 -0700 (PDT) X-Received: by 10.152.8.9 with SMTP id n9mr10106442laa.2.1411609493448; Wed, 24 Sep 2014 18:44:53 -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 of9csp678234lbb; Wed, 24 Sep 2014 18:44:52 -0700 (PDT) X-Received: by 10.220.20.5 with SMTP id d5mr8831427vcb.9.1411609491305; Wed, 24 Sep 2014 18:44:51 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id fc4si432430vcb.86.2014.09.24.18.44.50 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 24 Sep 2014 18:44:51 -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 1XWy5I-0001DP-Jy; Thu, 25 Sep 2014 01:43:04 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XWy5H-0001Ad-5a for xen-devel@lists.xen.org; Thu, 25 Sep 2014 01:43:03 +0000 Received: from [85.158.137.68:39459] by server-8.bemta-3.messagelabs.com id 99/55-31195-62373245; Thu, 25 Sep 2014 01:43:02 +0000 X-Env-Sender: roy.franz@linaro.org X-Msg-Ref: server-16.tower-31.messagelabs.com!1411609380!11885978!1 X-Originating-IP: [209.85.223.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 11816 invoked from network); 25 Sep 2014 01:43:01 -0000 Received: from mail-ie0-f182.google.com (HELO mail-ie0-f182.google.com) (209.85.223.182) by server-16.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 25 Sep 2014 01:43:01 -0000 Received: by mail-ie0-f182.google.com with SMTP id tp5so7439824ieb.27 for ; Wed, 24 Sep 2014 18:43:00 -0700 (PDT) X-Received: by 10.42.67.212 with SMTP id u20mr14563989ici.62.1411609380019; Wed, 24 Sep 2014 18:43:00 -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 x9sm5829238igl.10.2014.09.24.18.42.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Sep 2014 18:42:59 -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: Wed, 24 Sep 2014 18:42:30 -0700 Message-Id: <1411609352-24549-13-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1411609352-24549-1-git-send-email-roy.franz@linaro.org> References: <1411609352-24549-1-git-send-email-roy.franz@linaro.org> Cc: Roy Franz , fu.wei@linaro.org Subject: [Xen-devel] [PATCH for-4.5 V7 12/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.217.175 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 ed5e15b..5c79341 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -591,3 +591,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 f19db81..5c50243 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); @@ -966,12 +961,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 )