Method for running non-root linux on x86 platform-based jailhouse

By building a QEMU virtual machine and modifying the Jailhouse code to generate new cell files, the problem of the lack of non-root Linux running methods on the x86 platform was solved, and efficient deployment of non-root Linux systems was achieved.

CN114398145BActive Publication Date: 2026-02-06KYLIN CORP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111511902.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-06
Publication Date
2026-02-06
Estimated Expiration
2041-12-06

AI Technical Summary

Technical Problem

There is a lack of existing methods for running non-root Linux on the x86 platform. Jailhouse's documentation is incomplete and its tools contain errors, resulting in long investigation times for engineers.

Method used

By building a QEMU virtual machine, extracting the Linux kernel and root system files, modifying the Jailhouse code to generate new cell files, and merging the files, non-root Linux is run on the x86 platform.

Benefits of technology

It enables efficient running of non-root Linux on the x86 platform, shortening the technical research time for engineers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114398145B_ABST
    Figure CN114398145B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of computer science, in particular to a method for running Linux system based on X86 platform Jailhouse, comprising the following steps: S1, constructing QEMU virtual machine based on Jailhouse program on X86 platform, the QEMU virtual machine is used to simulate Linux system; S2, taking out Linux kernel file and Linux root system file in the construction file of the QEMU virtual machine; S3, modifying linux-x86-demo.c provided by Jailhouse and generating new linux-x86-demo.cell; S4, merging the Linux kernel file, the Linux root system file and the linux-x86-demo.cell to generate a merged file; S5, running non-root Linux on X86 platform through the merged file. The method can run non-root Linux using Jailhouse on X86 platform, and can greatly reduce the technical research time of domestic engineers in the related field.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer science, and particularly relates to a method for running non-root Linux based on an X86 platform. BACKGROUND

[0002] Jailhouse is a Linux-based partition manager released by Siemens in 2013, which complies with the GPLv2 agreement. Jailhouse is much more efficient than QEMU, KVM, XEN and the like in terms of virtualization, and can be applied to the embedded field. In addition to Linux, it can also run bare-metal applications or (adapted) operating systems. To this end, it configures the CPU and device virtualization functions of the hardware platform in a certain way, so that these domains (referred to as "cells" here) do not interfere with each other in an unacceptable manner. Jailhouse is optimized for simplicity rather than functionality, unlike Linux-based full-featured virtual machine managers such as KVM or XEN, Jailhouse does not support overuse of resources such as CPU, RAM or devices. It does not perform scheduling. Only those resources in the virtualization software that are essential to the platform and cannot be partitioned in hardware are virtualized. Once Jailhouse is enabled, it runs on a bare machine, that is, it can fully control the hardware without external support. However, compared with other bare-metal managers, it is loaded and configured by a normal Linux system. Its management interface is based on the Linux infrastructure. Therefore, Linux is started first, then Jailhouse is enabled, and finally a part of the system resources is split and allocated to other cells.

[0003] However, the help document of Jailhouse is not perfect at present, the official tools have many errors, and there is no method for running non-root Linux in the X86 environment, nor is there a systematic deployment tutorial. The so-called non-root Linux refers to the Guest Linux running on the host Linux.

[0004] Therefore, it is necessary to provide a running method, so that the method can enable Jailhouse to run non-root Linux on an X86 platform. SUMMARY

[0005] Technical problem to be solved

[0006] In view of the above-mentioned defects of the prior art, the present application provides a method for running non-root Linux based on X86 platform, which can run non-root Linux on X86 platform by using Jailhouse, and can greatly reduce the technical research time of engineers in the related field.

[0007] Technical solution

[0008] To achieve the above object, the present application is implemented by the following technical solutions:

[0009] The present application provides a method for running non-root Linux based on X86 platform, comprising the following steps:

[0010] S1, constructing a QEMU virtual machine on X86 platform based on Jailhouse program, wherein the QEMU virtual machine is used to simulate Linux system;

[0011] S2, taking out the Linux kernel file and Linux root system file in the construction file of the QEMU virtual machine;

[0012] S3, modifying the linux-x86-demo.c provided by Jailhouse and generating a new linux-x86-demo.cell;

[0013] S4, merging the Linux kernel file, the Linux root system file and the linux-x86-demo.cell to generate a merged file;

[0014] S5, running non-root Linux on X86 platform by using the merged file.

[0015] Further, the QEMU virtual machine constructed on X86 platform based on Jailhouse program specifically comprises:

[0016] correctly running Jailhouse program: downloading official Jailhouse program source code and compiling on X86 platform; detecting X86 platform hardware by using Jailhouse program, and modifying kernel parameters of Jailhouse program after no error is detected to select Linux system serial port; and generating configuration file and system cell by using Jailhouse command;

[0017] downloading official Jailhouse-images program source code, and constructing the QEMU virtual machine by using Jailhouse-images program.

