diff mbox series

[v2,40/60] KVM: PPC: Book3S HV P9: Implement TM fastpath for guest entry/exit

Message ID 20210811160134.904987-41-npiggin@gmail.com
State New
Headers show
Series KVM: PPC: Book3S HV P9: entry/exit optimisations | expand

Commit Message

Nicholas Piggin Aug. 11, 2021, 4:01 p.m. UTC
If TM is not active, only TM register state needs to be saved and
restored, avoiding several mfmsr/mtmsrd instructions and improving
performance.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kvm/book3s_hv_p9_entry.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

Comments

kernel test robot Aug. 11, 2021, 8:40 p.m. UTC | #1
Hi Nicholas,

I love your patch! Yet something to improve:

[auto build test ERROR on powerpc/next]
[also build test ERROR on linus/master v5.14-rc5 next-20210811]
[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]

url:    https://github.com/0day-ci/linux/commits/Nicholas-Piggin/KVM-PPC-Book3S-HV-P9-entry-exit-optimisations/20210812-000748
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc64-randconfig-r024-20210811 (attached as .config)
compiler: powerpc-linux-gcc (GCC) 10.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://github.com/0day-ci/linux/commit/30a3a9ae99f124a863c41f268c68b647d7116b65
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Nicholas-Piggin/KVM-PPC-Book3S-HV-P9-entry-exit-optimisations/20210812-000748
        git checkout 30a3a9ae99f124a863c41f268c68b647d7116b65
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross O=build_dir ARCH=powerpc SHELL=/bin/bash arch/powerpc/kvm/

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

All errors (new ones prefixed by >>):

   In file included from arch/powerpc/include/asm/processor.h:11,
                    from arch/powerpc/include/asm/thread_info.h:40,
                    from include/linux/thread_info.h:60,
                    from include/asm-generic/preempt.h:5,
                    from ./arch/powerpc/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:78,
                    from include/linux/percpu.h:6,
                    from include/linux/context_tracking_state.h:5,
                    from include/linux/hardirq.h:5,
                    from include/linux/kvm_host.h:7,
                    from arch/powerpc/kvm/book3s_hv_p9_entry.c:3:
   arch/powerpc/kvm/book3s_hv_p9_entry.c: In function 'load_vcpu_state':
>> arch/powerpc/kvm/book3s_hv_p9_entry.c:297:33: error: 'struct kvm_vcpu_arch' has no member named 'texasr'
     297 |    mtspr(SPRN_TEXASR, vcpu->arch.texasr);
         |                                 ^
   arch/powerpc/include/asm/reg.h:1396:33: note: in definition of macro 'mtspr'
    1396 |          : "r" ((unsigned long)(v)) \
         |                                 ^
>> arch/powerpc/kvm/book3s_hv_p9_entry.c:298:33: error: 'struct kvm_vcpu_arch' has no member named 'tfhar'; did you mean 'tar'?
     298 |    mtspr(SPRN_TFHAR, vcpu->arch.tfhar);
         |                                 ^~~~~
   arch/powerpc/include/asm/reg.h:1396:33: note: in definition of macro 'mtspr'
    1396 |          : "r" ((unsigned long)(v)) \
         |                                 ^
>> arch/powerpc/kvm/book3s_hv_p9_entry.c:299:33: error: 'struct kvm_vcpu_arch' has no member named 'tfiar'; did you mean 'tar'?
     299 |    mtspr(SPRN_TFIAR, vcpu->arch.tfiar);
         |                                 ^~~~~
   arch/powerpc/include/asm/reg.h:1396:33: note: in definition of macro 'mtspr'
    1396 |          : "r" ((unsigned long)(v)) \
         |                                 ^
   arch/powerpc/kvm/book3s_hv_p9_entry.c: In function 'store_vcpu_state':
   arch/powerpc/kvm/book3s_hv_p9_entry.c:331:14: error: 'struct kvm_vcpu_arch' has no member named 'texasr'
     331 |    vcpu->arch.texasr = mfspr(SPRN_TEXASR);
         |              ^
   arch/powerpc/kvm/book3s_hv_p9_entry.c:332:15: error: 'struct kvm_vcpu_arch' has no member named 'tfhar'; did you mean 'tar'?
     332 |    vcpu->arch.tfhar = mfspr(SPRN_TFHAR);
         |               ^~~~~
         |               tar
   arch/powerpc/kvm/book3s_hv_p9_entry.c:333:15: error: 'struct kvm_vcpu_arch' has no member named 'tfiar'; did you mean 'tar'?
     333 |    vcpu->arch.tfiar = mfspr(SPRN_TFIAR);
         |               ^~~~~
         |               tar


