All of lore.kernel.org
 help / color / mirror / Atom feed
* arch/mips/kvm/vz.c:391:10: warning: variable 'freeze_time' set but not used
@ 2021-06-20 18:22 ` kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-06-20 18:22 UTC (permalink / raw)
  To: Thomas Bogendoerfer; +Cc: kbuild-all, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 12280 bytes --]

Hi Thomas,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   913ec3c22ef425d63dd0bc81fb008ce7f9bcb07b
commit: 45c7e8af4a5e3f0bea4ac209eea34118dd57ac64 MIPS: Remove KVM_TE support
date:   3 months ago
config: mips-randconfig-r002-20210620 (attached as .config)
compiler: mipsel-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=45c7e8af4a5e3f0bea4ac209eea34118dd57ac64
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 45c7e8af4a5e3f0bea4ac209eea34118dd57ac64
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=mips 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   arch/mips/kvm/vz.c: In function '_kvm_vz_restore_htimer':
>> arch/mips/kvm/vz.c:391:10: warning: variable 'freeze_time' set but not used [-Wunused-but-set-variable]
     391 |  ktime_t freeze_time;
         |          ^~~~~~~~~~~
--
   arch/mips/kvm/vz.c:471: warning: Function parameter or member 'out_compare' not described in '_kvm_vz_save_htimer'
   arch/mips/kvm/vz.c:471: warning: Function parameter or member 'out_cause' not described in '_kvm_vz_save_htimer'
   arch/mips/kvm/vz.c:471: warning: Excess function parameter 'compare' description in '_kvm_vz_save_htimer'
   arch/mips/kvm/vz.c:471: warning: Excess function parameter 'cause' description in '_kvm_vz_save_htimer'
>> arch/mips/kvm/vz.c:1552: warning: expecting prototype for kvm_trap_vz_handle_cop_unusuable(). Prototype was for kvm_trap_vz_handle_cop_unusable() instead


vim +/freeze_time +391 arch/mips/kvm/vz.c

c992a4f6a9b0a3 James Hogan 2017-03-14  377  
c992a4f6a9b0a3 James Hogan 2017-03-14  378  /**
f4474d50c7d483 James Hogan 2017-03-14  379   * _kvm_vz_restore_htimer() - Restore hard timer state.
f4474d50c7d483 James Hogan 2017-03-14  380   * @vcpu:	Virtual CPU.
f4474d50c7d483 James Hogan 2017-03-14  381   * @compare:	CP0_Compare register value, restored by caller.
f4474d50c7d483 James Hogan 2017-03-14  382   * @cause:	CP0_Cause register to restore.
f4474d50c7d483 James Hogan 2017-03-14  383   *
f4474d50c7d483 James Hogan 2017-03-14  384   * Restore hard timer Guest.Count & Guest.Cause taking care to preserve the
f4474d50c7d483 James Hogan 2017-03-14  385   * value of Guest.CP0_Cause.TI while restoring Guest.CP0_Cause.
f4474d50c7d483 James Hogan 2017-03-14  386   */
f4474d50c7d483 James Hogan 2017-03-14  387  static void _kvm_vz_restore_htimer(struct kvm_vcpu *vcpu,
f4474d50c7d483 James Hogan 2017-03-14  388  				   u32 compare, u32 cause)
f4474d50c7d483 James Hogan 2017-03-14  389  {
f4474d50c7d483 James Hogan 2017-03-14  390  	u32 start_count, after_count;
f4474d50c7d483 James Hogan 2017-03-14 @391  	ktime_t freeze_time;
f4474d50c7d483 James Hogan 2017-03-14  392  	unsigned long flags;
f4474d50c7d483 James Hogan 2017-03-14  393  
f4474d50c7d483 James Hogan 2017-03-14  394  	/*
f4474d50c7d483 James Hogan 2017-03-14  395  	 * Freeze the soft-timer and sync the guest CP0_Count with it. We do
f4474d50c7d483 James Hogan 2017-03-14  396  	 * this with interrupts disabled to avoid latency.
f4474d50c7d483 James Hogan 2017-03-14  397  	 */
f4474d50c7d483 James Hogan 2017-03-14  398  	local_irq_save(flags);
f4474d50c7d483 James Hogan 2017-03-14  399  	freeze_time = kvm_mips_freeze_hrtimer(vcpu, &start_count);
f4474d50c7d483 James Hogan 2017-03-14  400  	write_c0_gtoffset(start_count - read_c0_count());
f4474d50c7d483 James Hogan 2017-03-14  401  	local_irq_restore(flags);
f4474d50c7d483 James Hogan 2017-03-14  402  
f4474d50c7d483 James Hogan 2017-03-14  403  	/* restore guest CP0_Cause, as TI may already be set */
f4474d50c7d483 James Hogan 2017-03-14  404  	back_to_back_c0_hazard();
f4474d50c7d483 James Hogan 2017-03-14  405  	write_gc0_cause(cause);
f4474d50c7d483 James Hogan 2017-03-14  406  
f4474d50c7d483 James Hogan 2017-03-14  407  	/*
f4474d50c7d483 James Hogan 2017-03-14  408  	 * The above sequence isn't atomic and would result in lost timer
f4474d50c7d483 James Hogan 2017-03-14  409  	 * interrupts if we're not careful. Detect if a timer interrupt is due
f4474d50c7d483 James Hogan 2017-03-14  410  	 * and assert it.
f4474d50c7d483 James Hogan 2017-03-14  411  	 */
f4474d50c7d483 James Hogan 2017-03-14  412  	back_to_back_c0_hazard();
f4474d50c7d483 James Hogan 2017-03-14  413  	after_count = read_gc0_count();
f4474d50c7d483 James Hogan 2017-03-14  414  	if (after_count - start_count > compare - start_count - 1)
f4474d50c7d483 James Hogan 2017-03-14  415  		kvm_vz_queue_irq(vcpu, MIPS_EXC_INT_TIMER);
f4474d50c7d483 James Hogan 2017-03-14  416  }
f4474d50c7d483 James Hogan 2017-03-14  417  
f4474d50c7d483 James Hogan 2017-03-14  418  /**
f4474d50c7d483 James Hogan 2017-03-14  419   * kvm_vz_restore_timer() - Restore timer state.
c992a4f6a9b0a3 James Hogan 2017-03-14  420   * @vcpu:	Virtual CPU.
c992a4f6a9b0a3 James Hogan 2017-03-14  421   *
c992a4f6a9b0a3 James Hogan 2017-03-14  422   * Restore soft timer state from saved context.
c992a4f6a9b0a3 James Hogan 2017-03-14  423   */
c992a4f6a9b0a3 James Hogan 2017-03-14  424  static void kvm_vz_restore_timer(struct kvm_vcpu *vcpu)
c992a4f6a9b0a3 James Hogan 2017-03-14  425  {
c992a4f6a9b0a3 James Hogan 2017-03-14  426  	struct mips_coproc *cop0 = vcpu->arch.cop0;
c992a4f6a9b0a3 James Hogan 2017-03-14  427  	u32 cause, compare;
c992a4f6a9b0a3 James Hogan 2017-03-14  428  
c992a4f6a9b0a3 James Hogan 2017-03-14  429  	compare = kvm_read_sw_gc0_compare(cop0);
c992a4f6a9b0a3 James Hogan 2017-03-14  430  	cause = kvm_read_sw_gc0_cause(cop0);
c992a4f6a9b0a3 James Hogan 2017-03-14  431  
c992a4f6a9b0a3 James Hogan 2017-03-14  432  	write_gc0_compare(compare);
c992a4f6a9b0a3 James Hogan 2017-03-14  433  	_kvm_vz_restore_stimer(vcpu, compare, cause);
c992a4f6a9b0a3 James Hogan 2017-03-14  434  }
c992a4f6a9b0a3 James Hogan 2017-03-14  435  
f4474d50c7d483 James Hogan 2017-03-14  436  /**
f4474d50c7d483 James Hogan 2017-03-14  437   * kvm_vz_acquire_htimer() - Switch to hard timer state.
f4474d50c7d483 James Hogan 2017-03-14  438   * @vcpu:	Virtual CPU.
f4474d50c7d483 James Hogan 2017-03-14  439   *
f4474d50c7d483 James Hogan 2017-03-14  440   * Restore hard timer state on top of existing soft timer state if possible.
f4474d50c7d483 James Hogan 2017-03-14  441   *
f4474d50c7d483 James Hogan 2017-03-14  442   * Since hard timer won't remain active over preemption, preemption should be
f4474d50c7d483 James Hogan 2017-03-14  443   * disabled by the caller.
f4474d50c7d483 James Hogan 2017-03-14  444   */
f4474d50c7d483 James Hogan 2017-03-14  445  void kvm_vz_acquire_htimer(struct kvm_vcpu *vcpu)
f4474d50c7d483 James Hogan 2017-03-14  446  {
f4474d50c7d483 James Hogan 2017-03-14  447  	u32 gctl0;
f4474d50c7d483 James Hogan 2017-03-14  448  
f4474d50c7d483 James Hogan 2017-03-14  449  	gctl0 = read_c0_guestctl0();
f4474d50c7d483 James Hogan 2017-03-14  450  	if (!(gctl0 & MIPS_GCTL0_GT) && kvm_vz_should_use_htimer(vcpu)) {
f4474d50c7d483 James Hogan 2017-03-14  451  		/* enable guest access to hard timer */
f4474d50c7d483 James Hogan 2017-03-14  452  		write_c0_guestctl0(gctl0 | MIPS_GCTL0_GT);
f4474d50c7d483 James Hogan 2017-03-14  453  
f4474d50c7d483 James Hogan 2017-03-14  454  		_kvm_vz_restore_htimer(vcpu, read_gc0_compare(),
f4474d50c7d483 James Hogan 2017-03-14  455  				       read_gc0_cause());
f4474d50c7d483 James Hogan 2017-03-14  456  	}
f4474d50c7d483 James Hogan 2017-03-14  457  }
f4474d50c7d483 James Hogan 2017-03-14  458  
f4474d50c7d483 James Hogan 2017-03-14  459  /**
f4474d50c7d483 James Hogan 2017-03-14  460   * _kvm_vz_save_htimer() - Switch to software emulation of guest timer.
f4474d50c7d483 James Hogan 2017-03-14  461   * @vcpu:	Virtual CPU.
f4474d50c7d483 James Hogan 2017-03-14  462   * @compare:	Pointer to write compare value to.
f4474d50c7d483 James Hogan 2017-03-14  463   * @cause:	Pointer to write cause value to.
f4474d50c7d483 James Hogan 2017-03-14  464   *
f4474d50c7d483 James Hogan 2017-03-14  465   * Save VZ guest timer state and switch to software emulation of guest CP0
f4474d50c7d483 James Hogan 2017-03-14  466   * timer. The hard timer must already be in use, so preemption should be
f4474d50c7d483 James Hogan 2017-03-14  467   * disabled.
f4474d50c7d483 James Hogan 2017-03-14  468   */
f4474d50c7d483 James Hogan 2017-03-14  469  static void _kvm_vz_save_htimer(struct kvm_vcpu *vcpu,
f4474d50c7d483 James Hogan 2017-03-14  470  				u32 *out_compare, u32 *out_cause)
f4474d50c7d483 James Hogan 2017-03-14 @471  {
f4474d50c7d483 James Hogan 2017-03-14  472  	u32 cause, compare, before_count, end_count;
f4474d50c7d483 James Hogan 2017-03-14  473  	ktime_t before_time;
f4474d50c7d483 James Hogan 2017-03-14  474  
f4474d50c7d483 James Hogan 2017-03-14  475  	compare = read_gc0_compare();
f4474d50c7d483 James Hogan 2017-03-14  476  	*out_compare = compare;
f4474d50c7d483 James Hogan 2017-03-14  477  
f4474d50c7d483 James Hogan 2017-03-14  478  	before_time = ktime_get();
f4474d50c7d483 James Hogan 2017-03-14  479  
f4474d50c7d483 James Hogan 2017-03-14  480  	/*
f4474d50c7d483 James Hogan 2017-03-14  481  	 * Record the CP0_Count *prior* to saving CP0_Cause, so we have a time
f4474d50c7d483 James Hogan 2017-03-14  482  	 * at which no pending timer interrupt is missing.
f4474d50c7d483 James Hogan 2017-03-14  483  	 */
f4474d50c7d483 James Hogan 2017-03-14  484  	before_count = read_gc0_count();
f4474d50c7d483 James Hogan 2017-03-14  485  	back_to_back_c0_hazard();
f4474d50c7d483 James Hogan 2017-03-14  486  	cause = read_gc0_cause();
f4474d50c7d483 James Hogan 2017-03-14  487  	*out_cause = cause;
f4474d50c7d483 James Hogan 2017-03-14  488  
f4474d50c7d483 James Hogan 2017-03-14  489  	/*
f4474d50c7d483 James Hogan 2017-03-14  490  	 * Record a final CP0_Count which we will transfer to the soft-timer.
f4474d50c7d483 James Hogan 2017-03-14  491  	 * This is recorded *after* saving CP0_Cause, so we don't get any timer
f4474d50c7d483 James Hogan 2017-03-14  492  	 * interrupts from just after the final CP0_Count point.
f4474d50c7d483 James Hogan 2017-03-14  493  	 */
f4474d50c7d483 James Hogan 2017-03-14  494  	back_to_back_c0_hazard();
f4474d50c7d483 James Hogan 2017-03-14  495  	end_count = read_gc0_count();
f4474d50c7d483 James Hogan 2017-03-14  496  
f4474d50c7d483 James Hogan 2017-03-14  497  	/*
f4474d50c7d483 James Hogan 2017-03-14  498  	 * The above sequence isn't atomic, so we could miss a timer interrupt
f4474d50c7d483 James Hogan 2017-03-14  499  	 * between reading CP0_Cause and end_count. Detect and record any timer
f4474d50c7d483 James Hogan 2017-03-14  500  	 * interrupt due between before_count and end_count.
f4474d50c7d483 James Hogan 2017-03-14  501  	 */
f4474d50c7d483 James Hogan 2017-03-14  502  	if (end_count - before_count > compare - before_count - 1)
f4474d50c7d483 James Hogan 2017-03-14  503  		kvm_vz_queue_irq(vcpu, MIPS_EXC_INT_TIMER);
f4474d50c7d483 James Hogan 2017-03-14  504  
f4474d50c7d483 James Hogan 2017-03-14  505  	/*
f4474d50c7d483 James Hogan 2017-03-14  506  	 * Restore soft-timer, ignoring a small amount of negative drift due to
f4474d50c7d483 James Hogan 2017-03-14  507  	 * delay between freeze_hrtimer and setting CP0_GTOffset.
f4474d50c7d483 James Hogan 2017-03-14  508  	 */
f4474d50c7d483 James Hogan 2017-03-14  509  	kvm_mips_restore_hrtimer(vcpu, before_time, end_count, -0x10000);
f4474d50c7d483 James Hogan 2017-03-14  510  }
f4474d50c7d483 James Hogan 2017-03-14  511  

:::::: The code at line 391 was first introduced by commit
:::::: f4474d50c7d483dd4432d5b0891b0bb9ad0eefc9 KVM: MIPS/VZ: Support hardware guest timer

:::::: TO: James Hogan <james.hogan@imgtec.com>
:::::: CC: James Hogan <james.hogan@imgtec.com>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 37584 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* arch/mips/kvm/vz.c:391:10: warning: variable 'freeze_time' set but not used
@ 2021-06-20 18:22 ` kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-06-20 18:22 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 12466 bytes --]

Hi Thomas,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   913ec3c22ef425d63dd0bc81fb008ce7f9bcb07b
commit: 45c7e8af4a5e3f0bea4ac209eea34118dd57ac64 MIPS: Remove KVM_TE support
date:   3 months ago
config: mips-randconfig-r002-20210620 (attached as .config)
compiler: mipsel-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=45c7e8af4a5e3f0bea4ac209eea34118dd57ac64
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 45c7e8af4a5e3f0bea4ac209eea34118dd57ac64
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=mips 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   arch/mips/kvm/vz.c: In function '_kvm_vz_restore_htimer':
>> arch/mips/kvm/vz.c:391:10: warning: variable 'freeze_time' set but not used [-Wunused-but-set-variable]
     391 |  ktime_t freeze_time;
         |          ^~~~~~~~~~~
--
   arch/mips/kvm/vz.c:471: warning: Function parameter or member 'out_compare' not described in '_kvm_vz_save_htimer'
   arch/mips/kvm/vz.c:471: warning: Function parameter or member 'out_cause' not described in '_kvm_vz_save_htimer'
   arch/mips/kvm/vz.c:471: warning: Excess function parameter 'compare' description in '_kvm_vz_save_htimer'
   arch/mips/kvm/vz.c:471: warning: Excess function parameter 'cause' description in '_kvm_vz_save_htimer'
>> arch/mips/kvm/vz.c:1552: warning: expecting prototype for kvm_trap_vz_handle_cop_unusuable(). Prototype was for kvm_trap_vz_handle_cop_unusable() instead


vim +/freeze_time +391 arch/mips/kvm/vz.c

c992a4f6a9b0a3 James Hogan 2017-03-14  377  
c992a4f6a9b0a3 James Hogan 2017-03-14  378  /**
f4474d50c7d483 James Hogan 2017-03-14  379   * _kvm_vz_restore_htimer() - Restore hard timer state.
f4474d50c7d483 James Hogan 2017-03-14  380   * @vcpu:	Virtual CPU.
f4474d50c7d483 James Hogan 2017-03-14  381   * @compare:	CP0_Compare register value, restored by caller.
f4474d50c7d483 James Hogan 2017-03-14  382   * @cause:	CP0_Cause register to restore.
f4474d50c7d483 James Hogan 2017-03-14  383   *
f4474d50c7d483 James Hogan 2017-03-14  384   * Restore hard timer Guest.Count & Guest.Cause taking care to preserve the
f4474d50c7d483 James Hogan 2017-03-14  385   * value of Guest.CP0_Cause.TI while restoring Guest.CP0_Cause.
f4474d50c7d483 James Hogan 2017-03-14  386   */
f4474d50c7d483 James Hogan 2017-03-14  387  static void _kvm_vz_restore_htimer(struct kvm_vcpu *vcpu,
f4474d50c7d483 James Hogan 2017-03-14  388  				   u32 compare, u32 cause)
f4474d50c7d483 James Hogan 2017-03-14  389  {
f4474d50c7d483 James Hogan 2017-03-14  390  	u32 start_count, after_count;
f4474d50c7d483 James Hogan 2017-03-14 @391  	ktime_t freeze_time;
f4474d50c7d483 James Hogan 2017-03-14  392  	unsigned long flags;
f4474d50c7d483 James Hogan 2017-03-14  393  
f4474d50c7d483 James Hogan 2017-03-14  394  	/*
f4474d50c7d483 James Hogan 2017-03-14  395  	 * Freeze the soft-timer and sync the guest CP0_Count with it. We do
f4474d50c7d483 James Hogan 2017-03-14  396  	 * this with interrupts disabled to avoid latency.
f4474d50c7d483 James Hogan 2017-03-14  397  	 */
f4474d50c7d483 James Hogan 2017-03-14  398  	local_irq_save(flags);
f4474d50c7d483 James Hogan 2017-03-14  399  	freeze_time = kvm_mips_freeze_hrtimer(vcpu, &start_count);
f4474d50c7d483 James Hogan 2017-03-14  400  	write_c0_gtoffset(start_count - read_c0_count());
f4474d50c7d483 James Hogan 2017-03-14  401  	local_irq_restore(flags);
f4474d50c7d483 James Hogan 2017-03-14  402  
f4474d50c7d483 James Hogan 2017-03-14  403  	/* restore guest CP0_Cause, as TI may already be set */
f4474d50c7d483 James Hogan 2017-03-14  404  	back_to_back_c0_hazard();
f4474d50c7d483 James Hogan 2017-03-14  405  	write_gc0_cause(cause);
f4474d50c7d483 James Hogan 2017-03-14  406  
f4474d50c7d483 James Hogan 2017-03-14  407  	/*
f4474d50c7d483 James Hogan 2017-03-14  408  	 * The above sequence isn't atomic and would result in lost timer
f4474d50c7d483 James Hogan 2017-03-14  409  	 * interrupts if we're not careful. Detect if a timer interrupt is due
f4474d50c7d483 James Hogan 2017-03-14  410  	 * and assert it.
f4474d50c7d483 James Hogan 2017-03-14  411  	 */
f4474d50c7d483 James Hogan 2017-03-14  412  	back_to_back_c0_hazard();
f4474d50c7d483 James Hogan 2017-03-14  413  	after_count = read_gc0_count();
f4474d50c7d483 James Hogan 2017-03-14  414  	if (after_count - start_count > compare - start_count - 1)
f4474d50c7d483 James Hogan 2017-03-14  415  		kvm_vz_queue_irq(vcpu, MIPS_EXC_INT_TIMER);
f4474d50c7d483 James Hogan 2017-03-14  416  }
f4474d50c7d483 James Hogan 2017-03-14  417  
f4474d50c7d483 James Hogan 2017-03-14  418  /**
f4474d50c7d483 James Hogan 2017-03-14  419   * kvm_vz_restore_timer() - Restore timer state.
c992a4f6a9b0a3 James Hogan 2017-03-14  420   * @vcpu:	Virtual CPU.
c992a4f6a9b0a3 James Hogan 2017-03-14  421   *
c992a4f6a9b0a3 James Hogan 2017-03-14  422   * Restore soft timer state from saved context.
c992a4f6a9b0a3 James Hogan 2017-03-14  423   */
c992a4f6a9b0a3 James Hogan 2017-03-14  424  static void kvm_vz_restore_timer(struct kvm_vcpu *vcpu)
c992a4f6a9b0a3 James Hogan 2017-03-14  425  {
c992a4f6a9b0a3 James Hogan 2017-03-14  426  	struct mips_coproc *cop0 = vcpu->arch.cop0;
c992a4f6a9b0a3 James Hogan 2017-03-14  427  	u32 cause, compare;
c992a4f6a9b0a3 James Hogan 2017-03-14  428  
c992a4f6a9b0a3 James Hogan 2017-03-14  429  	compare = kvm_read_sw_gc0_compare(cop0);
c992a4f6a9b0a3 James Hogan 2017-03-14  430  	cause = kvm_read_sw_gc0_cause(cop0);
c992a4f6a9b0a3 James Hogan 2017-03-14  431  
c992a4f6a9b0a3 James Hogan 2017-03-14  432  	write_gc0_compare(compare);
c992a4f6a9b0a3 James Hogan 2017-03-14  433  	_kvm_vz_restore_stimer(vcpu, compare, cause);
c992a4f6a9b0a3 James Hogan 2017-03-14  434  }
c992a4f6a9b0a3 James Hogan 2017-03-14  435  
f4474d50c7d483 James Hogan 2017-03-14  436  /**
f4474d50c7d483 James Hogan 2017-03-14  437   * kvm_vz_acquire_htimer() - Switch to hard timer state.
f4474d50c7d483 James Hogan 2017-03-14  438   * @vcpu:	Virtual CPU.
f4474d50c7d483 James Hogan 2017-03-14  439   *
f4474d50c7d483 James Hogan 2017-03-14  440   * Restore hard timer state on top of existing soft timer state if possible.
f4474d50c7d483 James Hogan 2017-03-14  441   *
f4474d50c7d483 James Hogan 2017-03-14  442   * Since hard timer won't remain active over preemption, preemption should be
f4474d50c7d483 James Hogan 2017-03-14  443   * disabled by the caller.
f4474d50c7d483 James Hogan 2017-03-14  444   */
f4474d50c7d483 James Hogan 2017-03-14  445  void kvm_vz_acquire_htimer(struct kvm_vcpu *vcpu)
f4474d50c7d483 James Hogan 2017-03-14  446  {
f4474d50c7d483 James Hogan 2017-03-14  447  	u32 gctl0;
f4474d50c7d483 James Hogan 2017-03-14  448  
f4474d50c7d483 James Hogan 2017-03-14  449  	gctl0 = read_c0_guestctl0();
f4474d50c7d483 James Hogan 2017-03-14  450  	if (!(gctl0 & MIPS_GCTL0_GT) && kvm_vz_should_use_htimer(vcpu)) {
f4474d50c7d483 James Hogan 2017-03-14  451  		/* enable guest access to hard timer */
f4474d50c7d483 James Hogan 2017-03-14  452  		write_c0_guestctl0(gctl0 | MIPS_GCTL0_GT);
f4474d50c7d483 James Hogan 2017-03-14  453  
f4474d50c7d483 James Hogan 2017-03-14  454  		_kvm_vz_restore_htimer(vcpu, read_gc0_compare(),
f4474d50c7d483 James Hogan 2017-03-14  455  				       read_gc0_cause());
f4474d50c7d483 James Hogan 2017-03-14  456  	}
f4474d50c7d483 James Hogan 2017-03-14  457  }
f4474d50c7d483 James Hogan 2017-03-14  458  
f4474d50c7d483 James Hogan 2017-03-14  459  /**
f4474d50c7d483 James Hogan 2017-03-14  460   * _kvm_vz_save_htimer() - Switch to software emulation of guest timer.
f4474d50c7d483 James Hogan 2017-03-14  461   * @vcpu:	Virtual CPU.
f4474d50c7d483 James Hogan 2017-03-14  462   * @compare:	Pointer to write compare value to.
f4474d50c7d483 James Hogan 2017-03-14  463   * @cause:	Pointer to write cause value to.
f4474d50c7d483 James Hogan 2017-03-14  464   *
f4474d50c7d483 James Hogan 2017-03-14  465   * Save VZ guest timer state and switch to software emulation of guest CP0
f4474d50c7d483 James Hogan 2017-03-14  466   * timer. The hard timer must already be in use, so preemption should be
f4474d50c7d483 James Hogan 2017-03-14  467   * disabled.
f4474d50c7d483 James Hogan 2017-03-14  468   */
f4474d50c7d483 James Hogan 2017-03-14  469  static void _kvm_vz_save_htimer(struct kvm_vcpu *vcpu,
f4474d50c7d483 James Hogan 2017-03-14  470  				u32 *out_compare, u32 *out_cause)
f4474d50c7d483 James Hogan 2017-03-14 @471  {
f4474d50c7d483 James Hogan 2017-03-14  472  	u32 cause, compare, before_count, end_count;
f4474d50c7d483 James Hogan 2017-03-14  473  	ktime_t before_time;
f4474d50c7d483 James Hogan 2017-03-14  474  
f4474d50c7d483 James Hogan 2017-03-14  475  	compare = read_gc0_compare();
f4474d50c7d483 James Hogan 2017-03-14  476  	*out_compare = compare;
f4474d50c7d483 James Hogan 2017-03-14  477  
f4474d50c7d483 James Hogan 2017-03-14  478  	before_time = ktime_get();
f4474d50c7d483 James Hogan 2017-03-14  479  
f4474d50c7d483 James Hogan 2017-03-14  480  	/*
f4474d50c7d483 James Hogan 2017-03-14  481  	 * Record the CP0_Count *prior* to saving CP0_Cause, so we have a time
f4474d50c7d483 James Hogan 2017-03-14  482  	 * at which no pending timer interrupt is missing.
f4474d50c7d483 James Hogan 2017-03-14  483  	 */
f4474d50c7d483 James Hogan 2017-03-14  484  	before_count = read_gc0_count();
f4474d50c7d483 James Hogan 2017-03-14  485  	back_to_back_c0_hazard();
f4474d50c7d483 James Hogan 2017-03-14  486  	cause = read_gc0_cause();
f4474d50c7d483 James Hogan 2017-03-14  487  	*out_cause = cause;
f4474d50c7d483 James Hogan 2017-03-14  488  
f4474d50c7d483 James Hogan 2017-03-14  489  	/*
f4474d50c7d483 James Hogan 2017-03-14  490  	 * Record a final CP0_Count which we will transfer to the soft-timer.
f4474d50c7d483 James Hogan 2017-03-14  491  	 * This is recorded *after* saving CP0_Cause, so we don't get any timer
f4474d50c7d483 James Hogan 2017-03-14  492  	 * interrupts from just after the final CP0_Count point.
f4474d50c7d483 James Hogan 2017-03-14  493  	 */
f4474d50c7d483 James Hogan 2017-03-14  494  	back_to_back_c0_hazard();
f4474d50c7d483 James Hogan 2017-03-14  495  	end_count = read_gc0_count();
f4474d50c7d483 James Hogan 2017-03-14  496  
f4474d50c7d483 James Hogan 2017-03-14  497  	/*
f4474d50c7d483 James Hogan 2017-03-14  498  	 * The above sequence isn't atomic, so we could miss a timer interrupt
f4474d50c7d483 James Hogan 2017-03-14  499  	 * between reading CP0_Cause and end_count. Detect and record any timer
f4474d50c7d483 James Hogan 2017-03-14  500  	 * interrupt due between before_count and end_count.
f4474d50c7d483 James Hogan 2017-03-14  501  	 */
f4474d50c7d483 James Hogan 2017-03-14  502  	if (end_count - before_count > compare - before_count - 1)
f4474d50c7d483 James Hogan 2017-03-14  503  		kvm_vz_queue_irq(vcpu, MIPS_EXC_INT_TIMER);
f4474d50c7d483 James Hogan 2017-03-14  504  
f4474d50c7d483 James Hogan 2017-03-14  505  	/*
f4474d50c7d483 James Hogan 2017-03-14  506  	 * Restore soft-timer, ignoring a small amount of negative drift due to
f4474d50c7d483 James Hogan 2017-03-14  507  	 * delay between freeze_hrtimer and setting CP0_GTOffset.
f4474d50c7d483 James Hogan 2017-03-14  508  	 */
f4474d50c7d483 James Hogan 2017-03-14  509  	kvm_mips_restore_hrtimer(vcpu, before_time, end_count, -0x10000);
f4474d50c7d483 James Hogan 2017-03-14  510  }
f4474d50c7d483 James Hogan 2017-03-14  511  

:::::: The code at line 391 was first introduced by commit
:::::: f4474d50c7d483dd4432d5b0891b0bb9ad0eefc9 KVM: MIPS/VZ: Support hardware guest timer

:::::: TO: James Hogan <james.hogan@imgtec.com>
:::::: CC: James Hogan <james.hogan@imgtec.com>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 37584 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* arch/mips/kvm/vz.c:391:10: warning: variable 'freeze_time' set but not used
@ 2021-06-03  4:28 ` kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-06-03  4:28 UTC (permalink / raw)
  To: Thomas Bogendoerfer; +Cc: kbuild-all, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 5465 bytes --]

Hi Thomas,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   324c92e5e0ee0e993bdb106fac407846ed677f6b
commit: 45c7e8af4a5e3f0bea4ac209eea34118dd57ac64 MIPS: Remove KVM_TE support
date:   3 months ago
config: mips-randconfig-r005-20210603 (attached as .config)
compiler: mips-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=45c7e8af4a5e3f0bea4ac209eea34118dd57ac64
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 45c7e8af4a5e3f0bea4ac209eea34118dd57ac64
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=mips 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   arch/mips/kvm/vz.c: In function '_kvm_vz_restore_htimer':
>> arch/mips/kvm/vz.c:391:10: warning: variable 'freeze_time' set but not used [-Wunused-but-set-variable]
     391 |  ktime_t freeze_time;
         |          ^~~~~~~~~~~
--
   arch/mips/kvm/vz.c:471: warning: Function parameter or member 'out_compare' not described in '_kvm_vz_save_htimer'
   arch/mips/kvm/vz.c:471: warning: Function parameter or member 'out_cause' not described in '_kvm_vz_save_htimer'
   arch/mips/kvm/vz.c:471: warning: Excess function parameter 'compare' description in '_kvm_vz_save_htimer'
   arch/mips/kvm/vz.c:471: warning: Excess function parameter 'cause' description in '_kvm_vz_save_htimer'
>> arch/mips/kvm/vz.c:1552: warning: expecting prototype for kvm_trap_vz_handle_cop_unusuable(). Prototype was for kvm_trap_vz_handle_cop_unusable() instead


vim +/freeze_time +391 arch/mips/kvm/vz.c

c992a4f6a9b0a3 James Hogan 2017-03-14  377  
c992a4f6a9b0a3 James Hogan 2017-03-14  378  /**
f4474d50c7d483 James Hogan 2017-03-14  379   * _kvm_vz_restore_htimer() - Restore hard timer state.
f4474d50c7d483 James Hogan 2017-03-14  380   * @vcpu:	Virtual CPU.
f4474d50c7d483 James Hogan 2017-03-14  381   * @compare:	CP0_Compare register value, restored by caller.
f4474d50c7d483 James Hogan 2017-03-14  382   * @cause:	CP0_Cause register to restore.
f4474d50c7d483 James Hogan 2017-03-14  383   *
f4474d50c7d483 James Hogan 2017-03-14  384   * Restore hard timer Guest.Count & Guest.Cause taking care to preserve the
f4474d50c7d483 James Hogan 2017-03-14  385   * value of Guest.CP0_Cause.TI while restoring Guest.CP0_Cause.
f4474d50c7d483 James Hogan 2017-03-14  386   */
f4474d50c7d483 James Hogan 2017-03-14  387  static void _kvm_vz_restore_htimer(struct kvm_vcpu *vcpu,
f4474d50c7d483 James Hogan 2017-03-14  388  				   u32 compare, u32 cause)
f4474d50c7d483 James Hogan 2017-03-14  389  {
f4474d50c7d483 James Hogan 2017-03-14  390  	u32 start_count, after_count;
f4474d50c7d483 James Hogan 2017-03-14 @391  	ktime_t freeze_time;
f4474d50c7d483 James Hogan 2017-03-14  392  	unsigned long flags;
f4474d50c7d483 James Hogan 2017-03-14  393  
f4474d50c7d483 James Hogan 2017-03-14  394  	/*
f4474d50c7d483 James Hogan 2017-03-14  395  	 * Freeze the soft-timer and sync the guest CP0_Count with it. We do
f4474d50c7d483 James Hogan 2017-03-14  396  	 * this with interrupts disabled to avoid latency.
f4474d50c7d483 James Hogan 2017-03-14  397  	 */
f4474d50c7d483 James Hogan 2017-03-14  398  	local_irq_save(flags);
f4474d50c7d483 James Hogan 2017-03-14  399  	freeze_time = kvm_mips_freeze_hrtimer(vcpu, &start_count);
f4474d50c7d483 James Hogan 2017-03-14  400  	write_c0_gtoffset(start_count - read_c0_count());
f4474d50c7d483 James Hogan 2017-03-14  401  	local_irq_restore(flags);
f4474d50c7d483 James Hogan 2017-03-14  402  
f4474d50c7d483 James Hogan 2017-03-14  403  	/* restore guest CP0_Cause, as TI may already be set */
f4474d50c7d483 James Hogan 2017-03-14  404  	back_to_back_c0_hazard();
f4474d50c7d483 James Hogan 2017-03-14  405  	write_gc0_cause(cause);
f4474d50c7d483 James Hogan 2017-03-14  406  
f4474d50c7d483 James Hogan 2017-03-14  407  	/*
f4474d50c7d483 James Hogan 2017-03-14  408  	 * The above sequence isn't atomic and would result in lost timer
f4474d50c7d483 James Hogan 2017-03-14  409  	 * interrupts if we're not careful. Detect if a timer interrupt is due
f4474d50c7d483 James Hogan 2017-03-14  410  	 * and assert it.
f4474d50c7d483 James Hogan 2017-03-14  411  	 */
f4474d50c7d483 James Hogan 2017-03-14  412  	back_to_back_c0_hazard();
f4474d50c7d483 James Hogan 2017-03-14  413  	after_count = read_gc0_count();
f4474d50c7d483 James Hogan 2017-03-14  414  	if (after_count - start_count > compare - start_count - 1)
f4474d50c7d483 James Hogan 2017-03-14  415  		kvm_vz_queue_irq(vcpu, MIPS_EXC_INT_TIMER);
f4474d50c7d483 James Hogan 2017-03-14  416  }
f4474d50c7d483 James Hogan 2017-03-14  417  

:::::: The code at line 391 was first introduced by commit
:::::: f4474d50c7d483dd4432d5b0891b0bb9ad0eefc9 KVM: MIPS/VZ: Support hardware guest timer

:::::: TO: James Hogan <james.hogan@imgtec.com>
:::::: CC: James Hogan <james.hogan@imgtec.com>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 46052 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* arch/mips/kvm/vz.c:391:10: warning: variable 'freeze_time' set but not used
@ 2021-06-03  4:28 ` kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-06-03  4:28 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 5557 bytes --]

Hi Thomas,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   324c92e5e0ee0e993bdb106fac407846ed677f6b
commit: 45c7e8af4a5e3f0bea4ac209eea34118dd57ac64 MIPS: Remove KVM_TE support
date:   3 months ago
config: mips-randconfig-r005-20210603 (attached as .config)
compiler: mips-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=45c7e8af4a5e3f0bea4ac209eea34118dd57ac64
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 45c7e8af4a5e3f0bea4ac209eea34118dd57ac64
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=mips 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   arch/mips/kvm/vz.c: In function '_kvm_vz_restore_htimer':
>> arch/mips/kvm/vz.c:391:10: warning: variable 'freeze_time' set but not used [-Wunused-but-set-variable]
     391 |  ktime_t freeze_time;
         |          ^~~~~~~~~~~
--
   arch/mips/kvm/vz.c:471: warning: Function parameter or member 'out_compare' not described in '_kvm_vz_save_htimer'
   arch/mips/kvm/vz.c:471: warning: Function parameter or member 'out_cause' not described in '_kvm_vz_save_htimer'
   arch/mips/kvm/vz.c:471: warning: Excess function parameter 'compare' description in '_kvm_vz_save_htimer'
   arch/mips/kvm/vz.c:471: warning: Excess function parameter 'cause' description in '_kvm_vz_save_htimer'
