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

Fixes for Xen grant table driver #128

Merged
merged 2 commits into from
Dec 11, 2024

Conversation

firscity
Copy link
Collaborator

Commits in this PR fixes 2 issues in Xen grant table driver for Zephyr RTOS:

  • incorrect initialization sequence
  • incorrect struct, that was used during unmap of foreign grant frames

These changes will be also upstreamed to Zephyr RTOS main branch

@@ -382,13 +380,6 @@ static int gnttab_init(void)
__ASSERT(!rc, "add_to_physmap failed; status = %d\n", rc);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This question is not related to these changes, but AFAIU this assert will work only in test builds: https://elixir.bootlin.com/zephyr/v4.0.0/source/subsys/debug/Kconfig#L249.

Is this expected, or should we use something else for assertions in any case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IIUC the purpose of asserts is Zephyr - it is expected to appear as critical error on test builds and completely disappear on target builds. Since we depend on hypervisor here, just if() will be more correct, assert is legacy taken from mini-os driver.

@LKomaryanskiy
Copy link

Good job!
Acked-by: Leonid Komarianskyi <[email protected]>

Initially this driver was a port from mini-os. Michal Orzel
(@orzelmichal) pointed that it contains incorrect grant table
initialization sequence and redundant calls. Driver mapped grant table
frames via loop of XENMEM_add_to_physmap calls and then tried to do the
same but via GNTTABOP_setup_table operation. After completion of latter
it did not even use provided frames list. This did not cause any major
issues, since XENMEM_add_to_physmap correctly map gnttab frames that
were used.

Remove redundant GNTTABOP_setup_table call from grant table driver to
clean up its initialization sequence.

Signed-off-by: Dmytro Firsov <[email protected]>
Acked-by: Leonid Komarianskyi <[email protected]>
Previously driver gnttab_unmap_refs() signature used incorrect struct
- the same one, that is used for mapping. Since host_addr field, that
is used to point to required frame is first in both structures it
somehow worked.

Fix mistake and use 'struct gnttab_unmap_grant_ref' for grant frames
unmapping hypercalls.

Signed-off-by: Dmytro Firsov <[email protected]>
Acked-by: Leonid Komarianskyi <[email protected]>
@firscity
Copy link
Collaborator Author

@LKomaryanskiy thanks for review, added AB

@firscity firscity merged commit 4d91cdd into xen-troops:zephyr-v3.6.0-xt Dec 11, 2024
9 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.

3 participants