From nobody Thu Sep 19 01:04:52 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=1721896090; cv=none; d=zohomail.com; s=zohoarc; b=ZF2PYB5gv6xxkvbyYeki3gKl3ykeF2s06f7EGolAfoGN0Yy0vtZqU9MPTKUD03QRJq6hpqjewkcXeEsox61vIupRd4URJQJcUj5BKfLqGvGLT42lTB8/jOwr8pe6f2yrM1ythQiKTPLXtrKfQaKce7sErCDq3IoeRKl7tOIh+T0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721896090; 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=DlS1KhWcLxjYccvIIzbFt8aClNyV66/s1GUBwIQYHsI=; b=YyXSwPWcTW5JZveN1phmZ9IsDb0zwl3e9cYlRXYLsRELGu+ocIiiHuWlNOiRatD1DZolUAOuqd9A5geX7mpiJdlAw6zgEtKRFdGyZx0QhSDHZQX+hFq0bHz8ipce9VIoBX2AoGYKhU5UUScKD8eueuf4mB1PRIdVpK2x3+Bv3CM= 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 1721896090805866.4222037096401; Thu, 25 Jul 2024 01:28:10 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.764816.1175370 (Exim 4.92) (envelope-from ) id 1sWtpJ-0006j4-Tt; Thu, 25 Jul 2024 08:27:53 +0000 Received: by outflank-mailman (output) from mailman id 764816.1175370; Thu, 25 Jul 2024 08:27:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sWtpJ-0006i0-NE; Thu, 25 Jul 2024 08:27:53 +0000 Received: by outflank-mailman (input) for mailman id 764816; Thu, 25 Jul 2024 08:27:53 +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 1sWtpJ-0006fy-19 for xen-devel@lists.xenproject.org; Thu, 25 Jul 2024 08:27:53 +0000 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [2a00:1450:4864:20::52c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c888f67d-4a5f-11ef-bbff-fd08da9f4363; Thu, 25 Jul 2024 10:27:52 +0200 (CEST) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-5a3458bf858so775042a12.1 for ; Thu, 25 Jul 2024 01:27:51 -0700 (PDT) Received: from fhilly.. ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ac63590e7esm558590a12.36.2024.07.25.01.27.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 01:27:50 -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: c888f67d-4a5f-11ef-bbff-fd08da9f4363 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1721896071; x=1722500871; 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=DlS1KhWcLxjYccvIIzbFt8aClNyV66/s1GUBwIQYHsI=; b=c7LMZXVi2We6MGyqpij+TBdQJk7Ssfl1yF05x8UM2JnRQbB10vWTA5y9DfvNhAYhw3 4A7wjqzb1p10mGnjxIRQUqKQ1w7G129OjlM31Mz+97okFehlCzvbiLhff00o80rUCJzy BWQ4XQbt1lDQs7HaIgo9qW4cA+ipTq+Eayl+E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721896071; x=1722500871; 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=DlS1KhWcLxjYccvIIzbFt8aClNyV66/s1GUBwIQYHsI=; b=U3+maFW335quJAVRpwXKdLop4fXmTj4v0KnoABD6WiYdd/V06UNoTpyMkw3JGHSN26 tFBzNQNJn05lWh9w/KsowyK0jlbIgkh2I/OJKDKvZdvsSePC7rq6LAyOB3hS2eeJi2ab BMEvoOJeVSyWGL9WhdNzD5vVOyWqvIFFOPOt2QkuESN+XcvzqVKGhi6Vbn85ohAln0NQ LhCXjVUp3NcS4BisHaQ0T/uAOgIPpM1cOqGbqvcFnmcitUw8mvZbuJNBSg0Fxif9H0bR IargPItFeb2KbDNgOrKGHYYnvw6GDD1jMRXr7+biKrrVWg/Yf+XQBHQW5omXju8qSz84 gcRA== X-Gm-Message-State: AOJu0Yw3nymmaEkiige79tvhhL4O8WB6klI61Vu6aIW7riWr2zhqFEjx j+PUfms8hz3oPFLOzbq/KA7dP17ibVaL7lj0PyJVrSoRQNF2hxxo03hH2HO/9sjF+pZGh6N2CV/ L X-Google-Smtp-Source: AGHT+IGTV8Q1xjQCN4TbbuLHy7aECY3v2sqai8ntavveWfSOYmY+ZgnOp4IJHYABt/xKMKw2wpr6qg== X-Received: by 2002:a50:d79b:0:b0:5a2:d411:89fa with SMTP id 4fb4d7f45d1cf-5ac6412964amr874373a12.36.1721896070978; Thu, 25 Jul 2024 01:27:50 -0700 (PDT) From: Fouad Hilly To: xen-devel@lists.xenproject.org Cc: Fouad Hilly , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Julien Grall , Stefano Stabellini Subject: [PATCH v6 1/4] x86/ucode: Introduce XENPF_microcode_update2 with flags parameter Date: Thu, 25 Jul 2024 09:27:22 +0100 Message-ID: <20240725082725.2685481-2-fouad.hilly@cloud.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240725082725.2685481-1-fouad.hilly@cloud.com> References: <20240725082725.2685481-1-fouad.hilly@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1721896091188116600 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 --- [v6] No change [v5] 1- Update commit message to include the full name of XENPF_microcode_update2 [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