Skip to contentSkip to conversation

xen/mem-reservation API and out-of-tree kernel modules

Xen-devel Oleksandr Andrushchenko 4 participants 15 messages Jan 31, 2019 – Feb 1, 2019 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

Hello,

I am working on porting an out-of-tree kernel driver to the kernel 5.0 and that driver uses functionality provided by drivers/xen/mem-reservation.c
module.  Since commit [1] it is not possible to build a kernel module which uses mem-reservation API as xen_scrub_pages variable, which is checked in
xenmem_reservation_scrub_page, became a kernel module parameter and is now only
accessible for built-in modules:

static inline void xenmem_reservation_scrub_page(struct page *page) ^^^^^^^^^^^^^
{
    if (xen_scrub_pages)
        ^^^^^^^^^^^^^^^
        clear_highpage(page);
}

This results in link-time warning:

    WARNING: "xen_scrub_pages" [yourmodule.ko] undefined!

and thus not allowing the module to run. At the moment I can only see a possible fix
for this by making the following change:

drivers/xen/mem-reservation.c +0 -0
index 3782cf070338..85fecfec50e1 100644
@@ -18,6 +18,7 @@
 
  bool __read_mostly xen_scrub_pages = 

IS_ENABLED(CONFIG_XEN_SCRUB_PAGES_DEFAULT);
 core_param(xen_scrub_pages, xen_scrub_pages, bool, 0);
+EXPORT_SYMBOL(xen_scrub_pages);

but this looks a bit unusual for the kernel?

I am looking for community advice here and help

Thank you,
Oleksandr

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=197ecb3802c04499d8ff4f8cb28f6efa008067db

#1 lore raw
Quoted 41 lines · Oleksandr Andrushchenko

Hello,

I am working on porting an out-of-tree kernel driver to the kernel 5.0 and that driver uses functionality provided by drivers/xen/mem-reservation.c
module.  Since commit [1] it is not possible to build a kernel module which uses mem-reservation API as xen_scrub_pages variable, which is checked in
xenmem_reservation_scrub_page, became a kernel module parameter and is now only
accessible for built-in modules:

static inline void xenmem_reservation_scrub_page(struct page *page) ^^^^^^^^^^^^^
{
    if (xen_scrub_pages)
        ^^^^^^^^^^^^^^^
        clear_highpage(page);
}

This results in link-time warning:

    WARNING: "xen_scrub_pages" [yourmodule.ko] undefined!

and thus not allowing the module to run. At the moment I can only see a possible fix
for this by making the following change:

drivers/xen/mem-reservation.c +1 -0
index 3782cf070338..85fecfec50e1 100644
@@ -18,6 +18,7 @@
 
  bool __read_mostly xen_scrub_pages = 
 IS_ENABLED(CONFIG_XEN_SCRUB_PAGES_DEFAULT);
  core_param(xen_scrub_pages, xen_scrub_pages, bool, 0);
+EXPORT_SYMBOL(xen_scrub_pages);
 

but this looks a bit unusual for the kernel?

Quoted 7 lines

I am looking for community advice here and help

Thank you,
Oleksandr

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=197ecb3802c04499d8ff4f8cb28f6efa008067db

The alternative would be to turn xenmem_reservation_scrub_page into a regular function (not a static inline)?

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
In reply to Oleksandr Andrushchenko
Quoted 41 lines · Oleksandr Andrushchenko

Hello,

I am working on porting an out-of-tree kernel driver to the kernel 5.0 and that driver uses functionality provided by drivers/xen/mem-reservation.c
module.  Since commit [1] it is not possible to build a kernel module which uses mem-reservation API as xen_scrub_pages variable, which is checked in
xenmem_reservation_scrub_page, became a kernel module parameter and is now only
accessible for built-in modules:

static inline void xenmem_reservation_scrub_page(struct page *page) ^^^^^^^^^^^^^
{
    if (xen_scrub_pages)
        ^^^^^^^^^^^^^^^
        clear_highpage(page);
}

