Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AArch64: speed up paging and fix exception caused by atomic operation #250

Merged
merged 4 commits into from
May 28, 2023

Conversation

jongwu
Copy link
Contributor

@jongwu jongwu commented May 10, 2023

There are some issues for rust firmware on arm64:

Two of them:

  • use atomic instruction before mmu enabled may cause exception;
  • page table creation takes too long;

To address above issues:

  • Use atomic operation after MMU enabled;
  • optimize page table creation algorithem;

jongwu added 3 commits May 10, 2023 14:46
Atomic operation may cause exception when MMU is not enabled.
Serial device struct is containered by atomic refcell that should be
done after MMU is enabled.

Signed-off-by: Jianyong Wu <[email protected]>
Firmware region is used for edk2 thus will not be used here.
Merge it into MMIO region to speed up page table creation.

Also enlarge memory map size to 128G then we can use large memory
when boot from rust firmware.

Signed-off-by: Jianyong Wu <[email protected]>
To set different page attribute for code segment, it must be align with
page size which is 64kB in current implementation.

Signed-off-by: Jianyong Wu <[email protected]>
@rbradford
Copy link
Member

Please fix your formatting.

@rbradford rbradford requested a review from retrage May 11, 2023 16:22
Creating page table takes 8K * 2 * MEM_SIZE(GB) times loop while
each loop is time-consuming. It may takes a few seconds to complete
page table creating.

As a certain memory region has the same memory attribute, saying the
whole MMIO region and the most normal memory, we can simply use 512M
block to map the region instead of use 64kB page.
Also, there is some optimization in page table creating algorithm.

After this change, page table creating takes only dozens of ms.

Signed-off-by: Jianyong Wu <[email protected]>
@jongwu jongwu force-pushed the speedup_paging branch 2 times, most recently from 7522586 to d73060a Compare May 12, 2023 09:03
Copy link
Contributor

@retrage retrage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the debug-related commit (d73060a) from your PR, as it's too specific to your testing environment. If you want to keep the debug feature, you should provide scripts and documents so that other people can use it.

@jongwu
Copy link
Contributor Author

jongwu commented May 15, 2023

Please remove the debug-related commit (d73060a) from your PR, as it's too specific to your testing environment. If you want to keep the debug feature, you should provide scripts and documents so that other people can use it.

OK, I will remove it currently.

Copy link
Contributor

@retrage retrage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me.

Copy link
Member

@rbradford rbradford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only have build testing on aarch64 so @retrage do you want to boot test it too?

@retrage
Copy link
Contributor

retrage commented May 18, 2023

@rbradford Yes, as it's listed on the tracking issue #198. I'd like to try vanilla Ubuntu cloud images with this PR changes.

@retrage retrage merged commit bb72524 into cloud-hypervisor:main May 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants