From patchwork Wed Mar 18 21:05:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11446067 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 9469313B1 for ; Wed, 18 Mar 2020 21:07:41 +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 658EC20775 for ; Wed, 18 Mar 2020 21:07:41 +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="Pd71npqP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 658EC20775 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 1jEfsq-0007Y5-8D; Wed, 18 Mar 2020 21:05:48 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jEfsp-0007Y0-Fk for xen-devel@lists.xenproject.org; Wed, 18 Mar 2020 21:05:47 +0000 X-Inumbo-ID: 3c3bf270-695c-11ea-b34e-bc764e2007e4 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 3c3bf270-695c-11ea-b34e-bc764e2007e4; Wed, 18 Mar 2020 21:05:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1584565546; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=NK67VgtZBL9Iw9OOeVuXZ8sHCZAlIIKa0NVNNjny/bU=; b=Pd71npqPg/XhX/klhAecWIGCk6IAf08KFPr8/JRBrTIXO5fFgiLkbIoB blC4bW5GXUZkENm3ZFQG8AkVMb09pJlqo4++P6Sg9PR/Ri5l9bpODlWPG Qf5cab1AbwmM3gTzsXK5ltY/C17QEg00Q1LwIRT+RU4iziH0uIATRjnCg g=; 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: jtQtRzbqNLKuYtYUcnCZISLhW1vh54c7jvTpbahOLqv9/36yOfF5kHI3zjD6mXFX1dZr3DUi1G qUJC7XTlufMIz6pWs+K1XrCTv12XKvKKRm05ZoH+/7ZGyAKdRL1VciYhCPP9McVVhJ4t5qZUcV wldz8PM3Fjs4nU8G8b0GRrk1DOXYeGC7BO8+4dc512EUH2K3Vo5+5Gh69UCbSx1+YlS/N3CU1W BBy9m+72aY0jkv9pHrjczrUjhgxcHO0FHVv4JBj8DXJBNn3XYkjiqgQBkiBQxJNtW2jPfZ0FtD wuE= X-SBRS: 2.7 X-MesageID: 14651278 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.70,569,1574139600"; d="scan'208";a="14651278" From: Andrew Cooper To: Xen-devel Date: Wed, 18 Mar 2020 21:05:40 +0000 Message-ID: <20200318210540.5602-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] xen/x86: Move microcode into its own directory 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" Split the existing asm/microcode.h in half, keeping the per-cpu cpu_sig available to external users, and moving everything else into private.h Take the opportunity to trim and clean up the include lists for all 3 source files, all of which include rather more than necessary. No functional change. Signed-off-by: Andrew Cooper Acked-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monné Inclusion of asm/flushtlb.h in isolation was broken by c/s 80943aa40e, and the commit message even states this breakage. I'm surprised it got accepted. Either this needs fixing, or the 23(!) other files including asm/flushtlb.h should be adjusted. Personally I don't think it is reasonable to require including xen/mm.h just to get at tlb flushing functionality, but I also can't spot an obvious way to untangle the dependencies (hence the TODO). --- xen/arch/x86/Makefile | 4 +-- xen/arch/x86/microcode/Makefile | 3 ++ xen/arch/x86/{microcode_amd.c => microcode/amd.c} | 12 ++++---- xen/arch/x86/{microcode.c => microcode/core.c} | 15 +++------- .../x86/{microcode_intel.c => microcode/intel.c} | 9 ++---- .../microcode.h => arch/x86/microcode/private.h} | 19 ++++--------- xen/include/asm-x86/microcode.h | 32 ---------------------- 7 files changed, 22 insertions(+), 72 deletions(-) create mode 100644 xen/arch/x86/microcode/Makefile rename xen/arch/x86/{microcode_amd.c => microcode/amd.c} (99%) rename xen/arch/x86/{microcode.c => microcode/core.c} (99%) rename xen/arch/x86/{microcode_intel.c => microcode/intel.c} (98%) copy xen/{include/asm-x86/microcode.h => arch/x86/microcode/private.h} (79%) diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index ed709e2373..fa87520c66 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -43,9 +43,7 @@ obj-$(CONFIG_INDIRECT_THUNK) += indirect-thunk.o obj-y += ioport_emulate.o obj-y += irq.o obj-$(CONFIG_KEXEC) += machine_kexec.o -obj-y += microcode_amd.o -obj-y += microcode_intel.o -obj-y += microcode.o +obj-y += microcode/ obj-y += mm.o x86_64/mm.o obj-$(CONFIG_HVM) += monitor.o obj-y += mpparse.o diff --git a/xen/arch/x86/microcode/Makefile b/xen/arch/x86/microcode/Makefile new file mode 100644 index 0000000000..aae235245b --- /dev/null +++ b/xen/arch/x86/microcode/Makefile @@ -0,0 +1,3 @@ +obj-y += amd.o +obj-y += core.o +obj-y += intel.o diff --git a/xen/arch/x86/microcode_amd.c b/xen/arch/x86/microcode/amd.c similarity index 99% rename from xen/arch/x86/microcode_amd.c rename to xen/arch/x86/microcode/amd.c index bc7459416c..9028889813 100644 --- a/xen/arch/x86/microcode_amd.c +++ b/xen/arch/x86/microcode/amd.c @@ -16,16 +16,14 @@ #include #include -#include -#include -#include -#include -#include +#include /* TODO: Fix asm/tlbflush.h breakage */ +#include #include #include -#include -#include +#include + +#include "private.h" #define pr_debug(x...) ((void)0) diff --git a/xen/arch/x86/microcode.c b/xen/arch/x86/microcode/core.c similarity index 99% rename from xen/arch/x86/microcode.c rename to xen/arch/x86/microcode/core.c index 6907b312cf..e99f4ab06c 100644 --- a/xen/arch/x86/microcode.c +++ b/xen/arch/x86/microcode/core.c @@ -22,29 +22,22 @@ */ #include +#include #include +#include #include -#include -#include -#include #include -#include -#include -#include #include #include -#include -#include -#include #include #include #include -#include #include #include #include -#include + +#include "private.h" /* * Before performing a late microcode update on any thread, we diff --git a/xen/arch/x86/microcode_intel.c b/xen/arch/x86/microcode/intel.c similarity index 98% rename from xen/arch/x86/microcode_intel.c rename to xen/arch/x86/microcode/intel.c index 91b7d473f7..90fb006c94 100644 --- a/xen/arch/x86/microcode_intel.c +++ b/xen/arch/x86/microcode/intel.c @@ -23,15 +23,12 @@ #include #include -#include -#include -#include -#include -#include #include #include -#include +#include + +#include "private.h" #define pr_debug(x...) ((void)0) diff --git a/xen/include/asm-x86/microcode.h b/xen/arch/x86/microcode/private.h similarity index 79% copy from xen/include/asm-x86/microcode.h copy to xen/arch/x86/microcode/private.h index 7d5a1f8e8a..97c7405dad 100644 --- a/xen/include/asm-x86/microcode.h +++ b/xen/arch/x86/microcode/private.h @@ -1,7 +1,9 @@ -#ifndef ASM_X86__MICROCODE_H -#define ASM_X86__MICROCODE_H +#ifndef ASM_X86_MICROCODE_PRIVATE_H +#define ASM_X86_MICROCODE_PRIVATE_H -#include +#include + +#include enum microcode_match_result { OLD_UCODE, /* signature matched, but revision id is older or equal */ @@ -9,8 +11,6 @@ enum microcode_match_result { MIS_UCODE, /* signature mismatched */ }; -struct cpu_signature; - struct microcode_patch { union { struct microcode_intel *mc_intel; @@ -32,15 +32,8 @@ struct microcode_ops { const struct microcode_patch *new, const struct microcode_patch *old); }; -struct cpu_signature { - unsigned int sig; - unsigned int pf; - unsigned int rev; -}; - -DECLARE_PER_CPU(struct cpu_signature, cpu_sig); extern const struct microcode_ops *microcode_ops; void microcode_free_patch(struct microcode_patch *patch); -#endif /* ASM_X86__MICROCODE_H */ +#endif /* ASM_X86_MICROCODE_PRIVATE_H */ diff --git a/xen/include/asm-x86/microcode.h b/xen/include/asm-x86/microcode.h index 7d5a1f8e8a..9b6ff7db08 100644 --- a/xen/include/asm-x86/microcode.h +++ b/xen/include/asm-x86/microcode.h @@ -3,35 +3,6 @@ #include -enum microcode_match_result { - OLD_UCODE, /* signature matched, but revision id is older or equal */ - NEW_UCODE, /* signature matched, but revision id is newer */ - MIS_UCODE, /* signature mismatched */ -}; - -struct cpu_signature; - -struct microcode_patch { - union { - struct microcode_intel *mc_intel; - struct microcode_amd *mc_amd; - void *mc; - }; -}; - -struct microcode_ops { - struct microcode_patch *(*cpu_request_microcode)(const void *buf, - size_t size); - int (*collect_cpu_info)(struct cpu_signature *csig); - int (*apply_microcode)(const struct microcode_patch *patch); - int (*start_update)(void); - void (*end_update_percpu)(void); - void (*free_patch)(void *mc); - bool (*match_cpu)(const struct microcode_patch *patch); - enum microcode_match_result (*compare_patch)( - const struct microcode_patch *new, const struct microcode_patch *old); -}; - struct cpu_signature { unsigned int sig; unsigned int pf; @@ -39,8 +10,5 @@ struct cpu_signature { }; DECLARE_PER_CPU(struct cpu_signature, cpu_sig); -extern const struct microcode_ops *microcode_ops; - -void microcode_free_patch(struct microcode_patch *patch); #endif /* ASM_X86__MICROCODE_H */