summaryrefslogtreecommitdiffstats
path: root/src/security
diff options
context:
space:
mode:
authorKrystian Hebel <krystian.hebel@3mdeb.com>2024-05-08 16:17:00 +0200
committerFelix Held <felix-coreboot@felixheld.de>2024-05-29 13:04:30 +0000
commitfda9d75d90dfb8b5a441eea9d108e6f075087dc0 (patch)
tree38ac106080fbdaa5d03896235e2b2dc00074de42 /src/security
parentb1bd442ca95bd05c40b6cd990f196514d091860f (diff)
downloadcoreboot-fda9d75d90dfb8b5a441eea9d108e6f075087dc0.tar.gz
coreboot-fda9d75d90dfb8b5a441eea9d108e6f075087dc0.tar.bz2
coreboot-fda9d75d90dfb8b5a441eea9d108e6f075087dc0.zip
cpu/x86/pae/pgtbl.c: extract reusable code from memset_pae()
Code dealing with PAE can be used outside of memset_pae(). This change extracts creation of identity mapped pagetables to init_pae_pagetables() and mapping of single 2 MiB map to pae_map_2M_page(). Both functions are exported in include/cpu/x86/pae.h to allow use outside of pgtbl.c. MEMSET_PAE_* macros were renamed to PAE_* since they no longer apply only to memset_pae(). Change-Id: I8aa80eb246ff0e77e1f51d71933d3d00ab75aaeb Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/82249 Reviewed-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/security')
-rw-r--r--src/security/memory/memory_clear.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/security/memory/memory_clear.c b/src/security/memory/memory_clear.c
index 996b1d380253..9af3205b0ee2 100644
--- a/src/security/memory/memory_clear.c
+++ b/src/security/memory/memory_clear.c
@@ -4,10 +4,10 @@
#include <cpu/x86/pae.h>
#else
#define memset_pae(a, b, c, d, e) 0
-#define MEMSET_PAE_PGTL_ALIGN 0
-#define MEMSET_PAE_PGTL_SIZE 0
-#define MEMSET_PAE_VMEM_ALIGN 0
-#define MEMSET_PAE_VMEM_SIZE 0
+#define PAE_PGTL_ALIGN 0
+#define PAE_PGTL_SIZE 0
+#define PAE_VMEM_ALIGN 0
+#define PAE_VMEM_SIZE 0
#endif
#include <memrange.h>
@@ -84,15 +84,12 @@ static void clear_memory(void *unused)
if (ENV_X86) {
/* Find space for PAE enabled memset */
- pgtbl = get_free_memory_range(&mem, MEMSET_PAE_PGTL_ALIGN,
- MEMSET_PAE_PGTL_SIZE);
+ pgtbl = get_free_memory_range(&mem, PAE_PGTL_ALIGN, PAE_PGTL_SIZE);
/* Don't touch page tables while clearing */
- memranges_insert(&mem, pgtbl, MEMSET_PAE_PGTL_SIZE,
- BM_MEM_TABLE);
+ memranges_insert(&mem, pgtbl, PAE_PGTL_SIZE, BM_MEM_TABLE);
- vmem_addr = get_free_memory_range(&mem, MEMSET_PAE_VMEM_ALIGN,
- MEMSET_PAE_VMEM_SIZE);
+ vmem_addr = get_free_memory_range(&mem, PAE_VMEM_ALIGN, PAE_VMEM_SIZE);
printk(BIOS_SPEW, "%s: pgtbl at %p, virt memory at %p\n",
__func__, (void *)pgtbl, (void *)vmem_addr);
@@ -128,9 +125,9 @@ static void clear_memory(void *unused)
if (ENV_X86) {
/* Clear previously skipped memory reserved for pagetables */
printk(BIOS_DEBUG, "%s: Clearing DRAM %016lx-%016lx\n",
- __func__, pgtbl, pgtbl + MEMSET_PAE_PGTL_SIZE);
+ __func__, pgtbl, pgtbl + PAE_PGTL_SIZE);
- memset((void *)pgtbl, 0, MEMSET_PAE_PGTL_SIZE);
+ memset((void *)pgtbl, 0, PAE_PGTL_SIZE);
}
memranges_teardown(&mem);