This results in link-time warning:

    WARNING: "xen_scrub_pages" [yourmodule.ko] undefined!

and thus not allowing the module to run. At the moment I can only see a possible fix
for this by making the following change:

drivers/xen/mem-reservation.c +1 -0
index 3782cf070338..85fecfec50e1 100644
@@ -18,6 +18,7 @@
 
  bool __read_mostly xen_scrub_pages = 
 IS_ENABLED(CONFIG_XEN_SCRUB_PAGES_DEFAULT);
  core_param(xen_scrub_pages, xen_scrub_pages, bool, 0);
+EXPORT_SYMBOL(xen_scrub_pages);
 

but this looks a bit unusual for the kernel?

Quoted 7 lines

I am looking for community advice here and help

Thank you,
Oleksandr

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=197ecb3802c04499d8ff4f8cb28f6efa008067db

The alternative would be to turn xenmem_reservation_scrub_page into a regular function (not a static inline)?

#4 lore raw
In reply to Stefano Stabellini
Quoted 2 lines · Stefano Stabellini

The alternative would be to turn xenmem_reservation_scrub_page into a regular function (not a static inline)?

All that is a moot point until said currently out of tree module gets submitted for inclusion anyway.

#5 lore raw
Quoted 5 lines · Christoph Hellwig
Quoted 2 lines · Stefano Stabellini

The alternative would be to turn xenmem_reservation_scrub_page into a regular function (not a static inline)?

All that is a moot point until said currently out of tree module gets submitted for inclusion anyway.

