Skip to content

Commit e2bddc2

Browse files
committed
Merge branch 'x86-hyperv-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 hyperv updates from Ingo Molnar: "Misc updates related to page size abstractions within the HyperV code, in preparation for future features" * 'x86-hyperv-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: drivers: hv: vmbus: Replace page definition with Hyper-V specific one x86/hyperv: Add functions to allocate/deallocate page for Hyper-V x86/hyperv: Create and use Hyper-V page definitions
2 parents 6f24671 + 83527ef commit e2bddc2

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

arch/x86/hyperv/hv_init.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@ EXPORT_SYMBOL_GPL(hyperv_pcpu_input_arg);
3737
u32 hv_max_vp_index;
3838
EXPORT_SYMBOL_GPL(hv_max_vp_index);
3939

40+
void *hv_alloc_hyperv_page(void)
41+
{
42+
BUILD_BUG_ON(PAGE_SIZE != HV_HYP_PAGE_SIZE);
43+
44+
return (void *)__get_free_page(GFP_KERNEL);
45+
}
46+
EXPORT_SYMBOL_GPL(hv_alloc_hyperv_page);
47+
48+
void hv_free_hyperv_page(unsigned long addr)
49+
{
50+
free_page(addr);
51+
}
52+
EXPORT_SYMBOL_GPL(hv_free_hyperv_page);
53+
4054
static int hv_cpu_init(unsigned int cpu)
4155
{
4256
u64 msr_vp_index;

arch/x86/include/asm/hyperv-tlfs.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
#include <linux/types.h>
1313
#include <asm/page.h>
1414

15+
/*
16+
* While not explicitly listed in the TLFS, Hyper-V always runs with a page size
17+
* of 4096. These definitions are used when communicating with Hyper-V using
18+
* guest physical pages and guest physical page addresses, since the guest page
19+
* size may not be 4096 on all architectures.
20+
*/
21+
#define HV_HYP_PAGE_SHIFT 12
22+
#define HV_HYP_PAGE_SIZE BIT(HV_HYP_PAGE_SHIFT)
23+
#define HV_HYP_PAGE_MASK (~(HV_HYP_PAGE_SIZE - 1))
24+
1525
/*
1626
* The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
1727
* is set by CPUID(HvCpuIdFunctionVersionAndFeatures).
@@ -847,7 +857,7 @@ union hv_gpa_page_range {
847857
* count is equal with how many entries of union hv_gpa_page_range can
848858
* be populated into the input parameter page.
849859
*/
850-
#define HV_MAX_FLUSH_REP_COUNT ((PAGE_SIZE - 2 * sizeof(u64)) / \
860+
#define HV_MAX_FLUSH_REP_COUNT ((HV_HYP_PAGE_SIZE - 2 * sizeof(u64)) / \
851861
sizeof(union hv_gpa_page_range))
852862

853863
struct hv_guest_mapping_flush_list {

arch/x86/include/asm/mshyperv.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ static inline struct hv_vp_assist_page *hv_get_vp_assist_page(unsigned int cpu)
218218

219219
void __init hyperv_init(void);
220220
void hyperv_setup_mmu_ops(void);
221-
221+
void *hv_alloc_hyperv_page(void);
222+
void hv_free_hyperv_page(unsigned long addr);
222223
void hyperv_reenlightenment_intr(struct pt_regs *regs);
223224
void set_hv_tscchange_cb(void (*cb)(void));
224225
void clear_hv_tscchange_cb(void);
@@ -241,6 +242,8 @@ static inline void hv_apic_init(void) {}
241242
#else /* CONFIG_HYPERV */
242243
static inline void hyperv_init(void) {}
243244
static inline void hyperv_setup_mmu_ops(void) {}
245+
static inline void *hv_alloc_hyperv_page(void) { return NULL; }
246+
static inline void hv_free_hyperv_page(unsigned long addr) {}
244247
static inline void set_hv_tscchange_cb(void (*cb)(void)) {}
245248
static inline void clear_hv_tscchange_cb(void) {}
246249
static inline void hyperv_stop_tsc_emulation(void) {};

drivers/hv/hyperv_vmbus.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,11 @@ int hv_ringbuffer_read(struct vmbus_channel *channel,
190190
u64 *requestid, bool raw);
191191

192192
/*
193-
* Maximum channels is determined by the size of the interrupt page
194-
* which is PAGE_SIZE. 1/2 of PAGE_SIZE is for send endpoint interrupt
195-
* and the other is receive endpoint interrupt
193+
* The Maximum number of channels (16348) is determined by the size of the
194+
* interrupt page, which is HV_HYP_PAGE_SIZE. 1/2 of HV_HYP_PAGE_SIZE is to
195+
* send endpoint interrupts, and the other is to receive endpoint interrupts.
196196
*/
197-
#define MAX_NUM_CHANNELS ((PAGE_SIZE >> 1) << 3) /* 16348 channels */
197+
#define MAX_NUM_CHANNELS ((HV_HYP_PAGE_SIZE >> 1) << 3)
198198

199199
/* The value here must be in multiple of 32 */
200200
/* TODO: Need to make this configurable */

0 commit comments

Comments
 (0)