x86/ucode/amd: Remove gratuitous memory allocations from cpu_request_microcode()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 30 Mar 2020 17:50:25 +0000 (18:50 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 1 Apr 2020 13:00:12 +0000 (14:00 +0100)
commitf4c663b88b7a2b5e9d104307ab1ad1f357fd44c9
treeb009d00969b3393291fc34e4cd41707f3a89ce31
parent38f6f11d104b4053410de19efbe140ff49ac6224
x86/ucode/amd: Remove gratuitous memory allocations from cpu_request_microcode()

Just as on the Intel side, there is no point having
get_ucode_from_buffer_amd() make $N memory allocations and free $N-1 of them.

Delete get_ucode_from_buffer_amd() and rewrite the loop in
cpu_request_microcode() to have 'saved' point into 'buf' until we finally
decide to duplicate that blob and return it to our caller.

Introduce a new struct container_microcode to simplify interpreting the
container format.  Doubly indent the logic to substantially reduce the churn
in a later change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/cpu/microcode/amd.c