From c68fd73909c5522f3d58a8267c4a0e50b3d88a5a Mon Sep 17 00:00:00 2001 From: Laura Abbott Date: Mon, 21 Oct 2019 15:27:30 -0400 Subject: [PATCH] Add support for building ipaclones While Fedora doesn't officially support kpatch, there's work being done to enable kpatch elsewhere. Add the packaging work but don't actually build anything. --- kernel.spec | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/kernel.spec b/kernel.spec index 47fdd82f2..9ad95794c 100644 --- a/kernel.spec +++ b/kernel.spec @@ -133,6 +133,11 @@ Summary: The Linux kernel # gcov support %define with_gcov %{?_with_gcov: 1} %{?!_with_gcov: 0} +# +# ipa_clone support +%define with_ipaclones %{?_without_ipaclones: 0} %{?!_without_ipaclones: 1} + + # Set debugbuildsenabled to 1 for production (build separate debug kernels) # and 0 for rawhide (all kernels are debug kernels). # See also 'make debug' and 'make release'. @@ -144,6 +149,8 @@ Summary: The Linux kernel %define with_cross_headers 0 # no selftests for now %define with_selftests 0 +# no ipa_clone for now +%define with_ipaclones 0 %endif %if %{with_verbose} @@ -189,6 +196,16 @@ Summary: The Linux kernel %define with_kabidwchk 0 %endif +# kpatch_kcflags are extra compiler flags applied to base kernel +# -fdump-ipa-clones is enabled only for base kernels on selected arches +%if %{with_ipaclones} +%ifarch x86_64 ppc64le +%define kpatch_kcflags -fdump-ipa-clones +%else +%define with_ipaclones 0 +%endif +%endif + %define make_target bzImage %define image_install_path boot @@ -750,6 +767,18 @@ This package provides kernel headers and makefiles sufficient to build modules\ against the %{?2:%{2} }kernel package.\ %{nil} +# +# kernel--ipaclones-internal package +# +%define kernel_ipaclones_package() \ +%package %{?1:%{1}-}ipaclones-internal\ +Summary: *.ipa-clones files generated by -fdump-ipa-clones for kernel%{?1:-%{1}}\ +Group: System Environment/Kernel\ +AutoReqProv: no\ +%description %{?1:%{1}-}ipaclones-internal\ +This package provides *.ipa-clones files.\ +%{nil} + # # This macro creates a kernel--modules-extra package. # %%kernel_modules_extra_package @@ -858,6 +887,10 @@ Linux operating system. The kernel handles the basic functions of the operating system: memory allocation, process allocation, device input and output, etc. +%if %{with_ipaclones} +%kernel_ipaclones_package +%endif + %prep # do a few sanity-checks for --with *only builds %if %{with_baseonly} @@ -1574,6 +1607,18 @@ BuildKernel() { # build a BLS config for this kernel %{SOURCE43} "$KernelVer" "$RPM_BUILD_ROOT" "%{?variant}" + +%if %{with_ipaclones} + MAXPROCS=$(echo %{?_smp_mflags} | sed -n 's/-j\s*\([0-9]\+\)/\1/p') + if [ -z "$MAXPROCS" ]; then + MAXPROCS=1 + fi + if [ "$Flavour" == "" ]; then + mkdir -p $RPM_BUILD_ROOT/$DevelDir-ipaclones + find . -name '*.ipa-clones' | xargs -i{} -r -n 1 -P $MAXPROCS install -m 644 -D "{}" "$RPM_BUILD_ROOT/$DevelDir-ipaclones/{}" + fi +%endif + } ### @@ -1985,6 +2030,19 @@ fi %kernel_variant_files %{_use_vdso} %{with_debug} debug %kernel_variant_files %{use_vdso} %{with_pae} lpae +%define kernel_variant_ipaclones(k:) \ +%if %{1}\ +%if %{with_ipaclones}\ +%{expand:%%files %{?2:%{2}-}ipaclones-internal}\ +%defattr(-,root,root)\ +%defverify(not mtime)\ +/usr/src/kernels/%{KVERREL}%{?2:+%{2}}-ipaclones\ +%endif\ +%endif\ +%{nil} + +%kernel_variant_ipaclones %{with_up} + # plz don't put in a version string unless you're going to tag # and build. #