Trying to compile ACS Override Patch and got stuck (Fedora 33)

Starting with the system I am working on:

Ryzen 9 3900x
MSI Mag b550 tomahawk
Vega 56 (host)
Gtx 1080ti (guest)
Fedora workstation 33

I have mainly been following two guides on installing the ACS patch on fedora.


https://wiki.myhypervisor.ca/books/linux/page/fedora-build-acs-override-patch-kernel
Both are similar but do have a few differences. I’m sure there are multiple ways to go about this, so it doesn’t surprise me that they do differ.

I’ve basically been copying the commands from these guides into my own bash script so that I have a history of everything I run, and can make comments to myself and whatnot.

Starting with a few questions that I have, I noticed that both guides download different ACS patches. If I remember correctly the github guide uses a patch for Fedora 5.6.x. I want to use a newer kernel (5.8 or 5.9) so I don’t think I can use that patch. The wiki.myhyperviser guide downloads a different patch and I am not sure if it will work for a newer kernel. And then there is the arch linux hosted acs patch which is what most of my googling comes to.
(https://aur.archlinux.org/pkgbase/linux-vfio/
I just want clarification on which acs patch I should use from someone that knows more than me.

My next question was about adding the build ID lines to the top of the kernel.spec file. Both guides do this and have you add the same lines of code but they don’t specify where beyond ‘near the top’. Currently, I have been inserting the build ID lines to line 31 of the kernel.spec file.

Lastly, I am stuck on the step where you compile the kernel. I’ve tried both rpmbuild -bb kernel.spec and rpmbuild -bs ~/rpmbuild/SPECS/kernel.spec from the two guides but neither worked. This is the error that I am receiving:

warning: Macro expanded in comment on line 758: %{rpmversion}-%{distro_build}.tar.bz2

warning: Macro expanded in comment on line 759: %{rpmversion}-%{distro_build}.tar.bz2

warning: Macro expanded in comment on line 767: %{rpmversion}-redhat.patch

error: %changelog not in descending chronological order
setting SOURCE_DATE_EPOCH=1604314239
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.tQDXsW

  • umask 022
  • cd /home/myname/rpmbuild/BUILD
    ERROR: Patch add-acs-override.patch listed in specfile but is missing
    error: Bad exit status from /var/tmp/rpm-tmp.tQDXsW (%prep)

RPM build errors:
Macro expanded in comment on line 758: %{rpmversion}-%{distro_build}.tar.bz2

Macro expanded in comment on line 759: %{rpmversion}-%{distro_build}.tar.bz2

Macro expanded in comment on line 767: %{rpmversion}-redhat.patch

%changelog not in descending chronological order
Bad exit status from /var/tmp/rpm-tmp.tQDXsW (%prep)

I’ve tried to figure out the rpm build errors but haven’t had any success on my own.

Here is the script that I have been using. There are a few duplicate commands (mostly downloading different acs patches) as I tried to see what worked best.

acs-script

#!/bin/bash

#Check for updates
sudo dnf check-update
sudo dnf upgrade

#1 Add RPM Fusion
sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-(rpm -E %fedora).noarch.rpm https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-(rpm -E %fedora).noarch.rpm

#2 Add dependencies to build your own kernel
sudo dnf install fedpkg fedora-packager rpmdevtools ncurses-devel pesign rpmdevtools

#3 Set home build directory
rpmdev-setuptree

#4 Install the kernel source and finish installing dependencies
cd ~/rpmbuild/SOURCES
#koji download-build --arch=src kernel-4.18.5-200.fc28
#rpm -Uvh kernel-4.18.5-200.fc28.src.rpm
#changed downloaded kernel from 4.18.4-200 to 5.8.18-300 since I wanted a newer kernel than 4.18
koji download-build --arch=src kernel-5.8.18-300.fc33
rpm -Uvh kernel-5.8.18-300.fc33.src.rpm
cd ~/rpmbuild/SPECS/
sudo dnf builddep kernel.spec

#5 Add the ACS patch (link) as ~/rpmbuild/SOURCES/add-acs-override.patch
#curl -o ~/rpmbuild/SOURCES/add-acs-override.patch https://raw.githubusercontent.com/Somersall-Natalie/fedora-acs-override/master/acs/add-acs-override.patch
#Here I strayed from the guides and downloaded the arch linux patch, and put it into the folder ~/acs-patch-files so that I could keep track of it easier
mkdir ~/acs-patch-files
cd ~/acs-patch-files
git clone https://aur.archlinux.org/linux-vfio.git
cp ~/acs-patch-files/linux-vfio/add-acs-overrides.patch ~/rpmbuild/SOURCES
#Then I copied the arch linux patch and put into the same folder ~/rpmbuild/SOURCES that the other guides do.

#6 Edit ~/rpmbuild/SPECS/kernel.spec to set the build ID and add the patch. Since each release of the spec file could change, it’s not much help giving line numbers, but both of these should be near the top of the file.
#To set the build id, add the two lines near the top of the spec file with the other release information.
#https://stackoverflow.com/questions/487894/how-can-i-add-a-line-to-a-file-in-a-shell-script
#This edits the kernel.spec file and inserts code starting at line 31, CONFIRMED got the lines to insert and save correctly!
cd ~/rpmbuild/SPECS
ls
sed -i ‘31 i # Set buildid’ ./kernel.spec
sed -i ‘32 i %define buildid .acs’ ./kernel.spec
sed -i ‘33 i # ACS override patch’ ./kernel.spec
sed -i ‘34 i Patch1000: add-acs-override.patch’ ./kernel.spec
#This is the part of my script that inserts the build ID into the kernel.spec file

#This overrights the old /rpmbuild/SPECS/add-acs-override.patch, FIXED ERROR MESSAGES, WILL KEEP
#cd ~/rpmbuild/SOURCES/
#wget https://git.myhypervisor.ca/dave/fedora-acs-override/raw/master/acs/add-acs-override.patch
#Me trying other acs patch files ^^

#7 Compile! This takes a long time.
rpmbuild -bb kernel.spec
#^^^This did not seem to work well^^^^^

#7 Alternate
#rpmbuild -bs ~/rpmbuild/SPECS/kernel.spec
#This also doesn’t seem to work ^^^

#######################################################

Have not gotten past this point

#######################################################

#8 (ACS only) - Install the new packages!
#cd ~/rpmbuild/RPMS/x86_64
#sudo dnf update *.rpm

#9 update and reboot
#sudo dnf clean all
#sudo dnf update -y
#sudo reboot

Somewhat related, what is the preferred method to post your code here? I was doing blockquotes but would prefer to have it collapsable as well. I’ll also upload a copy of my script if you’d prefer to look at it that way.fedora-acs-patch-nov102020.sh.txt (3.1 KB)
Thank you!

If you click the gear, then select hide details, that will allow collapsed text.
Like this:

[details="Summary"]
<code block here>
[/details]
Summary
code block here

That seems to be your problem. Have you made sure that the patch is in the right directory, named the right thing, and that the build script has permissions to it?


That was exactly what I was looking for! Thank you.

Good catch. I was calling for add-acs-override.patch but my file name was add-acs-overrides.patch.

I think I made some more progress regarding these errors:

warning: Macro expanded in comment on line 758: %{rpmversion}-%{distro_build}.tar.bz2

warning: Macro expanded in comment on line 759: %{rpmversion}-%{distro_build}.tar.bz2

warning: Macro expanded in comment on line 767: %{rpmversion}-redhat.patch

I went into ~/rpmbuild/SPECS/kernel.spec and went to those lines 758,759, and 767 and that is definitely the file it was referring to.

Here is what those lines say:
758: # Source300: kernel-abi-whitelists-%{rpmversion}-%{distro_build}.tar.bz2

759: # Source301: kernel-kabi-dw-%{rpmversion}-%{distro_build}.tar.bz2

767: # Patch1: patch-%{rpmversion}-redhat.patch

To be honest I don’t really what this error means. Should I uncomment those lines and run again?

Well uncommenting those lines and rerunning the rpmbuild command predictably ends up with this:

RPM build errors:

%changelog not in descending chronological order

Bad file: /home/dexterbarney/rpmbuild/SOURCES/patch-5.8.18-redhat.patch: No such file or directory

Bad file: /home/dexterbarney/rpmbuild/SOURCES/kernel-kabi-dw-5.8.18-%{distro_build}.tar.bz2: No such file or directory

Bad file: /home/dexterbarney/rpmbuild/SOURCES/kernel-abi-whitelists-5.8.18-%{distro_build}.tar.bz2: No such file or directory

I don’t know anything about these extra files/patches so I’m going to recomment them and ignore the warning: Macro expanded in comment warnings.

What about the error: %changelog not in descending chronological order. Does anyone know what this means?

Those are just warnings and shouldn’t be failing your build. Does the build produce the rpms you’re hoping for? A glance at the docs you linked suggest the rpms are in ~/rpmbuild/RPMS/x86_64.

I’m not an RPM expert but if I had to make an educated guess it is just telling you that a macro expanded in code that was commented out and it’s probably producing a warning just in case the author commented some code out by mistake. My advice would be to leave them commented out and ignore them…or if they really bother you, just delete the offending comments since comments have no effect on the actual build.

EDIT:

To be clear, I’m talking about the warnings in your prior comment. For example:

warning: Macro expanded in comment on line 758: %{rpmversion}-%{distro_build}.tar.bz2

Those are not errors. It looks like you then uncommented the lines with warnings and then got some errors; comment them back out and ignore the warnings.

1 Like

I am totally in agreement with you. I spent some more time working on the acs patch this evening and was able to get it to work, I left those lines commented out and it worked fine.
I found another writeup online and used the rebuild command they used and then the kernel actually started compiling.
rpmbuild -bb --without debug --target=x86_64 kernel.spec
I did have an issue where the new kernel didn’t install because it was being recognized as the same version that was already installed, (to be fair it was the same version it just had the acs patch added).
I changed my script to download kernel-5.9.8-200.fc33 and that installed no problem.

In case anyone else gets stuck trying to install the acs patch on fedora 33 here is a copy of the script I used.

acs-override-script-fedora33

#!/bin/bash

#Check for updates
sudo dnf check-update
sudo dnf upgrade

#install ‘mockbuild’ user
sudo yum install mock
sudo useradd -s /sbin/nologin mockbuild

#1 Add RPM Fusion
sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-(rpm -E %fedora).noarch.rpm https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-(rpm -E %fedora).noarch.rpm

#2 Add dependencies to build your own kernel
sudo dnf install fedpkg fedora-packager rpmdevtools ncurses-devel pesign

#3 Set home build directory
rpmdev-setuptree

#4 Install the kernel source and finish installing dependencies
cd ~/rpmbuild/SOURCES
koji download-build --arch=src kernel-5.9.8-200.fc33
rpm -Uvh kernel-5.9.8-200.fc33.src.rpm
cd ~/rpmbuild/SPECS/
sudo dnf builddep kernel.spec

#5 Add the ACS patch (link) as ~/rpmbuild/SOURCES/add-acs-override.patch
mkdir ~/acs-patch-files
cd ~/acs-patch-files
git clone https://aur.archlinux.org/linux-vfio.git
cp ~/acs-patch-files/linux-vfio/add-acs-overrides.patch ~/rpmbuild/SOURCES

#6 Edit ~/rpmbuild/SPECS/kernel.spec to set the build ID and add the patch. Since each release of the spec file could change, it’s not much help giving line numbers, but both of these should be near the top of the file.
cd ~/rpmbuild/SPECS
ls
sed -i ‘31 i # Set buildid’ ./kernel.spec
sed -i ‘32 i %define buildid .acs’ ./kernel.spec
sed -i ‘33 i # ACS overrides patch’ ./kernel.spec
sed -i ‘34 i Patch1000: add-acs-overrides.patch’ ./kernel.spec
#This is the part of my script that inserts the build ID into the kernel.spec file

#7 Compile the kernel! This can take a while.
cd ~/rpmbuilds/SPECS
ls
rpmbuild -bb --without debug --target=x86_64 kernel.spec

#8 install the kernel
cd ~/rpmbuild/RPMS/x86_64
sudo dnf update *.rpm

#9 Update Grub Config
sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

#10 update and reboot
sudo dnf clean all
sudo dnf update -y
sudo reboot

1 Like

If you are familiar using docker you can use my image to build Fedora ACS kernel rpms:


https://hub.docker.com/repository/docker/stefanlehmann/acs_fedora

Kind of familiar with docker but not really. I have an unRAID server setup and use docker containers with the community applications plugin, but haven’t gone beyond that. This looks pretty neat, I’ll have to play around with it.