From nobody Fri Nov 22 12:56:29 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; dkim=pass; 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=pass(p=reject dis=none) header.from=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1716910243; cv=none; d=zohomail.com; s=zohoarc; b=LuSuvKoLVi+twqXv8vCDTZI1wbmsvIgm/n/f5wBcetIwN4TZr4f5yl7d9ejJ/1/FmY12zQsqq1ogbEO75R4K1F/RZ/kOf77crN/e4Te2JGgjJmmupQ7MYFTx/Cjl9FyJIWrlw6H6/F6asF9LwzNH+79fVYIJ2OBChDPA0reCwzs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716910243; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bJX73ZmntNKRAs0BEZRhybEqHcJwu5VuVHE4B8+pY60=; b=l2HPh62aOGKRqi3EdLnrSHhhz3MxMFXepXj1CeGdZOMOIlxmCJgQLgOnljg98qVUMR53lu1cUGbcBCySPy7gwD3Rd8vvIQB87tf7AIa/rzUWBPSDAoa7w5AjVo7kpusWZVDk7WOahFlQvMsQFieI4tVbkaBGiq4/nwXINv53sGk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1716910243236457.9787235568257; Tue, 28 May 2024 08:30:43 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.731195.1136566 (Exim 4.92) (envelope-from ) id 1sBymC-0001Fo-8i; Tue, 28 May 2024 15:30:12 +0000 Received: by outflank-mailman (output) from mailman id 731195.1136566; Tue, 28 May 2024 15:30:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sBymC-0001FH-1d; Tue, 28 May 2024 15:30:12 +0000 Received: by outflank-mailman (input) for mailman id 731195; Tue, 28 May 2024 15:30:11 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sBymB-00018F-6L for xen-devel@lists.xenproject.org; Tue, 28 May 2024 15:30:11 +0000 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [2a00:1450:4864:20::633]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2accabe2-1d07-11ef-90a1-e314d9c70b13; Tue, 28 May 2024 17:30:09 +0200 (CEST) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-a6341cf2c99so98851466b.0 for ; Tue, 28 May 2024 08:30:09 -0700 (PDT) Received: from fhilly.citrite.net ([160.101.139.1]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a626c937444sm621673366b.61.2024.05.28.08.30.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 08:30:08 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2accabe2-1d07-11ef-90a1-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1716910208; x=1717515008; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bJX73ZmntNKRAs0BEZRhybEqHcJwu5VuVHE4B8+pY60=; b=jsH+tYRG95sELT8cWmsfGHEKCkPHYDNU3TW66Xhd9e98bau26M3lUVmgGOsC5GKd5m iLneUP35aqUVOdJkUOawonZiMCtloe9/+7D1B/kwKdD+flGQ50Ft56fS61TkqKFajSOA 7vSqM+qFtDmfgQMqZ3KwmBHMP5KWaoDy4cNQ4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716910208; x=1717515008; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bJX73ZmntNKRAs0BEZRhybEqHcJwu5VuVHE4B8+pY60=; b=Eh4PuwG0b4G7cGw3bmb766wb1N6DFYSygO5MnYEVKbB/BXNIrWGIPYo2PnK6PPTMV0 ZfILHwDUmZR8MGxlAqvYPIPoJUBIawN2xwlM56ffgGUV7tFr1SkpD38KXAl8FVrvpEXk 5sdY3XPhuQnXU+S0IYZyJvDSjg7aFBl47QQJNmJLOgJ3uc82MCwc2BTyd+DmZhUvyaWB T5ZV1wb51zOfngWOSVX5Dyw48yQC+MQ78KzNkuhCWd7hLmaNWj0OGO6tDs9+D9FptV6M OOLcKBzlOjpHlRx6frUUoW5KDN2wAzyOYYt4gN9cMVaHBczBI8Js1IzOJVmvlUNOKDYa QkgA== X-Gm-Message-State: AOJu0Yx87t1DNWHPTAp4KSCxodswAWOx/5HE0Q4V+SsmTbJ4m55P9sSx 9yl7pH/UcdORY25+lupDdXO5nIVd2RGFjNk32ofg9QyP7g9wxE9OrV+CM6w4yWxJc7YoIYSyElX 9U48= X-Google-Smtp-Source: AGHT+IHzLvVpGVHVUdhsRJaFBLhxIExE5P2Hb13QIBulTEa2VIkMdvPfsb8s3kG1g7MR5q0a2ZRzUg== X-Received: by 2002:a17:906:3741:b0:a5a:1f4f:cb4c with SMTP id a640c23a62f3a-a62641b4532mr886848066b.7.1716910208404; Tue, 28 May 2024 08:30:08 -0700 (PDT) From: Fouad Hilly To: Xen-devel Cc: Fouad Hilly , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , George Dunlap , Julien Grall , Stefano Stabellini Subject: [PATCH v4 1/4] x86/ucode: Introduce PF_microcode_update2 with flags parameter Date: Tue, 28 May 2024 16:29:40 +0100 Message-ID: <20240528152943.3915760-2-fouad.hilly@cloud.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240528152943.3915760-1-fouad.hilly@cloud.com> References: <20240528152943.3915760-1-fouad.hilly@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1716910243927100001 Content-Type: text/plain; charset="utf-8" Refactor microcode_update() by adding flags field. struct xenpf_microcode_update2 added with uint32_t flags field. Introduce XENPF_microcode_update2 hypercall with flags field. Signed-off-by: Fouad Hilly Reviewed-by: Andrew Cooper Suggested-by: Andrew Cooper --- [v4] 1- Commit message and description updated. 2- Changing the order of the patches. [v3] 1- Updated Commit message description. 2- Revereted changes to a stable ABI and introduced a new struct. 3- ucode_force_flag updated from static to a local variable. 4- microcode_update() updated to reject unsupported flags yet. [v2] 1- Update message description to highlight interface change. 2- Removed extra empty lines. 3- removed unnecessary define. 4- Corrected long lines. 5- Removed ternary operator. 6- Introduced static ucode_update_flags, which will be used later to determ= ine local ucode_force_flag. --- xen/arch/x86/cpu/microcode/core.c | 11 ++++++++--- xen/arch/x86/include/asm/microcode.h | 3 ++- xen/arch/x86/platform_hypercall.c | 13 ++++++++++++- xen/include/public/platform.h | 14 ++++++++++++++ 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index e90055772acf..8a9e744489b9 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -40,6 +40,8 @@ #include #include =20 +#include + #include "private.h" =20 /* @@ -570,6 +572,7 @@ static int cf_check do_microcode_update(void *patch) } =20 struct ucode_buf { + unsigned int flags; unsigned int len; char buffer[]; }; @@ -708,13 +711,14 @@ static long cf_check microcode_update_helper(void *da= ta) return ret; } =20 -int microcode_update(XEN_GUEST_HANDLE(const_void) buf, unsigned long len) +int microcode_update(XEN_GUEST_HANDLE(const_void) buf, + unsigned long len, unsigned int flags) { int ret; struct ucode_buf *buffer; =20 - if ( len !=3D (uint32_t)len ) - return -E2BIG; + if ( flags & ~XENPF_UCODE_FORCE ) + return -EINVAL; =20 if ( !ucode_ops.apply_microcode ) return -EINVAL; @@ -730,6 +734,7 @@ int microcode_update(XEN_GUEST_HANDLE(const_void) buf, = unsigned long len) return -EFAULT; } buffer->len =3D len; + buffer->flags =3D flags; =20 /* * Always queue microcode_update_helper() on CPU0. Most of the logic diff --git a/xen/arch/x86/include/asm/microcode.h b/xen/arch/x86/include/as= m/microcode.h index 8f59b20b0289..57c08205d475 100644 --- a/xen/arch/x86/include/asm/microcode.h +++ b/xen/arch/x86/include/asm/microcode.h @@ -22,7 +22,8 @@ struct cpu_signature { DECLARE_PER_CPU(struct cpu_signature, cpu_sig); =20 void microcode_set_module(unsigned int idx); -int microcode_update(XEN_GUEST_HANDLE(const_void) buf, unsigned long len); +int microcode_update(XEN_GUEST_HANDLE(const_void) buf, + unsigned long len, unsigned int flags); int early_microcode_init(unsigned long *module_map, const struct multiboot_info *mbi); int microcode_init_cache(unsigned long *module_map, diff --git a/xen/arch/x86/platform_hypercall.c b/xen/arch/x86/platform_hype= rcall.c index 95467b88ab64..7e3278109300 100644 --- a/xen/arch/x86/platform_hypercall.c +++ b/xen/arch/x86/platform_hypercall.c @@ -311,7 +311,18 @@ ret_t do_platform_op( =20 guest_from_compat_handle(data, op->u.microcode.data); =20 - ret =3D microcode_update(data, op->u.microcode.length); + ret =3D microcode_update(data, op->u.microcode.length, 0); + break; + } + + case XENPF_microcode_update2: + { + XEN_GUEST_HANDLE(const_void) data; + + guest_from_compat_handle(data, op->u.microcode2.data); + + ret =3D microcode_update(data, op->u.microcode2.length, + op->u.microcode2.flags); break; } =20 diff --git a/xen/include/public/platform.h b/xen/include/public/platform.h index 15777b541690..2725b8d1044f 100644 --- a/xen/include/public/platform.h +++ b/xen/include/public/platform.h @@ -624,6 +624,19 @@ struct xenpf_ucode_revision { typedef struct xenpf_ucode_revision xenpf_ucode_revision_t; DEFINE_XEN_GUEST_HANDLE(xenpf_ucode_revision_t); =20 +/* Hypercall to microcode_update with flags */ +#define XENPF_microcode_update2 66 +struct xenpf_microcode_update2 { + /* IN variables. */ + uint32_t flags; /* Flags to be passed with ucode. */ +/* Force to skip microcode version check */ +#define XENPF_UCODE_FORCE 1 + uint32_t length; /* Length of microcode data. */ + XEN_GUEST_HANDLE(const_void) data;/* Pointer to microcode data */ +}; +typedef struct xenpf_microcode_update2 xenpf_microcode_update2_t; +DEFINE_XEN_GUEST_HANDLE(xenpf_microcode_update2_t); + /* * ` enum neg_errnoval * ` HYPERVISOR_platform_op(const struct xen_platform_op*); @@ -656,6 +669,7 @@ struct xen_platform_op { xenpf_symdata_t symdata; xenpf_dom0_console_t dom0_console; xenpf_ucode_revision_t ucode_revision; + xenpf_microcode_update2_t microcode2; uint8_t pad[128]; } u; }; --=20 2.42.0 From nobody Fri Nov 22 12:56:29 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; dkim=pass; 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=pass(p=reject dis=none) header.from=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1716910240; cv=none; d=zohomail.com; s=zohoarc; b=H6epnkBElAjxM8g+78DjSzTIjwQx1Nzog3F5GNYvVOrocF7rEB7Lhc/Y6T27uvk6OmsynPMaNp75wddtS0wGtoLLhYFWdq7nlKJDBOcvQ7ydtiigEfkQKxwulQVaZRL5xSr38lCFRxaFy7LMcJEXsVZKSC1tbwHAimXjlnONHeQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716910240; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=eiZixxDd1y7HmvULwDCnAUl2gq5YDTcVfKI5Yqc7A6o=; b=ahip0VCk4v2VPkzKAZxo+3+ceEgSLp1wFhjDPn34qwvs2lLd3aHOTXyXBVov4tuAuM8pXUZJxN+92XzF0z6+GrYKyLUbPsZUiuvYZQG/b2Zt3VCV/MHgPbIvXpX3X8Zs5Jji2G4QNAHEh/0zbQjXsUtN6jttvYGg1g0sl6bctKY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1716910240129270.6951415968015; Tue, 28 May 2024 08:30:40 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.731194.1136559 (Exim 4.92) (envelope-from ) id 1sBymC-0001BX-0n; Tue, 28 May 2024 15:30:12 +0000 Received: by outflank-mailman (output) from mailman id 731194.1136559; Tue, 28 May 2024 15:30:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sBymB-0001AM-Qy; Tue, 28 May 2024 15:30:11 +0000 Received: by outflank-mailman (input) for mailman id 731194; Tue, 28 May 2024 15:30:10 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sBymA-00018F-P2 for xen-devel@lists.xenproject.org; Tue, 28 May 2024 15:30:10 +0000 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [2a00:1450:4864:20::634]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2af7124b-1d07-11ef-90a1-e314d9c70b13; Tue, 28 May 2024 17:30:09 +0200 (CEST) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a62ef52e837so116111266b.3 for ; Tue, 28 May 2024 08:30:09 -0700 (PDT) Received: from fhilly.citrite.net ([160.101.139.1]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a626c937444sm621673366b.61.2024.05.28.08.30.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 08:30:08 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2af7124b-1d07-11ef-90a1-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1716910209; x=1717515009; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eiZixxDd1y7HmvULwDCnAUl2gq5YDTcVfKI5Yqc7A6o=; b=Sh7lNcJHSd6q+jXD65e0hzkl69rRH8HrJdzb2lAtbzI+AM3jMi7xoX0ZuAge387TF3 S1c7tYqb3wCirwJNNuZnd001THXFe0dy40jCgaDen+HnqnJiIvcAW47jyyOb8rkFKuge mjKEdd0JF92934BaXrT7B5jkk9pXM0zBTntZc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716910209; x=1717515009; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eiZixxDd1y7HmvULwDCnAUl2gq5YDTcVfKI5Yqc7A6o=; b=G0L3j1cAHsoGMQAakdms81MHhTuT7k8vlvf/grpJzX6dVveUw72r+8Nu+LTPK8Mh+b +1tDCBPII6jfu6RzICf8HiCsTv1TnyDjStwK/uwNop9McHazdA1iSpYHBvSu4oJDzl/c pACPABuu+9BNSPSMgdQoIH78Zq1Dq8Vl8H1jDY8SbxWNoNcGUnLM4J/J0QuquGNDlwCQ 9ZXJOIONcd+PTZadx5xn2m2a87yzc1lzvQF7iv+2cXRa5o+aalfLV/FP4pq56wgVO0mt 5p4yD7RU5URxyxkS4n2Nvh1FTpaVfvCCUluhpUU+VNYaFzOv22e3YmNHV7hsvs/yiyjA V/ng== X-Gm-Message-State: AOJu0YwpQRQI1+FO5LU72mqYOn63gA82/WP3xf7bZUYFXnmpLPzxFqz/ gEpwh2YM2vPxPqziUt8hRtsbTRqOpXnI84L/JBhTPv3KRLyjG6uwyNctsmxt72VKIXgtwkYWSur +zP8= X-Google-Smtp-Source: AGHT+IGrPVCUH8m9ucxJfQ8Bfo55q54C/wA4hv+O7jryDjihHoTJ4VxJksixq/14le3M65dEFfPECg== X-Received: by 2002:a17:906:1945:b0:a59:b807:330a with SMTP id a640c23a62f3a-a62641cf941mr896251366b.32.1716910208980; Tue, 28 May 2024 08:30:08 -0700 (PDT) From: Fouad Hilly To: Xen-devel Cc: Fouad Hilly , Anthony PERARD Subject: [PATCH v4 2/4] x86/ucode: refactor xen-ucode to utilize getopt Date: Tue, 28 May 2024 16:29:41 +0100 Message-ID: <20240528152943.3915760-3-fouad.hilly@cloud.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240528152943.3915760-1-fouad.hilly@cloud.com> References: <20240528152943.3915760-1-fouad.hilly@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1716910241667100007 Content-Type: text/plain; charset="utf-8" Use getopt_long() to handle command line arguments. Introduce ext_err for common exit with errors. xc_microcode_update() refactored to accept flags and utilize xenpf_microcod= e_update2 Introducing usage() to handle usage\help messages in a common block. show_curr_cpu is printed to stdout only. Signed-off-by: Fouad Hilly Suggested-by: Andrew Cooper --- [v4] 1- Merge three patches into one. 2- usage() to print messages to the correct stream. 3- Update commit message and description. --- tools/misc/xen-ucode.c | 51 ++++++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/tools/misc/xen-ucode.c b/tools/misc/xen-ucode.c index 390969db3d1c..6f9dd2a7e431 100644 --- a/tools/misc/xen-ucode.c +++ b/tools/misc/xen-ucode.c @@ -11,12 +11,23 @@ #include #include #include +#include =20 static xc_interface *xch; =20 static const char intel_id[] =3D "GenuineIntel"; static const char amd_id[] =3D "AuthenticAMD"; =20 +static void usage(FILE *stream, const char *name) +{ + fprintf(stream, "%s: Xen microcode updating tool\n" + "Usage: %s [microcode file] [options]\n" + "options:\n" + " -h, --help display this help and exit\n" + " -s, --show-cpu-info show CPU information and exit\n", + name, name); +} + static void show_curr_cpu(FILE *f) { int ret; @@ -77,6 +88,13 @@ int main(int argc, char *argv[]) char *filename, *buf; size_t len; struct stat st; + int opt; + + static const struct option options[] =3D { + {"help", no_argument, NULL, 'h'}, + {"show-cpu-info", no_argument, NULL, 's'}, + {NULL, no_argument, NULL, 0} + }; =20 xch =3D xc_interface_open(NULL, NULL, 0); if ( xch =3D=3D NULL ) @@ -86,22 +104,25 @@ int main(int argc, char *argv[]) exit(1); } =20 - if ( argc < 2 ) + while ( (opt =3D getopt_long(argc, argv, "hs", options, NULL)) !=3D -1= ) { - fprintf(stderr, - "xen-ucode: Xen microcode updating tool\n" - "Usage: %s [ | show-cpu-info]\n", argv[0]); - show_curr_cpu(stderr); - exit(2); + switch (opt) + { + case 'h': + usage(stdout, argv[0]); + exit(EXIT_SUCCESS); + case 's': + show_curr_cpu(stdout); + exit(EXIT_SUCCESS); + default: + goto ext_err; + } } =20 - if ( !strcmp(argv[1], "show-cpu-info") ) - { - show_curr_cpu(stdout); - return 0; - } + if ( optind =3D=3D argc ) + goto ext_err; =20 - filename =3D argv[1]; + filename =3D argv[optind]; fd =3D open(filename, O_RDONLY); if ( fd < 0 ) { @@ -146,4 +167,10 @@ int main(int argc, char *argv[]) close(fd); =20 return 0; + + ext_err: + fprintf(stderr, + "%s: unable to process command line arguments\n", argv[0]); + usage(stderr, argv[0]); + exit(EXIT_FAILURE); } --=20 2.42.0 From nobody Fri Nov 22 12:56:29 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; dkim=pass; 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=pass(p=reject dis=none) header.from=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1716910237; cv=none; d=zohomail.com; s=zohoarc; b=nBtxKIYFTFdERsS3FqHxfMj3Pc8LDAukDuC3lGn04dOqQT4nE4ZDKq2fw9Khes16/sgQIQvP1QXJiZ2JvMP3m+a2PxryvRrKkqLaJHhhQDGHwUCN5C0R9x8aMOE5wxnwP841Ij5mqFmCA8e2xnI4s26dK1EnJ43SYmzWZZbD/F4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716910237; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=29kKGaSNhLed8Jk9dwMB1HDWbyK77p3VZnpuSymtJak=; b=Z1w2Jq6GJKIpTVj8+BmEWR2xcLJ5dnaQ+4O1DuLL+t7OTr7J/91tHdyGHCzjFKuFQzCcXSOQGro23DlUZlqm5hioDFgOYs10rDp0r75dvE6mkb2hRLJjzxZ13CLbyt+a5U1SBoaRF8v+C1GH00TbOC/haOmsP4Oz6qA2vBinJs4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1716910237768574.4085128412858; Tue, 28 May 2024 08:30:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.731197.1136589 (Exim 4.92) (envelope-from ) id 1sBymD-0001sk-Pm; Tue, 28 May 2024 15:30:13 +0000 Received: by outflank-mailman (output) from mailman id 731197.1136589; Tue, 28 May 2024 15:30:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sBymD-0001s8-Jp; Tue, 28 May 2024 15:30:13 +0000 Received: by outflank-mailman (input) for mailman id 731197; Tue, 28 May 2024 15:30:12 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sBymC-00018E-AS for xen-devel@lists.xenproject.org; Tue, 28 May 2024 15:30:12 +0000 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [2a00:1450:4864:20::432]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2b9df50d-1d07-11ef-b4bb-af5377834399; Tue, 28 May 2024 17:30:10 +0200 (CEST) Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-354faf5f1b4so779629f8f.1 for ; Tue, 28 May 2024 08:30:10 -0700 (PDT) Received: from fhilly.citrite.net ([160.101.139.1]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a626c937444sm621673366b.61.2024.05.28.08.30.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 08:30:09 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2b9df50d-1d07-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1716910210; x=1717515010; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=29kKGaSNhLed8Jk9dwMB1HDWbyK77p3VZnpuSymtJak=; b=ishgnpllRC/svCCzlkPPL7nnUgrCjrP1JeLR6CvohTRc/AnaYHsPUJ1/JnXjxJMvtb 48stk6/tUkjyr8RwLuO3mXGIbNhkcRXf+IhENdzwrukS/Og/m6C7Ev9UmUpqaGIibYiI dV5aOYRRt9cb4OKd3rxdHRBwLVKDWTOrZ7BmY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716910210; x=1717515010; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=29kKGaSNhLed8Jk9dwMB1HDWbyK77p3VZnpuSymtJak=; b=PLzoKtte6ONCmDChBq39npOQAra0eIcUuzyiHKer9A3l4MlVdZHUB/ZlAF1z1osgZF 5oOXO34DBkc5edfxHanu+k7ZNR+2ZldOUN71ASj4l9NuEDB2Rc9zis9nfw+EWzWiVq+N AMcHA0yRVN9Mgstp9zxsZATwco90kIFXz8MyirNo1MwxZWLro0EvWSzoRujLAixCT55o KhEnW+AC3ntiNzLUyotmdNJ/HVpQ69uVVVzPVSJMcksgMIdGf4OpEQRSelexml+vKNGV 2hxwnStGu6XJo4EkiMrOzFB6Tk4zYodcaUvO6YnfKaZ6mEETRzWoBEuR4TwJcpCdyzSP xkNg== X-Gm-Message-State: AOJu0YybK6Jr4tSM22vIzh7pgksLsY9daxQUluflw7X0OOFmEBnDadXZ xBuB1VHvZyeYDs8qWsVr2CDA7Yyw6A73rUPNi3turjzBDQPF45n5vy8Qzy75poBYxW17wk8iG8C oY48= X-Google-Smtp-Source: AGHT+IHJ5pIptnLo5qJAv1DVP0wUcqG2/5riYCtRVCTsvS+oNS+wekQ6nvMZBPq3NglWopzcliQulQ== X-Received: by 2002:adf:e681:0:b0:34c:b80a:233c with SMTP id ffacd0b85a97d-3552f4fd1b5mr10569229f8f.15.1716910209647; Tue, 28 May 2024 08:30:09 -0700 (PDT) From: Fouad Hilly To: Xen-devel Cc: Fouad Hilly , Anthony PERARD , Juergen Gross Subject: [PATCH v4 3/4] x86/ucode: Introduce --force option to xen-ucode to force skipping microcode version check Date: Tue, 28 May 2024 16:29:42 +0100 Message-ID: <20240528152943.3915760-4-fouad.hilly@cloud.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240528152943.3915760-1-fouad.hilly@cloud.com> References: <20240528152943.3915760-1-fouad.hilly@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1716910240700100002 Content-Type: text/plain; charset="utf-8" Introduce --force option to xen-ucode to force skipping microcode version c= heck, which allows the user to update x86 microcode even if both versions are the same = or downgrade. xc_microcode_update() refactored to accept flags and utilize xenpf_microcod= e_update2. Signed-off-by: Fouad Hilly Reviewed-by: Andrew Cooper Suggested-by: Andrew Cooper --- [4] 1- Add --force to xen-ucode options. 2- Update xc_microcode_update() to accept and handle flags. --- tools/include/xenctrl.h | 3 ++- tools/libs/ctrl/xc_misc.c | 12 +++++++----- tools/misc/xen-ucode.c | 14 +++++++++++--- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 499685594427..7fb409bc6dc4 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -1171,7 +1171,8 @@ typedef uint32_t xc_node_to_node_dist_t; int xc_physinfo(xc_interface *xch, xc_physinfo_t *info); int xc_cputopoinfo(xc_interface *xch, unsigned *max_cpus, xc_cputopo_t *cputopo); -int xc_microcode_update(xc_interface *xch, const void *buf, size_t len); +int xc_microcode_update(xc_interface *xch, const void *buf, + size_t len, unsigned int flags); int xc_get_cpu_version(xc_interface *xch, struct xenpf_pcpu_version *cpu_v= er); int xc_get_ucode_revision(xc_interface *xch, struct xenpf_ucode_revision *ucode_rev); diff --git a/tools/libs/ctrl/xc_misc.c b/tools/libs/ctrl/xc_misc.c index 50282fd60dcc..6a60216bda03 100644 --- a/tools/libs/ctrl/xc_misc.c +++ b/tools/libs/ctrl/xc_misc.c @@ -203,11 +203,12 @@ int xc_physinfo(xc_interface *xch, return 0; } =20 -int xc_microcode_update(xc_interface *xch, const void *buf, size_t len) +int xc_microcode_update(xc_interface *xch, const void *buf, + size_t len, unsigned int flags) { int ret; struct xen_platform_op platform_op =3D {}; - DECLARE_HYPERCALL_BUFFER(struct xenpf_microcode_update, uc); + DECLARE_HYPERCALL_BUFFER(struct xenpf_microcode_update2, uc); =20 uc =3D xc_hypercall_buffer_alloc(xch, uc, len); if ( uc =3D=3D NULL ) @@ -215,9 +216,10 @@ int xc_microcode_update(xc_interface *xch, const void = *buf, size_t len) =20 memcpy(uc, buf, len); =20 - platform_op.cmd =3D XENPF_microcode_update; - platform_op.u.microcode.length =3D len; - set_xen_guest_handle(platform_op.u.microcode.data, uc); + platform_op.cmd =3D XENPF_microcode_update2; + platform_op.u.microcode2.length =3D len; + platform_op.u.microcode2.flags =3D flags; + set_xen_guest_handle(platform_op.u.microcode2.data, uc); =20 ret =3D do_platform_op(xch, &platform_op); =20 diff --git a/tools/misc/xen-ucode.c b/tools/misc/xen-ucode.c index 6f9dd2a7e431..b878edf2399a 100644 --- a/tools/misc/xen-ucode.c +++ b/tools/misc/xen-ucode.c @@ -13,6 +13,8 @@ #include #include =20 +#include + static xc_interface *xch; =20 static const char intel_id[] =3D "GenuineIntel"; @@ -24,7 +26,8 @@ static void usage(FILE *stream, const char *name) "Usage: %s [microcode file] [options]\n" "options:\n" " -h, --help display this help and exit\n" - " -s, --show-cpu-info show CPU information and exit\n", + " -s, --show-cpu-info show CPU information and exit\n" + " -f, --force force to skip microcode version check\= n", name, name); } =20 @@ -89,10 +92,12 @@ int main(int argc, char *argv[]) size_t len; struct stat st; int opt; + uint32_t ucode_flags =3D 0; =20 static const struct option options[] =3D { {"help", no_argument, NULL, 'h'}, {"show-cpu-info", no_argument, NULL, 's'}, + {"force", no_argument, NULL, 'f'}, {NULL, no_argument, NULL, 0} }; =20 @@ -104,7 +109,7 @@ int main(int argc, char *argv[]) exit(1); } =20 - while ( (opt =3D getopt_long(argc, argv, "hs", options, NULL)) !=3D -1= ) + while ( (opt =3D getopt_long(argc, argv, "hsf", options, NULL)) !=3D -= 1 ) { switch (opt) { @@ -114,6 +119,9 @@ int main(int argc, char *argv[]) case 's': show_curr_cpu(stdout); exit(EXIT_SUCCESS); + case 'f': + ucode_flags =3D XENPF_UCODE_FORCE; + break; default: goto ext_err; } @@ -147,7 +155,7 @@ int main(int argc, char *argv[]) } =20 errno =3D 0; - ret =3D xc_microcode_update(xch, buf, len); + ret =3D xc_microcode_update(xch, buf, len, ucode_flags); if ( ret =3D=3D -1 && errno =3D=3D EEXIST ) printf("Microcode already up to date\n"); else if ( ret ) --=20 2.42.0 From nobody Fri Nov 22 12:56:29 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; dkim=pass; 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=pass(p=reject dis=none) header.from=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1716910239; cv=none; d=zohomail.com; s=zohoarc; b=LsGgs8xpX+heJ+nT+tyMnNDK8Gil3uiRPQs5gdej9CP8CDy8zcWUlXd67/PpHD9aR+CQgbFSpNGokHSzD4uW6ZGYsguPSfW7QgjzIzbqEq0U0QIH4xdRJKF8p0Cp+2wOEMTL9Q6uoLOqSzAGjHfboMIp5TzHEWnYxvk/HgM4bx8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716910239; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=z7mcoezWV0j0H2zzn7JIYS8Z2/p6a2i2l5f1Q/llZE0=; b=f7a1kQh7RzqZ3Sep0jXbRWALUPiAI4VVX+yTq0DdGq+XKuYXf6FLmfxa6tuuhVsWsgu9oSXAfdWpAlSYbeV3It4N1pUPyheuNGtxpDPZ/AeAT6QgxL220sPfaY6UmZ9J3u4jokArYZ2vpELXLDK7houuu/8yV1PMhkbphkzsArM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1716910239248488.54414023038817; Tue, 28 May 2024 08:30:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.731196.1136584 (Exim 4.92) (envelope-from ) id 1sBymD-0001pR-G0; Tue, 28 May 2024 15:30:13 +0000 Received: by outflank-mailman (output) from mailman id 731196.1136584; Tue, 28 May 2024 15:30:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sBymD-0001pK-C2; Tue, 28 May 2024 15:30:13 +0000 Received: by outflank-mailman (input) for mailman id 731196; Tue, 28 May 2024 15:30:12 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sBymC-00018F-6c for xen-devel@lists.xenproject.org; Tue, 28 May 2024 15:30:12 +0000 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [2a00:1450:4864:20::635]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2c014c96-1d07-11ef-90a1-e314d9c70b13; Tue, 28 May 2024 17:30:11 +0200 (CEST) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a63359aaaa6so126666066b.2 for ; Tue, 28 May 2024 08:30:11 -0700 (PDT) Received: from fhilly.citrite.net ([160.101.139.1]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a626c937444sm621673366b.61.2024.05.28.08.30.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 08:30:10 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2c014c96-1d07-11ef-90a1-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1716910210; x=1717515010; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=z7mcoezWV0j0H2zzn7JIYS8Z2/p6a2i2l5f1Q/llZE0=; b=CWQ9MkMxFzYjqVq8JEzhTJ2ctT11Uq0m1Aib1E4zLZMy6d2llX6MxmHmRyOXsxM4yF lY2w+uV/D2G8l7SkEej/y8Dl6HdQqozFCI2M/I9dy+CPPZ6i9lVc/RcUyZ9f73ues3rJ QJDnisQS1Cik7CiHF8f3X3WC43NUjndyejmsc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716910210; x=1717515010; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z7mcoezWV0j0H2zzn7JIYS8Z2/p6a2i2l5f1Q/llZE0=; b=N0raUnfeVDjtZtrpUEpJQ6EZv54SGUiVi+jUQqgzCEtAPdhV4ikeHea+K/4uYIWish 7mFKkfqUzpDxcyk1/TtcMEtarX3hB8TtF2mfY187U0ULZ2Hkpg0aJ7hZA5Q2429YzMiQ KZdKNIY5IiYxPwGBKFOFA7gu08r2iiikPPaAdu+R7P/diJZCF7eUWe99AwmJ/QdhxA6H Xlo37LyLyIULJThoC93cbgThHR1hhPNSGfvZciRwtgqx3KHlGYqhKXa2yZL38VYAfHKl Y6mlfQ6+Z15qJ+TY2ANi/ZYJjXxVkd8+i46ua5jC+edAc21tdIqdB77BTa22IXi19URe yN9Q== X-Gm-Message-State: AOJu0Yzn6/U2LcSvXk4aAir6uS5rgocu5QNViWEQJowp5WEPbwUfsfLk JMlCD31X5/ksYk2/aIH12u4Bf0aTlwimVWN9Z9Ml38JYqcfOjB10pXUKL+r8N81v1qvQIOrAAgI S2U0= X-Google-Smtp-Source: AGHT+IG4ytefBo9qwZrlmg2vHgWyH70OIDv7RtLE8pO6Uf1I0FZqM0xsPwXkUBHRuVwjEpLdxigKzQ== X-Received: by 2002:a17:906:a287:b0:a59:cb29:3fb3 with SMTP id a640c23a62f3a-a6265148babmr864229366b.53.1716910210477; Tue, 28 May 2024 08:30:10 -0700 (PDT) From: Fouad Hilly To: Xen-devel Cc: Fouad Hilly , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v4 4/4] x86/ucode: Utilize ucode_force and remove opt_ucode_allow_same Date: Tue, 28 May 2024 16:29:43 +0100 Message-ID: <20240528152943.3915760-5-fouad.hilly@cloud.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240528152943.3915760-1-fouad.hilly@cloud.com> References: <20240528152943.3915760-1-fouad.hilly@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1716910240704100003 Content-Type: text/plain; charset="utf-8" Pass ucode_force to common micorocde checks and utilize it to allow for mic= rocode downgrade or reapply the same version of the microcode. Update low level Intel and AMD to check for valid signature only. Any versi= on checks is done at core.c. While adding ucode_force, opt_ucode_allow_same was removed. Remove opt_ucode_allow_same from documentation. Signed-off-by: Fouad Hilly Suggested-by: Andrew Cooper --- [4] 1- As opt_ucode_allow_same is not required anymore, it has been removed whi= le introducing ucode_force. 2- Apply the changes for both AMD and Intel. 3- Remove the mention of opt_ucode_allow_same from documentation. --- docs/misc/xen-command-line.pandoc | 7 +------ xen/arch/x86/cpu/microcode/amd.c | 7 ------- xen/arch/x86/cpu/microcode/core.c | 9 +++------ xen/arch/x86/cpu/microcode/intel.c | 4 ---- xen/arch/x86/cpu/microcode/private.h | 2 -- 5 files changed, 4 insertions(+), 25 deletions(-) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line= .pandoc index 1dea7431fab6..a42ce1039fed 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -2648,7 +2648,7 @@ performance. Alternatively, selecting `tsx=3D1` will re-enable TSX at the users own = risk. =20 ### ucode -> `=3D List of [ | scan=3D, nmi=3D, allow-same=3D ]` +> `=3D List of [ | scan=3D, nmi=3D ]` =20 Applicability: x86 Default: `nmi` @@ -2680,11 +2680,6 @@ precedence over `scan`. stop_machine context. In NMI handler, even NMIs are blocked, which is considered safer. The default value is `true`. =20 -'allow-same' alters the default acceptance policy for new microcode to per= mit -trying to reload the same version. Many CPUs will actually reload microco= de -of the same version, and this allows for easy testing of the late microcode -loading path. - ### unrestricted_guest (Intel) > `=3D ` =20 diff --git a/xen/arch/x86/cpu/microcode/amd.c b/xen/arch/x86/cpu/microcode/= amd.c index f76a563c8b84..4bcc79f1ab2d 100644 --- a/xen/arch/x86/cpu/microcode/amd.c +++ b/xen/arch/x86/cpu/microcode/amd.c @@ -225,13 +225,6 @@ static int cf_check apply_microcode(const struct micro= code_patch *patch) if ( result =3D=3D MIS_UCODE ) return -EINVAL; =20 - /* - * Allow application of the same revision to pick up SMT-specific chan= ges - * even if the revision of the other SMT thread is already up-to-date. - */ - if ( result =3D=3D OLD_UCODE ) - return -EEXIST; - if ( check_final_patch_levels(sig) ) { printk(XENLOG_ERR diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index 8a9e744489b9..fc8ad8cfdd76 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -100,8 +100,6 @@ static bool __initdata ucode_scan; /* By default, ucode loading is done in NMI handler */ static bool ucode_in_nmi =3D true; =20 -bool __read_mostly opt_ucode_allow_same; - /* Protected by microcode_mutex */ static struct microcode_patch *microcode_cache; =20 @@ -128,8 +126,6 @@ static int __init cf_check parse_ucode(const char *s) =20 if ( (val =3D parse_boolean("nmi", s, ss)) >=3D 0 ) ucode_in_nmi =3D val; - else if ( (val =3D parse_boolean("allow-same", s, ss)) >=3D 0 ) - opt_ucode_allow_same =3D val; else if ( !ucode_mod_forced ) /* Not forced by EFI */ { if ( (val =3D parse_boolean("scan", s, ss)) >=3D 0 ) @@ -583,6 +579,7 @@ static long cf_check microcode_update_helper(void *data) struct ucode_buf *buffer =3D data; unsigned int cpu, updated; struct microcode_patch *patch; + bool ucode_force =3D buffer->flags =3D=3D XENPF_UCODE_FORCE; =20 /* cpu_online_map must not change during update */ if ( !get_cpu_maps() ) @@ -636,12 +633,12 @@ static long cf_check microcode_update_helper(void *da= ta) microcode_cache); =20 if ( result !=3D NEW_UCODE && - !(opt_ucode_allow_same && result =3D=3D SAME_UCODE) ) + (!ucode_force || (result & ~SAME_UCODE)) ) { spin_unlock(µcode_mutex); printk(XENLOG_WARNING "microcode: couldn't find any newer%s revision in the p= rovided blob!\n", - opt_ucode_allow_same ? " (or the same)" : ""); + ucode_force? " (or a valid)" : ""); microcode_free_patch(patch); ret =3D -EEXIST; =20 diff --git a/xen/arch/x86/cpu/microcode/intel.c b/xen/arch/x86/cpu/microcod= e/intel.c index f505aa1b7888..5e1b528ffe05 100644 --- a/xen/arch/x86/cpu/microcode/intel.c +++ b/xen/arch/x86/cpu/microcode/intel.c @@ -297,10 +297,6 @@ static int cf_check apply_microcode(const struct micro= code_patch *patch) if ( result =3D=3D MIS_UCODE ) return -EINVAL; =20 - if ( result =3D=3D OLD_UCODE || - (result =3D=3D SAME_UCODE && !opt_ucode_allow_same) ) - return -EEXIST; - wbinvd(); =20 wrmsrl(MSR_IA32_UCODE_WRITE, (unsigned long)patch->data); diff --git a/xen/arch/x86/cpu/microcode/private.h b/xen/arch/x86/cpu/microc= ode/private.h index da556fe5060a..aea51678a662 100644 --- a/xen/arch/x86/cpu/microcode/private.h +++ b/xen/arch/x86/cpu/microcode/private.h @@ -3,8 +3,6 @@ =20 #include =20 -extern bool opt_ucode_allow_same; - enum microcode_match_result { OLD_UCODE, /* signature matched, but revision id is older */ SAME_UCODE, /* signature matched, but revision id is the same */ --=20 2.42.0