[PATCH 03/11] xen/platform_op: Wrap around XENPF_microcode_update(2)

Jiqian Chen posted 11 patches 3 months, 1 week ago
[PATCH 03/11] xen/platform_op: Wrap around XENPF_microcode_update(2)
Posted by Jiqian Chen 3 months, 1 week ago
ucode_update_hcall() is only used for XENPF_microcode_update and
XENPF_microcode_update2, so wrap it and its call stack functions:
ucode_update_hcall
	ucode_update_hcall_cont
		do_microcode_update
			control_thread_fn
				microcode_nmi_callback
					is_cpu_primary
					primary_thread_work
					secondary_nmi_work
						wait_for_state
				set_state
				wait_for_condition
				wait_cpu_callin
				wait_cpu_callout
			primary_thread_fn
			secondary_thread_fn

Signed-off-by: Jiqian Chen <Jiqian.Chen@amd.com>
---
cc: Jan Beulich <jbeulich@suse.com>
cc: Andrew Cooper <andrew.cooper3@citrix.com>
cc: "Roger Pau Monné" <roger.pau@citrix.com>
---
 xen/arch/x86/cpu/microcode/core.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode/core.c
index 816e9bfe40ba..ec306cea895e 100644
--- a/xen/arch/x86/cpu/microcode/core.c
+++ b/xen/arch/x86/cpu/microcode/core.c
@@ -59,6 +59,7 @@
 #define MICROCODE_UPDATE_TIMEOUT_US 1000000
 
 static bool __initdata ucode_mod_forced;
+#ifdef CONFIG_PLATFORM_OP
 static unsigned int nr_cores;
 
 /*
@@ -76,6 +77,7 @@ static enum {
     LOADING_ENTER,
     LOADING_EXIT,
 } loading_state;
+#endif /* CONFIG_PLATFORM_OP */
 
 struct patch_with_flags {
     unsigned int flags;
@@ -167,6 +169,7 @@ static struct microcode_ops __ro_after_init ucode_ops;
 static DEFINE_SPINLOCK(microcode_mutex);
 
 DEFINE_PER_CPU(struct cpu_signature, cpu_sig);
+#ifdef CONFIG_PLATFORM_OP
 /* Store error code of the work done in NMI handler */
 static DEFINE_PER_CPU(int, loading_err);
 
@@ -183,6 +186,7 @@ static struct patch_with_flags nmi_patch =
 {
     .patch  = ZERO_BLOCK_PTR,
 };
+#endif /* CONFIG_PLATFORM_OP */
 
 /*
  * Return a patch that covers current CPU. If there are multiple patches,
@@ -195,6 +199,7 @@ static struct microcode_patch *parse_blob(const char *buf, size_t len)
     return alternative_call(ucode_ops.cpu_request_microcode, buf, len, true);
 }
 
+#ifdef CONFIG_PLATFORM_OP
 /* Returns true if ucode should be loaded on a given cpu */
 static bool is_cpu_primary(unsigned int cpu)
 {
@@ -646,6 +651,7 @@ int ucode_update_hcall(XEN_GUEST_HANDLE(const_void) buf,
      */
     return continue_hypercall_on_cpu(0, ucode_update_hcall_cont, buffer);
 }
+#endif /* CONFIG_PLATFORM_OP */
 
 /* Load a cached update to current cpu */
 int microcode_update_one(void)
-- 
2.34.1