Summary of the invention
The invention provides unit exception disposal route and device, crash to reduce the unit exception caused by access illegal address.
Technical scheme of the present invention is achieved in that
A kind of unit exception disposal route, the method comprises:
Device discovery self creates anomalous event, wherein, carries the order code of abnormal cause and triggering anomalous event in anomalous event;
Equipment judges whether abnormal cause is access illegal address, if, obtain the real instruction triggering anomalous event, judge whether this instruction is read write command, if read write command, obtain from this instruction and trigger the address of anomalous event, judge that whether this address is the legal address of system configuration, if so, next instruction in process internal memory is continued; Otherwise, carry out abnormality processing.
The described real instruction obtaining triggering anomalous event comprises:
Judging whether the order code in anomalous event is jump instruction, if so, from postponing next instruction obtaining this jump instruction groove, determining that this instruction postponed in groove is that the real of anomalous event touches originator; Otherwise, determine that the corresponding instruction of order code of carrying in anomalous event is that the real of anomalous event touches originator.
When determining that the order code in anomalous event is jump instruction, and when the address of determining to trigger anomalous event is the legal address of system configuration, next instruction in described continuation process internal memory comprises:
Calculate redirect return address according to jump instruction, go to the instruction that in internal memory, this redirect return address is corresponding, start to process this instruction.
Described equipment is adopt the equipment based on the linux system of MIPSCPU.
A kind of unit exception treating apparatus, comprising:
Anomalous event sending module: find that place equipment creates anomalous event, carries the order code of abnormal cause and triggering anomalous event, this anomalous event is sent to abnormal judge module in anomalous event;
Abnormal judge module: receive anomalous event, judge whether abnormal cause is access illegal address, if, obtain the real instruction triggering anomalous event, judge whether this instruction is read write command, if read write command, the address of triggering anomalous event is obtained from this instruction, judge that whether this address is the legal address of system configuration, if so, continue next instruction in process internal memory; Otherwise, determine to carry out abnormality processing.
Described abnormal judge module is further used for, when obtaining the real instruction triggering anomalous event, judge whether the order code in anomalous event is jump instruction, if, from postponing next instruction obtaining this jump instruction groove, determine that this instruction postponed in groove is that the real of anomalous event touches originator; Otherwise, determine that the corresponding instruction of order code of carrying in anomalous event is that the real of anomalous event touches originator.
Described abnormal judge module is further used for, when determining that the order code in anomalous event is jump instruction, and when determining that triggering the address of anomalous event is the legal address of system configuration, described next instruction continued in process internal memory comprises: calculate redirect return address according to jump instruction, go to the instruction that in internal memory, this redirect return address is corresponding, start to process this instruction.
Described device is positioned on router.
Described router adopts the linux system based on MIPSCPU.
Visible, the present invention can reduce the unit exception caused by access illegal address and crash, and improves the stability of device systems.
Embodiment
Below in conjunction with drawings and the specific embodiments, the present invention is further described in more detail.
The unit exception process flow figure that Fig. 1 provides for the embodiment of the present invention, as shown in Figure 1, its concrete steps are as follows:
Step 101: device discovery self creates anomalous event, wherein, carries the order code of abnormal cause and triggering anomalous event in anomalous event.
Step 102: equipment judges whether abnormal cause is access illegal address, if so, performs step 103; Otherwise, perform step 106.
Step 103: equipment obtains the real instruction triggering anomalous event, judges whether this instruction is read write command, if so, performs step 104; Otherwise, perform step 106.
Step 104: equipment obtains and triggers the address of anomalous event from read write command, judges that whether this address is the legal address of system configuration, if so, performs step 105; Otherwise, perform step 106.
Step 105: equipment continues next instruction in process internal memory, and this flow process terminates.
Step 106: equipment carries out abnormality processing.
The unit exception process flow figure that Fig. 2 provides for further embodiment of this invention, as shown in Figure 2, its concrete steps are as follows:
Step 201: device discovery self creates anomalous event, carries the order code of abnormal cause and triggering anomalous event in anomalous event.
Step 202: equipment judges whether abnormal cause is access illegal address, if so, performs step 203; Otherwise, perform step 206.
Step 203: equipment, according to the order code in anomalous event, judges whether this instruction is read write command, if so, performs step 204; Otherwise, perform step 206.
Step 204: equipment is read access address from this order code, judges that whether this address is the legal address of system configuration, if so, performs step 205; Otherwise, perform step 206.
The legal address of system configuration can be the permission reference address of system initial configuration.Wherein, the memory address space in equipment can be assigned with in advance, and some address space is configured to allow access, and other is not configured to allow the address space of access to be then whenever do not allow access.When allowing the pci card corresponding to address space of access etc. not in place, stopping continuing this address space of access, and system in case of system halt need not be caused to restart; But the access behavior of any address space for not being configured to permission access being true positive illegal act, all can causing equipment deadlock and restarting.
Step 205: equipment continues next instruction in process internal memory, and this flow process terminates.
Step 206: equipment sends exception handling instruction to the abnormality processing module of self, carry this anomalous event mark in this instruction, abnormality processing module receives this instruction, according to this anomalous event of existing procedure process.
Equipment in the present invention can adopt the linux system based on MIPSCPU, and equipment can be router.
It should be noted that; CPU due to equipment is the instruction in sequential processes internal memory; and when present instruction is jump instruction; the CPU of some type, such as MIPSCPU, first can perform next instruction of jump instruction usually; this next instruction enters and postpones in groove; when postponing the instruction triggers anomalous event in groove, CPU can be defaulted as this anomalous event and remain by the present instruction in internal memory, and namely jump instruction triggers.Under the circumstances, the present invention provides following embodiment:
The unit exception process flow figure that Fig. 3 provides for another embodiment of the present invention, as shown in Figure 3, its concrete steps are as follows:
Step 301: device discovery self creates anomalous event, carries the order code of abnormal cause and triggering anomalous event in anomalous event.
Step 302: equipment judges whether abnormal cause is access illegal address, if so, performs step 303; Otherwise, perform step 309.
Step 303: equipment judges whether the order code of carrying in anomalous event is jump instruction, if so, performs step 304; Otherwise, perform step 305.
Step 304: equipment, from postponing next instruction obtaining this jump instruction groove, is determined that this instruction postponed in groove is that the real of anomalous event touches originator, gone to step 306.
Step 305: the corresponding instruction of the order code in equipment determination anomalous event is that the real of anomalous event touches originator, performs step 306.
Step 306: equipment judges whether the instruction triggering anomalous event is read write command, if so, performs step 307; Otherwise, perform step 309.
Step 307: equipment reads address from read write command, judges that whether this address is the legal address of system configuration, if so, performs step 308; Otherwise, perform step 309.
Step 308: equipment calculates redirect return address according to the information that jump instruction is carried, goes to the instruction that in internal memory, this redirect return address is corresponding, and start to process this instruction, this flow process terminates.
Step 309: equipment sends exception handling instruction to the abnormality processing module of self, carry this anomalous event mark in this instruction, abnormality processing module receives this instruction, according to this anomalous event of existing procedure process.
Below provide application example of the present invention:
Be provided with a pci card to extract from router, perform an instruction in internal memory as CPU, this instruction be for address space corresponding to this pci card read instruction time, because CPU searches less than equipment corresponding to this address space, therefore, can think that this address space is illegal, thus produce anomalous event; Now, CPU carries out following detailed process:
01) first CPU judges whether abnormal cause is access illegal address, is judged as YES, performs step 02.
02) CPU is according to the order code in anomalous event, judges that whether this instruction is for reading instruction or write command, is judged as YES, and performs step 03.
03) CPU reads to read address instruction from this, judge that whether this address is the legal address of system configuration further, CPU finds the corresponding pci card in this address, and this pci card is not in place, then due to: access the permission reference address space that address space corresponding to the pci card that is pulled out is system initial configuration, should not cause system in case of system halt, thus determine not to be illegal act, perform step 04.
04) CPU determines continue normal work, then continue to perform next instruction in internal memory.
As can be seen from the above embodiment of the present invention:
In the present invention, anomalous event one produces, and will carry out illegal address access process, therefore, avoids the follow-up access behavior to illegal address.
The composition schematic diagram of the unit exception treating apparatus that Fig. 4 provides for the embodiment of the present invention, as shown in Figure 4, it mainly comprises: anomalous event sending module 41, abnormal judge module 42 and abnormality processing module 43, wherein:
Anomalous event sending module 41: find that place equipment creates anomalous event, carries the order code of abnormal cause and triggering anomalous event, this anomalous event is sent to abnormal judge module 42 in anomalous event.
Abnormal judge module 42: receive the anomalous event that anomalous event sending module 41 is sent, judge whether abnormal cause is access illegal address, if, obtain the real instruction triggering anomalous event, judge whether this instruction is read write command, if read write command, the address of triggering anomalous event is obtained from this instruction, judge that whether this address is the legal address of system configuration, if so, continue next instruction in process internal memory; Otherwise, send this anomalous event to abnormality processing module 43.
Abnormal judge module 42 is further used for, when obtaining the real instruction triggering anomalous event, judge whether the order code in anomalous event is jump instruction, if, from postponing next instruction obtaining this jump instruction groove, determine that this instruction postponed in groove is that the real of anomalous event touches originator; Otherwise, determine that the corresponding instruction of order code of carrying in anomalous event is that the real of anomalous event touches originator.
Abnormal judge module 42 is further used for, when determining that the order code in anomalous event is jump instruction, and when determining that triggering the address of anomalous event is the legal address of system configuration, described next instruction continued in process internal memory comprises: calculate redirect return address according to jump instruction, go to the instruction that in internal memory, this redirect return address is corresponding, start to process this instruction.
Abnormality processing module 43: receive the anomalous event that abnormal judge module 42 is sent, abnormality processing is carried out to this anomalous event.
In actual applications, Fig. 4 shown device can be positioned on router, and this router can adopt the linux system based on MIPSCPU.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, within the spirit and principles in the present invention all, any amendment made, equivalent replacement, improvement etc., all should be included within the scope of protection of the invention.