{"id":814725,"url":"http://patchwork.ozlabs.org/api/patches/814725/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20170917225927.117917-8-sjg@chromium.org/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170917225927.117917-8-sjg@chromium.org>","list_archive_url":null,"date":"2017-09-17T22:59:18","name":"[U-Boot,07/16] sandbox: smbios: Update to support sandbox","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"adb14dec0e31286a7121cdc3799a846ba967d901","submitter":{"id":6170,"url":"http://patchwork.ozlabs.org/api/people/6170/?format=json","name":"Simon Glass","email":"sjg@chromium.org"},"delegate":{"id":3400,"url":"http://patchwork.ozlabs.org/api/users/3400/?format=json","username":"agraf","first_name":"Alexander","last_name":"Graf","email":"agraf@suse.de"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20170917225927.117917-8-sjg@chromium.org/mbox/","series":[{"id":3549,"url":"http://patchwork.ozlabs.org/api/series/3549/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=3549","date":"2017-09-17T22:59:11","name":"efi: Enable basic sandbox support for EFI loader","version":1,"mbox":"http://patchwork.ozlabs.org/series/3549/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/814725/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/814725/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=google.com header.i=@google.com\n\theader.b=\"GJOW8yN+\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xwR8y2xv8z9s78\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 18 Sep 2017 10:05:22 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 2D99EC21D65; Mon, 18 Sep 2017 00:05:21 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 1FDE8C21E9C;\n\tSun, 17 Sep 2017 23:02:05 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid CDF81C21EE3; Sun, 17 Sep 2017 23:02:03 +0000 (UTC)","from mail-io0-f174.google.com (mail-io0-f174.google.com\n\t[209.85.223.174])\n\tby lists.denx.de (Postfix) with ESMTPS id CDE84C21E9C\n\tfor <u-boot@lists.denx.de>; Sun, 17 Sep 2017 22:59:38 +0000 (UTC)","by mail-io0-f174.google.com with SMTP id n69so14876380ioi.5\n\tfor <u-boot@lists.denx.de>; Sun, 17 Sep 2017 15:59:38 -0700 (PDT)","from kiwi.bld.corp.google.com ([100.101.164.89])\n\tby smtp.gmail.com with ESMTPSA id\n\td95sm2300983oic.3.2017.09.17.15.59.35\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tSun, 17 Sep 2017 15:59:36 -0700 (PDT)","by kiwi.bld.corp.google.com (Postfix, from userid 121222)\n\tid 699901417F3; Sun, 17 Sep 2017 16:59:35 -0600 (MDT)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,\n\tRCVD_IN_MSPIKE_H2,\n\tT_DKIM_INVALID autolearn=unavailable autolearn_force=no\n\tversion=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=20161025; \n\th=sender:from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=84dsfU+OPIe5e4xW1u7YqZOWytfrDH/4OHv32ljfaZQ=;\n\tb=GJOW8yN+iwH5uVCYBJU5Mw7oLwnmI35ISdnh4t97xMgztWDjyqETPHjNcV4sdF2I8t\n\thPVZZ1lgQR0MogSzwkCP5fcpcOoGhlrq9+ueZT699Dyg+hD2+6NO37ITCjo/8+e4H3XE\n\tshaNpW7Dw5drwK1iJMoPdRK6kjxRbtWLhQMkPrRO016c2bAYdr45TgUNGd3jUPrXVJ3x\n\t7s2cQtY9o6FckfEbyn/06mwfIJVv5Uyxx9UYSTQeP33MFCsDzcPWwdOpoG4dLTRcNLBN\n\t5TXXhrwQtQvNJblzxZrFaMleR7Fkm626aS86+e18donWVKO32F+D8ZQ9rXXKC++9+cNy\n\tjR2g==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:sender:from:to:cc:subject:date:message-id\n\t:in-reply-to:references;\n\tbh=84dsfU+OPIe5e4xW1u7YqZOWytfrDH/4OHv32ljfaZQ=;\n\tb=f32uL2CkeZEIQ7vk8JJCx0AT5iHPyp0UJzrMSHFeaELuav7XSdnaxGOcqG4rXG7+6v\n\tLtBkGke6h6f2mWjcVZIZQErAh9CDBLiGaSw0phgKrigG87lvuB6ZtNwJ76ZlRzAOhQoY\n\teQ9vSJgg7+DuzSNDzoFNk0rKyWmgcOlzPNqjrHP3tNXox2w8gFxtsAizWVDJYwethfIC\n\tOr3QlzVwDj+EZxVd0ziv8cNVBEp0N8EBiXbUY+zl+FSwqNlbrUPc4JODuIu/KqTB5Y9b\n\tHmF9mFUAzLe0sGZFROBAk8vbDMjmEY2bEYYUoSXy0rTTLK/R/Ic4UKNc1GSQfwEYaPZB\n\tlQWA==","X-Gm-Message-State":"AHPjjUiLd3bN8aSjJWsBR4vE4txvd1O7ckzZQn+iLtf/dXgLdGtkBbt+\n\tk0qg8F0nJb2mdurd","X-Google-Smtp-Source":"AOwi7QDyOWiYm3uiiZrl0yIqJoKblQ/k/Sbex+YOG8ekeKhirARM5e7t3gRgAsyxizS9mBXWOs4Qmw==","X-Received":"by 10.202.172.11 with SMTP id v11mr7213407oie.145.1505689177417; \n\tSun, 17 Sep 2017 15:59:37 -0700 (PDT)","From":"Simon Glass <sjg@chromium.org>","To":"U-Boot Mailing List <u-boot@lists.denx.de>","Date":"Sun, 17 Sep 2017 16:59:18 -0600","Message-Id":"<20170917225927.117917-8-sjg@chromium.org>","X-Mailer":"git-send-email 2.14.1.690.gbb1197296e-goog","In-Reply-To":"<20170917225927.117917-1-sjg@chromium.org>","References":"<20170917225927.117917-1-sjg@chromium.org>","Cc":"Andy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tHeinrich Schuchardt <xypron.glpk@gmx.de>","Subject":"[U-Boot] [PATCH 07/16] sandbox: smbios: Update to support sandbox","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"At present this code casts addresses to pointers so cannot be used with\nsandbox. Update it to use mapmem instead.\n\nSigned-off-by: Simon Glass <sjg@chromium.org>\n---\n\n lib/smbios.c | 38 +++++++++++++++++++++++++++++---------\n 1 file changed, 29 insertions(+), 9 deletions(-)","diff":"diff --git a/lib/smbios.c b/lib/smbios.c\nindex 8f19ad89c1..56481d448d 100644\n--- a/lib/smbios.c\n+++ b/lib/smbios.c\n@@ -7,6 +7,7 @@\n  */\n \n #include <common.h>\n+#include <mapmem.h>\n #include <smbios.h>\n #include <tables_csum.h>\n #include <version.h>\n@@ -75,9 +76,10 @@ static int smbios_string_table_len(char *start)\n \n static int smbios_write_type0(ulong *current, int handle)\n {\n-\tstruct smbios_type0 *t = (struct smbios_type0 *)*current;\n+\tstruct smbios_type0 *t;\n \tint len = sizeof(struct smbios_type0);\n \n+\tt = map_sysmem(*current, len);\n \tmemset(t, 0, sizeof(struct smbios_type0));\n \tfill_smbios_header(t, SMBIOS_BIOS_INFORMATION, len, handle);\n \tt->vendor = smbios_add_string(t->eos, \"U-Boot\");\n@@ -104,16 +106,18 @@ static int smbios_write_type0(ulong *current, int handle)\n \n \tlen = t->length + smbios_string_table_len(t->eos);\n \t*current += len;\n+\tunmap_sysmem(t);\n \n \treturn len;\n }\n \n static int smbios_write_type1(ulong *current, int handle)\n {\n-\tstruct smbios_type1 *t = (struct smbios_type1 *)*current;\n+\tstruct smbios_type1 *t;\n \tint len = sizeof(struct smbios_type1);\n \tchar *serial_str = env_get(\"serial#\");\n \n+\tt = map_sysmem(*current, len);\n \tmemset(t, 0, sizeof(struct smbios_type1));\n \tfill_smbios_header(t, SMBIOS_SYSTEM_INFORMATION, len, handle);\n \tt->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER);\n@@ -125,15 +129,17 @@ static int smbios_write_type1(ulong *current, int handle)\n \n \tlen = t->length + smbios_string_table_len(t->eos);\n \t*current += len;\n+\tunmap_sysmem(t);\n \n \treturn len;\n }\n \n static int smbios_write_type2(ulong *current, int handle)\n {\n-\tstruct smbios_type2 *t = (struct smbios_type2 *)*current;\n+\tstruct smbios_type2 *t;\n \tint len = sizeof(struct smbios_type2);\n \n+\tt = map_sysmem(*current, len);\n \tmemset(t, 0, sizeof(struct smbios_type2));\n \tfill_smbios_header(t, SMBIOS_BOARD_INFORMATION, len, handle);\n \tt->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER);\n@@ -143,15 +149,17 @@ static int smbios_write_type2(ulong *current, int handle)\n \n \tlen = t->length + smbios_string_table_len(t->eos);\n \t*current += len;\n+\tunmap_sysmem(t);\n \n \treturn len;\n }\n \n static int smbios_write_type3(ulong *current, int handle)\n {\n-\tstruct smbios_type3 *t = (struct smbios_type3 *)*current;\n+\tstruct smbios_type3 *t;\n \tint len = sizeof(struct smbios_type3);\n \n+\tt = map_sysmem(*current, len);\n \tmemset(t, 0, sizeof(struct smbios_type3));\n \tfill_smbios_header(t, SMBIOS_SYSTEM_ENCLOSURE, len, handle);\n \tt->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER);\n@@ -163,6 +171,7 @@ static int smbios_write_type3(ulong *current, int handle)\n \n \tlen = t->length + smbios_string_table_len(t->eos);\n \t*current += len;\n+\tunmap_sysmem(t);\n \n \treturn len;\n }\n@@ -201,9 +210,10 @@ static void smbios_write_type4_dm(struct smbios_type4 *t)\n \n static int smbios_write_type4(ulong *current, int handle)\n {\n-\tstruct smbios_type4 *t = (struct smbios_type4 *)*current;\n+\tstruct smbios_type4 *t;\n \tint len = sizeof(struct smbios_type4);\n \n+\tt = map_sysmem(*current, len);\n \tmemset(t, 0, sizeof(struct smbios_type4));\n \tfill_smbios_header(t, SMBIOS_PROCESSOR_INFORMATION, len, handle);\n \tt->processor_type = SMBIOS_PROCESSOR_TYPE_CENTRAL;\n@@ -217,32 +227,37 @@ static int smbios_write_type4(ulong *current, int handle)\n \n \tlen = t->length + smbios_string_table_len(t->eos);\n \t*current += len;\n+\tunmap_sysmem(t);\n \n \treturn len;\n }\n \n static int smbios_write_type32(ulong *current, int handle)\n {\n-\tstruct smbios_type32 *t = (struct smbios_type32 *)*current;\n+\tstruct smbios_type32 *t;\n \tint len = sizeof(struct smbios_type32);\n \n+\tt = map_sysmem(*current, len);\n \tmemset(t, 0, sizeof(struct smbios_type32));\n \tfill_smbios_header(t, SMBIOS_SYSTEM_BOOT_INFORMATION, len, handle);\n \n \t*current += len;\n+\tunmap_sysmem(t);\n \n \treturn len;\n }\n \n static int smbios_write_type127(ulong *current, int handle)\n {\n-\tstruct smbios_type127 *t = (struct smbios_type127 *)*current;\n+\tstruct smbios_type127 *t;\n \tint len = sizeof(struct smbios_type127);\n \n+\tt = map_sysmem(*current, len);\n \tmemset(t, 0, sizeof(struct smbios_type127));\n \tfill_smbios_header(t, SMBIOS_END_OF_TABLE, len, handle);\n \n \t*current += len;\n+\tunmap_sysmem(t);\n \n \treturn len;\n }\n@@ -271,7 +286,7 @@ ulong write_smbios_table(ulong addr)\n \t/* 16 byte align the table address */\n \taddr = ALIGN(addr, 16);\n \n-\tse = (struct smbios_entry *)(uintptr_t)addr;\n+\tse = map_sysmem(addr, sizeof(struct smbios_entry));\n \tmemset(se, 0, sizeof(struct smbios_entry));\n \n \taddr += sizeof(struct smbios_entry);\n@@ -280,9 +295,13 @@ ulong write_smbios_table(ulong addr)\n \n \t/* populate minimum required tables */\n \tfor (i = 0; i < ARRAY_SIZE(smbios_write_funcs); i++) {\n-\t\tint tmp = smbios_write_funcs[i]((ulong *)&addr, handle++);\n+\t\tulong *ptr = map_sysmem(addr, 0);\n+\t\tint tmp;\n+\n+\t\ttmp = smbios_write_funcs[i](ptr, handle++);\n \t\tmax_struct_size = max(max_struct_size, tmp);\n \t\tlen += tmp;\n+\t\tunmap_sysmem(ptr);\n \t}\n \n \tmemcpy(se->anchor, \"_SM_\", 4);\n@@ -300,6 +319,7 @@ ulong write_smbios_table(ulong addr)\n \tisize = sizeof(struct smbios_entry) - SMBIOS_INTERMEDIATE_OFFSET;\n \tse->intermediate_checksum = table_compute_checksum(istart, isize);\n \tse->checksum = table_compute_checksum(se, sizeof(struct smbios_entry));\n+\tunmap_sysmem(se);\n \n \treturn addr;\n }\n","prefixes":["U-Boot","07/16"]}