Page MenuHomeFreeBSD

libc/amd64: fix stpncpy.S again
ClosedPublic

Authored by fuz on Thu, Dec 18, 11:42 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Jan 14, 6:06 AM
Unknown Object (File)
Fri, Jan 9, 2:42 PM
Unknown Object (File)
Thu, Jan 8, 3:13 AM
Unknown Object (File)
Tue, Jan 6, 4:18 PM
Unknown Object (File)
Tue, Jan 6, 2:18 PM
Unknown Object (File)
Tue, Jan 6, 1:10 PM
Unknown Object (File)
Thu, Jan 1, 1:06 AM
Unknown Object (File)
Wed, Dec 31, 8:15 PM
Subscribers

Details

Summary

The previous fix introduced a regression on machines without the BMI1
instruction set extension. The TZCNT instruction used in this function
behaves different on old machines when the source operand is zero, but
the code was originally designed to never trigger this case. The bug
fix caused this case to be possible, leading to a regression on
sufficiently old hardware.

Fix the code by messing with things such that the source operand is
never zero.

PR: 291720
Fixes: 66eb78377bf109af1d9e25626bf254b4369436ec

Test Plan

passes unit test. The behaviour on older machines was
manually checked by replacing TZCNT with BSF in the affected code
path. Please check again before I land this.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

fuz requested review of this revision.Thu, Dec 18, 11:42 PM

Approved. If this doesn't land soon, say in the next day or two, we should revert the original change until it does.

Approved. If this doesn't land soon, say in the next day or two, we should revert the original change until it does.

A change to completely disable the SIMD code until this is fixed (line 39) had already been committed when the regression was discovered, so the tree is currently in working order.

I've been using this patch for a couple of weeks. No problems so far.

This revision is now accepted and ready to land.Sun, Jan 4, 8:04 AM
This revision was automatically updated to reflect the committed changes.