CN111506338A - Function level hot patching method and device, intelligent terminal and storage medium - Google Patents
Function level hot patching method and device, intelligent terminal and storage medium Download PDFInfo
- Publication number
- CN111506338A CN111506338A CN202010139830.8A CN202010139830A CN111506338A CN 111506338 A CN111506338 A CN 111506338A CN 202010139830 A CN202010139830 A CN 202010139830A CN 111506338 A CN111506338 A CN 111506338A
- Authority
- CN
- China
- Prior art keywords
- function
- patch
- bug
- patch file
- instruction
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/65—Updates
- G06F8/658—Incremental updates; Differential updates
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/50—Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
- G06F21/57—Certifying or maintaining trusted computer platforms, e.g. secure boots or power-downs, version controls, system software checks, secure updates or assessing vulnerabilities
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Hardware Design (AREA)
- Stored Programmes (AREA)
Abstract
The invention discloses a function-level hot patching method, a function-level hot patching device, an intelligent terminal and a storage medium, wherein the method comprises the following steps: when the BUG function needs to be patched, loading a preset patch file; when the CPU executes the instruction to the BUG function, triggering a preset MON function and executing the patch file; and returning the instruction of the BUG function or the upper layer function after the patch file is executed. The invention can patch the function where the BUG is located at the place where the patch is needed, and does not need to upgrade the whole system and modify the code instruction of the whole system, thereby avoiding the abnormal condition.
Description
Technical Field
The invention relates to the technical field of embedded system BSP, in particular to a function level hot patching method, a device, an intelligent terminal and a storage medium.
Background
When writing software codes, software BUGs always exist for various reasons, research and development personnel can repair BUGs, release versions and upgrade equipment, and therefore the BUGs can be thoroughly solved. However, some BUGs have been located, the cost of reissuing a version and completing an upgrade once for all devices is very large, and after all, upgrading a version requires restarting a device.
Common Windows systems often release patches, some of which need to be restarted, namely cold patches. A patch that can take effect without restarting the system is a hot patch.
The hot patching method generally sets a first instruction of a function where a BUG occurs as a jump instruction, jumps to a place where the patch is located, completes the function of an original function by a patch function, practically eliminates the function of the original BUG function, and takes over the BUG function by the patch function (as shown in fig. 1). However, such a patch has a very inconvenient place, and most of the current systems perform write protection on instructions of a code segment, and the instruction modification necessarily performs write operation on the code segment. This triggers a write exception. After acquiring the write authority of the code segment, it is necessary to remove the write protection from the instruction of the entire page (generally 4KB) where the code is located, and it is also dangerous to remove the write protection from the instruction of the entire page in order to write one instruction. In addition, the modified jump instruction also calculates the jump address, and once the jump is to the address of the abnormal instruction, the system generates more serious abnormity.
Thus, there is still a need for improvement and development of the prior art.
Disclosure of Invention
The technical problem to be solved by the present invention is to provide a function level hot patching method, device, intelligent terminal and storage medium, aiming at the above-mentioned defects of the prior art.
The technical scheme adopted by the invention for solving the problems is as follows:
in a first aspect, an embodiment of the present invention provides a function-level hot patching method, where the method includes:
when the BUG function needs to be patched, loading a preset patch file;
when the CPU executes the instruction to the BUG function, triggering a preset MON function and executing the patch file;
and returning the instruction of the BUG function or the upper layer function after the patch file is executed.
In an embodiment, when the BUG function needs to be patched, loading the preset patch file includes:
and compiling the patch function in advance and making the patch function into the patch file.
In one embodiment, the pre-compiling the patch function and making the patch file includes:
making the patch function in a compiling environment;
setting a null function in a system in advance, wherein the null function is provided with an instruction space;
and filling the patch function into the instruction space of the space-time function to manufacture the patch file.
In one embodiment, the pre-compiling the patch function and making the patch function into the patch file further includes:
and loading the patch file to equipment through a network protocol, and filling the patch file with the position of the BUG function.
In one embodiment, before the triggering a preset MON function and executing the patch file when the CPU executes an instruction to the BUG function, the method includes:
and setting the instruction address to be patched in the BUG function as a monitoring address, and mounting the MON system monitor to monitor the system.
In one embodiment, the triggering a preset MON function and executing the patch file when the CPU executes the instruction to the BUG function includes:
and triggering the MON system monitor to control the MON system monitor to interrupt and execute the patch file after monitoring that the CPU executes the instruction to the BUG function.
In a second aspect, an embodiment of the present invention further discloses a function-level hot patch apparatus, where the apparatus includes:
the loading unit is used for loading a preset patch file when the BUG function needs to be patched;
the execution unit is used for triggering a preset MON function and executing the patch file when the CPU executes the instruction to the BUG function;
and the return unit is used for returning the instruction of the BUG function or the upper-layer function after the patch file is executed.
In a third aspect, the present invention also provides an intelligent terminal, comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs configured to be executed by the one or more processors include a function level hot-patch method for performing the above-mentioned function level hot-patch method.
In a fourth aspect, embodiments of the present invention also provide a non-transitory computer-readable storage medium, wherein instructions of the storage medium, when executed by a processor of an electronic device, enable the electronic device to perform a function level hot-patch method as described in any one of the above.
The invention has the beneficial effects that: the invention can patch the function where the BUG is located at the place where the patch is needed, and does not need to upgrade the whole system and modify the code instruction of the whole system, thereby avoiding the abnormal condition.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments described in the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flow chart of patch function execution in the prior art.
Fig. 2 is a flowchart illustrating a function-level hot patching method according to an embodiment of the present invention.
Fig. 3 is a flow chart of the execution of the patch function in the embodiment of the present invention.
FIG. 4 is a functional block diagram of a function level hot patch apparatus in an embodiment of the invention.
Fig. 5 is a schematic block diagram of an internal structure of an intelligent terminal according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer and clearer, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
It should be noted that, if directional indications (such as up, down, left, right, front, and back … …) are involved in the embodiment of the present invention, the directional indications are only used to explain the relative positional relationship between the components, the movement situation, and the like in a specific posture (as shown in the drawing), and if the specific posture is changed, the directional indications are changed accordingly.
In order to solve the problems in the prior art, the present embodiment provides a function-level hot patching method, specifically as shown in fig. 2, the method includes:
s100, loading a preset patch file when the BUG function needs to be patched;
step S200, when the CPU executes the instruction to the BUG function, triggering a preset MON function and executing the patch file;
and step S300, after the patch file is executed, returning the instruction of the BUG function or the upper layer function.
In specific implementation, in this embodiment, a patch function is compiled in advance and is made into the patch file. Specifically, in this embodiment, the patch function is first manufactured in a compiling environment, and then a space-time function is set in the system in advance, where the space-time function is provided with an instruction space; and filling the patch function into the instruction space of the space-time function to manufacture the patch file. In this embodiment, all instruction spaces in the null function are null instruction spaces. The dummy instruction is stored in order to make the dummy function occupy a section of instruction space in advance. Once the useful patch function is loaded into the system, the actual instructions in the patch function will fill the empty instruction space. The size of the preset empty-bit function is set to 4KB, which is the size of one page, and its write protection is released. The patch file is typically modified from a small piece of code so the patch is not too large and 4KB of space is sufficient.
And after the patch file is manufactured, loading the patch file to equipment through a network protocol, and filling the patch file with the position of the BUG function. That is, referring to fig. 3, in the main program, the patch function is compiled in advance, and in the normal program space (i.e., the instruction space in the NULL function), the occupied space is 4KB, and 1K instruction can be stored. When the patch function is not loaded, its 1K instructions are all null instructions. And when the patch function is loaded, filling the empty instruction space of the empty function by the patch function. When a function with a BUG needs to be patched (the BUG function is assumed to be named as fBug ()), a patch file is loaded on a device through a network protocol, and finally, the position of the BUG function (namely the position needing patching) is filled.
Further, in this embodiment, an instruction address to be patched in the BUG function is set as a monitoring address in advance, the MON system monitor is mounted to monitor the system, and when the CPU executes an instruction to the BUG function, the MON system monitor is triggered to control the MON system monitor to interrupt, and the patch file is executed. That is, once the CPU executes an instruction into the monitored instruction in the fBug () function, the CPU immediately triggers an interrupt and enters the exeMon () function. exeMon () investigates the patch function fPatch () in the patch file for execution. Therefore, the positions of the BUG functions, which need to be patched, can be patched in a targeted manner, and the instructions of the whole system function do not need to be modified, so that the problem of abnormal conditions caused by modifying all the instructions can be avoided.
Further, after the patch file is executed, returning to the instruction of the BUG function or the upper layer function. As shown in fig. 3, since the patch function fPatch () in the patch file is compiled in the compilation environment in advance, its instruction is also fixed. When the execution of the patch function fPatch () in the patch file is finished, the value of the Program Counter (PC) is re-assigned, and whether the patch function fPatch () is returned to the fBug () or is an upper function of the fBug () is determined.
Based on the foregoing embodiment, the present invention further provides a function level hot patch apparatus, specifically as shown in fig. 4, where the function level hot patch apparatus includes: a load unit 410, an execute unit 420, and a return unit 430. Specifically, the loading unit 410 is configured to load a preset patch file when the BUG function needs to be patched. The execution unit 420 is configured to trigger a preset MON function and execute the patch file when the CPU executes the instruction to the BUG function. The returning unit 430 is configured to return the instruction of the BUG function or the upper function after the patch file is executed.
Based on the above embodiment, the present invention further provides an intelligent terminal, and a schematic block diagram thereof may be as shown in fig. 5. The intelligent terminal comprises a processor, a memory, a network interface, a display screen and a temperature sensor which are connected through a system bus. Wherein, the processor of the intelligent terminal is used for providing calculation and control capability. The memory of the intelligent terminal comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the intelligent terminal is used for being connected and communicated with an external terminal through a network. The computer program is executed by a processor to realize an intelligent terminal angle adjusting method. The display screen of the intelligent terminal can be a liquid crystal display screen or an electronic ink display screen, and the temperature sensor of the intelligent terminal is arranged inside the intelligent terminal in advance and used for detecting the operating temperature of internal equipment.
It will be understood by those skilled in the art that the block diagram shown in fig. 5 is only a block diagram of a part of the structure related to the solution of the present invention, and does not constitute a limitation to the intelligent terminal to which the solution of the present invention is applied, and a specific intelligent terminal may include more or less components than those shown in the figure, or combine some components, or have a different arrangement of components.
In one embodiment, an intelligent terminal is provided that includes a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs including instructions for:
when the BUG function needs to be patched, loading a preset patch file;
when the CPU executes the instruction to the BUG function, triggering a preset MON function and executing the patch file;
and returning the instruction of the BUG function or the upper layer function after the patch file is executed.
It will be understood by those of ordinary skill in the art that all or a portion of the processes of the methods of the embodiments described above may be implemented by a computer program that may be stored on a non-volatile computer-readable storage medium, which when executed, may include the processes of the embodiments of the methods described above, wherein any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory.
In summary, the present invention discloses a function-level hot patching method, device, intelligent terminal and storage medium, wherein the method comprises: when the BUG function needs to be patched, loading a preset patch file; when the CPU executes the instruction to the BUG function, triggering a preset MON function and executing the patch file; and returning the instruction of the BUG function or the upper layer function after the patch file is executed. The invention can patch the function where the BUG is located at the place where the patch is needed, and does not need to upgrade the whole system and modify the code instruction of the whole system, thereby avoiding the abnormal condition.
It is to be understood that the invention is not limited to the examples described above, but that modifications and variations may be effected thereto by those of ordinary skill in the art in light of the foregoing description, and that all such modifications and variations are intended to be within the scope of the invention as defined by the appended claims.
Claims (9)
1. A method of function level hot patching, the method comprising:
when the BUG function needs to be patched, loading a preset patch file;
when the CPU executes the instruction to the BUG function, triggering a preset MON function and executing the patch file;
and returning the instruction of the BUG function or the upper layer function after the patch file is executed.
2. The function level hot patching method of claim 1, wherein when patching of the BUG function is required, loading a preset patch file comprises:
and compiling the patch function in advance and making the patch function into the patch file.
3. The function-level hot patching method of claim 2, wherein the pre-compiling a patch function and making the patch file comprises:
making the patch function in a compiling environment;
setting a null function in a system in advance, wherein the null function is provided with an instruction space;
and filling the patch function into the instruction space of the space-time function to manufacture the patch file.
4. The function-level hot patching method of claim 3, wherein the pre-compiling a patch function and making it into the patch file further comprises:
and loading the patch file to equipment through a network protocol, and filling the patch file with the position of the BUG function.
5. The function level hot patching method of claim 1, wherein before triggering a preset MON function and executing the patch file when the CPU executes an instruction to the BUG function, the method comprises:
and setting the instruction address to be patched in the BUG function as a monitoring address, and mounting the MON system monitor to monitor the system.
6. The function level hot patching method of claim 1, wherein the triggering a preset MON function and executing the patch file when the CPU executes instructions to the BUG function comprises:
and triggering the MON system monitor to control the MON system monitor to interrupt and execute the patch file after monitoring that the CPU executes the instruction to the BUG function.
7. A function level hot-patch apparatus, the apparatus comprising:
the loading unit is used for loading a preset patch file when the BUG function needs to be patched;
the execution unit is used for triggering a preset MON function and executing the patch file when the CPU executes the instruction to the BUG function;
and the return unit is used for returning the instruction of the BUG function or the upper-layer function after the patch file is executed.
8. An intelligent terminal comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory, and wherein the one or more programs being configured to be executed by the one or more processors comprises instructions for performing the method of any of claims 1-7.
9. A non-transitory computer readable storage medium having instructions therein, which when executed by a processor of an electronic device, enable the electronic device to perform the method of any one of claims 1-7.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010139830.8A CN111506338B (en) | 2020-03-03 | 2020-03-03 | Function-level hot-patch method and device, intelligent terminal and storage medium |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010139830.8A CN111506338B (en) | 2020-03-03 | 2020-03-03 | Function-level hot-patch method and device, intelligent terminal and storage medium |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN111506338A true CN111506338A (en) | 2020-08-07 |
| CN111506338B CN111506338B (en) | 2023-08-11 |
Family
ID=71867005
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202010139830.8A Active CN111506338B (en) | 2020-03-03 | 2020-03-03 | Function-level hot-patch method and device, intelligent terminal and storage medium |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN111506338B (en) |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114564228A (en) * | 2022-03-17 | 2022-05-31 | 北京字跳网络技术有限公司 | A kind of application program updating method, apparatus, computer equipment and storage medium |
| CN119376769A (en) * | 2024-12-30 | 2025-01-28 | 浪潮电子信息产业股份有限公司 | Kernel hot patching method, device, storage medium and product |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20100205587A1 (en) * | 2009-02-10 | 2010-08-12 | Huafei Dai | Method, device and system for realizing kernel online patching |
| CN104239201A (en) * | 2013-06-20 | 2014-12-24 | 上海博达数据通信有限公司 | A method for monitoring memory reading and writing in a soft single-step system |
| CN104461625A (en) * | 2014-12-04 | 2015-03-25 | 上海斐讯数据通信技术有限公司 | Hot patch realization method and system |
| CN107943544A (en) * | 2017-12-11 | 2018-04-20 | 北京奇虎科技有限公司 | The loading method and device of a kind of kernel patch |
| CN115357515A (en) * | 2022-10-19 | 2022-11-18 | 北京紫光芯能科技有限公司 | Debugging method, device, computer equipment and storage medium of a multi-core system |
-
2020
- 2020-03-03 CN CN202010139830.8A patent/CN111506338B/en active Active
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20100205587A1 (en) * | 2009-02-10 | 2010-08-12 | Huafei Dai | Method, device and system for realizing kernel online patching |
| CN104239201A (en) * | 2013-06-20 | 2014-12-24 | 上海博达数据通信有限公司 | A method for monitoring memory reading and writing in a soft single-step system |
| CN104461625A (en) * | 2014-12-04 | 2015-03-25 | 上海斐讯数据通信技术有限公司 | Hot patch realization method and system |
| CN107943544A (en) * | 2017-12-11 | 2018-04-20 | 北京奇虎科技有限公司 | The loading method and device of a kind of kernel patch |
| CN115357515A (en) * | 2022-10-19 | 2022-11-18 | 北京紫光芯能科技有限公司 | Debugging method, device, computer equipment and storage medium of a multi-core system |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114564228A (en) * | 2022-03-17 | 2022-05-31 | 北京字跳网络技术有限公司 | A kind of application program updating method, apparatus, computer equipment and storage medium |
| CN114564228B (en) * | 2022-03-17 | 2025-02-14 | 北京字跳网络技术有限公司 | Application program updating method, device, computer equipment and storage medium |
| CN119376769A (en) * | 2024-12-30 | 2025-01-28 | 浪潮电子信息产业股份有限公司 | Kernel hot patching method, device, storage medium and product |
Also Published As
| Publication number | Publication date |
|---|---|
| CN111506338B (en) | 2023-08-11 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US7886287B1 (en) | Method and apparatus for hot updating of running processes | |
| US7712084B2 (en) | Method for monitoring a program execution using a debug logic | |
| US9665469B2 (en) | System and method of runtime downloading of debug code and diagnostics tools in an already deployed baseboard management controller (BMC) devices | |
| CN103688268B (en) | Vehicle unit and method for operating the vehicle unit | |
| US8504875B2 (en) | Debugging module to load error decoding logic from firmware and to execute logic in response to an error | |
| US7308547B2 (en) | Apparatus and method for control of write filter | |
| CN111506338A (en) | Function level hot patching method and device, intelligent terminal and storage medium | |
| US7546596B2 (en) | Non-disruptive method, system and program product for overlaying a first software module with a second software module | |
| US20020095619A1 (en) | Fault tolerant/redundant boot ROM reprogramming | |
| CN110874237A (en) | Software upgrading method, device, terminal and readable storage medium | |
| CN113342376B (en) | Method and device for upgrading operating system of Internet of things equipment | |
| US20140258699A1 (en) | Boot fault tolerant device and method thereof | |
| US7203819B2 (en) | Program processing device | |
| CN113986771B (en) | Method and device for debugging target program code and electronic equipment | |
| US20090138865A1 (en) | Performing an operating system upgrade without multiple system interruptions | |
| CN119440569A (en) | Firmware upgrade method, device, electronic device and computer readable storage medium | |
| WO2025044536A1 (en) | Micro-controller booting method and apparatus, and device and storage medium | |
| Lobdell | Robust over-the-air firmware updates using program flash memory swap on kinetis microcontrollers | |
| JP2007249748A (en) | Network equipment with version management function | |
| US20240160414A1 (en) | Vehicle Electronic Control Device and Program Rewriting Method | |
| CN118535184A (en) | Remote upgrading method for firmware program of singlechip | |
| KR100775431B1 (en) | Embedded system and firmware update method for embedded system | |
| CN118092983B (en) | Software upgrading method for preventing power-on failure, singlechip and storage medium | |
| US7246206B2 (en) | Method and device for storing a computer program in a program memory of a control unit | |
| EP4546130A1 (en) | Method and system for executing a safety-critical application |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |