x86: clear RDRAND CPUID bit on AMD family 15h/16h
authorJan Beulich <jbeulich@suse.com>
Wed, 27 May 2020 07:49:37 +0000 (09:49 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 27 May 2020 07:49:37 +0000 (09:49 +0200)
commit93401e28a84b9dc5945f5d0bf5bce68e9d5ee121
tree1528bf1a72b35570de21e87c8481b7941637aebe
parentd89e5e65f305740b2f7bd56e6f3b6c9c52ee0707
x86: clear RDRAND CPUID bit on AMD family 15h/16h

Inspired by Linux commit c49a0a80137c7ca7d6ced4c812c9e07a949f6f24:

    There have been reports of RDRAND issues after resuming from suspend on
    some AMD family 15h and family 16h systems. This issue stems from a BIOS
    not performing the proper steps during resume to ensure RDRAND continues
    to function properly.

    Update the CPU initialization to clear the RDRAND CPUID bit for any family
    15h and 16h processor that supports RDRAND. If it is known that the family
    15h or family 16h system does not have an RDRAND resume issue or that the
    system will not be placed in suspend, the "cpuid=rdrand" kernel parameter
    can be used to stop the clearing of the RDRAND CPUID bit.

    Note, that clearing the RDRAND CPUID bit does not prevent a processor
    that normally supports the RDRAND instruction from executing it. So any
    code that determined the support based on family and model won't #UD.

Warn if no explicit choice was given on affected hardware.

Check RDRAND functions at boot as well as after S3 resume (the retry
limit chosen is entirely arbitrary).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
docs/misc/xen-command-line.pandoc
xen/arch/x86/cpu/amd.c
xen/arch/x86/cpu/common.c
xen/arch/x86/cpuid.c
xen/include/asm-x86/processor.h