[PATCH 04/31] KVM: x86: Switch to use hrtimer_setup()

Nam Cao posted 31 patches 4 weeks ago
[PATCH 04/31] KVM: x86: Switch to use hrtimer_setup()
Posted by Nam Cao 4 weeks ago
There is a newly introduced hrtimer_setup() which will replace
hrtimer_init(). This new function is similar to the old one, except that it
also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Sean Christopherson <seanjc@google.com>
---
 arch/x86/kvm/hyperv.c     | 3 +--
 arch/x86/kvm/i8254.c      | 3 +--
 arch/x86/kvm/lapic.c      | 5 ++---
 arch/x86/kvm/vmx/nested.c | 5 ++---
 arch/x86/kvm/xen.c        | 5 ++---
 5 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index 4f0a94346d00..19ea425a7264 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -952,8 +952,7 @@ static void stimer_init(struct kvm_vcpu_hv_stimer *stimer, int timer_index)
 {
 	memset(stimer, 0, sizeof(*stimer));
 	stimer->index = timer_index;
-	hrtimer_init(&stimer->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-	stimer->timer.function = stimer_timer_callback;
+	hrtimer_setup(&stimer->timer, stimer_timer_callback, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
 	stimer_prepare_msg(stimer);
 }
 
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
index cd57a517d04a..9342442e9650 100644
--- a/arch/x86/kvm/i8254.c
+++ b/arch/x86/kvm/i8254.c
@@ -690,8 +690,7 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm, u32 flags)
 	pit->kvm = kvm;
 
 	pit_state = &pit->pit_state;
-	hrtimer_init(&pit_state->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-	pit_state->timer.function = pit_timer_fn;
+	hrtimer_setup(&pit_state->timer, pit_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
 
 	pit_state->irq_ack_notifier.gsi = 0;
 	pit_state->irq_ack_notifier.irq_acked = kvm_pit_ack_irq;
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 2098dc689088..1cfcd9125ffb 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -2887,9 +2887,8 @@ int kvm_create_lapic(struct kvm_vcpu *vcpu)
 
 	apic->nr_lvt_entries = kvm_apic_calc_nr_lvt_entries(vcpu);
 
-	hrtimer_init(&apic->lapic_timer.timer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_ABS_HARD);
-	apic->lapic_timer.timer.function = apic_timer_fn;
+	hrtimer_setup(&apic->lapic_timer.timer, apic_timer_fn, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_ABS_HARD);
 	if (lapic_timer_advance)
 		apic->lapic_timer.timer_advance_ns = LAPIC_TIMER_ADVANCE_NS_INIT;
 
diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index a8e7bc04d9bf..c8cdf2ef00aa 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -5279,9 +5279,8 @@ static int enter_vmx_operation(struct kvm_vcpu *vcpu)
 	if (enable_shadow_vmcs && !alloc_shadow_vmcs(vcpu))
 		goto out_shadow_vmcs;
 
-	hrtimer_init(&vmx->nested.preemption_timer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_ABS_PINNED);
-	vmx->nested.preemption_timer.function = vmx_preemption_timer_fn;
+	hrtimer_setup(&vmx->nested.preemption_timer, vmx_preemption_timer_fn, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_ABS_PINNED);
 
 	vmx->nested.vpid02 = allocate_vpid();
 
diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c
index c386fbe6b58d..73e85b1ebb08 100644
--- a/arch/x86/kvm/xen.c
+++ b/arch/x86/kvm/xen.c
@@ -265,9 +265,8 @@ static void kvm_xen_stop_timer(struct kvm_vcpu *vcpu)
 
 static void kvm_xen_init_timer(struct kvm_vcpu *vcpu)
 {
-	hrtimer_init(&vcpu->arch.xen.timer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_ABS_HARD);
-	vcpu->arch.xen.timer.function = xen_timer_callback;
+	hrtimer_setup(&vcpu->arch.xen.timer, xen_timer_callback, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_ABS_HARD);
 }
 
 static void kvm_xen_update_runstate_guest(struct kvm_vcpu *v, bool atomic)
-- 
2.39.5
Re: [PATCH 04/31] KVM: x86: Switch to use hrtimer_setup()
Posted by kernel test robot 3 weeks, 6 days ago
Hi Nam,

kernel test robot noticed the following build errors:

[auto build test ERROR on kvm/queue]
[also build test ERROR on tip/sched/core perf-tools-next/perf-tools-next tip/perf/core perf-tools/perf-tools tip/timers/core axboe-block/for-next linus/master v6.12-rc5 next-20241028]
[cannot apply to kvm/linux-next acme/perf/core]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Nam-Cao/KVM-MIPS-Switch-to-use-hrtimer_setup/20241028-154142
base:   https://git.kernel.org/pub/scm/virt/kvm/kvm.git queue
patch link:    https://lore.kernel.org/r/8774212e6c10c550743219e00738492eb379227c.1729864823.git.namcao%40linutronix.de
patch subject: [PATCH 04/31] KVM: x86: Switch to use hrtimer_setup()
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20241029/202410290239.urBaNd5D-lkp@intel.com/config)
compiler: clang version 19.1.2 (https://github.com/llvm/llvm-project 7ba7d8e2f7b6445b60679da826210cdde29eaf8b)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241029/202410290239.urBaNd5D-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410290239.urBaNd5D-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from arch/x86/kvm/lapic.c:20:
   In file included from include/linux/kvm_host.h:16:
   In file included from include/linux/mm.h:2213:
   include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     504 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     505 |                            item];
         |                            ~~~~
   include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     511 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     512 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     524 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     525 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
>> arch/x86/kvm/lapic.c:2878:2: error: call to undeclared function 'hrtimer_setup'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    2878 |         hrtimer_setup(&apic->lapic_timer.timer, apic_timer_fn, CLOCK_MONOTONIC,
         |         ^
   arch/x86/kvm/lapic.c:2878:2: note: did you mean 'hrtimer_start'?
   include/linux/hrtimer.h:272:20: note: 'hrtimer_start' declared here
     272 | static inline void hrtimer_start(struct hrtimer *timer, ktime_t tim,
         |                    ^
   4 warnings and 1 error generated.
--
   In file included from arch/x86/kvm/i8254.c:35:
   In file included from include/linux/kvm_host.h:16:
   In file included from include/linux/mm.h:2213:
   include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     504 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     505 |                            item];
         |                            ~~~~
   include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     511 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     512 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     524 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     525 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
>> arch/x86/kvm/i8254.c:693:2: error: call to undeclared function 'hrtimer_setup'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     693 |         hrtimer_setup(&pit_state->timer, pit_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
         |         ^
   arch/x86/kvm/i8254.c:693:2: note: did you mean 'hrtimer_start'?
   include/linux/hrtimer.h:272:20: note: 'hrtimer_start' declared here
     272 | static inline void hrtimer_start(struct hrtimer *timer, ktime_t tim,
         |                    ^
   4 warnings and 1 error generated.
--
   In file included from arch/x86/kvm/hyperv.c:22:
   In file included from arch/x86/kvm/x86.h:5:
   In file included from include/linux/kvm_host.h:16:
   In file included from include/linux/mm.h:2213:
   include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     504 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     505 |                            item];
         |                            ~~~~
   include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     511 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     512 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     524 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     525 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
>> arch/x86/kvm/hyperv.c:955:2: error: call to undeclared function 'hrtimer_setup'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     955 |         hrtimer_setup(&stimer->timer, stimer_timer_callback, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
         |         ^
   arch/x86/kvm/hyperv.c:955:2: note: did you mean 'hrtimer_start'?
   include/linux/hrtimer.h:272:20: note: 'hrtimer_start' declared here
     272 | static inline void hrtimer_start(struct hrtimer *timer, ktime_t tim,
         |                    ^
   4 warnings and 1 error generated.
--
   In file included from arch/x86/kvm/vmx/nested.c:8:
   In file included from arch/x86/include/asm/mmu_context.h:8:
   In file included from include/linux/pkeys.h:5:
   In file included from include/linux/mm.h:2213:
   include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     504 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     505 |                            item];
         |                            ~~~~
   include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     511 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     512 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     524 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     525 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
>> arch/x86/kvm/vmx/nested.c:5278:2: error: call to undeclared function 'hrtimer_setup'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    5278 |         hrtimer_setup(&vmx->nested.preemption_timer, vmx_preemption_timer_fn, CLOCK_MONOTONIC,
         |         ^
   arch/x86/kvm/vmx/nested.c:5278:2: note: did you mean 'hrtimer_start'?
   include/linux/hrtimer.h:272:20: note: 'hrtimer_start' declared here
     272 | static inline void hrtimer_start(struct hrtimer *timer, ktime_t tim,
         |                    ^
   4 warnings and 1 error generated.


vim +/hrtimer_setup +2878 arch/x86/kvm/lapic.c

  2847	
  2848	int kvm_create_lapic(struct kvm_vcpu *vcpu)
  2849	{
  2850		struct kvm_lapic *apic;
  2851	
  2852		ASSERT(vcpu != NULL);
  2853	
  2854		if (!irqchip_in_kernel(vcpu->kvm)) {
  2855			static_branch_inc(&kvm_has_noapic_vcpu);
  2856			return 0;
  2857		}
  2858	
  2859		apic = kzalloc(sizeof(*apic), GFP_KERNEL_ACCOUNT);
  2860		if (!apic)
  2861			goto nomem;
  2862	
  2863		vcpu->arch.apic = apic;
  2864	
  2865		if (kvm_x86_ops.alloc_apic_backing_page)
  2866			apic->regs = kvm_x86_call(alloc_apic_backing_page)(vcpu);
  2867		else
  2868			apic->regs = (void *)get_zeroed_page(GFP_KERNEL_ACCOUNT);
  2869		if (!apic->regs) {
  2870			printk(KERN_ERR "malloc apic regs error for vcpu %x\n",
  2871			       vcpu->vcpu_id);
  2872			goto nomem_free_apic;
  2873		}
  2874		apic->vcpu = vcpu;
  2875	
  2876		apic->nr_lvt_entries = kvm_apic_calc_nr_lvt_entries(vcpu);
  2877	
> 2878		hrtimer_setup(&apic->lapic_timer.timer, apic_timer_fn, CLOCK_MONOTONIC,
  2879			      HRTIMER_MODE_ABS_HARD);
  2880		if (lapic_timer_advance)
  2881			apic->lapic_timer.timer_advance_ns = LAPIC_TIMER_ADVANCE_NS_INIT;
  2882	
  2883		/*
  2884		 * Stuff the APIC ENABLE bit in lieu of temporarily incrementing
  2885		 * apic_hw_disabled; the full RESET value is set by kvm_lapic_reset().
  2886		 */
  2887		vcpu->arch.apic_base = MSR_IA32_APICBASE_ENABLE;
  2888		static_branch_inc(&apic_sw_disabled.key); /* sw disabled at reset */
  2889		kvm_iodevice_init(&apic->dev, &apic_mmio_ops);
  2890	
  2891		/*
  2892		 * Defer evaluating inhibits until the vCPU is first run, as this vCPU
  2893		 * will not get notified of any changes until this vCPU is visible to
  2894		 * other vCPUs (marked online and added to the set of vCPUs).
  2895		 *
  2896		 * Opportunistically mark APICv active as VMX in particularly is highly
  2897		 * unlikely to have inhibits.  Ignore the current per-VM APICv state so
  2898		 * that vCPU creation is guaranteed to run with a deterministic value,
  2899		 * the request will ensure the vCPU gets the correct state before VM-Entry.
  2900		 */
  2901		if (enable_apicv) {
  2902			apic->apicv_active = true;
  2903			kvm_make_request(KVM_REQ_APICV_UPDATE, vcpu);
  2904		}
  2905	
  2906		return 0;
  2907	nomem_free_apic:
  2908		kfree(apic);
  2909		vcpu->arch.apic = NULL;
  2910	nomem:
  2911		return -ENOMEM;
  2912	}
  2913	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH 04/31] KVM: x86: Switch to use hrtimer_setup()
Posted by kernel test robot 3 weeks, 6 days ago
Hi Nam,

kernel test robot noticed the following build errors:

[auto build test ERROR on kvm/queue]
[also build test ERROR on tip/sched/core perf-tools-next/perf-tools-next tip/perf/core perf-tools/perf-tools tip/timers/core axboe-block/for-next linus/master v6.12-rc5 next-20241028]
[cannot apply to kvm/linux-next acme/perf/core]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Nam-Cao/KVM-MIPS-Switch-to-use-hrtimer_setup/20241028-154142
base:   https://git.kernel.org/pub/scm/virt/kvm/kvm.git queue
patch link:    https://lore.kernel.org/r/8774212e6c10c550743219e00738492eb379227c.1729864823.git.namcao%40linutronix.de
patch subject: [PATCH 04/31] KVM: x86: Switch to use hrtimer_setup()
config: x86_64-rhel-8.3 (https://download.01.org/0day-ci/archive/20241028/202410282113.l2iM0IOZ-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241028/202410282113.l2iM0IOZ-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410282113.l2iM0IOZ-lkp@intel.com/

All errors (new ones prefixed by >>):

   arch/x86/kvm/lapic.c: In function 'kvm_create_lapic':
>> arch/x86/kvm/lapic.c:2878:9: error: implicit declaration of function 'hrtimer_setup'; did you mean 'timer_setup'? [-Werror=implicit-function-declaration]
    2878 |         hrtimer_setup(&apic->lapic_timer.timer, apic_timer_fn, CLOCK_MONOTONIC,
         |         ^~~~~~~~~~~~~
         |         timer_setup
   cc1: some warnings being treated as errors
--
   arch/x86/kvm/i8254.c: In function 'kvm_create_pit':
>> arch/x86/kvm/i8254.c:693:9: error: implicit declaration of function 'hrtimer_setup'; did you mean 'timer_setup'? [-Werror=implicit-function-declaration]
     693 |         hrtimer_setup(&pit_state->timer, pit_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
         |         ^~~~~~~~~~~~~
         |         timer_setup
   cc1: some warnings being treated as errors
--
   arch/x86/kvm/hyperv.c: In function 'stimer_init':
>> arch/x86/kvm/hyperv.c:955:9: error: implicit declaration of function 'hrtimer_setup'; did you mean 'timer_setup'? [-Werror=implicit-function-declaration]
     955 |         hrtimer_setup(&stimer->timer, stimer_timer_callback, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
         |         ^~~~~~~~~~~~~
         |         timer_setup
   cc1: some warnings being treated as errors
--
   arch/x86/kvm/vmx/nested.c: In function 'enter_vmx_operation':
>> arch/x86/kvm/vmx/nested.c:5278:9: error: implicit declaration of function 'hrtimer_setup'; did you mean 'timer_setup'? [-Werror=implicit-function-declaration]
    5278 |         hrtimer_setup(&vmx->nested.preemption_timer, vmx_preemption_timer_fn, CLOCK_MONOTONIC,
         |         ^~~~~~~~~~~~~
         |         timer_setup
   cc1: some warnings being treated as errors


vim +2878 arch/x86/kvm/lapic.c

  2847	
  2848	int kvm_create_lapic(struct kvm_vcpu *vcpu)
  2849	{
  2850		struct kvm_lapic *apic;
  2851	
  2852		ASSERT(vcpu != NULL);
  2853	
  2854		if (!irqchip_in_kernel(vcpu->kvm)) {
  2855			static_branch_inc(&kvm_has_noapic_vcpu);
  2856			return 0;
  2857		}
  2858	
  2859		apic = kzalloc(sizeof(*apic), GFP_KERNEL_ACCOUNT);
  2860		if (!apic)
  2861			goto nomem;
  2862	
  2863		vcpu->arch.apic = apic;
  2864	
  2865		if (kvm_x86_ops.alloc_apic_backing_page)
  2866			apic->regs = kvm_x86_call(alloc_apic_backing_page)(vcpu);
  2867		else
  2868			apic->regs = (void *)get_zeroed_page(GFP_KERNEL_ACCOUNT);
  2869		if (!apic->regs) {
  2870			printk(KERN_ERR "malloc apic regs error for vcpu %x\n",
  2871			       vcpu->vcpu_id);
  2872			goto nomem_free_apic;
  2873		}
  2874		apic->vcpu = vcpu;
  2875	
  2876		apic->nr_lvt_entries = kvm_apic_calc_nr_lvt_entries(vcpu);
  2877	
> 2878		hrtimer_setup(&apic->lapic_timer.timer, apic_timer_fn, CLOCK_MONOTONIC,
  2879			      HRTIMER_MODE_ABS_HARD);
  2880		if (lapic_timer_advance)
  2881			apic->lapic_timer.timer_advance_ns = LAPIC_TIMER_ADVANCE_NS_INIT;
  2882	
  2883		/*
  2884		 * Stuff the APIC ENABLE bit in lieu of temporarily incrementing
  2885		 * apic_hw_disabled; the full RESET value is set by kvm_lapic_reset().
  2886		 */
  2887		vcpu->arch.apic_base = MSR_IA32_APICBASE_ENABLE;
  2888		static_branch_inc(&apic_sw_disabled.key); /* sw disabled at reset */
  2889		kvm_iodevice_init(&apic->dev, &apic_mmio_ops);
  2890	
  2891		/*
  2892		 * Defer evaluating inhibits until the vCPU is first run, as this vCPU
  2893		 * will not get notified of any changes until this vCPU is visible to
  2894		 * other vCPUs (marked online and added to the set of vCPUs).
  2895		 *
  2896		 * Opportunistically mark APICv active as VMX in particularly is highly
  2897		 * unlikely to have inhibits.  Ignore the current per-VM APICv state so
  2898		 * that vCPU creation is guaranteed to run with a deterministic value,
  2899		 * the request will ensure the vCPU gets the correct state before VM-Entry.
  2900		 */
  2901		if (enable_apicv) {
  2902			apic->apicv_active = true;
  2903			kvm_make_request(KVM_REQ_APICV_UPDATE, vcpu);
  2904		}
  2905	
  2906		return 0;
  2907	nomem_free_apic:
  2908		kfree(apic);
  2909		vcpu->arch.apic = NULL;
  2910	nomem:
  2911		return -ENOMEM;
  2912	}
  2913	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki