ArticleslgStudy

computer science

Lazy FP state restore

Lazy FP state restore is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Lazy FP state restore rather than just read about it. In short: Lazy FPU state leak (CVE-2018-3665), also referred to as Lazy FP State Restore or LazyFP, is a security vulnerability affecting Intel Core CPUs. The vulnerability is caused by a combination of flaws in the speculative execution technology present within the affected CPUs and how certain operating systems handle context switching on the floating point unit (FPU).

Key takeaways

  • Lazy FP state restore belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Lazy FP state restore to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Lazy FP state restore from memory before moving on to harder problems.

Reference excerpt

Lazy FPU state leak (CVE-2018-3665), also referred to as Lazy FP State Restore or LazyFP, is a security vulnerability affecting Intel Core CPUs. The vulnerability is caused by a combination of flaws in the speculative execution technology present within the affected CPUs and how certain operating systems handle context switching on the floating point unit (FPU). By exploiting this vulnerability, a local process can leak the content of the FPU registers that belong to another process. This vulnerability is related to the Spectre and Meltdown vulnerabilities that were publicly disclosed in January 2018. It was announced by Intel on 13 June 2018, after being discovered by employees at Amazon, Cyberus Technology and SYSGO. Besides being used for floating point arithmetic, the FPU registers are also used for other purposes, including for storing cryptographic data when using the AES instruction set, present in many Intel CPUs. This means that this vulnerability may allow for key material to be compromised.

Mechanism The floating point and SIMD registers are large, and not used by every task (or thread) in the system. To make context switching faster, most common microprocessors support lazy state switching. Rather than storing the full state during a context switch, the operating system can simply mark the FPU "not available" in the hopes that the switched-to task will not need it. If the operating system has guessed correctly, time is saved. If the guess is wrong, the first FPU or SIMD instruction will cause a trap to the operating system, which can then save the state to the previous task and load the correct state for the current task. In out-of-order CPUs, the "FPU not available" condition is not detected immediately. (In fact, it almost cannot be detected immediately, as there may be multiple fault-causing instructions executing simultaneously and the processor must take the first fault encountered to preserve the illusion of in-order execution. The information about which is first is not available until the in-order retire stage.) The processor speculatively executes the instruction using the previous task's register contents, and some following instructions, and only later detects the FPU not available condition. Although all architectural state is reverted to the beginning of the faulting instruction, it is possible to use part of the FPU state as the address in a memory load, triggering a load into the processor's cache. Exploitation then follows the same pattern as all Spectre-family vulnerabilities: as the cache state is not architectural state (the cache only affect speed, not correctness), the cache load is not undone and the address, including part of the previous task's register state, can later be detected by measuring the time taken to access different memory addresses. It is possible to exploit this bug without actually triggering any operating system traps. By placing the FPU access in the shadow of a forced branch misprediction (e.g. using a retpoline) the processor will still speculatively execute the code, but will rewind to the mispredicted branch and never actually execute the operating system trap. This allows the attack to be rapidly repeated, quickly reading out the entire FPU and SIMD register state.

Mitigation It is possible to mitigate the vulnerability at the operating system and hypervisor levels by always restoring the FPU state when switching process contexts. With such a fix, no firmware upgrade is required. Some operating systems already did not lazily restore the FPU registers by default, protecting those operating systems on affected hardware platforms, even if the underlying hardware issue existed. On Linux operating system using kernel 3.7 or higher, it is possible to force the kernel to eagerly restore the FPU registers by using the eagerfpu=on kernel parameter. Also, many system software vendors and projects, including Linux distributions, OpenBSD, and Xen have released patches to address the vulnerability.

Notes

References

External links LazyFP: Leaking FPU Register State using Microarchitectural Side-Channel, by Julian Stecklina and Thomas Prescher (Research paper) Intel LazyFP vulnerability: Exploiting lazy FPU state switching, by Thomas Prescher, Julian Stecklina and Jacek Galowicz (Cyberus Technology) Archived 2020-11-09 at the Wayback Machine Lazy FP state restore (Intel Security Advisory) Theo de Raadt of OpenBSD explains Lazy FPU state vulnerability on YouTube

Worked examples

Example 1 — a first encounter with Lazy FP state restore

Start with the simplest possible case. Write down what Lazy FP state restore claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Lazy FP state restore before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Lazy FP state restore ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Lazy FP state restore

In research
Lazy FP state restore appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Lazy FP state restore in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Lazy FP state restore is common in secondary-school and first-year university syllabi. It links to neighbouring topics 2018 in computing, Computer security stubs, Transient execution CPU vulnerabilities, so understanding it makes those chapters shorter.
In everyday life
Look for Lazy FP state restore outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Lazy FP state restore” →

How to study Lazy FP state restore in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Lazy FP state restore means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Lazy FP state restore out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Lazy FP state restore in simple terms?

Lazy FPU state leak (CVE-2018-3665), also referred to as Lazy FP State Restore or LazyFP, is a security vulnerability affecting Intel Core CPUs. The vulnerability is caused by a combination of flaws in the speculative execution technology present within the affected CPUs and how certain operating s…

Why does Lazy FP state restore matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Lazy FP state restore?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Lazy FP state restore.

Tags

  • 2018 in computing
  • Computer security stubs
  • Transient execution CPU vulnerabilities

Keep exploring