Program running method, computer device and system supporting multiple instruction set architecture

By implementing a multi-instruction set architecture on the processor and supporting the execution of multiple instruction sets, it solves the problems of high application transplant costs and low binary translation efficiency in the existing technology, achieving compatibility and efficient execution without translation. Reduces hardware overhead.

CN114116003BActive Publication Date: 2024-10-15NAT UNIV OF DEFENSE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111415643.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-25
Publication Date
2024-10-15
Estimated Expiration
2041-11-25

AI Technical Summary

Technical Problem

When the existing technology updates the processor architecture, the cost of transplanting applications is high and complicated. The binary translation technology has problems of execution errors and slow speed. Moreover, the existing multi-instruction set processors have high hardware overhead and cannot be supported in user mode at the same time. Various instruction sets.

Method used

By implementing a multi-instruction set architecture on the processor, using the status register and control register of the default instruction set architecture for initialization and mapping, it supports the execution of multiple instruction sets. It only supports multiple instruction sets in user mode and avoids full stack Support, each instruction set, processor hardware implementation overhead is small.

Benefits of technology

It realizes binary program execution that is compatible with multiple instruction sets without binary translation, ensuring the correctness and speed of the program, and reducing the implementation overhead of processor hardware.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114116003B_ABST
    Figure CN114116003B_ABST
Patent Text Reader

Abstract

The present invention discloses a program running method, computer equipment and system supporting multiple instruction set architectures. The method of the present invention comprises: starting from the address specified by the reset address register defined by the default instruction set architecture to fetch and execute instructions, setting the control register and the configuration register; loading the binary application when it is necessary to execute the binary application; setting the processor state backup register according to the instruction set architecture based on the binary application; executing the exception return instruction to read the value of the processor state backup register to set the processor state register and enter the user state, and executing the binary application to be executed. The present invention can directly run programs of multiple instruction set architectures on the processor, and there are no problems such as execution errors and slow execution speed that may be caused by the translation process. It only supports multiple instruction set architectures in the user state, and does not need to fully support each instruction set architecture, and the processor hardware implementation overhead is small.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to processor architecture technology, and in particular to a program running method, computer equipment and system supporting multiple instruction set architectures. Background Art

[0002] For processor users, when upgrading the processor architecture, the migration of the original application is very labor-intensive and material-intensive, especially when the program is large in scale, the migration cost is even higher; in addition, some applications may only have executable binary files and cannot be migrated. Because software migration is expensive and difficult, processor users usually do not easily switch to processors with different architectures. Even for the same architecture, in order to achieve software compatibility, backward compatibility must be achieved during the development of the architecture to ensure that previously developed applications can run on processors with the new architecture. So, when a new processor system appears, how can processor users switch to processors with the new architecture while allowing the original binary programs based on other processor architectures to run normally and quickly on the new processor? Then, processor users will find it easy and willing to upgrade the processor architecture.

[0003] Binary translation technology can translate binary programs executed on a processor based on one architecture to execute on a processor based on another architecture, thereby realizing the mutual migration of binary programs between processors of different architectures. However, binary translation technology has the following problems. First, if the original architecture is very complex, then the binary translation will also be very complex. If there is a translation error among hundreds of thousands of instructions, it will cause program execution errors; second, the original binary program needs to be translated before execution, and it is possible that the original instruction is translated into multiple instructions for execution because the new architecture does not have corresponding functional instructions, which will cause the application execution speed to slow down.

[0004] In addition to binary translation technology, there are related studies that propose to implement multi-instruction set processors. For example, in Microsoft's patent document "Multiple-core processor supporting multiple instruction set architectures (US8806182B2)", multiple processor cores that implement a different instruction set are integrated together, such as one processor core that implements the PowerPC instruction set architecture, and one processor core that implements the x86 instruction set architecture. Such a multi-core processor can run both binary programs of the x86 instruction set architecture and binary programs of the PowerPC instruction set architecture. To support two instruction sets using this method, at least two processor cores that support a different instruction set must be integrated together, and this method does not involve modifications at the architecture level, but only integrates processor cores of different architectures. The patent document "Heterogeneous ISA microprocessor with shared hardware ISA registers (US9141389B2)" describes the implementation of a heterogeneous instruction set processor that can execute both x86 instructions and Arm instructions. The heterogeneous instruction set processor in the patent supports two instruction sets in the super-privileged state, privileged state and user state full stack, and needs to maintain the architecture states of the x86 instruction set and the Arm instruction set at the same time. When reset, it can enter the x86 execution state or the Arm execution state according to the configuration, and the execution state switching needs to be completed by adding reset-to-arm or reset-to-x86 instructions. This processor that supports two instruction sets in the full stack has a large hardware overhead, and the patent only proposes how to support two instruction set architectures at the processor microarchitecture level at the same time. The difference from the previously mentioned Microsoft multi-core processor supporting multiple instruction sets is that the two instruction set architectures are implemented in one processor core, and there is no modification at the architecture level. ARM's patent document "Instruction Predecoding for Multiple Instruction Sets (CN200910006111.2)" describes how to predecode instructions when a processor implements multiple instruction sets. Instructions from different instruction sets are pre-decoded into instruction codes with a shared format. Only one set of decoders needs to be implemented to decode the instruction codes with a shared format. This patent solves the problem of how to reduce the hardware overhead of the decoder in a multi-instruction set processor, and does not involve the implementation of a multi-instruction set architecture. Summary of the invention

[0005] Technical problem to be solved by the present invention: In view of the above-mentioned problems in the prior art, a program running method, computer device and system supporting multiple instruction set architectures are provided. The present invention can directly run programs of multiple instruction set architectures on the processor, and there are no problems such as execution errors and slow execution speed that may be caused by the translation process. Multiple instruction set architectures are supported only in user mode, and there is no need for full stack support for each instruction set architecture, and the processor hardware implementation overhead is small.

