x86/microcode: reduce memory allocation and copy when creating a patch
authorChao Gao <chao.gao@intel.com>
Fri, 27 Sep 2019 12:18:10 +0000 (14:18 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 27 Sep 2019 12:18:10 +0000 (14:18 +0200)
commitc2b276501945efccbbf2769eb32840b4d6d1c848
tree3f258b85d502ebb84db1824db9a6b124fe801c94
parentc6f4df21580b6c65d63011c172b779d209ff7fa9
x86/microcode: reduce memory allocation and copy when creating a patch

To create a microcode patch from a vendor-specific update,
allocate_microcode_patch() copied everything from the update.
It is not efficient. Essentially, we just need to go through
ucodes in the blob, find the one with the newest revision and
install it into the microcode_patch. In the process, buffers
like mc_amd, equiv_cpu_table (on AMD side), and mc (on Intel
side) can be reused. microcode_patch now is allocated after
it is sure that there is a matching ucode.

Signed-off-by: Chao Gao <chao.gao@intel.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/microcode_amd.c
xen/arch/x86/microcode_intel.c