summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorSimon Glass <[email protected]>2025-03-15 14:25:42 +0000
committerTom Rini <[email protected]>2025-04-03 11:41:55 -0600
commit8bd563707d909d7bb414de2c0ff4ab66eb8009db (patch)
tree2c2c62b064691532cc3f4721072d7ff3ab04533e /cmd
parent5ee60f3afa146e45752e1e99c382f18dd7f8200e (diff)
x86: Add functions to convert between mtrr size and mask
Rather than repeating the same code in several places, add some functions which can do the conversion. Use the cpu_phys_address_size() function to obtain the physical-address size, since it is more reliable with kvm, where the host CPU may have a different value from the emulation CPU. Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/x86/mtrr.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/cmd/x86/mtrr.c b/cmd/x86/mtrr.c
index b2afb598c73..93be84f74b8 100644
--- a/cmd/x86/mtrr.c
+++ b/cmd/x86/mtrr.c
@@ -14,7 +14,7 @@ static int do_mtrr_set(int cpu_select, uint reg, int argc, char *const argv[])
{
const char *typename = argv[0];
uint32_t start, size;
- uint64_t base, mask;
+ u64 base, mask;
int type = -1;
bool valid;
int ret;
@@ -31,8 +31,7 @@ static int do_mtrr_set(int cpu_select, uint reg, int argc, char *const argv[])
base = start | type;
valid = native_read_msr(MTRR_PHYS_MASK_MSR(reg)) & MTRR_PHYS_MASK_VALID;
- mask = ~((uint64_t)size - 1);
- mask &= (1ULL << CONFIG_CPU_ADDR_BITS) - 1;
+ mask = mtrr_to_mask(size);
if (valid)
mask |= MTRR_PHYS_MASK_VALID;