Drivers: hv: vmbus: Remove x86-isms in arch independent code
Subsystems (2)
cover Drivers: hv: vmbus: Remove x86-isms in arch independent code
From: Michael Kelley <[email protected]>
More changes to cleanly separate architecture independent code from architecture dependent code. The first patch moves x86-specific code out of the Hyper-V architecture independent drivers and into the arch/x86 directory. The second patch removes the string "X64" from symbol names that aren't x86/x64-specific.
These changes are preparation for supporting Hyper-V on ARM64.
Michael Kelley (2):
Drivers: hv: vmbus: Remove x86 MSR refs in arch independent code
Drivers: hv: vmbus: Make TLFS #define names architecture neutral
arch/x86/hyperv/hv_init.c | 4 ++-- arch/x86/include/asm/hyperv-tlfs.h | 12 ++++++------ arch/x86/include/asm/mshyperv.h | 12 ++++++++---- arch/x86/kernel/cpu/mshyperv.c | 4 ++-- drivers/hv/hv.c | 30 +++++++++++++----------------- 5 files changed, 31 insertions(+), 31 deletions(-)
Signature · 6 lines
2.7.4 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 1/2 Drivers: hv: vmbus: Remove x86 MSR refs in arch independent code
From: Michael Kelley <[email protected]>
In architecture independent code for manipulating Hyper-V synthetic timers and synthetic interrupts, pass in an ordinal number identifying the timer or interrupt, rather than an actual MSR register address. Then in x86/x64 specific code, map the ordinal number to the appropriate MSR. This change facilitates the introduction of an ARM64 version of Hyper-V, which uses the same synthetic timers and interrupts, but a different mechanism for accessing them.
--- arch/x86/include/asm/mshyperv.h | 12 ++++++++---- drivers/hv/hv.c | 20 ++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-)
arch/x86/include/asm/mshyperv.h +8 -4
@@ -75,8 +75,10 @@ static inline void vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type) } } -#define hv_init_timer (timer, tick) wrmsrl(timer, tick) -#define hv_init_timer_config (config, val) wrmsrl(config, val) +#define hv_init_timer (timer, tick) \ + wrmsrl(HV_X64_MSR_STIMER0_COUNT + (2*timer), tick) +#define hv_init_timer_config (timer, val) \ + wrmsrl(HV_X64_MSR_STIMER0_CONFIG + (2*timer), val)#define hv_get_simp (val) rdmsrl(HV_X64_MSR_SIMP, val)#define hv_set_simp (val) wrmsrl(HV_X64_MSR_SIMP, val)
@@ -89,8 +91,10 @@ static inline void vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type)#define hv_get_vp_index (index) rdmsrl(HV_X64_MSR_VP_INDEX, index) -#define hv_get_synint_state (int_num, val) rdmsrl(int_num, val) -#define hv_set_synint_state (int_num, val) wrmsrl(int_num, val) +#define hv_get_synint_state (int_num, val) \ + rdmsrl(HV_X64_MSR_SINT0 + int_num, val) +#define hv_set_synint_state (int_num, val) \ + wrmsrl(HV_X64_MSR_SINT0 + int_num, val)void hyperv_callback_vector (void );void hyperv_reenlightenment_vector (void );
drivers/hv/hv.c +8 -12
@@ -127,14 +127,14 @@ static int hv_ce_set_next_event(unsigned long delta, current_tick = hyperv_cs->read (NULL ); current_tick += delta; -hv_init_timer (HV_X64_MSR_STIMER0_COUNT , current_tick); +hv_init_timer (0 , current_tick);return 0 ; }static int hv_ce_shutdown (struct clock_event_device *evt) { -hv_init_timer (HV_X64_MSR_STIMER0_COUNT ,0 ); -hv_init_timer_config (HV_X64_MSR_STIMER0_CONFIG ,0 ); +hv_init_timer (0 ,0 ); +hv_init_timer_config (0 ,0 );if (direct_mode_enabled)hv_disable_stimer0_percpu_irq (stimer0_irq);
@@ -164,7 +164,7 @@ static int hv_ce_set_oneshot(struct clock_event_device *evt) timer_cfg.direct_mode =0 ; timer_cfg.sintx =VMBUS_MESSAGE_SINT ; } -hv_init_timer_config (HV_X64_MSR_STIMER0_CONFIG , timer_cfg.as_uint64); +hv_init_timer_config (0 , timer_cfg.as_uint64);return 0 ; }
@@ -298,8 +298,7 @@ int hv_synic_init(unsigned int cpu)hv_set_siefp (siefp.as_uint64);/* Setup the shared SINT. */ -hv_get_synint_state (HV_X64_MSR_SINT0 +VMBUS_MESSAGE_SINT , - shared_sint.as_uint64); +hv_get_synint_state (VMBUS_MESSAGE_SINT , shared_sint.as_uint64); shared_sint.vector =HYPERVISOR_CALLBACK_VECTOR ; shared_sint.masked = false;
@@ -308,8 +307,7 @@ int hv_synic_init(unsigned int cpu)else shared_sint.auto_eoi = true; -hv_set_synint_state (HV_X64_MSR_SINT0 +VMBUS_MESSAGE_SINT , - shared_sint.as_uint64); +hv_set_synint_state (VMBUS_MESSAGE_SINT , shared_sint.as_uint64);/* Enable the global synic bit */ hv_get_synic_state (sctrl.as_uint64);
@@ -405,15 +403,13 @@ int hv_synic_cleanup(unsigned int cpu)put_cpu_ptr (hv_cpu); } -hv_get_synint_state (HV_X64_MSR_SINT0 +VMBUS_MESSAGE_SINT , - shared_sint.as_uint64); +hv_get_synint_state (VMBUS_MESSAGE_SINT , shared_sint.as_uint64); shared_sint.masked =1 ;/* Need to correctly cleanup in the case of SMP!!! */ /* Disable the interrupt */ -hv_set_synint_state (HV_X64_MSR_SINT0 +VMBUS_MESSAGE_SINT , - shared_sint.as_uint64); +hv_set_synint_state (VMBUS_MESSAGE_SINT , shared_sint.as_uint64);hv_get_simp (simp.as_uint64); simp.simp_enabled =0 ;
Signature · 6 lines
2.7.4 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH char-misc 1/2] Drivers: hv: vmbus: Remove x86 MSR refs in arch independent code
Quoted 36 lines
-----Original Message-----
From: [email protected] <[email protected]>
Sent: Tuesday, May 8, 2018 8:38 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Stephen Hemminger <[email protected]>; KY Srinivasan <[email protected]>
Subject: [PATCH char-misc 1/2] Drivers: hv: vmbus: Remove x86 MSR refs in arch independent codeFrom: Michael Kelley <[email protected]>
In architecture independent code for manipulating Hyper-V synthetic timers and synthetic interrupts, pass in an ordinal number identifying the timer or interrupt, rather than an actual MSR register address. Then in x86/x64 specific code, map the ordinal number to the appropriate MSR. This change facilitates the introduction of an ARM64 version of Hyper-V, which uses the same synthetic timers and interrupts, but a different mechanism for accessing them.
Signed-off-by Michael Kelley <[email protected]>--- arch/x86/include/asm/mshyperv.h | 12 ++++++++---- drivers/hv/hv.c | 20 ++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-)arch/x86/include/asm/mshyperv.h +0
-0
arch/x86/include/asm/mshyperv.h static inline void vmbus_signal_eom(struct · line 82
Quoted 10 lines
arch/x86/include/asm/mshyperv.h +4
-2@@ -75,8 +75,10 @@ static inline void vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type) } } -#define hv_init_timer (timer, tick) wrmsrl(timer, tick) -#define hv_init_timer_config (config, val) wrmsrl(config, val) +#define hv_init_timer (timer, tick) \ + wrmsrl(HV_X64_MSR_STIMER0_COUNT + (2*timer), tick) +#define hv_init_timer_config (timer, val) \ + wrmsrl(HV_X64_MSR_STIMER0_CONFIG + (2*timer), val)
Why are we stepping in units of 2?
K. Y
RE: [PATCH char-misc 1/2] Drivers: hv: vmbus: Remove x86 MSR refs in arch independent code
Quoted 10 lines
arch/x86/include/asm/mshyperv.h static inline void vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type) · line 81
Quoted 6 lines
arch/x86/include/asm/mshyperv.h +4
-2-#define hv_init_timer (timer, tick) wrmsrl(timer, tick) -#define hv_init_timer_config (config, val) wrmsrl(config, val) +#define hv_init_timer (timer, tick) \ + wrmsrl(HV_X64_MSR_STIMER0_COUNT + (2*timer), tick) +#define hv_init_timer_config (timer, val) \ + wrmsrl(HV_X64_MSR_STIMER0_CONFIG + (2*timer), val)Why are we stepping in units of 2?
K. Y
The register addresses for the *_CONFIG and *_COUNT registers are interleaved. From hyperv-tlfs.h:
#define HV_X64_MSR_STIMER0_CONFIG 0x400000B0 #define HV_X64_MSR_STIMER0_COUNT 0x400000B1 #define HV_X64_MSR_STIMER1_CONFIG 0x400000B2 #define HV_X64_MSR_STIMER1_COUNT 0x400000B3 #define HV_X64_MSR_STIMER2_CONFIG 0x400000B4 #define HV_X64_MSR_STIMER2_COUNT 0x400000B5 #define HV_X64_MSR_STIMER3_CONFIG 0x400000B6 #define HV_X64_MSR_STIMER3_COUNT 0x400000B7
Michael
PATCH 2/2 Drivers: hv: vmbus: Make TLFS #define names architecture neutral
In reply to [email protected]From: Michael Kelley <[email protected]>
The Hyper-V feature and hint flags in hyperv-tlfs.h are all defined with the string "X64" in the name. Some of these flags are indeed x86/x64 specific, but others are not. For the ones that are used in architecture independent Hyper-V driver code, or will be used in the upcoming support for Hyper-V for ARM64, this patch removes the "X64" from the name.
This patch changes the flags that are currently known to be used on multiple architectures. Hyper-V for ARM64 is still a work-in-progress and the Top Level Functional Spec (TLFS) has not been separated into x86/x64 and ARM64 areas. So additional flags may need to be updated later.
This patch only changes symbol names. There are no functional changes.
--- arch/x86/hyperv/hv_init.c | 4 ++-- arch/x86/include/asm/hyperv-tlfs.h | 12 ++++++------ arch/x86/kernel/cpu/mshyperv.c | 4 ++-- drivers/hv/hv.c | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-)
arch/x86/hyperv/hv_init.c +2 -2
@@ -302,7 +302,7 @@ void hyperv_init(void)* Register Hyper-V specific clocksource. */ #ifdef CONFIG_HYPERV_TSCPAGE -if (ms_hyperv.features &HV_X64_MSR_REFERENCE_TSC_AVAILABLE ) { +if (ms_hyperv.features &HV_MSR_REFERENCE_TSC_AVAILABLE ) {union hv_x64_msr_hypercall_contents tsc_msr; tsc_pg =__vmalloc (PAGE_SIZE ,GFP_KERNEL ,PAGE_KERNEL );
@@ -331,7 +331,7 @@ void hyperv_init(void)*/ hyperv_cs = &hyperv_cs_msr; -if (ms_hyperv.features &HV_X64_MSR_TIME_REF_COUNT_AVAILABLE ) +if (ms_hyperv.features &HV_MSR_TIME_REF_COUNT_AVAILABLE )clocksource_register_hz (&hyperv_cs_msr,NSEC_PER_SEC /100 );return ;
arch/x86/include/asm/hyperv-tlfs.h +6 -6
@@ -35,9 +35,9 @@/* VP Runtime (HV_X64_MSR_VP_RUNTIME) available */ #define HV_X64_MSR_VP_RUNTIME_AVAILABLE (1 << 0)/* Partition Reference Counter (HV_X64_MSR_TIME_REF_COUNT) available*/ -#define HV_X64_MSR_TIME_REF_COUNT_AVAILABLE (1 << 1) +#define HV_MSR_TIME_REF_COUNT_AVAILABLE (1 << 1)/* Partition reference TSC MSR is available */ -#define HV_X64_MSR_REFERENCE_TSC_AVAILABLE (1 << 9) +#define HV_MSR_REFERENCE_TSC_AVAILABLE (1 << 9)/* A partition's reference time stamp counter (TSC) page */ #define HV_X64_MSR_REFERENCE_TSC 0x40000021
@@ -60,7 +60,7 @@* Synthetic Timer MSRs (HV_X64_MSR_STIMER0_CONFIG through * HV_X64_MSR_STIMER3_COUNT) available */ -#define HV_X64_MSR_SYNTIMER_AVAILABLE (1 << 3) +#define HV_MSR_SYNTIMER_AVAILABLE (1 << 3)/* * APIC access MSRs (HV_X64_MSR_EOI, HV_X64_MSR_ICR and HV_X64_MSR_TPR) * are available
@@ -86,7 +86,7 @@#define HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE (1 << 10)/* stimer Direct Mode is available */ -#define HV_X64_STIMER_DIRECT_MODE_AVAILABLE (1 << 19) +#define HV_STIMER_DIRECT_MODE_AVAILABLE (1 << 19)/* * Feature identification: EBX indicates which flags were specified at
@@ -160,9 +160,9 @@#define HV_X64_RELAXED_TIMING_RECOMMENDED (1 << 5)/* -* Virtual APIC support +* Recommend not using Auto End-Of-Interrupt feature */ -#define HV_X64_DEPRECATING_AEOI_RECOMMENDED (1 << 9) +#define HV_DEPRECATING_AEOI_RECOMMENDED (1 << 9)/* Recommend using the newer ExProcessorMasks interface */ #define HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED (1 << 11)
arch/x86/kernel/cpu/mshyperv.c +2 -2
@@ -50,7 +50,7 @@ void hyperv_vector_handler(struct pt_regs *regs)if (vmbus_handler)vmbus_handler (); -if (ms_hyperv.hints &HV_X64_DEPRECATING_AEOI_RECOMMENDED ) +if (ms_hyperv.hints &HV_DEPRECATING_AEOI_RECOMMENDED )ack_APIC_irq ();exiting_irq ();
@@ -300,7 +300,7 @@ static void __init ms_hyperv_init_platform(void) hyperv_reenlightenment_vector);/* Setup the IDT for stimer0 */ -if (ms_hyperv.misc_features &HV_X64_STIMER_DIRECT_MODE_AVAILABLE ) +if (ms_hyperv.misc_features &HV_STIMER_DIRECT_MODE_AVAILABLE )alloc_intr_gate (HYPERV_STIMER0_VECTOR , hv_stimer0_callback_vector);#endif
drivers/hv/hv.c +5 -5
@@ -64,7 +64,7 @@ int hv_init(void)return -ENOMEM ; direct_mode_enabled = ms_hyperv.misc_features & -HV_X64_STIMER_DIRECT_MODE_AVAILABLE ; +HV_STIMER_DIRECT_MODE_AVAILABLE ;return 0 ; }
@@ -302,7 +302,7 @@ int hv_synic_init(unsigned int cpu) shared_sint.vector =HYPERVISOR_CALLBACK_VECTOR ; shared_sint.masked = false; -if (ms_hyperv.hints &HV_X64_DEPRECATING_AEOI_RECOMMENDED ) +if (ms_hyperv.hints &HV_DEPRECATING_AEOI_RECOMMENDED ) shared_sint.auto_eoi = false;else shared_sint.auto_eoi = true;
@@ -320,7 +320,7 @@ int hv_synic_init(unsigned int cpu)/* * Register the per-cpu clockevent source. */ -if (ms_hyperv.features &HV_X64_MSR_SYNTIMER_AVAILABLE ) +if (ms_hyperv.features &HV_MSR_SYNTIMER_AVAILABLE ) clockevents_config_and_register(hv_cpu->clk_evt, HV_TIMER_FREQUENCY, HV_MIN_DELTA_TICKS,
@@ -335,7 +335,7 @@ void hv_synic_clockevents_cleanup(void) {int cpu; -if (!(ms_hyperv.features &HV_X64_MSR_SYNTIMER_AVAILABLE )) +if (!(ms_hyperv.features &HV_MSR_SYNTIMER_AVAILABLE ))return ;if (direct_mode_enabled)
@@ -394,7 +394,7 @@ int hv_synic_cleanup(unsigned int cpu)return -EBUSY ;/* Turn off clockevent device */ -if (ms_hyperv.features &HV_X64_MSR_SYNTIMER_AVAILABLE ) { +if (ms_hyperv.features &HV_MSR_SYNTIMER_AVAILABLE ) {struct hv_per_cpu_context *hv_cpu =this_cpu_ptr (hv_context.cpu_context);
Signature · 6 lines
2.7.4 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel