Skip to content

Commit

Permalink
arm64: Fix comparing ID register fields
Browse files Browse the repository at this point in the history
The logic in update_special_reg_field was reversed. Fix by swapping the
order of the arguments.

PR:		282505
Fixes:		f1fb1d5 ("arm64: Support more ID register field types")
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D47437
  • Loading branch information
zxombie committed Nov 19, 2024
1 parent 40555e4 commit fe5fa72
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sys/arm64/arm64/identcpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2261,14 +2261,14 @@ update_special_reg_field(uint64_t user_reg, u_int type, uint64_t value,

switch (type & MRS_TYPE_MASK) {
case MRS_EXACT_IF_DIFFERENT:
if (mrs_field_cmp(cur, new_val, shift, width, sign) != 0)
if (mrs_field_cmp(new_val, cur, shift, width, sign) != 0)
break;
/* FALLTHROUGH */
case MRS_EXACT:
cur = (uint64_t)MRS_SAFE_VAL(type) << shift;
break;
case MRS_LOWER:
if (mrs_field_cmp(cur, new_val, shift, width, sign) < 0)
if (mrs_field_cmp(new_val, cur, shift, width, sign) < 0)
cur = new_val;
break;
case MRS_HIGHER_OR_ZERO:
Expand All @@ -2278,7 +2278,7 @@ update_special_reg_field(uint64_t user_reg, u_int type, uint64_t value,
}
/* FALLTHROUGH */
case MRS_HIGHER:
if (mrs_field_cmp(cur, new_val, shift, width, sign) > 0)
if (mrs_field_cmp(new_val, cur, shift, width, sign) > 0)
cur = new_val;
break;
default:
Expand Down

0 comments on commit fe5fa72

Please sign in to comment.