>> arch/mips/kvm/vz.c:1552: warning: expecting prototype for kvm_trap_vz_handle_cop_unusuable(). Prototype was for kvm_trap_vz_handle_cop_unusable() instead


vim +/freeze_time +391 arch/mips/kvm/vz.c

c992a4f6a9b0a3 James Hogan 2017-03-14  377  
c992a4f6a9b0a3 James Hogan 2017-03-14  378  /**
f4474d50c7d483 James Hogan 2017-03-14  379   * _kvm_vz_restore_htimer() - Restore hard timer state.
f4474d50c7d483 James Hogan 2017-03-14  380   * @vcpu:	Virtual CPU.
f4474d50c7d483 James Hogan 2017-03-14  381   * @compare:	CP0_Compare register value, restored by caller.
f4474d50c7d483 James Hogan 2017-03-14  382   * @cause:	CP0_Cause register to restore.
f4474d50c7d483 James Hogan 2017-03-14  383   *
f4474d50c7d483 James Hogan 2017-03-14  384   * Restore hard timer Guest.Count & Guest.Cause taking care to preserve the
f4474d50c7d483 James Hogan 2017-03-14  385   * value of Guest.CP0_Cause.TI while restoring Guest.CP0_Cause.
f4474d50c7d483 James Hogan 2017-03-14  386   */
f4474d50c7d483 James Hogan 2017-03-14  387  static void _kvm_vz_restore_htimer(struct kvm_vcpu *vcpu,
f4474d50c7d483 James Hogan 2017-03-14  388  				   u32 compare, u32 cause)
f4474d50c7d483 James Hogan 2017-03-14  389  {
f4474d50c7d483 James Hogan 2017-03-14  390  	u32 start_count, after_count;
f4474d50c7d483 James Hogan 2017-03-14 @391  	ktime_t freeze_time;
f4474d50c7d483 James Hogan 2017-03-14  392  	unsigned long flags;
f4474d50c7d483 James Hogan 2017-03-14  393  
f4474d50c7d483 James Hogan 2017-03-14  394  	/*
f4474d50c7d483 James Hogan 2017-03-14  395  	 * Freeze the soft-timer and sync the guest CP0_Count with it. We do
f4474d50c7d483 James Hogan 2017-03-14  396  	 * this with interrupts disabled to avoid latency.
f4474d50c7d483 James Hogan 2017-03-14  397  	 */
f4474d50c7d483 James Hogan 2017-03-14  398  	local_irq_save(flags);
f4474d50c7d483 James Hogan 2017-03-14  399  	freeze_time = kvm_mips_freeze_hrtimer(vcpu, &start_count);
f4474d50c7d483 James Hogan 2017-03-14  400  	write_c0_gtoffset(start_count - read_c0_count());
f4474d50c7d483 James Hogan 2017-03-14  401  	local_irq_restore(flags);
f4474d50c7d483 James Hogan 2017-03-14  402  
f4474d50c7d483 James Hogan 2017-03-14  403  	/* restore guest CP0_Cause, as TI may already be set */
f4474d50c7d483 James Hogan 2017-03-14  404  	back_to_back_c0_hazard();
f4474d50c7d483 James Hogan 2017-03-14  405  	write_gc0_cause(cause);
f4474d50c7d483 James Hogan 2017-03-14  406  
f4474d50c7d483 James Hogan 2017-03-14  407  	/*
f4474d50c7d483 James Hogan 2017-03-14  408  	 * The above sequence isn't atomic and would result in lost timer
f4474d50c7d483 James Hogan 2017-03-14  409  	 * interrupts if we're not careful. Detect if a timer interrupt is due
f4474d50c7d483 James Hogan 2017-03-14  410  	 * and assert it.
f4474d50c7d483 James Hogan 2017-03-14  411  	 */
f4474d50c7d483 James Hogan 2017-03-14  412  	back_to_back_c0_hazard();
f4474d50c7d483 James Hogan 2017-03-14  413  	after_count = read_gc0_count();
f4474d50c7d483 James Hogan 2017-03-14  414  	if (after_count - start_count > compare - start_count - 1)
f4474d50c7d483 James Hogan 2017-03-14  415  		kvm_vz_queue_irq(vcpu, MIPS_EXC_INT_TIMER);
f4474d50c7d483 James Hogan 2017-03-14  416  }
f4474d50c7d483 James Hogan 2017-03-14  417  

:::::: The code at line 391 was first introduced by commit
:::::: f4474d50c7d483dd4432d5b0891b0bb9ad0eefc9 KVM: MIPS/VZ: Support hardware guest timer

:::::: TO: James Hogan <james.hogan@imgtec.com>
:::::: CC: James Hogan <james.hogan@imgtec.com>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 46052 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-20 18:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-20 18:22 arch/mips/kvm/vz.c:391:10: warning: variable 'freeze_time' set but not used kernel test robot
2021-06-20 18:22 ` kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2021-06-03  4:28 kernel test robot
2021-06-03  4:28 ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.