Spinning lock unlocking method, spinning lock device, electronic equipment and storage medium

The spin lock unlocking method and device use a random number generator and one-time programmable memory to secure state transitions, addressing issues of abnormal state jumps and enhancing security in high-security environments.

CN119167445APending Publication Date: 2024-12-20YAOYAO
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411188272.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-28
Publication Date
2024-12-20

AI Technical Summary

Technical Problem

Conventional spin locks in high-security environments like automotive electronics are prone to abnormal state jumps due to subjective or non-subjective factors, such as malicious code or hardware failures, which compromise their security and reliability.

Method used

A spin lock unlocking method and device that incorporates a random number generator and a one-time programmable memory to generate and store unlocking keys, ensuring secure state transitions by using key attributes and redundancy to block subjective and non-subjective factors.

Benefits of technology

Enhances the security and reliability of spin locks by suppressing non-subjective factors and blocking unauthorized access, thereby achieving high-security state transitions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119167445A_ABST
    Figure CN119167445A_ABST
Patent Text Reader

Abstract

The invention provides a spin lock protection method, comprising: acquiring a target unlocking demand, the target unlocking demand comprising a lock code of a target to-be-used lock; an unlocking secret key of the target to-be-used lock is obtained, the unlocking secret key is written into a register corresponding to the lock code, and the unlocking secret key comprises secret key attributes and a random number secret key; and obtaining an unlocking result of the target to-be-used lock, wherein the unlocking result comprises unlocking success and unlocking failure. According to the method, non-subjective factors are inhibited by increasing the redundancy of the state transition condition, and subjective factors are blocked by enabling the state transition condition to have the key attribute. Therefore, the hardware spin lock with high safety can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of spin lock unlocking, and in particular to a spin lock unlocking method, a spin lock device, an electronic device and a storage medium. Background Art

[0002] Spin lock is a synchronization mechanism used to protect shared resources. In multithreaded programming, when multiple threads access a shared resource at the same time, in order to avoid competition and hazard problems, a synchronization mechanism is needed to ensure that only one thread can access the resource at a time.

[0003] Spin lock is a type of busy-wait lock, that is, when a thread is acquiring a lock, if the lock has been acquired by another thread, the thread will wait in a loop, and then constantly determine whether the lock can be successfully acquired, and will not exit the loop until the lock is acquired. Implementing spin locks through hardware can improve system performance and make lock operations more efficient.

[0004] In the current conventional technical field, taking the spin lock in TI's TDA4 chip as an example, the module implements a total of 256 locks, and the operation of each lock can be completed with only one instruction (read or write a register), avoiding the read-modify-write operation during software implementation and improving efficiency. For each lock, it only receives one instruction (read or write) at a time, and can only accept the next one after completing the command. The lock is not occupied (Not Taken) after reset. If the lock is read and returns 0, it means that the current lock is not occupied and the lock is successfully acquired (Taken); if the lock is read and returns 1, it means that the current lock is occupied and the lock acquisition fails. To unlock, just write 0 to the occupied lock. For scenarios with high functional safety and high information security requirements such as automotive electronics, since the state transfer of the lock only requires reading and writing 0 or 1 to complete, this hardware lock is prone to abnormal state jumps due to subjective or non-subjective factors. Subjective factors refer to malicious code actively locking or unlocking spin locks being used by other threads; non-subjective factors refer to incorrect operations on the corresponding registers of the spin lock due to code bugs (systematic failures) or hardware transient failures (random failures).

[0005] Therefore, there is a need for a hardware lock that can suppress non-subjective factors and block subjective factors by using secret key attributes, thereby achieving high-security. Summary of the invention

[0006] In view of this, the embodiments of the present disclosure provide a spin lock unlocking method, a spin lock device, an electronic device and a storage medium, which at least partially solve the problems existing in the prior art, can increase the redundancy of the state transition conditions to suppress non-subjective factors, and block subjective factors by making the state transition conditions have key attributes. Thus, a highly secure hardware spin lock can be realized.