[0006] In order to solve the above technical problems, the technical solution adopted by the present invention is:

[0007] A method for running a program supporting a multiple instruction set architecture, comprising:

[0008] 1) After power-on reset, the processor status register is reset to the encoding corresponding to the default instruction set architecture;

[0009] 2) Start fetching instructions from the address specified by the reset address register defined by the default instruction set architecture;

[0010] 3) using instructions in a default instruction set architecture to respectively set control registers and configuration registers defined by a specification of the default instruction set architecture;

[0011] 4) When a binary application needs to be executed, load the binary application to be executed;

[0012] 5) setting the processor state backup register according to the instruction set architecture on which the binary application is based;

[0013] 6) Execute the exception return instruction to read the value of the processor state backup register to set the processor state register and enter the user state, and execute the binary application that needs to be executed; when the binary application is executed or an application switch occurs, the processor leaves the user state; jump to execute step 4).

[0014] Optionally, the default instruction set architecture refers to the instruction set architecture adopted by the super privileged state layer and the privileged state layer, the super privileged state layer runs a virtual machine monitor based on the default instruction set architecture, the privileged state layer is the privileged layer in the client operating system based on the default instruction set architecture on the virtual machine monitor, and the user layer of the client operating system supports binary applications of multiple instruction set architectures including the default instruction set architecture.

[0015] Optionally, the default instruction set architecture is the Armv8 AArch64 instruction set architecture; the multiple instruction set architectures include the Armv8 AArch64 instruction set architecture and the RISC-V instruction set architecture.

[0016] Optionally, under the Armv8 AArch64 instruction set architecture, the processor state register refers to the processor state register PSTATE defined by the specification of the Armv8AArch64 instruction set architecture, and the 5th bit PSTATE[4] of the processor state register PSTATE indicates the instruction set architecture type, which is 0 for the Armv8 AArch64 instruction set architecture and the processor runs in the Armv8 AArch64 execution state, and is 1 for the RISC-V instruction set architecture and the processor runs in the RISC-V execution state; under the RISC-V instruction set architecture, the fields of the processor state register include privilege level, instruction set architecture type, debug and interrupt mask bits, and multiple reserved zero fields.

[0017] Optionally, the processor state backup register in step 5) refers to the processor state backup register SPSR defined in the specification under the Armv8 AArch64 instruction set architecture.

[0018] Optionally, before executing the binary application to be executed in step 6), it also includes mapping the user-state visible states of the Armv8 AArch64 instruction set architecture and the RISC-V instruction set architecture, and using the control registers of the super-privileged state and privileged state of the Armv8AArch64 instruction set architecture to control the behavior of the Armv8 AArch64 instruction set architecture and the RISC-V instruction set architecture in user state.

[0019] Optionally, when mapping the user-state visible states of the Armv8 AArch64 instruction set architecture and the RISC-V instruction set architecture, the registers corresponding to the user-state visible states of the Armv8 AArch64 instruction set architecture and the RISC-V instruction set architecture include integer registers, a program counter PC, a floating-point register, and a series of system registers;

[0020] Optionally, the integer register refers to 32 64-bit integer registers defined by the Armv8 AArch64 instruction set architecture, and the above 32 integer registers are accessed by both the Armv8 AArch64 instruction execution state and the RISC-V instruction execution state. These 32 integer registers are used in accordance with the Armv8 AArch64 architecture specification in the Armv8 AArch64 instruction execution state, and are used in accordance with the RISC-V architecture specification in the RISC-V instruction execution state, including: in the Armv8 AArch64 instruction execution state, register No. 31 is a zero-value register, and the read value is always all zero, and the write to the register is ignored, while in the RISC-V instruction execution state, register No. 0 is a zero-value register; in the Armv8 AArch64 instruction execution state, register No. 30 is used as a procedure call link register, and in the RISC-V instruction execution state, register No. 1 is used for the procedure call link register, and register No. 5 is used as an alternative link register; in the Armv8 In the AArch64 instruction execution state, there is a dedicated stack pointer register, while in the RISC-V instruction execution state, there is no dedicated stack pointer register, but the integer register No. 2 is used as the stack pointer register; in both execution states, the integer register can be accessed as both a 64-bit register and a 32-bit register; when accessed as a 32-bit register, the data is stored in the lower 32 bits of the 64-bit register, and the value of the upper 32-bit data depends on the execution state. In the Armv8 AArch64 instruction execution state, the upper 32 bits are always written to 0, while in the RISC-V instruction execution state, the upper 32 bits are written to the sign bit of the lower 32-bit data;

[0021] Program counter PC refers to a 64-bit program counter PC defined by the Armv8 AArch64 instruction set architecture. The 64-bit program counter PC is accessed by both the Armv8 AArch64 instruction execution state and the RISC-V instruction execution state. According to the Armv8 AArch64 instruction set architecture specification and the RISC-V instruction set architecture specification, in two execution states: instructions cannot explicitly write the program counter PC, and the program counter PC is only implicitly modified when executing branch instructions, exception entry, and exception return, but instructions can directly read the program counter PC as a source operand;

[0022] Floating-point registers refer to 32 128-bit floating-point / vector registers defined by the Armv8 AArch64 instruction set architecture. They are accessed by both the Armv8 AArch64 instruction execution state and the RISC-V instruction execution state. These 32 floating-point / vector registers are used in accordance with the Armv8 AArch64 architecture specification in the Armv8 AArch64 instruction execution state and in accordance with the RISC-V instruction set architecture specification in the RISC-V instruction execution state, including: In the AArch64 instruction execution state, the data stored in each floating-point / vector register can be a 32-bit single-precision floating-point scalar, a 64-bit double-precision floating-point scalar, a 64-bit vector, or a 128-bit vector. The 32-bit single-precision floating-point scalar data is stored in the lower 32 bits of the 128-bit register, and the upper 96 bits are written to 0. The 64-bit double-precision floating-point scalar data is stored in the lower 64 bits of the 128-bit register, and the upper 64 bits are written to 0. The 64-bit vector data is stored in the lower 64 bits of the 128-bit register, and the upper 64 bits are written to 0. In RIS In the F extended instruction set in the C-V instruction execution state, 32-bit single-precision floating-point data is stored in the lower 32 bits of the 128-bit floating-point / vector register. When the [63:32] bits of the floating-point / vector register are written, they are always written as all 1s, and when the upper 64 bits of the floating-point / vector register are written, they are always written as all 0s. In the D extended instruction set in the RISC-V instruction execution state, 64-bit double-precision floating-point data is stored in the lower 64 bits of the 128-bit floating-point / vector register. When the upper 64 bits of the floating-point / vector register are written, they are always written as all 0s.

[0023] The series of system registers include: system registers visible in user mode under the Armv8 AArch64 instruction set architecture, including: floating-point status register FPSR and floating-point control register FPCR, cache ID registers CTR_EL0 and DCZID_EL0, debug registers MDCCSR_EL0, DBGDTR_EL0, DBGDTRRX_EL0 and DBGDTRTX_EL0, a group of performance monitoring registers, a group of behavior monitoring registers, thread ID registers TPIDR_EL0 and TPIDRRO_EL0, and a group of timer registers; system registers visible in user mode under the RISC-V instruction set architecture, including: floating-point status and control register fcsr, floating-point cumulative exception flag register fflags, floating-point rounding mode register frm, and a group of read-only performance counters, wherein the group of read-only performance counters includes a clock cycle counter cycle, a timer counter time, a submitted instruction number counter instret, and 29 performance monitoring counters hpmcounter3~hpmcounter31.

[0024] In addition, the present invention also provides a computer device supporting a multiple instruction set architecture, the computer device comprising a virtual machine monitor executable environment HEE, a virtual machine monitor Hypervisor and at least one virtual machine, wherein a client operating system Guest OS runs in the virtual machine, and the virtual machine computer device is programmed or configured to execute the steps of the program running method supporting a multiple instruction set architecture.

[0025] In addition, the present invention also provides a program running system supporting multiple instruction set architectures, comprising a microprocessor and a memory connected to each other, wherein the microprocessor is programmed or configured to execute the steps of the program running method supporting multiple instruction set architectures.

[0026] In addition, the present invention also provides a computer-readable storage medium, which stores a computer program programmed or configured to execute the program running method supporting multiple instruction set architecture.

[0027] Compared with the prior art, the present invention has the following advantages:

[0028] 1. Binary program compatibility can be achieved without binary translation, and the correctness and speed of program execution are guaranteed. The present invention proposes a method for implementing a multi-instruction set architecture, which supports multiple instruction set architectures at the same time in user mode. Binary application programs compatible with any supported instruction set architecture specification can be directly executed, and binary program compatibility can be achieved without binary translation. Since there is no need for software transplantation, the binary program does not need to be translated and runs directly on the processor. There are no execution errors and slow execution speeds that may be caused by the transplantation or translation process, so the correctness and speed of program execution are guaranteed.

[0029] 2. The hardware implementation overhead of the processor based on the multi-instruction set architecture is low. The implementation method of the multi-instruction set architecture proposed in the present invention redefines a multi-instruction set architecture based on the multiple instruction sets to be supported. This architecture does not support each instruction set architecture in full stack, but supports multiple instruction set architectures in user mode, and only supports one of the multiple instruction set architectures supported by the user mode in the privileged mode and the super-privileged mode. The hardware implementation overhead of the processor based on the multi-instruction set architecture is low. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 Schematic diagram of the basic flow of the method of the embodiment of the present invention.

[0031] Figure 2 Schematic diagram of implementation steps of an embodiment of the present invention.

[0032] Figure 3 Schematic diagram of a system architecture supporting a multiple instruction set architecture in an embodiment of the present invention.

[0033] Figure 4 The following is a schematic diagram of a simplified system architecture in an embodiment of the present invention.

[0034] Figure 5 This is a definition diagram of the processor status register in the RISC-V execution state in an embodiment of the present invention.

[0035] Figure 6 The figure is a schematic diagram of a simplified program running flow in an embodiment of the present invention. DETAILED DESCRIPTION

[0036] like Figure 1 As shown, the program running method supporting the multi-instruction set architecture (mArch for short) in this embodiment includes:

[0037] 1) After power-on reset, the processor status register is reset to the encoding corresponding to the default instruction set architecture; see Figure 1 In this embodiment, the various instruction set architectures are Arch_1, Arch_2, ..., Arch_N, where N>1; the default instruction set architecture is Arch_n, and the encoding corresponding to the default instruction set architecture is n-1.

[0038] 2) Start fetching instructions from the address specified by the reset address register defined by the default instruction set architecture;

[0039] 3) using instructions in a default instruction set architecture to respectively set control registers and configuration registers defined by a specification of the default instruction set architecture;

[0040] 4) When a binary application needs to be executed, load the binary application to be executed;

[0041] 5) setting the processor state backup register according to the instruction set architecture on which the binary application is based;

[0042] 6) Execute the exception return instruction to read the value of the processor state backup register to set the processor state register and enter the user state, and execute the binary application that needs to be executed; when the binary application is executed or an application switch occurs, the processor leaves the user state; jump to execute step 4).

[0043] like Figure 2As shown, before implementing the method of this embodiment, first determine the N instruction set architectures to be supported, namely Arch_1, Arch_2, ..., Arch_N, where N>1; in the super-privileged state and privileged state, only one of the N instruction set architectures is supported, which can be any one of Arch_1, Arch_2, ..., Arch_N, that is, Arch_n in step 1) of this embodiment, where Arch_n∈{Arch_1, Arch_2, ..., Arch_N}, and in the user state, all N instruction set architectures are supported. In the user state, each instruction set architecture in the multi-instruction set architecture mArc follows its own application-level architecture specification; in the super-privileged state and privileged state, the multi-instruction set architecture mArc follows the system-level architecture specification of Arch_n. Afterwards, it is necessary to further map the user-state visible states of the N instruction set architectures, and use the control registers of Arch_n in the super-privileged state and privileged state to control the behavior of each instruction set architecture in the user state. Therefore, before executing the binary application to be executed in step 6) of this embodiment, it also includes mapping the user-visible states of N instruction set architectures, and using the control registers of the super-privileged state and privileged state of the Arch_n instruction set architecture to control the behavior of each instruction set architecture in user mode.

[0044] like Figure 3As shown, the default instruction set architecture in this embodiment refers to the instruction set architecture adopted by the super privileged state layer and the privileged state layer. The super privileged state layer runs a virtual machine monitor based on the default instruction set architecture (Hypervisior in the figure), and the privileged state layer is the privileged layer in the client operating system (Guest OS in the figure) based on the default instruction set architecture on the virtual machine monitor. The user layer of the guest operating system supports binary applications of multiple instruction set architectures including the default instruction set architecture (Arch_1_APP1~Arch_n_APP1 in the figure are binary applications of n instruction set architectures on the guest operating system Guest OS1 respectively). ABI_Arch_1 includes the instruction set of Arch_1 visible in user mode and a group of system calls dealing with the operating system, ABI_Arch_2 includes the instruction set of Arch_2 visible in user mode and a group of system calls dealing with the operating system, and so on, ABI_Arch_N includes the instruction set of Arch_N visible in user mode and a group of system calls dealing with the operating system. Any binary application compatible with the Arch_i (Arch_i∈{Arch_1, Arch_2, …, Arch_N}) instruction set architecture specification can be executed in user mode on a mAch-based processor without modification. In particular, in this embodiment, the multi-instruction set architecture mAch defines a processor state register that indicates the instruction set architecture of the processor currently running. Since there are N instruction set architectures, log 2The N-bit field indicates that the processor is running in the Arch_(i+1) instruction set architecture. When the value of this field is i, it means that the processor is running in the Arch_(i+1) instruction set architecture. In the super-privileged state and privileged state, the instruction set architecture can only be Arch_n, so the value of this field can only be n-1, and any other value is illegal. The instruction set architecture can only be switched when an exception occurs to leave the user state or an exception returns to the user state. Specifically, when an exception occurs to enter the privileged state or super-privileged state, the instruction set architecture must become Arch_n; when the exception returns to the user state, the instruction set architecture can remain Arch_n unchanged, or it can become any of the other N-1 instruction set architectures except Arch_n; if the exception returns to the privileged state or super-privileged state, then the instruction set architecture must remain Arch_n unchanged. In order to correctly return to the application where the exception occurred after handling the exception, the multi-instruction set architecture mArc also defines a processor state backup register. When an exception occurs, the processor hardware saves the contents of the current processor state register to the processor state backup register, sets the value of the processor state register to n-1, and then enters the exception handler; when the exception returns, the processor state register is restored using the value of the processor state backup register. Since the value of the processor state backup register is written to the processor state register when the exception returns, the instruction set architecture of the processor runtime after entering the user state is consistent with the instruction set architecture based on the loaded binary application, so that the loaded binary application can run correctly.

[0045] In this embodiment, Armv8 AArch64 (i.e., Arm's pure 64-bit Armv8 architecture) and RISC-V (i.e., the RISC-V open source instruction set architecture) are used as examples to further describe the implementation process of the embodiment of the present invention. Based on the above embodiments, it can be seen that the default instruction set architecture in this simplified example is the Armv8 AArch64 instruction set architecture; the multi-instruction set architecture includes the Armv8 AArch64 instruction set architecture and the RISC-V instruction set architecture. For ease of description, we refer to this multi-instruction set architecture as ArmRV. When the instruction set architecture of the processor is Armv8AArch64, we say that the processor is running in the Arm execution state. When the instruction set architecture of the processor is RISC-V, we say that the processor is running in the RV execution state.

[0046] In this simplified example, only the Armv8 AArch64 instruction set architecture is supported in the super-privileged state and privileged state, and both the Armv8 AArch64 instruction set architecture and the RISC-V instruction set architecture are supported in the user state. The switch between the Arm and RV execution states can only occur when an exception occurs or an exception return occurs. When an exception occurs and enters the super-privileged state or privileged state, the execution state must be changed to Arm; when the exception returns to the user state, the Arm execution state can remain unchanged or change to the RV execution state, but if it returns to the super-privileged state or privileged state, the Arm execution state must remain unchanged, otherwise an illegal exception return is reported.

[0047] like Figure 4 As shown in the figure, RV_APP1~Arm_APP1 are binary applications of two instruction set architectures on the client operating system Guest OS1. RV_APP2~Arm_APP2 are binary applications of two instruction set architectures on the client operating system Guest OS2. ABI_RV is the user-mode execution environment of the RISC-V instruction set architecture, ABI_Arm is the user-mode execution environment of the Armv8 AArch64 instruction set architecture, SBI_Arm is the privileged execution environment of the Armv8 AArch64 instruction set architecture, and HBI_Arm is the super-privileged execution environment of the Armv8 AArch64 instruction set architecture. ABI_RV contains the RISC-V instruction set visible in user mode and a set of system calls that interact with the operating system, while ABI_Arm contains the Armv8 AArch64 instruction set visible in user mode and a set of system calls that interact with the operating system. Any binary application compatible with the Armv8 AArch64 architecture specification or compatible with the RISC-V architecture specification can be executed in the user mode of ArmRV without modification.

[0048] In this simplified example, under the Armv8 AArch64 instruction set architecture, the aforementioned processor state register refers to the processor state register PSTATE defined in the specification of the Armv8 AArch64 instruction set architecture, and the fifth bit PSTATE[4] of the processor state register PSTATE indicates the instruction set architecture type, which is 0 for the Armv8 AArch64 instruction set architecture and the processor runs in the Arm execution state, and 1 for the RISC-V instruction set architecture and the processor runs in the RV execution state. The definition of PSTATE under the Arm instruction set architecture follows the Armv8 AArch64 architecture specification, and its field meanings and access methods are consistent with those of PSTATE in the Armv8 AArch64 architecture, which will not be described in detail in the present invention; there is no user-visible processor state register in the RISC-V architecture, and the definition of the processor state register in the RV execution state in ArmRV is as follows: Figure 5 As shown, the processor status register has a total of 32 bits, including the privilege level, instruction set architecture type, debug and interrupt mask bits, and multiple reserved zero fields, which are specifically defined as follows:

[0049] [31:10]: RES0 (reserved 0, that is, the read value is always all zeros, and the write is ignored);

[0050] [9:6]: DAIF, debug and interrupt mask bit. The meaning of this field in RV execution state is consistent with that in Arm execution state, but it cannot be explicitly read and written by application instructions based on RV instruction set architecture in user mode.

[0051] [5]:RES0;

[0052] [4]: 1'b1, indicating that the instruction set architecture of the processor is RV;

[0053] [3:2]: 2'b00, indicating that the processor is in user mode, and other values ​​are illegal. An exception return will generate an illegal exception return when attempting to write 1 to [4] of the processor status register and a non-zero value to [3:2];

[0054] [1:0]:RES0.

[0055] In this simplified example, the processor state backup register in step 5) refers to the processor state backup register SPSR defined in the specification under the Armv8 AArch64 instruction set architecture. The Armv8 AArch64 architecture defines the processor state backup register (SPSR, Saved Program Status Register) for the privileged state and the super-privileged state respectively. ArmRV uses the SPSR register to save and restore the processor state when an exception occurs and an exception return occurs. Since the SPSR register belongs to the scope defined by the Armv8 AArch64 system-level architecture specification, the Armv8 AArch64 architecture specification is fully followed in ArmRV, and this simplified example will not be repeated. In user mode, each execution state in ArmRV follows its own application-level architecture specification, that is, Arm follows the Armv8 AArch64 application-level architecture specification, and RV follows the RISC-V application-level architecture specification, which will not be repeated in this simplified example; in the super-privileged state and privileged state, ArmRV follows the Armv8 AArch64 system-level architecture specification, which will not be repeated in this simplified example.

