From 614568ec5876372e0acb0120e5f397074b0115c8 Mon Sep 17 00:00:00 2001 From: Felix Held Date: Thu, 28 Sep 2023 20:28:40 +0200 Subject: [PATCH] soc/amd/common/noncar/cpu: simplify get_reserved_phys_addr_bits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simplify the code a bit by returning 0 early in the function when the SYSCFG_MSR_SMEE bit isn't set. Signed-off-by: Felix Held Suggested-by: Jeremy Compostella Change-Id: I7536b82d98e55c51105448090d1206e1ed7f62d8 Reviewed-on: https://review.coreboot.org/c/coreboot/+/78176 Reviewed-by: Jérémy Compostella Reviewed-by: Matt DeVillier Tested-by: build bot (Jenkins) --- src/soc/amd/common/block/cpu/noncar/cpu.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/soc/amd/common/block/cpu/noncar/cpu.c b/src/soc/amd/common/block/cpu/noncar/cpu.c index eefd62fcf0..136cb42e0e 100644 --- a/src/soc/amd/common/block/cpu/noncar/cpu.c +++ b/src/soc/amd/common/block/cpu/noncar/cpu.c @@ -38,10 +38,9 @@ void set_cstate_io_addr(void) /* Number of most significant physical address bits reserved for secure memory encryption */ unsigned int get_reserved_phys_addr_bits(void) { - if (rdmsr(SYSCFG_MSR).raw & SYSCFG_MSR_SMEE) - return (cpuid_ebx(CPUID_EBX_MEM_ENCRYPT) & - CPUID_EBX_MEM_ENCRYPT_ADDR_BITS_MASK) >> - CPUID_EBX_MEM_ENCRYPT_ADDR_BITS_SHIFT; - else + if (!(rdmsr(SYSCFG_MSR).raw & SYSCFG_MSR_SMEE)) return 0; + + return (cpuid_ebx(CPUID_EBX_MEM_ENCRYPT) & CPUID_EBX_MEM_ENCRYPT_ADDR_BITS_MASK) >> + CPUID_EBX_MEM_ENCRYPT_ADDR_BITS_SHIFT; }