Allow unaligned load/store in QVM interpreter/x86 compiler
constructions like (dataMask & ~3) was used to protect against out-of-bound load/store when address is 4-byte closer to dataMask but at the same time it effectively cut low address bits for ALL load/store operations which is totally wrong in terms of conformance to ALLOWED (i.e. generated by q3lcc from C sources) low-level operations like packed binary data parsing
This commit is contained in:
parent
abce15055c
commit
566fb0edfc
4 changed files with 17 additions and 14 deletions
|
@ -790,7 +790,7 @@ qboolean ConstOptimize(vm_t *vm, int callProcOfsSyscall)
|
|||
return qtrue;
|
||||
|
||||
case OP_STORE4:
|
||||
EmitMovEAXStack(vm, (vm->dataMask & ~3));
|
||||
EmitMovEAXStack(vm, vm->dataMask);
|
||||
#if idx64
|
||||
EmitRexString(0x41, "C7 04 01"); // mov dword ptr [r9 + eax], 0x12345678
|
||||
Emit4(Constant4());
|
||||
|
@ -805,7 +805,7 @@ qboolean ConstOptimize(vm_t *vm, int callProcOfsSyscall)
|
|||
return qtrue;
|
||||
|
||||
case OP_STORE2:
|
||||
EmitMovEAXStack(vm, (vm->dataMask & ~1));
|
||||
EmitMovEAXStack(vm, vm->dataMask);
|
||||
#if idx64
|
||||
Emit1(0x66); // mov word ptr [r9 + eax], 0x1234
|
||||
EmitRexString(0x41, "C7 04 01");
|
||||
|
@ -1377,7 +1377,7 @@ void VM_Compile(vm_t *vm, vmHeader_t *header)
|
|||
case OP_STORE4:
|
||||
EmitMovEAXStack(vm, 0);
|
||||
EmitString("8B 54 9F FC"); // mov edx, dword ptr -4[edi + ebx * 4]
|
||||
MASK_REG("E2", vm->dataMask & ~3); // and edx, 0x12345678
|
||||
MASK_REG("E2", vm->dataMask); // and edx, 0x12345678
|
||||
#if idx64
|
||||
EmitRexString(0x41, "89 04 11"); // mov dword ptr [r9 + edx], eax
|
||||
#else
|
||||
|
@ -1389,7 +1389,7 @@ void VM_Compile(vm_t *vm, vmHeader_t *header)
|
|||
case OP_STORE2:
|
||||
EmitMovEAXStack(vm, 0);
|
||||
EmitString("8B 54 9F FC"); // mov edx, dword ptr -4[edi + ebx * 4]
|
||||
MASK_REG("E2", vm->dataMask & ~1); // and edx, 0x12345678
|
||||
MASK_REG("E2", vm->dataMask); // and edx, 0x12345678
|
||||
#if idx64
|
||||
Emit1(0x66); // mov word ptr [r9 + edx], eax
|
||||
EmitRexString(0x41, "89 04 11");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue