unit tests and get_user_pages_ptes_fast()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



During the last kvm forum, I described a unit test framework that can help test the kvm APIs. Briefly, it starts a process in host userspace, which sets up a memory slot mapping gpa 0:3G to hva 0:3G. It then sets up guest registers for unpaged protected mode (or paged protected mode with 1:1 mapping). The effect is that we have a 1:1 gva->hva translation, and can use KVM_RUN to run host code in guest mode.

There is a snag however. kvm calls get_user_pages_fast(.write = 1), and the host process maps its code pages read-only.

The way I'd like to work around this is to map read-only accesses to read-only pages as read-only. This also prevents ksm cow pages from being broken by read accesses. It can also be used to get the page size for transparent huge pages (and later hugetlbfs too).

So, for a read fault we do:

  pte_t pte;
  get_user_pages_ptes_fast(..., page, &pte, 1, .write = 0)
  ...
  if (pte_transhuge(pte)) // or however it's called
      ...
  ...
  if (pte_write(pte))
        map writeable
  else
        map readonly

Any snags?  or alternatives?

--
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux