[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250422173355.GDaAfTA8GqnGBfDk7G@renoirsky.local>
Date: Tue, 22 Apr 2025 19:33:55 +0200
From: Borislav Petkov <bp@...en8.de>
To: Sean Christopherson <seanjc@...gle.com>
Cc: Pavel Machek <pavel@...x.de>, Sasha Levin <sashal@...nel.org>,
linux-kernel@...r.kernel.org, stable@...r.kernel.org,
Max Grobecker <max@...becker.info>, Ingo Molnar <mingo@...nel.org>,
tglx@...utronix.de, mingo@...hat.com, dave.hansen@...ux.intel.com,
x86@...nel.org, thomas.lendacky@....com, perry.yuan@....com,
mario.limonciello@....com, riel@...riel.com, mjguzik@...il.com,
darwi@...utronix.de, Paolo Bonzini <pbonzini@...hat.com>
Subject: CONFIG_X86_HYPERVISOR (was: Re: [PATCH AUTOSEL 5.10 2/6] x86/cpu:
Don't clear X86_FEATURE_LAHF_LM flag in init_amd_k8() on AMD when running in
a virtual machine)
On Tue, Apr 22, 2025 at 10:22:54AM -0700, Sean Christopherson wrote:
> > Because I really hate wagging the dog and "fixing" the kernel because something
> > else can't be bothered. I didn't object stronger to that fix because it is
> > meh, more of those "if I'm a guest" gunk which we sprinkle nowadays and that's
> > apparently not that awful-ish...
>
> FWIW, I think splattering X86_FEATURE_HYPERVISOR everywhere is quite awful. There
> are definitely cases where the kernel needs to know if it's running as a guest,
> because the behavior of "hardware" fundamentally changes in ways that can't be
> enumerated otherwise. E.g. that things like the HPET are fully emulated and thus
> will be prone to significant jitter.
>
> But when it comes to feature enumeration, IMO sprinkling HYPERVISOR everywhere is
> unnecessary because it's the hypervisor/VMM's responsibility to present a sane
> model. And I also think it's outright dangerous, because everywhere the kernel
> does X for bare metal and Y for guest results in reduced test coverage.
>
> E.g. things like syzkaller and other bots will largely be testing the HYPERVISOR
> code, while humans will largely be testing and using the bare metal code.
All valid points...
At least one case justifies the X86_FEATURE_HYPERVISOR check: microcode loading
and we've chewed that topic back then with Xen ad nauseam.
But I'd love to whack as many of such checks as possible.
$ git grep X86_FEATURE_HYPERVISOR | wc -l
60
I think I should start whacking at those and CC you if I'm not sure.
It'll be a long-term, low prio thing but it'll be a good cleanup.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
Powered by blists - more mailing lists