All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Wei Liu" <wl@xen.org>, "Jan Beulich" <JBeulich@suse.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [Xen-devel] [PATCH 2/6] x86/ucode: Move microcode into its own directory
Date: Thu, 19 Mar 2020 15:26:18 +0000	[thread overview]
Message-ID: <20200319152622.31758-3-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20200319152622.31758-1-andrew.cooper3@citrix.com>

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 <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wl@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>

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                              |  3 ---
 xen/arch/x86/cpu/Makefile                          |  1 +
 xen/arch/x86/cpu/microcode/Makefile                |  3 +++
 .../x86/{microcode_amd.c => cpu/microcode/amd.c}   | 12 ++++-----
 xen/arch/x86/{microcode.c => cpu/microcode/core.c} | 15 +++--------
 .../{microcode_intel.c => cpu/microcode/intel.c}   |  9 +++----
 .../x86/cpu/microcode/private.h}                   | 19 +++++---------
 xen/include/asm-x86/microcode.h                    | 30 ----------------------
 8 files changed, 22 insertions(+), 70 deletions(-)
 create mode 100644 xen/arch/x86/cpu/microcode/Makefile
 rename xen/arch/x86/{microcode_amd.c => cpu/microcode/amd.c} (99%)
 rename xen/arch/x86/{microcode.c => cpu/microcode/core.c} (99%)
 rename xen/arch/x86/{microcode_intel.c => cpu/microcode/intel.c} (98%)
 copy xen/{include/asm-x86/microcode.h => arch/x86/cpu/microcode/private.h} (78%)

diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index ed709e2373..e954edbc2e 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -43,9 +43,6 @@ 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 += mm.o x86_64/mm.o
 obj-$(CONFIG_HVM) += monitor.o
 obj-y += mpparse.o
diff --git a/xen/arch/x86/cpu/Makefile b/xen/arch/x86/cpu/Makefile
index de983006a1..35561fe51d 100644
--- a/xen/arch/x86/cpu/Makefile
+++ b/xen/arch/x86/cpu/Makefile
@@ -1,4 +1,5 @@
 obj-y += mcheck/
+obj-y += microcode/
 obj-y += mtrr/
 
 obj-y += amd.o
diff --git a/xen/arch/x86/cpu/microcode/Makefile b/xen/arch/x86/cpu/microcode/Makefile
new file mode 100644
index 0000000000..aae235245b
--- /dev/null
+++ b/xen/arch/x86/cpu/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/cpu/microcode/amd.c
similarity index 99%
rename from xen/arch/x86/microcode_amd.c
rename to xen/arch/x86/cpu/microcode/amd.c
index bc7459416c..9028889813 100644
--- a/xen/arch/x86/microcode_amd.c
+++ b/xen/arch/x86/cpu/microcode/amd.c
@@ -16,16 +16,14 @@
 
 #include <xen/err.h>
 #include <xen/init.h>
-#include <xen/kernel.h>
-#include <xen/lib.h>
-#include <xen/sched.h>
-#include <xen/smp.h>
-#include <xen/spinlock.h>
+#include <xen/mm.h> /* TODO: Fix asm/tlbflush.h breakage */
 
+#include <asm/hvm/svm/svm.h>
 #include <asm/msr.h>
 #include <asm/processor.h>
-#include <asm/microcode.h>
-#include <asm/hvm/svm/svm.h>
+#include <asm/system.h>
+
+#include "private.h"
 
 #define pr_debug(x...) ((void)0)
 
diff --git a/xen/arch/x86/microcode.c b/xen/arch/x86/cpu/microcode/core.c
similarity index 99%
rename from xen/arch/x86/microcode.c
rename to xen/arch/x86/cpu/microcode/core.c
index 27a88c6826..ac5da6b2fe 100644
--- a/xen/arch/x86/microcode.c
+++ b/xen/arch/x86/cpu/microcode/core.c
@@ -22,29 +22,22 @@
  */
 
 #include <xen/cpu.h>
+#include <xen/earlycpio.h>
 #include <xen/err.h>
+#include <xen/guest_access.h>
 #include <xen/init.h>
-#include <xen/kernel.h>
-#include <xen/lib.h>
-#include <xen/notifier.h>
 #include <xen/param.h>
