Re: [PATCH v9 15/22] KVM: x86: Mark CR4.FRED as not reserved
From: Sean Christopherson
Date: Thu Mar 05 2026 - 10:35:32 EST
On Wed, Mar 04, 2026, Xin Li wrote:
>
> >> 2. mk_cr_64() drops the high 32 bits of the new CR4 value. So, CR4.FRED is always
> >> dropped. This may need an update.
> >
> > Ugh, I didn't realize FRED broke into bits 63:32. Yeah, that needs to be updated,
> > and _that_ one is unique to the emulator.
> >
> > Unless Chao and I can't read code and are missing magic, KVM's virtualization of
> > FRED is quite lacking.
> >
> > More importantly, I don't see *any* tests. At a bare minimum, KVM's msrs_test
> > needs to be updated too get coverage for userspace vs. guest accesses, save/restore
> > needs to be covered (maybe nothing additional required?), and there need to be
> > negative tests for things like leaving 64-bit mode with FRED=1. We can probably
> > get enough confidence in the "happy" paths just by running VMs, but even then I
> > would ideally like to see tests for edge cases that are relatively rare when just
> > running a VM.
> >
> > I'm straight up not going to look at new versions if there aren't tests. Like
> > CET before it, both Intel and AMD are pushing FRED and want to get it merged,
> > yet no one is providing tests. That's not going to fly this time, as I don't
> > have the bandwidth to help write the number of testcases FRED warrants.
>
> I must admit the issues Chao raised were a clear oversight on my part.
>
> I wrote some basic functionality unit tests in kernel selftests, which were
> included in v1 and v2.
>
> Later I started to create FRED tests in kvm-unit-tests and extended one
> nested test case to CET:
>
> https://lore.kernel.org/kvm/aJ9DB12YVJEyDORD@xxxxxxxxx/
>
> I planned to send out these new kvm unit tests (not just FRED tests) after
> KVM FRED patch series gets merged.
Definitely send them before. Even if no one outside of Intel can run them (I
forget when FRED hardware is coming), people like me can at least see what you're
testing, which makes it more likely that we'll spot bugs. E.g. in this case, the
lack of negative tests for CR4.FRED is a big red flag.