Skip to content

Commit ed5d47b

Browse files
committed
Fixup cr register on be (s390x)
1 parent 59ff63a commit ed5d47b

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

qemu/target/i386/unicorn.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,19 +1492,19 @@ uc_err reg_write(void *_env, int mode, unsigned int regid, const void *value,
14921492
break;
14931493
case UC_X86_REG_CR0:
14941494
CHECK_REG_TYPE(uint64_t);
1495-
cpu_x86_update_cr0(env, *(uint32_t *)value);
1495+
cpu_x86_update_cr0(env, (*(uint64_t *)value) & 0xFFFFFFFF);
14961496
goto write_cr64;
14971497
case UC_X86_REG_CR1:
14981498
case UC_X86_REG_CR2:
14991499
CHECK_REG_TYPE(uint64_t);
15001500
goto write_cr64;
15011501
case UC_X86_REG_CR3:
15021502
CHECK_REG_TYPE(uint64_t);
1503-
cpu_x86_update_cr3(env, *(uint32_t *)value);
1503+
cpu_x86_update_cr3(env, (*(uint64_t *)value) & 0xFFFFFFFF);
15041504
goto write_cr64;
15051505
case UC_X86_REG_CR4:
15061506
CHECK_REG_TYPE(uint64_t);
1507-
cpu_x86_update_cr4(env, *(uint32_t *)value);
1507+
cpu_x86_update_cr4(env, (*(uint64_t *)value) & 0xFFFFFFFF);
15081508
goto write_cr64;
15091509
case UC_X86_REG_CR8:
15101510
CHECK_REG_TYPE(uint64_t);

tests/unit/test_x86.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,8 +1474,8 @@ static void test_x86_16_incorrect_ip(void)
14741474
static void test_x86_mmu_prepare_tlb(uc_engine *uc, uint64_t vaddr,
14751475
uint64_t tlb_base)
14761476
{
1477-
uint32_t cr0;
1478-
uint32_t cr4;
1477+
uint64_t cr0;
1478+
uint64_t cr4;
14791479
uc_x86_msr msr = {.rid = 0x0c0000080, .value = 0};
14801480
uint64_t pml4o = ((vaddr & 0x00ff8000000000) >> 39) * 8;
14811481
uint64_t pdpo = ((vaddr & 0x00007fc0000000) >> 30) * 8;
@@ -1489,9 +1489,7 @@ static void test_x86_mmu_prepare_tlb(uc_engine *uc, uint64_t vaddr,
14891489
OK(uc_mem_write(uc, tlb_base + pml4o, &pml4e_mem, sizeof(pml4o)));
14901490
OK(uc_mem_write(uc, tlb_base + 0x1000 + pdpo, &pdpe_mem, sizeof(pdpe)));
14911491
OK(uc_mem_write(uc, tlb_base + 0x2000 + pdo, &pde_mem, sizeof(pde)));
1492-
uint32_t cr3 = tlb_base & 0xFFFFFFFF;
1493-
cr3 = LEINT32(cr3);
1494-
OK(uc_reg_write(uc, UC_X86_REG_CR3, &cr3));
1492+
OK(uc_reg_write(uc, UC_X86_REG_CR3, &tlb_base));
14951493
OK(uc_reg_read(uc, UC_X86_REG_CR0, &cr0));
14961494
OK(uc_reg_read(uc, UC_X86_REG_CR4, &cr4));
14971495
OK(uc_reg_read(uc, UC_X86_REG_MSR, &msr));

0 commit comments

Comments
 (0)