[0007] On the one hand, the present embodiment discloses a spin lock unlocking method, characterized in that it includes: obtaining a target unlocking requirement, the target unlocking requirement includes a lock code of a target lock to be used; obtaining an unlocking key of the target lock to be used, and writing the unlocking key to a register corresponding to the lock code, the unlocking key including a key attribute and a random number key; obtaining an unlocking result of the target lock to be used, the unlocking result including an unlocking success and an unlocking failure.

[0008] Specifically, obtaining the unlocking result of the target lock to be used includes: when the target lock to be used is not locked and when the unlocking key is inconsistent with the locking key of the target lock to be used, the unlocking result is unlocking failure.

[0009] Specifically, the locking key of the target lock to be used is cleared, and the target lock to be used is unlocked, and the unlocking result is unlocking success.

[0010] Specifically, the unlocking key also includes a master key. When the unlocking key is inconsistent with the locking key, it is determined whether the unlocking key is a preset master key. If so, the target lock to be used is unlocked.

[0011] Specifically, before obtaining the target unlocking requirement, it also includes: obtaining a target locking requirement, the target locking requirement includes the lock code of the target lock to be used; based on the lock code of the target lock to be used, reading the register corresponding to the lock code; judging the usage status of the target lock to be used based on the register return value, wherein, when the register return value is 0, it is judged that the target lock to be used has been locked, and when the register return value is a non-zero value, it is judged that the target lock to be used is not locked, and the current target lock to be used is successfully locked.

[0012] Specifically, when the register return value is a non-zero value, the non-zero value is the unlocking key of the target lock to be used.

[0013] On the other hand, an embodiment of the present disclosure provides a spin lock device, including: a controller, a one-time programmable memory, a random number generator, and multiple locks; the controller is used to receive control commands from an external processor and perform locking, querying or unlocking operations based on the control commands; the random number generator is used to generate random numbers, and when the lock receives a locking command, a random number is obtained; the multiple locks exist in multiple channels and are used to execute commands such as locking and unlocking; the one-time programmable memory is used to store the universal key and send it to the controller when power is turned on.

[0014] Specifically, the random number generator also includes a PRNG pseudo-random number generator based on LFSR.

[0015] In a third aspect, an embodiment of the present disclosure further provides an electronic device, the electronic device comprising: at least one processor; and a memory in communication with the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions are executed by the at least one processor, so that the at least one processor can execute any one of claims 1 to 7. In a fourth aspect, an embodiment of the present disclosure further provides a non-transitory computer-readable storage medium, the non-transitory computer-readable storage medium stores computer instructions, the computer instructions are used to enable the computer to execute the spin lock unlocking method described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0017] Figure 1 A schematic diagram of a process for unlocking a spin lock in an embodiment of the present application;

[0018] Figure 2 This is a schematic diagram of a spin lock unlocking process in another embodiment of the present application;

[0019] Figure 3 A schematic diagram of a spin lock locking process in a spin lock unlocking method in an embodiment of the present application;

[0020] Figure 4 Schematic diagram of the structure of the spin lock device in this embodiment;

[0021] Figure 5 This is a schematic diagram of a state machine of a spin lock device in an embodiment of the present application;

[0022] Figure 6The connection method of the linear feedback shift register in the embodiment of the present application;

[0023] Figure 7 Another connection method of the linear feedback shift register in the embodiment of the present application;

[0024] Figure 8 A schematic diagram of a method or device 1000 that can implement an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0025] The embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.

[0026] The following describes the embodiments of the present disclosure through specific examples, and those skilled in the art can easily understand other advantages and effects of the present disclosure from the contents disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all of the embodiments. The present disclosure can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present disclosure. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present disclosure.

[0027] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein may be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on the present disclosure, it should be understood by those skilled in the art that an aspect described herein may be implemented independently of any other aspect, and two or more of these aspects may be combined in various ways. For example, any number of aspects described herein may be used to implement the device and / or practice the method. In addition, other structures and / or functionalities other than one or more of the aspects described herein may be used to implement this device and / or practice this method.

[0028] It should also be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present disclosure. The drawings only show components related to the present disclosure rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0029] Additionally, in the following description, specific details are provided to facilitate a thorough understanding of the examples. However, one skilled in the art will appreciate that aspects may be practiced without these specific details.

