Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8666809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:49:17+00:00 2026-06-12T17:49:17+00:00

I am studying the Linux kernel and at the moment I try to implement

  • 0

I am studying the Linux kernel and at the moment I try to implement my own system call.

In the kernel code it looks the following:

asmlinkage long sys_my_syscall()
{
     printk("My system call\n");
     return 0;
}

If I call it with a systemcall() function it works fine, but I have found another one way:

int my_syscall(void)
{
    long __res;
    __asm__ volatile (
    "movl $312, %%eax;"
    "int $0x80;"
    "movl %%eax, %0;"
    : "=m" (__res)
    :
    : "%eax"
    );
    if ((unsigned long) (__res) >= (unsigned long) (-125)) {
       errno = -(__res);
       __res = -1;
    }
    return (int)(__res);
}

But it returns the value -14 EFAULT.

What am I doing wrong?

Setup: Linux kernel 3.4, ARCH x86_64

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:49:18+00:00Added an answer on June 12, 2026 at 5:49 pm

    For 64-bit systems the Linux system call ABI is completely different from i*86 one unless there’s a layer of compatibility.
    This may help:
    http://callumscode.com/blog/3

    I also found the syscall source in the eglibc, it looks different indeed:
    http://www.eglibc.org/cgi-bin/viewvc.cgi/trunk/libc/sysdeps/unix/sysv/linux/x86_64/syscall.S?view=markup

    So it looks like int $0x80 does not work for x86_64 Linux kernels, you need to use syscall instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm studying linux slab allocation. Following to linux kernel source code mm/slab.c , it
I am studying system call in linux with source code in version 2.6.39.4. Books
I'm studying the mechanism of module loading inside the linux kernel, and I'm stuck
I'm studying the linux-3.2.9 kernel, and in sched_rt.c function pick_next_highest_task_rt() there is a for
Studying some code from a codeigniter tut, the following preg_match pattern has me baffled:
I'm studying about Linux kernel and I have a problem. I see many Linux
I'm studying the code of the netstat tool (Linux), which AFAIK mostly reads a
I'm studying about System Calls in Linux and I read the read() System Calls.
I am studying the book Beginning Linux Programming 4th ed and chapter 2 is
While studying for a Functional Programming exam, I came across the following questions from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.