Commit 71b491d
Drivers: hv: mshv_vtl: fix GUP into VTL0 mappings on the 4K fault path
Extend the folio-aware fault path to the 4K case so GUP into
/dev/mshv_vtl_low works after MSHV_ADD_VTL0_MEMORY has registered the
range. With the previous vmf_insert_mixed() path the PTE was always
pte_special, vm_normal_page() returned NULL during pin_user_pages*(),
follow_pfn_pte() returned -EEXIST, and io_uring O_DIRECT surfaced it
as "disk io error: io error: File exists (os error 17)" on the first
DMA into a freshly-registered VTL0 chunk.
The 4K path now resolves the PFN via mshv_vtl_low_resolve_page(): when
backed by an mshv_vtl pgmap the PTE is installed with
vmf_insert_page_mkwrite(), giving GUP a normal pinnable page; otherwise
it falls back to vmf_insert_mixed() so early CPU accesses (e.g. the
VTL2 guest-memory self test reading GPA 0 before any add_vtl0_mem
ioctl) still succeed instead of SIGBUSing.
Such fallback PTEs would persist across registration and break later
GUP. Capture the cdev's address_space on first open and, on successful
MSHV_ADD_VTL0_MEMORY, invalidate the file-offset range via
unmap_mapping_range() for both the encrypted (pfn) and decrypted
(pfn | DECRYPTED_MASK) aliases that mshv_vtl_low_mmap() exposes. The
next access re-faults into the folio path and GUP works.
Signed-off-by: Naman Jain <namjain@linux.microsoft.com>1 parent 8444765 commit 71b491d
1 file changed
Lines changed: 37 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1155 | 1155 | | |
1156 | 1156 | | |
1157 | 1157 | | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
1158 | 1164 | | |
1159 | 1165 | | |
1160 | 1166 | | |
| |||
1210 | 1216 | | |
1211 | 1217 | | |
1212 | 1218 | | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
1213 | 1233 | | |
1214 | 1234 | | |
1215 | 1235 | | |
| |||
3667 | 3687 | | |
3668 | 3688 | | |
3669 | 3689 | | |
| 3690 | + | |
| 3691 | + | |
| 3692 | + | |
3670 | 3693 | | |
3671 | 3694 | | |
3672 | 3695 | | |
| |||
3760 | 3783 | | |
3761 | 3784 | | |
3762 | 3785 | | |
3763 | | - | |
3764 | | - | |
| 3786 | + | |
| 3787 | + | |
| 3788 | + | |
| 3789 | + | |
| 3790 | + | |
| 3791 | + | |
| 3792 | + | |
| 3793 | + | |
| 3794 | + | |
| 3795 | + | |
| 3796 | + | |
| 3797 | + | |
| 3798 | + | |
3765 | 3799 | | |
3766 | 3800 | | |
3767 | 3801 | | |
| |||
3821 | 3855 | | |
3822 | 3856 | | |
3823 | 3857 | | |
3824 | | - | |
| 3858 | + | |
3825 | 3859 | | |
3826 | 3860 | | |
3827 | 3861 | | |
| |||
0 commit comments