From nobody Thu Oct 30 18:55:08 2025 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1753824743; cv=none; d=zohomail.com; s=zohoarc; b=XEO7awZl+a0EbpsdlMfAYWz/6HogxGBTJwIBQ9i2htgaJXP0rR00fgxfU3KLIZ9WUdJOlgAVvPrj9ab+kfjd8Tz4EfxannF6zFGaEMYHY5k1Yn6JdmK4Nx7Xal3alSqOT3obANDY7pfLBpFASjL12xqn53QTsTkjqIIH8NE7pA4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753824743; h=Content-Type: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=gYS1r36qs+Kqa8dRxSHhrgjOqY6KhuerE4DlOOPShYQ=; b=jBmCs8pnHB78b6WOliV/16ItPnXWCaueYs2n2dZHgFL82RMKmJTwp+G1AXzD8ogKwTWF9m+vVxrjldw2axIWhwPCCzsaXHqOLKC28HnmfOYqoFtPrP7bu10kYwSv+olA8jGi549jWpMkPMr7TFPux87awwF4VNLMUn2E7AXJjd0= 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=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1753824743023886.5413601285751; Tue, 29 Jul 2025 14:32:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1063124.1428913 (Exim 4.92) (envelope-from ) id 1ugrve-0000p4-Jn; Tue, 29 Jul 2025 21:32:10 +0000 Received: by outflank-mailman (output) from mailman id 1063124.1428913; Tue, 29 Jul 2025 21:32: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 1ugrve-0000ox-Fh; Tue, 29 Jul 2025 21:32:10 +0000 Received: by outflank-mailman (input) for mailman id 1063124; Tue, 29 Jul 2025 21:32:09 +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 1ugrou-0004NS-Ie for xen-devel@lists.xenproject.org; Tue, 29 Jul 2025 21:25:12 +0000 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [2a00:1450:4864:20::52d]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8299ac26-6cc2-11f0-a320-13f23c93f187; Tue, 29 Jul 2025 23:25:12 +0200 (CEST) Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-615234e9d3aso352079a12.0 for ; Tue, 29 Jul 2025 14:25:12 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6156591fe7bsm1587728a12.51.2025.07.29.14.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Jul 2025 14:25: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: 8299ac26-6cc2-11f0-a320-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753824311; x=1754429111; 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=gYS1r36qs+Kqa8dRxSHhrgjOqY6KhuerE4DlOOPShYQ=; b=U5CQxhWZKvZnjz6Mj2dVSFW1JfGLGluXBdvF+Z743y6q2x7pGhY1JcwYlhmSupNykX IcL320zDtvOnFsYNQwf+n5cnj6t3mtpQ16RaUjcRbBh1BdnchqlDdNDR1wdqHoKzp6LT 2ROVV4wvmt8Vm0S/XgxKG5P1gg2B9zAj4CNaE8+3JOYuoi2HXqqg9nPLIA0uCqDnHMro lZmnKH+9+7ZeMdIu4+cJcU3NjSq7MUBwBEh4T9N+ZNDqim0SYAWA0VOBsk4eO5Iyo6IU eynwFARZ/jkT+4ET43vfvOBjfV55FdCqltpmfavFj7F8thSWn+uXYIMMU1KmtFmfnXEo aHHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753824311; x=1754429111; 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=gYS1r36qs+Kqa8dRxSHhrgjOqY6KhuerE4DlOOPShYQ=; b=IU3c4/xvY+xgaITGLUKLSr99RQ7ovSjkLJliLYY9Jsf2XMeXRS3xnipVYdda3k9/o1 GNkExAcz0K/mHoPGzhUCL4I49X++fsC06opduUBpUywZfz53e4AKzzkEvIZQ+xBdPRvE 5XmT6jqjGk+1d+m2yOvZAW0NZIHGgtDj+n6Q7xovcFwo0myDPOERJijx9JXEzks4xUCE oceu997W2x7M9Iho3/B3NhpniE8Mqel1gBuNpIL2sg1WjoxeL94YHGd5cdzjozunvMuf hw9RobLX8yDhclZzK/3jEUov3pGxkXJgdI0bU/5SEEg7xafeWs/Jkx33ne6yjslelev+ 8lGA== X-Gm-Message-State: AOJu0YwSVSgFh6cNhqGE7mYjFM8XyB1ckYK8iGYz4IBSTBwXwdGL5pDB F4k7jqqwGFivrmmFvS4ln1JyrMykYjOQ3QQ+eqOR3SSlneqsD/W9aDiu0gExikudYe8= X-Gm-Gg: ASbGncvJT1MXGfaYNSc/HIjP58TKrRFlyUq5SzGhWxJeRZ1qa2v17IH/S1YxUsl9MDL cHT7A5MMHm59XntMQZa5aQ6nS3oXjUTkqObSukWEvi4bqOOlOwkVumW9M7OD/DZLsT1nQOBRBOP RZrfF3tdNApGEGOmG7s5KbiLves0ahnCuA2vB3vsJFzj5FibcrC3UCUZpNdTqiaa6/gFa5lXAqJ GrTEQrb4c8bA9Pxk4Matcgvr95hX1SPuZqvoapGHD1C88kSr4lffFNkVUpOyJcA+at3XLFEpJ/+ OZaB5aP2SXw51CA5WHkgf9TqWQlKHrdO5HKxovC1hzYoVyypBYWhIxJF2oU3QN7HU82Erl+tMhL CpAaAoQmUCXiCmu0xnib3PkS1QeaeTjujt0XEST5XpWyWKTy2320RUjiIYowNSZuM9iztTAcx3B zjEpI6KdAaQLQDYX9DGUguYg== X-Google-Smtp-Source: AGHT+IFUVt7RK+iIy4ct7MC7XBalbUEwTJ/tJpRWMV07x51wKB3a1AP0vBElMPIFL4EW2rRi0Ch/lw== X-Received: by 2002:a05:6402:2110:b0:615:61fb:49e9 with SMTP id 4fb4d7f45d1cf-615871f3892mr469186a12.7.1753824310880; Tue, 29 Jul 2025 14:25:10 -0700 (PDT) From: "=?UTF-8?q?Petr=20Bene=C5=A1?=" X-Google-Original-From: =?UTF-8?q?Petr=20Bene=C5=A1?= To: xen-devel@lists.xenproject.org Cc: =?UTF-8?q?Petr=20Bene=C5=A1?= , Anthony PERARD Subject: [PATCH v3 1/3] tools: add sizeof_field and offsetofend macros Date: Tue, 29 Jul 2025 21:25:04 +0000 Message-Id: <556d53ef59bf771a727bd49116e91bb515ed7ec6.1753823663.git.w1benny@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1753824744721116600 From: Petr Bene=C5=A1 'offsetofend' macro appears in Linux codebase, so the name was chosen to be consistent with it. Signed-off-by: Petr Bene=C5=A1 --- tools/include/xen-tools/common-macros.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/include/xen-tools/common-macros.h b/tools/include/xen-to= ols/common-macros.h index 0088208c2e..c98a6beffd 100644 --- a/tools/include/xen-tools/common-macros.h +++ b/tools/include/xen-tools/common-macros.h @@ -83,6 +83,11 @@ #define __packed __attribute__((__packed__)) #endif =20 +#define sizeof_field(type, member) sizeof(((type *)NULL)->member) + +#define offsetofend(type, member) \ + (offsetof(type, member) + sizeof_field(type, member)) + #define container_of(ptr, type, member) ({ \ typeof(((type *)0)->member) *mptr__ =3D (ptr); \ (type *)((char *)mptr__ - offsetof(type, member)); \ --=20 2.34.1 From nobody Thu Oct 30 18:55:08 2025 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1753824759; cv=none; d=zohomail.com; s=zohoarc; b=fzrmxCFrW5gxdaow06h4IsVf7O+ozfz+XFwiO+GSoMMiIdb2Qm5uprJatvXp1pGWGPQYRcFNCrET4mpBoVpZfoMIq3XbJyHGxTKQElbBmCDShbdMpjqYQcv6FLrNJabt4eREJqTg0TCOpZJS6RVoA6V4zlduHAaZcFRbnbTLV+U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753824759; h=Content-Type: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=zqxtdLSvzaahRRjqVa083XvlybPW7VZWDBhsW5p9Dbg=; b=hPUSQwqd53mCB99sKU94g5rhuJ62It5zbJCLJqhCNAOt/tF7HdIdZTvZO12Z+4U0Frv1nOjm150fPpLJnfqX8nyOImReuXudLph2UNDB+t5soHR2gp9axmFcCPlMKKRFn4RdP8k3MhJ775EHyosmjJJ4fF4WVfpcb/gIl87SZ5U= 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=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1753824759949906.7378533756699; Tue, 29 Jul 2025 14:32:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1063129.1428922 (Exim 4.92) (envelope-from ) id 1ugrvu-0001Ma-Qi; Tue, 29 Jul 2025 21:32:26 +0000 Received: by outflank-mailman (output) from mailman id 1063129.1428922; Tue, 29 Jul 2025 21:32:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ugrvu-0001MR-Nj; Tue, 29 Jul 2025 21:32:26 +0000 Received: by outflank-mailman (input) for mailman id 1063129; Tue, 29 Jul 2025 21:32:25 +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 1ugrov-0004NS-Sf for xen-devel@lists.xenproject.org; Tue, 29 Jul 2025 21:25:14 +0000 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [2a00:1450:4864:20::531]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 831a3180-6cc2-11f0-a320-13f23c93f187; Tue, 29 Jul 2025 23:25:13 +0200 (CEST) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-615547ee514so427373a12.1 for ; Tue, 29 Jul 2025 14:25:12 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6156591fe7bsm1587728a12.51.2025.07.29.14.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Jul 2025 14:25:11 -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: 831a3180-6cc2-11f0-a320-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753824312; x=1754429112; 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=zqxtdLSvzaahRRjqVa083XvlybPW7VZWDBhsW5p9Dbg=; b=e4hM0EnDSRtq1J+aMz6GJBPtvgNkRS1JUAnxFc4Visxi1hhwkuIMwDSIGlm3RBpbjt GXO3mU+dQeStA/DNnBdULoRc4ACk0lCqVcjK9Ue1raZbMGAeynBBhJHRXSzt3dJnx0wg PCBdafOi9x5JfY1mDCMdQnRg7zO8/deOrYFV6a9QmcCBWxWxFdB7nSyeuzZP0qXE0M4s WJqGPTBVxrQCT0sU/nSI2bJ6l+Ao6Gxib7HMxUSjsdpXcbGv2Z5+2Rlv7aN0y+T2UGTS Tk4hJylqhO6xze/Qa2AhLkZx4UGaCDsSoYYGjypbv1GJhWD8s2EN73tDEOJD2lnddZ6x yrMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753824312; x=1754429112; 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=zqxtdLSvzaahRRjqVa083XvlybPW7VZWDBhsW5p9Dbg=; b=b5g7aSPjGsCsRRGVAhR61uchjmC3ndW5P6ddgEVqFNETZzzxaoYvL2VPKllZ25UqyB QvrtJwvNRbhVTtcjXInlaR+EQA0u2Pl/XjuejFSIasVQwRHe6e3D6X63ZKNPB3uC4iyH xMpSHkuGv/WnxIR0vBvnAgN3B3BAQrEQF6bfNCKmpwY0VvRPScgD47AU4jnrC8YjEEqp 7br6om60W63H1J3DqU1dbL3f71JAp9Ud3KxzHE6iqEHOPO21qpSn1a+U1pgSWmjBw4oT qcsqPtH3Dv9qXpF19C4j3yBRDUhLqAQbjViYdQOGyKlqYQ2uF+4rrWia89FzFZM3GVqO y/Lg== X-Gm-Message-State: AOJu0YzTBfOL3srEbQVbWS6Zn/S+YUcz3D5zx4GuQbQxCRmyRVlUELSp XxXnPS3Ag6syXMq2KFJm6pO5rMG16TK3QYDfzwfSA4EFwSXR/hsM7lX/misms9PmuDo= X-Gm-Gg: ASbGncvLf7hq5xkr94cRCbm9Fam6bgil1RPjnbryDaYyl0YXhl0Kimw+9TM42X9StBF V7WEQtBSoKLMROwvgoQwUYTk+WzKMy0nj03+kXxvX9mzM6WNOMIIS3mzFcv4V8bv4+qpDdtL/gD Vbgbjsz6ih0kI9A9ngUKxFybcvBrUnQJc9b39h5opK0Y92t1pK0Av348GEc+NHOb7r27XtLm274 U+IV07/hJJzbvHtpQO7dRDM5fIOp6Yc0z9J6OWOQc4ioT51HBC1jVkgFzVJS6NOMQqaAiquOVLX tTqPtXjHo4ENnBdZXfM98/9MFWyuCpS3L/1QNY4B+5XrMrYnjaRSk0HfT3lb/kIEtg2KBxEG1WL enEffkjl8XfSeSgRXkXOQ1mDjpkWhKHMW42EycxHR/Thz/SZOXnQ69UXqoQw0aI4m/XHFb2csBl xKONF+jDGkE+7ks0k7Dch/xw== X-Google-Smtp-Source: AGHT+IGCnJmcAO55hkrB4CxMj1eabASeMpc45FZOZdSG2TQhNL9Noi8kwe2lXKYDkl7c1zobVVYqLw== X-Received: by 2002:a05:6402:278d:b0:607:eea1:1038 with SMTP id 4fb4d7f45d1cf-615871f0420mr437482a12.6.1753824311688; Tue, 29 Jul 2025 14:25:11 -0700 (PDT) From: "=?UTF-8?q?Petr=20Bene=C5=A1?=" X-Google-Original-From: =?UTF-8?q?Petr=20Bene=C5=A1?= To: xen-devel@lists.xenproject.org Cc: =?UTF-8?q?Petr=20Bene=C5=A1?= , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Anthony PERARD Subject: [PATCH v3 2/3] hvmloader: fix SMBIOS table length checks Date: Tue, 29 Jul 2025 21:25:05 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1753824761246116600 From: Petr Bene=C5=A1 SMBIOS specification dictates that tables should have a minimal length. This commit introduces further validation for user-input SMBIOS tables. As per SMBIOS Reference Specification: * Type 0: For version 2.3 and later implementations, the length is at least= 14h * Type 1: 1Bh for 2.4 and later * Type 2: at least 08h * Type 3: 0Dh for version 2.1 and later * Type 11: 5h (+ strings) * Type 22: 1Ah (+ strings) * Type 39: a minimum of 10h Notably, this also fixes previously incorrect check for chassis handle in smbios_type_2_init. Chassis handle is a WORD, therefore, the condition now correctly checks for >=3D 13 instead of > 13. hvmloader currently implements version 2.4 Furthermore, this commit introduces smbios_pt_copy helper function to subst= itute previously repeating pattern of locating the struct in physical memory (via get_smbios_pt_struct), checking the length and copying it into SMBIOS regio= n. Signed-off-by: Petr Bene=C5=A1 --- tools/firmware/hvmloader/smbios.c | 179 ++++++++++++++---------- tools/firmware/hvmloader/smbios_types.h | 32 ++--- 2 files changed, 124 insertions(+), 87 deletions(-) diff --git a/tools/firmware/hvmloader/smbios.c b/tools/firmware/hvmloader/s= mbios.c index 6bcdcc233a..585f7f8165 100644 --- a/tools/firmware/hvmloader/smbios.c +++ b/tools/firmware/hvmloader/smbios.c @@ -47,6 +47,8 @@ static void smbios_pt_init(void); static void* get_smbios_pt_struct(uint8_t type, uint32_t *length_out); +static void * +smbios_pt_copy(void *start, uint8_t type, uint16_t handle, size_t table_si= ze); static void get_cpu_manufacturer(char *buf, int len); static int @@ -154,6 +156,24 @@ get_smbios_pt_struct(uint8_t type, uint32_t *length_ou= t) return NULL; } =20 +static void * +smbios_pt_copy(void *start, uint8_t type, uint16_t handle, size_t table_si= ze) +{ + struct smbios_structure_header *header =3D start; + void *pts; + uint32_t length; + + pts =3D get_smbios_pt_struct(type, &length); + if ( pts !=3D NULL && length >=3D table_size ) + { + memcpy(start, pts, length); + header->handle =3D handle; + return start + length; + } + + return start; +} + static void get_cpu_manufacturer(char *buf, int len) { @@ -381,16 +401,17 @@ smbios_type_0_init(void *start, const char *xen_versi= on, struct smbios_type_0 *p =3D start; static const char *smbios_release_date =3D __SMBIOS_DATE__; const char *s; - void *pts; - uint32_t length; + void *next; =20 - pts =3D get_smbios_pt_struct(0, &length); - if ( pts !=3D NULL && length > 0 ) - { - memcpy(start, pts, length); - p->header.handle =3D SMBIOS_HANDLE_TYPE0; - return start + length; - } + /* + * Specification says Type 0 table has length of at least 18h for v2.4= -3.0. + */ + + BUILD_BUG_ON(sizeof(*p) !=3D 24); + + next =3D smbios_pt_copy(start, 0, SMBIOS_HANDLE_TYPE0, sizeof(*p)); + if ( next !=3D start ) + return next; =20 memset(p, 0, sizeof(*p)); =20 @@ -440,16 +461,14 @@ smbios_type_1_init(void *start, const char *xen_versi= on, char uuid_str[37]; struct smbios_type_1 *p =3D start; const char *s; - void *pts; - uint32_t length; + void *next; =20 - pts =3D get_smbios_pt_struct(1, &length); - if ( pts !=3D NULL && length > 0 ) - { - memcpy(start, pts, length); - p->header.handle =3D SMBIOS_HANDLE_TYPE1; - return start + length; - } + /* Specification says Type 1 table has length of 1Bh for v2.4 and late= r. */ + BUILD_BUG_ON(sizeof(*p) !=3D 27); + + next =3D smbios_pt_copy(start, 1, SMBIOS_HANDLE_TYPE1, sizeof(*p)); + if ( next !=3D start ) + return next; =20 memset(p, 0, sizeof(*p)); =20 @@ -498,26 +517,30 @@ smbios_type_2_init(void *start) { struct smbios_type_2 *p =3D start; const char *s; - uint8_t *ptr; - void *pts; - uint32_t length; + void *next; unsigned int counter =3D 0; =20 - pts =3D get_smbios_pt_struct(2, &length); - if ( pts !=3D NULL && length > 0 ) - { - memcpy(start, pts, length); - p->header.handle =3D SMBIOS_HANDLE_TYPE2; + /* + * Specification says Type 2 table has length of at least 08h, + * which corresponds with the end of the "Serial Number" field. + */ + + BUILD_BUG_ON(offsetofend(struct smbios_type_2, serial_number_str) !=3D= 8); =20 + next =3D smbios_pt_copy(start, 2, SMBIOS_HANDLE_TYPE2, + offsetofend(struct smbios_type_3, + serial_number_str)); + if ( next !=3D start ) + { /* Set current chassis handle if present */ - if ( p->header.length > 13 ) + if ( p->header.length >=3D offsetofend(struct smbios_type_2, + chassis_handle) ) { - ptr =3D ((uint8_t*)start) + 11; =20 - if ( *((uint16_t*)ptr) !=3D 0 ) - *((uint16_t*)ptr) =3D SMBIOS_HANDLE_TYPE3; + if ( p->chassis_handle !=3D 0 ) + p->chassis_handle =3D SMBIOS_HANDLE_TYPE3; } =20 - return start + length; + return next; } =20 memset(p, 0, sizeof(*p)); @@ -593,18 +616,21 @@ smbios_type_3_init(void *start) { struct smbios_type_3 *p =3D start; const char *s; - void *pts; - uint32_t length; + void *next; uint32_t counter =3D 0; =20 - pts =3D get_smbios_pt_struct(3, &length); - if ( pts !=3D NULL && length > 0 ) - { - memcpy(start, pts, length); - p->header.handle =3D SMBIOS_HANDLE_TYPE3; - return start + length; - } - =20 + /* + * Specification says Type 3 table has length of at least 0Dh (for v2.= 1+), + * which corresponds with the end of the "Security Status" field. + */ + + BUILD_BUG_ON(offsetofend(struct smbios_type_3, security_status) !=3D 1= 3); + + next =3D smbios_pt_copy(start, 3, SMBIOS_HANDLE_TYPE3, + offsetof(struct smbios_type_3, security_status)); + if ( next !=3D start ) + return next; + memset(p, 0, sizeof(*p)); =20 p->header.type =3D 3; @@ -656,6 +682,9 @@ smbios_type_4_init( struct smbios_type_4 *p =3D start; uint32_t eax, ebx, ecx, edx; =20 + /* Specification says Type 4 table has length of 23h for v2.3+. */ + BUILD_BUG_ON(sizeof(*p) !=3D 35); + memset(p, 0, sizeof(*p)); =20 p->header.type =3D 4; @@ -707,17 +736,15 @@ smbios_type_11_init(void *start) struct smbios_type_11 *p =3D start; char path[20]; const char *s; + void *next; int i; - void *pts; - uint32_t length; =20 - pts =3D get_smbios_pt_struct(11, &length); - if ( pts !=3D NULL && length > 0 ) - { - memcpy(start, pts, length); - p->header.handle =3D SMBIOS_HANDLE_TYPE11; - return start + length; - } + /* Specification says Type 11 table has length of 05h. */ + BUILD_BUG_ON(sizeof(*p) !=3D 5); + =20 + next =3D smbios_pt_copy(start, 11, SMBIOS_HANDLE_TYPE11, sizeof(*p)); + if ( next !=3D start ) + return next; =20 p->header.type =3D 11; p->header.length =3D sizeof(*p); @@ -756,6 +783,9 @@ smbios_type_16_init(void *start, uint32_t memsize, int = nr_mem_devs) { struct smbios_type_16 *p =3D start; =20 + /* Specification says Type 16 table has length of 0Fh for v2.1-2.7. */ + BUILD_BUG_ON(sizeof(*p) !=3D 15); + memset(p, 0, sizeof(*p)); =20 p->header.type =3D 16; @@ -781,6 +811,9 @@ smbios_type_17_init(void *start, uint32_t memory_size_m= b, int instance) char buf[16]; struct smbios_type_17 *p =3D start; =20 + /* Specification says Type 17 table has length of 1Bh for v2.3-2.6. */ + BUILD_BUG_ON(sizeof(*p) !=3D 27); + memset(p, 0, sizeof(*p)); =20 p->header.type =3D 17; @@ -816,6 +849,9 @@ smbios_type_19_init(void *start, uint32_t memory_size_m= b, int instance) { struct smbios_type_19 *p =3D start; =20 + /* Specification says Type 19 table has length of 0Fh for v2.1-2.7. */ + BUILD_BUG_ON(sizeof(*p) !=3D 15); + memset(p, 0, sizeof(*p)); =20 p->header.type =3D 19; @@ -838,6 +874,9 @@ smbios_type_20_init(void *start, uint32_t memory_size_m= b, int instance) { struct smbios_type_20 *p =3D start; =20 + /* Specification says Type 20 table has length of 13h for v2.1-2.7. */ + BUILD_BUG_ON(sizeof(*p) !=3D 19); + memset(p, 0, sizeof(*p)); =20 p->header.type =3D 20; @@ -865,16 +904,14 @@ smbios_type_22_init(void *start) struct smbios_type_22 *p =3D start; static const char *smbios_release_date =3D __SMBIOS_DATE__; const char *s; - void *pts; - uint32_t length; + void *next; =20 - pts =3D get_smbios_pt_struct(22, &length); - if ( pts !=3D NULL && length > 0 ) - { - memcpy(start, pts, length); - p->header.handle =3D SMBIOS_HANDLE_TYPE22; - return start + length; - } + /* Specification says Type 22 table has length of 1Ah. */ + BUILD_BUG_ON(sizeof(*p) !=3D 26); + + next =3D smbios_pt_copy(start, 22, SMBIOS_HANDLE_TYPE22, sizeof(*p)); + if ( next !=3D start ) + return next; =20 s =3D xenstore_read(HVM_XS_SMBIOS_DEFAULT_BATTERY, "0"); if ( strncmp(s, "1", 1) !=3D 0 ) @@ -929,6 +966,9 @@ smbios_type_32_init(void *start) { struct smbios_type_32 *p =3D start; =20 + /* Specification says Type 32 table has length of at least 0Bh. */ + BUILD_BUG_ON(sizeof(*p) !=3D 11); + memset(p, 0, sizeof(*p)); =20 p->header.type =3D 32; @@ -946,20 +986,17 @@ smbios_type_32_init(void *start) static void * smbios_type_39_init(void *start) { - struct smbios_type_39 *p =3D start; - void *pts; - uint32_t length; + /* + * Specification says Type 39 table has length of at least 10h, + * which corresponds with the end of the "Characteristics" field. + * + * Only present when passed in. + */ =20 - pts =3D get_smbios_pt_struct(39, &length); - if ( pts !=3D NULL && length > 0 ) - { - memcpy(start, pts, length); - p->header.handle =3D SMBIOS_HANDLE_TYPE39; - return start + length; - } + BUILD_BUG_ON(offsetofend(struct smbios_type_39, characteristics) !=3D = 16); =20 - /* Only present when passed in */ - return start; + return smbios_pt_copy(start, 39, SMBIOS_HANDLE_TYPE39, + offsetofend(struct smbios_type_39, characteristi= cs)); } =20 static void * diff --git a/tools/firmware/hvmloader/smbios_types.h b/tools/firmware/hvmlo= ader/smbios_types.h index 7c648ece71..a04d194975 100644 --- a/tools/firmware/hvmloader/smbios_types.h +++ b/tools/firmware/hvmloader/smbios_types.h @@ -90,13 +90,13 @@ struct smbios_type_2 { uint8_t product_name_str; uint8_t version_str; uint8_t serial_number_str; - uint8_t asset_tag_str; - uint8_t feature_flags; - uint8_t location_in_chassis_str; - uint16_t chassis_handle; - uint8_t board_type; - uint8_t contained_handle_count; - uint16_t contained_handles[]; + uint8_t asset_tag_str; /* Optional */ + uint8_t feature_flags; /* Optional */ + uint8_t location_in_chassis_str; /* Optional */ + uint16_t chassis_handle; /* Optional */ + uint8_t board_type; /* Optional */ + uint8_t contained_handle_count; /* Optional */ + uint16_t contained_handles[]; /* Optional */ } __attribute__ ((packed)); =20 /* System Enclosure - Contained Elements */ @@ -118,12 +118,12 @@ struct smbios_type_3 { uint8_t power_supply_state; uint8_t thermal_state; uint8_t security_status; - uint32_t oem_specific; - uint8_t height; - uint8_t number_of_power_cords; - uint8_t contained_element_count; - uint8_t contained_element_length; - struct smbios_contained_element contained_elements[]; + uint32_t oem_specific; /* Optional */ + uint8_t height; /* Optional */ + uint8_t number_of_power_cords; /* Optional */ + uint8_t contained_element_count; /* Optional */ + uint8_t contained_element_length; /* Optional */ + struct smbios_contained_element contained_elements[]; /* Optional */ } __attribute__ ((packed)); =20 /* SMBIOS type 4 - Processor Information */ @@ -252,9 +252,9 @@ struct smbios_type_39 { uint8_t revision_level_str; uint16_t max_capacity; uint16_t characteristics; - uint16_t input_voltage_probe_handle; - uint16_t cooling_device_handle; - uint16_t input_current_probe_handle; + uint16_t input_voltage_probe_handle; /* Optional */ + uint16_t cooling_device_handle; /* Optional */ + uint16_t input_current_probe_handle; /* Optional */ } __attribute__ ((packed)); =20 /* SMBIOS type 127 -- End-of-table */ --=20 2.34.1 From nobody Thu Oct 30 18:55:08 2025 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1753824675; cv=none; d=zohomail.com; s=zohoarc; b=PWo+S1GAUc7NRMhsopSHj29TeekNnXndBaHnIPV3zyb/ZoRi5v64jfVSww7McmMHBg7/EZH4mwbfhX2rYdmxEDuFdVg35RCcMc/4hUoa54Pb0bHEqDilb72olMgXZ2APkrzxBHVAKzifNRF8HYJ73Uon4jZ4lFoqx/Ke+oBb7qQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753824675; h=Content-Type: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=mj53EHQ52Dtsxd70YzqRxEmGljTKHDFX4pLLI8bOt7s=; b=Fe2H1mDxwFVE/5TT1Ie9e3v0Lqmix+vBcgrcFrNp6SZZASz7YeCl+O1kjQFrdQjrcmvlG04Iy3L4AqXR5FSLe9s7ZXk/1xssq21yXMrLYolgAsfAanei+9oYjilNZDd41JVvo68b9710464Cp9wIcwKHVTjpVIdMbRFTFQvmqQE= 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=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 175382467574847.42865878018051; Tue, 29 Jul 2025 14:31:15 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1063114.1428903 (Exim 4.92) (envelope-from ) id 1ugruP-0000EZ-5S; Tue, 29 Jul 2025 21:30:53 +0000 Received: by outflank-mailman (output) from mailman id 1063114.1428903; Tue, 29 Jul 2025 21:30: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 1ugruP-0000ES-2C; Tue, 29 Jul 2025 21:30:53 +0000 Received: by outflank-mailman (input) for mailman id 1063114; Tue, 29 Jul 2025 21:30:51 +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 1ugrox-0005Qf-Do for xen-devel@lists.xenproject.org; Tue, 29 Jul 2025 21:25:15 +0000 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [2a00:1450:4864:20::532]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 83a83c35-6cc2-11f0-b895-0df219b8e170; Tue, 29 Jul 2025 23:25:13 +0200 (CEST) Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-61563789ab7so247227a12.3 for ; Tue, 29 Jul 2025 14:25:13 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6156591fe7bsm1587728a12.51.2025.07.29.14.25.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Jul 2025 14:25:12 -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: 83a83c35-6cc2-11f0-b895-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753824313; x=1754429113; 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=mj53EHQ52Dtsxd70YzqRxEmGljTKHDFX4pLLI8bOt7s=; b=kmmho7IKvjSCcL6of+rAAJYG8YcfZ08aZv1b6YfN4ccAP3g8PHK1meulkgVa7/nq2z 4niwCk4MopAMohP4t5dCatj5SLO3PKEYzkp7i53gr9d13G5blLkYl5O7FqwdH+GfNuZe MV/i6CeTXX4wXzRD6Ta2rQA0NHq98AGXPTDeKtAR0htj0Pkgg6/A90ZwzBn0nXi/Cv17 UWhGqmQF+FovFNNQo/Bu+1GEvkJ6vm6mpPfUv7hrtTbgVwmtPXSMKhruSAq9REMvxmI6 iaArnq5epf7U03lZrnOPEhKwEWwZ/JLfdSQ2vzblo5Ru9QkmUpOX/4EDdBxQHyODvBXP CQNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753824313; x=1754429113; 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=mj53EHQ52Dtsxd70YzqRxEmGljTKHDFX4pLLI8bOt7s=; b=beIcUkeZuQt4e/blAKUmMCNN2Lwh0GiPfiCMtPyCUB+rjzgkz2y43Te7Fp5+wgWhhp caDLgjiKXI5LotI78ReC3VnMM8nXHybPDUyaIsQ21LohZpYP0n0CJcTbWJ6XxJ7DFazB UrMzRpv6B/C77TNeXXN3Xe/0dLMKZD1iWzOmfgigYDt3YcOsocgyO7r4+bs8GqLIt4ER /psyspNgwjTduATGx/3qiE96VdnWlTeFXXch0HNc4qcPtCMjlBDY+Um/iR688usFNZ4W fjsR3yQGEUvj3ByQ3X68sCjUDcC1oUYs2HdMEVoNTPP99vUV/xpPlB+pt2PjH9h+Vnlb t3sQ== X-Gm-Message-State: AOJu0Yz809pdbnTHp9Sv5jyZBNSlyX/Nht5DNW3fkDz7hH39mPwGWIkH N1VVikhtjsK7FUDT3zEZ3iA164SD8X+JqncD3MN3yBDdzuTwkqL9Lc7PRooBsf4VoOI= X-Gm-Gg: ASbGncuKj2x6R9qwn7lSMVGb+FB1FiF0j5WxhOI1DNN4VGP9cofrBa8TYO0nL/0T9hV +UvYLQfSzXSBFnHEnvdsyTVQzh71fWzB3p1pa4WzI5U8nSa+2hlG2zOGyQ8KLDkduKVwEyowa/O ZLMHSjEz+SXdS+in5Uf/TNalh8iX12qlC0Q24EqeePpUmeWgIWD54a9GNB5gqYfoZikmhiUxL86 fHzbG497eoO1U5D4lHygONLEsolXOZbyG/tDiS7I+6kgCdWWEYhLPzsvrqFEy+CtZWCn6Mr5UiR KghK365vWMjsDRarYGKZyZqzUGB44iQBF6UUzcZi9deEyQBaE810jAXnINpmoOXRiABKxHjjKSU pJZ50FZea3dE6DnxYG4QykF+oI2VgQKgvKeuQMPEDMzGzvbEtE/6kwS7peWGM01WiGCprgLBQcg 0gqOQ+DgmlV8m9JpZ1l5cuNw== X-Google-Smtp-Source: AGHT+IFQt3O7WSxjQPHUGj2k6P+gPIq8PH4A17mX6o3e0sF/1NZOqoYlCudlXsaqW285+ST5W+rAiQ== X-Received: by 2002:a05:6402:1d50:b0:612:f2fc:2b9b with SMTP id 4fb4d7f45d1cf-61586ec3ea8mr374023a12.1.1753824312521; Tue, 29 Jul 2025 14:25:12 -0700 (PDT) From: "=?UTF-8?q?Petr=20Bene=C5=A1?=" X-Google-Original-From: =?UTF-8?q?Petr=20Bene=C5=A1?= To: xen-devel@lists.xenproject.org Cc: =?UTF-8?q?Petr=20Bene=C5=A1?= , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Anthony PERARD Subject: [PATCH v3 3/3] hvmloader: add new SMBIOS tables (7, 8, 9, 26, 27, 28) Date: Tue, 29 Jul 2025 21:25:06 +0000 Message-Id: <33b15fdbfd03a79007b0df0f2f22db920bf67e2a.1753823663.git.w1benny@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1753824678553116600 From: Petr Bene=C5=A1 Some SMBIOS tables are used by certain malware families to detect virtualiz= ed environments via WMI queries. To improve stealth for sandboxing purposes, this patch adds support for populating these SMBIOS tables from an external binary specified via the "smbios_firmware" domain config option: *=C2=A07 - Cache Info * 8 - Port Connector * 9 - System Slots * 26 - Voltage Probe * 27 - Cooling Device * 28 - Temperature Probe If particular table is absent in binary file, then it will not be mapped to memory. This method works for Windows domains as tables 7,8,9,26,27,28 are = not critical for OS boot and runtime. Also if "smbios_firmware" parameter is not provided, these tables will be skipped in write_smbios_tables function. From: Anton Belousov Signed-off-by: Petr Bene=C5=A1 --- tools/firmware/hvmloader/smbios.c | 111 ++++++++++++++++++++++++ tools/firmware/hvmloader/smbios_types.h | 77 ++++++++++++++++ 2 files changed, 188 insertions(+) diff --git a/tools/firmware/hvmloader/smbios.c b/tools/firmware/hvmloader/s= mbios.c index 585f7f8165..2df230f427 100644 --- a/tools/firmware/hvmloader/smbios.c +++ b/tools/firmware/hvmloader/smbios.c @@ -33,12 +33,18 @@ #define SMBIOS_HANDLE_TYPE2 0x0200 #define SMBIOS_HANDLE_TYPE3 0x0300 #define SMBIOS_HANDLE_TYPE4 0x0400 +#define SMBIOS_HANDLE_TYPE7 0x0700 +#define SMBIOS_HANDLE_TYPE8 0x0800 +#define SMBIOS_HANDLE_TYPE9 0x0900 #define SMBIOS_HANDLE_TYPE11 0x0B00 #define SMBIOS_HANDLE_TYPE16 0x1000 #define SMBIOS_HANDLE_TYPE17 0x1100 #define SMBIOS_HANDLE_TYPE19 0x1300 #define SMBIOS_HANDLE_TYPE20 0x1400 #define SMBIOS_HANDLE_TYPE22 0x1600 +#define SMBIOS_HANDLE_TYPE26 0x1A00 +#define SMBIOS_HANDLE_TYPE27 0x1B00 +#define SMBIOS_HANDLE_TYPE28 0x1C00 #define SMBIOS_HANDLE_TYPE32 0x2000 #define SMBIOS_HANDLE_TYPE39 0x2700 #define SMBIOS_HANDLE_TYPE127 0x7f00 @@ -79,6 +85,12 @@ static void * smbios_type_4_init(void *start, unsigned int cpu_number, char *cpu_manufacturer); static void * +smbios_type_7_init(void *start); +static void * +smbios_type_8_init(void *start); +static void * +smbios_type_9_init(void *start); +static void * smbios_type_11_init(void *start); static void * smbios_type_16_init(void *start, uint32_t memory_size_mb, int nr_mem_devs); @@ -91,6 +103,12 @@ smbios_type_20_init(void *start, uint32_t memory_size_m= b, int instance); static void * smbios_type_22_init(void *start); static void * +smbios_type_26_init(void *start); +static void * +smbios_type_27_init(void *start); +static void * +smbios_type_28_init(void *start); +static void * smbios_type_32_init(void *start); static void * smbios_type_39_init(void *start); @@ -225,6 +243,9 @@ write_smbios_tables(void *ep, void *start, do_struct(smbios_type_3_init(p)); for ( cpu_num =3D 1; cpu_num <=3D vcpus; cpu_num++ ) do_struct(smbios_type_4_init(p, cpu_num, cpu_manufacturer)); + do_struct(smbios_type_7_init(p)); + do_struct(smbios_type_8_init(p)); + do_struct(smbios_type_9_init(p)); do_struct(smbios_type_11_init(p)); =20 /* Each 'memory device' covers up to 16GB of address space. */ @@ -241,6 +262,9 @@ write_smbios_tables(void *ep, void *start, } =20 do_struct(smbios_type_22_init(p)); + do_struct(smbios_type_26_init(p)); + do_struct(smbios_type_27_init(p)); + do_struct(smbios_type_28_init(p)); do_struct(smbios_type_32_init(p)); do_struct(smbios_type_39_init(p)); do_struct(smbios_type_vendor_oem_init(p)); @@ -729,6 +753,42 @@ smbios_type_4_init( return start+1; } =20 +/* Type 7 -- Cache Information */ +static void * +smbios_type_7_init(void *start) +{ + /* Specification says Type 7 table has length of 13h for v2.1+. */ + BUILD_BUG_ON(sizeof(struct smbios_type_7) !=3D 19); + + /* Only present when passed in. */ + return smbios_pt_copy(start, 7, SMBIOS_HANDLE_TYPE7, + sizeof(struct smbios_type_7)); +} + +/* Type 8 -- Port Connector Information */ +static void * +smbios_type_8_init(void *start) +{ + /* Specification says Type 8 table has length of 09h. */ + BUILD_BUG_ON(sizeof(struct smbios_type_8) !=3D 9); + + /* Only present when passed in. */ + return smbios_pt_copy(start, 8, SMBIOS_HANDLE_TYPE8, + sizeof(struct smbios_type_8)); +} + +/* Type 9 -- System Slots */ +static void * +smbios_type_9_init(void *start) +{ + /* Specification says Type 9 table has length of 0Dh for v2.1-2.5. */ + BUILD_BUG_ON(sizeof(struct smbios_type_9) !=3D 13); + + /* Only present when passed in. */ + return smbios_pt_copy(start, 9, SMBIOS_HANDLE_TYPE9, + sizeof(struct smbios_type_9)); +} + /* Type 11 -- OEM Strings */ static void * smbios_type_11_init(void *start) @@ -960,6 +1020,57 @@ smbios_type_22_init(void *start) return start + 1; } =20 +/* Type 26 -- Voltage Probe */ +static void * +smbios_type_26_init(void *start) +{ + /* + * Specification says Type 26 table has length of at least 14h, + * which corresponds with the end of the "OEM-defined" field. + * + * Only present when passed in. + */ + + BUILD_BUG_ON(offsetofend(struct smbios_type_26, oem_defined) !=3D 20); + + return smbios_pt_copy(start, 26, SMBIOS_HANDLE_TYPE26, + offsetofend(struct smbios_type_26, oem_defined)); +} + +/* Type 27 -- Cooling Device */ +static void * +smbios_type_27_init(void *start) +{ + /* + * Specification says Type 27 table has length of at least 0Ch, + * which corresponds with the end of the "OEM-defined" field. + * + * Only present when passed in. + */ + + BUILD_BUG_ON(offsetofend(struct smbios_type_27, oem_defined) !=3D 12); +=20 + return smbios_pt_copy(start, 27, SMBIOS_HANDLE_TYPE27, + offsetofend(struct smbios_type_27, oem_defined)); +} + +/* Type 28 -- Temperature Probe */ +static void * +smbios_type_28_init(void *start) +{ + /* + * Specification says Type 28 table has length of at least 14h, + * which corresponds with the end of the "OEM-defined" field. + * + * Only present when passed in. + */ + + BUILD_BUG_ON(offsetofend(struct smbios_type_28, oem_defined) !=3D 20); + + return smbios_pt_copy(start, 28, SMBIOS_HANDLE_TYPE28, + offsetofend(struct smbios_type_28, oem_defined)); +} + /* Type 32 -- System Boot Information */ static void * smbios_type_32_init(void *start) diff --git a/tools/firmware/hvmloader/smbios_types.h b/tools/firmware/hvmlo= ader/smbios_types.h index a04d194975..c04b435d31 100644 --- a/tools/firmware/hvmloader/smbios_types.h +++ b/tools/firmware/hvmloader/smbios_types.h @@ -149,6 +149,44 @@ struct smbios_type_4 { uint8_t part_number_str; } __attribute__ ((packed)); =20 +/* SMBIOS type 7 - Cache Information */ +struct smbios_type_7 { + struct smbios_structure_header header; + uint8_t socket_designation_str; + uint16_t cache_configuration; + uint16_t maximum_cache_size; + uint16_t installed_size; + uint16_t supported_SRAM_type; + uint16_t current_SRAM_type; + uint8_t cache_speed; + uint8_t error_connection_type; + uint8_t system_cache_type; + uint8_t associativity; +} __attribute__ ((packed)); + +/* SMBIOS type 8 - Port Connector Information */ +struct smbios_type_8 { + struct smbios_structure_header header; + uint8_t internal_reference_designator_str; + uint8_t internal_connector_type; + uint8_t external_reference_designator_str; + uint8_t external_connector_type; + uint8_t port_type; +} __attribute__ ((packed)); + +/* SMBIOS type 9 - System Slots */ +struct smbios_type_9 { + struct smbios_structure_header header; + uint8_t slot_designation_str; + uint8_t slot_type; + uint8_t slot_data_bus_width; + uint8_t current_usage; + uint8_t slot_length; + uint16_t slot_id; + uint8_t slot_characteristics_1; + uint8_t slot_characteristics_2; +} __attribute__ ((packed)); + /* SMBIOS type 11 - OEM Strings */ struct smbios_type_11 { struct smbios_structure_header header; @@ -232,6 +270,45 @@ struct smbios_type_22 { uint32_t oem_specific; } __attribute__ ((packed)); =20 +/* SMBIOS type 26 - Voltage Probe */ +struct smbios_type_26 { + struct smbios_structure_header header; + uint8_t description_str; + uint8_t location_and_status; + uint16_t maximum_value; + uint16_t minimum_value; + uint16_t resolution; + uint16_t tolerance; + uint16_t accuracy; + uint32_t oem_defined; + uint16_t nominal_value; /* Optional */ +} __attribute__ ((packed)); + +/* SMBIOS type 27 - Cooling Device */ +struct smbios_type_27 { + struct smbios_structure_header header; + uint16_t temperature_probe_handle; + uint8_t device_type_and_status; + uint8_t cooling_unit_group; + uint32_t oem_defined; + uint16_t nominal_speed; /* Optional */ + uint8_t description_str; /* Optional */ +} __attribute__ ((packed)); + +/* SMBIOS type 28 - Temperature Probe */ +struct smbios_type_28 { + struct smbios_structure_header header; + uint8_t description_str; + uint8_t location_and_status; + uint16_t maximum_value; + uint16_t minimum_value; + uint16_t resolution; + uint16_t tolerance; + uint16_t accuracy; + uint32_t oem_defined; + uint16_t nominal_value; /* Optional */ +} __attribute__ ((packed)); + /* SMBIOS type 32 - System Boot Information */ struct smbios_type_32 { struct smbios_structure_header header; --=20 2.34.1