Re: [PATCH v5 10/17] KVM: Implement KVM_CAP_USERFAULT_ON_MISSING by atomizing __gfn_to_pfn_memslot() calls

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

 



Eh, the shortlog basically says "do work" with a lot of fancy words.  It really
just boils down to:

  KVM: Let callers of __gfn_to_pfn_memslot() opt-out of USERFAULT_ON_MISSING

On Fri, Sep 08, 2023, Anish Moorthy wrote:
> Change the "atomic" parameter of __gfn_to_pfn_memslot() to an enum which

I've pushed back on more booleans multiple times, but IMO this is even worse.
E.g. what does an "upgrade" to atomic even mean?

Since we have line of sight to getting out of boolean hell via David's series,
just bite the bullet for now.  Deciphering the callers will suck, but not really
anymore than it already sucks.

kvm_pfn_t __gfn_to_pfn_memslot(const struct kvm_memory_slot *slot, gfn_t gfn,
			       bool atomic, bool interruptible, bool *async,
			       bool write_fault, bool *writable,
			       bool can_do_userfault, hva_t *hva)
{
	unsigned long addr = __gfn_to_hva_many(slot, gfn, NULL, write_fault);

	if (hva)
		*hva = addr;

	if (kvm_is_error_hva(addr)) {
		if (writable)
			*writable = false;

		if (addr == KVM_HVA_ERR_RO_BAD)
			return KVM_PFN_ERR_RO_FAULT;

		return KVM_PFN_NOSLOT;
	}

	if (!atomic && can_do_userfault &&
	    kvm_is_slot_userfault_on_missing(slot)) {
		atomic = true;
		if (async) {
			*async = false;
			async = NULL;
		}
	}

	/* Do not map writable pfn in the readonly memslot. */
	if (writable && memslot_is_readonly(slot)) {
		*writable = false;
		writable = NULL;
	}

	return hva_to_pfn(addr, atomic, interruptible, async, write_fault,
			  writable);
}



[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