Skip to content

Commit

Permalink
kpatch-build: handle paravirt absence in Linux v6.8+
Browse files Browse the repository at this point in the history
Adds linux kernel version checks to all functions pertaining to struct
paravirt_patch_site as it is removed in Linux v6.8+

Fixes: #1380

Signed-off-by: Ryan Sullivan <[email protected]>
  • Loading branch information
ryanbsull committed May 2, 2024
1 parent ef68b4e commit 11d822a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion kpatch-build/create-diff-object.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <argp.h>
#include <libgen.h>
#include <unistd.h>
#include <sys/utsname.h>

#include "list.h"
#include "lookup.h"
Expand Down Expand Up @@ -2100,10 +2101,17 @@ static int printk_index_group_size(struct kpatch_elf *kelf, int offset)

static int parainstructions_group_size(struct kpatch_elf *kelf, int offset)
{
struct utsname name;
static int size = 0;
char *str;
int major, minor;

if (!size) {
if (uname(&name) < 0) {
ERROR("uname error");
}
major = atoi(&name.release[0]);
minor = atoi(&name.release[2]);
if (!size && major <= 6 && minor <= 8) {
str = getenv("PARA_STRUCT_SIZE");
if (!str)
ERROR("PARA_STRUCT_SIZE not set");
Expand Down
4 changes: 2 additions & 2 deletions kpatch-build/kpatch-build
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ find_special_section_data() {
"x86_64")
check[a]=true # alt_instr
kernel_version_gte 5.10.0 && check[s]=true # static_call_site
[[ -n "$CONFIG_PARAVIRT" ]] && check[p]=true # paravirt_patch_site
[[ -n "$CONFIG_PARAVIRT" ]] && ! kernel_version_gte 6.8.0 && check[p]=true # paravirt_patch_site
;;
"ppc64le")
check[f]=true # fixup_entry
Expand Down Expand Up @@ -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"
[[ ${check[s]} && -z "$STATIC_CALL_STRUCT_SIZE" ]] && die "can't find special struct static_call_site size"

save_env
Expand Down

0 comments on commit 11d822a

Please sign in to comment.