Skip to content

Commit afd12f9

Browse files
committed
Merge tag 'hyperv-fixes-signed-20260112' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux
Pull hyperv fixes from Wei Liu: - Minor fixes and cleanups for the MSHV driver * tag 'hyperv-fixes-signed-20260112' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux: mshv: release mutex on region invalidation failure hyperv: Avoid -Wflex-array-member-not-at-end warning mshv: hide x86-specific functions on arm64 mshv: Initialize local variables early upon region invalidation mshv: Use PMD_ORDER instead of HPAGE_PMD_ORDER when processing regions
2 parents b71e635 + 173d6f6 commit afd12f9

3 files changed

Lines changed: 18 additions & 11 deletions

File tree

drivers/hv/mshv_common.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ int hv_call_get_partition_property(u64 partition_id,
142142
}
143143
EXPORT_SYMBOL_GPL(hv_call_get_partition_property);
144144

145+
#ifdef CONFIG_X86
145146
/*
146147
* Corresponding sleep states have to be initialized in order for a subsequent
147148
* HVCALL_ENTER_SLEEP_STATE call to succeed. Currently only S5 state as per
@@ -237,3 +238,4 @@ void hv_machine_power_off(void)
237238
BUG();
238239

239240
}
241+
#endif

drivers/hv/mshv_regions.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static long mshv_region_process_chunk(struct mshv_mem_region *region,
5858

5959
page_order = folio_order(page_folio(page));
6060
/* The hypervisor only supports 4K and 2M page sizes */
61-
if (page_order && page_order != HPAGE_PMD_ORDER)
61+
if (page_order && page_order != PMD_ORDER)
6262
return -EINVAL;
6363

6464
stride = 1 << page_order;
@@ -494,31 +494,33 @@ static bool mshv_region_interval_invalidate(struct mmu_interval_notifier *mni,
494494
unsigned long mstart, mend;
495495
int ret = -EPERM;
496496

497-
if (mmu_notifier_range_blockable(range))
498-
mutex_lock(&region->mutex);
499-
else if (!mutex_trylock(&region->mutex))
500-
goto out_fail;
501-
502-
mmu_interval_set_seq(mni, cur_seq);
503-
504497
mstart = max(range->start, region->start_uaddr);
505498
mend = min(range->end, region->start_uaddr +
506499
(region->nr_pages << HV_HYP_PAGE_SHIFT));
507500

508501
page_offset = HVPFN_DOWN(mstart - region->start_uaddr);
509502
page_count = HVPFN_DOWN(mend - mstart);
510503

504+
if (mmu_notifier_range_blockable(range))
505+
mutex_lock(&region->mutex);
506+
else if (!mutex_trylock(&region->mutex))
507+
goto out_fail;
508+
509+
mmu_interval_set_seq(mni, cur_seq);
510+
511511
ret = mshv_region_remap_pages(region, HV_MAP_GPA_NO_ACCESS,
512512
page_offset, page_count);
513513
if (ret)
514-
goto out_fail;
514+
goto out_unlock;
515515

516516
mshv_region_invalidate_pages(region, page_offset, page_count);
517517

518518
mutex_unlock(&region->mutex);
519519

520520
return true;
521521

522+
out_unlock:
523+
mutex_unlock(&region->mutex);
522524
out_fail:
523525
WARN_ONCE(ret,
524526
"Failed to invalidate region %#llx-%#llx (range %#lx-%#lx, event: %u, pages %#llx-%#llx, mm: %#llx): %d\n",

include/hyperv/hvgdk_mini.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,9 +578,12 @@ struct hv_tlb_flush { /* HV_INPUT_FLUSH_VIRTUAL_ADDRESS_LIST */
578578
struct hv_tlb_flush_ex {
579579
u64 address_space;
580580
u64 flags;
581-
struct hv_vpset hv_vp_set;
582-
u64 gva_list[];
581+
__TRAILING_OVERLAP(struct hv_vpset, hv_vp_set, bank_contents, __packed,
582+
u64 gva_list[];
583+
);
583584
} __packed;
585+
static_assert(offsetof(struct hv_tlb_flush_ex, hv_vp_set.bank_contents) ==
586+
offsetof(struct hv_tlb_flush_ex, gva_list));
584587

585588
struct ms_hyperv_tsc_page { /* HV_REFERENCE_TSC_PAGE */
586589
volatile u32 tsc_sequence;

0 commit comments

Comments
 (0)