KVM: x86: Add a cap to disable NX hugepages on a VM
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v9 Latest10 patches 0 repliesNew
- v811 patches 1 replySuperseded
- v711 patches 7 repliesSuperseded
Earlier versions · 6
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v6 | 10 patches | 10 replies | Superseded | |
| v5 | 10 patches | 8 replies | Superseded | |
| v4 | 10 patches | 20 replies | Superseded | |
| v3 | 11 patches | 20 replies | Superseded | |
| v2 | 11 patches | 7 replies | Superseded | |
| v1 | 13 patches | 5 replies | Superseded |
Changes in v9 from the cover letter
Rebased on top of Sean's giant selftests refactor series
Patches in v9 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/10 | KVM: selftests: Remove dynamic memory allocation for stats headertools/ | +27 | 0 replies | |
| 2/10 | KVM: selftests: Read binary stats header in libtools/ tools/ | +10 | 0 replies | |
| 3/10 | KVM: selftests: Read binary stats desc in libtools/ tools/ tools/ | +63 | 0 replies | |
| 4/10 | KVM: selftests: Clean up coding style in binary stats testtools/ | +45 | 0 replies | |
| 5/10 | KVM: selftests: Read binary stat data in libtools/ tools/ tools/ | +41 | 0 replies | |
| 6/10 | KVM: selftests: Add NX huge pages testtools/ tools/ tools/ +3 more | +337 | 0 replies | |
| 7/10 | KVM: x86: Fix errant brace in KVM capability handlingarch/ | +1 | 0 replies | |
| 8/10 | KVM: x86/MMU: Allow NX huge pages to be disabled on a per-vm basisDocumentation/ arch/ arch/ +5 more | +60 | 0 replies | |
| 9/10 | KVM: selftests: Test disabling NX hugepages on a VMtools/ tools/ tools/ | +106 | 0 replies | |
| 10/10 | KVM: selftests: Cache binary stats metadata for duration of testtools/ tools/ | +22 | 0 replies |
Reviews trailers per patch
9 of 10 patches have a Reviewed-by or Acked-by.
| Patch | David Matlack | Peter Xu |
|---|---|---|
| 1/10 | R-b | R-b |
| 2/10 | R-b | R-b |
| 3/10 | R-b | R-b |
| 4/10 | R-b | |
| 5/10 | R-b | R-b |
| 6/10 | R-b | |
| 7/10 | R-b | R-b |
| 8/10 | R-b | R-b |
| 9/10 | R-b | |
| 10/10 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v9 00/10] KVM: x86: Add a cap to disable NX hugepages on a VM
Given the high cost of NX hugepages in terms of TLB performance, it may be desirable to disable the mitigation on a per-VM basis. In the case of public cloud providers with many VMs on a single host, some VMs may be more trusted than others. In order to maximize performance on critical VMs, while still providing some protection to the host from iTLB Multihit, allow the mitigation to be selectively disabled.
Disabling NX hugepages on a VM is relatively straightforward, but I took this as an opportunity to add some NX hugepages test coverage and clean up selftests infrastructure a bit.
This series was tested with the new selftest and the rest of the KVM selftests on an Intel Haswell machine.
Changelog:v1->v2:
Dropped the complicated memslot refactor in favor of Ricardo Koller's patch with a similar effect.
Incorporated David Dunn's feedback and reviewed by tag: shortened waits to speed up test.v2->v3:
Incorporated a suggestion from David on how to build the NX huge pages test.
Fixed a build breakage identified by David.
Dropped the per-vm nx_huge_pages field in favor of simply checking the global + per-VM disable override.
Documented the new capability
Separated out the commit to test disabling NX huge pages Removed permission check when checking if the disable NX capability is supported.
Added test coverage for the permission check.v3->v4:
Collected RB's from Jing and David
Modified stat collection to reduce a memory allocation [David] Incorporated various improvments to the NX test [David] Changed the NX disable test to run by default [David] Removed some now unnecessary commits
Dropped the code to dump KVM stats from the binary stats test, and factor out parts of the existing test to library functions instead. [David, Jing, Sean]
Dropped the improvement to a debugging log message as it's no longer relevant to this series.v4->v5:
Incorporated cleanup suggestions from David and Sean
Added a patch with style fixes for the binary stats test from Sean Added a restriction that NX huge pages can only be disabled before vCPUs are created [Sean]
v5->v6:
Scooped up David's RBs
Added a magic token to skip nx_huge_pages_test when not run via wrapper script [Sean]
Made the call to nx_huge_pages_test in the wrapper script more robust [Sean]
Incorportated various nits and comment / documentation suggestions from Sean.
Improved negative testing of NX disable without reboot permissions. [Sean]
v6->v7:
Collected Peter Xu's Reviewed-by tags
Added stats metadata caching to kvm_util
Misc NX test fixups
v7->v8:
Spell out descriptors in library function names [Sean] Reorganize stat descriptor size calculation [Sean]
Addded a get_stats_descriptor helper [Sean]
Remove misleading comment about error reporting in read_stat_data() [Sean] Use unsigned size_t for input to pread [Sean]
Clean up read_stat_data() [Sean]
Add nx_huge_pages_test to .gitignore [Sean]
Fix organization of get_vm_stat() functions. [Sean]
Clean up #defines in NX huge pages test [Sean]
Add flag parsing and reclaim period flag to NX test [Sean] Don't reduce hugepage allocation for NX test [Sean]
Fix error check when disabling NX huge pages [Sean]
Don't leave reboot permissions on test binary when executing as root [Sean]
v8->v9:
Rebased on top of Sean's giant selftests refactor series
Ben Gardon (9):
KVM: selftests: Remove dynamic memory allocation for stats header
KVM: selftests: Read binary stats header in lib
KVM: selftests: Read binary stats desc in lib
KVM: selftests: Read binary stat data in lib
KVM: selftests: Add NX huge pages test
KVM: x86: Fix errant brace in KVM capability handling
KVM: x86/MMU: Allow NX huge pages to be disabled on a per-vm basis
KVM: selftests: Test disabling NX hugepages on a VM
KVM: selftests: Cache binary stats metadata for duration of test
Sean Christopherson (1):
KVM: selftests: Clean up coding style in binary stats test
Documentation/virt/kvm/api.rst | 16 ++ arch/x86/include/asm/kvm_host.h | 2 + arch/x86/kvm/mmu/mmu_internal.h | 7 +- arch/x86/kvm/mmu/spte.c | 7 +- arch/x86/kvm/mmu/spte.h | 3 +- arch/x86/kvm/mmu/tdp_mmu.c | 2 +- arch/x86/kvm/x86.c | 32 ++- include/uapi/linux/kvm.h | 1 + tools/testing/selftests/kvm/.gitignore | 1 + tools/testing/selftests/kvm/Makefile | 10 + .../selftests/kvm/include/kvm_util_base.h | 59 ++++ .../selftests/kvm/kvm_binary_stats_test.c | 138 +++++---- tools/testing/selftests/kvm/lib/kvm_util.c | 116 ++++++++ .../selftests/kvm/x86_64/nx_huge_pages_test.c | 269 ++++++++++++++++++ .../kvm/x86_64/nx_huge_pages_test.sh | 52 ++++ 15 files changed, 635 insertions(+), 80 deletions(-) create mode 100644 tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c create mode 100755 tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.sh
Signature · 1 line
2.36.1.476.g0c4daa206d-goog