November 29, 2023

PBX Science

VoIP & PBX, Networking, DIY, Computers.

Linus personally helped Intel optimize the LAM code

2 min read

Linus personally helped Intel optimize the LAM code

 

Linus personally helped Intel optimize the LAM code. 

At the end of last year, Intel submitted the LAM (Linear Address Masking: linear address mask) function to the merge window of Linux 6.2, but this function was criticized by Linus and refused to merge.

After a period of code improvement, Linus finally agreed to merge the LAM code into Linux 6.4 windows.

 

But Linus still seems not satisfied with the code submitted by Intel engineers.

After merging the LAM code, he first wrote a new patch to make access_ok() independent of LAM , and then wrote several patches by himself to optimize the LAM code. .

 




Linus personally helped Intel optimize the LAM code

 

In the latest LAM optimization patch submission , Linus explains his motivation:

I was very upset with the way the “access_ok()” of the LAM (“Linear Address Mask”) was done in this version, and it actually had some small bugs, so I got my hands dirty and cleaned up the code.

 

The changes mainly focus on the following aspects:

  • Use the sign bit of the __user pointer instead of the masked address, and check it against the TASK_SIZE range. The get/put_user() side does this part, but ‘access_ok()’ does a naive “mask and range check”, which not only generates redundant code, but also means that __access_ok itself doesn’t do its job well, copy_from_user_nmi () is not properly checked.
  • Move all 64-bit code into header files only for 64-bit versions, so you don’t pollute shared x86 code, and don’t mislead users that LAM works in 32-bit environments.
  • Fix bug in address mask (it doesn’t matter, just removes bad code completely).
  • A couple of simple cleanups, and added a note about the access_ok() rule.

Linus rewrote about a hundred lines of code to clean up the LAM, which means that if the test is OK, the LAM function can be successfully enabled in Linux 6.4 . However, this time Linus actually personally modified the “flawed code” for Intel engineers, which is quite rare.

 

 

 

Linus personally helped Intel optimize the LAM code


Copyright © All rights reserved. | Newsphere by AF themes.