Re: [RFCv2 14/16] KVM: Handle protected memory in __kvm_map_gfn()/__kvm_unmap_gfn()

2020-10-23 Thread Kirill A. Shutemov
On Thu, Oct 22, 2020 at 04:59:49PM +, Edgecombe, Rick P wrote: > On Thu, 2020-10-22 at 15:06 +0300, Kirill A. Shutemov wrote: > > > I think the page could have got unmapped since the gup via the > > > hypercall on another CPU. It could be an avenue for the guest to > > > crash > > > the host.

Re: [RFCv2 14/16] KVM: Handle protected memory in __kvm_map_gfn()/__kvm_unmap_gfn()

2020-10-22 Thread Edgecombe, Rick P
On Thu, 2020-10-22 at 15:06 +0300, Kirill A. Shutemov wrote: > > I think the page could have got unmapped since the gup via the > > hypercall on another CPU. It could be an avenue for the guest to > > crash > > the host. > > Hm.. I'm not sure I follow. Could you elaborate on what scenario you >

Re: [RFCv2 14/16] KVM: Handle protected memory in __kvm_map_gfn()/__kvm_unmap_gfn()

2020-10-22 Thread Kirill A. Shutemov
On Thu, Oct 22, 2020 at 05:26:47AM +0200, Halil Pasic wrote: > On Tue, 20 Oct 2020 09:18:57 +0300 > "Kirill A. Shutemov" wrote: > > > We cannot access protected pages directly. Use ioremap() to > > create a temporary mapping of the page. The mapping is destroyed > > on __kvm_unmap_gfn(). > > >

Re: [RFCv2 14/16] KVM: Handle protected memory in __kvm_map_gfn()/__kvm_unmap_gfn()

2020-10-22 Thread Kirill A. Shutemov
On Wed, Oct 21, 2020 at 06:50:28PM +, Edgecombe, Rick P wrote: > On Tue, 2020-10-20 at 09:18 +0300, Kirill A. Shutemov wrote: > > @@ -467,7 +477,7 @@ void iounmap(volatile void __iomem *addr) > > p = find_vm_area((void __force *)addr); > > > > if (!p) { > > -

Re: [RFCv2 14/16] KVM: Handle protected memory in __kvm_map_gfn()/__kvm_unmap_gfn()

2020-10-21 Thread Halil Pasic
On Tue, 20 Oct 2020 09:18:57 +0300 "Kirill A. Shutemov" wrote: > We cannot access protected pages directly. Use ioremap() to > create a temporary mapping of the page. The mapping is destroyed > on __kvm_unmap_gfn(). > > The new interface gfn_to_pfn_memslot_protected() is used to detect if > the

Re: [RFCv2 14/16] KVM: Handle protected memory in __kvm_map_gfn()/__kvm_unmap_gfn()

2020-10-21 Thread Edgecombe, Rick P
On Tue, 2020-10-20 at 09:18 +0300, Kirill A. Shutemov wrote: > We cannot access protected pages directly. Use ioremap() to > create a temporary mapping of the page. The mapping is destroyed > on __kvm_unmap_gfn(). > > The new interface gfn_to_pfn_memslot_protected() is used to detect if > the

[RFCv2 14/16] KVM: Handle protected memory in __kvm_map_gfn()/__kvm_unmap_gfn()

2020-10-20 Thread Kirill A. Shutemov
We cannot access protected pages directly. Use ioremap() to create a temporary mapping of the page. The mapping is destroyed on __kvm_unmap_gfn(). The new interface gfn_to_pfn_memslot_protected() is used to detect if the page is protected. ioremap_cache_force() is a hack to bypass