vim +297 arch/powerpc/kvm/book3s_hv_p9_entry.c

   283	
   284	/* Returns true if current MSR and/or guest MSR may have changed */
   285	bool load_vcpu_state(struct kvm_vcpu *vcpu,
   286			     struct p9_host_os_sprs *host_os_sprs)
   287	{
   288		bool ret = false;
   289	
   290		if (cpu_has_feature(CPU_FTR_TM) ||
   291		    cpu_has_feature(CPU_FTR_P9_TM_HV_ASSIST)) {
   292			unsigned long guest_msr = vcpu->arch.shregs.msr;
   293			if (MSR_TM_ACTIVE(guest_msr)) {
   294				kvmppc_restore_tm_hv(vcpu, guest_msr, true);
   295				ret = true;
   296			} else {
 > 297				mtspr(SPRN_TEXASR, vcpu->arch.texasr);
 > 298				mtspr(SPRN_TFHAR, vcpu->arch.tfhar);
 > 299				mtspr(SPRN_TFIAR, vcpu->arch.tfiar);
   300			}
   301		}
   302	
   303		load_spr_state(vcpu, host_os_sprs);
   304	
   305		load_fp_state(&vcpu->arch.fp);
   306	#ifdef CONFIG_ALTIVEC
   307		load_vr_state(&vcpu->arch.vr);
   308	#endif
   309		mtspr(SPRN_VRSAVE, vcpu->arch.vrsave);
   310	
   311		return ret;
   312	}
   313	EXPORT_SYMBOL_GPL(load_vcpu_state);
   314	

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

Patch

diff --git a/arch/powerpc/kvm/book3s_hv_p9_entry.c b/arch/powerpc/kvm/book3s_hv_p9_entry.c
index 9ea70736f3d7..e52d8b040970 100644
--- a/arch/powerpc/kvm/book3s_hv_p9_entry.c
+++ b/arch/powerpc/kvm/book3s_hv_p9_entry.c
@@ -289,8 +289,15 @@  bool load_vcpu_state(struct kvm_vcpu *vcpu,
 
 	if (cpu_has_feature(CPU_FTR_TM) ||
 	    cpu_has_feature(CPU_FTR_P9_TM_HV_ASSIST)) {
-		kvmppc_restore_tm_hv(vcpu, vcpu->arch.shregs.msr, true);
-		ret = true;
+		unsigned long guest_msr = vcpu->arch.shregs.msr;
+		if (MSR_TM_ACTIVE(guest_msr)) {
+			kvmppc_restore_tm_hv(vcpu, guest_msr, true);
+			ret = true;
+		} else {
+			mtspr(SPRN_TEXASR, vcpu->arch.texasr);
+			mtspr(SPRN_TFHAR, vcpu->arch.tfhar);
+			mtspr(SPRN_TFIAR, vcpu->arch.tfiar);
+		}
 	}
 
 	load_spr_state(vcpu, host_os_sprs);
@@ -316,8 +323,16 @@  void store_vcpu_state(struct kvm_vcpu *vcpu)
 	vcpu->arch.vrsave = mfspr(SPRN_VRSAVE);
 
 	if (cpu_has_feature(CPU_FTR_TM) ||
-	    cpu_has_feature(CPU_FTR_P9_TM_HV_ASSIST))
-		kvmppc_save_tm_hv(vcpu, vcpu->arch.shregs.msr, true);
+	    cpu_has_feature(CPU_FTR_P9_TM_HV_ASSIST)) {
+		unsigned long guest_msr = vcpu->arch.shregs.msr;
+		if (MSR_TM_ACTIVE(guest_msr)) {
+			kvmppc_save_tm_hv(vcpu, guest_msr, true);
+		} else {
+			vcpu->arch.texasr = mfspr(SPRN_TEXASR);
+			vcpu->arch.tfhar = mfspr(SPRN_TFHAR);
+			vcpu->arch.tfiar = mfspr(SPRN_TFIAR);
+		}
+	}
 }
 EXPORT_SYMBOL_GPL(store_vcpu_state);