SYSCALL cycles

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
tsdnz
Member
Member
Posts: 333
Joined: Sun Jun 16, 2013 4:09 am

SYSCALL cycles

Post by tsdnz »

Hi everyone.

I have timed my SYSCALL & SYSRET functions.
I am averaging 82.60 cycles for the following code.
I was wondering what everyone else was getting?
I thought this might have been faster??

Code: Select all

volatile QWORD TestAccount = 0;

	void AlignTo(64) SYSCALL()
	{
		TestAccount += 1;

		asm volatile("SYSRETQ");
	}

	void AlignTo(64) TestUserspace()
	{
		while (true)
		{
			asm volatile("SYSCALL");
		}
	}
Here is the asm:

Code: Select all

0000000000303640 <_ZN6Kernel7SYSCALLEv>:
  303640:	48 b8 40 f0 35 00 00 	movabs rax,0x35f040
  303647:	00 00 00 
  30364a:	48 8b 10             	mov    rdx,QWORD PTR [rax]
  30364d:	48 83 c2 01          	add    rdx,0x1
  303651:	48 89 10             	mov    QWORD PTR [rax],rdx
  303654:	48 0f 07             	rex.W sysret

Code: Select all

0000000000303680 <_ZN6Kernel13TestUserspaceEv>:
  303680:	0f 05                	syscall 
  303682:	eb fc                	jmp    303680 <_ZN6Kernel13TestUserspaceEv>
Post Reply