From patchwork Thu Feb 5 10:28:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 44422 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D8ED721521 for ; Thu, 5 Feb 2015 10:29:33 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id u10sf4728656lbd.3 for ; Thu, 05 Feb 2015 02:29:32 -0800 (PST) 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:subject:precedence:reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=wZgfNt7H/hbxbwzEy5qPdEkM/rz2T2QrUIr78ootFvw=; b=LVWF05AjzJP4zNZ2zQ6juQjrgrXMIUI5lqhqkCkhN3G9bUjreX/386UrbPI3j7mwyl tMQhHt52AE6scacZZsxx6l0Jg5i8dcgDtpKaKdUxAiGsUAcrnu4n8cj7tYbYyaIlsTkz pi6XuC6HmnopNDo8LbfyGfC0iG66y+VlQQ+6s0lSwVwdhrldGmmFwqXJl9jo/PKOotY1 aTGcT1dJnnmpxvSRXV9r8Fh9DSB6rNwgnF8xzr0EWlJ3zKwk99O+zmhXKDRvapZu6INB StbK81fND5wZ0yX2t30RhDdhV5XZwPnxYiOz3FXAt7L5Rr3Yc4auSlVsqileQxTIqFn8 yVDw== X-Gm-Message-State: ALoCoQlYoCvkSBfQAn20umqguM2EUH6mPSGFUx98WmC5SX9PTX3XbzrII8mPbImRw6FQPwDkl+SY X-Received: by 10.180.84.7 with SMTP id u7mr970979wiy.0.1423132172839; Thu, 05 Feb 2015 02:29:32 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.132 with SMTP id b4ls133387lah.16.gmail; Thu, 05 Feb 2015 02:29:32 -0800 (PST) X-Received: by 10.112.122.52 with SMTP id lp20mr2576538lbb.98.1423132172600; Thu, 05 Feb 2015 02:29:32 -0800 (PST) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id 8si3571667lam.85.2015.02.05.02.29.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Feb 2015 02:29:32 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by mail-lb0-f170.google.com with SMTP id w7so6245266lbi.1 for ; Thu, 05 Feb 2015 02:29:32 -0800 (PST) X-Received: by 10.112.243.12 with SMTP id wu12mr2528477lbc.91.1423132172123; Thu, 05 Feb 2015 02:29:32 -0800 (PST) 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.35.133 with SMTP id h5csp1049492lbj; Thu, 5 Feb 2015 02:29:31 -0800 (PST) X-Received: by 10.42.68.73 with SMTP id w9mr6324399ici.84.1423132166888; Thu, 05 Feb 2015 02:29:26 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id e15si3639605igq.21.2015.02.05.02.29.26 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 05 Feb 2015 02:29:26 -0800 (PST) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YJJgT-0006SU-Qi; Thu, 05 Feb 2015 10:29:17 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YJJgS-0006SM-IX for edk2-devel@lists.sourceforge.net; Thu, 05 Feb 2015 10:29:16 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of linaro.org designates 209.85.212.176 as permitted sender) client-ip=209.85.212.176; envelope-from=ard.biesheuvel@linaro.org; helo=mail-wi0-f176.google.com; Received: from mail-wi0-f176.google.com ([209.85.212.176]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YJJgQ-0002lp-Vs for edk2-devel@lists.sourceforge.net; Thu, 05 Feb 2015 10:29:16 +0000 Received: by mail-wi0-f176.google.com with SMTP id bs8so37927557wib.3 for ; Thu, 05 Feb 2015 02:29:09 -0800 (PST) X-Received: by 10.194.205.162 with SMTP id lh2mr6249774wjc.34.1423132149019; Thu, 05 Feb 2015 02:29:09 -0800 (PST) Received: from ards-macbook-pro.local (205.28.43.5.rev.vodafone.pt. [5.43.28.205]) by mx.google.com with ESMTPSA id x6sm6706609wjf.24.2015.02.05.02.29.06 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Feb 2015 02:29:08 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.sourceforge.net, lersek@redhat.com, olivier.martin@arm.com, roy.franz@linaro.org, leif.lindholm@linaro.org Date: Thu, 5 Feb 2015 10:28:54 +0000 Message-Id: <1423132136-19349-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1423132136-19349-1-git-send-email-ard.biesheuvel@linaro.org> References: <1423132136-19349-1-git-send-email-ard.biesheuvel@linaro.org> X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1YJJgQ-0002lp-Vs Subject: [edk2] [PATCH 2/4] ArmPkg: split off ArmGicArchLib from ArmGicLib X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@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.170 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 The current implementation of ArmGicGetSupportedArchRevision () that is used by all ARM platforms is entirely stateless (in order to support being executed from flash) so it needs to interrogate the hardware for the supported GIC revision upon each invocation. However, on platforms that execute under virtualization, every read or write to a system register may require handling by the host, which on KVM incurs two (!) world switches, i.e., from guest to host and vice versa. Considering how often ArmGicGetSupportedArchRevision () is called, it would be preferable to allow platforms that execute under virtualization to supply a custom version of this function. This patch introduces the ArmGicArchLib library class and default implementation, and moves just this function to it. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- ArmPkg/ArmPkg.dec | 1 + ArmPkg/ArmPkg.dsc | 1 + ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf | 33 ++++++++++++++++++++++ ArmPkg/Drivers/ArmGic/ArmGicLib.inf | 3 +- ArmPkg/Drivers/ArmGic/ArmGicSecLib.inf | 3 +- ArmPkg/Include/Library/ArmGicArchLib.h | 33 ++++++++++++++++++++++ ArmPkg/Include/Library/ArmGicLib.h | 14 +-------- ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc | 1 + ArmPlatformPkg/ArmPlatformPkg.dsc | 1 + .../ArmRealViewEbPkg/ArmRealViewEb.dsc.inc | 1 + ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc | 1 + .../ArmVirtualizationPkg/ArmVirtualization.dsc.inc | 1 + 12 files changed, 76 insertions(+), 17 deletions(-) create mode 100644 ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf create mode 100644 ArmPkg/Include/Library/ArmGicArchLib.h diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec index c8d7f50d8072..37d7fd1e50dd 100644 --- a/ArmPkg/ArmPkg.dec +++ b/ArmPkg/ArmPkg.dec @@ -38,6 +38,7 @@ UncachedMemoryAllocationLib|Include/Library/UncachedMemoryAllocationLib.h DefaultExceptionHandlerLib|Include/Library/DefaultExceptionHandlerLib.h ArmDisassemblerLib|Include/Library/ArmDisassemblerLib.h + ArmGicArchLib|Include/Library/ArmGicArchLib.h [Guids.common] gArmTokenSpaceGuid = { 0xBB11ECFE, 0x820F, 0x4968, { 0xBB, 0xA6, 0xF7, 0x6A, 0xFE, 0x30, 0x25, 0x96 } } diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc index be5126ccefd9..0e32f500c8b0 100644 --- a/ArmPkg/ArmPkg.dsc +++ b/ArmPkg/ArmPkg.dsc @@ -66,6 +66,7 @@ CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf + ArmGicArchLib|ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf diff --git a/ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf b/ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf new file mode 100644 index 000000000000..d71b2adc3027 --- /dev/null +++ b/ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf @@ -0,0 +1,33 @@ +#/* @file +# Copyright (c) 2015, Linaro Ltd. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +#*/ + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = ArmGicArchLib + FILE_GUID = cd67f41a-26e9-4482-90c9-a9aff803382a + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = ArmGicArchLib + +[Sources.ARM] + Arm/ArmGicArchLib.c + +[Sources.AARCH64] + AArch64/ArmGicArchLib.c + +[Packages] + MdePkg/MdePkg.dec + ArmPkg/ArmPkg.dec + +[LibraryClasses] + ArmGicLib diff --git a/ArmPkg/Drivers/ArmGic/ArmGicLib.inf b/ArmPkg/Drivers/ArmGic/ArmGicLib.inf index 9f466792e996..62f20eb55294 100644 --- a/ArmPkg/Drivers/ArmGic/ArmGicLib.inf +++ b/ArmPkg/Drivers/ArmGic/ArmGicLib.inf @@ -27,18 +27,17 @@ GicV2/ArmGicV2NonSecLib.c [Sources.ARM] - Arm/ArmGicArchLib.c GicV3/Arm/ArmGicV3.S | GCC GicV3/Arm/ArmGicV3.asm | RVCT [Sources.AARCH64] - AArch64/ArmGicArchLib.c GicV3/AArch64/ArmGicV3.S [LibraryClasses] ArmLib DebugLib IoLib + ArmGicArchLib [Packages] ArmPkg/ArmPkg.dec diff --git a/ArmPkg/Drivers/ArmGic/ArmGicSecLib.inf b/ArmPkg/Drivers/ArmGic/ArmGicSecLib.inf index 9097b37f2b81..efea9c828170 100644 --- a/ArmPkg/Drivers/ArmGic/ArmGicSecLib.inf +++ b/ArmPkg/Drivers/ArmGic/ArmGicSecLib.inf @@ -27,12 +27,10 @@ GicV2/ArmGicV2SecLib.c [Sources.ARM] - Arm/ArmGicArchLib.c GicV3/Arm/ArmGicV3.S | GCC GicV3/Arm/ArmGicV3.asm | RVCT [Sources.AARCH64] - AArch64/ArmGicArchLib.c GicV3/AArch64/ArmGicV3.S [Packages] @@ -45,6 +43,7 @@ ArmLib DebugLib IoLib + ArmGicArchLib [Pcd] gArmPlatformTokenSpaceGuid.PcdCoreCount diff --git a/ArmPkg/Include/Library/ArmGicArchLib.h b/ArmPkg/Include/Library/ArmGicArchLib.h new file mode 100644 index 000000000000..e6964a2d5790 --- /dev/null +++ b/ArmPkg/Include/Library/ArmGicArchLib.h @@ -0,0 +1,33 @@ +/** @file +* +* Copyright (c) 2015, Linaro Ltd. All rights reserved. +* +* This program and the accompanying materials are licensed and made available +* under the terms and conditions of the BSD License which accompanies this +* distribution. The full text of the license may be found at +* http://opensource.org/licenses/bsd-license.php +* +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +* +**/ + +#ifndef __ARM_GIC_ARCH_LIB_H__ +#define __ARM_GIC_ARCH_LIB_H__ + +// +// GIC definitions +// +typedef enum { + ARM_GIC_ARCH_REVISION_2, + ARM_GIC_ARCH_REVISION_3 +} ARM_GIC_ARCH_REVISION; + + +ARM_GIC_ARCH_REVISION +EFIAPI +ArmGicGetSupportedArchRevision ( + VOID + ); + +#endif diff --git a/ArmPkg/Include/Library/ArmGicLib.h b/ArmPkg/Include/Library/ArmGicLib.h index e2a4818c4c0c..a13f7d6c8b4a 100644 --- a/ArmPkg/Include/Library/ArmGicLib.h +++ b/ArmPkg/Include/Library/ArmGicLib.h @@ -15,13 +15,7 @@ #ifndef __ARMGIC_H #define __ARMGIC_H -// -// GIC definitions -// -typedef enum { - ARM_GIC_ARCH_REVISION_2, - ARM_GIC_ARCH_REVISION_3 -} ARM_GIC_ARCH_REVISION; +#include // // GIC Distributor @@ -103,12 +97,6 @@ typedef enum { // Bit Mask for #define ARM_GIC_ICCIAR_ACKINTID 0x3FF -ARM_GIC_ARCH_REVISION -EFIAPI -ArmGicGetSupportedArchRevision ( - VOID - ); - UINTN EFIAPI ArmGicGetInterfaceIdentification ( diff --git a/ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc b/ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc index 66a9797a1c03..8bcd8cc819af 100644 --- a/ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc +++ b/ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc @@ -78,6 +78,7 @@ ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf DmaLib|ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf + ArmGicArchLib|ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf diff --git a/ArmPlatformPkg/ArmPlatformPkg.dsc b/ArmPlatformPkg/ArmPlatformPkg.dsc index 81402da5b303..d332fed7b0bd 100644 --- a/ArmPlatformPkg/ArmPlatformPkg.dsc +++ b/ArmPlatformPkg/ArmPlatformPkg.dsc @@ -78,6 +78,7 @@ ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf DmaLib|ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf + ArmGicArchLib|ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc index 2a6a5b755af6..dd551739a6ce 100644 --- a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc +++ b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc @@ -61,6 +61,7 @@ ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf DmaLib|ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf + ArmGicArchLib|ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc index ddc796dc0410..9a0bbcd2056d 100644 --- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc +++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc @@ -67,6 +67,7 @@ ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf DmaLib|ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf + ArmGicArchLib|ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc index e7a03cd13d3a..c72591ff48b7 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc +++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc @@ -68,6 +68,7 @@ ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf DmaLib|ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf + ArmGicArchLib|ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf ArmHvcLib|ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf