|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH] x86/microcode: Support builtin CPU microcode
On 13.12.19 14:40, Andrew Cooper wrote: On 09/12/2019 21:49, Eslam Elnikety wrote:+ +extern const char __builtin_intel_ucode_start[], __builtin_intel_ucode_end[]; +extern const char __builtin_amd_ucode_start[], __builtin_amd_ucode_end[]; +#endif + /* By default, ucode loading is done in NMI handler */ static bool ucode_in_nmi = true; @@ -110,9 +118,9 @@ void __init microcode_set_module(unsigned int idx) } /* - * The format is '[<integer>|scan=<bool>, nmi=<bool>]'. Both options are - * optional. If the EFI has forced which of the multiboot payloads is to be - * used, only nmi=<bool> is parsed. + * The format is '[<integer>|scan=<bool>|builtin=<bool>, nmi=<bool>]'. All + * options are optional. If the EFI has forced which of the multiboot payloads + * is to be used, only nmi=<bool> is parsed. */Please delete this, or I'll do a prereq patch to fix it and the command line docs. (Both are in a poor state.)Unless you are planning that along your on-going docs/hypervisor-guide/microcode-loading.rst effort, I can pick up this clean-up/prereq patch myself. What do you have in mind? (Or point me to a good example and I will figure things out).c/s 3c5552954, 53a84f672, 633a40947 or 3136dee9c are good examples. ucode= is definitely more complicated to explain because of its implicit EFI behaviour. Currently massaging a patch to that effect.
Avoiding the xmalloc/memcpy on the scan for microcode is one of the patches that I will share shortly. In particular, the ucode_blob.data would directly point to the buffer matching the canonical name within the cpio name space. We are still a bit away from pushing the BSP microcode update earlier though. We will need to surgically remove all the unnecessary xmalloc/memcpy from within microcode_{amd,intel}.c. Also, as you hinted, the challenging bit is the per-cpu microcode cache. + +builtin_ucode.o: Makefile $(amd-blobs) $(intel-blobs) + # Create AMD microcode blob if there are AMD updates on the build system + if [ ! -z "$(amd-blobs)" ]; then \ + cat $(amd-blobs) > $@.bin ; \ + $(OBJCOPY) -I binary -O elf64-x86-64 -B i386:x86-64 --rename-section .data=.builtin_amd_ucode,alloc,load,readonly,data,contents $@.bin $@.amd; \ + rm -f $@.bin; \ + fi + # Create INTEL microcode blob if there are INTEL updates on the build system + if [ ! -z "$(intel-blobs)" ]; then \ + cat $(intel-blobs) > $@.bin; \ + $(OBJCOPY) -I binary -O elf64-x86-64 -B i386:x86-64 --rename-section .data=.builtin_intel_ucode,alloc,load,readonly,data,contents $@.bin $@.intel; \ + rm -f $@.bin; \ + fi + # Create fake builtin_ucode.o if no updates were present. Otherwise, builtin_ucode.o carries the available updates + if [ -z "$(amd-blobs)" -a -z "$(intel-blobs)" ]; then \ + $(CC) $(CFLAGS) -c -x c /dev/null -o $@; \ + else \ + $(LD) $(LDFLAGS) -r -o $@ $@.*; \ + rm -f $@.*; \ + fiHow about using weak symbols, rather than playing games like this?Just to make sure we are on the same page. You are after a dummy binary with weak symbols that eventually get overridden when I link the actual microcode binaries into builtin_ucode.o? If so, possible of course. Except that I do not particularly see the downside of the existing approach with dummy builtin_ucode.o.Actually, you don't even need week symbols. Size being 0 means that no blob was inserted. There doesn't appear to be a need to organise a dummy builtin_ucode.o, or to manually merge Intel/AMD together. Simply make obj-y += ucode-$VENDOR.o dependent on there being some blob to insert. I have reworked this part in v2 such that the configurations specify explicitly the individual microcode blobs to include. I have also adopted the "obj-y += ucode-$VENDOR.o" and made it dependent on the corresponding blobs being available. That said, I was not able to get rid of the dummy object. The dummy is still needed in case no amd nor intel ucode blobs were specified. In case of no microcode blobs, obj-y will not refer to any dependency within xen/arch/x86/microcode/ and there will be no rule to generate microcode/built_in.o (which is required for all subdir in xen/arch/x86/). Of course, we can do logic in xen/arch/x86/Makefile to mark microcode as a subdir iff there are microcode blobs available, but it seems to me that this logic does not belong there. Also, my initial attempt at this quickly proved that the dummy approach is way simpler. -- Eslam ~Andrew _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |