coreboot-kgpe-d16/src
Subrata Banik 36faccfec5 include/cpu/x86: Skip wbinvd on CPUs with cache self-snooping (SS)
This patch refers and backport some of previous work from Linux Kernel
(https://lore.kernel.org/all/1561689337-19390-3-git-send-email-ricardo.
neri-calderon@linux.intel.com/T/#u) that optimizes the MTRR register
programming in multi-processor systems by relying on the CPUID
(self-snoop feature supported).

Refer to the details below:

Programming MTRR registers in multi-processor systems is a rather
lengthy process as it involves flushing caches. As a result, the
process may take a considerable amount of time. Furthermore, all
processors must program these registers serially.

`wbinvd` instruction is used to invalidate the cache line to ensure
that all modified data is written back to memory. All logical processors
are stopped from executing until after the write-back and invalidate
operation is completed.

The amount of time or cycles for WBINVD to complete will vary due to the
size of different cache hierarchies and other factors. As a consequence,
the use of the WBINVD instruction can have an impact on response time.

As per measurements, around 98% of the time needed by the procedure to
program MTRRs in multi-processor systems is spent flushing caches with
wbinvd(). As per the Section 11.11.8 of the Intel 64 and IA 32
Architectures Software Developer's Manual, it is not necessary to flush
caches if the CPU supports cache self-snooping (ss).

"Flush all caches using the WBINVD instructions. Note on a processor
that supports self-snooping, CPUID feature flag bit 27, this step is
unnecessary."

Thus, skipping the cache flushes can reduce by several tens of
milliseconds the time needed to complete the programming of the MTRR
registers:

Platform                              Before	 After
  12-core (14 Threads) MeteorLake      35ms       1ms

BUG=b:260455826
TEST=Able to build and boot google/rex.

Change-Id: I83cac2b1e1707bbb1bc1bba82cf3073984e9768f
Signed-off-by: Subrata Banik <subratabanik@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/75511
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jérémy Compostella <jeremy.compostella@intel.com>
Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
Reviewed-by: Himanshu Sahdev <himanshu.sahdev@intel.com>
Reviewed-by: Tarun Tuli <taruntuli@google.com>
2023-06-01 07:52:12 +00:00
..
acpi acpi/acpigen: rename and clarify bus/IO/MMIO resource producer functions 2023-05-30 16:05:35 +00:00
arch libpayload;arch,cpu/x86: drop USE_MARCH_586 Kconfig option 2023-05-27 00:29:02 +00:00
commonlib commonlib/bsd/tpm_log_defs.h: replace macro with enum 2023-05-28 20:10:20 +00:00
console console: Deselect using ANSI escape characters when SimNow is used 2023-03-30 13:36:35 +00:00
cpu cpu/x86/mp_init: Use clflush to write SIPI data back to RAM 2023-05-31 14:22:31 +00:00
device device/dram: Update RDIMM classification from RIMM to DIMM 2023-05-31 18:52:39 +00:00
drivers drivers/spi/spi_sdcard.c: Fix set but unused variable 2023-05-26 14:53:06 +00:00
ec ec/purism,system76: Provide probe for fixed Librem-EC jack detect 2023-05-26 14:57:27 +00:00
include include/cpu/x86: Skip wbinvd on CPUs with cache self-snooping (SS) 2023-06-01 07:52:12 +00:00
lib lib/ubsan.c: Restore Jonas' copyright 2023-05-22 12:33:32 +00:00
mainboard mb/google/rex/var/screebo: Add MIPI camera device 2023-05-31 18:55:30 +00:00
northbridge nb/intel/haswell: Allow using Broadwell MRC.bin 2023-05-23 08:25:00 +00:00
sbom payloads/Yabits: Remove deprecated Yabits Payload 2023-02-17 01:21:43 +00:00
security security/tpm: make usage of PCRs configurable via Kconfig 2023-04-10 04:01:08 +00:00
soc soc/amd/picasso/acpi/sb_pci0_fch: replace Memory32Fixed with DWordMemory 2023-05-31 13:46:26 +00:00
southbridge nb/intel/haswell: Allow using Broadwell MRC.bin 2023-05-23 08:25:00 +00:00
superio superio/common: Support more than one SuperIO in ACPI 2023-05-26 19:21:12 +00:00
vendorcode vc/intel/fsp/fsp20/meteorlake: Add SaGvWpMask 2023-05-25 05:02:32 +00:00
Kconfig Kconfig: Group dependency on X86EMU_DEBUG 2023-05-02 18:49:50 +00:00