Re: [PATCH net-next v5 1/5] rust: core abstractions for network PHY drivers
From: Benno Lossin <hidden>
Date: 2023-10-21 13:06:15
Also in:
rust-for-linux
On 21.10.23 15:00, FUJITA Tomonori wrote:
On Sat, 21 Oct 2023 12:50:10 +0000 Benno Lossin [off-list ref] wrote:quoted
quoted
quoted
quoted
quoted
I think this is very weird, do you have any idea why this could happen?DriverVtable is created on kernel stack, I guess.But how does that invalidate the function pointers?Not only funciton pointers. You can't store something on stack for later use.It is not stored on the stack, it is only created on the stack and moved to a global static later on. The `module!` macro creates a `static mut __MOD: Option<Module>` where the module data is stored in.I know. The problem is that we call phy_drivers_register() with DriverVTable on stack. Then it was moved.
I see, what exactly is the problem with that? In other words: why does PHYLIB need `phy_driver` to stay at the same address? This is an important requirement in Rust. Rust can ensure that types are not moved by means of pinning them. In this case, Wedson's patch below should fix the issue completely. But we should also fix this in the abstractions, the `DriverVTable` type should only be constructible in a pinned state. For this purpose we have the `pin-init` API [2]. Are there any other things in PHY that must not change address? [2]: https://rust-for-linux.github.io/docs/v6.6-rc2/kernel/init/index.html -- Cheers, Benno
quoted
It seems that constructing the driver table not at that location is somehow interfering with something? Wedson has a patch [1] to create in-place initialized modules, but it probably is not completely finished, as he has not yet begun to post it to the list. But I am sure that it is mature enough for you to test this hypothesis. [1]: https://github.com/wedsonaf/linux/commit/484ec70025ff9887d9ca228ec631264039cee35