Indeed this is a moot point, so I can't argue here. But this is how it is and unfortunately we have to live with those modules and depend on 3rd parties willing or not to disclose their sources to public...
_______________________________________________
Xen-devel mailing list [email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#6 lore raw
In reply to Christoph Hellwig
Quoted 5 lines · Christoph Hellwig
Quoted 2 lines · Stefano Stabellini

The alternative would be to turn xenmem_reservation_scrub_page into a regular function (not a static inline)?

All that is a moot point until said currently out of tree module gets submitted for inclusion anyway.

Indeed this is a moot point, so I can't argue here. But this is how it is and unfortunately we have to live with those modules and depend on 3rd parties willing or not to disclose their sources to public...

#7 lore raw
Quoted 10 lines · Oleksandr Andrushchenko
Quoted 5 lines · Christoph Hellwig
Quoted 2 lines · Stefano Stabellini

The alternative would be to turn xenmem_reservation_scrub_page into a regular function (not a static inline)?

All that is a moot point until said currently out of tree module gets submitted for inclusion anyway.

Indeed this is a moot point, so I can't argue here. But this is how it is and unfortunately we have to live with those modules and depend on 3rd parties willing or not to disclose their sources to public...

The point is that the kernel does generally not export interfaces not used by in-tree modules. So there is no reason to change anything here.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#8 lore raw
In reply to Oleksandr Andrushchenko
Quoted 10 lines · Oleksandr Andrushchenko
Quoted 5 lines · Christoph Hellwig
Quoted 2 lines · Stefano Stabellini

The alternative would be to turn xenmem_reservation_scrub_page into a regular function (not a static inline)?

All that is a moot point until said currently out of tree module gets submitted for inclusion anyway.

Indeed this is a moot point, so I can't argue here. But this is how it is and unfortunately we have to live with those modules and depend on 3rd parties willing or not to disclose their sources to public...

The point is that the kernel does generally not export interfaces not used by in-tree modules. So there is no reason to change anything here.

#9 lore raw
In reply to Stefano Stabellini
Quoted 44 lines · Stefano Stabellini
Quoted 43 lines · Oleksandr Andrushchenko

Hello,

I am working on porting an out-of-tree kernel driver to the kernel 5.0 and that driver uses functionality provided by drivers/xen/mem-reservation.c
module.  Since commit [1] it is not possible to build a kernel module which uses mem-reservation API as xen_scrub_pages variable, which is checked in
xenmem_reservation_scrub_page, became a kernel module parameter and is now only
accessible for built-in modules:

static inline void xenmem_reservation_scrub_page(struct page *page) ^^^^^^^^^^^^^
{
    if (xen_scrub_pages)
        ^^^^^^^^^^^^^^^
        clear_highpage(page);
}

This results in link-time warning:

    WARNING: "xen_scrub_pages" [yourmodule.ko] undefined!

and thus not allowing the module to run. At the moment I can only see a possible fix
for this by making the following change:

drivers/xen/mem-reservation.c +1 -0
index 3782cf070338..85fecfec50e1 100644
@@ -18,6 +18,7 @@
 
   bool __read_mostly xen_scrub_pages =
 IS_ENABLED(CONFIG_XEN_SCRUB_PAGES_DEFAULT);
   core_param(xen_scrub_pages, xen_scrub_pages, bool, 0);
+EXPORT_SYMBOL(xen_scrub_pages);
 

but this looks a bit unusual for the kernel?

I am looking for community advice here and help

Quoted 7 lines
Quoted 5 lines

Thank you,
Oleksandr

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=197ecb3802c04499d8ff4f8cb28f6efa008067db

The alternative would be to turn xenmem_reservation_scrub_page into a regular function (not a static inline)?

Yes, it seems there is no other reasonable solution to this, but a regular function. I'll send a patch for that

Thank you,
Oleksandr
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#10 lore raw
In reply to Stefano Stabellini
Quoted 44 lines · Stefano Stabellini
Quoted 43 lines · Oleksandr Andrushchenko

Hello,

I am working on porting an out-of-tree kernel driver to the kernel 5.0 and that driver uses functionality provided by drivers/xen/mem-reservation.c
module.  Since commit [1] it is not possible to build a kernel module which uses mem-reservation API as xen_scrub_pages variable, which is checked in
xenmem_reservation_scrub_page, became a kernel module parameter and is now only
accessible for built-in modules:

static inline void xenmem_reservation_scrub_page(struct page *page) ^^^^^^^^^^^^^
{
    if (xen_scrub_pages)
        ^^^^^^^^^^^^^^^
        clear_highpage(page);
}

This results in link-time warning:

    WARNING: "xen_scrub_pages" [yourmodule.ko] undefined!

and thus not allowing the module to run. At the moment I can only see a possible fix
for this by making the following change:

drivers/xen/mem-reservation.c +1 -0
index 3782cf070338..85fecfec50e1 100644
@@ -18,6 +18,7 @@
 
   bool __read_mostly xen_scrub_pages =
 IS_ENABLED(CONFIG_XEN_SCRUB_PAGES_DEFAULT);
   core_param(xen_scrub_pages, xen_scrub_pages, bool, 0);
+EXPORT_SYMBOL(xen_scrub_pages);
 

but this looks a bit unusual for the kernel?

I am looking for community advice here and help

Quoted 7 lines
Quoted 5 lines

Thank you,
Oleksandr

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=197ecb3802c04499d8ff4f8cb28f6efa008067db

The alternative would be to turn xenmem_reservation_scrub_page into a regular function (not a static inline)?

Yes, it seems there is no other reasonable solution to this, but a regular function. I'll send a patch for that

Thank you,
Oleksandr

maintainer
#11 lore raw
Quoted 48 lines · Oleksandr Andrushchenko
Quoted 47 lines · Stefano Stabellini
Quoted 46 lines · Oleksandr Andrushchenko

Hello,

I am working on porting an out-of-tree kernel driver to the kernel 5.0 and that driver uses functionality provided by drivers/xen/mem-reservation.c
module.  Since commit [1] it is not possible to build a kernel module which uses mem-reservation API as xen_scrub_pages variable, which is checked in
xenmem_reservation_scrub_page, became a kernel module parameter and is now only
accessible for built-in modules:

static inline void xenmem_reservation_scrub_page(struct page *page) ^^^^^^^^^^^^^
{
    if (xen_scrub_pages)
        ^^^^^^^^^^^^^^^
        clear_highpage(page);
}

This results in link-time warning:

    WARNING: "xen_scrub_pages" [yourmodule.ko] undefined!

and thus not allowing the module to run. At the moment I can only see a possible fix
for this by making the following change:

drivers/xen/mem-reservation.c +1 -0
index 3782cf070338..85fecfec50e1 100644
@@ -18,6 +18,7 @@
 
   bool __read_mostly xen_scrub_pages =
 IS_ENABLED(CONFIG_XEN_SCRUB_PAGES_DEFAULT);
   core_param(xen_scrub_pages, xen_scrub_pages, bool, 0);
+EXPORT_SYMBOL(xen_scrub_pages);
 

but this looks a bit unusual for the kernel?

I am looking for community advice here and help

Thank you,
Oleksandr

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=197ecb3802c04499d8ff4f8cb28f6efa008067db

The alternative would be to turn xenmem_reservation_scrub_page into a regular function (not a static inline)?

Yes, it seems there is no other reasonable solution to this, but a regular function. I'll send a patch for that

What would you gain? This function would need to be exported.

So its either the variable or the function.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

maintainer
#12 lore raw
In reply to Oleksandr Andrushchenko
Quoted 48 lines · Oleksandr Andrushchenko
Quoted 47 lines · Stefano Stabellini
Quoted 46 lines · Oleksandr Andrushchenko

Hello,

I am working on porting an out-of-tree kernel driver to the kernel 5.0 and that driver uses functionality provided by drivers/xen/mem-reservation.c
module.  Since commit [1] it is not possible to build a kernel module which uses mem-reservation API as xen_scrub_pages variable, which is checked in
xenmem_reservation_scrub_page, became a kernel module parameter and is now only
accessible for built-in modules:

static inline void xenmem_reservation_scrub_page(struct page *page) ^^^^^^^^^^^^^
{
    if (xen_scrub_pages)
        ^^^^^^^^^^^^^^^
        clear_highpage(page);
}

This results in link-time warning:

    WARNING: "xen_scrub_pages" [yourmodule.ko] undefined!

and thus not allowing the module to run. At the moment I can only see a possible fix
for this by making the following change:

drivers/xen/mem-reservation.c +1 -0
index 3782cf070338..85fecfec50e1 100644
@@ -18,6 +18,7 @@
 
   bool __read_mostly xen_scrub_pages =
 IS_ENABLED(CONFIG_XEN_SCRUB_PAGES_DEFAULT);
   core_param(xen_scrub_pages, xen_scrub_pages, bool, 0);
+EXPORT_SYMBOL(xen_scrub_pages);
 

but this looks a bit unusual for the kernel?

I am looking for community advice here and help

Thank you,
Oleksandr

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=197ecb3802c04499d8ff4f8cb28f6efa008067db

The alternative would be to turn xenmem_reservation_scrub_page into a regular function (not a static inline)?

Yes, it seems there is no other reasonable solution to this, but a regular function. I'll send a patch for that

What would you gain? This function would need to be exported.

So its either the variable or the function.

Juergen

#13 lore raw
Quoted 49 lines · Juergen Gross
Quoted 48 lines · Oleksandr Andrushchenko
Quoted 47 lines · Stefano Stabellini
Quoted 46 lines · Oleksandr Andrushchenko

Hello,

I am working on porting an out-of-tree kernel driver to the kernel 5.0 and that driver uses functionality provided by drivers/xen/mem-reservation.c
module.  Since commit [1] it is not possible to build a kernel module which uses mem-reservation API as xen_scrub_pages variable, which is checked in
xenmem_reservation_scrub_page, became a kernel module parameter and is now only
accessible for built-in modules:

static inline void xenmem_reservation_scrub_page(struct page *page) ^^^^^^^^^^^^^

{
       if (xen_scrub_pages)
           ^^^^^^^^^^^^^^^
           clear_highpage(page);
}

This results in link-time warning:

    WARNING: "xen_scrub_pages" [yourmodule.ko] undefined!

and thus not allowing the module to run. At the moment I can only see a possible fix
for this by making the following change:

drivers/xen/mem-reservation.c +1 -0
index 3782cf070338..85fecfec50e1 100644
@@ -18,6 +18,7 @@
 
    bool __read_mostly xen_scrub_pages =
 IS_ENABLED(CONFIG_XEN_SCRUB_PAGES_DEFAULT);
    core_param(xen_scrub_pages, xen_scrub_pages, bool, 0);
+EXPORT_SYMBOL(xen_scrub_pages);
 

but this looks a bit unusual for the kernel?

I am looking for community advice here and help

Thank you,
Oleksandr

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=197ecb3802c04499d8ff4f8cb28f6efa008067db

The alternative would be to turn xenmem_reservation_scrub_page into a regular function (not a static inline)?

Yes, it seems there is no other reasonable solution to this, but a regular function. I'll send a patch for that

What would you gain? This function would need to be exported.

Yes, this is true, the function should be exported then

Quoted 1 line

So its either the variable or the function.

I am a bit confused with this because I'll have to export module parameter in this case, e.g.

core_param(xen_scrub_pages, xen_scrub_pages, bool, 0); EXPORT_SYMBOL(xen_scrub_pages);

which looks a bit unusual to me

Quoted 2 lines

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#14 lore raw
In reply to Juergen Gross
Quoted 49 lines · Juergen Gross
Quoted 48 lines · Oleksandr Andrushchenko
Quoted 47 lines · Stefano Stabellini
Quoted 46 lines · Oleksandr Andrushchenko

Hello,

I am working on porting an out-of-tree kernel driver to the kernel 5.0 and that driver uses functionality provided by drivers/xen/mem-reservation.c
module.  Since commit [1] it is not possible to build a kernel module which uses mem-reservation API as xen_scrub_pages variable, which is checked in
xenmem_reservation_scrub_page, became a kernel module parameter and is now only
accessible for built-in modules:

static inline void xenmem_reservation_scrub_page(struct page *page) ^^^^^^^^^^^^^

{
       if (xen_scrub_pages)
           ^^^^^^^^^^^^^^^
           clear_highpage(page);
}

This results in link-time warning:

    WARNING: "xen_scrub_pages" [yourmodule.ko] undefined!

and thus not allowing the module to run. At the moment I can only see a possible fix
for this by making the following change:

drivers/xen/mem-reservation.c +1 -0
index 3782cf070338..85fecfec50e1 100644
@@ -18,6 +18,7 @@
 
    bool __read_mostly xen_scrub_pages =
 IS_ENABLED(CONFIG_XEN_SCRUB_PAGES_DEFAULT);
    core_param(xen_scrub_pages, xen_scrub_pages, bool, 0);
+EXPORT_SYMBOL(xen_scrub_pages);
 

but this looks a bit unusual for the kernel?

I am looking for community advice here and help

Thank you,
Oleksandr

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=197ecb3802c04499d8ff4f8cb28f6efa008067db

The alternative would be to turn xenmem_reservation_scrub_page into a regular function (not a static inline)?

Yes, it seems there is no other reasonable solution to this, but a regular function. I'll send a patch for that

What would you gain? This function would need to be exported.

Yes, this is true, the function should be exported then

Quoted 1 line

So its either the variable or the function.

I am a bit confused with this because I'll have to export module parameter in this case, e.g.

core_param(xen_scrub_pages, xen_scrub_pages, bool, 0); EXPORT_SYMBOL(xen_scrub_pages);

which looks a bit unusual to me

Quoted 2 lines

Juergen