Skip to content

Commit d02727d

Browse files
palash-gandhilyriclake
authored andcommitted
Extract PKG_ABI from mutated string
1 parent 9956ef1 commit d02727d

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

debian/rules.d/0-common-vars.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ kmake = make ARCH=$(build_arch) \
206206
KERNELRELEASE=$(abi_release)-$* \
207207
CONFIG_DEBUG_SECTION_MISMATCH=y \
208208
KBUILD_BUILD_VERSION="$(uploadnum)" \
209-
CFLAGS_MODULE="-DPKG_ABI=$(abinum)" \
209+
CFLAGS_MODULE='-DPKG_ABI=\"$(abinum)\"' \
210210
PYTHON=$(PYTHON)
211211
ifneq ($(LOCAL_ENV_CC),)
212212
kmake += CC="$(LOCAL_ENV_CC)" DISTCC_HOSTS="$(LOCAL_ENV_DISTCC_HOSTS)"

include/asm-generic/mshyperv.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef _ASM_GENERIC_MSHYPERV_H
1818
#define _ASM_GENERIC_MSHYPERV_H
1919

20+
#include <linux/kernel.h>
2021
#include <linux/types.h>
2122
#include <linux/atomic.h>
2223
#include <linux/bitops.h>
@@ -156,7 +157,7 @@ static inline u64 hv_do_rep_hypercall(u16 code, u16 rep_count, u16 varhead_size,
156157
* Preserve the ability to 'make deb-pkg' since PKG_ABI is provided
157158
* by the Ubuntu build rules.
158159
*/
159-
#define PKG_ABI 0
160+
#define PKG_ABI "0"
160161
#endif
161162

162163
/* Generate the guest OS identifier as described in the Hyper-V TLFS */
@@ -166,7 +167,15 @@ static inline u64 hv_generate_guest_id(u64 kernel_version)
166167

167168
guest_id = (((u64)HV_LINUX_VENDOR_ID) << 48);
168169
guest_id |= (kernel_version << 16);
169-
guest_id |= PKG_ABI;
170+
/*
171+
* Delphix mutates the ABI number by appending a date and the commit hash. Strip it.
172+
*/
173+
char *token;
174+
char *pkg_abi_str = PKG_ABI;
175+
token = strsep(&pkg_abi_str, "-");
176+
unsigned long abi_number = simple_strtoul(token, NULL, 10);
177+
guest_id |= (abi_number << 8);
178+
170179

171180
return guest_id;
172181
}

0 commit comments

Comments
 (0)