Add a helper, is_transparent_hugepage(), to explicitly check whether a compound page is a THP and use it when populating KVM's secondary MMU. The explicit check fixes a bug where a remapped compound page, e.g. for an XDP Rx socket, is mapped into a KVM guest and is mistaken for a THP, which results in KVM incorrectly creating a huge page in its secondary MMU.
Showing the changes to include/linux (2 of 6 files). Show all
Unified · Split
| @@ -160,6 +160,7 @@ extern unsigned long thp_get_unmapped_area(struct file *filp, · 159 unmodified lines | |||
| 160 | 160 | ||
| 161 | extern void prep_transhuge_page(struct page *page); | 161 | extern void prep_transhuge_page(struct page *page); |
| 162 | extern void free_transhuge_page(struct page *page); | 162 | extern void free_transhuge_page(struct page *page); |
| 163 | bool is_transparent_hugepage(struct page *page); | ||
| 163 | 164 | ||
| 164 | bool can_split_huge_page(struct page *page, int *pextra_pins); | 165 | bool can_split_huge_page(struct page *page, int *pextra_pins); |
| 165 | int split_huge_page_to_list(struct page *page, struct list_head *list); | 166 | int split_huge_page_to_list(struct page *page, struct list_head *list); |
| @@ -308,6 +309,11 @@ static inline bool transhuge_vma_suitable(struct vm_area_struct *vma, · 142 unmodified lines | |||
| 308 | 309 | ||
| 309 | static inline void prep_transhuge_page(struct page *page) {} | 310 | static inline void prep_transhuge_page(struct page *page) {} |
| 310 | 311 | ||
| 312 | static inline bool is_transparent_hugepage(struct page *page) | ||
| 313 | { | ||
| 314 | return false; | ||
| 315 | } | ||
| 316 | |||
| 311 | #define transparent_hugepage_flags 0UL | 317 | #define transparent_hugepage_flags 0UL |
| 312 | 318 | ||
| 313 | #define thp_get_unmapped_area NULL | 319 | #define thp_get_unmapped_area NULL |
| @@ -976,6 +976,7 @@ int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu); · 975 unmodified lines | |||
| 976 | 976 | ||
| 977 | bool kvm_is_reserved_pfn(kvm_pfn_t pfn); | 977 | bool kvm_is_reserved_pfn(kvm_pfn_t pfn); |
| 978 | bool kvm_is_zone_device_pfn(kvm_pfn_t pfn); | 978 | bool kvm_is_zone_device_pfn(kvm_pfn_t pfn); |
| 979 | bool kvm_is_transparent_hugepage(kvm_pfn_t pfn); | ||
| 979 | 980 | ||
| 980 | struct kvm_irq_ack_notifier { | 981 | struct kvm_irq_ack_notifier { |
| 981 | struct hlist_node link; | 982 | struct hlist_node link; |