Re: [PATCH] x86/cpu/hygon: Work around XSAVES Erratum 1386

From: Tina Zhang

Date: Sat Nov 21 2026 - 04:02:02 EST



On 11/21/2026 3:14 PM, Borislav Petkov wrote:
On Sat, Nov 21, 2026 at 02:46:31PM +0800, Tina Zhang wrote:
I'll extend the existing erratum_1386_microcode[] table with the Hygon
entries and make Hygon reuse fix_erratum_1386() instead of duplicating the
workaround in hygon.c.

Sorry that I couldn't jump in here earlier. Those folks are all giving you
confusing ideas, don't listen to them... :)

You simply need to copy the amd.c code and adjust it with your numbers.

The reason why we're copying and not sharing code with AMD is because AMD
cannot test on Hygon and thus risk breaking Hygon or you vice versa.

So we have it all separate, that's why there's a cpu/hygon.c.

Once it all settles and once we absolutely cannot live with the mini code
duplication this causes, then we can start unifying.

But that time hasn't come yet. For now we will do all separate.

Thanks and sorry again that I couldn't jump in in time.


Thanks for clarifying, Boris, and no worries.

I'll keep the implementation and microcode data self-contained in
hygon.c, as you suggested.

Andrew's pointer to the existing AMD workaround was still very helpful.
I'll follow the same established pattern for Hygon, but keep the actual implementation separate from AMD.

Dave's suggestion to describe the affected processors with x86_cpu_id
tables also makes the model and stepping selection much cleaner. I'll
retain that data-driven organization in the Hygon-specific
implementation instead of using explicit family/model checks and a switch statement.

The next version will therefore keep the workaround entirely in hygon.c, while following the AMD implementation pattern and using the CPU ID tables for the Hygon-specific processor and microcode data.

Thanks everyone for the review and guidance.

Tina