Subject: Re: [PATCH v3 32/32] powerpc/64s: system call support for scv/rfscv instructions

From: kbuild test robot <[email-masked]>
Date: Sun, 1 Mar 2020 20:20:49 +0800

Hi Nicholas,

I love your patch! Yet something to improve:

[auto build test ERROR on powerpc/next]
[also build test ERROR on v5.6-rc3 next-20200228]
[cannot apply to kvm-ppc/kvm-ppc-next scottwood/next]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Nicholas-Piggin/powerpc-64-interrupts-and-syscalls-series/20200226-043224
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-ppc64e_defconfig (attached as .config)
compiler: powerpc64-linux-gcc (GCC) 7.5.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.5.0 make.cross ARCH=powerpc 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <[email-masked]>

All errors (new ones prefixed by >>):

   arch/powerpc/kernel/entry_64.S: Assembler messages:
>> arch/powerpc/kernel/entry_64.S:67: Error: unrecognized opcode: `interrupt_to_kernel'
>> arch/powerpc/kernel/entry_64.S:164: Error: unrecognized opcode: `rfscv_to_user'

vim +67 arch/powerpc/kernel/entry_64.S

    47	
    48	/*
    49	 * System calls.
    50	 */
    51		.section	".toc","aw"
    52	SYS_CALL_TABLE:
    53		.tc sys_call_table[TC],sys_call_table
    54	
    55	COMPAT_SYS_CALL_TABLE:
    56		.tc compat_sys_call_table[TC],compat_sys_call_table
    57	
    58	/* This value is used to mark exception frames on the stack. */
    59	exception_marker:
    60		.tc	ID_EXC_MARKER[TC],STACK_FRAME_REGS_MARKER
    61	
    62		.section	".text"
    63		.align 7
    64	
    65		.globl system_call_vectored_common
    66	system_call_vectored_common:
  > 67		INTERRUPT_TO_KERNEL
    68		mr	r10,r1
    69		ld	r1,PACAKSAVE(r13)
    70		std	r10,0(r1)
    71		std	r11,_NIP(r1)
    72		std	r12,_MSR(r1)
    73		std	r0,GPR0(r1)
    74		std	r10,GPR1(r1)
    75		std	r2,GPR2(r1)
    76		ld	r2,PACATOC(r13)
    77		mfcr	r12
    78		li	r11,0
    79		/* Can we avoid saving r3-r8 in common case? */
    80		std	r3,GPR3(r1)
    81		std	r4,GPR4(r1)
    82		std	r5,GPR5(r1)
    83		std	r6,GPR6(r1)
    84		std	r7,GPR7(r1)
    85		std	r8,GPR8(r1)
    86		/* Zero r9-r12, this should only be required when restoring all GPRs */
    87		std	r11,GPR9(r1)
    88		std	r11,GPR10(r1)
    89		std	r11,GPR11(r1)
    90		std	r11,GPR12(r1)
    91		std	r9,GPR13(r1)
    92		SAVE_NVGPRS(r1)
    93		std	r11,_XER(r1)
    94		std	r11,_LINK(r1)
    95		std	r11,_CTR(r1)
    96	
    97		li	r11,0xc00
    98		std	r11,_TRAP(r1)
    99		std	r12,_CCR(r1)
   100		std	r3,ORIG_GPR3(r1)
   101		addi	r10,r1,STACK_FRAME_OVERHEAD
   102		ld	r11,exception_marker@toc(r2)
   103		std	r11,-16(r10)		/* "regshere" marker */
   104	
   105		/*
   106		 * RECONCILE_IRQ_STATE without calling trace_hardirqs_off(), which
   107		 * would clobber syscall parameters. Also we always enter with IRQs
   108		 * enabled and nothing pending. system_call_exception() will call
   109		 * trace_hardirqs_off().
   110		 *
   111		 * scv enters with MSR[EE]=1, so don't set PACA_IRQ_HARD_DIS.
   112		 */
   113		li	r9,IRQS_ALL_DISABLED
   114		stb	r9,PACAIRQSOFTMASK(r13)
   115	
   116		/* Calling convention has r9 = orig r0, r10 = regs */
   117		mr	r9,r0
   118		bl	system_call_exception
   119	
   120	.Lsyscall_vectored_exit:
   121		addi    r4,r1,STACK_FRAME_OVERHEAD
   122		li	r5,1 /* scv */
   123		bl	syscall_exit_prepare
   124	
   125		ld	r2,_CCR(r1)
   126		ld	r4,_NIP(r1)
   127		ld	r5,_MSR(r1)
   128	
   129	BEGIN_FTR_SECTION
   130		stdcx.	r0,0,r1			/* to clear the reservation */
   131	END_FTR_SECTION_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS)
   132	
   133		mtlr	r4
   134		mtctr	r5
   135	
   136		cmpdi	r3,0
   137		bne	syscall_vectored_restore_regs
   138		li	r0,0
   139		li	r4,0
   140		li	r5,0
   141		li	r6,0
   142		li	r7,0
   143		li	r8,0
   144		li	r9,0
   145		li	r10,0
   146		li	r11,0
   147		li	r12,0
   148		mtspr	SPRN_XER,r0
   149	.Lsyscall_vectored_restore_regs_cont:
   150	
   151	BEGIN_FTR_SECTION
   152		HMT_MEDIUM_LOW
   153	END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
   154	
   155		/*
   156		 * We don't need to restore AMR on the way back to userspace for KUAP.
   157		 * The value of AMR only matters while we're in the kernel.
   158		 */
   159		mtcr	r2
   160		ld	r2,GPR2(r1)
   161		ld	r3,GPR3(r1)
   162		ld	r13,GPR13(r1)
   163		ld	r1,GPR1(r1)
 > 164		RFSCV_TO_USER
   165		b	.	/* prevent speculative execution */
   166	_ASM_NOKPROBE_SYMBOL(system_call_vectored_common);
   167	
   168	syscall_vectored_restore_regs:
   169		ld	r4,_XER(r1)
   170		REST_NVGPRS(r1)
   171		mtspr	SPRN_XER,r4
   172		ld	r0,GPR0(r1)
   173		REST_8GPRS(4, r1)
   174		ld	r12,GPR12(r1)
   175		b	.Lsyscall_vectored_restore_regs_cont
   176	
   177		.balign IFETCH_ALIGN_BYTES
   178		.globl system_call_common
   179	system_call_common:
   180	_ASM_NOKPROBE_SYMBOL(system_call_common)
   181		mr	r10,r1
   182		ld	r1,PACAKSAVE(r13)
   183		std	r10,0(r1)
   184		std	r11,_NIP(r1)
   185		std	r12,_MSR(r1)
   186		std	r0,GPR0(r1)
   187		std	r10,GPR1(r1)
   188		std	r2,GPR2(r1)
   189	#ifdef CONFIG_PPC_FSL_BOOK3E
   190	START_BTB_FLUSH_SECTION
   191		BTB_FLUSH(r10)
   192	END_BTB_FLUSH_SECTION
   193	#endif
   194		ld	r2,PACATOC(r13)
   195		mfcr	r12
   196		li	r11,0
   197		/* Can we avoid saving r3-r8 in common case? */
   198		std	r3,GPR3(r1)
   199		std	r4,GPR4(r1)
   200		std	r5,GPR5(r1)
   201		std	r6,GPR6(r1)
   202		std	r7,GPR7(r1)
   203		std	r8,GPR8(r1)
   204		/* Zero r9-r12, this should only be required when restoring all GPRs */
   205		std	r11,GPR9(r1)
   206		std	r11,GPR10(r1)
   207		std	r11,GPR11(r1)
   208		std	r11,GPR12(r1)
   209		std	r9,GPR13(r1)
   210		SAVE_NVGPRS(r1)
   211		std	r11,_XER(r1)
   212		std	r11,_CTR(r1)
   213		mflr	r10
   214	
   215		/*
   216		 * This clears CR0.SO (bit 28), which is the error indication on
   217		 * return from this system call.
   218		 */
   219		rldimi	r12,r11,28,(63-28)
   220		li	r11,0xc00
   221		std	r10,_LINK(r1)
   222		std	r11,_TRAP(r1)
   223		std	r12,_CCR(r1)
   224		std	r3,ORIG_GPR3(r1)
   225		addi	r10,r1,STACK_FRAME_OVERHEAD
   226		ld	r11,exception_marker@toc(r2)
   227		std	r11,-16(r10)		/* "regshere" marker */
   228	
   229		/*
   230		 * RECONCILE_IRQ_STATE without calling trace_hardirqs_off(), which
   231		 * would clobber syscall parameters. Also we always enter with IRQs
   232		 * enabled and nothing pending. system_call_exception() will call
   233		 * trace_hardirqs_off().
   234		 */
   235		li	r11,IRQS_ALL_DISABLED
   236		li	r12,PACA_IRQ_HARD_DIS
   237		stb	r11,PACAIRQSOFTMASK(r13)
   238		stb	r12,PACAIRQHAPPENED(r13)
   239	
   240		/* Calling convention has r9 = orig r0, r10 = regs */
   241		mr	r9,r0
   242		bl	system_call_exception
   243	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email-masked]