From patchwork Tue Mar 26 06:45:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Li X-Patchwork-Id: 10870465 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7AAE8139A for ; Tue, 26 Mar 2019 06:48:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 623192906A for ; Tue, 26 Mar 2019 06:48:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 51F7829092; Tue, 26 Mar 2019 06:48:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0FDE52906A for ; Tue, 26 Mar 2019 06:48:14 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h8fqD-00062U-2g; Tue, 26 Mar 2019 06:45:45 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h8fqB-00062P-NN for xen-devel@lists.xen.org; Tue, 26 Mar 2019 06:45:43 +0000 X-Inumbo-ID: c57663eb-4f92-11e9-bc90-bc764e045a96 Received: from mail-wm1-x341.google.com (unknown [2a00:1450:4864:20::341]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id c57663eb-4f92-11e9-bc90-bc764e045a96; Tue, 26 Mar 2019 06:45:41 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id h18so11570160wml.1 for ; Mon, 25 Mar 2019 23:45:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=M6CDS8Bix+QEuP6iMbIV4i2pgCqZLEifUmRJdet/qtg=; b=Yt32hGlkNZHAR2RsikZpPuIIzsCYwmrNsPlBq5SNUYzi5IcWY3N30VzZm1ieLIJztR Z9SYS4S2F1ONfVUDWRrQJcEZJjsWbLu10gLM0IUqc1RJnaSZvz9zzed8wlapkylQL6pB rPB4jaPfOpD3DYjMrJ8IjnQl9jwj3ZdAm78cr8OZDAcBqfL3zxmPhHzYT6L16tHWYn3V Mt42IDomlVdwJijdFNs3M28Xkr+jvBuHbVocIV9e6D1iwqVPrx/Zm2VW6WBs194nlEs2 v6ioKuNUipPel7yZMgvcHRNr3JdBptYhwHa8kJU+jnpkZe9lwSeUpKQUZFRvQT8AwPOm pYrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=M6CDS8Bix+QEuP6iMbIV4i2pgCqZLEifUmRJdet/qtg=; b=Progn/d6IFMiQKOMDFjjVTwO7CPVp/LAJAncWptyyqQrtsx38QcYH7FH7Lb2gxeNKR 495LDRzVi/oP4wHf/aiWzcAHREWC5pes2iiXBt+Z6Px+A0YOaNARZYj3aiHJLs0hL4Wq ttHSecE+4jYaBycs3q/9fMIsj/ZKixvC2b6mlk+h94erPjAtpBZtcq3wrASnyoVRPKCg FqISGPE518Ks450vd3Rhk3XsS00zfLvPEkeQHT8YnhkZupV8cD15Zlkwihw+WfP4UeG/ mEFISLhajvT80dAQXGrUbxwm+UTiP0GuTCkNGlRF2z/rLE6ghrvVHfdM0q61fsxwjHtT JwCw== X-Gm-Message-State: APjAAAUVqmR8x+xGbYQi6FDqRJkBuEFut0k8oSIS4EjtKrb2VSo2Ot3r qPbpoMVmB3haprXCga6uOqQ5wYJ0vT//mkrb X-Google-Smtp-Source: APXvYqzpgqb9p8p6bGNeDt5/08MWGLVa80nLRjV5AObx71A8ZICcHOCarn3ASnv3W/mQGiZIBzxkRA== X-Received: by 2002:a1c:43c2:: with SMTP id q185mr6682645wma.53.1553582740230; Mon, 25 Mar 2019 23:45:40 -0700 (PDT) Received: from lcy2-dt16.xenrtcloud ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id t69sm26670438wmt.16.2019.03.25.23.45.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Mar 2019 23:45:39 -0700 (PDT) From: Xin Li X-Google-Original-From: Xin Li To: xen-devel@lists.xen.org Date: Tue, 26 Mar 2019 06:45:32 +0000 Message-Id: <20190326064532.9054-1-xin.li@citrix.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v1 1/1] hvmloader: allow overriding SMBIOS type 2 info X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Xin Li , Sergey Dyasli , Andrew Cooper , Igor Druzhinin Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Extend smbios type 2 struct to match specification, add support to override strings from toolstack. Signed-off-by: Xin Li --- CC: Igor Druzhinin CC: Sergey Dyasli CC: Andrew Cooper --- tools/firmware/hvmloader/smbios.c | 64 ++++++++++++++++++++++++- tools/firmware/hvmloader/smbios_types.h | 6 +++ xen/include/public/hvm/hvm_xs_strings.h | 30 +++++++----- 3 files changed, 87 insertions(+), 13 deletions(-) diff --git a/tools/firmware/hvmloader/smbios.c b/tools/firmware/hvmloader/smbios.c index 40d8399be1..90cfe9fd10 100644 --- a/tools/firmware/hvmloader/smbios.c +++ b/tools/firmware/hvmloader/smbios.c @@ -497,9 +497,11 @@ static void * smbios_type_2_init(void *start) { struct smbios_type_2 *p = (struct smbios_type_2 *)start; + const char *s; uint8_t *ptr; void *pts; uint32_t length; + uint32_t counter = 0; pts = get_smbios_pt_struct(2, &length); if ( (pts != NULL)&&(length > 0) ) @@ -518,7 +520,67 @@ smbios_type_2_init(void *start) return (start + length); } - /* Only present when passed in */ + s = xenstore_read(HVM_XS_BASEBOARD_MANUFACTURER, NULL); + if ( (s != NULL) && (*s != '\0') ) + { + memset(p, 0, sizeof(*p)); + p->header.type = 2; + p->header.length = sizeof(struct smbios_type_2); + p->header.handle = SMBIOS_HANDLE_TYPE2; + p->feature_flags = 0x09; /* Board is a hosting board and replaceable */ + p->chassis_handle = SMBIOS_HANDLE_TYPE3; + p->board_type = 0x0a; /* Motherboard */ + start += sizeof(struct smbios_type_2); + + strcpy((char *)start, s); + start += strlen(s) + 1; + p->manufacturer_str = ++counter; + + s = xenstore_read(HVM_XS_BASEBOARD_PRODUCT_NAME, NULL); + if ( (s != NULL) && (*s != '\0') ) + { + strcpy((char *)start, s); + start += strlen(s) + 1; + p->product_name_str = ++counter; + } + + s = xenstore_read(HVM_XS_BASEBOARD_VERSION, NULL); + if ( (s != NULL) && (*s != '\0') ) + { + strcpy((char *)start, s); + start += strlen(s) + 1; + p->version_str = ++counter; + } + + s = xenstore_read(HVM_XS_BASEBOARD_SERIAL_NUMBER, NULL); + if ( (s != NULL) && (*s != '\0') ) + { + strcpy((char *)start, s); + start += strlen(s) + 1; + p->serial_number_str = ++counter; + } + + s = xenstore_read(HVM_XS_BASEBOARD_ASSET_TAG, NULL); + if ( (s != NULL) && (*s != '\0') ) + { + strcpy((char *)start, s); + start += strlen(s) + 1; + p->asset_tag_str = ++counter; + } + + s = xenstore_read(HVM_XS_BASEBOARD_LOCATION_IN_CHASSIS, NULL); + if ( (s != NULL) && (*s != '\0') ) + { + strcpy((char *)start, s); + start += strlen(s) + 1; + p->location_in_chassis_str = ++counter; + } + + *((uint8_t *)start) = 0; + return start + 1; + } + + /* Only present when passed in or overriden */ return start; } diff --git a/tools/firmware/hvmloader/smbios_types.h b/tools/firmware/hvmloader/smbios_types.h index acb63e2fe9..834ef38fba 100644 --- a/tools/firmware/hvmloader/smbios_types.h +++ b/tools/firmware/hvmloader/smbios_types.h @@ -90,6 +90,12 @@ 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; } __attribute__ ((packed)); /* System Enclosure - Contained Elements */ diff --git a/xen/include/public/hvm/hvm_xs_strings.h b/xen/include/public/hvm/hvm_xs_strings.h index fea1dd4407..e3b328321d 100644 --- a/xen/include/public/hvm/hvm_xs_strings.h +++ b/xen/include/public/hvm/hvm_xs_strings.h @@ -62,18 +62,24 @@ /* The following xenstore values are used to override some of the default * string values in the SMBIOS table constructed in hvmloader. */ -#define HVM_XS_BIOS_STRINGS "bios-strings" -#define HVM_XS_BIOS_VENDOR "bios-strings/bios-vendor" -#define HVM_XS_BIOS_VERSION "bios-strings/bios-version" -#define HVM_XS_SYSTEM_MANUFACTURER "bios-strings/system-manufacturer" -#define HVM_XS_SYSTEM_PRODUCT_NAME "bios-strings/system-product-name" -#define HVM_XS_SYSTEM_VERSION "bios-strings/system-version" -#define HVM_XS_SYSTEM_SERIAL_NUMBER "bios-strings/system-serial-number" -#define HVM_XS_ENCLOSURE_MANUFACTURER "bios-strings/enclosure-manufacturer" -#define HVM_XS_ENCLOSURE_SERIAL_NUMBER "bios-strings/enclosure-serial-number" -#define HVM_XS_ENCLOSURE_ASSET_TAG "bios-strings/enclosure-asset-tag" -#define HVM_XS_BATTERY_MANUFACTURER "bios-strings/battery-manufacturer" -#define HVM_XS_BATTERY_DEVICE_NAME "bios-strings/battery-device-name" +#define HVM_XS_BIOS_STRINGS "bios-strings" +#define HVM_XS_BIOS_VENDOR "bios-strings/bios-vendor" +#define HVM_XS_BIOS_VERSION "bios-strings/bios-version" +#define HVM_XS_SYSTEM_MANUFACTURER "bios-strings/system-manufacturer" +#define HVM_XS_SYSTEM_PRODUCT_NAME "bios-strings/system-product-name" +#define HVM_XS_SYSTEM_VERSION "bios-strings/system-version" +#define HVM_XS_SYSTEM_SERIAL_NUMBER "bios-strings/system-serial-number" +#define HVM_XS_BASEBOARD_MANUFACTURER "bios-strings/baseboard-manufacturer" +#define HVM_XS_BASEBOARD_PRODUCT_NAME "bios-strings/baseboard-product-name" +#define HVM_XS_BASEBOARD_VERSION "bios-strings/baseboard-version" +#define HVM_XS_BASEBOARD_SERIAL_NUMBER "bios-strings/baseboard-serial-number" +#define HVM_XS_BASEBOARD_ASSET_TAG "bios-strings/baseboard-asset-tag" +#define HVM_XS_BASEBOARD_LOCATION_IN_CHASSIS "bios-strings/baseboard-location-in-chassis" +#define HVM_XS_ENCLOSURE_MANUFACTURER "bios-strings/enclosure-manufacturer" +#define HVM_XS_ENCLOSURE_SERIAL_NUMBER "bios-strings/enclosure-serial-number" +#define HVM_XS_ENCLOSURE_ASSET_TAG "bios-strings/enclosure-asset-tag" +#define HVM_XS_BATTERY_MANUFACTURER "bios-strings/battery-manufacturer" +#define HVM_XS_BATTERY_DEVICE_NAME "bios-strings/battery-device-name" /* 1 to 99 OEM strings can be set in xenstore using values of the form * below. These strings will be loaded into the SMBIOS type 11 structure.