[0018] Further, the official Jailhouse program source code is downloaded on the X86 platform and compiled using the git tool.

[0019] Further, the step S3 specifically comprises:

[0020] All members in the.pci_caps array in linux-x86-demo.c provided by Jailhouse are contained by #ifdef CONFIG_QEMU_E1000E_ASSIGNMENT, and the.pci_caps array length is modified;

[0021] The irqchips field is modified, the sysconfig.c is reserved, the PIO_RANGE(0x3000) is deleted, and the pio_range array length is modified to generate a new linux-x86-demo.cell.

[0022] Based on the same inventive concept, the application further provides an electronic device comprising a processor and a memory, wherein the memory stores a computer program, and the computer program is executed by the processor to implement the method according to any one of the preceding embodiments.

[0023] Based on the same inventive concept, the application further provides a readable storage medium, wherein the readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of the preceding embodiments.

[0024] Advantages

[0025] The application provides a method for running non-root Linux based on an X86 platform Jailhouse, which can run non-root Linux using Jailhouse on the X86 platform, and can greatly reduce the technical research time of domestic engineers in the related field. BRIEF DESCRIPTION OF DRAWINGS

[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained from these drawings without creative labor.

[0027] Figure 1 The method for running non-root Linux based on an X86 platform Jailhouse provided by an embodiment of the present application is shown in the step schematic diagram;

[0028] Figure 2 A flowchart of a method for running non-root Linux based on X86 platform by Jailhouse is provided for an embodiment of the present application. DETAILED DESCRIPTION

[0029] In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.

[0030] With reference to Figure 1 An embodiment of the present application provides a method for running non-root Linux based on X86 platform by Jailhouse, which comprises the following steps:

[0031] S1, constructing a QEMU virtual machine based on a Jailhouse program on an X86 platform, wherein the QEMU virtual machine is used for simulating a Linux system;

[0032] S2, taking out a Linux kernel file and a Linux root system file in a construction file of the QEMU virtual machine;

[0033] S3, modifying a linux-x86-demo.c provided by the Jailhouse and generating a new linux-x86-demo.cell;

[0034] S4, merging the Linux kernel file, the Linux root system file and the linux-x86-demo.cell to generate a merged file;

[0035] S5, running non-root Linux on the X86 platform through the merged file.

[0036] The target is to run non-root Linux system based on X86 platform through Jailhouse (a Linux-based partition manager), and the idea is: firstly, the official apic-demo of Jailhouse needs to be correctly run, then the official jailhouse-images project is downloaded to build a QEMU virtual machine, the kernel file (for example, vmlinuxz-5.10.31) and the root system file (for example, rootfs.cpio) are taken out from the QEMU virtual machine folder, the linux-x86-demo.c provided by the official code of Jailhouse is modified and a new linux-x86-demo.cell is created. Finally, the three files of linux-x86-demo.cell, the kernel file and the root system file are used as the system files of non-root Linux on the X86 platform to start the non-root Linux.

[0037] In this embodiment, for step S1, refer to Figure 2, download the official Jailhouse source code and compile, use the git tool to clone the source code from the official address of Jailhouse, execute the command: make-j8; make install. Then, detect the X86 platform hardware through the Jailhouse program, that is, through jailhouse hardware check, and the display result must be "check passed!", indicating that the detection is correct. After the detection is correct, modify the kernel parameters of the Jailhouse program to select the serial port of the Linux system and execute the command; if not, the CPU supporting VMX and Preempt timer needs to be replaced. Further, modify the kernel parameters of the Jailhouse program, that is, modify the GRUB_CMDLINE_LINUX variable of the / etc / default / grub file, and finally append the "intel_iommu=offmemmap=82M\\\$0x3a000000console=ttyS1,115200" parameter, and regenerate the grub configuration file. Note that here must not use ttyS0, because the real available serial port is reserved for jailhouse debugging. If ttyS0 is used here, the Jailhouse will report a 3F8 port error problem in the running. Further, generate the configuration file and system cell: use the jailhouse command to generate the sysconfig.c configuration file in the configs / x86 folder, and then make again after success. At this time, the sysconfig.cell file will be generated in the configs / x86 folder. Finally, download the official Jailhouse-images source code and build the QEMU virtual machine: install git elfutils-libelf-devel qemu-kvm python3 python3-pip software, use the git tool to download the source code from the official address, set the terminal proxy, then manually download the container image, and then run the container to manually build the QEMU virtual machine.

[0038] In this embodiment, refer to Figure 2, modify the linux-x86-demo.c of Jailhouse and generate a new cell, the specific operation steps are as follows: first, include all members in the.pci_caps array with #ifdef CONFIG_QEMU_E1000E_ASSIGNMENT, and modify the length of the.pci_caps array. Then, modify the irqchips field, and copy sysconfig.c. Finally, delete PIO_RANGE(0x3000), and modify the array length of pio_range, to generate a new linux-x86-demo.cell. Through the modification of the.pci_caps field, the modification of the irqchips field and the modification of the pio_range field, the target that the linux-x86-demo.cell does not crash can be achieved.

[0039] In the embodiment, running non-root Linux on an X86 platform through the merged file can be performed according to the following steps: using the command: jailhouse cell linux linux-x86-demo.cell vmlinuxz-5.10.31-i rootfs.cpio

[0040] "console=ttyS0,1152008250.nr_uarts=1", the vmlinuxz-5.10.31 and the rootfs.cpio are both generated in step 3. If a kernel of one's own is used, the configuration CONFIG_JAILHOUSE_GUEST=y, CONFIG_SERIO=n and CONFIG_PM_TRACE_RTC=n can be modified, and a new kernel file can be generated to replace the vmlinuxz-5.10.31. Correspondingly, the rootfs.cpio can also use the initramfs.img generated by the new kernel.

[0041] Based on the same inventive concept, the application further provides an electronic device comprising a processor and a memory, wherein the memory stores a computer program, and the computer program is executed by the processor to implement the method for running non-root Linux based on the X86 platform of Jailhouse.

[0042] The processor in some embodiments can be a central processing unit (CPU), a controller, a microcontroller, a microprocessor (such as a GPU (Graphics Processing Unit)), or other data processing chip. The processor is generally used to control the overall operation of the electronic device. In the present embodiment, the processor is used to run program codes or process data stored in the memory, such as the program codes of the method for running non-root Linux of the Jailhouse based on the X86 platform.

[0043] The memory at least includes one type of readable storage medium, such as flash memory, hard disk, multimedia card, card-type memory (such as SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory can be an internal storage unit of the electronic device, such as the hard disk or memory of the electronic device. In other embodiments, the memory can also be an external storage device of the electronic device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device. Of course, the memory can also include both the internal storage unit and the external storage device of the electronic device. In the present embodiment, the memory is generally used to store the operating method and various application software installed on the electronic device, such as the program codes of the method for running non-root Linux of the Jailhouse based on the X86 platform. In addition, the memory can also be used to temporarily store various data that have been output or will be output.

[0044] Based on the same inventive concept, the present application also provides a readable storage medium, which stores a computer program. When the computer program is executed by a processor, the method for running non-root Linux of the Jailhouse based on the X86 platform is realized.

[0045] The above examples are only used to illustrate the technical solutions of the present application, and are not intended to limit the present application; although the present application has been described in detail with reference to the foregoing examples, those skilled in the art should understand that the technical solutions recorded in the foregoing examples can be modified, or some technical features can be replaced by equivalent features; and these modifications or replacements will not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for running non-root Linux based on X86 platform Jailhouse, characterized in that, The method comprises the following steps: S1, constructing a QEMU virtual machine based on a Jailhouse program on an X86 platform, the QEMU virtual machine being used to simulate a Linux system; The step of constructing the QEMU virtual machine based on the Jailhouse program on the X86 platform specifically comprises: correctly running the Jailhouse program: downloading official Jailhouse program source code and compiling on the X86 platform; detecting X86 platform hardware through the Jailhouse program, and modifying kernel parameters of the Jailhouse program after no error is detected to select a Linux system serial port; generating a configuration file and a system cell using a Jailhouse command; downloading official Jailhouse-images program source code, and constructing the QEMU virtual machine through the Jailhouse-images program; S2, taking out a Linux kernel file and a Linux root system file in a construction file of the QEMU virtual machine; S3, modifying a linux-x86-demo.c provided by the Jailhouse and generating a new linux-x86-demo.cell, specifically comprising: including all members in a.pci_caps array in the linux-x86-demo.c provided by the Jailhouse in an #ifdefCONFIG_QEMU_E1000E_ASSIGNMENT, and modifying a.pci_caps array length; modifying an irqchips field, retaining a sysconfig.c, deleting a PIO_RANGE(0x3000), and modifying a pio_range array length to generate the new linux-x86-demo.cell; S4, merging the Linux kernel file, the Linux root system file, and the linux-x86-demo.cell to generate a merged file; S5, running a non-root Linux on the X86 platform through the merged file.

2. The method of claim 1, wherein the Jailhouse running non-root Linux on an X86 platform is characterized by, The step of downloading the official Jailhouse program source code and compiling on the X86 platform uses a git tool.

3. An electronic device, comprising: The computer program is stored in the memory and is executed by the processor to implement the method of claim 1 or 2.

4. A readable storage medium, characterized by, The computer program is stored in the readable storage medium and is executed by the processor to implement the method of claim 1 or 2.

Citation Information

Patent Citations

  • Method and device for judging hardware platform based on Linux kernel

    CN106293759A

  • Automated kernel hook module building

    US8677118B1