From patchwork Tue Jan 23 18:42:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 13527990 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 46E60C48260 for ; Tue, 23 Jan 2024 18:44:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rSLkR-0004rJ-Ud; Tue, 23 Jan 2024 13:43:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rSLk7-0004ih-QC for qemu-devel@nongnu.org; Tue, 23 Jan 2024 13:43:30 -0500 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rSLk6-0002oM-0b for qemu-devel@nongnu.org; Tue, 23 Jan 2024 13:43:27 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 64A1D40336 for ; Tue, 23 Jan 2024 18:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1706035396; bh=2lZi8/g8Zu9Qh6cePCjSVFHsW4sIk9nk2jSdvhZS48Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LSAfxdVLYKDXmRPnriHHuNXW0mXlvJQei5EyNDC1R+JVyrigzxkKqF9ZqHh0fBS/+ Ra6kGB7IALAoHW8s6WdESWEyp5E/MCVFQzFuNIP7AFpT3NjWz0z0IarbGkjEXiTA3D X3sH5/yNc/TjMNUZQULFD7y/DClerl+PaIdpWhV5zsl36TGAzpIlZ235m/sl553vHE DwB0IQdtjs7HpVzvOeT5UWxJAEdLMlkI33hYo54+qWVbJxSCYBqvPraIU+xEZ03Gom dkD93uEwDbxTBCnJFq6mx1LMOg9MSSbbEPc+khv/HYS5ozur8c18YLshjOVqMeqedW ydLPieNPGOXHQ== Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-40e40126031so46149525e9.0 for ; Tue, 23 Jan 2024 10:43:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706035391; x=1706640191; 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=2lZi8/g8Zu9Qh6cePCjSVFHsW4sIk9nk2jSdvhZS48Q=; b=I0VJrFfoikeQ3eKzTS1AAckIoM8AxJpuCRxjewjrhhOjmSTbufkXvQe1FKMztQQfzB NUuOWzFoPXdvlMaAHXCAWq0lLV0hwyuIMgmsgwmw4cYwL/u09I+Z70Wam+wRCgA2RPuV x9Txn4YGPLg8fhrhOnBmU7eA5E1iUbHcZN+PJVWcJS749vsjcEER/seEGsdVWZD9oM0q uHFehLf84BjFbAI+dw2zL2w6XdKWuul+ErBoeHGBTGFnoA9DHYJoOnXyycyWif1IvjrE zidV1Sb0Oq6X4hfUC0niaz2AP6Sin19XGSPIT0gzVna5xkalSZJeEmE3+pdhN8B+dYea w9Ig== X-Gm-Message-State: AOJu0YyxI3Rj6ZLow7PMaeC9q5C3DxpweNQ76UlFpBmKI99bedQl04D6 SwIbR2/bZaen7FgzZooNLb7xtIVv33ulaWaMf5Sm6/jQfYQp01emJqU4UkhwV8IgE87gZIOgqQ1 s79jwpwVIPc85Mtk9qaQX6Ae0CSVPjBBpX//qN/OV4eN5qpkXt+bVckMH5SlYRvbZdNSc X-Received: by 2002:adf:fdc7:0:b0:337:bd80:c104 with SMTP id i7-20020adffdc7000000b00337bd80c104mr3625207wrs.71.1706035391767; Tue, 23 Jan 2024 10:43:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IEk7rHpt3qwLbhbcrrQTiM1uunl2M1RzFx6Ly++PyLBcpoSS/G3+IGvdkBFAOdy6DKE48kfoQ== X-Received: by 2002:adf:fdc7:0:b0:337:bd80:c104 with SMTP id i7-20020adffdc7000000b00337bd80c104mr3625193wrs.71.1706035391543; Tue, 23 Jan 2024 10:43:11 -0800 (PST) Received: from workstation5.fritz.box (ip-178-202-040-247.um47.pools.vodafone-ip.de. [178.202.40.247]) by smtp.gmail.com with ESMTPSA id u9-20020a5d6ac9000000b00337d392c6c3sm14180252wrw.13.2024.01.23.10.43.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 10:43:11 -0800 (PST) From: Heinrich Schuchardt To: Palmer Dabbelt , Alistair Francis Cc: Andrew Jones , Paolo Bonzini , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Heinrich Schuchardt Subject: [PATCH v4 1/4] smbios: add processor-family option Date: Tue, 23 Jan 2024 19:42:26 +0100 Message-ID: <20240123184229.10415-2-heinrich.schuchardt@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123184229.10415-1-heinrich.schuchardt@canonical.com> References: <20240123184229.10415-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=185.125.188.122; envelope-from=heinrich.schuchardt@canonical.com; helo=smtp-relay-internal-0.canonical.com X-Spam_score_int: -56 X-Spam_score: -5.7 X-Spam_bar: ----- X-Spam_report: (-5.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.327, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org For RISC-V the SMBIOS standard requires specific values of the processor family value depending on the bitness of the CPU. Add a processor-family option for SMBIOS table 4. The value of processor-family may exceed 255 and therefore must be provided in the Processor Family 2 field. Set the Processor Family field to 0xFE which signals that the Processor Family 2 is used. Signed-off-by: Heinrich Schuchardt Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- v4: no change v3: no change v2: new patch --- hw/smbios/smbios.c | 13 +++++++++++-- qemu-options.hx | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 2a90601ac5..647bc6d603 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -102,6 +102,7 @@ static struct { #define DEFAULT_CPU_SPEED 2000 static struct { + uint16_t processor_family; const char *sock_pfx, *manufacturer, *version, *serial, *asset, *part; uint64_t max_speed; uint64_t current_speed; @@ -110,6 +111,7 @@ static struct { .max_speed = DEFAULT_CPU_SPEED, .current_speed = DEFAULT_CPU_SPEED, .processor_id = 0, + .processor_family = 0x01, /* Other */ }; struct type8_instance { @@ -337,6 +339,10 @@ static const QemuOptDesc qemu_smbios_type4_opts[] = { .name = "part", .type = QEMU_OPT_STRING, .help = "part number", + }, { + .name = "processor-family", + .type = QEMU_OPT_NUMBER, + .help = "processor family", }, { .name = "processor-id", .type = QEMU_OPT_NUMBER, @@ -726,7 +732,7 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance) snprintf(sock_str, sizeof(sock_str), "%s%2x", type4.sock_pfx, instance); SMBIOS_TABLE_SET_STR(4, socket_designation_str, sock_str); t->processor_type = 0x03; /* CPU */ - t->processor_family = 0x01; /* Other */ + t->processor_family = 0xfe; /* use Processor Family 2 field */ SMBIOS_TABLE_SET_STR(4, processor_manufacturer_str, type4.manufacturer); if (type4.processor_id == 0) { t->processor_id[0] = cpu_to_le32(smbios_cpuid_version); @@ -758,7 +764,7 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance) t->thread_count = (threads_per_socket > 255) ? 0xFF : threads_per_socket; t->processor_characteristics = cpu_to_le16(0x02); /* Unknown */ - t->processor_family2 = cpu_to_le16(0x01); /* Other */ + t->processor_family2 = cpu_to_le16(type4.processor_family); if (tbl_len == SMBIOS_TYPE_4_LEN_V30) { t->core_count2 = t->core_enabled2 = cpu_to_le16(cores_per_socket); @@ -1402,6 +1408,9 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) return; } save_opt(&type4.sock_pfx, opts, "sock_pfx"); + type4.processor_family = qemu_opt_get_number(opts, + "processor-family", + 0x01 /* Other */); save_opt(&type4.manufacturer, opts, "manufacturer"); save_opt(&type4.version, opts, "version"); save_opt(&type4.serial, opts, "serial"); diff --git a/qemu-options.hx b/qemu-options.hx index ced8284863..d90bdffc7a 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2686,7 +2686,7 @@ DEF("smbios", HAS_ARG, QEMU_OPTION_smbios, " specify SMBIOS type 3 fields\n" "-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str]\n" " [,asset=str][,part=str][,max-speed=%d][,current-speed=%d]\n" - " [,processor-id=%d]\n" + " [,processor-family=%d,processor-id=%d]\n" " specify SMBIOS type 4 fields\n" "-smbios type=8[,external_reference=str][,internal_reference=str][,connector_type=%d][,port_type=%d]\n" " specify SMBIOS type 8 fields\n" @@ -2714,7 +2714,7 @@ SRST ``-smbios type=3[,manufacturer=str][,version=str][,serial=str][,asset=str][,sku=str]`` Specify SMBIOS type 3 fields -``-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str][,asset=str][,part=str][,processor-id=%d]`` +``-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str][,asset=str][,part=str][,processor-family=%d][,processor-id=%d]`` Specify SMBIOS type 4 fields ``-smbios type=11[,value=str][,path=filename]`` From patchwork Tue Jan 23 18:42:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 13527991 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CE805C47258 for ; Tue, 23 Jan 2024 18:44:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rSLkS-0004rh-QF; Tue, 23 Jan 2024 13:43:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rSLkA-0004jF-Kb for qemu-devel@nongnu.org; Tue, 23 Jan 2024 13:43:34 -0500 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rSLk6-0002oW-Jx for qemu-devel@nongnu.org; Tue, 23 Jan 2024 13:43:28 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 918E440342 for ; Tue, 23 Jan 2024 18:43:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1706035399; bh=wxjzye6ArgMxmoVHqUrJaFh02KD7JKVgYqu3hfX0S3g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jrfhVpJ/URccex16MDtXw5mQyd/aGQP0R6rtx6Bw2dmJ3+juUH/gaZ1GOlgHUYBle I3BdcCT3X8NCS1X2R/3jTrtbHqGrplxF715juktd5jwBYnz1xURAEtVskthXpE9Hzq vXL9iNkH/b738P24Z2lZaojDmWzKSmnQ0ljl+puKb/cQR5b/yL/co0pTDvddXGlmtP Zc6Ee6L041cRWIb3cyJzP6z9hYkX8jWGEuDc8MKO4P00CUYckO18iCV5cx+7Q/pblq RbKls3nEXjKdDuYfA8ZSHb0nF3n1PWbeaDFWicB9PPnX4A6RHBwJ8SzUopqNhwEvd7 XvC+grUXzHUQg== Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-337bf78ef28so1965456f8f.3 for ; Tue, 23 Jan 2024 10:43:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706035393; x=1706640193; 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=wxjzye6ArgMxmoVHqUrJaFh02KD7JKVgYqu3hfX0S3g=; b=L5UvNDekakhr/DTC4blTlG61ndV8IS4Lym0XkyFc56ZMnVbR5jAPvTKQJ66SLYPwhZ Amk/LVfYzL0XK8qJxCCH6RY3SbUKxy4bt/URyyWZdGsADW4CbJ7RFj7lsmhlvLo20XJj ZgdKeyPFcbEqEKL+QvXq0KMOEaWsF3wRpDcrm3YrP92RvfNF1GnS6/9uffgAcGTCNfQ9 5zO0mb7OXE903Bg+sKXHJyExnk7DBR/MFqmjYC0q8VLOf4v1ifkJbYAypZk50Q9QhD4e pqo7yvfTRJ5aTlXCsGHVI1U70u//fq0mZJQr+gCVuDfOn3QdXOee/FTdwE0YPcfn/kCW xFAA== X-Gm-Message-State: AOJu0Yyey1qnJQBc6jhgXUkM4U0Oen0/OxoNQzByNdLTo5lYFGOXa7/Z G5XYrs12VbHP7Lgpvi0vvrA3TTWSS9R0iKqxczQteBUtNEiMwOkMiYCD1hFgagNFuaa4yPHRWV+ TL8Xkkv095g2y/0lrGAFOLBsOQ06/d3w0UxwhEB/Yw0WVkzrJ2sBA2Ycl70F0cz3q4AZ2 X-Received: by 2002:a05:6000:1f8b:b0:336:8b43:acac with SMTP id bw11-20020a0560001f8b00b003368b43acacmr3550514wrb.13.1706035392772; Tue, 23 Jan 2024 10:43:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IEVkMEoT3CoARuuvLZvj7i4pj60uiyJpsHob7hO0S6XTcGGzaqwL/W8ylqJOXfi3ZW9ne8TkA== X-Received: by 2002:a05:6000:1f8b:b0:336:8b43:acac with SMTP id bw11-20020a0560001f8b00b003368b43acacmr3550505wrb.13.1706035392419; Tue, 23 Jan 2024 10:43:12 -0800 (PST) Received: from workstation5.fritz.box (ip-178-202-040-247.um47.pools.vodafone-ip.de. [178.202.40.247]) by smtp.gmail.com with ESMTPSA id u9-20020a5d6ac9000000b00337d392c6c3sm14180252wrw.13.2024.01.23.10.43.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 10:43:12 -0800 (PST) From: Heinrich Schuchardt To: Palmer Dabbelt , Alistair Francis Cc: Andrew Jones , Paolo Bonzini , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Heinrich Schuchardt Subject: [PATCH v4 2/4] smbios: function to set default processor family Date: Tue, 23 Jan 2024 19:42:27 +0100 Message-ID: <20240123184229.10415-3-heinrich.schuchardt@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123184229.10415-1-heinrich.schuchardt@canonical.com> References: <20240123184229.10415-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=185.125.188.122; envelope-from=heinrich.schuchardt@canonical.com; helo=smtp-relay-internal-0.canonical.com X-Spam_score_int: -56 X-Spam_score: -5.7 X-Spam_bar: ----- X-Spam_report: (-5.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.327, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Provide a function to set the default processor family. Signed-off-by: Heinrich Schuchardt Reviewed-by: Andrew Jones --- v4: no change v3: no change v2: new patch --- hw/smbios/smbios.c | 7 +++++++ include/hw/firmware/smbios.h | 1 + 2 files changed, 8 insertions(+) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 647bc6d603..c0c5a81e66 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -989,6 +989,13 @@ void smbios_set_cpuid(uint32_t version, uint32_t features) field = value; \ } +void smbios_set_default_processor_family(uint16_t processor_family) +{ + if (type4.processor_family <= 0x01) { + type4.processor_family = processor_family; + } +} + void smbios_set_defaults(const char *manufacturer, const char *product, const char *version, bool legacy_mode, bool uuid_encoded, SmbiosEntryPointType ep_type) diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h index 7f3259a630..6e514982d4 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -295,6 +295,7 @@ void smbios_set_cpuid(uint32_t version, uint32_t features); void smbios_set_defaults(const char *manufacturer, const char *product, const char *version, bool legacy_mode, bool uuid_encoded, SmbiosEntryPointType ep_type); +void smbios_set_default_processor_family(uint16_t processor_family); uint8_t *smbios_get_table_legacy(MachineState *ms, size_t *length); void smbios_get_tables(MachineState *ms, const struct smbios_phys_mem_area *mem_array, From patchwork Tue Jan 23 18:42:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 13527992 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 47650C47DDB for ; Tue, 23 Jan 2024 18:44:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rSLkV-0004tp-05; Tue, 23 Jan 2024 13:43:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rSLkJ-0004lg-Ej for qemu-devel@nongnu.org; Tue, 23 Jan 2024 13:43:42 -0500 Received: from smtp-relay-internal-1.canonical.com ([185.125.188.123]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rSLkH-0002pA-8n for qemu-devel@nongnu.org; Tue, 23 Jan 2024 13:43:39 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id F108C40A04 for ; Tue, 23 Jan 2024 18:43:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1706035399; bh=iGr0FnTYaT+qArrCpsR1nJW5AEkfoz2acQmeTnnwl5I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WIIYqj4ptsSdCYilcm1hp9CLZx0wgx8/S7mZeX/NdGZep0C8MRniWLS2nGHbUfoM8 64a3gVma3lcK6DgsrAxciMo0eai7eKk60j0JJF7E6OURlz3z2Jdw3aBX90gKraGmDW 3nQQnv6PO+EZgg0n2heeP92rLRo/jd4F+O+f9AszaDl8HfHSwQ5hW2cfA0acwZKRKb JtC4GkMlkOrs/YIENK0iAcm/9EAEPaE9Xhd6AM9aNGZtJkYFpNUt+msRmqL79Irr18 I7fi/vPysixdNJj3JHHvDcnpDVoclV7HNQBAOCj7jrzVQtACwFBFXXtiKAszI6Hxmc nO1NH5QuSiz+Q== Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-339214f9199so2544409f8f.3 for ; Tue, 23 Jan 2024 10:43:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706035393; x=1706640193; 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=iGr0FnTYaT+qArrCpsR1nJW5AEkfoz2acQmeTnnwl5I=; b=VpDWsG6hyimISun+UO0Q5fCTge0iDFn7cXjEKxlaEWO2GygOAHxzMDcmDsFgPFp5Zg EJKdhIGusZ/1TvpOOG09UCZS+vBYzgUHbnyijVQXfhgaVs+7hQf2M4Pnt3pVhYHyIEvD QrKDF2+muSVupQmPbrcAqyxapmZd09g+6wmNizcYBRy6Kv1N914TF6y+1g3L306IPZkO iXZbircMdQDUwU3YI14RxZ0UET5/pZZo+EbSR2gne00bU5eZ6S+c4jBDwdP/3dofskGW mwGs0dkvVqxhqT/hH3BI9J4LRYM4w9G55YQp3iqOA/fu1gmE03+aJGociZxMznW2I9pQ AXCA== X-Gm-Message-State: AOJu0Yx3nQpCyiJXzCzq/Mu/ELOhu9WNHU+r+f6zra1y+wpNdmB91trp wb0D4sSHWnCjoJ5OrM04r964hjSGeUxehT3PlseUj3AUYLA+VrOrecmN6/mPH8lqAW10sJRenjA RhASLS2l39+B41FwI3Rf86XDymyrMqIDd+UueOXmHaL3Kavdneb5KOjJzJJx5KmFysk2V X-Received: by 2002:adf:f243:0:b0:337:cdc5:daf4 with SMTP id b3-20020adff243000000b00337cdc5daf4mr3549855wrp.9.1706035393570; Tue, 23 Jan 2024 10:43:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IHhLhrfATAl+MbUI9CG7wf9yl5VnYt7D1KtWSc4Uw3hcCY/iekiY5zgW3rbp/1ejbrfypYWjg== X-Received: by 2002:adf:f243:0:b0:337:cdc5:daf4 with SMTP id b3-20020adff243000000b00337cdc5daf4mr3549842wrp.9.1706035393317; Tue, 23 Jan 2024 10:43:13 -0800 (PST) Received: from workstation5.fritz.box (ip-178-202-040-247.um47.pools.vodafone-ip.de. [178.202.40.247]) by smtp.gmail.com with ESMTPSA id u9-20020a5d6ac9000000b00337d392c6c3sm14180252wrw.13.2024.01.23.10.43.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 10:43:12 -0800 (PST) From: Heinrich Schuchardt To: Palmer Dabbelt , Alistair Francis Cc: Andrew Jones , Paolo Bonzini , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Heinrich Schuchardt Subject: [PATCH v4 3/4] target/riscv: SMBIOS support for RISC-V virt machine Date: Tue, 23 Jan 2024 19:42:28 +0100 Message-ID: <20240123184229.10415-4-heinrich.schuchardt@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123184229.10415-1-heinrich.schuchardt@canonical.com> References: <20240123184229.10415-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=185.125.188.123; envelope-from=heinrich.schuchardt@canonical.com; helo=smtp-relay-internal-1.canonical.com X-Spam_score_int: -56 X-Spam_score: -5.7 X-Spam_bar: ----- X-Spam_report: (-5.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.327, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Generate SMBIOS tables for the RISC-V mach-virt. Add CONFIG_SMBIOS=y to the RISC-V default config. Set the default processor family in the type 4 table. The implementation is based on the corresponding ARM and Loongson code. With the patch the following firmware tables are provided: etc/smbios/smbios-anchor etc/smbios/smbios-tables Signed-off-by: Heinrich Schuchardt Reviewed-by: Andrew Jones --- v4: remove a superfluous #ifdef v3: use misa_mxl_max to determine bitness v2: set processor family --- hw/riscv/Kconfig | 1 + hw/riscv/virt.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig index a50717be87..5d644eb7b1 100644 --- a/hw/riscv/Kconfig +++ b/hw/riscv/Kconfig @@ -41,6 +41,7 @@ config RISCV_VIRT select RISCV_IMSIC select SIFIVE_PLIC select SIFIVE_TEST + select SMBIOS select VIRTIO_MMIO select FW_CFG_DMA select PLATFORM_BUS diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index f9fd1341fc..1b333af4f0 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -36,6 +36,7 @@ #include "hw/riscv/boot.h" #include "hw/riscv/numa.h" #include "kvm/kvm_riscv.h" +#include "hw/firmware/smbios.h" #include "hw/intc/riscv_aclint.h" #include "hw/intc/riscv_aplic.h" #include "hw/intc/sifive_plic.h" @@ -1263,6 +1264,45 @@ static void create_platform_bus(RISCVVirtState *s, DeviceState *irqchip) sysbus_mmio_get_region(sysbus, 0)); } +static void virt_build_smbios(RISCVVirtState *s) +{ + MachineClass *mc = MACHINE_GET_CLASS(s); + MachineState *ms = MACHINE(s); + uint8_t *smbios_tables, *smbios_anchor; + size_t smbios_tables_len, smbios_anchor_len; + struct smbios_phys_mem_area mem_array; + const char *product = "QEMU Virtual Machine"; + + if (kvm_enabled()) { + product = "KVM Virtual Machine"; + } + + smbios_set_defaults("QEMU", product, mc->name, false, + true, SMBIOS_ENTRY_POINT_TYPE_64); + + if (riscv_is_32bit(&s->soc[0])) { + smbios_set_default_processor_family(0x200); + } else { + smbios_set_default_processor_family(0x201); + } + + /* build the array of physical mem area from base_memmap */ + mem_array.address = s->memmap[VIRT_DRAM].base; + mem_array.length = ms->ram_size; + + smbios_get_tables(ms, &mem_array, 1, + &smbios_tables, &smbios_tables_len, + &smbios_anchor, &smbios_anchor_len, + &error_fatal); + + if (smbios_anchor) { + fw_cfg_add_file(s->fw_cfg, "etc/smbios/smbios-tables", + smbios_tables, smbios_tables_len); + fw_cfg_add_file(s->fw_cfg, "etc/smbios/smbios-anchor", + smbios_anchor, smbios_anchor_len); + } +} + static void virt_machine_done(Notifier *notifier, void *data) { RISCVVirtState *s = container_of(notifier, RISCVVirtState, @@ -1351,6 +1393,8 @@ static void virt_machine_done(Notifier *notifier, void *data) riscv_setup_direct_kernel(kernel_entry, fdt_load_addr); } + virt_build_smbios(s); + if (virt_is_acpi_enabled(s)) { virt_acpi_setup(s); } From patchwork Tue Jan 23 18:42:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 13527989 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3434EC47DDB for ; Tue, 23 Jan 2024 18:44:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rSLkS-0004rg-Q7; Tue, 23 Jan 2024 13:43:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rSLkA-0004jH-Kn for qemu-devel@nongnu.org; Tue, 23 Jan 2024 13:43:34 -0500 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rSLk6-0002oX-JD for qemu-devel@nongnu.org; Tue, 23 Jan 2024 13:43:28 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 1F3224032F for ; Tue, 23 Jan 2024 18:43:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1706035402; bh=cpcO92XOl2zNt9sq2MJVJ7XaxnnPhG6+lYWq+HSy79Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VNH+ihOZtior15lJDTXQOwfIbhjbhh1EZmXALZAqmuKgDTlPixlCUKjTyS1XHmuYb PDV6vsUZVnzI0qVXORxaS79TpYBD74EjQxih5BHNrNjuMCJ1S9nkcLMGHN+GFbMRVb tCGLgoqhWMGSF2yeJkyZLTLlleY4oO5X/VGp+zwMxgEtJKbctUdY9gawzdEiClVkOQ WW18iWs/n81547Fcs2mso5XlBzmKXLm0YP9Age6ErL8QxF0CLJSDK9Itm33TkuqEC2 JfuxxebM7iXPM4R2eBiD5RZ4SjsSpyEaDPEm9bV/x6IB8qVbvNlsBfsTI7VfpCPGxU Zlq23DJ5mVa0g== Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-33944381671so464065f8f.3 for ; Tue, 23 Jan 2024 10:43:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706035394; x=1706640194; 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=cpcO92XOl2zNt9sq2MJVJ7XaxnnPhG6+lYWq+HSy79Q=; b=NYGLbBdLmamSn9StTgDCZjxjWcgtxqKTyyXhIGNHxdJsaabNKGMKwrZAe8Cfj8GCcM K7HiqZssYleJb6X2bm/fBXvki3r1ambY0E/38XukYQnQFOzTPqqVotS97MDoi4wGUb4L BHxhy7zLL3usJ+BCdcvweoyODOmEeovVssJJhGHuOjJ7E/LBXdSmcJiU1oTr4FUG9EBj 1x30Ob6EN0Pi3hPKpy6KXAd80M1XhqT7szNNxeAM4CROTCd4n66BwA981IQ8HTLFKh6c Tqek36UCQe6Ec1DxmzXVWtjZ2TWuS3phBUm9FzSncquUWpQG3ENr9QSVvrSlIq1vEgXa FVvw== X-Gm-Message-State: AOJu0YxIaEM1sLw16YftuSTULGOHeAYQh9DPiMa6ANQNstmNm4xeNjYA anEapmMVAiY6hO2IMLs4T8qYs9j+sn3chDUY3EVXKHI25TsYUaRkwZ3lhH9Hn3RQv40+jOuB7Il gNW0Z+V2cDezqyJTfN0/6tTZp3rB1mrcRCTZpLQkfCssDF2RNwgO75MFm15A8fADCdXeU X-Received: by 2002:a05:6000:1191:b0:337:c658:9952 with SMTP id g17-20020a056000119100b00337c6589952mr3233715wrx.107.1706035394513; Tue, 23 Jan 2024 10:43:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IHu0IRY8+uf1KeQwVMffTCixbfa+fmoMjDnc3VXSJ4eZMwG8v35HE8xmwzX+psaF/O6gw4x/w== X-Received: by 2002:a05:6000:1191:b0:337:c658:9952 with SMTP id g17-20020a056000119100b00337c6589952mr3233701wrx.107.1706035394265; Tue, 23 Jan 2024 10:43:14 -0800 (PST) Received: from workstation5.fritz.box (ip-178-202-040-247.um47.pools.vodafone-ip.de. [178.202.40.247]) by smtp.gmail.com with ESMTPSA id u9-20020a5d6ac9000000b00337d392c6c3sm14180252wrw.13.2024.01.23.10.43.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 10:43:13 -0800 (PST) From: Heinrich Schuchardt To: Palmer Dabbelt , Alistair Francis Cc: Andrew Jones , Paolo Bonzini , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Heinrich Schuchardt Subject: [PATCH v4 4/4] qemu-options: enable -smbios option on RISC-V Date: Tue, 23 Jan 2024 19:42:29 +0100 Message-ID: <20240123184229.10415-5-heinrich.schuchardt@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123184229.10415-1-heinrich.schuchardt@canonical.com> References: <20240123184229.10415-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=185.125.188.122; envelope-from=heinrich.schuchardt@canonical.com; helo=smtp-relay-internal-0.canonical.com X-Spam_score_int: -56 X-Spam_score: -5.7 X-Spam_bar: ----- X-Spam_report: (-5.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.327, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org With SMBIOS support added for RISC-V we also should enable the command line option. Signed-off-by: Heinrich Schuchardt Reviewed-by: Daniel Henrique Barboza Acked-by: Alistair Francis Reviewed-by: Andrew Jones --- v4: no change v3: no change v2: new patch --- qemu-options.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu-options.hx b/qemu-options.hx index d90bdffc7a..935aec7cb9 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2697,7 +2697,7 @@ DEF("smbios", HAS_ARG, QEMU_OPTION_smbios, " specify SMBIOS type 17 fields\n" "-smbios type=41[,designation=str][,kind=str][,instance=%d][,pcidev=str]\n" " specify SMBIOS type 41 fields\n", - QEMU_ARCH_I386 | QEMU_ARCH_ARM | QEMU_ARCH_LOONGARCH) + QEMU_ARCH_I386 | QEMU_ARCH_ARM | QEMU_ARCH_LOONGARCH | QEMU_ARCH_RISCV) SRST ``-smbios file=binary`` Load SMBIOS entry from binary file.