On Tue, 6 Oct 2026 at 17:51, Richard Biener <[email protected]> wrote:
>
>
>
> > Am 06.10.2026 um 18:37 schrieb Sammy Al Hashemi <[email protected]>:
> >
> > From: Sammyalhashe <[email protected]>
> >
> > Patching libstdc++ random so that it checks if rdrand on amd is broken
> > before returning a value.
> >
> > AMD 3000 CPUs seem to have a bug where the RDRAND instruction always
> > emits all 1s (aka 4294967295).
> >
> > This commit provides a workaround (upon detecting an AMD cpu) - to try
> > the random function a number of times. If it continues to return the
> > same broken consistent value, we confirm the random instruction is buggy
> > on this cpu and emit a runtime error.
>
> Is that a good failure mode upon libstdc++ upgrade ? IIRC the kernel will 
> stop advertising the feature on buggy CPUs, so if we can statically detect 
> this then we can use a fallback implementation based on a static var?

As you said in PR 100444, the bug occurs after suspend/resume, so an
application can be running fine with working rdrand instructions, then
the system is suspended and when it resumes the rdrand stops working.
So a static var would not handle that scenario. It would detect that
the instruction works, remember that, and then be wrong when it stops
working later.

Reply via email to