From patchwork Thu Sep 18 22:50:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 37621 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6F6682054E for ; Thu, 18 Sep 2014 22:52:43 +0000 (UTC) Received: by mail-la0-f70.google.com with SMTP id s18sf1036592lam.1 for ; Thu, 18 Sep 2014 15:52:42 -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=MxM4l0jRJ5pCkYVKOaaFZi3VsvOIVjKHW1BiQTBHtoI=; b=SMQADRwYPjG4nu1laUK2qybn2WKuIY/P1jjXUaOafNwoV0qvKRPjs0PdpJ2L3DvKuf AtNChH/Y/ngO0RtwPtgSIMjxGvhOytVcjFzxkwl3S6HfkI5hQCoYuKjXnnzijUmad03e elaa2eZfHK0h4C1xcpp5ttXYlXFPGwmtuRXu6S1w+az1DN33MgJ3cvmzagF+FrufEt+h 50cWxmfIDThyPI9SrIvGfaeBk2BgOOZ3BI3foBHMvq0O4pVeXuFvS1C3fpYYUi4B9pAh 7cAxUuggd4FKFPvsX2gbfE40VG6uikoCVKlKOnSOpX2zjuHaAu+teKLrJ7qDqRZ+iLtK v5/A== X-Gm-Message-State: ALoCoQn5msGt9c1Hs1rB1v8FFw99d/fzFUqBj7Iud72FbxlBU3lSXba1Ngrv2s29FygsY7sS1rI0 X-Received: by 10.180.109.194 with SMTP id hu2mr1361007wib.1.1411080762262; Thu, 18 Sep 2014 15:52:42 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.22.130 with SMTP id d2ls231711laf.98.gmail; Thu, 18 Sep 2014 15:52:41 -0700 (PDT) X-Received: by 10.152.9.200 with SMTP id c8mr2824322lab.76.1411080761718; Thu, 18 Sep 2014 15:52:41 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com [209.85.217.173]) by mx.google.com with ESMTPS id v5si151560lae.56.2014.09.18.15.52.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Sep 2014 15:52:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by mail-lb0-f173.google.com with SMTP id 10so365729lbg.32 for ; Thu, 18 Sep 2014 15:52:41 -0700 (PDT) X-Received: by 10.112.24.104 with SMTP id t8mr2745310lbf.46.1411080761638; Thu, 18 Sep 2014 15:52:41 -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 of9csp843163lbb; Thu, 18 Sep 2014 15:52:41 -0700 (PDT) X-Received: by 10.52.34.104 with SMTP id y8mr1419430vdi.37.1411080760399; Thu, 18 Sep 2014 15:52:40 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id xi6si67446vcb.44.2014.09.18.15.52.39 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 18 Sep 2014 15:52:40 -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 1XUkX4-0006Oe-CM; Thu, 18 Sep 2014 22:50:34 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XUkX2-0006NK-Jr for xen-devel@lists.xen.org; Thu, 18 Sep 2014 22:50:32 +0000 Received: from [85.158.137.68:12876] by server-14.bemta-3.messagelabs.com id 6F/26-01575-7B16B145; Thu, 18 Sep 2014 22:50:31 +0000 X-Env-Sender: roy.franz@linaro.org X-Msg-Ref: server-6.tower-31.messagelabs.com!1411080629!10953475!1 X-Originating-IP: [209.85.192.177] 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 8617 invoked from network); 18 Sep 2014 22:50:31 -0000 Received: from mail-pd0-f177.google.com (HELO mail-pd0-f177.google.com) (209.85.192.177) by server-6.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 18 Sep 2014 22:50:31 -0000 Received: by mail-pd0-f177.google.com with SMTP id y10so1250190pdj.36 for ; Thu, 18 Sep 2014 15:50:29 -0700 (PDT) X-Received: by 10.66.139.200 with SMTP id ra8mr10032821pab.69.1411080629189; Thu, 18 Sep 2014 15:50:29 -0700 (PDT) Received: from rfranz-t520.swisscom.com (70-35-38-154.static.wiline.com. [70.35.38.154]) by mx.google.com with ESMTPSA id ig4sm66332pbb.55.2014.09.18.15.50.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Sep 2014 15:50:28 -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, 18 Sep 2014 15:50:02 -0700 Message-Id: <1411080607-32365-12-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1411080607-32365-1-git-send-email-roy.franz@linaro.org> References: <1411080607-32365-1-git-send-email-roy.franz@linaro.org> Cc: Roy Franz , fu.wei@linaro.org Subject: [Xen-devel] [PATCH V5 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.217.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 Acked-by: Jan Beulich --- xen/common/efi/boot.c | 18 ++++-------------- xen/include/asm-x86/efi-boot.h | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 4acab40..f4ef308 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -207,11 +207,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.w); @@ -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 ) diff --git a/xen/include/asm-x86/efi-boot.h b/xen/include/asm-x86/efi-boot.h index 3902b6c..2a3a2b6 100644 --- a/xen/include/asm-x86/efi-boot.h +++ b/xen/include/asm-x86/efi-boot.h @@ -603,3 +603,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; +}