[0030] First, this embodiment discloses a spin lock unlocking method, which is characterized by comprising:

[0031] S101, obtaining a target unlocking requirement, wherein the target unlocking requirement includes a lock code of a target lock to be used;

[0032] In this embodiment, if Figure 1 , Figure 1 FIG. 1 is a flow chart of unlocking a spin lock in an embodiment of the present application. Figure 1 As shown, if you want to unlock the i-th lock through software, you need to obtain the corresponding i-code or an instruction that can specify the i-th lock.

[0033] S102, obtaining an unlocking key of the target lock to be used, and writing the unlocking key into a register corresponding to the lock code, wherein the unlocking key includes a key attribute and a random number key;

[0034] It can be understood that when the i-th lock needs to be unlocked, it is necessary to obtain the unlocking key of the i-th lock and write the key to the register. The key is obtained by concatenating the key attributes and the random number key. In this embodiment, the unlocking key is {1'bx, A}, where "1'bx" refers to the key attributes of the current key, such as whether the current key corresponds to the random number unlocking key, and A is the random number A[M-1], where M is the random number bit width.

[0035] S103, obtaining an unlocking result of the target lock to be used, wherein the unlocking result includes an unlocking success and an unlocking failure.

[0036] When the unlocking key is written to the register, the corresponding unlocking result will be obtained, and it can be judged whether the current unlocking is successful. Generally speaking, unlocking includes unlocking success, unlocking failure, or the current lock is not locked.

[0037] Specifically, obtaining the unlocking result of the target lock to be used includes: when the target lock to be used is not locked and when the unlocking key is inconsistent with the locking key of the target lock to be used, the unlocking result is unlocking failure.

[0038] In this embodiment, if the lock is not occupied, or an erroneous unlocking key is written, there will be no impact, that is, no result will be fed back, and the current unlocking result can be determined as unlocking failure.

[0039] Specifically, the locking key of the target lock to be used is cleared, and the target lock to be used is unlocked, and the unlocking result is unlocking success.

[0040] It is easy to understand that when the lock is locked and the unlocking key is the correct key, the lock will be successfully unlocked and the locking key of the lock will be cleared through hardware, at which point it can be determined that the unlocking is successful.

[0041] Specifically, the unlocking key also includes a master key. When the unlocking key is inconsistent with the locking key, it is determined whether the unlocking key is a preset master key. If so, the target lock to be used is unlocked.

[0042] It is easy to understand that the unlocking key can include a universal key in addition to the random number key. The key attributes of the current key also include random number key and universal key. When x=0, the unlocking key is a random number unlocking key. When x=1, the key is a universal key. That is to say, there are two types of unlocking. When (1'bx==0, A==key), the key attribute is a random number key, and the random number key is consistent, the lock can be unlocked. Or when (1'bx==1, A==universal key), the key attribute is a universal key, and the universal key is consistent, the lock can be successfully unlocked and the current key can be cleared.

[0043] It should be noted that this embodiment also has a mechanism to prevent ambiguity or error when the master key and the random key are the same. Therefore, assuming that the stored master key and the random number generated by the random number generator have a bit width of M bits, when locked, the lock will obtain a random number A[M-1:0] and splice a 0 in the highest bit as the key, that is, {1'b0,A[M-1]}. When unlocking with an ordinary random number key, {1'b0,A[M-1]} will be written to unlock; when unlocking with the master key A[M-1:0], a 1 will be spliced ​​in the highest bit as the key, that is, the key attribute is set, that is, {1'b1,A[M-1]} is written to unlock.

[0044] The redundancy of locking / unlocking can improve its ability to cope with random hardware failures. In addition to using the multi-bit pseudo-random numbers mentioned in the present invention, in fact, any multi-bit number can be used, for example, 0 can be replaced by 0xA5, and 1 can be replaced by 0x5A.

[0045] like Figure 2 , Figure 2This is a schematic diagram of the spin lock unlocking process in another embodiment of the present application. First, the software part reads the target unlocking requirement, that is, the lock code of the lock. In this embodiment, it is the i-th lock, and the lock code is lock_i. After reading the register, the existing unlocking key needs to be written into the register. When writing to the register, the register will determine whether the current lock is locked. If it is not locked, it will determine that the unlocking failed. If it is locked, first determine the key attribute of the key. If the key attribute is a random number key, determine whether the random number key is consistent. If the key attribute is not a random number key, determine whether the random key value is consistent with the universal key. If it is consistent, it can be unlocked and the lock key is cleared, and the lock is changed to an unlocked state, and the unlocking is successful. If they are all inconsistent, the unlocking fails.

[0046] Specifically, before obtaining the target unlocking requirement, it also includes: obtaining a target locking requirement, the target locking requirement includes the lock code of the target lock to be used; based on the lock code of the target lock to be used, reading the register corresponding to the lock code; judging the usage status of the target lock to be used based on the register return value, wherein, when the register return value is 0, it is judged that the target lock to be used has been locked, and when the register return value is a non-zero value, it is judged that the target lock to be used is not locked, and the current target lock to be used is successfully locked.

[0047] In this embodiment, in addition to unlocking the lock, it also includes locking the lock. First, it is necessary to obtain the locking requirement for the target lock, that is, if the i-th lock needs to be locked, the lock code or corresponding instruction of the i-th lock needs to be obtained; then, the register return value will be used to determine the ready-to-use status of the current target lock to be used. It is easy to understand that the current lock may be unlocked or locked. Whenever the lock is unlocked, the target lock to be used can be locked and applied to subsequent use. If the current lock has been locked, it cannot be locked and cannot be used or the unlocking key of the lock cannot be obtained. In this embodiment, the return value of the register is used to determine whether the current lock has been used. When the return value is 0, it means that the lock has been occupied by other processes. In other embodiments, the return value can be other values. It only needs to be preset in advance and the status of the current lock can be determined; when a non-zero value is returned, it can be determined that the current lock is not locked, and the lock has been obtained, has been successfully locked, and can be used later.

[0048] Specifically, when the register return value is a non-zero value, the non-zero value is the unlocking key of the target lock to be used.

[0049] It is easy to understand that when the non-zero value is returned, the non-zero value can be used as an unlocking key to subsequently unlock the target lock to be used.

[0050] like Figure 3 , Figure 3 The following is a schematic diagram of the spin lock locking process in the spin lock locking method in the embodiment of the present application. First, the software part determines the start of the process through Start. At this time, the CPU reads the register corresponding to lock_i, that is, it obtains the lock code of the i-th lock, that is, lock_i. Then the register determines whether the current lock is locked and returns the corresponding value. If it is locked, it returns 0. If it is not locked, it returns the unlocking key. At this time, the unlocking key also needs to be requested from PRNG, that is, through a random number generator, and the requested unlocking key is used as the register return value. At this time, it is determined that the lock has been successfully locked and the unlocking key is returned.

[0051] On the other hand, an embodiment of the present disclosure provides a spin lock device, including: a controller, a one-time programmable memory, a random number generator, and multiple locks; the controller is used to receive control commands from an external processor and perform locking, querying or unlocking operations based on the control commands; the random number generator is used to generate random numbers, and when the lock receives a locking command, a random number is obtained; the multiple locks exist in multiple channels and are used to execute commands such as locking and unlocking; the one-time programmable memory is used to store the universal key and send it to the controller when power is turned on.

[0052] like Figure 4 , Figure 4 It is a structural diagram of the spin lock device in this embodiment. The hardware structure of the hardware spin lock and its integration relationship in the SoC are shown in the figure. The spin lock is composed of a controller (Controller), a pseudo-random number generator (PRNG) based on LFSR and several channel locks. - The controller is used to accept the control command of the CPU and lock, query or unlock the corresponding lock; - The pseudo-random number generator is used to generate pseudo-random numbers. When a lock receives a lock command, it will apply for a random number from the PRNG; - The lock provides several channel locks inside a spin lock, which can execute the lock / unlock and other commands of the CPU. An OTP needs to be provided on the SoC to store a universal key. The key is delivered by the OTP control circuit when the chip is powered on and is a quasi-static signal.

[0053] like Figure 5 As shown, Figure 5 This is a schematic diagram of the state machine of the spin lock device in the embodiment of the present application. In the figure, the lock is not locked after being reset. At this time, the lock can be read to obtain the unlocking key and the lock state can be taken as the locked state. The locked lock will not be unlocked when reading or writing an incorrect unlocking key, but when the correct unlocking key is written, it can be unlocked and enter the unlocked state. When any value is written to the unlocked lock, the current lock state will not be changed.

[0054] The hardware structure of the present invention is basically similar to the implementation of TDA4. The biggest difference is that when the lock is successfully acquired, the return value is not 0, but a multi-bit (redundant) random number (key attribute), which can be used as a key for unlocking. If 0 is returned, it means that the lock is occupied. When unlocking is required, the corresponding key must be written, otherwise it cannot be unlocked.

[0055] Taking into account situations such as the unexpected termination of a thread, it is possible that the lock occupied by the thread cannot be unlocked by software due to the loss of the key, and the lock can only be reset. Therefore, a "master key" can be provided. The master key can be stored in the OTP (one-time programmable) area of ​​the chip, and its accessible range is determined by the SoC during integration to ensure that only recognized high-security modules (Supervisor, security island, hardware security module, etc.) can obtain the master key and unlock the abnormal hardware spin lock.

[0056] In order to generate random numbers, the hardware spin lock needs to be equipped with a random number generator. Considering the balance between implementation cost and protection capability, it is recommended to use a linear feedback shift register (LFSR) to implement a pseudo-random number generator. Of course, other random number generators can also be used.

[0057] Specifically, the random number generator also includes a PRNG pseudo-random number generator based on LFSR. In this embodiment, the linear feedback shift register mainly includes two categories: Galois (internal LFSR) and Fibonacci (external LFSR), respectively. Figure 6 and Figure 7 As shown, Figure 6 The connection method of the linear feedback shift register in the embodiment of the present application is as follows: Figure 7 Another connection mode of the linear feedback shift register in the embodiment of the present application; wherein gn is the feedback coefficient, which can only be 0 or 1. When it is 0, it indicates that the feedback path does not exist, and when it is 1, it indicates that the feedback path exists; the feedback coefficient here determines the difference in the algorithm for generating random numbers.

[0058] The feedback function can be expressed as y=a0x^0+a1x+a2x^2… If the feedback function is linear, it is called a linear shift feedback sequence, otherwise it is called a nonlinear feedback shift sequence.

[0059] Q1, Q2, Q3, Qn are the outputs of LFSR, M(x) is the input codeword polynomial, such as M(x) = x^4 + x^1 + 1, which means the input sequence of the input end is 11001. Similarly, the structure of LFSR can also be expressed as a polynomial G(x), called the generating polynomial:

[0060] G(x)=gn*x^n+…+g1*x^1+g0;

[0061] The present invention can adopt any structure without limitation.

[0062] In addition, since 0 cannot be used as the key to obtain the lock, the random number generator needs to filter out 0. Since the pseudo-random number generator implemented by LFSR does not generate 0, it naturally meets the requirement.

[0063] In a third aspect, an embodiment of the present disclosure further provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the spin lock unlocking method described in the first aspect above.

[0064] In a fourth aspect, an embodiment of the present disclosure further provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable the computer to execute the spin lock unlocking method described in the first aspect.

[0065] Figure 8 A schematic diagram of a method or device 1000 that can implement an embodiment of the present invention is shown, which may include more or fewer devices than shown in the figure in some embodiments. In some embodiments, it can be implemented using a single or multiple devices. In some embodiments, it can be implemented using cloud or distributed devices.

[0066] like Figure 8 As shown, the device 1000 includes a processor 1001, which can perform various appropriate operations and processes according to the program and / or data stored in the read-only memory (ROM) 1002 or the program and / or data loaded from the storage part 1008 to the random access memory (RAM) 1003. Processor 1001 can be a multi-core processor or can include multiple processors. In some embodiments, processor 1001 can include a general main processor and one or more special coprocessors, such as a central processing unit (CPU), a graphics processing unit (GPU), a neural network processor (NPU), a digital signal processor (DSP), etc. In RAM 1003, various programs and data required for the operation of device 1000 are also stored. Processor 1001, ROM 1002 and RAM 1003 are connected to each other via bus 1004. Input / output (I / O) interface 1005 is also connected to bus 1004.

[0067] The processor and the memory are used together to execute the program stored in the memory. When the program is executed by the computer, the methods, steps or functions described in the above embodiments can be implemented.

[0068] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, a touch screen, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage section 1008 as needed. Figure 5 Only some components are schematically shown, which does not mean that the device 1000 only includes Figure 8 Components shown.

[0069] The beneficial effects of the present invention are as follows: the present invention at least partially solves the problems existing in the prior art through a spin lock unlocking method, a spin lock device, an electronic device and a storage medium, can increase the redundancy of the state transition condition to suppress non-subjective factors, and can block subjective factors by making the state transition condition have a key attribute. Thus, a high-security hardware spin lock can be realized.

[0070] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0071] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0072] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0073] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to perform some steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (English: Read-Only Memory, abbreviated: ROM), random access memory (English: RandomAccess Memory, abbreviated: RAM), disk or optical disk and other media that can store program codes.

