Re: 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)

From: Borislav Petkov
Date: Sat Apr 26 2025 - 07:27:13 EST


On April 26, 2025 3:08:29 AM GMT+03:00, Sean Christopherson <seanjc@xxxxxxxxxx> wrote:
>The kernel already can enforce policy. Setting host breakpoints on guest code
>is done through a dedicated ioctl(), and access to said ioctl() can be restricted
>through various sandboxing methods, e.g. seccomp.

Ok, makes sense.

>No, that would defeat the purpose of the check. The X86_FEATURE_HYPERVISOR has
>nothing to do with correctness, it's all about performance. Critically, it's a
>static check that gets patched at runtime. It's a micro-optimization for bare
>metal to avoid a single cache miss (the __this_cpu_read(cpu_dr7)). Routing
>through cc_platform_has() would be far, far heavier than calling hw_breakpoint_active().

Huh, we care so much about speed here?

--
Sent from a small device: formatting sucks and brevity is inevitable.