From patchwork Mon Mar 23 10:17:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11452613 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 8DF06174A for ; Mon, 23 Mar 2020 10:19:10 +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 69E402074D for ; Mon, 23 Mar 2020 10:19:10 +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="fZk3aMQg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 69E402074D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass 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 1jGK9L-0007Vk-Ar; Mon, 23 Mar 2020 10:17:39 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jGK9J-0007VF-Gv for xen-devel@lists.xenproject.org; Mon, 23 Mar 2020 10:17:37 +0000 X-Inumbo-ID: 816027e1-6cef-11ea-829d-12813bfff9fa Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 816027e1-6cef-11ea-829d-12813bfff9fa; Mon, 23 Mar 2020 10:17:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1584958652; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6EHUmISE0rB4Cji1BaxN5Ahahi+xG3W8SbhZePFiOBA=; b=fZk3aMQgJsMp8fHHaZcWBD2qVtIlWmZN7K7db5cyH7uFTAlH7dVMEfO3 3QTCd0fHeXjJIwBRhP37+ZYALnMlv3uB/AvjdQga7v7rnxEYzQFA5V6Q7 B0QYoIJyndC+E/8+eTQ0BDC0ruPcOdk7bebZm1iD0FNzA8tSjdTzT6U7u U=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: erf+zgqO8iNIhBxXT49sTVGEdckxSl7VDMfVDjGRbbWl7caz4FuDWOfTutBt7Z+LSacQSvAesx ygUBqTy3gbVLvr5ZfcmMRp7TNvnVuN/ut3V4p82Hu2AmtPyz7OCqBusTlkAJn7XjoytHFZtyAs lR1qlO8k72xYwaQrboL7+t2jQxM13uWfUOmLhQqUVuN6GoA74nR9KTkhenpYnAsWTZPr0vswoP YwAFfz/jmunmw6LocQlFC+N9J2Of0uNIWmHh6jalAgUP1qA8xwpY076lh4JoxKQK+CwlPzCBoj nTY= X-SBRS: 2.7 X-MesageID: 14866919 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.72,296,1580792400"; d="scan'208";a="14866919" From: Andrew Cooper To: Xen-devel Date: Mon, 23 Mar 2020 10:17:18 +0000 Message-ID: <20200323101724.15655-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200323101724.15655-1-andrew.cooper3@citrix.com> References: <20200323101724.15655-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 1/7] x86/ucode: Document the behaviour of the microcode_ops hooks 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: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" ... and struct cpu_signature for good measure. No comment is passed on the suitability of the behaviour... Signed-off-by: Andrew Cooper Acked-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monné --- xen/arch/x86/cpu/microcode/private.h | 46 ++++++++++++++++++++++++++++++++++++ xen/include/asm-x86/microcode.h | 5 ++++ 2 files changed, 51 insertions(+) diff --git a/xen/arch/x86/cpu/microcode/private.h b/xen/arch/x86/cpu/microcode/private.h index e64168a502..a2aec53047 100644 --- a/xen/arch/x86/cpu/microcode/private.h +++ b/xen/arch/x86/cpu/microcode/private.h @@ -14,14 +14,60 @@ enum microcode_match_result { struct microcode_patch; /* Opaque */ struct microcode_ops { + /* + * Parse a microcode container. Format is vendor-specific. + * + * Search within the container for the patch, suitable for the current + * CPU, which has the highest revision. (Note: May be a patch which is + * older that what is running in the CPU. This is a feature, to better + * cope with corner cases from buggy firmware.) + * + * If one is found, allocate and return a struct microcode_patch + * encapsulating the appropriate microcode patch. Does not alias the + * original buffer. + * + * If one is not found, (nothing matches the current CPU), return NULL. + * Also may return ERR_PTR(-err), e.g. bad container, out of memory. + */ struct microcode_patch *(*cpu_request_microcode)(const void *buf, size_t size); + + /* Obtain microcode-relevant details for the current CPU. */ int (*collect_cpu_info)(struct cpu_signature *csig); + + /* + * Attempt to load the provided patch into the CPU. Returns -EIO if + * anything didn't go as expected. + */ int (*apply_microcode)(const struct microcode_patch *patch); + + /* + * Optional. If provided and applicable to the specific update attempt, + * is run once by the initiating CPU. Returning an error will abort the + * load attempt. + */ int (*start_update)(void); + + /* + * Optional. If provided, called on every CPU which completes a microcode + * load. May be called in the case of some errors, and not others. May + * be called even if start_update() wasn't. + */ void (*end_update_percpu)(void); + + /* Free a patch previously allocated by cpu_request_microcode(). */ void (*free_patch)(struct microcode_patch *patch); + + /* + * Is the microcode patch applicable for the current CPU, and newer than + * the currently running patch? + */ bool (*match_cpu)(const struct microcode_patch *patch); + + /* + * Given two patches, are they both applicable to the current CPU, and is + * new a higher revision than old? + */ enum microcode_match_result (*compare_patch)( const struct microcode_patch *new, const struct microcode_patch *old); }; diff --git a/xen/include/asm-x86/microcode.h b/xen/include/asm-x86/microcode.h index 89b9aaa02d..41e85a24d2 100644 --- a/xen/include/asm-x86/microcode.h +++ b/xen/include/asm-x86/microcode.h @@ -7,8 +7,13 @@ #include struct cpu_signature { + /* CPU signature (CPUID.1.EAX). Only written on Intel. */ unsigned int sig; + + /* Platform Flags (only actually 1 bit). Only applicable to Intel. */ unsigned int pf; + + /* Microcode Revision. */ unsigned int rev; };