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

  • Home
  • SEARCH
  • 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 111787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:26:30+00:00 2026-05-11T02:26:30+00:00

This is related to this question . I’m not an expert on Linux device

  • 0

This is related to this question.

I’m not an expert on Linux device drivers or kernel modules, but I’ve been reading ‘Linux Device Drivers’ [O’Reilly] by Rubini & Corbet and a number of online sources, but I haven’t been able to find anything on this specific issue yet.

When is a kernel or driver module allowed to use floating-point registers?
If so, who is responsible for saving and restoring their contents?
(Assume x86-64 architecture)

If I understand correctly, whenever a KM is running, it is using a hardware context (or hardware thread or register set — whatever you want to call it) that has been preempted from some application thread. If you write your KM in c, the compiler will correctly insure that the general-purpose registers are properly saved and restored (much as in an application), but that doesn’t automatically happen with floating-point registers. For that matter, a lot of KMs can’t even assume that the processor has any floating-point capability.

Am I correct in guessing that a KM that wants to use floating-point has to carefully save and restore the floating-point state? Are there standard kernel functions for doing this?

Are the coding conventions for this spelled out anywhere?
Are they different for SMP-non SMP drivers?
Are they different for older non-preemptive kernels and newer preemptive kernels?

  • 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. 2026-05-11T02:26:31+00:00Added an answer on May 11, 2026 at 2:26 am

    Short answer: Kernel code can use floating point if this use is surrounded by kernel_fpu_begin()/kernel_fpu_end(). These function handle saving and restoring the fpu context. Also, they call preempt_disable()/preempt_enable(), which means no sleeping, page faults etc. in the code between those functions. Google the function names for more information.

    If I understand correctly, whenever a KM is running, it is using a hardware context (or hardware thread or register set — whatever you want to call it) that has been preempted from some application thread.

    No, a kernel module can run in user context as well (eg. when userspace calls syscalls on a device provided by the KM). It has, however, no relation to the float issue.

    If you write your KM in c, the compiler will correctly insure that the general-purpose registers are properly saved and restored (much as in an application), but that doesn’t automatically happen with floating-point registers.

    That is not because of the compiler, but because of the kernel context-switching code.

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

Sidebar

Related Questions

This is related to this question , but given the direction of the answers,
First of all, I looked up this related question in here but the solution
The answers to this related question of mine lead me to choose Java for
I found this related question: How do I use composition with inheritance? I would
This is a related question to one I posted earlier... I'm trying to sum
This is a related question to: Android NFC start service In Android, can an
This is a related question to one I posted earlier today, I was initially
Please note this question related to performance only. Lets skip design guidelines, philosophy, compatibility,
I hope this is programmer-related question. I'm in the hobby business of C# programming.
Important : Please see this very much related question: Return multiple values in C++

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.