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

kpatch-build: handle paravirt absence in Linux v6.8+ #1392

Merged
merged 1 commit into from
May 15, 2024

Conversation

ryanbsull
Copy link
Contributor

Adds linux kernel version checks to all functions pertaining to struct paravirt_patch_site as it is removed in Linux v6.8+

Fixes: #1380

@@ -438,7 +438,7 @@ find_special_section_data() {
[[ ${check[i]} && -z "$PRINTK_INDEX_STRUCT_SIZE" ]] && die "can't find special struct pi_entry size"
[[ ${check[j]} && -z "$JUMP_STRUCT_SIZE" ]] && die "can't find special struct jump_entry size"
[[ ${check[o]} && -z "$ORC_STRUCT_SIZE" ]] && die "can't find special struct orc_entry size"
[[ ${check[p]} && -z "$PARA_STRUCT_SIZE" ]] && die "can't find special struct paravirt_patch_site size"
[[ ${check[p]} && -z "$PARA_STRUCT_SIZE" ]] && ! kernel_version_gte 6.8.0 && die "can't find special struct paravirt_patch_site size"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this second kernel_version_gte check is redundant as ${check[p]} should only be set if it's >= 6.8.0, right?


if (!size) {
if (uname(&name) < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately create-diff-object can't assume that it's building for the currently running kernel. (Think about how it operates when kpatch-build is passed the -r, -s, -v options.)

@ryanbsull ryanbsull force-pushed the x86-paravirt-fix branch from 11d822a to 4329cf5 Compare May 3, 2024 17:42
if (omit_str)
omit = atoi(omit_str);

if (!size && !omit) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this work out if you omitted this "omit" code and left create-diff-object untouched? If I read the code correctly, the group_size callbacks are only executed when their sections are encountered:

kpatch_process_special_sections()
  	for (special = special_sections; special->name; special++) {
		...
		sec = find_section_by_name(&kelf->sections, special->name);
		if (!sec || !sec->rela)
			continue;

		kpatch_regenerate_special_section(kelf, lookup, special, sec->rela);

			group_size = special->group_size(kelf, src_offset);

So I'd expect create-diff-object would only care about PARA_STRUCT_SIZE when the corresponding .parainstructions section is present. (Which I believe torvalds/linux@f7af6977 removes.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are correct, my bad do not need to even pass omit

@ryanbsull ryanbsull force-pushed the x86-paravirt-fix branch 2 times, most recently from 6fe14ce to 18a796f Compare May 3, 2024 19:46
Upstream kernel commit f7af6977621a ("x86/paravirt: Remove no longer
needed paravirt patching code") v6.8+ removed the .parainstructions
section and its paravirt_patch_site struct. Therefore this checks the
kernel version and does not export the struct size if the kernel
version is >= v6.8.0, avoiding the code path for it in
create-diff-object.c entirely.

Fixes: dynup#1380

Signed-off-by: Ryan Sullivan <[email protected]>
@ryanbsull ryanbsull force-pushed the x86-paravirt-fix branch from 18a796f to 36ba2b8 Compare May 3, 2024 20:11
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.

x86 paravirt code uses alternatives v6.8+
2 participants