[0074] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0075] The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A spin lock unlocking method, characterized in that: include: Obtaining a target unlocking requirement, wherein the target unlocking requirement includes a lock code of a target lock to be used; Obtaining an unlocking key of the target lock to be used, and writing the unlocking key into a register corresponding to the lock code, wherein the unlocking key includes a key attribute and a random number key; Obtain an unlock result of the target lock to be used, wherein the unlock result includes unlock success and unlock failure.

2. The spin lock unlocking method according to claim 1, characterized in that: The unlocking result of obtaining the target lock to be used includes: When the target lock to be used is not locked and when the unlocking key is inconsistent with the locking key of the target lock to be used, the unlocking result is unlocking failure.

3. The spin lock unlocking method according to claim 2, characterized in that: The step of obtaining the unlocking result of the target lock to be used further includes: When the unlocking key is consistent with the locking key, the locking key of the target lock to be used is cleared, and the target lock to be used is unlocked, and the unlocking result is unlocking success.

4. The spin lock unlocking method according to claim 2, characterized in that: The unlocking key also includes a master key. When the unlocking key is inconsistent with the locking key, it is determined whether the unlocking key is a preset master key. If so, the target lock to be used is unlocked.

5. The spin lock unlocking method according to claim 1, characterized in that: The acquiring target unlocking requirement also includes: Obtaining a target locking requirement, wherein the target locking requirement includes a lock code of a lock to be used by the target; Based on the lock code of the target lock to be used, reading the register corresponding to the lock code; The usage status of the target lock to be used is determined based on the register return value, wherein: When the register return value is 0, it is determined that the target lock to be used has been locked. When the register return value is a non-zero value, it is determined that the target lock to be used has not been locked, and the current target lock to be used has been successfully locked.

6. The spin lock unlocking method according to claim 5, characterized in that: When the register return value is a non-zero value, the non-zero value is the unlocking key of the target lock to be used.

7. A spin lock device, characterized in that: The spin lock unlocking method applied to any one of claims 1 to 6, comprising: a controller, a one-time programmable memory, a random number generator, and a plurality of locks; The controller is used to receive a control command from an external processor and perform a locking, querying or unlocking operation based on the control command; The random number generator is used to generate a random number. When the lock receives a lock command, a random number is obtained; The multiple locks exist in multiple channels and are used to execute commands such as locking and unlocking; The one-time programmable memory is used to store the master key and send it to the controller when powered on.

8. The spin lock device according to claim 7, characterized in that: The random number generator also includes a PRNG pseudo-random number generator based on LFSR.

9. An electronic device, characterized in that: The electronic device includes: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any one of claims 1 to 7.

10. A non-transitory computer-readable storage medium, characterized in that: The non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the spin lock unlocking method described in any one of claims 1 to 6.