From patchwork Fri Nov 22 10:52:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sergey Dyasli X-Patchwork-Id: 11257725 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DDF026C1 for ; Fri, 22 Nov 2019 10:53:18 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B956E2070E for ; Fri, 22 Nov 2019 10:53:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="iLSNLdjZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B956E2070E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iY6Xv-0000d5-Sj; Fri, 22 Nov 2019 10:52:15 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iY6Xu-0000d0-7J for xen-devel@lists.xen.org; Fri, 22 Nov 2019 10:52:14 +0000 X-Inumbo-ID: 23467f1c-0d16-11ea-9631-bc764e2007e4 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 23467f1c-0d16-11ea-9631-bc764e2007e4; Fri, 22 Nov 2019 10:52:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1574419932; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=bRujceWkPNcpDP73fmp1sTpTovbp0lpQ4DSjX6d6T0g=; b=iLSNLdjZOa5/zEN7TmoYhV3czira/diZ/ff/tjUOv5lTMzFEAgy+yEbK oZomxN11V/xi3BaK+hycn9JdB98aBDnokoSh+Asg9xTzH88muDqygxDac oPfZy5O4ZGyJSYOUU/6QTEmHTTL0aHl1isY8p9YUBCcf96wTCuJyhHkD9 Q=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=sergey.dyasli@citrix.com; spf=Pass smtp.mailfrom=sergey.dyasli@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of sergey.dyasli@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="sergey.dyasli@citrix.com"; x-sender="sergey.dyasli@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.hc3370-68.iphmx.com: domain of sergey.dyasli@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="sergey.dyasli@citrix.com"; x-sender="sergey.dyasli@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="sergey.dyasli@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 3qk733YXkHDjqd53hSp4UhjYSsUXklb6TN1x3RZXQoTvWL9B900MyZrtvRL9wCPW1IYFBSV+oS Kjcu85K5BMtjqi0puyleNKNRdlNjP3K8jCEotd6O9cezegUegwd4f7Ik6OwNpTiL1Ax0ZcE7QQ UnAyD3FTS9ffI/4nvud5tNkhR2YBteCF/Zkc37LFmajOhLlee0dIOlTX9d6HjuWvrFTYSBv1yC EvFw1f3OR2DdjanwhslxlTjtj1jpJ/noRjoRn3C9BwpSmF4bZpcgmg0VEmAUmBvGtxJouqRdh2 oIg= X-SBRS: 2.7 X-MesageID: 8709342 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,229,1571716800"; d="scan'208";a="8709342" From: Sergey Dyasli To: Date: Fri, 22 Nov 2019 10:52:02 +0000 Message-ID: <20191122105202.25507-1-sergey.dyasli@citrix.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v1 for 4.13] x86/microcode: refuse to load the same revision ucode X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Sergey Dyasli , Andrew Cooper , Jan Beulich , Chao Gao , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Currently if a user tries to live-load the same ucode revision that CPU already has, he will get a single message in Xen log like: (XEN) 128 cores are to update their microcode No actual ucode loading will happen and this situation can be quite confusing. Fix this by starting ucode update only when a newer ucode revision has been provided. This is based on an assumption that all CPUs in the system have the same ucode revision. If that's not the case, the system must be considered unstable. Additionally, print a user friendly message if no newer ucode can be found. This also requires ignoring -ENODATA in AMD-side code, otherwise the message given to user is: (XEN) Parsing microcode blob error -61 Which actually means that a ucode blob was parsed fine, but no matching ucode was found. Signed-off-by: Sergey Dyasli --- CC: Jan Beulich CC: Andrew Cooper CC: Roger Pau Monné CC: Chao Gao CC: Juergen Gross --- xen/arch/x86/microcode.c | 2 ++ xen/arch/x86/microcode_amd.c | 4 ++-- xen/arch/x86/microcode_intel.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/microcode.c b/xen/arch/x86/microcode.c index 65d1f41e7c..255613569d 100644 --- a/xen/arch/x86/microcode.c +++ b/xen/arch/x86/microcode.c @@ -641,6 +641,8 @@ int microcode_update(XEN_GUEST_HANDLE_PARAM(const_void) buf, unsigned long len) if ( !patch ) { ret = -ENOENT; + printk(XENLOG_WARNING "microcode: couldn't find any newer revision in " + "the provided blob!\n"); goto put; } diff --git a/xen/arch/x86/microcode_amd.c b/xen/arch/x86/microcode_amd.c index 1e52f7f49a..dd81b5239a 100644 --- a/xen/arch/x86/microcode_amd.c +++ b/xen/arch/x86/microcode_amd.c @@ -518,7 +518,7 @@ static struct microcode_patch *cpu_request_microcode(const void *buf, * If the new ucode covers current CPU, compare ucodes and store the * one with higher revision. */ - if ( (microcode_fits(mc_amd) != MIS_UCODE) && + if ( (microcode_fits(mc_amd) == NEW_UCODE) && (!saved || (compare_header(mc_amd->mpb, saved) == NEW_UCODE)) ) { xfree(saved); @@ -576,7 +576,7 @@ static struct microcode_patch *cpu_request_microcode(const void *buf, free_patch(mc_amd); out: - if ( error && !patch ) + if ( error && error != -ENODATA && !patch ) patch = ERR_PTR(error); return patch; diff --git a/xen/arch/x86/microcode_intel.c b/xen/arch/x86/microcode_intel.c index 9f66057aad..a76b860226 100644 --- a/xen/arch/x86/microcode_intel.c +++ b/xen/arch/x86/microcode_intel.c @@ -377,7 +377,7 @@ static struct microcode_patch *cpu_request_microcode(const void *buf, * If the new update covers current CPU, compare updates and store the * one with higher revision. */ - if ( (microcode_update_match(&mc->hdr) != MIS_UCODE) && + if ( (microcode_update_match(&mc->hdr) == NEW_UCODE) && (!saved || (mc->hdr.rev > saved->hdr.rev)) ) { xfree(saved);