Commit afd12f91 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'hyperv-fixes-signed-20260112' of...

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
parents b71e635f 173d6f64
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -142,6 +142,7 @@ int hv_call_get_partition_property(u64 partition_id,
}
EXPORT_SYMBOL_GPL(hv_call_get_partition_property);

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

}
#endif
+11 −9
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ static long mshv_region_process_chunk(struct mshv_mem_region *region,

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

	stride = 1 << page_order;
@@ -494,13 +494,6 @@ static bool mshv_region_interval_invalidate(struct mmu_interval_notifier *mni,
	unsigned long mstart, mend;
	int ret = -EPERM;

	if (mmu_notifier_range_blockable(range))
		mutex_lock(&region->mutex);
	else if (!mutex_trylock(&region->mutex))
		goto out_fail;

	mmu_interval_set_seq(mni, cur_seq);

	mstart = max(range->start, region->start_uaddr);
	mend = min(range->end, region->start_uaddr +
		   (region->nr_pages << HV_HYP_PAGE_SHIFT));
@@ -508,10 +501,17 @@ static bool mshv_region_interval_invalidate(struct mmu_interval_notifier *mni,
	page_offset = HVPFN_DOWN(mstart - region->start_uaddr);
	page_count = HVPFN_DOWN(mend - mstart);

	if (mmu_notifier_range_blockable(range))
		mutex_lock(&region->mutex);
	else if (!mutex_trylock(&region->mutex))
		goto out_fail;

	mmu_interval_set_seq(mni, cur_seq);

	ret = mshv_region_remap_pages(region, HV_MAP_GPA_NO_ACCESS,
				      page_offset, page_count);
	if (ret)
		goto out_fail;
		goto out_unlock;

	mshv_region_invalidate_pages(region, page_offset, page_count);

@@ -519,6 +519,8 @@ static bool mshv_region_interval_invalidate(struct mmu_interval_notifier *mni,

	return true;

out_unlock:
	mutex_unlock(&region->mutex);
out_fail:
	WARN_ONCE(ret,
		  "Failed to invalidate region %#llx-%#llx (range %#lx-%#lx, event: %u, pages %#llx-%#llx, mm: %#llx): %d\n",
+5 −2
Original line number Diff line number Diff line
@@ -578,9 +578,12 @@ struct hv_tlb_flush { /* HV_INPUT_FLUSH_VIRTUAL_ADDRESS_LIST */
struct hv_tlb_flush_ex {
	u64 address_space;
	u64 flags;
	struct hv_vpset hv_vp_set;
	__TRAILING_OVERLAP(struct hv_vpset, hv_vp_set, bank_contents, __packed,
		u64 gva_list[];
	);
} __packed;
static_assert(offsetof(struct hv_tlb_flush_ex, hv_vp_set.bank_contents) ==
	      offsetof(struct hv_tlb_flush_ex, gva_list));

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