From patchwork Thu Mar 28 13:56:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Li X-Patchwork-Id: 10875055 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 B3269922 for ; Thu, 28 Mar 2019 13:59:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CC5328A1D for ; Thu, 28 Mar 2019 13:59:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9120828DA5; Thu, 28 Mar 2019 13:59:00 +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 7BFA628A1D for ; Thu, 28 Mar 2019 13:58:56 +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 1h9VWl-0002ab-SO; Thu, 28 Mar 2019 13:57:07 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h9VWk-0002Xi-GZ for xen-devel@lists.xen.org; Thu, 28 Mar 2019 13:57:06 +0000 X-Inumbo-ID: 5dffa6aa-5161-11e9-bc90-bc764e045a96 Received: from mail-wm1-x343.google.com (unknown [2a00:1450:4864:20::343]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 5dffa6aa-5161-11e9-bc90-bc764e045a96; Thu, 28 Mar 2019 13:57:05 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id z24so4166341wmi.5 for ; Thu, 28 Mar 2019 06:57:04 -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=S3e3BiEFhEfHf8L+R2K6k4vZwefBOyR9llX3Siq0R10=; b=VAKgYV96r/lCRm0Q0mMCy7AGDkBUqYzD8wofnrg5DjE7cxYBvnt9EPe6rYc2ORLnTm 9L/aQnDbyw1pV6wuz/yB59clsXre55Y89iUhWBlS+oy900QMKJOiOhXNS/yXKEfK97wb fcffDHfuRkvOPhIhJqVppWSyfmKslcfMcxqt7KueUwAoSChqGeF3gtTuwtz6q3RGOC/S ZplD63+NZk8Gd+z5y7qVbl4asXsiytqChFWQdSjIGVHwz61xgjYgNzR9w2mRe4OjgdUu Oqql9UwcqpiaW2esryRXciY9pCHHsdKEdRUa+ZDQXB30AAGhG3YqGcYQhR1tX4QYM+ai NvrQ== 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=S3e3BiEFhEfHf8L+R2K6k4vZwefBOyR9llX3Siq0R10=; b=JLM4B63vo5FI8bXc7eukvnh9MA2c4qX035jA03qK9KS1xmrqNADl2rKQ0wNfK5iPH9 XZQHyEjd/whgG4Xd166SDv6MrfGpDcdDlSK7RvVHwsOAoYu07V9JPmwwZJWstcXj8Ei4 dIhiEslQBjIx9GbruY7Pq6Wga0iUrRuMw7aLFi/vfmc+oohMSYU0y0IOTfdFSwzBvMcP ZNy2M0kpGNjGqxRxAAQWCR1+/JxPkAo1bb1884vQYmQv/ydUuNRIEYNALlmmy0XB5GwY oqNkCcAJFf+u5CtIGbaMGl7XQmcegY+1b741t0uQr30ctk1wFHXp0b6os+DUILxEB4YT s1YQ== X-Gm-Message-State: APjAAAULcGSw3Absz+3PztkW4oeaHlTiWlbidvUL9TEuFaaGI/Sffl0f NN7a7LEwqddwmGzgybC4zMDiI2QjiuI= X-Google-Smtp-Source: APXvYqwgz6Ve5FljFMDXLAz1oQ1lr+5m59sahV3gCkRPkFL9nbW/5EIWrTLD5Hl4cT4ECRHAVobHOw== X-Received: by 2002:a1c:7008:: with SMTP id l8mr69747wmc.63.1553781423528; Thu, 28 Mar 2019 06:57:03 -0700 (PDT) Received: from lcy2-dt16.xenrtcloud ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a11sm2823595wmm.35.2019.03.28.06.57.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Mar 2019 06:57:03 -0700 (PDT) From: Xin Li X-Google-Original-From: Xin Li To: xen-devel@lists.xen.org Date: Thu, 28 Mar 2019 13:56:57 +0000 Message-Id: <20190328135657.4030-1-xin.li@citrix.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 1/1] hvmloader: add SMBIOS type 2 info for customized string 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 , Jan Beulich , 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 write it when customized string provided and no smbios passed in. Signed-off-by: Xin Li Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Igor Druzhinin CC: Sergey Dyasli CC: Andrew Cooper v2 1: write the struct if any of the strings is provided 2: add contained_handles as flexible array member 3: update commit message and fix style issue --- tools/firmware/hvmloader/smbios.c | 69 ++++++++++++++++++++++++- tools/firmware/hvmloader/smbios_types.h | 7 +++ xen/include/public/hvm/hvm_xs_strings.h | 6 +++ 3 files changed, 80 insertions(+), 2 deletions(-) diff --git a/tools/firmware/hvmloader/smbios.c b/tools/firmware/hvmloader/smbios.c index 40d8399be1..7815f1dbd3 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; + unsigned int counter = 0; pts = get_smbios_pt_struct(2, &length); if ( (pts != NULL)&&(length > 0) ) @@ -518,8 +520,71 @@ smbios_type_2_init(void *start) return (start + length); } - /* Only present when passed in */ - return start; + 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(*p); + + s = xenstore_read(HVM_XS_BASEBOARD_MANUFACTURER, NULL); + if ( (s != NULL) && (*s != '\0') ) + { + strcpy(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(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(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(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(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(start, s); + start += strlen(s) + 1; + p->location_in_chassis_str = ++counter; + } + + if ( counter ) + { + *((uint8_t *)start) = 0; + return start + 1; + } + + /* Only present when passed in or with customized string */ + return start - sizeof(*p); } /* Type 3 -- System Enclosure */ diff --git a/tools/firmware/hvmloader/smbios_types.h b/tools/firmware/hvmloader/smbios_types.h index acb63e2fe9..7c648ece71 100644 --- a/tools/firmware/hvmloader/smbios_types.h +++ b/tools/firmware/hvmloader/smbios_types.h @@ -90,6 +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[]; } __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..fba2546424 100644 --- a/xen/include/public/hvm/hvm_xs_strings.h +++ b/xen/include/public/hvm/hvm_xs_strings.h @@ -69,6 +69,12 @@ #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"