Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix signed integer overflow in RV32IM #324

Merged
merged 2 commits into from
Jan 8, 2024

Commits on Jan 6, 2024

  1. Fix signed integer overflow in RV32I

    The implementation of add, sub, and addi instructions incorrectly used
    int32_t for arithmetic operations, leading to signed integer overflow.
    Address the issue by maintaining the uint32_t type for arithmetic
    operations, ensuring compliance with the laws of arithmetic modulo 2^n.
    This approach prevents undefined behavior resulting from signed integer
    overflow.
    visitorckw committed Jan 6, 2024
    Configuration menu
    Copy the full SHA
    2a58885 View commit details
    Browse the repository at this point in the history
  2. Fix signed integer overflow in RV32M

    The current implementation of the mul instruction does not guard
    against integer overflow, potentially leading to undefined behavior.
    Cast the operands to int64_t before performing the multiplication to
    ensure that the result can be accommodated without overflow. The lower
    32 bits of the product are then extracted, preserving the correct
    uint32_t type.
    visitorckw committed Jan 6, 2024
    1 Configuration menu
    Copy the full SHA
    32895fb View commit details
    Browse the repository at this point in the history