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

mm: always use this_cpu().get_pgtable() instead of get_init_pgtable_locked() #443

Merged
merged 8 commits into from
Aug 23, 2024

Conversation

Freax13
Copy link
Contributor

@Freax13 Freax13 commented Aug 21, 2024

get_init_pgtable_locked() was problematic because the returned mutable reference was aliasing the mutable reference returned in this_cpu().get_pgtable() in stage2.

Removing get_init_pgtable_locked() now will probably also make it easier to implement isolated pagetables in the future because everything is already only accessing this_cpu().get_pgtable().

We don't use the &mut PageTableRef for anything but dereferencing it
into a &mut PageTable.
It's the same reason why &T and &[T] are generally prefered over
&Box<T> or &Vec<T>.

Signed-off-by: Tom Dohrmann <[email protected]>
This safety comment isn't followed by any unsafe code.

Signed-off-by: Tom Dohrmann <[email protected]>
Previously we had PageTableRef for this, but all we really need is a static
mut reference.

Signed-off-by: Tom Dohrmann <[email protected]>
We know that we'll return PageTableRef::Owned and never PageTableRef::Shared,
so let's just return the PageBox directly.

Signed-off-by: Tom Dohrmann <[email protected]>
This will make it possible to create the pagetables slightly
differently depending on where in the boot process this code is called.

Signed-off-by: Tom Dohrmann <[email protected]>
There's no need to use the pagetables stored in a global when we can
just use the CPUs active pagetables.

Signed-off-by: Tom Dohrmann <[email protected]>
INIT_PGTABLE was problematic because it contained a mutable static reference to
the same page tables pointed to by the BSPs percpu pagetables. Obviously we
should avoid creating two static mutable references pointing to the same
memory.
Now that code is always using this_cpu().get_pgtables() there's no need for
INIT_PGTABLE anymore.

Signed-off-by: Tom Dohrmann <[email protected]>
This type is now unused.

Signed-off-by: Tom Dohrmann <[email protected]>
@Freax13 Freax13 force-pushed the remove-init-pgtable branch from 864491f to 4814e0a Compare August 22, 2024 09:00
@Freax13 Freax13 mentioned this pull request Aug 22, 2024
14 tasks
Copy link
Member

@joergroedel joergroedel left a comment

Choose a reason for hiding this comment

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

LGTM.

@joergroedel joergroedel merged commit 1fb6f4f into coconut-svsm:main Aug 23, 2024
3 checks passed
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.

2 participants