Skip to content

KVM: introduce readonly memslot

Xiao Guangrong kvm lkml 4 versions – Applied

Status from this message: Thanks, applied 1-11.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest12 patches 20 repliesApplied
  2. v512 patches 22 repliesSuperseded
  3. v410 patches 4 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v36 patches12 repliesSuperseded

Changelog from the cover letter

- fix endless retrying for unhandleable instruction which accesses on readonly host memory
- divide slot->flags by 16:16, the lower part is visible for userspace, the reset is internally used in kvm, and document this in the code
- check slot->flags for gfn_to_hva_memslot

Patches in v6 Applied

#Subject and filesSizeRepliesApplied
1/12KVM: x86: fix possible infinite loop caused by reexecute_instructionarch/x86/kvm/x86.c+11 -12 replies
2/12KVM: fix missing check for memslot flagsvirt/kvm/kvm_main.c+12 -00 replies
3/12KVM: hide KVM_MEMSLOT_INVALID from userspaceinclude/linux/kvm.h include/linux/kvm_host.h+12 -20 replies
4/12KVM: introduce gfn_to_pfn_memslot_atomicarch/x86/kvm/mmu.c include/linux/kvm_host.h virt/kvm/kvm_main.c+11 -110 replies
5/12KVM: introduce gfn_to_hva_read/kvm_read_hva/kvm_read_hva_atomicvirt/kvm/kvm_main.c+23 -40 replies
6/12KVM: reorganize hva_to_pfnvirt/kvm/kvm_main.c+97 -620 replies
7/12KVM: use 'writable' as a hint to map writable pfnvirt/kvm/kvm_main.c+23 -10 replies
8/12KVM: introduce KVM_PFN_ERR_RO_FAULTinclude/linux/kvm_host.h+1 -00 replies
9/12KVM: introduce KVM_HVA_ERR_BADinclude/linux/kvm_host.h virt/kvm/kvm_main.c+8 -130 replies
10/12KVM: introduce KVM_HVA_ERR_RO_BADinclude/linux/kvm_host.h+3 -20 replies
11/12KVM: introduce readonly memslotDocumentation/virtual/kvm/api.txt arch/x86/include/asm/kvm.h arch/x86/kvm/mmu.c +4 more+102 -285 replies
12/12KVM: indicate readonly access faultarch/x86/kvm/x86.c include/linux/kvm.h include/linux/kvm_host.h +1 more+21 -912 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v6 yet.

Read the v6 thread

Cover letter [PATCH v6 00/12] KVM: introduce readonly memslot

Changelog:
- fix endless retrying for unhandleable instruction which accesses on readonly host memory
- divide slot->flags by 16:16, the lower part is visible for userspace, the reset is internally used in kvm, and document this in the code
- check slot->flags for gfn_to_hva_memslot

The test case can be found at:
http://lkml.indiana.edu/hypermail/linux/kernel/1207.2/00819/migrate-perf.tar.bz2

In current code, if we map a readonly memory space from host to guest and the page is not currently mapped in the host, we will get a fault-pfn and async is not allowed, then the vm will crash.

As Avi's suggestion, We introduce readonly memory region to map ROM/ROMD to the guest, read access is happy for readonly memslot, write access on readonly memslot will cause KVM_EXIT_MMIO exit.