-#include <xen/sched.h>
-#include <xen/smp.h>
-#include <xen/softirq.h>
 #include <xen/spinlock.h>
 #include <xen/stop_machine.h>
-#include <xen/tasklet.h>
-#include <xen/guest_access.h>
-#include <xen/earlycpio.h>
 #include <xen/watchdog.h>
 
 #include <asm/apic.h>
 #include <asm/delay.h>
-#include <asm/msr.h>
 #include <asm/nmi.h>
 #include <asm/processor.h>
 #include <asm/setup.h>
-#include <asm/microcode.h>
+
+#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/cpu/microcode/intel.c
similarity index 98%
rename from xen/arch/x86/microcode_intel.c
rename to xen/arch/x86/cpu/microcode/intel.c
index 91b7d473f7..90fb006c94 100644
--- a/xen/arch/x86/microcode_intel.c
+++ b/xen/arch/x86/cpu/microcode/intel.c
@@ -23,15 +23,12 @@
 
 #include <xen/err.h>
 #include <xen/init.h>
-#include <xen/kernel.h>
-#include <xen/lib.h>
-#include <xen/sched.h>
-#include <xen/smp.h>
-#include <xen/spinlock.h>
 
 #include <asm/msr.h>
 #include <asm/processor.h>
-#include <asm/microcode.h>
+#include <asm/system.h>
+
+#include "private.h"
 
 #define pr_debug(x...) ((void)0)
 
diff --git a/xen/include/asm-x86/microcode.h b/xen/arch/x86/cpu/microcode/private.h
similarity index 78%
copy from xen/include/asm-x86/microcode.h
copy to xen/arch/x86/cpu/microcode/private.h
index 1a2bbacc6c..2e3be79eaf 100644
--- a/xen/include/asm-x86/microcode.h
+++ b/xen/arch/x86/cpu/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 <xen/percpu.h>
+#include <xen/types.h>
+
+#include <asm/microcode.h>
 
 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,13 +32,6 @@ 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;
 
-#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 1a2bbacc6c..9b6ff7db08 100644
--- a/xen/include/asm-x86/microcode.h
+++ b/xen/include/asm-x86/microcode.h
@@ -3,35 +3,6 @@
 
 #include <xen/percpu.h>
 
-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,6 +10,5 @@ struct cpu_signature {
 };
 
 DECLARE_PER_CPU(struct cpu_signature, cpu_sig);
-extern const struct microcode_ops *microcode_ops;
 
 #endif /* ASM_X86__MICROCODE_H */
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2020-03-19 15:27 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-19 15:26 [Xen-devel] [PATCH 0/6] x86/ucode: Cleanup - Part 1/n Andrew Cooper
2020-03-19 15:26 ` [Xen-devel] [PATCH 1/6] x86/ucode: Remove declarations for non-external functions Andrew Cooper
2020-03-19 15:26 ` Andrew Cooper [this message]
2020-03-19 15:26 ` [Xen-devel] [PATCH 3/6] x86/ucode: Move interface from processor.h to microcode.h Andrew Cooper
2020-03-19 15:26 ` [Xen-devel] [PATCH 4/6] x86/ucode: Rationalise startup and family/model checks Andrew Cooper
2020-03-20 13:37   ` Jan Beulich
2020-03-20 13:40     ` Andrew Cooper
2020-03-20 13:56       ` Jan Beulich
2020-03-20 14:27         ` Andrew Cooper
2020-03-20 14:48           ` Jan Beulich
2020-03-19 15:26 ` [Xen-devel] [PATCH 5/6] x86/ucode: Alter ops->free_patch() to free the entire patch Andrew Cooper
2020-03-20 13:51   ` Jan Beulich
2020-03-20 14:50     ` Andrew Cooper
2020-03-20 15:15       ` Jan Beulich
2020-03-20 16:10         ` Andrew Cooper
2020-03-20 16:16           ` Jan Beulich
2020-03-20 16:48             ` Andrew Cooper
2020-03-23  7:52               ` Jan Beulich
2020-03-19 15:26 ` [Xen-devel] [PATCH 6/6] x86/ucode: Make struct microcode_patch opaque Andrew Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200319152622.31758-3-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.