You are not logged in.

#1 2021-11-17 11:45:58

Simulacrum
Member
Registered: 2017-02-23
Posts: 28

Configuration for old Kernels

Hey guys,

I'm currently trying to get an older kernel to run. I successfully downloaded the source (5.7 and even older versions) and followed the instructions of the arch-wiki. When it comes to

make modules

it fails with the following error (in the end):

make[1]: *** [scripts/Makefile.build:500: drivers/net] Error 2
make: *** [Makefile:1691: drivers] Error 2

The

make

command seems to finish its task successfully.
As I'm quite unexperienced with kernel related stuff, I don't know where to start searching for a fix. Any suggestions would be great!

Thanks in advance.


P.S.: I hope this is the right sub.

Offline

#2 2021-11-17 11:52:09

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: Configuration for old Kernels

Do you actually need to recompile or will the copy in the archive still just work?
https://archive.archlinux.org/packages/l/linux/


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2021-11-17 12:48:36

Simulacrum
Member
Registered: 2017-02-23
Posts: 28

Re: Configuration for old Kernels

i actually have to recompile, as i have to apply some minor changes.

Offline

#4 2021-11-17 13:04:50

seth
Member
Registered: 2012-09-03
Posts: 49,979

Re: Configuration for old Kernels

Be mindful of https://archlinux.org/news/moving-to-zs … kinitcpio/ and post the build log - nobody can tell *what* the error is (just about where)

Offline

#5 2021-11-17 14:54:44

Simulacrum
Member
Registered: 2017-02-23
Posts: 28

Re: Configuration for old Kernels

Ok, thanks so far!

Im not getting to the point where i use mkinitcpio yet. Just to make things clear, i did the following steps with Kernel 5.4.41:

$ make mrproper

-> no output at all

i set the config with:

$ zcat /proc/config.gz > .config

and then i ran

$ make -j8

I got asked in the first place what modules i want to have / how they have to be configured. I just passed these questions with ENTER, as i just wanted the default (or recommended) settings.

Output of make ix.io

P.S.: @seth, your footer is really helpfull, 0bin has a maximum file size i exceeded with my log big_smile

P.P.S: The "minor changes" i mentioned above are NOT applied yet. the errors occure with the normal kernel source.

Last edited by Simulacrum (2021-11-17 14:56:14)

Offline

#6 2021-11-17 15:06:58

seth
Member
Registered: 2012-09-03
Posts: 49,979

Re: Configuration for old Kernels

The uploaded log doesn't seem to include stderr?
Ftr, ix.io has a quota as well, in doubt tail the last MB or so.

Offline

#7 2021-11-17 15:18:52

Simulacrum
Member
Registered: 2017-02-23
Posts: 28

Re: Configuration for old Kernels

Thanks for the hint - the upload is actually incomplete.
When it comes to STDERR, its not included in the file at all (at least as it appears).

I now used

[user@machine linux-5.4.41]$ make -j8 > >(tee /home/user/make.log) 2>&1

without running mrproper or copying the config beforehand. So the output is shortend. If you nee the full log, I'll start from scratch.

The Logfile

Offline

#8 2021-11-17 15:48:23

loqs
Member
Registered: 2014-03-06
Posts: 17,192

Re: Configuration for old Kernels

https://github.com/torvalds/linux/commi … f76ee47d62
Which was backported to 5.4.59 and newer.  So is included in 5.4.160 as used by https://aur.archlinux.org/packages/linux-lts54/
Edit:
What are these minor changes you need to make to the kernel?  Why can they not be made to the current kernel?

Last edited by loqs (2021-11-17 16:05:51)

Offline

#9 2021-11-17 17:09:57

Simulacrum
Member
Registered: 2017-02-23
Posts: 28

Re: Configuration for old Kernels

@loqs

Thanks for the info. I'll try 5.4.160 soon. I'll report afterwards.

The "minor changes" are related to kvm for rdtsc spoofing. For Details, please refer to this github page.

Offline

#10 2021-11-17 17:39:04

loqs
Member
Registered: 2014-03-06
Posts: 17,192

Re: Configuration for old Kernels

It should apply to the current Arch kernel as well.  This is the diff for the Intel changes against 5.15.2

diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index dcd4f43c23de..be08197c7a4f 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -2502,7 +2502,8 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf,
 	      CPU_BASED_MWAIT_EXITING |
 	      CPU_BASED_MONITOR_EXITING |
 	      CPU_BASED_INVLPG_EXITING |
-	      CPU_BASED_RDPMC_EXITING;
+	      CPU_BASED_RDPMC_EXITING |
+	      CPU_BASED_RDTSC_EXITING;
 
 	opt = CPU_BASED_TPR_SHADOW |
 	      CPU_BASED_USE_MSR_BITMAPS |
@@ -5641,6 +5642,41 @@ static int handle_bus_lock_vmexit(struct kvm_vcpu *vcpu)
 	return 0;
 }
 
+static u32 print_once = 1;
+
+static int handle_rdtsc(struct kvm_vcpu *vcpu)
+{
+	static u64 rdtsc_fake = 0;
+	static u64 rdtsc_prev = 0;
+	u64 rdtsc_real = rdtsc();
+
+	if(print_once)
+	{
+		printk("[handle_rdtsc] fake rdtsc vmx function is working\n");
+		print_once = 0;
+		rdtsc_fake = rdtsc_real;
+	}
+
+	if(rdtsc_prev != 0)
+	{
+		if(rdtsc_real > rdtsc_prev)
+		{
+			u64 diff = rdtsc_real - rdtsc_prev;
+			u64 fake_diff =  diff / 16; // if you have 4.2Ghz on your vm, change 16 to 20
+			rdtsc_fake += fake_diff;
+		}
+	}
+	if(rdtsc_fake > rdtsc_real)
+	{
+		rdtsc_fake = rdtsc_real;
+	}
+	rdtsc_prev = rdtsc_real;
+    	vcpu->arch.regs[VCPU_REGS_RAX] = rdtsc_fake & -1u;
+    	vcpu->arch.regs[VCPU_REGS_RDX] = (rdtsc_fake >> 32) & -1u;
+
+    	return skip_emulated_instruction(vcpu);
+}
+
 /*
  * The exit handlers return 1 if the exit was handled fully and guest execution
  * may resume.  Otherwise they set the kvm_run parameter to indicate what needs
@@ -5698,6 +5734,7 @@ static int (*kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu) = {
 	[EXIT_REASON_PREEMPTION_TIMER]	      = handle_preemption_timer,
 	[EXIT_REASON_ENCLS]		      = handle_encls,
 	[EXIT_REASON_BUS_LOCK]                = handle_bus_lock_vmexit,
+	[EXIT_REASON_RDTSC]		      = handle_rdtsc,
 };
 
 static const int kvm_vmx_max_exit_handlers =

Offline

#11 2021-11-17 17:42:52

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,425

Re: Configuration for old Kernels

Also, last sentence of the readme

Readme wrote:

... Latest kernel modification for Arch linux uses the same vmx and svm files as official repository, so it should work too.

Online

#12 2021-11-25 14:07:43

Simulacrum
Member
Registered: 2017-02-23
Posts: 28

Re: Configuration for old Kernels

Sorry, it took my way too long to reply. I caught a nasty cold and had to catch up with my work.

loqs wrote:

It should apply to the current Arch kernel as well.  This is the diff for the Intel changes against 5.15.2

diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index dcd4f43c23de..be08197c7a4f 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -2502,7 +2502,8 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf,
 	      CPU_BASED_MWAIT_EXITING |
 	      CPU_BASED_MONITOR_EXITING |
 	      CPU_BASED_INVLPG_EXITING |
-	      CPU_BASED_RDPMC_EXITING;
+	      CPU_BASED_RDPMC_EXITING |
+	      CPU_BASED_RDTSC_EXITING;
 
 	opt = CPU_BASED_TPR_SHADOW |
 	      CPU_BASED_USE_MSR_BITMAPS |
@@ -5641,6 +5642,41 @@ static int handle_bus_lock_vmexit(struct kvm_vcpu *vcpu)
 	return 0;
 }
 
+static u32 print_once = 1;
+
+static int handle_rdtsc(struct kvm_vcpu *vcpu)
+{
+	static u64 rdtsc_fake = 0;
+	static u64 rdtsc_prev = 0;
+	u64 rdtsc_real = rdtsc();
+
+	if(print_once)
+	{
+		printk("[handle_rdtsc] fake rdtsc vmx function is working\n");
+		print_once = 0;
+		rdtsc_fake = rdtsc_real;
+	}
+
+	if(rdtsc_prev != 0)
+	{
+		if(rdtsc_real > rdtsc_prev)
+		{
+			u64 diff = rdtsc_real - rdtsc_prev;
+			u64 fake_diff =  diff / 16; // if you have 4.2Ghz on your vm, change 16 to 20
+			rdtsc_fake += fake_diff;
+		}
+	}
+	if(rdtsc_fake > rdtsc_real)
+	{
+		rdtsc_fake = rdtsc_real;
+	}
+	rdtsc_prev = rdtsc_real;
+    	vcpu->arch.regs[VCPU_REGS_RAX] = rdtsc_fake & -1u;
+    	vcpu->arch.regs[VCPU_REGS_RDX] = (rdtsc_fake >> 32) & -1u;
+
+    	return skip_emulated_instruction(vcpu);
+}
+
 /*
  * The exit handlers return 1 if the exit was handled fully and guest execution
  * may resume.  Otherwise they set the kvm_run parameter to indicate what needs
@@ -5698,6 +5734,7 @@ static int (*kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu) = {
 	[EXIT_REASON_PREEMPTION_TIMER]	      = handle_preemption_timer,
 	[EXIT_REASON_ENCLS]		      = handle_encls,
 	[EXIT_REASON_BUS_LOCK]                = handle_bus_lock_vmexit,
+	[EXIT_REASON_RDTSC]		      = handle_rdtsc,
 };
 
 static const int kvm_vmx_max_exit_handlers =

I checked the kernel manually, and the changes haven't been made there? What the hell? big_smile


Also, last sentence of the readme

I saw that one but had problems compiling the (back then current) kernel. Maybe i should retry for now, as my knowledge base has improved since i started.



Further more: I tried compiling the kernel 5.4.160 (as mentioned by loqs) without any changes. The compilation and module installation ran without any errors but trying to boot the kernel brought up the following error:
https://imgur.com/kgDdwlc (Sorry for the poor quality)

I tried fixing this by:
- re-checking if all build tools are installed (which they where)
- changing the ext4 parameter in the .config of the kernel to

CONFIG_EXT4_FS=y

as my FS on /boot is ext4 and it has been loaded as module before.


I also checked the /etc/mkinitcpio.conf and saw the following entries:

# COMPRESSION
# Use this to compress the initramfs image. By default, gzip compression
# is used. Use 'cat' to create an uncompressed image.
#COMPRESSION="gzip"
#COMPRESSION="bzip2"
#COMPRESSION="lzma"
#COMPRESSION="xz"
#COMPRESSION="lzop"
#COMPRESSION="lz4"

What makes me wonder is that neither of my files in /boot/ seem to be compressed as gz..?

[user@machine linux-5.4.160]$ file /boot/initramfs-linux.img 
/boot/initramfs-linux.img: Zstandard compressed data (v0.8+), Dictionary ID: None
[user@machine linux-5.4.160]$ file /boot/vmlinuz-linux
/boot/vmlinuz-linux: Linux kernel x86 boot executable bzImage, version 5.15.4-arch1-1 (linux@archlinux) #1 SMP PREEMPT Sun, 21 Nov 2021 21:34:33 +0000, RO-rootFS, swap_dev 0X9, Normal VGA

Last edited by Simulacrum (2021-11-25 14:08:49)

Offline

#13 2021-11-25 15:04:09

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,463

Re: Configuration for old Kernels

For the initramfs, you're either on a very old version or you didn't merge your .pacnew files. https://github.com/archlinux/mkinitcpio … 04f3a130e6

Edit: Actually, if you were on an old version, it wouldn't be zstd, so it's definitely a .pacnew issue.

Last edited by Scimmia (2021-11-25 15:06:30)

Offline

#14 2021-11-25 16:29:03

Simulacrum
Member
Registered: 2017-02-23
Posts: 28

Re: Configuration for old Kernels

Wow. I don't know what actually happend (or why i haven't done this for a longer time), but i think I got some merge work to do big_smile

[user@machine ~]$ sudo find / -type f -name "*.pacnew" 2>/dev/null | wc -l
9

Thanks for the hint so far, maybe that fixes something. I'll report afterwards.

Last edited by Simulacrum (2021-11-25 16:46:31)

Offline

Board footer

Powered by FluxBB