From patchwork Wed Sep 10 00:52:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 37176 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7B10220566 for ; Wed, 10 Sep 2014 00:55:09 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id i7sf87534611oag.0 for ; Tue, 09 Sep 2014 17:55:08 -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=dHDA+HESmrdIiB704iCBGmcg7kWBfJD+lJjQ5FQVTxM=; b=CiVVGVSQjInBkAgU704BBYp2G9BZGl1UzjLQD+7aY7ZJ8Djtg627e6g2dYtMwsnW8M DycHVhPIGm9quLUzJLbOFrcxsTcwH7ibJa72/p98VGzUrumfLnIrC5ItIVRxCRZMCdrc xnxIbwJEzTAB2RrdgeedwcHQgOH1Vy2HMdSt8N7rxLcLalv7Lpb1uUunXFHUhgg3O7Oa hwXgUQ8bQ2a45qWTBX8jiyMkqGVv0ewrQOJsC5RZEp+wZquwRPmFO/nksYYCZJTY/Zet GznS55S7KcRs+Xanq5ju/6l/5LksQfEixWGP8fUVEEpcAGNTxC42cJZwR/GVQbNBC/8i WbGQ== X-Gm-Message-State: ALoCoQmk6VhFfxJErVOXGQ9ziWAoiphg7xRuzwOQ2WQzAvRfeBae1N9mXzF8Eer/RntPCdRcHO9U X-Received: by 10.182.213.105 with SMTP id nr9mr24461450obc.36.1410310508926; Tue, 09 Sep 2014 17:55:08 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.88.6 with SMTP id s6ls2425887qgd.22.gmail; Tue, 09 Sep 2014 17:55:08 -0700 (PDT) X-Received: by 10.52.0.132 with SMTP id 4mr27917830vde.10.1410310508806; Tue, 09 Sep 2014 17:55:08 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id pu11si6438632vdb.55.2014.09.09.17.55.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Sep 2014 17:55:08 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id la4so1314503vcb.22 for ; Tue, 09 Sep 2014 17:55:08 -0700 (PDT) X-Received: by 10.221.24.7 with SMTP id rc7mr3886461vcb.54.1410310508724; Tue, 09 Sep 2014 17:55:08 -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 uj3csp363938vcb; Tue, 9 Sep 2014 17:55:08 -0700 (PDT) X-Received: by 10.52.228.67 with SMTP id sg3mr27984618vdc.6.1410310508321; Tue, 09 Sep 2014 17:55:08 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id gs5si6425719vdc.69.2014.09.09.17.55.07 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 09 Sep 2014 17:55:08 -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 1XRW9F-0006Iu-Jf; Wed, 10 Sep 2014 00:52:37 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XRW9D-0006Hd-Nq for xen-devel@lists.xen.org; Wed, 10 Sep 2014 00:52:35 +0000 Received: from [85.158.139.211:44512] by server-1.bemta-5.messagelabs.com id 88/B0-17892-3D0AF045; Wed, 10 Sep 2014 00:52:35 +0000 X-Env-Sender: roy.franz@linaro.org X-Msg-Ref: server-10.tower-206.messagelabs.com!1410310351!8168081!1 X-Originating-IP: [209.85.223.170] 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 32557 invoked from network); 10 Sep 2014 00:52:32 -0000 Received: from mail-ie0-f170.google.com (HELO mail-ie0-f170.google.com) (209.85.223.170) by server-10.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 10 Sep 2014 00:52:32 -0000 Received: by mail-ie0-f170.google.com with SMTP id tp5so6833662ieb.29 for ; Tue, 09 Sep 2014 17:52:31 -0700 (PDT) X-Received: by 10.50.66.130 with SMTP id f2mr35841804igt.10.1410310351064; Tue, 09 Sep 2014 17:52:31 -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 dx10sm654825igb.4.2014.09.09.17.52.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Sep 2014 17:52:30 -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, 9 Sep 2014 17:52:01 -0700 Message-Id: <1410310325-4509-12-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1410310325-4509-1-git-send-email-roy.franz@linaro.org> References: <1410310325-4509-1-git-send-email-roy.franz@linaro.org> Cc: Roy Franz , fu.wei@linaro.org Subject: [Xen-devel] [PATCH V4 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.177 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 | 24 ++++++++++++++++++++++++ 2 files changed, 28 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 b2e8599..e7e9b15 100644 --- a/xen/include/asm-x86/efi-boot.h +++ b/xen/include/asm-x86/efi-boot.h @@ -985,6 +985,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) @@ -1039,3 +1047,19 @@ 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; +}