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

Patch for the setup of realm in ACS #197

Merged
merged 9 commits into from
Oct 13, 2023
Merged

Conversation

nook1208
Copy link
Collaborator

@nook1208 nook1208 commented Oct 6, 2023

This PR is related with #188 issue.
With this PR, we can see the realm is boot successfully in ACS test.

@nook1208 nook1208 force-pushed the acs_realm_setup_failed_resolve1 branch 2 times, most recently from ec595f9 to a51150b Compare October 11, 2023 09:41
Signed-off-by: Sunwook Eom <speed.eom@samsung.com>
Remove Rec::rd field based by RMM spec in A2.3.2 REC attributes

Signed-off-by: Sunwook Eom <speed.eom@samsung.com>
Signed-off-by: Sunwook Eom <speed.eom@samsung.com>
Signed-off-by: Sunwook Eom <speed.eom@samsung.com>
@nook1208 nook1208 force-pushed the acs_realm_setup_failed_resolve1 branch from a51150b to 209c479 Compare October 12, 2023 09:16
let flags = bits_in_reg(S2TTE::INVALID_RIPAS, invalid_ripas::RAM);
let new_s2tte = pa as u64 | flags;
let new_s2tte = s2tte.get() | flags;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Uoops, it's my fault. Thank you for finding and fixing it!

@nook1208 nook1208 force-pushed the acs_realm_setup_failed_resolve1 branch from d9d85c2 to 895a0e2 Compare October 13, 2023 03:41
Signed-off-by: Sunwook Eom <speed.eom@samsung.com>
Signed-off-by: Sunwook Eom <speed.eom@samsung.com>
Signed-off-by: Sunwook Eom <speed.eom@samsung.com>
Signed-off-by: Sunwook Eom <speed.eom@samsung.com>
The previous TIMEOUT is not enough

Signed-off-by: Sunwook Eom <speed.eom@samsung.com>
@nook1208 nook1208 force-pushed the acs_realm_setup_failed_resolve1 branch from 895a0e2 to 7840a8c Compare October 13, 2023 03:42
@nook1208 nook1208 marked this pull request as ready for review October 13, 2023 04:25
let vcpuid = rec.id();
let config_ipa = rmi.get_reg(realmid, vcpuid, 1)?;
rmi.realm_config(realmid, config_ipa)?;
rmi.realm_config(realmid, config_ipa, rec.ipa_bits()?)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rec.ipa_bits() should inquire Rd to get this. This makes another wrapper.
I think Rd should directly expose the ipa_bits() method because Rd holds the information.
Why don't we get it as following?
let rd = rec.rd()
rm.realm_config(rd.id(), config_ipa, rd.ipa_bits());

Copy link
Collaborator Author

@nook1208 nook1208 Oct 13, 2023

Choose a reason for hiding this comment

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

I tried to make a rec.rd() which gets the granule of the rd and return it.
But in rust, it's impossible to return a reference to a variable created in a function.
So maybe I can write like this :

let rd = get_granule_if!(rec.owner(), GranuleState::RD)?;
rm.realm_config(rd.id(), config_ipa, rd.ipa_bits());

l'll make a new PR to apply your comment. Thank you :)

Copy link
Collaborator

@zpzigi754 zpzigi754 left a comment

Choose a reason for hiding this comment

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

Thank you for debugging and fixing many issues!

.lock()
.page_table
.lock()
.ipa_to_pa(crate::realm::mm::address::GuestPhysAddr::from(ipa), 3)
Copy link
Collaborator

Choose a reason for hiding this comment

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

[minor]
How about using const value instead of 3 like the below?

.ipa_to_pa(crate::realm::mm::address::GuestPhysAddr::from(ipa), RTT_PAGE_LEVEL)

Copy link
Collaborator Author

@nook1208 nook1208 Oct 13, 2023

Choose a reason for hiding this comment

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

Thank you for the review! I'll make a new PR to apply your comments after pushing this PR :)

Comment on lines -105 to +107
unsafe {
// TODO: copy rec::entry gprs to host_call gprs
let ipa: u64 = 0x800088e00000;
if run.entry_gpr0() == ipa {
// TODO: Get ipa from rec->regs[1] and map to pa
let pa: usize = 0x88b0_6000;
let host_call = rsi::hostcall::HostCall::parse_mut(pa);
host_call.set_gpr0(ipa);
}
if rec.host_call_pending() {
do_host_call(&arg, ret, rmm, rec, &mut run)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good to remove the hardcoded values!

.lock()
.page_table
.lock()
.ipa_to_pa(crate::realm::mm::address::GuestPhysAddr::from(ipa), 3)
Copy link
Collaborator

@zpzigi754 zpzigi754 Oct 13, 2023

Choose a reason for hiding this comment

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

[minor]
How about using the const value instead of 3 (the same comment as before)?

.ipa_to_pa(crate::realm::mm::address::GuestPhysAddr::from(ipa), RTT_PAGE_LEVEL)

rmm/src/rsi/hostcall.rs Show resolved Hide resolved
@nook1208 nook1208 merged commit 6fa86f4 into main Oct 13, 2023
7 checks passed
@nook1208 nook1208 deleted the acs_realm_setup_failed_resolve1 branch October 13, 2023 07:10
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.

None yet

4 participants