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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions drivers/xen/gnttab.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, unsigned int count)
return 0;
}

int gnttab_unmap_refs(struct gnttab_map_grant_ref *unmap_ops, unsigned int count)
int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops, unsigned int count)
{
#ifdef CONFIG_XEN_REGIONS
for (unsigned int i = 0; i < count; i++) {
Expand Down Expand Up @@ -349,8 +349,6 @@ static int gnttab_init(void)
{
grant_ref_t gref;
struct xen_add_to_physmap xatp;
struct gnttab_setup_table setup;
xen_pfn_t frames[CONFIG_NR_GRANT_FRAMES];
int rc = 0, i;
unsigned long xen_max_grant_frames;
uintptr_t gnttab_base = DT_REG_ADDR_BY_IDX(DT_INST(0, xen_xen), 0);
Expand Down Expand Up @@ -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.

}

setup.dom = DOMID_SELF;
setup.nr_frames = CONFIG_NR_GRANT_FRAMES;
set_xen_guest_handle(setup.frame_list, frames);
rc = HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
__ASSERT((!rc) && (!setup.status), "Table setup failed; status = %s\n",
gnttabop_error(setup.status));

/*
* Xen DT region reserved for grant table (first reg in hypervisor node)
* may be much bigger than CONFIG_NR_GRANT_FRAMES multiplied by page size.
Expand Down
4 changes: 2 additions & 2 deletions include/zephyr/xen/gnttab.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, unsigned int count);
* Unmap foreign grant refs. The gnttab_put_page() should be used after this for
* each page, that was successfully unmapped.
*
* @param unmap_ops - array of prepared gnttab_map_grant_ref's for unmapping
* @param unmap_ops - array of prepared gnttab_unmap_grant_ref's for unmapping
* @param count - number of grefs in unmap_ops array
* @return - @count on success or negative errno on failure
* also per-page status will be set in unmap_ops[i].status (GNTST_*)
*/
int gnttab_unmap_refs(struct gnttab_map_grant_ref *unmap_ops, unsigned int count);
int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops, unsigned int count);

/*
* Convert grant ref status codes (GNTST_*) to text messages.
Expand Down