Re: [PATCH v2] x86/kvm: Handle async page faults directly through do_page_fault()

From: Nadav Amit
Date: Mon Mar 02 2020 - 04:28:20 EST


> On Feb 29, 2020, at 9:50 AM, Andy Lutomirski <luto@xxxxxxxxxx> wrote:
>
> KVM overloads #PF to indicate two types of not-actually-page-fault
> events. Right now, the KVM guest code intercepts them by modifying
> the IDT and hooking the #PF vector. This makes the already fragile
> fault code even harder to understand, and it also pollutes call
> traces with async_page_fault and do_async_page_fault for normal page
> faults.
>
> Clean it up by moving the logic into do_page_fault() using a static
> branch. This gets rid of the platform trap_init override mechanism
> completely.
>
> Signed-off-by: Andy Lutomirski <luto@xxxxxxxxxx>

Indeed the async-PF mechanism is only used by KVM, and there is no need for
over-engineering the solution just in case some other hypervisor ever
introduces support for a similar paravirtual feature.

Yet, this might be a slippery slope, making Linux optimized to run on KVM
(and maybe Xen). In other words, I wonder whether a similar change was
acceptable for a paravirtual feature that is only supported by a proprietary
hypervisor, such as Hyper-V or VMware.