From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.groups.io with SMTP id smtpd.web12.3014.1585392208679388492 for ; Sat, 28 Mar 2020 03:43:29 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=MQVBkqln; spf=pass (domain: linaro.org, ip: 209.85.221.68, mailfrom: ard.biesheuvel@linaro.org) Received: by mail-wr1-f68.google.com with SMTP id a25so14840943wrd.0 for ; Sat, 28 Mar 2020 03:43:28 -0700 (PDT) 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=6LRgYmtUQbZoTOi9D7YVBN9C1lL9P+lfAaAF2oDRQPY=; b=MQVBkqln2Ban38FgEMwPBXftArPYYuTP+ysljw/YxVQtAf3nXvEPtlGqI+y+PK7cpC 7QvWRClmXeQR9FB8ihG6zJZsIPp7vxjmW6XKHXA2ssKFTjQhsYdu6mXFCcvOfT4vyjUK 2pm68mgp5Le+cdUPWPKKue0GtSExwUrh5SguQM3ew5y61i1kMii4GcpUTKEHBJFgledv XNjGWs7TbRdZctY4G1JhQrJHRqG6Xd/GOPy2tDOO0/W0ck99BYvge9i61xx1NeA9Olzk hTd01jeW5yWY716pbVYNybkY+IrZCirncgKmSQTA+8KBUjhe9rCVzVPOk70b1grEbHTy Yx8A== 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=6LRgYmtUQbZoTOi9D7YVBN9C1lL9P+lfAaAF2oDRQPY=; b=EDdTthUbzI6azL9jSOaHVBkCSscrUrgDoqClvDvoHFzRSKcZ5jM1zggGumaDts7/ZK YkM2B349eulrotAoavv6zwGegSQ9qGbo4TyzstaLckRJK1kobfLTubCEF6aIayoKV3sB NUTgRHd4FC55QkHilNsQoMf5e5Cs7Hwodb4NqHbJspcFUF3Xh86kKjMsml8EFmMMweKK FzHS++zIj0S+5hfmOc1eZ5GeHI+qLaKXTJf1v5KAuEU/m95CecEDsSOIIqtfvq1RuwTQ n6g9tqMFa6n0RGl25msWQ498etuJhiQsDHl5sGEYRP/Wvm3FD4IH2mpbF2VlKTh0+CGr 8gxg== X-Gm-Message-State: ANhLgQ2Op6dmjksR4RYJ/FP0hEmwZXG4AwJ/4lGiSS4TjJIWjIhcu/Ny InHJz82QeYXOMFTTFHXIKwxf/QsuqJw6KA== X-Google-Smtp-Source: ADFU+vuYxCZSjC1vT9zD04kCiz8tkRapZ0EAcO3/PO6hKUfuO7bRalt/ZTJGjUu35jv6cG1NCiIxmA== X-Received: by 2002:adf:f1ce:: with SMTP id z14mr4378776wro.68.1585392207063; Sat, 28 Mar 2020 03:43:27 -0700 (PDT) Return-Path: Received: from e123331-lin.home (amontpellier-657-1-18-247.w109-210.abo.wanadoo.fr. [109.210.65.247]) by smtp.gmail.com with ESMTPSA id a13sm4756386wrt.64.2020.03.28.03.43.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Mar 2020 03:43:26 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif@nuviainc.com, Ard Biesheuvel Subject: [PATCH 1/5] ArmPkg/CpuDxe: use private copy of GetRootTranslationTableInfo() Date: Sat, 28 Mar 2020 11:43:17 +0100 Message-Id: <20200328104321.8668-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200328104321.8668-1-ard.biesheuvel@linaro.org> References: <20200328104321.8668-1-ard.biesheuvel@linaro.org> Before getting rid of GetRootTranslationTableInfo() and the related LookupAddresstoRootTable() in AARCH64's version of ArmMmuLib, add a version of the former to CpuDxe, which will be its only remaining user. While at it, simplify it a bit, since in the CpuDxe cases, both OUT arguments are always provided. Signed-off-by: Ard Biesheuvel --- ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c | 15 +++++++++++++++ ArmPkg/Drivers/CpuDxe/CpuDxe.h | 7 ------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c index 3b6c5e733709..24eb1c4221e3 100644 --- a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c +++ b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c @@ -15,6 +15,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define TT_ATTR_INDX_INVALID ((UINT32)~0) +#define MIN_T0SZ 16 +#define BITS_PER_LEVEL 9 + +STATIC +VOID +GetRootTranslationTableInfo ( + IN UINTN T0SZ, + OUT UINTN *RootTableLevel, + OUT UINTN *RootTableEntryCount + ) +{ + *RootTableLevel = (T0SZ - MIN_T0SZ) / BITS_PER_LEVEL; + *RootTableEntryCount = TT_ENTRY_COUNT >> (T0SZ - MIN_T0SZ) % BITS_PER_LEVEL; +} + STATIC UINT64 GetFirstPageAttribute ( diff --git a/ArmPkg/Drivers/CpuDxe/CpuDxe.h b/ArmPkg/Drivers/CpuDxe/CpuDxe.h index b627c3c50ff8..3fe5c24d5e5b 100644 --- a/ArmPkg/Drivers/CpuDxe/CpuDxe.h +++ b/ArmPkg/Drivers/CpuDxe/CpuDxe.h @@ -134,13 +134,6 @@ GetMemoryRegion ( OUT UINTN *RegionAttributes ); -VOID -GetRootTranslationTableInfo ( - IN UINTN T0SZ, - OUT UINTN *TableLevel, - OUT UINTN *TableEntryCount - ); - EFI_STATUS SetGcdMemorySpaceAttributes ( IN EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap, -- 2.17.1