From patchwork Tue Apr 16 09:15:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fouad Hilly X-Patchwork-Id: 13631531 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 72097C04FF6 for ; Tue, 16 Apr 2024 09:16:18 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.706795.1104174 (Exim 4.92) (envelope-from ) id 1rwev9-0000jD-Av; Tue, 16 Apr 2024 09:16:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 706795.1104174; Tue, 16 Apr 2024 09:16:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rwev9-0000j6-8S; Tue, 16 Apr 2024 09:16:07 +0000 Received: by outflank-mailman (input) for mailman id 706795; Tue, 16 Apr 2024 09:16:06 +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 1rwev8-0000j0-Nm for xen-devel@lists.xenproject.org; Tue, 16 Apr 2024 09:16:06 +0000 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [2a00:1450:4864:20::631]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id f3f36ab4-fbd1-11ee-b909-491648fe20b8; Tue, 16 Apr 2024 11:16:05 +0200 (CEST) Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a5269c3f9c7so249524866b.2 for ; Tue, 16 Apr 2024 02:16:05 -0700 (PDT) Received: from fhilly.citrite.net (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id u2-20020a17090657c200b00a524476aac9sm4654723ejr.108.2024.04.16.02.16.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 02:16:03 -0700 (PDT) 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: f3f36ab4-fbd1-11ee-b909-491648fe20b8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1713258965; x=1713863765; 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=VMo9HfH+/6PT62gxIGHAj1EtchV4P4c0BEQDSxaYl8E=; b=VJEok3iEtIuwmTdUJzPtp1ihuKw0D7NcjP8Gb5OBw6Cg9Q2WNz13BveNZpueLRBpzm 5B3eUEwjBxfTgDED4tygut7mHvXw4Pnqs33ekd599tE6tovSANBxNZBGKCRFNaHoCrd4 czA7ZJI/AxEdHPjl6DE+U6W4ZpGgwgEYYtyC8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713258965; x=1713863765; 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=VMo9HfH+/6PT62gxIGHAj1EtchV4P4c0BEQDSxaYl8E=; b=kbM/vrt1FgsQcXvaA0wsXNEK+sCJ8ZdgbAjHhN5Us0521WVnKZOaycgbHk5YJwm06y Yc0C6/xozr6pPp9L9bEVBtXETMwlmF+ZDg7B54+NWEHi+d5ruT386N1NmllMQ6GAtm5d T7V/2rH3pmB6kC87uNgcnx6zIZOsjYumiqD8KCQzLHBLjN/81ghSiDDTUysQvzfLqvgJ 4f4Az0SEVfpR5OVgSj3ubHc3iAc1ug7NRZuPfLv/t3SXrKAWPoNB9uUtHz5Up1Z6nG6H hQWwsoOW+qiF6YMU9Yp9w0cDpEktB0U48vX3ckQvahUmgQiNuMkVjMUYZ07yQ4n8OCcD z0wQ== X-Gm-Message-State: AOJu0Yzbuz9+rdStdh2Q9OTjVNdv9L39mdB6BMa27fWO/ml4bOvmZzsv KvkRZpADfa7LDxm1gmLJO13nzCqNF3cB4i1Jkam7XWB2lxP1MXirtsCOziIQ1mhn/BeAqSgAvq2 5 X-Google-Smtp-Source: AGHT+IGiVFzED4vE2YgqcbK2WERtwlr9k7iUaPSamGBfKHXw9VfXOpLltOmof+L9ChbTrnrinumiKA== X-Received: by 2002:a17:906:2dc5:b0:a52:225a:2ebe with SMTP id h5-20020a1709062dc500b00a52225a2ebemr6719632eji.71.1713258964803; Tue, 16 Apr 2024 02:16:04 -0700 (PDT) From: Fouad Hilly To: Xen-devel Cc: Fouad Hilly , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v2 1/5] x86: Update x86 low level version check of microcode Date: Tue, 16 Apr 2024 10:15:42 +0100 Message-ID: <20240416091546.11622-2-fouad.hilly@cloud.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240416091546.11622-1-fouad.hilly@cloud.com> References: <20240416091546.11622-1-fouad.hilly@cloud.com> MIME-Version: 1.0 Update microcode version check at Intel and AMD Level by: Preventing the low level code from sending errors if the microcode version provided is not a newer version. Other errors will be sent like before. When the provided microcode version is the same as the current one, code to point to microcode provided. Microcode version check happens at higher and common level in core.c. Keep all the required code at low level that checks for signature and CPU compatibility [v2] Update message description to better describe the changes Signed-off-by: Fouad Hilly --- xen/arch/x86/cpu/microcode/amd.c | 8 ++------ xen/arch/x86/cpu/microcode/intel.c | 11 +++-------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/amd.c b/xen/arch/x86/cpu/microcode/amd.c index 75fc84e445ce..4f805f662701 100644 --- a/xen/arch/x86/cpu/microcode/amd.c +++ b/xen/arch/x86/cpu/microcode/amd.c @@ -383,12 +383,8 @@ static struct microcode_patch *cf_check cpu_request_microcode( goto skip; } - /* - * If the new ucode covers current CPU, compare ucodes and store the - * one with higher revision. - */ - if ( (microcode_fits(mc->patch) != MIS_UCODE) && - (!saved || (compare_header(mc->patch, saved) == NEW_UCODE)) ) + /* If the provided ucode covers current CPU, then store its revision. */ + if ( (microcode_fits(mc->patch) != MIS_UCODE) && !saved ) { saved = mc->patch; saved_size = mc->len; diff --git a/xen/arch/x86/cpu/microcode/intel.c b/xen/arch/x86/cpu/microcode/intel.c index 060c529a6e5d..e65c02a57987 100644 --- a/xen/arch/x86/cpu/microcode/intel.c +++ b/xen/arch/x86/cpu/microcode/intel.c @@ -294,8 +294,7 @@ static int cf_check apply_microcode(const struct microcode_patch *patch) result = microcode_update_match(patch); - if ( result != NEW_UCODE && - !(opt_ucode_allow_same && result == SAME_UCODE) ) + if ( result != NEW_UCODE && result != SAME_UCODE ) return -EINVAL; wbinvd(); @@ -354,12 +353,8 @@ static struct microcode_patch *cf_check cpu_request_microcode( if ( error ) break; - /* - * If the new update covers current CPU, compare updates and store the - * one with higher revision. - */ - if ( (microcode_update_match(mc) != MIS_UCODE) && - (!saved || compare_revisions(saved->rev, mc->rev) == NEW_UCODE) ) + /* If the provided ucode covers current CPU, then store its revision. */ + if ( (microcode_update_match(mc) != MIS_UCODE) && !saved ) saved = mc; buf += blob_size; From patchwork Tue Apr 16 09:15:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fouad Hilly X-Patchwork-Id: 13631527 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 17463C04FF8 for ; Tue, 16 Apr 2024 09:16:18 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.706796.1104185 (Exim 4.92) (envelope-from ) id 1rwevA-0000xd-KK; Tue, 16 Apr 2024 09:16:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 706796.1104185; Tue, 16 Apr 2024 09:16:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rwevA-0000xW-Fb; Tue, 16 Apr 2024 09:16:08 +0000 Received: by outflank-mailman (input) for mailman id 706796; Tue, 16 Apr 2024 09:16:07 +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 1rwev9-0000j0-DM for xen-devel@lists.xenproject.org; Tue, 16 Apr 2024 09:16:07 +0000 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [2a00:1450:4864:20::62a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id f4a4db3f-fbd1-11ee-b909-491648fe20b8; Tue, 16 Apr 2024 11:16:06 +0200 (CEST) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a526a200879so259444566b.1 for ; Tue, 16 Apr 2024 02:16:06 -0700 (PDT) Received: from fhilly.citrite.net (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id u2-20020a17090657c200b00a524476aac9sm4654723ejr.108.2024.04.16.02.16.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 02:16:05 -0700 (PDT) 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: f4a4db3f-fbd1-11ee-b909-491648fe20b8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1713258965; x=1713863765; 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=5JYgU5u131JTGNDKaVXDUtjVdH+AOMW24dDk4iz+IAQ=; b=BzYa4uWHuv2Zvez4tzfhdDI/KoMiyVC6rj2YpR1zB1V6o7MQaEHqTGeHINqH32Zq1w /9PYScTREX0D+fqhd0bjRAGUzPCCFTF/pKUnueI4i4cSgtSG7r1BDQOGCYBiZNQR/xHR ysZ8aA71P81R79L7RSdNaF4zRJWD9T2NOtMCk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713258965; x=1713863765; 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=5JYgU5u131JTGNDKaVXDUtjVdH+AOMW24dDk4iz+IAQ=; b=f2BX9A74SeYKemXzAmQuC3/t6lWwEab6aIgmQyhExTmESIebEk4SDYKugmEHC1Rvz5 L7Mf8asg+Dksvg6zxmEVptvbA6jzlbS2wvzXHPoh4v948BSGQbvM8ew1vFxBjq/ddy7E AxeXb+nos26IzJh9T4WslNoSzuna/2NvqkH9RY5SVSgP/6+3dgMPzb1V9hLge3Y7e86m zEC0TRQKZ/YSgLsHGESfO73XyRSrGHEKQ+kdQFMQQGJfZsqHRVlXYftoKo1yjE+Lnz+w +BBJv6rpKvDDVL52goRPEyrMpDUEpkbiGNKk0MdhFLacxpU6qO7yWlO5jdYXhzADPlWx bffQ== X-Gm-Message-State: AOJu0YwYDuTrf69LNg7Kt5RsPFUx1G8amvC0hLH9Bm4YOrRUQleriE0J +uOFhznHnligavd+ywBZon22dIvGyEhA3C9JSJjoTZx/I6pDar73XnsBGsgMwJBE+OGkqG8s4QM q X-Google-Smtp-Source: AGHT+IHxM5DeAYgkZJbDRrxtvBfaz5fjtIiGJp51U0h7y+qo192KWoRi01Ube2KEpZZGxGO6bm3fPA== X-Received: by 2002:a17:906:aed4:b0:a52:6a31:a9f2 with SMTP id me20-20020a170906aed400b00a526a31a9f2mr3136041ejb.70.1713258965596; Tue, 16 Apr 2024 02:16:05 -0700 (PDT) From: Fouad Hilly To: Xen-devel Cc: Fouad Hilly , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Julien Grall , Stefano Stabellini Subject: [PATCH v2 2/5] x86: Refactor microcode_update() hypercall with flags Date: Tue, 16 Apr 2024 10:15:43 +0100 Message-ID: <20240416091546.11622-3-fouad.hilly@cloud.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240416091546.11622-1-fouad.hilly@cloud.com> References: <20240416091546.11622-1-fouad.hilly@cloud.com> MIME-Version: 1.0 Refactor microcode_update() hypercall by adding flags field. Introduce XENPF_microcode_update2 hypercall to handle flags field. struct xenpf_microcode_update updated to have uint32_t flags at the end of the sturcture. [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 determine local ucode_force_flag. Signed-off-by: Fouad Hilly --- xen/arch/x86/cpu/microcode/core.c | 14 +++++++++++--- xen/arch/x86/include/asm/microcode.h | 3 ++- xen/arch/x86/platform_hypercall.c | 12 +++++++++++- xen/include/public/platform.h | 6 ++++++ 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode/core.c index 1c9f66ea8a0f..99b651d8c3a1 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -40,6 +40,8 @@ #include #include +#include + #include "private.h" /* @@ -100,6 +102,8 @@ static bool ucode_in_nmi = true; bool __read_mostly opt_ucode_allow_same; +static unsigned int ucode_update_flags = 0; + /* Protected by microcode_mutex */ static struct microcode_patch *microcode_cache; @@ -580,6 +584,7 @@ static long cf_check microcode_update_helper(void *data) struct ucode_buf *buffer = data; unsigned int cpu, updated; struct microcode_patch *patch; + bool ucode_force_flag = ucode_update_flags == XENPF_UCODE_FLAG_FORCE_SET; /* cpu_online_map must not change during update */ if ( !get_cpu_maps() ) @@ -633,12 +638,12 @@ static long cf_check microcode_update_helper(void *data) microcode_cache); if ( result != NEW_UCODE && - !(opt_ucode_allow_same && result == SAME_UCODE) ) + !((opt_ucode_allow_same || ucode_force_flag) && result == SAME_UCODE) ) { spin_unlock(µcode_mutex); printk(XENLOG_WARNING "microcode: couldn't find any newer%s revision in the provided blob!\n", - opt_ucode_allow_same ? " (or the same)" : ""); + (opt_ucode_allow_same || ucode_force_flag) ? " (or the same)" : ""); microcode_free_patch(patch); ret = -ENOENT; @@ -708,7 +713,8 @@ static long cf_check microcode_update_helper(void *data) return ret; } -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; @@ -731,6 +737,8 @@ int microcode_update(XEN_GUEST_HANDLE(const_void) buf, unsigned long len) } buffer->len = len; + ucode_update_flags = flags; + /* * Always queue microcode_update_helper() on CPU0. Most of the logic * won't care, but the update of the Raw CPU policy wants to (re)run on diff --git a/xen/arch/x86/include/asm/microcode.h b/xen/arch/x86/include/asm/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); 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_hypercall.c index 95467b88ab64..3b29ede8b316 100644 --- a/xen/arch/x86/platform_hypercall.c +++ b/xen/arch/x86/platform_hypercall.c @@ -311,7 +311,17 @@ ret_t do_platform_op( guest_from_compat_handle(data, op->u.microcode.data); - ret = microcode_update(data, op->u.microcode.length); + ret = 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.microcode.data); + + ret = microcode_update(data, op->u.microcode.length, op->u.microcode.flags); break; } diff --git a/xen/include/public/platform.h b/xen/include/public/platform.h index 15777b541690..cc19b2956b46 100644 --- a/xen/include/public/platform.h +++ b/xen/include/public/platform.h @@ -99,6 +99,9 @@ struct xenpf_microcode_update { /* IN variables. */ XEN_GUEST_HANDLE(const_void) data;/* Pointer to microcode data */ uint32_t length; /* Length of microcode data. */ + uint32_t flags; /* Flags to be passed with ucode. */ +/* Force to skip microcode version check when set */ +#define XENPF_UCODE_FLAG_FORCE_SET 1 }; typedef struct xenpf_microcode_update xenpf_microcode_update_t; DEFINE_XEN_GUEST_HANDLE(xenpf_microcode_update_t); @@ -624,6 +627,9 @@ struct xenpf_ucode_revision { typedef struct xenpf_ucode_revision xenpf_ucode_revision_t; DEFINE_XEN_GUEST_HANDLE(xenpf_ucode_revision_t); +/* Hypercall to microcode_update with flags */ +#define XENPF_microcode_update2 66 + /* * ` enum neg_errnoval * ` HYPERVISOR_platform_op(const struct xen_platform_op*); From patchwork Tue Apr 16 09:15:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fouad Hilly X-Patchwork-Id: 13631526 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0D900C4345F for ; Tue, 16 Apr 2024 09:16:18 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.706798.1104205 (Exim 4.92) (envelope-from ) id 1rwevC-0001Rz-6N; Tue, 16 Apr 2024 09:16:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 706798.1104205; Tue, 16 Apr 2024 09:16:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rwevC-0001Rr-1r; Tue, 16 Apr 2024 09:16:10 +0000 Received: by outflank-mailman (input) for mailman id 706798; Tue, 16 Apr 2024 09:16:08 +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 1rwevA-0000j0-DQ for xen-devel@lists.xenproject.org; Tue, 16 Apr 2024 09:16:08 +0000 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [2a00:1450:4864:20::629]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id f503c26e-fbd1-11ee-b909-491648fe20b8; Tue, 16 Apr 2024 11:16:07 +0200 (CEST) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a5200afe39eso512106966b.1 for ; Tue, 16 Apr 2024 02:16:07 -0700 (PDT) Received: from fhilly.citrite.net (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id u2-20020a17090657c200b00a524476aac9sm4654723ejr.108.2024.04.16.02.16.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 02:16:05 -0700 (PDT) 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: f503c26e-fbd1-11ee-b909-491648fe20b8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1713258966; x=1713863766; 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=8L5gTKzhiipTLmXWv/M3h8GXKJ30XFqq9tUQkMs7y54=; b=bOkaKFjMhNuUeICsj4Kb/zaUNlqdoUInm5//RCaxOUjHwVX86j7VcuBkFSlJnAy50Y QEr70VoUrQBphwDXecZycAxA8caAV05DE/wGO71czteAjy+y7v3qDoxELqsGF4tyFHQ5 +iH0yJG6HrLJnPZx4J9Uy7U2FwZNpojCH4UfI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713258966; x=1713863766; 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=8L5gTKzhiipTLmXWv/M3h8GXKJ30XFqq9tUQkMs7y54=; b=kOZk74AdXTIjlVIVhiLJT2pC9rJyup35fxRRwYRFgLWgdde7WXzS6+YGQn4couSmFd iCzhzjLWkOUSg2BxJFTiZBabXsah0zkAjYMq2O21Pj6dFLo161opdX181LTwe7h7CS5S /5574pv4dUwZlj9t8EQo2cXSZV9qHzGWGiv75fDDHPp0PZ10D94XjbCK8fjdLQ/k8XVt yiZmTvgXAlTBurUsalLV8Ggx+XypoNX1t938LZYP/9hJzQGNuJV8k8BSp94JDKYD4c8r n+5kIZHE9KKhLht1Gv8KXQ6lO4u5h0YnAI1kLpZGhL01qvXgeQsJUAQzk690i9Q2kZcO AK+g== X-Gm-Message-State: AOJu0Yzb2IbWVRsr1qFgqs6+L6YEekf5Wr9wvkjWGm36dlLwbcF6V9Uy aI2JVqnfqBzgldtZ8RJQB//GZWbC5T84fDFgAdqm96tMLb0znjVuaw2P+U1msSEgzFbv4mpyHBv 9 X-Google-Smtp-Source: AGHT+IFZEmBGqBvnw2Jp/PJNHnVx1tMBkCNCPTVTjpqTQ1tLdZHbYTcE8DSmFB2Nf2q5YLdd+VNC2Q== X-Received: by 2002:a17:906:af14:b0:a52:68db:9fe7 with SMTP id lx20-20020a170906af1400b00a5268db9fe7mr4714628ejb.11.1713258966751; Tue, 16 Apr 2024 02:16:06 -0700 (PDT) From: Fouad Hilly To: Xen-devel Cc: Fouad Hilly , Anthony PERARD Subject: [PATCH v2 3/5] x86: Add usage() to print out usage message Date: Tue, 16 Apr 2024 10:15:44 +0100 Message-ID: <20240416091546.11622-4-fouad.hilly@cloud.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240416091546.11622-1-fouad.hilly@cloud.com> References: <20240416091546.11622-1-fouad.hilly@cloud.com> MIME-Version: 1.0 Refactor xen-ucode tool by adding usage() to handle usage\help messages As we add more command options this will keep help\usage messages in common block [v2] 1- Improved message description. 2- Fixed formatting and indentation. 3- Error message to print to stderr. Signed-off-by: Fouad Hilly --- tools/misc/xen-ucode.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/misc/xen-ucode.c b/tools/misc/xen-ucode.c index c6ae6498d659..0c0b2337b4ea 100644 --- a/tools/misc/xen-ucode.c +++ b/tools/misc/xen-ucode.c @@ -17,6 +17,15 @@ static xc_interface *xch; static const char intel_id[] = "GenuineIntel"; static const char amd_id[] = "AuthenticAMD"; +static void usage(const char *name) +{ + printf("%s: Xen microcode updating tool\n" + "Usage: %s [microcode file] [options]\n" + "Options:\n" + "show-cou-info show CPU information and exit\n", + name, name); +} + static void show_curr_cpu(FILE *f) { int ret; From patchwork Tue Apr 16 09:15:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fouad Hilly X-Patchwork-Id: 13631530 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 18668C05052 for ; Tue, 16 Apr 2024 09:16:19 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.706799.1104214 (Exim 4.92) (envelope-from ) id 1rwevD-0001hX-Dl; Tue, 16 Apr 2024 09:16:11 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 706799.1104214; Tue, 16 Apr 2024 09:16: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 1rwevD-0001h0-AZ; Tue, 16 Apr 2024 09:16:11 +0000 Received: by outflank-mailman (input) for mailman id 706799; Tue, 16 Apr 2024 09:16:09 +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 1rwevB-0000mP-HQ for xen-devel@lists.xenproject.org; Tue, 16 Apr 2024 09:16:09 +0000 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [2a00:1450:4864:20::52c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f560a58d-fbd1-11ee-94a3-07e782e9044d; Tue, 16 Apr 2024 11:16:08 +0200 (CEST) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-570097653faso2633925a12.0 for ; Tue, 16 Apr 2024 02:16:08 -0700 (PDT) Received: from fhilly.citrite.net (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id u2-20020a17090657c200b00a524476aac9sm4654723ejr.108.2024.04.16.02.16.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 02:16:07 -0700 (PDT) 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: f560a58d-fbd1-11ee-94a3-07e782e9044d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1713258967; x=1713863767; 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=QqMqjbPKATTcFkSZJE0LrlnS9bwDIdnbbvMhDvcYVI0=; b=VD4zMLkKJwilqmWZlfTGn1w949+B5OUX+RIw4cWqBbSjNcY21YbJPv30FhVrPmtXuY 9aH19xWrPj7JC9DCRge8f+iz98s9Dt3GWVLbydEd72H204chs4PzqYb4dxKMSz41K1sK MwgywaYiv9AeYXPDoGFoA1ajGZWIaesCYxk2o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713258967; x=1713863767; 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=QqMqjbPKATTcFkSZJE0LrlnS9bwDIdnbbvMhDvcYVI0=; b=eDu7yhf8ftMqfsmH9tSSN0sS/AeoUVE692+1rZKXDWXv7MJPVjLAk6w/fZvlBGSHtd kXblyNC8ENE0lgVV/Sr2umUTTiVTjjzK64VMoNbWaWq5rzYE6SH4pmJV3tRX2AKpAvc7 59OlDuXp0ia26GvckPh6ZcKfxX3eS3+ee1gxa/3JoArv8Gzhc0o1Qx03SNu/dUpbPw5U 1BvrPGrqbO+4JcT+oHDve8ZpcWu1RUBBuE7P508KVd94KhKFtwuQPqBKVIuIxZyWccrF Z5GqNySqBt3eGxOylspyOg181XJ6qeFeI4TA1B3fPXQ76asbMYJKf4pPThT81GZ1qto7 Ye7A== X-Gm-Message-State: AOJu0Ywyp/crmbzYrJwYorogv+n5nxEaOt7UT2vGx+jKWKw3pSTzmRYw JqJSs0LfZH3Q/EX2jhuP6+RIU3z/oQBlI9QgIqGLyXrZEOPY6/kko2FxdUEcA4wQZEJB+9a288V f X-Google-Smtp-Source: AGHT+IGZFc5vZSLMqmSJtZ9LG3B1/EYB+WqDlokgwcpiJVA1CYkpP42KgKueD+A6VdIm2whqItACUA== X-Received: by 2002:a17:907:9443:b0:a52:3f00:616d with SMTP id dl3-20020a170907944300b00a523f00616dmr10232289ejc.30.1713258967372; Tue, 16 Apr 2024 02:16:07 -0700 (PDT) From: Fouad Hilly To: Xen-devel Cc: Fouad Hilly , Anthony PERARD Subject: [PATCH v2 4/5] x86: Use getopt to handle command line args Date: Tue, 16 Apr 2024 10:15:45 +0100 Message-ID: <20240416091546.11622-5-fouad.hilly@cloud.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240416091546.11622-1-fouad.hilly@cloud.com> References: <20240416091546.11622-1-fouad.hilly@cloud.com> MIME-Version: 1.0 Use getopt_long() to handle command line arguments. Introduce ext_err for common exit with errors. [v2] 1- Removed unnecessary NULL initialization. 2- Used static at the beginning of type struct declaration. 3- Corrected switch\case indentations. 4- Removed redundant checks. 5- Corrected label indentation. Signed-off-by: Fouad Hilly --- tools/misc/xen-ucode.c | 43 ++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/tools/misc/xen-ucode.c b/tools/misc/xen-ucode.c index 0c0b2337b4ea..e3c1943e3633 100644 --- a/tools/misc/xen-ucode.c +++ b/tools/misc/xen-ucode.c @@ -11,6 +11,7 @@ #include #include #include +#include static xc_interface *xch; @@ -22,7 +23,8 @@ static void usage(const char *name) printf("%s: Xen microcode updating tool\n" "Usage: %s [microcode file] [options]\n" "Options:\n" - "show-cou-info show CPU information and exit\n", + " -h, --help display this help and exit\n" + " -s, --show-cpu-info show CPU information and exit\n", name, name); } @@ -86,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[] = { + {"help", no_argument, NULL, 'h'}, + {"show-cpu-info", no_argument, NULL, 's'}, + {NULL, no_argument, NULL, 0} + }; xch = xc_interface_open(NULL, NULL, 0); if ( xch == NULL ) @@ -95,19 +104,22 @@ int main(int argc, char *argv[]) exit(1); } - if ( argc < 2 ) - { - fprintf(stderr, - "xen-ucode: Xen microcode updating tool\n" - "Usage: %s [ | show-cpu-info]\n", argv[0]); - show_curr_cpu(stderr); - exit(2); - } + if ( argc != 2 ) + goto ext_err; - if ( !strcmp(argv[1], "show-cpu-info") ) + while ( (opt = getopt_long(argc, argv, "hs", options, NULL)) != -1 ) { - show_curr_cpu(stdout); - return 0; + switch (opt) + { + case 'h': + usage(argv[0]); + exit(EXIT_SUCCESS); + case 's': + show_curr_cpu(stdout); + exit(EXIT_SUCCESS); + default: + goto ext_err; + } } filename = argv[1]; @@ -152,4 +164,11 @@ int main(int argc, char *argv[]) close(fd); return 0; + + ext_err: + fprintf(stderr, + "xen-ucode: Xen microcode updating tool\n" + "Usage: %s [microcode file] [options]\n", argv[0]); + show_curr_cpu(stderr); + exit(STDERR_FILENO); } From patchwork Tue Apr 16 09:15:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fouad Hilly X-Patchwork-Id: 13631528 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 81E08C05023 for ; Tue, 16 Apr 2024 09:16:18 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.706800.1104221 (Exim 4.92) (envelope-from ) id 1rwevD-0001nA-UZ; Tue, 16 Apr 2024 09:16:11 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 706800.1104221; Tue, 16 Apr 2024 09:16: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 1rwevD-0001lY-Lj; Tue, 16 Apr 2024 09:16:11 +0000 Received: by outflank-mailman (input) for mailman id 706800; Tue, 16 Apr 2024 09:16:10 +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 1rwevC-0000mP-RT for xen-devel@lists.xenproject.org; Tue, 16 Apr 2024 09:16:10 +0000 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [2a00:1450:4864:20::62a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f61d111e-fbd1-11ee-94a3-07e782e9044d; Tue, 16 Apr 2024 11:16:09 +0200 (CEST) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a51a7dc45easo461971566b.2 for ; Tue, 16 Apr 2024 02:16:09 -0700 (PDT) Received: from fhilly.citrite.net (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id u2-20020a17090657c200b00a524476aac9sm4654723ejr.108.2024.04.16.02.16.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 02:16:07 -0700 (PDT) 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: f61d111e-fbd1-11ee-94a3-07e782e9044d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1713258968; x=1713863768; 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=sEqOdsYIwbuJuEjSHon4MvvMLQajO7Ykh4oIkPsh7vk=; b=EFcGpBQXmYHnfRATV1FQR91RHfwKH8mQB3gp7V4eOrU3x+SiLzbkTGzG7zBkSu0nCt bhCTB79DuUHkGkRh2JmPBrT7V/08J8Rr0B6dSn8PmLHZKoTsugDpEfP6Sm7OPCiF+ugg LaEj4lkQ6jljTPALMmb0NG443Zjn8DHUwdB7Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713258968; x=1713863768; 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=sEqOdsYIwbuJuEjSHon4MvvMLQajO7Ykh4oIkPsh7vk=; b=uJQ1yHCsg+JrhsDrINwBmITEnwxHQBR1MRV4TrB0NKFPIDXq8ajEe0g9TsogTA8fnx sdjV707XpALj+LPXb0Yjn3QXb2/sokS1wLwRlz8scjiTs/NeB3JmnE3U+xTX/otr+X24 klL+wwTHkCveYme25fM2/ol5+MNCIysTLDg5oQIgQuBM8yEzJkh2mtC6qviIHrILa4VL 6ZRRsNowMLtEyyiyTlmGhAuE3fKiIvREvYGuxoMiMgEYymDDdQk9k30TrlaOqHTe7ujZ NvNf+JChUp6aWSePetqAE7hAriOzmDIGpMDxIblLooq3yba8Pgod/D/ufzKyQ6rISEAk LJhg== X-Gm-Message-State: AOJu0YzGOlnA0ZtR1Sxde0vRRGyW0ubzo/eumZtUd9UXwZ5GpP5hRxQk +bWZHHa2KTwGMn6yEcwDk9+Qb6dpOLNY6/1M4iLEkENRz96QaQAtRx2ddwZVW07wEX/vaKwkHZi H X-Google-Smtp-Source: AGHT+IFWpEzwKPPdl1mw7tvXvVp9ZxgCj5ozb/nm/DQDDqkJUfTfQKWsf4eXQoXnBllzoU9TwfBbVQ== X-Received: by 2002:a17:907:6d18:b0:a51:e2a9:97c with SMTP id sa24-20020a1709076d1800b00a51e2a9097cmr12237822ejc.6.1713258968006; Tue, 16 Apr 2024 02:16:08 -0700 (PDT) From: Fouad Hilly To: Xen-devel Cc: Fouad Hilly , Anthony PERARD , Juergen Gross , Andrew Cooper Subject: [PATCH v2 5/5] x86: Add --force option to xen-ucode to override microcode version check Date: Tue, 16 Apr 2024 10:15:46 +0100 Message-ID: <20240416091546.11622-6-fouad.hilly@cloud.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240416091546.11622-1-fouad.hilly@cloud.com> References: <20240416091546.11622-1-fouad.hilly@cloud.com> MIME-Version: 1.0 Introduce --force option to xen-ucode to force skipping microcode version check, which allows the user to update x86 microcode even if both versions are the same. [v2] 1- Changed data type from uint32_t to unsigned int. 2- Corrected line length. 3- Removed XENPF_UCODE_FLAG_FORCE_NOT_SET. 4- Corrected indentations. 5- Changed command line options to have the file name as first argument when applicable. 6- --force option doesn't require an argument anymore. 7- Used optint to access filename in argv. Signed-off-by: Fouad Hilly --- Suggested-by: Andrew Cooper --- tools/include/xenctrl.h | 3 ++- tools/libs/ctrl/xc_misc.c | 13 +++++++++++-- tools/misc/xen-ucode.c | 18 +++++++++++++----- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 2ef8b4e05422..49d2f19c0d77 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_ver); 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 5ecdfa2c7934..fbc17cefa82e 100644 --- a/tools/libs/ctrl/xc_misc.c +++ b/tools/libs/ctrl/xc_misc.c @@ -203,7 +203,8 @@ int xc_physinfo(xc_interface *xch, return 0; } -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 = {}; @@ -215,7 +216,15 @@ int xc_microcode_update(xc_interface *xch, const void *buf, size_t len) memcpy(uc, buf, len); - platform_op.cmd = XENPF_microcode_update; + if ( flags > 0 ) + { + platform_op.cmd = XENPF_microcode_update2; + platform_op.u.microcode.flags = flags; + } + else + { + platform_op.cmd = XENPF_microcode_update; + } platform_op.u.microcode.length = len; set_xen_guest_handle(platform_op.u.microcode.data, uc); diff --git a/tools/misc/xen-ucode.c b/tools/misc/xen-ucode.c index e3c1943e3633..4178fd2221ea 100644 --- a/tools/misc/xen-ucode.c +++ b/tools/misc/xen-ucode.c @@ -13,6 +13,8 @@ #include #include +#include + static xc_interface *xch; static const char intel_id[] = "GenuineIntel"; @@ -24,7 +26,8 @@ static void usage(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 micorocde version check\n", name, name); } @@ -89,10 +92,12 @@ int main(int argc, char *argv[]) size_t len; struct stat st; int opt; + uint32_t ucode_flag = 0; static const struct option options[] = { {"help", no_argument, NULL, 'h'}, {"show-cpu-info", no_argument, NULL, 's'}, + {"force", no_argument, NULL, 'f'}, {NULL, no_argument, NULL, 0} }; @@ -104,10 +109,10 @@ int main(int argc, char *argv[]) exit(1); } - if ( argc != 2 ) + if ( argc < 2 || argc > 3) goto ext_err; - while ( (opt = getopt_long(argc, argv, "hs", options, NULL)) != -1 ) + while ( (opt = getopt_long(argc, argv, "hsf", options, NULL)) != -1 ) { switch (opt) { @@ -117,12 +122,15 @@ int main(int argc, char *argv[]) case 's': show_curr_cpu(stdout); exit(EXIT_SUCCESS); + case 'f': + ucode_flag = XENPF_UCODE_FLAG_FORCE_SET; + break; default: goto ext_err; } } - filename = argv[1]; + filename = argv[optind]; fd = open(filename, O_RDONLY); if ( fd < 0 ) { @@ -146,7 +154,7 @@ int main(int argc, char *argv[]) exit(1); } - ret = xc_microcode_update(xch, buf, len); + ret = xc_microcode_update(xch, buf, len, ucode_flag); if ( ret ) { fprintf(stderr, "Failed to update microcode. (err: %s)\n",