x86: change divide-by-zero fault to divide-error

Same exception is raised whether division with zero is performed or the
quotient is greater than the maximum value that the provided space can hold.
Divide-by-Zero is the AMD terminology, while Divide-Error is Intel's.
This commit is contained in:
Nilay Vaish
2015-04-29 22:35:22 -05:00
parent 179787f31f
commit ee06fed656
2 changed files with 7 additions and 6 deletions

View File

@@ -167,7 +167,7 @@ namespace X86ISA
// Class | Type | vector | Cause | mnem // Class | Type | vector | Cause | mnem
//------------------------------------------------------------------------ //------------------------------------------------------------------------
//Contrib Fault 0 Divide-by-Zero-Error #DE //Contrib Fault 0 Divide Error #DE
//Benign Either 1 Debug #DB //Benign Either 1 Debug #DB
//Benign Interrupt 2 Non-Maskable-Interrupt #NMI //Benign Interrupt 2 Non-Maskable-Interrupt #NMI
//Benign Trap 3 Breakpoint #BP //Benign Trap 3 Breakpoint #BP
@@ -193,11 +193,12 @@ namespace X86ISA
//Benign Interrupt 0-255 External Interrupts #INTR //Benign Interrupt 0-255 External Interrupts #INTR
//Benign Interrupt 0-255 Software Interrupts INTn //Benign Interrupt 0-255 Software Interrupts INTn
class DivideByZero : public X86Fault // Note that
class DivideError : public X86Fault
{ {
public: public:
DivideByZero() : DivideError() :
X86Fault("Divide-by-Zero-Error", "#DE", 0) X86Fault("Divide-Error", "#DE", 0)
{} {}
}; };

View File

@@ -629,7 +629,7 @@ let {{
uint64_t dividend = remainder; uint64_t dividend = remainder;
//Do the division. //Do the division.
if (divisor == 0) { if (divisor == 0) {
fault = std::make_shared<DivideByZero>(); fault = std::make_shared<DivideError>();
} else { } else {
divide(dividend, divisor, quotient, remainder); divide(dividend, divisor, quotient, remainder);
//Record the final results. //Record the final results.
@@ -652,7 +652,7 @@ let {{
//If we overshot, do nothing. This lets us unrool division loops a //If we overshot, do nothing. This lets us unrool division loops a
//little. //little.
if (divisor == 0) { if (divisor == 0) {
fault = std::make_shared<DivideByZero>(); fault = std::make_shared<DivideError>();
} else if (remaining) { } else if (remaining) {
if (divisor & (ULL(1) << 63)) { if (divisor & (ULL(1) << 63)) {
while (remaining && !(dividend & (ULL(1) << 63))) { while (remaining && !(dividend & (ULL(1) << 63))) {