Re: [PATCH 1/1] direct mmio for passthrough - kernel part

Avi Kivity
2008-04-02T04:32:35Z

Anthony Liguori wrote:
> What about switching the KVM MMU code to use hfn_t instead of struct
> page? The initial conversion is pretty straight forward as the places
> where you actually need a struct page you can always get it from
> pfn_to_page() (like in kvm_release_page_dirty).
>
> We can then teach the MMU to deal with hfn_t's that don't have a
> corresponding page. IIUC, the implementation of something like
> kvm_release_page_dirty is a nop for pfn's that don't have a
> corresponding page. We just have to be able to detect a pfn_to_page()
> failure and then assume we're dealing with IO memory.
>
>

It ought to work. gfn_to_hfn() (old gfn_to_page) will still need to
take a refcount if possible.

This will increase the potential for type errors, so maybe we need to
make gfn_t and hfn_t distinct structures, and use accessors to get the
actual values.

--
Any sufficiently difficult bug is indistinguishable from a feature.