Skip to content

Commit

Permalink
Merge pull request #175 from flaviojs/fix-unintentional-integer-overf…
Browse files Browse the repository at this point in the history
…low-ppc32_slow_lookup

Fix unintentional integer overflow in ppc32_slow_lookup.
  • Loading branch information
grossmj authored Mar 14, 2024
2 parents 8b2a272 + 17872ce commit 80260b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions stable/ppc32_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,9 @@ static mts32_entry_t *ppc32_slow_lookup(cpu_ppc_t *cpu,m_uint32_t vaddr,

pte_lookup_done:
pte2 = vmtoh32(*(m_uint32_t *)(pte_haddr + sizeof(m_uint32_t)));
paddr = pte2 & PPC32_PTEL_RPN_MASK;
paddr |= (pte2 & PPC32_PTEL_XPN_MASK) << (33 - PPC32_PTEL_XPN_SHIFT);
paddr |= (pte2 & PPC32_PTEL_X_MASK) << (32 - PPC32_PTEL_X_SHIFT);
paddr = ((m_uint64_t)(pte2 & PPC32_PTEL_RPN_MASK));
paddr |= ((m_uint64_t)(pte2 & PPC32_PTEL_XPN_MASK)) << (33 - PPC32_PTEL_XPN_SHIFT);
paddr |= ((m_uint64_t)(pte2 & PPC32_PTEL_X_MASK)) << (32 - PPC32_PTEL_X_SHIFT);

map.vaddr = vaddr & ~PPC32_MIN_PAGE_IMASK;
map.paddr = paddr;
Expand Down
6 changes: 3 additions & 3 deletions unstable/ppc32_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,9 @@ static mts32_entry_t *ppc32_slow_lookup(cpu_ppc_t *cpu,m_uint32_t vaddr,

pte_lookup_done:
pte2 = vmtoh32(*(m_uint32_t *)(pte_haddr + sizeof(m_uint32_t)));
paddr = pte2 & PPC32_PTEL_RPN_MASK;
paddr |= (pte2 & PPC32_PTEL_XPN_MASK) << (33 - PPC32_PTEL_XPN_SHIFT);
paddr |= (pte2 & PPC32_PTEL_X_MASK) << (32 - PPC32_PTEL_X_SHIFT);
paddr = ((m_uint64_t)(pte2 & PPC32_PTEL_RPN_MASK));
paddr |= ((m_uint64_t)(pte2 & PPC32_PTEL_XPN_MASK)) << (33 - PPC32_PTEL_XPN_SHIFT);
paddr |= ((m_uint64_t)(pte2 & PPC32_PTEL_X_MASK)) << (32 - PPC32_PTEL_X_SHIFT);

map.vaddr = vaddr & ~PPC32_MIN_PAGE_IMASK;
map.paddr = paddr;
Expand Down

0 comments on commit 80260b3

Please sign in to comment.