From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::444; helo=mail-wr1-x444.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9086321A02937 for ; Wed, 28 Nov 2018 11:16:58 -0800 (PST) Received: by mail-wr1-x444.google.com with SMTP id j10so27462703wru.4 for ; Wed, 28 Nov 2018 11:16:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3LcTY6BHxmwlSdVt5d+w6c8AXsD4V4klKyBvu/ZB/3I=; b=eglo64mdpK1R2gQ+YybGWphhjT6vxXM7LbXqJpKEch7JlWii5TvdFKMEuE1SDs4p8k di0s77ttC4mn8pgTQ4qeJ378BJV4Vn/xj6R/p75NODycp9bAvzFzJjQbVrnERXMUmTOC WBIvYMaiU3+0fl2QQuMobPXpvh7BGYPB2JwAY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3LcTY6BHxmwlSdVt5d+w6c8AXsD4V4klKyBvu/ZB/3I=; b=ReA3r0nRb7OBZkR+bJ8a/QkM29qW0bchIyroBQNRJSusQaNnQ77rp6K0zCLYH9C+Fc rUdxdjEirR1qZJ0W3+UtSoIM059k+RWun4Oe45/0q3qHnbE/6lFfwC14GDGXqUZ1z1YW pecKYWMysXnQjvHlwjIbxtrtCeFQ1MLj4jYpBpu2KE/sWRWsfiROdshhGAfErdI4juwf mTv8lg9aAZvPc7o2ak1BjEnAMKE3NgNoYyw2Pti70h0k7UupF7vqkFsFvjkbtGtfJGXz 6mnAAEiAihjpEiRYCE/oDet7jiukGOCZ6v0rP+uEgg6qltCGFEXTgjKxiiDuAH3M4LCR eYdw== X-Gm-Message-State: AA+aEWbeasT6744I2aqwf5vhHe8DoN/cRnq4iO1trvLCfw6pYceTD+Ly mmjeM9HgBGLMM0b9T0DURKBKcI01RqI= X-Google-Smtp-Source: AFSGD/Wo5JDvOinocDfBV+umA273Er6hSafp/gJEnwHlcZ8FXBHI2V+Y7JPvm4zSHGCN6vQcTrzM+A== X-Received: by 2002:a5d:4303:: with SMTP id h3mr28581512wrq.273.1543432616768; Wed, 28 Nov 2018 11:16:56 -0800 (PST) Received: from harold.home ([2a01:cb1d:112:6f00:296f:238b:c20d:3626]) by smtp.gmail.com with ESMTPSA id b18sm6273104wrr.43.2018.11.28.11.16.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Nov 2018 11:16:55 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Cc: Ard Biesheuvel , Laszlo Ersek , Eric Auger , Andrew Jones , Philippe Mathieu-Daude Date: Wed, 28 Nov 2018 20:16:45 +0100 Message-Id: <20181128191646.31526-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181128191646.31526-1-ard.biesheuvel@linaro.org> References: <20181128191646.31526-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Subject: [RFC PATCH 1/2] ArmVirtPkg/NorFlashQemuLib: disregard our primary FV X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Nov 2018 19:16:59 -0000 Content-Transfer-Encoding: 8bit The primary FV contains the firmware boot image, which is not runtime updatable in our case. So exposing it to the NOR flash driver is undesirable, since it may attempt to modify the NOR flash contents. It is also rather pointless, since we don't keep anything there that we don't already expose via the FVB protocol instances that DXE core creates for us based on the FV HOBs (and so there is nothing the partition or file system drivers could potentially attach to via the block I/O and disk I/O protocol instances that the NOR flash driver creates) So let's disregard the NOR flash block that covers the primary FV. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf | 5 +++++ ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c | 13 +++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf index d86ff36dbd58..c5752a243e6b 100644 --- a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf +++ b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf @@ -28,6 +28,7 @@ [Sources.common] [Packages] MdePkg/MdePkg.dec ArmPlatformPkg/ArmPlatformPkg.dec + ArmPkg/ArmPkg.dec ArmVirtPkg/ArmVirtPkg.dec [LibraryClasses] @@ -40,3 +41,7 @@ [Protocols] [Depex] gFdtClientProtocolGuid + +[Pcd] + gArmTokenSpaceGuid.PcdFvBaseAddress + gArmTokenSpaceGuid.PcdFvSize diff --git a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c index 2678f57eaaad..72b47bdb5a78 100644 --- a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c +++ b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c @@ -75,13 +75,22 @@ NorFlashPlatformGetDevices ( Size = SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[2])); Reg += 4; + PropSize -= 4 * sizeof (UINT32); + + // + // Disregard any flash devices that overlap with the primary FV. + // The firmware is not updatable from inside the guest anyway. + // + if ((PcdGet64 (PcdFvBaseAddress) + PcdGet32 (PcdFvSize) >= Base) && + (Base + Size) >= PcdGet64 (PcdFvBaseAddress)) { + continue; + } + mNorFlashDevices[Num].DeviceBaseAddress = (UINTN)Base; mNorFlashDevices[Num].RegionBaseAddress = (UINTN)Base; mNorFlashDevices[Num].Size = (UINTN)Size; mNorFlashDevices[Num].BlockSize = QEMU_NOR_BLOCK_SIZE; Num++; - - PropSize -= 4 * sizeof (UINT32); } } -- 2.19.1