Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2644158rdb; Tue, 12 Sep 2023 08:03:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHStc+EQo0mqCctyobPdqkbNGXscH+RTVZQQ6k3DJLERkGIpfYhPQn/dxJqIoTwFf7LumLd X-Received: by 2002:a05:6a20:5486:b0:127:72c3:6427 with SMTP id i6-20020a056a20548600b0012772c36427mr18024330pzk.2.1694531007248; Tue, 12 Sep 2023 08:03:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694531007; cv=none; d=google.com; s=arc-20160816; b=M4XgFx3PeE3rIRUg4WYmuj0og0ziSBOsJdnBeqNfofcZyEtzp0w/yO8zdONnYjZwVJ Nn7Hd7sJOFAduLD7/Bo3gYsKsxazKu/2trXHtgwfam79r+IkzORF9SU6UBiZULEyU6uE rya4dlUHMB/ehCQd6Kq9/NqRgIoAFHx/yiyIdk1NTKZCFv//nfrmWs+beY+sbwooHOCN DyVJjMb0FYLXcKCQ7kzwrqy1img1bwjbrEA2Vwtz5BVeSLjYxsxsTPqKt6/wSL7eUeAV bPfS0baZzBWokYgNMDrBbqspNd5+gcoXSpQG8naUpmHIbGJPf6i9geQ7JiouxRt6/Iny fBWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:subject:cc:to:from:dkim-signature :dkim-signature:message-id; bh=AJw1wx6YPuzaZhvYGTfk54O9w+U0r7o+iwnk/Je3HJs=; fh=u57tXYamzTrJA+Ht8n1u7SfTMptrQaIb6LVW+jsaYf4=; b=gRBJ3cNoDtH6X4/xP/QvY7K5Kj8ythhptVvUJT/hkpTFYnG5Xmq/DtREl8RkoY28EG K/HuwKbAUVE347j+f1SKq24d7jKRVTg5fg6J3D9vgxeJkUF1xFzmGVeYqsG7/661AqM+ DpB8XiuKf20Q0bvbvLe9ADmUO+nbHpZ/fOro2cz4IkYN/nfvFOQTsOH5gnvfY0eKBe4Z Eh3U0sFczCOW2b+vVZTfD1hxxEjymS/xRGWFblquMM18uXm4Au9+bMBNbOSrWwY0pEbv IBl3XCb4We1oR75oraYWh8jZAuOETsLoXc8AWg2gOuhcVE6FE+tc3gvxBBltUtLaTh1X i1YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=IOD0lYYw; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id b3-20020a6567c3000000b005696a8e371csi7730488pgs.35.2023.09.12.08.03.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 08:03:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=IOD0lYYw; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 2556A81F3796; Tue, 12 Sep 2023 00:57:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231868AbjILH5u (ORCPT + 99 others); Tue, 12 Sep 2023 03:57:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231822AbjILH5t (ORCPT ); Tue, 12 Sep 2023 03:57:49 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6426310C2 for ; Tue, 12 Sep 2023 00:57:45 -0700 (PDT) Message-ID: <20230912065249.695681286@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694505463; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=AJw1wx6YPuzaZhvYGTfk54O9w+U0r7o+iwnk/Je3HJs=; b=IOD0lYYwGmgzv3nD4SUAMPlshas3CHBw0PElNpSBV0G/pJL/FeV1R8/Cfxk78uvibLQQUE 4kbrcUvzwpgS2hWqbEDgpDb8OpUkjD+QAOyIk9d8a1ilty6z1R37Q0jn2mCEIYiWUybMaz s/1XHE4PVQSl3U8pJuHFNpvz3O1dTxc0BKd1H4NF1FcZuYN3z7mUjF5aC+wItlYnGA7kfP gjdhsxsvAruGrf/1QVPvaocokP04EdOBEqAS0PrxzpYl3R88dGcHCVwjqno5QWeCDgEKed lAsaDw7gjF0eTu1wi+p0MR+/CtfABsv34PyHu7mC84KQUutLiheFsUw6FvZI1g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694505463; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=AJw1wx6YPuzaZhvYGTfk54O9w+U0r7o+iwnk/Je3HJs=; b=QsEQK975y5S1rul1ukUb6TKuSlENYV0iOnMCxQZf4vQoooPb90SaKQjrIEEGVzLwQeK0P0 88jgn0Fxuh4MR6CA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Borislav Petkov , "Chang S. Bae" , Arjan van de Ven , Nikolay Borisov Subject: [patch V3 00/30] x86/microcode: Cleanup and late loading enhancements Date: Tue, 12 Sep 2023 09:57:43 +0200 (CEST) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 12 Sep 2023 00:57:53 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email This is a follow up on: https://lore.kernel.org/lkml/20230812194003.682298127@linutronix.de Late microcode loading is desired by enterprise users. Late loading is problematic as it requires detailed knowledge about the change and an analysis whether this change modifies something which is already in use by the kernel. Large enterprise customers have engineering teams and access to deep technical vendor support. The regular admin does not have such resources, so the kernel has always tainted the kernel after late loading. Intel recently added a new previously reserved field to the microcode header which contains the minimal microcode revision which must be running on the CPU to make the load safe. This field is 0 in all older microcode revisions, which the kernel assumes to be unsafe. Minimal revision checking can be enforced via Kconfig or kernel command line. It then refuses to load an unsafe revision. The default loads unsafe revisions like before and taints the kernel. If a safe revision is loaded the kernel is not tainted. But that does not solve all other known problems with late loading: - Late loading on current Intel CPUs is unsafe vs. NMI when hyperthreading is enabled. If a NMI hits the secondary sibling while the primary loads the microcode, the machine can crash. - Soft offline SMT siblings which are playing dead with MWAIT can cause damage too when the microcode update modifies MWAIT. That's a realistic scenario in the context of 'nosmt' mitigations. :( Neither the core code nor the Intel specific code handles any of this at all. While trying to implement this, I stumbled over disfunctional, horribly complex and redundant code, which I decided to clean up first so the new functionality can be added on a clean slate. So the series has several sections: 1) Move the 32bit early loading after paging enable 2) Cleanup of the Intel specific code 3) Implementation of proper core control logic to handle the NMI safe requirements 4) Support for minimal revision check in the core and the Intel specific parts. Changes vs. V2: - Rebased on v6.5-rc1 - Removed the 32bit oddity of invoking the microcode loader before paging is enabled. - Some minor improvements. The series is also available from git: git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git ucode-v3 Thanks, tglx --- Documentation/admin-guide/kernel-parameters.txt | 5 arch/x86/Kconfig | 25 arch/x86/include/asm/apic.h | 5 arch/x86/include/asm/cpu.h | 20 arch/x86/include/asm/microcode.h | 16 arch/x86/kernel/Makefile | 1 arch/x86/kernel/apic/apic_flat_64.c | 2 arch/x86/kernel/apic/ipi.c | 8 arch/x86/kernel/apic/x2apic_cluster.c | 1 arch/x86/kernel/apic/x2apic_phys.c | 1 arch/x86/kernel/cpu/common.c | 12 arch/x86/kernel/cpu/microcode/amd.c | 57 -- arch/x86/kernel/cpu/microcode/core.c | 643 +++++++++++++++-------- arch/x86/kernel/cpu/microcode/intel.c | 659 ++++++------------------ arch/x86/kernel/cpu/microcode/internal.h | 32 - arch/x86/kernel/head32.c | 6 arch/x86/kernel/head_32.S | 10 arch/x86/kernel/nmi.c | 9 arch/x86/kernel/smpboot.c | 12 drivers/platform/x86/intel/ifs/load.c | 8 include/linux/cpuhotplug.h | 1 21 files changed, 740 insertions(+), 793 deletions(-)