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

Fix Linux 5.18 #18

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Conversation

s9105947
Copy link

fixes two deprecated calls into the kernel to their updated versions.

Breaks compatibility to kernels with CONFIG_THREAD_INFO_IN_TASK disabled.
(This is checked and a CPP #error is created if this is the case.)

Previous kernel version provided the current CPU inside of task_struct
directly.
This is not the case anymore, and the current CPU has to be extracted by
using information from thread_info, which is only provided if
CONFIG_THREAD_INFO_IN_TASK is enabled in the kernel config.

Builds without CONFIG_THREAD_INFO_IN_TASK will be aborted.

Note: I am not confident that this is the complete and correct solution,
however the most practical one. (I.e. feel free to overrule it down the
road)
The previously used functions get_online_cpus() and put_online_cpus()
have been removed in 8c854303ce0e38e5bbedd725ff39da7e235865d8.
As both functions where pure aliases they are replaced with the calls
they were previously pointing to, cpus_read_lock() and cpus_read_unlock().
The driver module depends on the definition module.
dkms offer the variable BUILD_DEPENDS for that, even if it notes that it
is not necessarily enforced this should be used to avoid build failures.
In Linux kernel commit 39808e451fdf ("kbuild: do not read
$(KBUILD_EXTMOD)/Module.symvers") the in x86_adapt used way of communicating
dependencies for symbols of other modules has been updated.

This commit applies this new method to the x86_adapt_driver module by
setting the variable KBUILD_EXTRA_SYMBOLS in the make file.
The previous version used shell globbing to find files, which also
returned directories which failed in the subsequent call to sed.

The fix is to search for files only using `find DIR -type f` and apply
sed only to these found files.
Copy link
Member

@rschoene rschoene left a comment

Choose a reason for hiding this comment

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

Could you just remove the function get_current_task_cpu() and use task_cpu(current); instead?

@@ -1551,11 +1551,11 @@ static int __init x86_adapt_init(void)
{
int i,err;

get_online_cpus();
cpus_read_lock();
Copy link
Member

Choose a reason for hiding this comment

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

is this avail. for older Linuxes? Since when? Also check unlock

Copy link
Author

Choose a reason for hiding this comment

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

Introduced in 8f553c498e17, first released in Linux 4.13.

@s9105947
Copy link
Author

Could you just remove the function get_current_task_cpu() and use task_cpu(current); instead?

In theory, yes.
In practice I am not confident that I will understand/test possible side effects in a timely manner.

Furthermore, as far as I understand the implementation, this still requires CONFIG_THREAD_INFO_IN_TASK to be enabled?

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.

2 participants