Encountered a problem installing the compiled Linux 4.9.3 kernel into GuestOS

93 views
Skip to first unread message

Jay Ironman

unread,
Nov 14, 2023, 8:11:07 AM11/14/23
to S2E Developer Forum
Before explaining this issue, I need to introduce the prerequisites to you. I am now preparing to use UOS 1050d as GuestOS (this operating system is based on Debian, and I will use UOS to refer to this operating system in the following text). Before building the S2E platform for this GuestOS, I need to verify whether the Linux 4.9.3 kernel can run successfully on UOS. Therefore, I have done the following:
  • Compile the original kernel of Linux 4.9.3 (from https://www.kernel.org/ )Generate the deb package and compile it using the default generated. config file. The result is successful compilation, and the Linux kernel can also be successfully installed on UOS and can be used normally.
  • Compile the original kernel of Linux 4.9.3 (from https://www.kernel.org/ )Generate deb packages and compile them using the. config file of the UOS system. The result is successful compilation, and the Linux kernel can also be successfully installed on UOS and can be used normally.
  • Compile the Linux 4.9.3 kernel in the S2E source code to generate deb packages, compile using the. config file of the UOS system, and successfully set the S2E related header files as environment variables. The result is successful compilation. This compiled Linux kernel can be successfully installed on UOS, but when I started the UOS system using this compiled and installed Linux kernel, the situation shown in the following figure occurred:Snipaste_2023-11-14_17-23-47.png
After my analysis, UOS is compatible with the Linux 4.9.3 kernel, and there is no problem compiling this Linux kernel using UOS's. config. The problem occurred when I compiled and installed the Linux 4.9.3 kernel in the S2E source code, as shown in the above figure. So I was wondering if there were any targeted modifications made to the Linux kernel in the S2E source code? Or other details about compiling the Linux kernel that I haven't noticed? I currently have no clue about this and have been troubled by it for two weeks. I hope you can give me some guidance.

Vitaly Chipounov

unread,
Nov 14, 2023, 8:47:59 AM11/14/23
to s2e...@googlegroups.com
Hi,

It's hard to tell, there isn't enough information. The error trace is truncated, perhaps sending it to the serial port would help. S2E has a modified Linux kernel that cannot run in vanilla QEMU because it uses custom S2E instructions. These instructions would result in invalid opcode exceptions and crash the guest.

Vitaly

--
You received this message because you are subscribed to the Google Groups "S2E Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to s2e-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/s2e-dev/2784887f-03c7-446d-a4d2-b39affaec671n%40googlegroups.com.

Jay Ironman

unread,
Nov 14, 2023, 9:15:46 AM11/14/23
to S2E Developer Forum
Unfortunately, this is all of its output information (although I will try to print more information). In addition, I didn't quite understand the second half of your sentence. Do you mean that the Linux 4.9.3 kernel of S2E can only be applied to Ubuntu and Debian at present? Actually, I can't think of any other possibilities besides that, because I have only reached this conclusion using the exclusion method so far. Do you have any other ideas?

Jay Ironman

unread,
Nov 14, 2023, 11:17:50 AM11/14/23
to S2E Developer Forum
I have a question now. The config file in the Linux 4.9.3 code in the S2E source code was specially written, and when I compile using the config files from other systems (which are definitely not the corresponding files for the 4.9.3 Linux kernel), although I used the 'make oldconfig' command and the 'make menuconfig' command, I also configured the S2E header file and ultimately compiled successfully. But the compiled kernel is no longer the customized kernel for Linux 4.9.3 in the S2E source code (because I used the 'make oldconfig' command and the 'make menuconfig' command)

Vitaly Chipounov

unread,
Nov 14, 2023, 11:39:56 AM11/14/23
to s2e...@googlegroups.com
Hi,

On Tue, Nov 14, 2023 at 3:15 PM Jay Ironman <ironman...@gmail.com> wrote:
Unfortunately, this is all of its output information (although I will try to print more information). In addition, I didn't quite understand the second half of your sentence. Do you mean that the Linux 4.9.3 kernel of S2E can only be applied to Ubuntu and Debian at present? Actually, I can't think of any other possibilities besides that, because I have only reached this conclusion using the exclusion method so far. Do you have any other ideas?


No, the kernel can be installed on any system. I meant that it can only run inside the S2E VM. You cannot install it in other hypervisors.

Vitaly
 
在2023年11月14日星期二 UTC+8 21:47:59<Vitaly Chipounov> 写道:
Hi,

It's hard to tell, there isn't enough information. The error trace is truncated, perhaps sending it to the serial port would help. S2E has a modified Linux kernel that cannot run in vanilla QEMU because it uses custom S2E instructions. These instructions would result in invalid opcode exceptions and crash the guest.

Vitaly

On Tue, Nov 14, 2023 at 2:11 PM Jay Ironman <ironman...@gmail.com> wrote:
Before explaining this issue, I need to introduce the prerequisites to you. I am now preparing to use UOS 1050d as GuestOS (this operating system is based on Debian, and I will use UOS to refer to this operating system in the following text). Before building the S2E platform for this GuestOS, I need to verify whether the Linux 4.9.3 kernel can run successfully on UOS. Therefore, I have done the following:
  • Compile the original kernel of Linux 4.9.3 (from https://www.kernel.org/ )Generate the deb package and compile it using the default generated. config file. The result is successful compilation, and the Linux kernel can also be successfully installed on UOS and can be used normally.
  • Compile the original kernel of Linux 4.9.3 (from https://www.kernel.org/ )Generate deb packages and compile them using the. config file of the UOS system. The result is successful compilation, and the Linux kernel can also be successfully installed on UOS and can be used normally.
  • Compile the Linux 4.9.3 kernel in the S2E source code to generate deb packages, compile using the. config file of the UOS system, and successfully set the S2E related header files as environment variables. The result is successful compilation. This compiled Linux kernel can be successfully installed on UOS, but when I started the UOS system using this compiled and installed Linux kernel, the situation shown in the following figure occurred:Snipaste_2023-11-14_17-23-47.png
After my analysis, UOS is compatible with the Linux 4.9.3 kernel, and there is no problem compiling this Linux kernel using UOS's. config. The problem occurred when I compiled and installed the Linux 4.9.3 kernel in the S2E source code, as shown in the above figure. So I was wondering if there were any targeted modifications made to the Linux kernel in the S2E source code? Or other details about compiling the Linux kernel that I haven't noticed? I currently have no clue about this and have been troubled by it for two weeks. I hope you can give me some guidance.

--
You received this message because you are subscribed to the Google Groups "S2E Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to s2e-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/s2e-dev/2784887f-03c7-446d-a4d2-b39affaec671n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "S2E Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to s2e-dev+u...@googlegroups.com.

Jay Ironman

unread,
Nov 14, 2023, 8:21:32 PM11/14/23
to S2E Developer Forum
Sorry, I don't quite understand what you mean by 'it can only run inside the S2E VM'. Do you mean installing a S2E virtual machine? However, after carefully reviewing the Makefile file, I did not find that S2E needs to be installed in GuestOS. I still do not understand and hope to receive your answer

Jay Ironman

unread,
Nov 15, 2023, 6:30:01 AM11/15/23
to S2E Developer Forum
I seem to understand your point. What you mean is that Kernel can only be installed in the QEMU virtual machine of S2E. I did indeed do this, using the QEMU of S2E to build the virtual machine and install the compiled kernel, but still encountered the error shown in the above figure.

Vitaly Chipounov

unread,
Nov 15, 2023, 6:45:33 AM11/15/23
to s2e...@googlegroups.com
Note that if you just use QEMU that ships with S2E without any special flags, it will behave like normal QEMU. You must LD_PRELOAD libs2e.so into it and use --enable-kvm. The makefile takes care of that [1].


Jay Ironman

unread,
Nov 15, 2023, 8:21:39 AM11/15/23
to S2E Developer Forum
Thank you very much. I'll give it a try now. I hope you can hear my good news!

Jay Ironman

unread,
Nov 15, 2023, 9:25:11 AM11/15/23
to S2E Developer Forum
Thank you very much. After experimentation, we have successfully replaced the compiled S2E Linux 4.9.3 kernel, so we should be able to successfully replace it with a new GuestOS! Thank you again for your wonderful reminder!

Jay Ironman

unread,
Nov 17, 2023, 12:02:15 AM11/17/23
to S2E Developer Forum
I'm sorry to bother you again. Although I can successfully start GuestOS using the Linux 4.9.3 kernel of S2E, I still don't quite understand why it is necessary to import s2e.so when starting GuestOS. What is this dynamic link library for? What is the function? Why does not importing s2e.so when starting GuestOS cause GuestOS to fail to start?
I hope you can help me answer, because I am curious about the principle behind this, or where is there an introduction to s2e. so?

Vitaly Chipounov

unread,
Nov 17, 2023, 5:52:30 AM11/17/23
to s2e...@googlegroups.com
libs2e.so implements the S2E engine. It extends the x86 instruction set with special instructions so that the guest can communicate with S2E. If you don't load that library, these instructions will cause an invalid opcode exception and crash the kernel. See [1] for details.

Vitaly


Jay Ironman

unread,
Nov 17, 2023, 10:03:43 AM11/17/23
to S2E Developer Forum
Thank you very much for your reply. I will carefully study it.
Thank you again for your patient answer to me for such a long time.
Reply all
Reply to author
Forward
0 new messages