Re: [PATCH] drm/ttm: set TTM allocated pages as reserved

2023-03-30 Thread David Stevens
On Thu, Mar 30, 2023 at 2:22 AM Sean Christopherson wrote: > > +David > > On Wed, Mar 29, 2023, Paolo Bonzini wrote: > > On 3/29/23 18:43, Christian K�nig wrote: > > > > > > > > > > > > 3) other uses of kmap() must switch to MMU-notifier protection. > > > > > > I would rather suggest to return

Re: [PATCH] drm/ttm: set TTM allocated pages as reserved

2023-03-29 Thread Sean Christopherson
On Wed, Mar 29, 2023, Christian K�nig wrote: > Am 29.03.23 um 19:39 schrieb Sean Christopherson: > > On Wed, Mar 29, 2023, Christian K�nig wrote: > > > Am 29.03.23 um 19:22 schrieb Sean Christopherson: > > > > +David > > > > > > > > On Wed, Mar 29, 2023, Paolo Bonzini wrote: > > > > > On

Re: [PATCH] drm/ttm: set TTM allocated pages as reserved

2023-03-29 Thread Christian König
Am 29.03.23 um 19:39 schrieb Sean Christopherson: On Wed, Mar 29, 2023, Christian K�nig wrote: Am 29.03.23 um 19:22 schrieb Sean Christopherson: +David On Wed, Mar 29, 2023, Paolo Bonzini wrote: On 3/29/23 18:43, Christian K�nig wrote: 3) other uses of kmap() must switch to MMU-notifier

Re: [PATCH] drm/ttm: set TTM allocated pages as reserved

2023-03-29 Thread Sean Christopherson
On Wed, Mar 29, 2023, Christian K�nig wrote: > Am 29.03.23 um 19:22 schrieb Sean Christopherson: > > +David > > > > On Wed, Mar 29, 2023, Paolo Bonzini wrote: > > > On 3/29/23 18:43, Christian K�nig wrote: > > > > > > > > > > 3) other uses of kmap() must switch to MMU-notifier protection. >

Re: [PATCH] drm/ttm: set TTM allocated pages as reserved

2023-03-29 Thread Christian König
Am 29.03.23 um 19:22 schrieb Sean Christopherson: +David On Wed, Mar 29, 2023, Paolo Bonzini wrote: On 3/29/23 18:43, Christian K�nig wrote: 3) other uses of kmap() must switch to MMU-notifier protection. I would rather suggest to return the page additionally to the pfn from hva_to_pfn()

Re: [PATCH] drm/ttm: set TTM allocated pages as reserved

2023-03-29 Thread Sean Christopherson
+David On Wed, Mar 29, 2023, Paolo Bonzini wrote: > On 3/29/23 18:43, Christian K�nig wrote: > > > > > > > > > 3) other uses of kmap() must switch to MMU-notifier protection. > > > > I would rather suggest to return the page additionally to the pfn from > > hva_to_pfn() when the function was

Re: [PATCH] drm/ttm: set TTM allocated pages as reserved

2023-03-29 Thread Paolo Bonzini
On 3/29/23 18:43, Christian König wrote: 3) other uses of kmap() must switch to MMU-notifier protection. I would rather suggest to return the page additionally to the pfn from hva_to_pfn() when the function was able to grab a reference to it. When the page is then not available you can't

Re: [PATCH] drm/ttm: set TTM allocated pages as reserved

2023-03-29 Thread Christian König
Am 29.03.23 um 17:51 schrieb Paolo Bonzini: On 3/29/23 17:29, Christian König wrote: First, is it a _host_ corruption or a guest corruption/crash?  A guest crash would be KVM doing exactly what it's meant to do: it detects the non-reserved, non-refcounted page and refuses to map it into

Re: [PATCH] drm/ttm: set TTM allocated pages as reserved

2023-03-29 Thread Paolo Bonzini
On 3/29/23 17:29, Christian König wrote: First, is it a _host_ corruption or a guest corruption/crash?  A guest crash would be KVM doing exactly what it's meant to do: it detects the non-reserved, non-refcounted page and refuses to map it into the guest. Yes I think that this is what happens.

Re: [PATCH] drm/ttm: set TTM allocated pages as reserved

2023-03-29 Thread Christian König
Am 29.03.23 um 17:08 schrieb Paolo Bonzini: On 3/29/23 16:28, Paolo Bonzini wrote: On 3/29/23 15:54, Christian König wrote: KVM tries to grab references to pages in VMAs marked with VM_PFNMAP. This is illegal and can cause data corruption with TTM pages because only some of them are actually

Re: [PATCH] drm/ttm: set TTM allocated pages as reserved

2023-03-29 Thread Paolo Bonzini
On 3/29/23 16:28, Paolo Bonzini wrote: On 3/29/23 15:54, Christian König wrote: KVM tries to grab references to pages in VMAs marked with VM_PFNMAP. This is illegal and can cause data corruption with TTM pages because only some of them are actually reference counted. After some other offlist

Re: [PATCH] drm/ttm: set TTM allocated pages as reserved

2023-03-29 Thread Paolo Bonzini
On 3/29/23 15:54, Christian König wrote: KVM tries to grab references to pages in VMAs marked with VM_PFNMAP. This is illegal and can cause data corruption with TTM pages because only some of them are actually reference counted. I think that you are referring to this: /* Don't set the

[PATCH] drm/ttm: set TTM allocated pages as reserved

2023-03-29 Thread Christian König
KVM tries to grab references to pages in VMAs marked with VM_PFNMAP. This is illegal and can cause data corruption with TTM pages because only some of them are actually reference counted. Mark all pages allocated by TTM as reserved, this way KVM handles the PFNs like they would point to MMIO