Skip to content

Commit eb6fa6f

Browse files
committed
i386: check cpl in verr and verw
1 parent 675ed23 commit eb6fa6f

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

src/devices/cpu/i386/i386.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "divtlb.h"
1616

1717
#include "i386dasm.h"
18+
#include <algorithm>
1819

1920
#define INPUT_LINE_A20 1
2021
#define INPUT_LINE_SMI 2

src/devices/cpu/i386/i386op16.hxx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3260,14 +3260,18 @@ void i386_device::i386_group0F00_16() // Opcode 0x0f 00
32603260
{ // check if conforming, these are always readable, regardless of privilege
32613261
if(!(seg.flags & 0x04))
32623262
{
3263-
// if not conforming, then we must check privilege levels (TODO: current privilege level check)
3264-
if(((seg.flags >> 5) & 0x03) < (address & 0x03))
3263+
// if not conforming, then we must check privilege levels
3264+
if(((seg.flags >> 5) & 0x03) < std::max(m_CPL, (uint8_t)(address & 0x03)))
32653265
result = 0;
32663266
}
32673267
}
32683268
}
3269+
else
3270+
{
3271+
if(((seg.flags >> 5) & 0x03) < std::max(m_CPL, (uint8_t)(address & 0x03)))
3272+
result = 0;
3273+
}
32693274
}
3270-
// check that the descriptor privilege is greater or equal to the selector's privilege level and the current privilege (TODO)
32713275
SetZF(result);
32723276
}
32733277
else
@@ -3308,8 +3312,7 @@ void i386_device::i386_group0F00_16() // Opcode 0x0f 00
33083312
result = 0;
33093313
}
33103314
}
3311-
// check that the descriptor privilege is greater or equal to the selector's privilege level and the current privilege (TODO)
3312-
if(((seg.flags >> 5) & 0x03) < (address & 0x03))
3315+
if(((seg.flags >> 5) & 0x03) < std::max(m_CPL, (uint8_t)(address & 0x03)))
33133316
result = 0;
33143317
SetZF(result);
33153318
}

src/devices/cpu/i386/i386op32.hxx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3061,14 +3061,18 @@ void i386_device::i386_group0F00_32() // Opcode 0x0f 00
30613061
{ // check if conforming, these are always readable, regardless of privilege
30623062
if(!(seg.flags & 0x04))
30633063
{
3064-
// if not conforming, then we must check privilege levels (TODO: current privilege level check)
3065-
if(((seg.flags >> 5) & 0x03) < (address & 0x03))
3064+
// if not conforming, then we must check privilege levels
3065+
if(((seg.flags >> 5) & 0x03) < std::max(m_CPL, (uint8_t)(address & 0x03)))
30663066
result = 0;
30673067
}
30683068
}
30693069
}
3070+
else
3071+
{
3072+
if(((seg.flags >> 5) & 0x03) < std::max(m_CPL, (uint8_t)(address & 0x03)))
3073+
result = 0;
3074+
}
30703075
}
3071-
// check that the descriptor privilege is greater or equal to the selector's privilege level and the current privilege (TODO)
30723076
SetZF(result);
30733077
}
30743078
else
@@ -3108,8 +3112,7 @@ void i386_device::i386_group0F00_32() // Opcode 0x0f 00
31083112
result = 0;
31093113
}
31103114
}
3111-
// check that the descriptor privilege is greater or equal to the selector's privilege level and the current privilege (TODO)
3112-
if(((seg.flags >> 5) & 0x03) < (address & 0x03))
3115+
if(((seg.flags >> 5) & 0x03) < std::max(m_CPL, (uint8_t)(address & 0x03)))
31133116
result = 0;
31143117
SetZF(result);
31153118
}

0 commit comments

Comments
 (0)