Felix Held has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/74619 )
Change subject: [RFC] include/cpu/amd/mtrr: rename TOP_MEM(2) and remove workaround
......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
i'm not entirely sure if this makes things more or less confusing
--
To view, visit https://review.coreboot.org/c/coreboot/+/74619
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ibad72dac17bd0b05734709d42c6802b7c8a87455
Gerrit-Change-Number: 74619
Gerrit-PatchSet: 1
Gerrit-Owner: Felix Held <felix-coreboot(a)felixheld.de>
Gerrit-Comment-Date: Thu, 20 Apr 2023 14:13:05 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Felix Held has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/74619 )
Change subject: [RFC] include/cpu/amd/mtrr: rename TOP_MEM(2) and remove workaround
......................................................................
[RFC] include/cpu/amd/mtrr: rename TOP_MEM(2) and remove workaround
Both AGESA.h and cpu/amd/mtrr.h defined TOP_MEM and TOP_MEM2, but since
it was defined as unsigned long in AGESA.h, a workaround was needed in
cpu/amd/mtrr.h to not have the build fail due to a non-identical
redefinition of TOP_MEM and TOP_MEM2. Just removing the workaround
without reaming the defines isn't trivially possible, since the
stoneyridge romstage.c still ends up including both definitions which
can't be easily worked around. Now all non-vendorcode coreboot code uses
TOP_MEM_MSR and TOP_MEM2_MSR while the vendorcode part uses TOP_MEM and
TOP_MEM2 to avoid this.
Signed-off-by: Felix Held <felix-coreboot(a)felixheld.de>
Change-Id: Ibad72dac17bd0b05734709d42c6802b7c8a87455
---
M src/drivers/amd/agesa/s3_mtrr.c
M src/include/cpu/amd/mtrr.h
2 files changed, 26 insertions(+), 11 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/19/74619/1
diff --git a/src/drivers/amd/agesa/s3_mtrr.c b/src/drivers/amd/agesa/s3_mtrr.c
index 51e8a4d..55c9c40 100644
--- a/src/drivers/amd/agesa/s3_mtrr.c
+++ b/src/drivers/amd/agesa/s3_mtrr.c
@@ -39,8 +39,8 @@
MTRR_PHYS_BASE(7),
MTRR_PHYS_MASK(7),
SYSCFG_MSR,
- TOP_MEM,
- TOP_MEM2,
+ TOP_MEM_MSR,
+ TOP_MEM2_MSR,
};
void backup_mtrr(void)
diff --git a/src/include/cpu/amd/mtrr.h b/src/include/cpu/amd/mtrr.h
index e96dc90..57edfe6 100644
--- a/src/include/cpu/amd/mtrr.h
+++ b/src/include/cpu/amd/mtrr.h
@@ -29,13 +29,8 @@
#define IORRBase_MSR(reg) (0xC0010016 + 2 * (reg))
#define IORRMask_MSR(reg) (0xC0010016 + 2 * (reg) + 1)
-#if defined(__ASSEMBLER__)
-#define TOP_MEM 0xC001001A
-#define TOP_MEM2 0xC001001D
-#else
-#define TOP_MEM 0xC001001Aul
-#define TOP_MEM2 0xC001001Dul
-#endif
+#define TOP_MEM_MSR 0xC001001A
+#define TOP_MEM2_MSR 0xC001001D
#if !defined(__ASSEMBLER__)
@@ -67,12 +62,12 @@
static inline uint32_t get_top_of_mem_below_4gb(void)
{
- return rdmsr(TOP_MEM).lo;
+ return rdmsr(TOP_MEM_MSR).lo;
}
static inline uint64_t get_top_of_mem_above_4g(void)
{
- msr_t msr = rdmsr(TOP_MEM2);
+ msr_t msr = rdmsr(TOP_MEM2_MSR);
return (uint64_t)msr.hi << 32 | msr.lo;
}
#endif
--
To view, visit https://review.coreboot.org/c/coreboot/+/74619
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ibad72dac17bd0b05734709d42c6802b7c8a87455
Gerrit-Change-Number: 74619
Gerrit-PatchSet: 1
Gerrit-Owner: Felix Held <felix-coreboot(a)felixheld.de>
Gerrit-MessageType: newchange
Attention is currently required from: Matt DeVillier.
Felix Held has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/74614 )
Change subject: soc/amd/stoneyridge/memmap: use get_top_of_mem_below_4gb
......................................................................
soc/amd/stoneyridge/memmap: use get_top_of_mem_below_4gb
Use get_top_of_mem_below_4gb instead of open-coding the functionality.
Signed-off-by: Felix Held <felix-coreboot(a)felixheld.de>
Change-Id: Ic673deb725a541c7535ae769f589cd82ea42a561
---
M src/soc/amd/stoneyridge/memmap.c
1 file changed, 13 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/14/74614/1
diff --git a/src/soc/amd/stoneyridge/memmap.c b/src/soc/amd/stoneyridge/memmap.c
index 8f73a8c..32d6d96 100644
--- a/src/soc/amd/stoneyridge/memmap.c
+++ b/src/soc/amd/stoneyridge/memmap.c
@@ -13,9 +13,7 @@
uintptr_t cbmem_top_chipset(void)
{
- msr_t tom = rdmsr(TOP_MEM);
-
- if (!tom.lo)
+ if (!get_top_of_mem_below_4gb())
return 0;
/* 8MB alignment to keep MTRR usage low */
--
To view, visit https://review.coreboot.org/c/coreboot/+/74614
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ic673deb725a541c7535ae769f589cd82ea42a561
Gerrit-Change-Number: 74614
Gerrit-PatchSet: 1
Gerrit-Owner: Felix Held <felix-coreboot(a)felixheld.de>
Gerrit-Reviewer: Matt DeVillier <matt.devillier(a)amd.corp-partner.google.com>
Gerrit-Attention: Matt DeVillier <matt.devillier(a)amd.corp-partner.google.com>
Gerrit-MessageType: newchange
Attention is currently required from: Jason Glenesk, Raul Rangel, Matt DeVillier, Fred Reitberger.
Felix Held has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/74612 )
Change subject: soc/amd/common/block/acpi/tables: use get_top_of_mem_[below,above]_4gb
......................................................................
soc/amd/common/block/acpi/tables: use get_top_of_mem_[below,above]_4gb
Use get_top_of_mem_below_4gb and get_top_of_mem_above_4g instead of
open-coding the functionality.
Signed-off-by: Felix Held <felix-coreboot(a)felixheld.de>
Change-Id: I35895340f6e747e2f5e1669d40f40b201d8c1845
---
M src/soc/amd/common/block/acpi/tables.c
1 file changed, 16 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/12/74612/1
diff --git a/src/soc/amd/common/block/acpi/tables.c b/src/soc/amd/common/block/acpi/tables.c
index b7c942c..17db421 100644
--- a/src/soc/amd/common/block/acpi/tables.c
+++ b/src/soc/amd/common/block/acpi/tables.c
@@ -40,7 +40,6 @@
/* Used by \_SB.PCI0._CRS */
void acpi_fill_root_complex_tom(const struct device *device)
{
- msr_t msr;
const char *scope;
assert(device);
@@ -49,9 +48,8 @@
assert(scope);
acpigen_write_scope(scope);
- msr = rdmsr(TOP_MEM);
- acpigen_write_name_dword("TOM1", msr.lo);
- msr = rdmsr(TOP_MEM2);
+ acpigen_write_name_dword("TOM1", get_top_of_mem_below_4gb());
+
/*
* Since XP only implements parts of ACPI 2.0, we can't use a qword
* here.
@@ -60,6 +58,6 @@
* Shift value right by 20 bit to make it fit into 32bit,
* giving us 1MB granularity and a limit of almost 4Exabyte of memory.
*/
- acpigen_write_name_dword("TOM2", (msr.hi << 12) | msr.lo >> 20);
+ acpigen_write_name_dword("TOM2", get_top_of_mem_above_4g() >> 20);
acpigen_pop_len();
}
--
To view, visit https://review.coreboot.org/c/coreboot/+/74612
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I35895340f6e747e2f5e1669d40f40b201d8c1845
Gerrit-Change-Number: 74612
Gerrit-PatchSet: 1
Gerrit-Owner: Felix Held <felix-coreboot(a)felixheld.de>
Gerrit-Reviewer: Fred Reitberger <reitbergerfred(a)gmail.com>
Gerrit-Reviewer: Jason Glenesk <jason.glenesk(a)gmail.com>
Gerrit-Reviewer: Matt DeVillier <matt.devillier(a)amd.corp-partner.google.com>
Gerrit-Reviewer: Raul Rangel <rrangel(a)chromium.org>
Gerrit-Attention: Jason Glenesk <jason.glenesk(a)gmail.com>
Gerrit-Attention: Raul Rangel <rrangel(a)chromium.org>
Gerrit-Attention: Matt DeVillier <matt.devillier(a)amd.corp-partner.google.com>
Gerrit-Attention: Fred Reitberger <reitbergerfred(a)gmail.com>
Gerrit-MessageType: newchange
Felix Held has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/74611 )
Change subject: nb/amd/pi/00730F01/northbridge: use get_top_of_mem_[below,above]_4gb
......................................................................
nb/amd/pi/00730F01/northbridge: use get_top_of_mem_[below,above]_4gb
Use get_top_of_mem_below_4gb and get_top_of_mem_above_4g instead of
open-coding the functionality.
Signed-off-by: Felix Held <felix-coreboot(a)felixheld.de>
Change-Id: I6332b051acf8d00ba6528360b18ea0d3c4dc30fd
---
M src/northbridge/amd/pi/00730F01/northbridge.c
1 file changed, 16 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/11/74611/1
diff --git a/src/northbridge/amd/pi/00730F01/northbridge.c b/src/northbridge/amd/pi/00730F01/northbridge.c
index d963171..d373493 100644
--- a/src/northbridge/amd/pi/00730F01/northbridge.c
+++ b/src/northbridge/amd/pi/00730F01/northbridge.c
@@ -538,13 +538,11 @@
static void northbridge_fill_ssdt_generator(const struct device *device)
{
- msr_t msr;
char pscope[] = "\\_SB.PCI0";
acpigen_write_scope(pscope);
- msr = rdmsr(TOP_MEM);
- acpigen_write_name_dword("TOM1", msr.lo);
- msr = rdmsr(TOP_MEM2);
+ acpigen_write_name_dword("TOM1", get_top_of_mem_below_4gb());
+
/*
* Since XP only implements parts of ACPI 2.0, we can't use a qword
* here.
@@ -553,7 +551,7 @@
* Shift value right by 20 bit to make it fit into 32bit,
* giving us 1MB granularity and a limit of almost 4Exabyte of memory.
*/
- acpigen_write_name_dword("TOM2", (msr.hi << 12) | msr.lo >> 20);
+ acpigen_write_name_dword("TOM2", get_top_of_mem_above_4g() >> 20);
acpigen_pop_len();
}
--
To view, visit https://review.coreboot.org/c/coreboot/+/74611
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I6332b051acf8d00ba6528360b18ea0d3c4dc30fd
Gerrit-Change-Number: 74611
Gerrit-PatchSet: 1
Gerrit-Owner: Felix Held <felix-coreboot(a)felixheld.de>
Gerrit-MessageType: newchange