From patchwork Tue Feb 3 19:19:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 44287 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f199.google.com (mail-we0-f199.google.com [74.125.82.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 56F5C2034D for ; Tue, 3 Feb 2015 19:21:08 +0000 (UTC) Received: by mail-we0-f199.google.com with SMTP id u56sf22235037wes.2 for ; Tue, 03 Feb 2015 11:21:07 -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=d854N0AWsHLnGkJcsQQujiUq9hoTopIXObPuOv+vX/w=; b=ezFuka9kqzHiTmWWdgWe49IcvI6YKV6uWQRHcMNGbysm/Vi94J3WapeVCXBycK2BCU LVY0C+FV5A8v+Xh7j5vI8KbiNFEHgpeBbFZreo9I1BwUXcXgVYi+G0+ljXnazY8PeZb1 sZQcicY8voxWTApZ+8G901fZIQcuNypF98ysG/7In6ftizbvEoMH2oaSOBBG2WHgdc7t xseR/mFzu0LMPsPfTzfkgbykxKKi14JUGNHEvqU0aut0xRBZbu4cDEjrROTPKFVgs9EI /5CiG5EHVRLug1OT+X/8uvCr/zxNfaosA7HeQfvGKtq0RrdLfLWFmj5OlyVEb0NnLcgp 7zKA== X-Gm-Message-State: ALoCoQmoeIbjFeyPI3LPXhgdD0ek027h4CPU+g9Jji+jCchDpj2JwljQg4vsPmYiK5gVMprJmsL9 X-Received: by 10.152.121.65 with SMTP id li1mr3356242lab.0.1422991267625; Tue, 03 Feb 2015 11:21:07 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.170.193 with SMTP id ao1ls857872lac.20.gmail; Tue, 03 Feb 2015 11:21:07 -0800 (PST) X-Received: by 10.153.4.5 with SMTP id ca5mr23224504lad.28.1422991267481; Tue, 03 Feb 2015 11:21:07 -0800 (PST) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id r14si20139833lal.15.2015.02.03.11.21.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Feb 2015 11:21:07 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by mail-la0-f54.google.com with SMTP id hv19so53984827lab.13 for ; Tue, 03 Feb 2015 11:21:07 -0800 (PST) X-Received: by 10.152.219.37 with SMTP id pl5mr22546509lac.6.1422991267269; Tue, 03 Feb 2015 11:21:07 -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 h5csp33785lbj; Tue, 3 Feb 2015 11:21:06 -0800 (PST) X-Received: by 10.42.79.76 with SMTP id q12mr25694986ick.16.1422991265577; Tue, 03 Feb 2015 11:21:05 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id 1si10374582icx.94.2015.02.03.11.21.04 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 03 Feb 2015 11:21:05 -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-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YIj1t-0002KX-4v; Tue, 03 Feb 2015 19:20:57 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YIj1r-0002KN-5x for edk2-devel@lists.sourceforge.net; Tue, 03 Feb 2015 19:20:55 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of linaro.org designates 74.125.82.177 as permitted sender) client-ip=74.125.82.177; envelope-from=ard.biesheuvel@linaro.org; helo=mail-we0-f177.google.com; Received: from mail-we0-f177.google.com ([74.125.82.177]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YIj1q-0002RT-2G for edk2-devel@lists.sourceforge.net; Tue, 03 Feb 2015 19:20:55 +0000 Received: by mail-we0-f177.google.com with SMTP id l61so46784745wev.8 for ; Tue, 03 Feb 2015 11:20:48 -0800 (PST) X-Received: by 10.194.63.172 with SMTP id h12mr13008420wjs.32.1422991248137; Tue, 03 Feb 2015 11:20:48 -0800 (PST) Received: from ards-macbook-pro.local (73.233.28.37.rev.vodafone.pt. [37.28.233.73]) by mx.google.com with ESMTPSA id eb7sm25860139wic.11.2015.02.03.11.20.44 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Feb 2015 11:20:47 -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, stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com, anthony.perard@citrix.com, christoffer.dall@linaro.org, xen-devel@lists.xen.org, ilias.biris@linaro.org, julien.grall@linaro.org Date: Tue, 3 Feb 2015 19:19:49 +0000 Message-Id: <1422991212-9257-5-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1422991212-9257-1-git-send-email-ard.biesheuvel@linaro.org> References: <1422991212-9257-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 -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1YIj1q-0002RT-2G Subject: [edk2] [PATCH v3 04/27] ArmVirtualizationPkg: add GICv3 detection to VirtFdtDxe 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.215.54 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 This adds support for detecting the presence of a GICv3 interrupt controller from the device tree, and recording its distributor and redistributor base addresses in their respective PCDs. Contributed-under: TianoCore Contribution Agreement 1.0 Acked-by: Laszlo Ersek Signed-off-by: Ard Biesheuvel --- Removed Olivier's R-b due to the fact that this patch was changed to accomodate pending but not yet finalized changes to the GICv3 driver. I think that recording the distributor and redistributor base addresses should be sufficient in any case, but we may have to revisit this still when the GIC dust settles. .../ArmVirtualizationPkg/ArmVirtualizationQemu.dsc | 1 + .../ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c | 31 +++++++++++++++++++++- .../ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc index 32c8deb3b1d6..f38ffd034a59 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc +++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc @@ -172,6 +172,7 @@ # ARM General Interrupt Controller # gArmTokenSpaceGuid.PcdGicDistributorBase|0x0 + gArmTokenSpaceGuid.PcdGicRedistributorBase|0x0 gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x0 ## PL031 RealTimeClock diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c index 1d44f9ba02b3..e8bbea0847c0 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c +++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c @@ -46,6 +46,7 @@ typedef enum { PropertyTypeTimer, PropertyTypePsci, PropertyTypeFwCfg, + PropertyTypeGicV3, } PROPERTY_TYPE; typedef struct { @@ -62,6 +63,7 @@ STATIC CONST PROPERTY CompatibleProperties[] = { { PropertyTypeTimer, "arm,armv8-timer" }, { PropertyTypePsci, "arm,psci-0.2" }, { PropertyTypeFwCfg, "qemu,fw-cfg-mmio" }, + { PropertyTypeGicV3, "arm,gic-v3" }, { PropertyTypeUnknown, "" } }; @@ -114,7 +116,7 @@ InitializeVirtFdtDxe ( VIRTIO_TRANSPORT_DEVICE_PATH *DevicePath; EFI_HANDLE Handle; UINT64 RegBase; - UINT64 DistBase, CpuBase; + UINT64 DistBase, CpuBase, RedistBase; CONST INTERRUPT_PROPERTY *InterruptProp; INT32 SecIntrNum, IntrNum, VirtIntrNum, HypIntrNum; CONST CHAR8 *PsciMethod; @@ -256,6 +258,33 @@ InitializeVirtFdtDxe ( DEBUG ((EFI_D_INFO, "Found GIC @ 0x%Lx/0x%Lx\n", DistBase, CpuBase)); break; + case PropertyTypeGicV3: + // + // The GIC v3 DT binding describes a series of at least 3 physical base + // addresses: the distributor interface (GICD), at least one redistributor + // interface (GICR) and the CPU interface (GICC). + // Under virtualization, we assume that the first redistributor interface + // listed covers the boot CPU. Also, our GICv3 driver only supports the + // system register CPU interface, so we can safely ignore the MMIO version + // which is listed after the sequence of redistributor interfaces. + // This means we are only interested in the first two memory regions + // supplied, and ignore everything else. + // + ASSERT (Len >= 32); + + DistBase = fdt64_to_cpu (((UINT64 *)RegProp)[0]); + ASSERT (DistBase < MAX_UINT32); + + RedistBase = fdt64_to_cpu (((UINT64 *)RegProp)[2]); + ASSERT (RedistBase < MAX_UINT32); + + PcdSet32 (PcdGicDistributorBase, (UINT32)DistBase); + PcdSet32 (PcdGicRedistributorBase, (UINT32)RedistBase); + + DEBUG ((EFI_D_INFO, "Found GIC v3 (re)distributor @ 0x%Lx (0x%Lx)\n", + DistBase, RedistBase)); + break; + case PropertyTypeRtc: ASSERT (Len == 16); diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf index 514ce2fdf658..dbf0f8eb54bc 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf +++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf @@ -51,6 +51,7 @@ gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress gArmTokenSpaceGuid.PcdGicDistributorBase + gArmTokenSpaceGuid.PcdGicRedistributorBase gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum gArmTokenSpaceGuid.PcdArmArchTimerIntrNum