i386: check cpl in verr and verw

This commit is contained in:
cracyc 2025-05-20 18:52:27 -05:00
parent 675ed2356a
commit eb6fa6f6dc
3 changed files with 17 additions and 10 deletions

View File

@ -15,6 +15,7 @@
#include "divtlb.h"
#include "i386dasm.h"
#include <algorithm>
#define INPUT_LINE_A20 1
#define INPUT_LINE_SMI 2

View File

@ -3260,14 +3260,18 @@ void i386_device::i386_group0F00_16() // Opcode 0x0f 00
{ // check if conforming, these are always readable, regardless of privilege
if(!(seg.flags & 0x04))
{
// if not conforming, then we must check privilege levels (TODO: current privilege level check)
if(((seg.flags >> 5) & 0x03) < (address & 0x03))
// if not conforming, then we must check privilege levels
if(((seg.flags >> 5) & 0x03) < std::max(m_CPL, (uint8_t)(address & 0x03)))
result = 0;
}
}
}
else
{
if(((seg.flags >> 5) & 0x03) < std::max(m_CPL, (uint8_t)(address & 0x03)))
result = 0;
}
}
// check that the descriptor privilege is greater or equal to the selector's privilege level and the current privilege (TODO)
SetZF(result);
}
else
@ -3308,8 +3312,7 @@ void i386_device::i386_group0F00_16() // Opcode 0x0f 00
result = 0;
}
}
// check that the descriptor privilege is greater or equal to the selector's privilege level and the current privilege (TODO)
if(((seg.flags >> 5) & 0x03) < (address & 0x03))
if(((seg.flags >> 5) & 0x03) < std::max(m_CPL, (uint8_t)(address & 0x03)))
result = 0;
SetZF(result);
}

View File

@ -3061,14 +3061,18 @@ void i386_device::i386_group0F00_32() // Opcode 0x0f 00
{ // check if conforming, these are always readable, regardless of privilege
if(!(seg.flags & 0x04))
{
// if not conforming, then we must check privilege levels (TODO: current privilege level check)
if(((seg.flags >> 5) & 0x03) < (address & 0x03))
// if not conforming, then we must check privilege levels
if(((seg.flags >> 5) & 0x03) < std::max(m_CPL, (uint8_t)(address & 0x03)))
result = 0;
}
}
}
else
{
if(((seg.flags >> 5) & 0x03) < std::max(m_CPL, (uint8_t)(address & 0x03)))
result = 0;
}
}
// check that the descriptor privilege is greater or equal to the selector's privilege level and the current privilege (TODO)
SetZF(result);
}
else
@ -3108,8 +3112,7 @@ void i386_device::i386_group0F00_32() // Opcode 0x0f 00
result = 0;
}
}
// check that the descriptor privilege is greater or equal to the selector's privilege level and the current privilege (TODO)
if(((seg.flags >> 5) & 0x03) < (address & 0x03))
if(((seg.flags >> 5) & 0x03) < std::max(m_CPL, (uint8_t)(address & 0x03)))
result = 0;
SetZF(result);
}