[0056] In this simplified example, when the user-visible states of the Armv8 AArch64 instruction set architecture and the RISC-V instruction set architecture are mapped, the registers corresponding to the user-visible states of the Armv8 AArch64 instruction set architecture and the RISC-V instruction set architecture include integer registers, program counters PC, floating-point registers, and a series of system registers; ArmRV maps these registers as follows:

[0057] The aforementioned integer registers refer to 32 64-bit integer registers defined by the Armv8 AArch64 instruction set architecture. The above 32 integer registers are accessed by both the Armv8 AArch64 instruction execution state and the RISC-V instruction execution state. These 32 integer registers are used in accordance with the Armv8 AArch64 architecture specification in the Armv8 AArch64 instruction execution state and in accordance with the RISC-V architecture specification in the RISC-V instruction execution state, including: in the Armv8AArch64 instruction execution state, register No. 31 is a zero-value register, and the read value is always all zero, and the write to this register is ignored, while in the RISC-V instruction execution state, register No. 0 is a zero-value register; in the Armv8 AArch64 instruction execution state, register No. 30 is used as a procedure call link register, while in the RISC-V instruction execution state, register No. 1 is used as a procedure call link register, and register No. 5 is used as an alternative link register; in the Armv8 In the AArch64 instruction execution state, there is a dedicated stack pointer register, while in the RISC-V instruction execution state, there is no dedicated stack pointer register, but the integer register No. 2 is used as the stack pointer register; in both execution states, the integer register can be accessed as both a 64-bit register and a 32-bit register; when accessed as a 32-bit register, the data is stored in the lower 32 bits of the 64-bit register, and the value of the upper 32-bit data depends on the execution state. In the Armv8 AArch64 instruction execution state, the upper 32 bits are always written to 0, while in the RISC-V instruction execution state, the upper 32 bits are written to the sign bit of the lower 32-bit data;

[0058] The program counter PC refers to a 64-bit program counter PC (Program Counter) defined by the Armv8 AArch64 instruction set architecture. The 64-bit program counter PC is accessed by both the Armv8 AArch64 instruction execution state and the RISC-V instruction execution state. According to the Armv8 AArch64 instruction set architecture specification and the RISC-V instruction set architecture specification, in two execution states: instructions cannot explicitly write the program counter PC, and the program counter PC is only implicitly modified when executing branch instructions, exception entry, and exception return, but instructions can directly read the program counter PC as a source operand;

[0059] Floating-point registers refer to 32 128-bit floating-point / vector registers defined by the Armv8 AArch64 instruction set architecture. They are accessed by both the Armv8 AArch64 instruction execution state and the RISC-V instruction execution state. These 32 floating-point / vector registers are used in accordance with the Armv8 AArch64 architecture specification in the Armv8 AArch64 instruction execution state and in accordance with the RISC-V instruction set architecture specification in the RISC-V instruction execution state, including: In the AArch64 instruction execution state, the data stored in each floating-point / vector register can be a 32-bit single-precision floating-point scalar, a 64-bit double-precision floating-point scalar, a 64-bit vector, or a 128-bit vector. The 32-bit single-precision floating-point scalar data is stored in the lower 32 bits of the 128-bit register, and the upper 96 bits are written to 0. The 64-bit double-precision floating-point scalar data is stored in the lower 64 bits of the 128-bit register, and the upper 64 bits are written to 0. The 64-bit vector data is stored in the lower 64 bits of the 128-bit register, and the upper 64 bits are written to 0. In RIS In the F extended instruction set in the C-V instruction execution state, 32-bit single-precision floating-point data is stored in the lower 32 bits of the 128-bit floating-point / vector register. When the [63:32] bits of the floating-point / vector register are written, they are always written as all 1s, and when the upper 64 bits of the floating-point / vector register are written, they are always written as all 0s. In the D extended instruction set in the RISC-V instruction execution state, 64-bit double-precision floating-point data is stored in the lower 64 bits of the 128-bit floating-point / vector register. When the upper 64 bits of the floating-point / vector register are written, they are always written as all 0s.

