From nobody Mon Feb 9 16:47:14 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1566177768; cv=none; d=zoho.com; s=zohoarc; b=gYVax7e5K2QNtJ8mVE8PzMysrYcmJoGxvZK7ov5pPjo0bSnyDXy4FVC+1n7jiU7jUMmsRaC1urEtlS0vkmRWi9HClsOuxdNR5PS37deeZ1NlVkdJ49t6giX/kQijVo9EFgEgtX0hNxmVT1mJNBJFCZWrCY3zC9EdXq47RsaFt28= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566177768; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=sAcbJxYLuzMNUL3FcbwHFyo3IZO8oPYKCLh5bw8kq3Y=; b=KXDDpuAovdNoPFbL8q+me+2iEVbyGslFBxIZnSwNxin+k9jV+IvAj8VDMt1lCaypa7gi2h/vENJkl8cnIGa5y8VyOX5OvMNVWaUUGY5GI7NfmDkmtR/43iKqSGI8zFRrPvYCQ/XDOr6S+Dl4TtiXLJ+h/q44wFECtqBXgToU+As= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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 15661777689729.02956432045653; Sun, 18 Aug 2019 18:22:48 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hzWMn-0001Cm-85; Mon, 19 Aug 2019 01:21:49 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hzWMm-0001Bp-9z for xen-devel@lists.xenproject.org; Mon, 19 Aug 2019 01:21:48 +0000 Received: from mga03.intel.com (unknown [134.134.136.65]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id b6ac3130-c21f-11e9-8be6-12813bfff9fa; Mon, 19 Aug 2019 01:21:47 +0000 (UTC) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Aug 2019 18:21:47 -0700 Received: from gao-cwp.sh.intel.com ([10.239.159.26]) by orsmga001.jf.intel.com with ESMTP; 18 Aug 2019 18:21:45 -0700 X-Inumbo-ID: b6ac3130-c21f-11e9-8be6-12813bfff9fa X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,403,1559545200"; d="scan'208";a="261683905" From: Chao Gao To: xen-devel@lists.xenproject.org Date: Mon, 19 Aug 2019 09:25:21 +0800 Message-Id: <1566177928-19114-9-git-send-email-chao.gao@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1566177928-19114-1-git-send-email-chao.gao@intel.com> References: <1566177928-19114-1-git-send-email-chao.gao@intel.com> Subject: [Xen-devel] [PATCH v9 08/15] microcode/amd: call svm_host_osvw_init() in common code 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: Ashok Raj , Wei Liu , Andrew Cooper , Jan Beulich , Chao Gao , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Introduce a vendor hook, .end_update, for svm_host_osvw_init(). The hook function is called on each cpu after loading an update. It is a preparation for spliting out apply_microcode() from cpu_request_microcode(). Note that svm_host_osvm_init() should be called regardless of the result of loading an update. Signed-off-by: Chao Gao Reviewed-by: Roger Pau Monn=C3=A9 --- Changes in v9: - call .end_update in early loading path - on AMD side, initialize .{start,end}_update only if "CONFIG_HVM" is true. --- xen/arch/x86/microcode.c | 10 +++++++++- xen/arch/x86/microcode_amd.c | 23 ++++++++++------------- xen/include/asm-x86/microcode.h | 1 + 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/microcode.c b/xen/arch/x86/microcode.c index 3b87c72..c9401a7 100644 --- a/xen/arch/x86/microcode.c +++ b/xen/arch/x86/microcode.c @@ -277,6 +277,9 @@ static long do_microcode_update(void *_info) if ( error ) info->error =3D error; =20 + if ( microcode_ops->end_update ) + microcode_ops->end_update(); + info->cpu =3D cpumask_next(info->cpu, &cpu_online_map); if ( info->cpu < nr_cpu_ids ) return continue_hypercall_on_cpu(info->cpu, do_microcode_update, i= nfo); @@ -377,7 +380,12 @@ int __init early_microcode_update_cpu(bool start_updat= e) if ( rc ) return rc; =20 - return microcode_update_cpu(data, len); + rc =3D microcode_update_cpu(data, len); + + if ( microcode_ops->end_update ) + microcode_ops->end_update(); + + return rc; } else return -ENOMEM; diff --git a/xen/arch/x86/microcode_amd.c b/xen/arch/x86/microcode_amd.c index dd3821c..b85fb04 100644 --- a/xen/arch/x86/microcode_amd.c +++ b/xen/arch/x86/microcode_amd.c @@ -594,10 +594,6 @@ static int cpu_request_microcode(const void *buf, size= _t bufsize) xfree(mc_amd); =20 out: -#if CONFIG_HVM - svm_host_osvw_init(); -#endif - /* * In some cases we may return an error even if processor's microcode = has * been updated. For example, the first patch in a container file is l= oaded @@ -609,27 +605,28 @@ static int cpu_request_microcode(const void *buf, siz= e_t bufsize) =20 static int start_update(void) { -#if CONFIG_HVM /* - * We assume here that svm_host_osvw_init() will be called on each cpu= (from - * cpu_request_microcode()). - * - * Note that if collect_cpu_info() returns an error then - * cpu_request_microcode() will not invoked thus leaving OSVW bits not - * updated. Currently though collect_cpu_info() will not fail on proce= ssors - * supporting OSVW so we will not deal with this possibility. + * svm_host_osvw_init() will be called on each cpu by calling '.end_up= date' + * in common code. */ svm_host_osvw_reset(); -#endif =20 return 0; } =20 +static void end_update(void) +{ + svm_host_osvw_init(); +} + static const struct microcode_ops microcode_amd_ops =3D { .cpu_request_microcode =3D cpu_request_microcode, .collect_cpu_info =3D collect_cpu_info, .apply_microcode =3D apply_microcode, +#if CONFIG_HVM .start_update =3D start_update, + .end_update =3D end_update, +#endif .free_patch =3D free_patch, .compare_patch =3D compare_patch, .match_cpu =3D match_cpu, diff --git a/xen/include/asm-x86/microcode.h b/xen/include/asm-x86/microcod= e.h index 35223eb..c8d2c4f 100644 --- a/xen/include/asm-x86/microcode.h +++ b/xen/include/asm-x86/microcode.h @@ -24,6 +24,7 @@ struct microcode_ops { int (*collect_cpu_info)(struct cpu_signature *csig); int (*apply_microcode)(void); int (*start_update)(void); + void (*end_update)(void); void (*free_patch)(void *mc); bool (*match_cpu)(const struct microcode_patch *patch); enum microcode_match_result (*compare_patch)( --=20 1.8.3.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel