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::342; helo=mail-wm1-x342.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) (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 15F37211B6C33 for ; Mon, 14 Jan 2019 09:02:15 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id d15so304490wmb.3 for ; Mon, 14 Jan 2019 09:02:14 -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; bh=XdQ5sklo+Qz80Ae4y52qxp7E/lOGURYTmKjPIcTjcjY=; b=fnK2KzAD8RO2pk1jyat0xNdFXoepJ6zaju8s5+evqdlEOoJg89O9Fc+1om6Ekryn0a 2RJAcfyMVSVWoXryTx5Zn+WtI+ExZHBFjrVEc51ynKT9WcdMgLe9vW/vaVUButSKHINN vhIqBBlinvpLSWpErFxULj1MZlqYH0QOSc/6I= 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; bh=XdQ5sklo+Qz80Ae4y52qxp7E/lOGURYTmKjPIcTjcjY=; b=ihtotBQYHzhwq7wt6DEZ5uk0Q5uQbHS4f33SnyIEjg8P8E77HziRfqOfLbzcapMYSU JDCvencAnUKa+36q1jdTy7V2mRSWf/mlCJrgk92gv95vkH2/SWL0x9PUe9q0XVjt4qeV pB8F8ILLT0VzEozlyv2/LKHHvEkuoIwS+Jxb33oD9SbZUJfmYSQVFgj3eJveusKTD5Uf tFWO4rlyZxzykM/3wztcqjNRjv3XZhqoB6cktq4YwRver4zK6GmugQ/DBzvi2uDumS4f 5A+rHQxZyodG8eXEzOred8HiGwvNyNU03XNbhOCGOrvq9DSvZKneii37SPE0Y2tIdshq dmgw== X-Gm-Message-State: AJcUukdZYqaGEKNzCZKZTrSYVatzFth/XjhVq6/znTkWkRAvmgGBPlA+ UspIg7BFWTd9RcR57J6R0ZSUOYoCYpwMtw== X-Google-Smtp-Source: ALg8bN4LmRw4Fo72DxpLD55hxgSGXOCvUBuAJhHyVQZ0T2jUE7kiTmt5nLic6s5HifbyfyD04CmtOw== X-Received: by 2002:a1c:e18a:: with SMTP id y132mr97077wmg.48.1547485333205; Mon, 14 Jan 2019 09:02:13 -0800 (PST) Received: from dogfood.home ([2a01:cb1d:112:6f00:2ced:5cd0:34f4:7bab]) by smtp.gmail.com with ESMTPSA id h184sm17224319wmf.0.2019.01.14.09.02.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Jan 2019 09:02:12 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Mon, 14 Jan 2019 18:02:01 +0100 Message-Id: <20190114170205.9748-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190114170205.9748-1-ard.biesheuvel@linaro.org> References: <20190114170205.9748-1-ard.biesheuvel@linaro.org> Subject: [PATCH edk2-platforms 4/8] Silicon/SynQuacerMemoryInitPeiLib: don't map memory above MAX_ALLOC_ADDRESS 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: Mon, 14 Jan 2019 17:02:15 -0000 When encountering memory that is above the threshold of what we can map, don't add it to the virtual memory table. This table is only used by the early MMU code that creates the 1:1 mapping, and since it cannot be mapped in the first place, there is no point. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c index 1402ecafce4a..3955b6df84a0 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c @@ -156,17 +156,22 @@ DeclareDram ( DramDescriptor = *VirtualMemoryTable + ARRAY_SIZE (mVirtualMemoryTable); - for (Idx = 0; Idx < RegionCount; Idx++, DramDescriptor++) { + for (Idx = 0; Idx < RegionCount; Idx++) { Status = DramInfo->GetRegion (Idx, &Base, &Size); ASSERT_EFI_ERROR (Status); BuildResourceDescriptorHob (EFI_RESOURCE_SYSTEM_MEMORY, mDramResourceAttributes, Base, Size); + if (Base > MAX_ALLOC_ADDRESS - Size + 1) { + continue; + } + DramDescriptor->PhysicalBase = Base; DramDescriptor->VirtualBase = Base; - DramDescriptor->Length = Size; + DramDescriptor->Length = MIN (Size, MAX_ALLOC_ADDRESS - Base + 1); DramDescriptor->Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK; + DramDescriptor++; } DramDescriptor->PhysicalBase = 0; -- 2.17.1