[0060] The aforementioned series of system registers include: system registers visible in user mode under the Armv8 AArch64 instruction set architecture, including: floating-point status register FPSR and floating-point control register FPCR, cache ID registers CTR_EL0 and DCZID_EL0, debug registers MDCCSR_EL0, DBGDTR_EL0, DBGDTRRX_EL0 and DBGDTRTX_EL0, a group of performance monitoring registers, a group of behavior monitoring registers, thread ID registers TPIDR_EL0 and TPIDRRO_EL0, and a group of timer registers; system registers visible in user mode under the RISC-V instruction set architecture, including: floating-point status and control register fcsr, floating-point cumulative exception flag register fflags, floating-point rounding mode register frm, and a group of read-only performance counters, wherein a group of read-only performance counters includes a clock cycle counter cycle, a timer counter time, a submitted instruction number counter instret, and 29 performance monitoring counters hpmcounter3 to hpmcounter31. Among them, the floating point status and control register fcsr contains two fields fflags and frm, fflags and frm can also be accessed separately by instructions. The ArmRV architecture maps fflags in the RV execution state to the corresponding field of FPSR in the Arm execution state, and maps frm in the RV execution state to the corresponding field of FPCR in the Arm execution state. The specific definition is: Among them, frm is a field of fcsr, occupying fcsr[7:5], frm[2:0] / fcsr[7:5] is mapped to {{FPCR

[31] , FPCR[23:22]} in the Arm execution state; fflags is a field of fcsr, occupying fcs r[4:0], fflags[0] / fcsr[0] is mapped to FPSR[4] in the Arm execution state, fflags[1] / fcsr[1] is mapped to FPSR[3] in the Arm execution state, fflags[2] / fcsr[2] is mapped to FPSR[2] in the Arm execution state, fflags[3] / fcsr[3] is mapped to FPSR[1] in the Arm execution state, and fflags[4] / fcsr[4] is mapped to FPSR[0] in the Arm execution state. The cycle register is a 64-bit read-only register, mapped to the PMCCNTR_EL0 register in the Arm execution state. The difference is that PMCCNTR_EL0 is readable and writable in the Arm execution state, but writing the cycle register in the RV execution state will report an abnormal instruction exception.The time register is a 64-bit read-only register, which is mapped to the CNTPCT_EL0 register in the Arm execution state. CNTPCT_EL0 is also read-only in the Arm execution state. Writing CNTPCT_EL0 in the Arm execution state and writing the time register in the RV execution state will report an abnormal instruction exception. The instret register is a 64-bit read-only register. There is no register with equivalent function in the Arm execution state, so ArmRV defines a 64-bit read-only register instret for the RV execution state to record the number of instructions submitted during processor execution. The performance monitoring counters hpmcounter3~hpmcounter31 are all 64-bit registers, which are mapped one-to-one with PMEVCNTR0_EL0~PMEVCNTR28_EL0 in the Arm execution state. If the Arm execution state implements the Armv8.5-PMU attribute, then PMEVCNTR0_EL0~PMEVCNTR28_EL0 in the Arm execution state are all 64-bit and can be directly mapped. The difference is that PMEVCNTR0_EL0~PMEVCNTR28_EL0 are readable and writable in the Arm execution state, but writing hpmcounter3~hpmcounter31 registers in the RV execution state will report an abnormal instruction exception. If the Arm execution state does not implement the Armv8.5-PMU attribute, then PMEVCNTR0_EL0~PMEVCNTR28_EL0 in the Arm execution state are all 32-bit. At this time, PMEVCNTR0_EL0~PMEVCNTR28_EL0 in the Arm execution state are mapped to the lower 32 bits of hpmcounter3~hpmcounter31 in the RV execution state.

[0061] When using the control registers of the super-privileged state and privileged state of Armv8 AArch64 to control the behavior of the Arm instruction set architecture and the RV instruction set architecture in user mode, the user-mode program can execute the WFI instruction to put the processor into a low-power state when idling, and the processor will not leave the low-power state until it receives the WFI wake-up event. In the Arm execution state, according to the Armv8 AArch64 architecture specification, by configuring the relevant system registers of the privileged state or super-privileged state, the processor can be put into a privileged state or super-privileged state instead of a low-power state when the WFI instruction is executed in the user state. The ArmRV architecture stipulates that the behavior of WFI in the RV execution state is consistent with the behavior of WFI in the Arm execution state, that is, by configuring the relevant system registers of the privileged state or super-privileged state of Armv8 AArch64, the processor can be put into a privileged state or super-privileged state when the WFI instruction is executed in the user state. The behavior of unaligned access in Armv8 AArch64 can be configured through the system registers of the privileged state or super-privileged state, which can be configured to generate an exception or not, while access to unaligned addresses in RISC-V will definitely generate an exception. The ArmRV architecture specifies that the configuration of system registers is ignored in the RV execution state, and access to non-aligned addresses always generates exceptions. In Armv8 AArch64, application access to specific storage areas is restricted by page table attributes, and in RISC-V, application access to specific storage areas is restricted by PMP (Physical Memory Protection). Both methods are set and managed by privileged or super-privileged states. Since ArmRV only allows support for RISC-V architecture in user state, in ArmRV, when user state runs in the RV instruction set architecture, it follows the Armv8 AArch64 architecture specification and restricts application access to specific storage areas through page table attributes. The byte order for data access and instruction access in Armv8 AArch64 and RISC-V is the same, that is, data access supports both big-endian and little-endian byte orders, and instruction access only supports little-endian byte order. The registers that control the byte order of data access are located above the user state. Therefore, ArmRV follows the Armv8 AArch64 architecture specification, and the byte order of data access is controlled by the relevant registers in the privileged state and super-privileged state in Armv8AArch64.

[0062] like Figure 6 As shown, the program running process in this simplified example is:

[0063] 1) Power-on reset, PSTATE[4] is reset to 1'b0, indicating that the processor enters the Arm execution state after power-on reset;

[0064] 2) Start fetching instructions from the address specified by the reset address register RVBAR (Reset VectorBase Address Register) defined by the Armv8 AArch64 instruction set architecture;

[0065] 3) Use instructions in the Armv8 AArch64 instruction set architecture to set control registers and configuration registers defined by the Armv8 AArch64 system-level architecture specification;

[0066] 4) Load the binary application to be executed;

[0067] 5) Set the processor state backup register SPSR according to the instruction set architecture type based on the binary application. If it is Armv8 AArch64, set SPSR[4] to 1'b0 (indicating Arm execution state) and SPSR[3:2] to 2'b00 (indicating user state). If it is RISC-V, set SPSR[4] to 1'b1 (indicating RV execution state) and SPSR[3:2] to 2'b00 (indicating user state).

[0068] 6) Execute the exception return instruction to read the value of SPSR, set PSTATE and enter the user state to execute the binary application. Since the value of SPSR is written to PSTATE when the exception is returned, the processor runtime instruction set architecture indicated by PSTATE after entering the user state is consistent with the instruction set architecture based on the loaded binary application, so the loaded binary application can run correctly.

[0069] In summary, the method of this embodiment is a method for implementing a multi-instruction set architecture that can achieve binary program compatibility without binary translation. It supports multiple instruction set architectures in user mode, but only supports one instruction set architecture in privileged and super-privileged modes. A processor based on this multi-instruction set architecture can execute binary applications developed based on different instruction set architectures. There is no need for software porting, and the binary program does not need to be translated. It runs directly on the processor, and there are no problems such as execution errors and slow execution speed that may be caused by the translation process. The method of this embodiment redefines a multi-instruction set architecture based on the multiple instruction sets to be supported. It does not require full stack support for each instruction set architecture. It only supports multiple instruction set architectures in user mode, and the processor hardware implementation overhead is small.

[0070] In addition, this embodiment also provides a computer device that supports multiple instruction set architectures, wherein the computer device includes a virtual machine monitor executable environment HEE, a virtual machine monitor Hypervisor, and at least one virtual machine, wherein a client operating system Guest OS runs in the virtual machine, and the virtual machine computer device is programmed or configured to execute the steps of the program running method that supports multiple instruction set architectures.

[0071] In addition, this embodiment also provides a program running system supporting multiple instruction set architectures, including a microprocessor and a memory connected to each other, wherein the microprocessor is programmed or configured to execute the steps of the program running method supporting multiple instruction set architectures.

[0072] In addition, this embodiment also provides a computer-readable storage medium, which stores a computer program programmed or configured to execute the aforementioned program running method supporting a multiple instruction set architecture.

[0073] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes. The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, may be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the functions in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or boxes Figure 1These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0074] The above is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should also be regarded as the protection scope of the present invention.

Claims

1. A method for running a program supporting a multiple instruction set architecture, characterized in that: include: 1) After power-on reset, the processor status register is reset to the encoding corresponding to the default instruction set architecture; 2) Start fetching instructions from the address specified by the reset address register defined by the default instruction set architecture; 3) using instructions in the default instruction set architecture to respectively set control registers and configuration registers defined by the specification of the default instruction set architecture; 4) When a binary application needs to be executed, load the binary application to be executed; 5) setting the processor state backup registers according to the instruction set architecture on which the binary application is based; 6) Execute the exception return instruction to read the value of the processor status backup register to set the processor status register and enter the user state to execute the binary application that needs to be executed; When the binary application finishes executing or an application switch occurs, the processor leaves the user state; Jump to step 4); The default instruction set architecture refers to the instruction set architecture adopted by the super privileged state layer and the privileged state layer, the super privileged state layer runs a virtual machine monitor based on the default instruction set architecture, the privileged state layer is a privileged layer in a client operating system based on the default instruction set architecture on the virtual machine monitor, and the user layer of the client operating system supports binary applications of multiple instruction set architectures including the default instruction set architecture; the default instruction set architecture is the Armv8 AArch64 instruction set architecture; the multiple instruction set architectures include the Armv8 AArch64 instruction set architecture and the RISC-V instruction set architecture; The processor state backup register in step 5) refers to the processor state backup register SPSR defined in the specification under the Armv8 AArch64 instruction set architecture; Before executing the binary application to be executed in step 6), the user-mode visible states of the Armv8 AArch64 instruction set architecture and the RISC-V instruction set architecture are mapped, and the control registers of the super-privileged state and the privileged state of the Armv8 AArch64 instruction set architecture are used to control the behavior of the Armv8 AArch64 instruction set architecture and the RISC-V instruction set architecture in the user mode.

2. The method for running a program supporting a multiple instruction set architecture according to claim 1, characterized in that: Under the Armv8 AArch64 instruction set architecture, the processor state register refers to the processor state register PSTATE defined by the specification of the Armv8 AArch64 instruction set architecture, and the fifth bit PSTATE[4] of the processor state register PSTATE indicates the instruction set architecture type, which is 0 for the Armv8 AArch64 instruction set architecture and the processor runs in the Armv8 AArch64 execution state, and is 1 for the RISC-V instruction set architecture and the processor runs in the RISC-V execution state; under the RISC-V instruction set architecture, the fields of the processor state register include privilege level, instruction set architecture type, debug and interrupt mask bits, and multiple reserved zero fields.

3. The method for running a program supporting a multiple instruction set architecture according to claim 2, characterized in that: When mapping the user-state visible states of the Armv8 AArch64 instruction set architecture and the RISC-V instruction set architecture, the registers corresponding to the user-state visible states of the Armv8 AArch64 instruction set architecture and the RISC-V instruction set architecture include integer registers, program counters PC, floating-point registers, and a series of system registers; The integer registers refer to 32 64-bit integer registers defined by the Armv8 AArch64 instruction set architecture. The above 32 64-bit integer registers are accessed by both the Armv8 AArch64 instruction execution state and the RISC-V instruction execution state. These 32 64-bit integer registers are used in accordance with the Armv8 AArch64 architecture specification in the Armv8 AArch64 instruction execution state and in accordance with the RISC-V architecture specification in the RISC-V instruction execution state, including: in the Armv8AArch64 instruction execution state, register No. 31 is a zero-value register, and the read value is always all zero, and the write to the register is ignored, while in the RISC-V instruction execution state, register No. 0 is a zero-value register; in the Armv8 AArch64 instruction execution state, register No. 30 is used as a procedure call link register, and in the RISC-V instruction execution state, register No. 1 is used for the procedure call link register, and register No. 5 is used as an alternative link register; in the Armv8 In the AArch64 instruction execution state, there is a dedicated stack pointer register, while in the RISC-V instruction execution state, there is no dedicated stack pointer register, but the integer register No. 2 is used as the stack pointer register; in both execution states, the integer register can be accessed as both a 64-bit register and a 32-bit register; when accessed as a 32-bit register, the data is stored in the lower 32 bits of the 64-bit register, and the value of the upper 32-bit data depends on the execution state. In the Armv8 AArch64 instruction execution state, the upper 32 bits are always written to 0, while in the RISC-V instruction execution state, the upper 32 bits are written to the sign bit of the lower 32-bit data; Program counter PC refers to a 64-bit program counter PC defined by the Armv8 AArch64 instruction set architecture. The 64-bit program counter PC is accessed by both the Armv8 AArch64 instruction execution state and the RISC-V instruction execution state. According to the Armv8 AArch64 instruction set architecture specification and the RISC-V instruction set architecture specification, in two execution states: instructions cannot explicitly write the program counter PC, and the program counter PC is only implicitly modified when executing branch instructions, exception entry, and exception return, but instructions can directly read the program counter PC as a source operand; Floating-point registers refer to 32 128-bit floating-point / vector registers defined by the Armv8 AArch64 instruction set architecture. They are accessed by both the Armv8 AArch64 instruction execution state and the RISC-V instruction execution state. These 32 floating-point / vector registers are used in accordance with the Armv8 AArch64 architecture specification in the Armv8 AArch64 instruction execution state and in accordance with the RISC-V instruction set architecture specification in the RISC-V instruction execution state, including: In the AArch64 instruction execution state, the data stored in each floating-point / vector register can be a 32-bit single-precision floating-point scalar, a 64-bit double-precision floating-point scalar, a 64-bit vector, or a 128-bit vector. The 32-bit single-precision floating-point scalar data is stored in the lower 32 bits of the 128-bit register, and the upper 96 bits are written to 0. The 64-bit double-precision floating-point scalar data is stored in the lower 64 bits of the 128-bit register, and the upper 64 bits are written to 0. The 64-bit vector data is stored in the lower 64 bits of the 128-bit register, and the upper 64 bits are written to 0. In RIS In the F extended instruction set in the C-V instruction execution state, 32-bit single-precision floating-point data is stored in the lower 32 bits of the 128-bit floating-point / vector register. When the [63:32] bits of the floating-point / vector register are written, they are always written as all 1s, and when the upper 64 bits of the floating-point / vector register are written, they are always written as all 0s. In the D extended instruction set in the RISC-V instruction execution state, 64-bit double-precision floating-point data is stored in the lower 64 bits of the 128-bit floating-point / vector register. When the upper 64 bits of the floating-point / vector register are written, they are always written as all 0s. The series of system registers include: system registers visible in user mode under the Armv8 AArch64 instruction set architecture, including: floating-point status register FPSR and floating-point control register FPCR, cache ID registers CTR_EL0 and DCZID_EL0, debug registers MDCCSR_EL0, DBGDTR_EL0, DBGDTRRX_EL0 and DBGDTRTX_EL0, a group of performance monitoring registers, a group of behavior monitoring registers, thread ID registers TPIDR_EL0 and TPIDRRO_EL0, and a group of timer registers; system registers visible in user mode under the RISC-V instruction set architecture, including: floating-point status and control register fcsr, floating-point cumulative exception flag register fflags, floating-point rounding mode register frm, and a group of read-only performance counters, wherein the group of read-only performance counters includes a clock cycle counter cycle, a timer counter time, a submitted instruction number counter instret, and 29 performance monitoring counters hpmcounter3~hpmcounter31.

4. A computer device supporting a multiple instruction set architecture, the computer device comprising a virtual machine monitor executable environment HEE, a virtual machine monitor Hypervisor and at least one virtual machine, wherein a guest operating system Guest OS runs in the virtual machine, characterized in that: The virtual machine computer device is programmed or configured to execute the steps of the program running method supporting multiple instruction set architectures as claimed in any one of claims 1 to 3.

5. A program execution system supporting a multiple instruction set architecture, comprising a microprocessor and a memory connected to each other, characterized in that: The microprocessor is programmed or configured to execute the steps of the program running method supporting multiple instruction set architectures as claimed in any one of claims 1 to 3.

6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program that is programmed or configured to execute the program running method supporting multiple instruction set architectures as described in any one of claims 1 to 3.