Jailhouse transplantation Android adaptation method, device and medium
By configuring and compiling adapter files, the problem that the Android system cannot deploy Jailhouse virtualization tool is solved, and Jailhouse is implemented to run Jailhouse under Android system, providing a high reliability and low latency environment.
Patent Information
- Application Number
- CN202510000995.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-02
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2045-01-02
AI Technical Summary
The Android system cannot deploy Jailhouse virtualization tools, resulting in the inability to achieve high reliability and low latency application scenarios on the Android system.
By configuring root and non-root cell configuration files, turn off the conflict options between Android and Jailhouse, compile the Jailhouse driver into kernel file mode, and finally compile Jailhouse tools into executable files for Android system.
It realizes running Jailhouse virtualization tools under Android system, providing a high reliability and low latency environment, and meeting application needs that require high isolation and security.
Smart Images

Figure CN119376791B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Android systems, and in particular to an adaptation method, device and medium for transplanting Jailhouse to Android. Background Art
[0002] Jailhouse is a Linux-based embedded system virtualization tool. It is mainly used in embedded systems, emphasizes partitioning and real-time performance, and provides high isolation and security. Jailhouse has good real-time performance and is suitable for application scenarios that require high reliability and low latency. The architecture of Jailhouse includes a root cell and multiple non-root cells. Each cell can run a different operating system or application, thereby achieving resource isolation and sharing. Through virtualization technology, Jailhouse enables multiple client units to run on the same physical hardware without interfering with each other, while ensuring the stability and security of the system.
[0003] Although Android is an operating system that runs on Linux, Android itself cannot be a version of Linux, so Jailhouse cannot be deployed on the Android system. Summary of the invention
[0004] The embodiments of the present invention provide a Jailhouse-to-Android adaptation method, device, and medium to solve the technical problem in the prior art that the Android system cannot deploy Jailhouse.
[0005] In a first aspect, an embodiment of the present invention provides a Jailhouse adaptation method for transplanting to Android, comprising:
[0006] Configure root cell configuration files and non-root cell configuration files according to the information of the Android system;
[0007] Disable the conflict between Android and jailhouse, and add a way to handle the conflict.
[0008] Compile the jailhouse driver into kernel file mode and compile the jailhouse tools into executable files suitable for the Android system.
[0009] In a second aspect, an embodiment of the present invention further provides an adaptation device for transplanting Jailhouse to Android, including:
[0010] A configuration module, used to configure a root cell configuration file and a non-root cell configuration file according to information of the Android system;
[0011] The shutdown module is used to close the conflicting options between Android and Jailhouse, and add a way to handle the conflict;
[0012] Compilation module, used to compile Jailhouse drivers into kernel file mode and compile Jailhouse tools into executable files suitable for Android system.
[0013] In a third aspect, an embodiment of the present invention further provides a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute the Jailhouse Android porting adaptation method provided in the above embodiment.
[0014] The Jailhouse adaptation method, device and medium provided in the embodiment of the present invention configure the root cell configuration file and the non-root cell configuration file according to the information of the Android system; turn off the conflict option between Android and Jailhouse, and add a processing method for the conflict; compile the Jailhouse driver into the kernel file mode, and compile the Jailhouse tools into an executable file suitable for the Android system. By modifying the characteristics of the Android system, Jailhouse is adapted on the platform of the Android system, and combined with the Jailhouse operation requirements, Jailhouse can be run under the Android system. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0016] Figure 1 It is a flowchart of the adaptation method of Jailhouse transplantation to Android provided in the first embodiment of the present invention;
[0017] Figure 2 It is a flowchart of the adaptation method of Jailhouse transplantation to Android provided in the second embodiment of the present invention;
[0018] Figure 3 It is a structural diagram of an adaptation device for transplanting Jailhouse to Android provided in Embodiment 3 of the present invention. DETAILED DESCRIPTION
[0019] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0020] Embodiment 1
[0021] Figure 1 : is a flowchart of the adaptation method of Jailhouse transplanted to Android provided by the first embodiment of the present invention. This embodiment is applicable to the case of adapting and transplanting Jailhouse to the Android system. The method can be executed by the adaptation device of Jailhouse transplanted to Android, and specifically includes the following steps:
[0022] Step 110: configure the root cell configuration file and the non-root cell configuration file according to the information of the Android system.
[0023] Exemplarily, it may include: adding reserved memory in the Android kernel device tree for use by the hypervisor and for guest loading and running, setting parameters of the root cell configuration file and the non-root cell configuration file according to information of the Android kernel device tree, and compiling and generating the root cell configuration file and the non-root cell configuration file.
[0024] Jailhouse consists of five parts: user program jailhouse_tools, driver jailhouse.ko, configuration file .cell, and virtual machine monitor firmware hypervisor.bin.
[0025] Add reserved memory in Android kernel dts to provide it for hypervisor use and for guest loading and running. Then add root and non-root cell configuration files according to the platform dts file, and configure system memory, interrupt and other parameters in the configuration files. System memory, interrupt and other parameters can be obtained according to the information of Android kernel device tree and compiled into root.cell file and non_root.cell file.
[0026] Step 120, turn off the conflict option between Android and Jailhouse, and add a processing method for the conflict.
[0027] There are some conflicts between the Android system and Jailhouse, so you need to turn off the conflicting options and add a way to handle them.
[0028] Exemplarily, it may include: disabling the CONFIG_SHADOW_CALL_STCAK feature in the Android kernel that conflicts with Jailhouse, so as to avoid conflicts when executing the enter_hypervisor function in the instrumentation mode, which may cause the value of the x18 register to be changed, resulting in an error in reading the return address when the calling function returns; and disabling ARM64_VHE to allow the CPU to return to EL1 to continue execution.
[0029] SHADOW_CALL_STCAK is an LLVM instrumentation mode that saves the return address of a function to a ShadowCallStack allocated separately in the function prolog, and loads the return address from the ShadowCallStack in the function epilog, thereby preventing the return address from being overwritten (such as a stack buffer overflow). On aarch64, the instrumentation mechanism uses the x18 register to reference ShadowCallStack, so the reference to ShadowCallStack does not need to be stored in memory. When Jailhouse is compiled with llvm, it automatically uses the X18 register to help functions save and restore certain registers. When executing the enter_hypervisor function, a conflict occurs, causing the value of the x18 register to be changed, resulting in an error in reading the return address when the calling function returns, so this feature needs to be turned off.
[0030] If VHE is enabled and the processor supports virtualization extensions, the kernel will not switch back to EL1, but will keep EL2 running to provide better services for KVM. When running jailhouse, KVM-related services are not needed, and ARM64_VHE needs to be disabled to return the CPU to EL1 for continued execution.
[0031] Step 130 , compile the Jailhouse driver into a kernel file mode, and compile the Jailhouse tools into an executable file suitable for the Android system.
[0032] The root.cell, non_root.cell configuration files and jailhouse.bin files generated in the above steps are binary files and have nothing to do with the compilation platform. Therefore, they are compiled with gcc, and only the driver part is compiled with llvm to reduce the workload of porting to llvm. And the kernel module file is configured with a generation path, and the kernel module file is automatically added to the kernel using modules.load according to the generation path. The jailhouse driver part is ported to the drivers directory of the kernel, and compiled using the Android kernel compilation environment llvm to compile it into the corresponding kernel module file jailhouse.ko kernel module file to reduce the workload of modifying the jailhosue as a whole when it is compiled with llvm. Configure the generation path and add the module in modules.load to achieve automatic loading at startup.
[0033] And compile Jailhouse tools into an executable file suitable for the Android system. So that users can operate Jailhouse on the Android system. Exemplary, it can include: porting the Jailhouse tools tool to the Android code directory to write an Android build description file, and using the Android compilation system in combination with the bionic library to compile it into an executable file suitable for the Android system. Porting the jailhouse tools tool to the Android code directory to write the Android.bp file, and using the Android compilation system in combination with the bionic library to compile it into an executable program jailhouse_tools.
[0034] This embodiment configures the root cell configuration file and the non-root cell configuration file according to the information of the Android system; turns off the conflict option between Android and Jailhouse, and adds a processing method for the conflict; compiles the Jailhouse driver into the kernel file mode, and compiles the Jailhouse tools into an executable file suitable for the Android system. By modifying the characteristics of the Android system, Jailhouse is adapted on the platform of the Android system, and combined with the Jailhouse operation requirements, Jailhouse can be run under the Android system.
[0035] Embodiment 2
[0036] Figure 2 1 is a flow chart of the adaptation method of Jailhouse transplantation to Android provided in the second embodiment of the present invention. This embodiment is optimized based on the above embodiment, and the method can also add the following steps: configure the jailhouse path to import the bin file compiled by gcc to the temporary storage address of the firmware / vendor / firmware as the path for loading the Jailhouse firmware; import the root.cell, non_root.cell, jailhouse_tools, jailhouse.bin, and baremetal programs to the specified directory of the external storage, and copy each user-side file to / system / bin / jailhouse through the init.rc script after the Android system is started, and copy the firmware jailhouse.bin to vendor / firmware, wherein jailhouse_tools is the user entry program.
[0037] See also Figure 2 The Jailhouse adaptation method for transplanting Android includes:
[0038] Step 210: configure a root cell configuration file and a non-root cell configuration file according to information of the Android system.
[0039] Step 220, turn off the conflict option between Android and Jailhouse, and add a processing method for the conflict.
[0040] Step 230 , compile the Jailhouse driver into a kernel file mode, and compile the Jailhouse tools into an executable file suitable for the Android system.
[0041] Step 240, configure the jailhouse path to import the bin file compiled by gcc into the firmware temporary storage address / vendor / firmware as the path for loading the jailhouse firmware.
[0042] Step 250, import root.cell, non_root.cell, jailhouse_tools, jailhouse.bin, and baremetal programs into a specified directory of an external storage device, and after the Android system is powered on, use the init.rc script to copy each user-side file to / system / bin / jailhouse, and copy the firmware jailhouse.bin to vendor / firmware, where jailhouse_tools is a user entry program.
[0043] The init.rc script is parsed by init, the first user-level process of Linux in Android. After booting, initrc copies various user-side files to / system / bin / jailhouse, and the firmware jailhouse.bin is copied to vendor / firmware. Each time the computer is booted, the user-side programs, firmware and configuration files are automatically updated. jailhouse_tools is the user entry program.
[0044] Correspondingly, the Android application side app is used to provide an interface for creating a virtual machine, loading a program, checking the status of the virtual machine, and destroying the virtual machine through the UI interface. The backend user program jailhouse_tools is called through the runtime.exec method, and jailhouse_tools enable root.cell is executed to enable the virtual machine, and jailhouse_toolscreate non_root.cell is executed to create a guest virtual machine. The virtual machine is destroyed by executing the shell command jailhouse_tools destroy, and the serial port output information of the root cell and non_root cell is printed on the screen through the virtual serial port for real-time monitoring and operation.
[0045] This embodiment adds the following steps: configure the jailhouse path to import the bin file compiled by gcc to the firmware temporary storage address / vendor / firmware as the path for loading the Jailhouse firmware; import root.cell, non_root.cell, jailhouse_tools, jailhouse.bin, and baremetal programs to the specified directory of the external storage, and copy each user-side file to / system / bin / jailhouse through the init.rc script after the Android system is turned on, and copy the firmware jailhouse.bin to vendor / firmware, where jailhouse_tools is the user entry program. Using the above method, it is convenient for users to complete the operation through the app interface in the Android system without directly operating the command line, and the running status of Jailhose is more intuitively displayed in a visual way, which brings more friendly interaction, shields cumbersome command operations, and brings many conveniences to users.
[0046] Embodiment 3
[0047] Figure 3 This is a schematic diagram of the structure of the adaptation device for transplanting Jailhouse to Android provided by the third embodiment of the present invention, see Figure 3 The Jailhouse Android porting adapter includes:
[0048] A configuration module 310, configured to configure a root cell configuration file and a non-root cell configuration file according to information of the Android system;
[0049] A closing module 320, used to close the conflicting options between Android and jailhouse, and to add a processing method for the conflict;
[0050] The compiling module 330 is used to compile the jailhouse driver into a kernel file mode and compile jailhousetools into an executable file suitable for the Android system.
[0051] The Jailhouse adaptation device provided in this embodiment is configured with the root cell configuration file and the non-root cell configuration file according to the information of the Android system; the conflict option between Android and Jailhouse is turned off, and a processing method is added for the conflict; the Jailhouse driver is compiled into the kernel file mode, and the Jailhouse tools are compiled into an executable file suitable for the Android system. By modifying the characteristics of the Android system, Jailhouse is adapted on the platform of the Android system, and combined with the Jailhouse operation requirements, Jailhouse can be run under the Android system.
[0052] Based on the above embodiments, the configuration module includes:
[0053] The compiling and generating unit is used to add reserved memory in the Android kernel device tree for use by the hypervisor and for guest loading and running, and to set the parameters of the root cell configuration file and the non-root cell configuration file according to the information of the Android kernel device tree, and to compile and generate the root cell configuration file and the non-root cell configuration file.
[0054] Based on the above embodiments, the compiling module is used for:
[0055] The Llvm compilation unit is used to transplant the jailhouse driver part to the drivers directory of the kernel, and use the Android kernel compilation environment llvm to compile it into the corresponding kernel module file jailhouse.ko kernel module file to reduce the workload of modifying the jailhouse as a whole when using llvm compilation. Based on the above embodiments, the compilation generation unit is used to:
[0056] Use gcc to compile the root cell configuration file, non-root cell configuration file and Jailhouse.bin file.
[0057] Based on the above embodiments, the closing module includes:
[0058] The first shutdown unit is used to disable the feature CONFIG_SHADOW_CALL_STCAK in the Android kernel that conflicts with Jailhouse, so as to avoid conflicts when executing the enter_hypervisor function in the instrumentation mode, which causes the value of the x18 register to be changed, resulting in an error in reading the return address when the calling function returns;
[0059] The second shutdown unit is used to shut down ARM64_VHE and return the CPU to EL1 to continue execution.
[0060] Based on the above embodiments, the compiling module includes:
[0061] The writing unit is used to port the Jailhouse tools to the Android code directory to write the Android build description file, and use the Android build system combined with the bionic library to compile it into an executable file suitable for the Android system.
[0062] Based on the above embodiments, the device further includes:
[0063] Import module, used to configure jailhouse path to import bin file compiled by gcc to temporary firmware storage address / vendor / firmware as the path for loading jailhouse firmware;
[0064] The copy module is used to import root.cell, non_root.cell, jailhouse_tools, jailhouse.bin, and baremetal programs into the specified directory of the external storage. After the Android system is started, the init.rc script is used to copy each user-side file to / system / bin / jailhouse, and the firmware jailhouse.bin is copied to vendor / firmware. Jailhouse_tools is the user entry program.
[0065] The adaptation device for transplanting Jailhouse to Android provided in the embodiment of the present invention can execute the adaptation method for transplanting Jailhouse to Android provided in any embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method.
[0066] Embodiment 4
[0067] Embodiment 4 of the present invention further provides a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute the Jailhouse Android adaptation method as described in any one of the above embodiments.
[0068] The computer storage medium of the embodiment of the present invention may adopt any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, device or device.
[0069] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0070] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0071] Computer program code for performing the operation of the present invention may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or device. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0072] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A Jailhouse adaptation method for Android, characterized in that: include: Configure root cell configuration files and non-root cell configuration files according to the information of the Android system; Disable the conflict between Android and Jailhouse, and add a way to handle the conflict. Compile Jailhouse drivers into kernel file mode and Jailhouse tools into executable files suitable for Android system; The configuring the root cell configuration file and the non-root cell configuration file according to the information of the Android system includes: Add reserved memory in the Android kernel device tree for use by the hypervisor and for guest loading and running, set parameters of the root cell configuration file and the non-root cell configuration file according to the information of the Android kernel device tree, and compile and generate the root cell configuration file and the non-root cell configuration file; The option to close the conflict between Android and Jailhouse and add a way to handle the conflict include: Disable the CONFIG_SHADOW_CALL_STCAK feature in the Android kernel that conflicts with Jailhouse to avoid conflicts when executing the enter_hypervisor function in instrumentation mode, which causes the value of the x18 register to be changed, resulting in an error in reading the return address when the calling function returns; And turning off ARM64_VHE causes the CPU to return to EL1 to continue execution.
2. The method according to claim 1, characterized in that Compiling the Jailhouse driver into a kernel file mode includes: Port the jailhouse driver part to the drivers directory of the kernel, and use the Android kernel compilation environment llvm to compile it into the corresponding kernel module file jailhouse.ko kernel module file to reduce the workload of modifying the jailhosue as a whole when using llvm to compile.
3. The method according to claim 2, characterized in that The method further comprises: A generation path is configured for the kernel module file, and the kernel module file is automatically added to the kernel using modules.load according to the generation path.
4. The method according to claim 1, characterized in that: The compiling and generating of the root cell configuration file and the non-root cell configuration file includes: Use gcc to compile the root cell configuration file, non-root cell configuration file and Jailhouse.bin file.
5. The method according to claim 1, characterized in that The Jailhouse tools are compiled into an executable file suitable for the Android system, including: Port the Jailhouse tools to the Android code directory to write the Android build description file, and use the Android build system combined with the bionic library to compile it into an executable file suitable for the Android system.
6. The method according to claim 3, characterized in that The method further comprises: Configure the jailhouse path to import the bin file compiled by gcc to the temporary firmware storage address / vendor / firmware as the path for loading the jailhouse firmware; Import root.cell, non_root.cell, jailhouse_tools, jailhouse.bin, and baremetal programs to the specified directory of the external storage, and after the Android system is started, use the init.rc script to copy each user-side file to / system / bin / jailhouse, and copy the firmware jailhouse.bin to vendor / firmware, where jailhouse_tools is the user entry program.
7. An adaptation device for transplanting Jailhouse to Android, characterized in that: include: A configuration module, used to configure a root cell configuration file and a non-root cell configuration file according to information of the Android system; The shutdown module is used to close the conflicting options between Android and jailhouse, and add a way to handle the conflict; Compilation module, used to compile jailhouse drivers into kernel file mode and jailhouse tools into executable files suitable for Android system; The configuration module includes: A compiling and generating unit, used for adding reserved memory in the Android kernel device tree, for providing it to the hypervisor and for guest loading and running, and setting the parameters of the root cell configuration file and the non-root cell configuration file according to the information of the Android kernel device tree, and compiling and generating the root cell configuration file and the non-root cell configuration file; The closing module includes: The first shutdown unit is used to disable the feature CONFIG_SHADOW_CALL_STCAK in the Android kernel that conflicts with Jailhouse, so as to avoid conflicts when executing the enter_hypervisor function in the instrumentation mode, which causes the value of the x18 register to be changed, resulting in an error in reading the return address when the calling function returns; The second shutdown unit is used to shut down ARM64_VHE and return the CPU to EL1 to continue execution.
8. A storage medium containing computer executable instructions, characterized in that: The computer executable instructions, when executed by a computer processor, are used to execute the Jailhouse Android adaptation method as described in any one of claims 1-6.
Citation Information
Patent Citations
Apparatus and method for compiling configuration in android project
CN105607941A
Embedded virtualization system, construction method, test method, terminal and medium
CN113672342A