From nobody Sat May 4 16:05:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1591023539; cv=none; d=zohomail.com; s=zohoarc; b=n7ViMfRDB8vXHgUrvtQuM6h5BE9siBujCdbronWoBF5DFRpikNpiqlz9EEPYZcmKx69WU9Tto/ap/M4mKQyEvdnJm0E+qlX9/bjvFjv/S3p42d8GOd3Rs9gvNnDq0Uqfu+CkBx47rLwU7deWRR0Pnl/kinAQDD4d+E1zeSEzyKk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591023539; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=RAJrXn2+HRK2qk2R6vEPYkXuUbrUxT2jZZEi9OedAi0=; b=RM5ZHg+n7M09mdX7EnGTARySw9BmHGwWJKrrxXi64aFdTFXhzHXRjxJ0WMx/U6xx50X/FjrZDtah3aF7dcIQGydBihyNYmsup6BKdWDtYxrvXENT59XMCZgWYR6oePslt3wS8Hpdej6TuzVIqKRHFpyxASanjUE8m78MNNy60mo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1591023539098381.68245695569647; Mon, 1 Jun 2020 07:58:59 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jfltR-0000S6-Ci; Mon, 01 Jun 2020 14:58:25 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jfltP-0000RN-NW for xen-devel@lists.xenproject.org; Mon, 01 Jun 2020 14:58:23 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 560f8602-a418-11ea-9947-bc764e2007e4; Mon, 01 Jun 2020 14:58:22 +0000 (UTC) X-Inumbo-ID: 560f8602-a418-11ea-9947-bc764e2007e4 Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: 3aa6tkOX8BFo1ojd5/NrdAWpp3pC7JcKZ3SmeR3zZnAv5DKz+B0DAVG6vj7BVrs9BYvyVo7Cxv kO5kXiqYsGF2rxoCE6QO1VauM50C2fm8CicaRLYEfnqHjXveI4IhVkV/31BbCXErOMUYma0dIO /bEfOmLov3BPZFrLfQwmGloVFUyjerfoC1s1eJ7+2ULXl6P+fq7sOvb7NrCMj6HtfTfHOkcXhZ NqXdPG2ZyP8ScGcPVFm1jfJ0bzccrtEuU4AOoMWXn0tHxKN43Ozvk1VIeL28fJlO7aYAU4WBLV DFo= X-SBRS: 2.7 X-MesageID: 19671656 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.73,461,1583211600"; d="scan'208";a="19671656" From: Andrew Cooper To: Xen-devel Subject: [PATCH for-4.14] x86/ucode: Fix errors with start/end_update() Date: Mon, 1 Jun 2020 15:57:55 +0100 Message-ID: <20200601145755.3661-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Paul Durrant , Wei Liu , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" c/s 9267a439c "x86/ucode: Document the behaviour of the microcode_ops hooks" identified several poor behaviours of the start_update()/end_update_percpu() hooks. AMD have subsequently confirmed that OSVW don't, and are not expected to, change across a microcode load, rendering all of this complexity unecessary. Instead of fixing up the logic to not leave the OSVW state reset in a number of corner cases, delete the logic entirely. This in turn allows for the removal of the poorly-named 'start_update' parameter to microcode_update_one(). Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich Reviewed-by: Roger Pau Monn=C3=A9 --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 CC: Paul Durrant This wants backporting to 4.13, hence considering for 4.14 at this point. --- xen/arch/x86/acpi/power.c | 2 +- xen/arch/x86/cpu/microcode/amd.c | 17 ----------------- xen/arch/x86/cpu/microcode/core.c | 33 +++------------------------------ xen/arch/x86/cpu/microcode/private.h | 14 -------------- xen/arch/x86/smpboot.c | 2 +- xen/include/asm-x86/microcode.h | 2 +- 6 files changed, 6 insertions(+), 64 deletions(-) diff --git a/xen/arch/x86/acpi/power.c b/xen/arch/x86/acpi/power.c index 0cda362045..dfffe08e18 100644 --- a/xen/arch/x86/acpi/power.c +++ b/xen/arch/x86/acpi/power.c @@ -287,7 +287,7 @@ static int enter_state(u32 state) console_end_sync(); watchdog_enable(); =20 - microcode_update_one(true); + microcode_update_one(); =20 if ( !recheck_cpu_features(0) ) panic("Missing previously available feature(s)\n"); diff --git a/xen/arch/x86/cpu/microcode/amd.c b/xen/arch/x86/cpu/microcode/= amd.c index 3f0969e70d..11e24637e7 100644 --- a/xen/arch/x86/cpu/microcode/amd.c +++ b/xen/arch/x86/cpu/microcode/amd.c @@ -395,26 +395,9 @@ static struct microcode_patch *cpu_request_microcode(c= onst void *buf, size_t siz return patch; } =20 -#ifdef CONFIG_HVM -static int start_update(void) -{ - /* - * svm_host_osvw_init() will be called on each cpu by calling '.end_up= date' - * in common code. - */ - svm_host_osvw_reset(); - - return 0; -} -#endif - const struct microcode_ops amd_ucode_ops =3D { .cpu_request_microcode =3D cpu_request_microcode, .collect_cpu_info =3D collect_cpu_info, .apply_microcode =3D apply_microcode, -#ifdef CONFIG_HVM - .start_update =3D start_update, - .end_update_percpu =3D svm_host_osvw_init, -#endif .compare_patch =3D compare_patch, }; diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index d879d28787..18ebc07b13 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -546,9 +546,6 @@ static int do_microcode_update(void *patch) else ret =3D secondary_thread_fn(); =20 - if ( microcode_ops->end_update_percpu ) - microcode_ops->end_update_percpu(); - return ret; } =20 @@ -620,16 +617,6 @@ static long microcode_update_helper(void *data) } spin_unlock(µcode_mutex); =20 - if ( microcode_ops->start_update ) - { - ret =3D microcode_ops->start_update(); - if ( ret ) - { - microcode_free_patch(patch); - goto put; - } - } - cpumask_clear(&cpu_callin_map); atomic_set(&cpu_out, 0); atomic_set(&cpu_updated, 0); @@ -728,28 +715,14 @@ static int __init microcode_init(void) __initcall(microcode_init); =20 /* Load a cached update to current cpu */ -int microcode_update_one(bool start_update) +int microcode_update_one(void) { - int err; - if ( !microcode_ops ) return -EOPNOTSUPP; =20 microcode_ops->collect_cpu_info(); =20 - if ( start_update && microcode_ops->start_update ) - { - err =3D microcode_ops->start_update(); - if ( err ) - return err; - } - - err =3D microcode_update_cpu(NULL); - - if ( microcode_ops->end_update_percpu ) - microcode_ops->end_update_percpu(); - - return err; + return microcode_update_cpu(NULL); } =20 /* BSP calls this function to parse ucode blob and then apply an update. */ @@ -790,7 +763,7 @@ static int __init early_microcode_update_cpu(void) spin_unlock(µcode_mutex); ASSERT(rc); =20 - return microcode_update_one(true); + return microcode_update_one(); } =20 int __init early_microcode_init(void) diff --git a/xen/arch/x86/cpu/microcode/private.h b/xen/arch/x86/cpu/microc= ode/private.h index dc5c7a81ae..c00ba590d1 100644 --- a/xen/arch/x86/cpu/microcode/private.h +++ b/xen/arch/x86/cpu/microcode/private.h @@ -46,20 +46,6 @@ struct microcode_ops { int (*apply_microcode)(const struct microcode_patch *patch); =20 /* - * Optional. If provided and applicable to the specific update attemp= t, - * is run once by the initiating CPU. Returning an error will abort t= he - * load attempt. - */ - int (*start_update)(void); - - /* - * Optional. If provided, called on every CPU which completes a micro= code - * load. May be called in the case of some errors, and not others. M= ay - * be called even if start_update() wasn't. - */ - void (*end_update_percpu)(void); - - /* * Given two patches, are they both applicable to the current CPU, and= is * new a higher revision than old? */ diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 13b3dade9c..f878a00760 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -369,7 +369,7 @@ void start_secondary(void *unused) =20 initialize_cpu_data(cpu); =20 - microcode_update_one(false); + microcode_update_one(); =20 /* * If MSR_SPEC_CTRL is available, apply Xen's default setting and disc= ard diff --git a/xen/include/asm-x86/microcode.h b/xen/include/asm-x86/microcod= e.h index 9da63f992e..3b0234e9fa 100644 --- a/xen/include/asm-x86/microcode.h +++ b/xen/include/asm-x86/microcode.h @@ -22,6 +22,6 @@ DECLARE_PER_CPU(struct cpu_signature, cpu_sig); void microcode_set_module(unsigned int idx); int microcode_update(XEN_GUEST_HANDLE(const_void), unsigned long len); int early_microcode_init(void); -int microcode_update_one(bool start_update); +int microcode_update_one(void); =20 #endif /* ASM_X86__MICROCODE_H */ --=20 2.11.0