microsoft / mu_basecore

Project Mu BaseCore
https://microsoft.github.io/mu/
Other
239 stars 122 forks source link

[CHERRY-PICK] UefiCpuPkg:fix issue when splitting paging entry #1064

Closed kenlautner closed 1 month ago

kenlautner commented 1 month ago

Description

This patch is to fix issue when splitting leaf paging entry in CpuPageTableLib code.

In previous code, before we assign the new child paging structure address to the content of splitted paging entry, PageTableLibSetPnle() is called to make sure the bit7 is set to 0, which indicate the previous leaf entry is changed to non-leaf entry now. There is a gap between we change the bit7 and we assign the new child paging structure address to the content of the splitted paging entry. If the address of code execution or data access happens to be in the range covered by the splitted paging entry, this gap may cause issue.

In this patch, we prepare the new paging entry content value in a local variable and assign the value to the splitted paging entry at once. The volatile keyword is used to ensure that no optimization will occur in compilation.

Reviewed-by: Ray Ni ray.ni@intel.com Cc: Rahul Kumar rahul1.kumar@intel.com Cc: Gerd Hoffmann kraxel@redhat.com Reviewed-by: Jiaxin Wu jiaxin.wu@intel.com Cc: Zhou Jianfeng jianfeng.zhou@intel.com

How This Was Tested

Tested on Intel physical platforms that were hitting a paging split issue and ones that weren't having any problems. With this fix both platforms are able to boot correctly.

Integration Instructions

N/A

codecov-commenter commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Please upload report for BASE (release/202405@6664692). Learn more about missing BASE report.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## release/202405 #1064 +/- ## ================================================ Coverage ? 4.76% ================================================ Files ? 133 Lines ? 26095 Branches ? 534 ================================================ Hits ? 1243 Misses ? 24828 Partials ? 24 ``` | [Flag](https://app.codecov.io/gh/microsoft/mu_basecore/pull/1064/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=microsoft) | Coverage Δ | | |---|---|---| | [UefiCpuPkg](https://app.codecov.io/gh/microsoft/mu_basecore/pull/1064/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=microsoft) | `4.76% <100.00%> (?)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=microsoft#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.