On Tue, Jun 03, 2025 at 12:43:30PM -0700, ross.philip...@oracle.com wrote: > On 5/30/25 6:17 AM, Sergii Dmytruk wrote: > > From: Krystian Hebel <krystian.he...@3mdeb.com> > > > > In preparation for TXT SENTER call, GRUB had to modify MTRR settings > > to be UC for everything except SINIT ACM. Old values are restored > > from SLRT where they were saved by the bootloader. > > > > Signed-off-by: Krystian Hebel <krystian.he...@3mdeb.com> > > Signed-off-by: Michał Żygowski <michal.zygow...@3mdeb.com> > > Signed-off-by: Sergii Dmytruk <sergii.dmyt...@3mdeb.com> > > --- > > xen/arch/x86/e820.c | 5 ++ > > xen/arch/x86/include/asm/intel-txt.h | 3 ++ > > xen/arch/x86/intel-txt.c | 75 ++++++++++++++++++++++++++++ > > 3 files changed, 83 insertions(+) > > > > diff --git a/xen/arch/x86/e820.c b/xen/arch/x86/e820.c > > index ca577c0bde..60f00e5259 100644 > > --- a/xen/arch/x86/e820.c > > +++ b/xen/arch/x86/e820.c > > @@ -11,6 +11,8 @@ > > #include <asm/mtrr.h> > > #include <asm/msr.h> > > #include <asm/guest.h> > > +#include <asm/intel-txt.h> > > +#include <asm/slaunch.h> > > /* > > * opt_mem: Limit maximum address of physical RAM. > > @@ -442,6 +444,9 @@ static uint64_t __init mtrr_top_of_ram(void) > > ASSERT(paddr_bits); > > addr_mask = ((1ULL << paddr_bits) - 1) & PAGE_MASK; > > + if ( slaunch_active ) > > + txt_restore_mtrrs(e820_verbose); > > + > > I was just curious why they are being restored here in the e820 code? It > seems that could be restored earlier. Until they are restored, most of RAM > is set UC as you know. I also don't have an exact idea how early in Xen boot > cycle this is occurring so maybe this is fine but obviously for performance > reasons it should be done as early as possible. > > Thanks, > Ross
Original MTRR values are in SLRT which is deliberately measured before being used by e820 code. I'm not sure if anything precludes moving that part (mapping memory, interacting with TPM) earlier in __start_xen(). Could be worth trying moving it up. Regards