From patchwork Tue Mar 24 19:15:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 46282 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f198.google.com (mail-we0-f198.google.com [74.125.82.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1E4E521596 for ; Tue, 24 Mar 2015 19:16:16 +0000 (UTC) Received: by wesq59 with SMTP id q59sf414233wes.1 for ; Tue, 24 Mar 2015 12:16:15 -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: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=NxwzVu2LGJL6GaegpinXXzBVsOo2jxfnntZQETUqG6U=; b=Wp/OrLd4cMoSxxyC8+YlcskhW+qEwvqLJ4HOZGxx56K4HG6dwW85fcpRHvlalHgySm vOmpili+RnWxKWusEq4y1xNofnn23OxJEDtDlc0q0+Ul2YuwIW3Huo5NRB37jn4iHfES raThWSshosE9P1+ZgblwL0NTtXJEuv3lxpmweqcL0qBSTUvG94k0WY4KOCel0TuT6pRk prZxrN+QGx/V8QJPK4ACEUBine7UHTlEX+c7zgZGbNbyy4avZNe0L4r26I/mmn4+yDvN 8BQ0RVPCFdLNL6N7jZ3JtkDWoMUDhi7mCf2ea/TFzMryMU5PQBVrojTwcHjxsSrGKwrd ZJNg== X-Gm-Message-State: ALoCoQni17UBvRX6ge7753WJI6NXdCff+QJNTE8AzEVICnI1EGe576Uz9GQLN9ooJN7+6zKZSWMY X-Received: by 10.180.23.40 with SMTP id j8mr388782wif.2.1427224575447; Tue, 24 Mar 2015 12:16:15 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.1.135 with SMTP id 7ls10491lam.8.gmail; Tue, 24 Mar 2015 12:16:15 -0700 (PDT) X-Received: by 10.152.4.39 with SMTP id h7mr5252681lah.58.1427224575162; Tue, 24 Mar 2015 12:16:15 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id q8si135993lah.51.2015.03.24.12.16.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Mar 2015 12:16:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by laae1 with SMTP id e1so2110686laa.2 for ; Tue, 24 Mar 2015 12:16:15 -0700 (PDT) X-Received: by 10.152.22.67 with SMTP id b3mr4906683laf.117.1427224575060; Tue, 24 Mar 2015 12:16:15 -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.57.201 with SMTP id k9csp1648045lbq; Tue, 24 Mar 2015 12:16:14 -0700 (PDT) X-Received: by 10.107.7.18 with SMTP id 18mr8671382ioh.69.1427224571580; Tue, 24 Mar 2015 12:16:11 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id y7si518440igl.37.2015.03.24.12.16.10 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 24 Mar 2015 12:16:11 -0700 (PDT) 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 1YaUJ0-0007mM-R6; Tue, 24 Mar 2015 19:16:02 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YaUJ0-0007mH-25 for edk2-devel@lists.sourceforge.net; Tue, 24 Mar 2015 19:16:02 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of linaro.org designates 74.125.82.170 as permitted sender) client-ip=74.125.82.170; envelope-from=ard.biesheuvel@linaro.org; helo=mail-we0-f170.google.com; Received: from mail-we0-f170.google.com ([74.125.82.170]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YaUIz-0003H0-2t for edk2-devel@lists.sourceforge.net; Tue, 24 Mar 2015 19:16:02 +0000 Received: by weoy45 with SMTP id y45so2061115weo.2 for ; Tue, 24 Mar 2015 12:15:55 -0700 (PDT) X-Received: by 10.194.159.105 with SMTP id xb9mr10881043wjb.156.1427224555105; Tue, 24 Mar 2015 12:15:55 -0700 (PDT) Received: from ards-macbook-pro.local ([90.174.5.10]) by mx.google.com with ESMTPSA id eo1sm824517wib.16.2015.03.24.12.15.53 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 24 Mar 2015 12:15:54 -0700 (PDT) From: Ard Biesheuvel To: lersek@redhat.com, ian.campbell@citrix.com, julien.grall@linaro.org, edk2-devel@lists.sourceforge.net Date: Tue, 24 Mar 2015 20:15:44 +0100 Message-Id: <1427224544-29955-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1427224544-29955-1-git-send-email-ard.biesheuvel@linaro.org> References: <1427224544-29955-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: 1YaUIz-0003H0-2t Cc: stefano.stabellini@eu.citrix.com Subject: [edk2] [PATCH 3/3] ArmVirtualizationPkg: wipe caches by VA before enabling the MMU 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.52 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 As a guest under virtualization, it is not sufficient to enable the caches using the architecturally mandated procedure of invalidating by set/way. We also have to explicitly invalidate the stack and heap regions by virtual address, to prevent dirty cachelines in system caches or on other CPUs to shadow the data that we have written straight to main memory while executing with the MMU off. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- .../ArmVirtualizationPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf | 1 + ArmPlatformPkg/ArmVirtualizationPkg/PrePi/PrePi.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf b/ArmPlatformPkg/ArmVirtualizationPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf index 86cf870b79ac..16023382a679 100755 --- a/ArmPlatformPkg/ArmVirtualizationPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf +++ b/ArmPlatformPkg/ArmVirtualizationPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf @@ -55,6 +55,7 @@ PrePiHobListPointerLib PlatformPeiLib MemoryInitPeiLib + CacheMaintenanceLib [Ppis] gArmMpCoreInfoPpiGuid diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/PrePi/PrePi.c b/ArmPlatformPkg/ArmVirtualizationPkg/PrePi/PrePi.c index 0772805890f2..99f23a665f46 100755 --- a/ArmPlatformPkg/ArmVirtualizationPkg/PrePi/PrePi.c +++ b/ArmPlatformPkg/ArmVirtualizationPkg/PrePi/PrePi.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -117,12 +118,15 @@ PrePiMain ( ); PrePeiSetHobList (HobList); + StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize); + InvalidateDataCacheRange ((VOID *) StacksBase, StacksSize); + InvalidateDataCacheRange ((VOID *) UefiMemoryBase, FixedPcdGet32 (PcdSystemMemoryUefiRegionSize)); + // Initialize MMU and Memory HOBs (Resource Descriptor HOBs) Status = MemoryPeim (UefiMemoryBase, FixedPcdGet32 (PcdSystemMemoryUefiRegionSize)); ASSERT_EFI_ERROR (Status); // Create the Stacks HOB (reserve the memory for all stacks) - StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize); BuildStackHob (StacksBase, StacksSize); // Declare the Global Variable HOB