Re: [RFC 0/33] KVM: x86: hyperv: Introduce VSM support

From: Sean Christopherson
Date: Wed Nov 08 2023 - 11:55:58 EST


On Wed, Nov 08, 2023, Nicolas Saenz Julienne wrote:
> This RFC series introduces the necessary infrastructure to emulate VSM
> enabled guests. It is a snapshot of the progress we made so far, and its
> main goal is to gather design feedback.

Heh, then please provide an overview of the design, and ideally context and/or
justification for various design decisions. It doesn't need to be a proper design
doc, and you can certainly point at other documentation for explaining VSM/VTLs,
but a few paragraphs and/or verbose bullet points would go a long way.

The documentation in patch 33 provides an explanation of VSM itself, and a little
insight into how userspace can utilize the KVM implementation. But the documentation
provides no explanation of the mechanics that KVM *developers* care about, e.g.
the use of memory attributes, how memory attributes are enforced, whether or not
an in-kernel local APIC is required, etc.

Nor does the documentation explain *why*, e.g. why store a separate set of memory
attributes per VTL "device", which by the by is broken and unnecessary.

> Specifically on the KVM APIs we introduce. For a high level design overview,
> see the documentation in patch 33.
>
> Additionally, this topic will be discussed as part of the KVM
> Micro-conference, in this year's Linux Plumbers Conference [2].
>
> The series is accompanied by two repositories:
> - A PoC QEMU implementation of VSM [3].
> - VSM kvm-unit-tests [4].
>
> Note that this isn't a full VSM implementation. For now it only supports
> 2 VTLs, and only runs on uniprocessor guests. It is capable of booting
> Windows Sever 2016/2019, but is unstable during runtime.
>
> The series is based on the v6.6 kernel release, and depends on the
> introduction of KVM memory attributes, which is being worked on
> independently in "KVM: guest_memfd() and per-page attributes" [5].

This doesn't actually apply on 6.6 with v14 of guest_memfd, because v14 of
guest_memfd is based on kvm-6.7-1. Ah, and looking at your github repo, this
isn't based on v14 at all, it's based on v12.

That's totally fine, but the cover letter needs to explicitly, clearly, and
*accurately* state the dependencies. I can obviously grab the full branch from
github, but that's not foolproof, e.g. if you accidentally delete or force push
to that branch. And I also prefer to know that what I'm replying to on list is
the exact same code that I am looking at.

> A full Linux tree is also made available [6].
>
> Series rundown:
> - Patch 2 introduces the concept of APIC ID groups.
> - Patches 3-12 introduce the VSM capability and basic VTL awareness into
> Hyper-V emulation.
> - Patch 13 introduces vCPU polling support.
> - Patches 14-31 use KVM's memory attributes to implement VTL memory
> protections. Introduces the VTL KMV device and secure memory
> intercepts.
> - Patch 32 is a temporary implementation of
> HVCALL_TRANSLATE_VIRTUAL_ADDRESS necessary to boot Windows 2019.
> - Patch 33 introduces documentation.
>
> Our intention is to integrate feedback gathered in the RFC and LPC while
> we finish the VSM implementation. In the future, we will split the series
> into distinct feature patch sets and upstream these independently.
>
> Thanks,
> Nicolas
>
> [1] https://raw.githubusercontent.com/Microsoft/Virtualization-Documentation/master/tlfs/Hypervisor%20Top%20Level%20Functional%20Specification%20v6.0b.pdf
> [2] https://lpc.events/event/17/sessions/166/#20231114
> [3] https://github.com/vianpl/qemu/tree/vsm-rfc-v1
> [4] https://github.com/vianpl/kvm-unit-tests/tree/vsm-rfc-v1
> [5] https://lore.kernel.org/lkml/20231105163040.14904-1-pbonzini@xxxxxxxxxx/.
> [6] Full tree: https://github.com/vianpl/linux/tree/vsm-rfc-v1.

When providing github links, my preference is to format the pointers as:

<repo> <branch>

or
<repo> tags/<tag>

e.g.

https://github.com/vianpl/linux vsm-rfc-v1

so that readers can copy+paste the full thing directly into `git fetch`. It's a
minor thing, but AFAIK no one actually does review by clicking through github's
webview.

> There are also two small dependencies with
> https://marc.info/?l=kvm&m=167887543028109&w=2 and
> https://lkml.org/lkml/2023/10/17/972

Please use lore links, there's zero reason to use anything else these days. For
those of us that use b4, lore links make life much easier.