in sparc linux system call entry assembly code
Hi, below is a code snippet from arch/sparc/kernel/entry.S. I can't understand a part of it (I think I once understood it but forgot..). #define LINUX_SYSCALL_TRAP \ sethi %hi(sys_call_table), %l7; \ or %l7, %lo(sys_call_table), %l7; \ b linux_sparc_syscall; \ rd %psr, %l0; .... linux_sparc_syscall: sethi %hi(PSR_SYSCALL), %l4 or %l0, %l4, %l0 /* Direct access to user regs, must faster. */ cmp %g1, NR_syscalls bgeu linux_sparc_ni_syscall sll %g1, 2, %l4 ld [%l7 + %l4], %l7 andcc %l7, 1, %g0 bne linux_fast_syscall /* Just do first insn from SAVE_ALL in the delay slot */ when linux system call trap is entered, the sys_call_table address is stored in %l7 and %psr in %l0 and it branches to linux_sparc_syscall. (%psr is read in branch delayed slot). From the linux_sparc_syscall, the the %l0 (PSR value) is set with system call bit (to indicate it's in system call later), and if the system call number is compared with the max value, if it is greater or equal, it branches to linux_sparc_ni_syscall (not implemented). The part I can't understand follows. %l7 contains sys_call_table, so it loads the system call address with corresponding offset (nubmer * 4, or 2 bit shift left). Then what is this "andcc %l7, 1, %g0" doing? Thanks! Chan
On Fri, 28 Mar 2014 07:25:37 -0000, 김찬 said:
andcc %l7, 1, %g0 bne linux_fast_syscall
Then what is this "andcc %l7, 1, %g0" doing?
Well, I'm not an expert on Sparc assembler, but.. 'andcc' looks like it's doing an and, and setting the cc (condition code). Then 'bne' branch not equal. Looks to me like it's testing a bit in the just-loaded address to see if it's flagged as using the fast_syscall code. Go check the code that generates the table and see if there is something different about the way they generate some entries.
Thanks Valdis, I thought similar way and it's clearer. Probably bit 0 of the sys_call_table contains whether it's using fast syscal. But I couldn't find the code setting bit 0. I'll try later when I'm done with more urgent things. Thank you! Chan ________________________________ From : "Valdis.Kletnieks@vt.edu" <Valdis.Kletnieks@vt.edu> Sent : 2014-03-28 22:36:27 ( +09:00 ) To : Chan Kim <ckim@etri.re.kr> Cc : kernelnewbies@kernelnewbies.org <kernelnewbies@kernelnewbies.org> Subject : Re: in sparc linux system call entry assembly code On Fri, 28 Mar 2014 07:25:37 -0000, 김찬 said:
andcc %l7, 1, %g0 bne linux_fast_syscall
Then what is this "andcc %l7, 1, %g0" doing?
Well, I'm not an expert on Sparc assembler, but.. 'andcc' looks like it's doing an and, and setting the cc (condition code). Then 'bne' branch not equal. Looks to me like it's testing a bit in the just-loaded address to see if it's flagged as using the fast_syscall code. Go check the code that generates the table and see if there is something different about the way they generate some entries.
participants (3)
-
Chan Kim -
Valdis.Kletnieks@vt.edu -
김찬