From cae15066089715fd10b03687283f47c7083c08ae Mon Sep 17 00:00:00 2001 From: Zhenzhong Duan Date: Thu, 26 Jun 2014 17:18:23 +0800 Subject: [PATCH] xen/microcode: Use dummy microcode_ops for non initial domain guest Orabug: 19053626 Currently non initial domain guest use Intel or AMD specific ops. This will also slow up the startup on heavily overcommited guests (say 256VCPUs on 20 PCPU), as there are many read and write to x86 MSR registers which will trap to xen during microcode update. Finally it will fail and report errors. A dummy ops could fix that and also make udevd silent (bug18379824) by augmenting the commit c18a317f6892536851e5852b6aaa4ef42cbc11a2 "xen/microcode: Only load under initial domain." which fell short of its intended fix. Signed-off-by: Zhenzhong Duan Acked-by: Konrad Rzeszutek Wilk Signed-off-by: Guangyu Sun (cherry picked from commit 62b84234f23c1020c690d162b7d8250042425e1e) Signed-off-by: Konrad Rzeszutek Wilk Conflicts: arch/x86/kernel/microcode_core.c --- arch/x86/kernel/microcode_core.c | 2 +- arch/x86/kernel/microcode_xen.c | 35 +++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c index 38186572bfcd..805603100b1e 100644 --- a/arch/x86/kernel/microcode_core.c +++ b/arch/x86/kernel/microcode_core.c @@ -546,7 +546,7 @@ static int __init microcode_init(void) struct cpuinfo_x86 *c = &cpu_data(0); int error; - if (xen_pv_domain()) + if (xen_domain()) microcode_ops = init_xen_microcode(); else if (c->x86_vendor == X86_VENDOR_INTEL) microcode_ops = init_intel_microcode(); diff --git a/arch/x86/kernel/microcode_xen.c b/arch/x86/kernel/microcode_xen.c index 34f2a3a6b7dd..29ae2215b6f1 100644 --- a/arch/x86/kernel/microcode_xen.c +++ b/arch/x86/kernel/microcode_xen.c @@ -194,9 +194,38 @@ static struct microcode_ops microcode_xen_ops = { .microcode_fini_cpu = xen_microcode_fini_cpu, }; +static int dummy_xen_microcode_update(int cpu) +{ + return 0; +} + +static enum ucode_state dummy_xen_request_microcode_fw(int cpu, struct device *device) +{ + return UCODE_OK; +} + +static enum ucode_state dummy_xen_request_microcode_user(int cpu, + const void __user *buf, size_t size) +{ + return UCODE_OK; +} + +static void dummy_xen_microcode_fini_cpu(int cpu) +{ +} + +static struct microcode_ops microcode_dummy_xen_ops = { + .request_microcode_user = dummy_xen_request_microcode_user, + .request_microcode_fw = dummy_xen_request_microcode_fw, + .collect_cpu_info = xen_collect_cpu_info, + .apply_microcode = dummy_xen_microcode_update, + .microcode_fini_cpu = dummy_xen_microcode_fini_cpu, +}; + struct microcode_ops * __init init_xen_microcode(void) { - if (!xen_initial_domain()) - return NULL; - return µcode_xen_ops; + if (xen_initial_domain()) + return µcode_xen_ops; + else + return µcode_dummy_xen_ops; } -- 2.50.1