From nobody Sat May 4 06:34:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1643055410; cv=none; d=zohomail.com; s=zohoarc; b=QgJrR7J2o5DStH9zRPK6K70go4zDd8c/nwh8lYnc5IvWHDVUdwXt/8zJreOKHb79ARayS9w9YOBmZVe4xHEIIZBbJahXnr02YU6GpCcHcWdM8JxD2aT5oWUfcUo4kNkvqeMgPkPN8JPis471QDtMmXlCA26I8JzCVEeSLj21erQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643055410; h=Content-Type:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=1nHZ62rYJ5DDP40SfGf8ieLj3Ru3dy+9vCvs9k2i+fg=; b=S9bszKgtbSS884tTMn9eFfs4wyjMlK1Dp6dpwKb6IbdoaCVVStqWX/0I6+zyDgdseVCsp5Ah+4DLHbI/Q7akASzajM3440dTj+Mm/ydSfkcqFFfLxKObqQguZVduiGtlLkgyUYo77xmq7D7e88ZHE0Uwl+KLwypFUvrOTGpPw38= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1643055410228886.022241109671; Mon, 24 Jan 2022 12:16:50 -0800 (PST) Received: from localhost ([::1]:44528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nC5lh-0005td-2J for importer@patchew.org; Mon, 24 Jan 2022 15:16:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3CwjvYQcKCuwjSbhifSUccUZS.QcaeSai-RSjSZbcbUbi.cfU@flex--venture.bounces.google.com>) id 1nC5h0-0001VS-J9 for qemu-devel@nongnu.org; Mon, 24 Jan 2022 15:11:58 -0500 Received: from [2607:f8b0:4864:20::b4a] (port=37487 helo=mail-yb1-xb4a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3CwjvYQcKCuwjSbhifSUccUZS.QcaeSai-RSjSZbcbUbi.cfU@flex--venture.bounces.google.com>) id 1nC5gy-0002cF-RD for qemu-devel@nongnu.org; Mon, 24 Jan 2022 15:11:58 -0500 Received: by mail-yb1-xb4a.google.com with SMTP id v70-20020a25c549000000b006130de5790aso37042279ybe.4 for ; Mon, 24 Jan 2022 12:11:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=1nHZ62rYJ5DDP40SfGf8ieLj3Ru3dy+9vCvs9k2i+fg=; b=nVoL61PSzgL+drHTD5knYfsiyhu6deP9o3SelReRaZ10m3qEr+URfQvSOkTvv6EXYj F52sjPE2JAzR+kAkRZ0Clx+uzfftIKcBvF0JvhN+xKWQOTGnXW0ejJ0Lb/TmUcU6aWwx EHBhP9KksTjHN9/LXphI+pyWMCkuuSu2TFCGB+XTvj4oScqbZS0NoQlOpcpLAZrqb2e9 5w7hvFzWPo1KNEloea12R1H/NNPe1qssXRSmdQfOjUiMmzldX8tPxji7W0zsZubvhgYz wNuNCVIn381538P6mCH1rCBgIi2Yq8qepQwmgUefEEkty0QUa8mRlkv603kBpn1vuhFP 0ZMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=1nHZ62rYJ5DDP40SfGf8ieLj3Ru3dy+9vCvs9k2i+fg=; b=DE/ExRQajz5PAX5P/LBbS4XlaelEGEgnZaK8eN+qo3oUZR0UU0EHimgnpNvjPWumWX bzetyDMZw+ZklcdkbPrqeTMhspSotUJSQNhe49PNM7w/RM3poEVobUoGQLHO97SWkmNl d+h5UQN0PsjMmZ9ea/VQfnVqOsppyxkoc/rn9MCn5h0eApaO9Fd1mjI0gppjnnhmDgrk xByyShDbNDPvjBNCWFj2hQX1vIJnhdbUtNd8pvWZDsSLXlWCK0n2jXZBuvC7pyzKRiFJ 2ttBgGlnYNbftgZdleO+YDMx/QwSpfv2Xw7QBtM0pyJhuSRUr11F1Ecp8Hu9Mgbg1qJ5 hphw== X-Gm-Message-State: AOAM5311Wqw+aoHCvlzJ1ThknCbUbY9qaWIOd/uPmSB1aRbWlTWwVh6H 0/liQRkhvujfs8zk+SJc/QwyhOx1AFfo X-Google-Smtp-Source: ABdhPJyMYaVPxP2PYvkq4jaI6LRi7hoJUNfO2SSOMgjrLnD+7bZVqnnfo2/4Gs8oJ4sqi15V78y6vAAUjFlL X-Received: from venture.svl.corp.google.com ([2620:15c:2a3:200:f1c8:fddb:d88f:ccec]) (user=venture job=sendgmr) by 2002:a81:6804:0:b0:2ca:287c:6b67 with SMTP id 00721157ae682-2ca287c6daamr955497b3.12.1643055115282; Mon, 24 Jan 2022 12:11:55 -0800 (PST) Date: Mon, 24 Jan 2022 12:11:51 -0800 Message-Id: <20220124201151.833769-1-venture@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH v2] hw/smbios: Add table 4 parameter, "processor-id" From: Patrick Venture To: mst@redhat.com, imammedo@redhat.com, ani@anisinha.ca Cc: qemu-devel@nongnu.org, Patrick Venture , Peter Foley , Titus Rwantare X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::b4a (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::b4a; envelope-from=3CwjvYQcKCuwjSbhifSUccUZS.QcaeSai-RSjSZbcbUbi.cfU@flex--venture.bounces.google.com; helo=mail-yb1-xb4a.google.com X-Spam_score_int: -87 X-Spam_score: -8.8 X-Spam_bar: -------- X-Spam_report: (-8.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5 autolearn=no 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1643055413157100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This parameter is to be used in the processor_id lower 32-bit entry in the type 4 table. The upper 32-bits represent the features for the CPU. This patch leaves those as 0 when the lower 32-bits are set. This parameter is set as optional and if left will use the values from the CPU model. This enables hiding the host information from the guest and allowing AMD VMs to run pretending to be Intel for some userspace software concerns. Reviewed-by: Peter Foley Reviewed-by: Titus Rwantare Signed-off-by: Patrick Venture Reviewed-by: Igor Mammedov --- v2: Added to SRST options list, upgraded to full 64-bit value. --- hw/smbios/smbios.c | 19 ++++++++++++++++--- qemu-options.hx | 3 ++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 7397e56737..385b69b0c9 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -104,9 +104,11 @@ static struct { const char *sock_pfx, *manufacturer, *version, *serial, *asset, *part; uint64_t max_speed; uint64_t current_speed; + uint64_t processor_id; } type4 =3D { .max_speed =3D DEFAULT_CPU_SPEED, - .current_speed =3D DEFAULT_CPU_SPEED + .current_speed =3D DEFAULT_CPU_SPEED, + .processor_id =3D 0, }; =20 static struct { @@ -327,6 +329,10 @@ static const QemuOptDesc qemu_smbios_type4_opts[] =3D { .name =3D "part", .type =3D QEMU_OPT_STRING, .help =3D "part number", + }, { + .name =3D "processor-id", + .type =3D QEMU_OPT_NUMBER, + .help =3D "processor id", }, { /* end of list */ } }; @@ -669,8 +675,13 @@ static void smbios_build_type_4_table(MachineState *ms= , unsigned instance) t->processor_type =3D 0x03; /* CPU */ t->processor_family =3D 0x01; /* Other */ SMBIOS_TABLE_SET_STR(4, processor_manufacturer_str, type4.manufacturer= ); - t->processor_id[0] =3D cpu_to_le32(smbios_cpuid_version); - t->processor_id[1] =3D cpu_to_le32(smbios_cpuid_features); + if (type4.processor_id =3D=3D 0) { + t->processor_id[0] =3D cpu_to_le32(smbios_cpuid_version); + t->processor_id[1] =3D cpu_to_le32(smbios_cpuid_features); + } else { + t->processor_id[0] =3D cpu_to_le32((uint32_t)type4.processor_id); + t->processor_id[1] =3D cpu_to_le32(type4.processor_id >> 32); + } SMBIOS_TABLE_SET_STR(4, processor_version_str, type4.version); t->voltage =3D 0; t->external_clock =3D cpu_to_le16(0); /* Unknown */ @@ -1292,6 +1303,8 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) save_opt(&type4.serial, opts, "serial"); save_opt(&type4.asset, opts, "asset"); save_opt(&type4.part, opts, "part"); + /* If the value is 0, it will take the value from the CPU mode= l. */ + type4.processor_id =3D qemu_opt_get_number(opts, "processor-id= ", 0); type4.max_speed =3D qemu_opt_get_number(opts, "max-speed", DEFAULT_CPU_SPEED); type4.current_speed =3D qemu_opt_get_number(opts, "current-spe= ed", diff --git a/qemu-options.hx b/qemu-options.hx index ec90505d84..6256417935 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2527,6 +2527,7 @@ DEF("smbios", HAS_ARG, QEMU_OPTION_smbios, " specify SMBIOS type 3 fields\n" "-smbios type=3D4[,sock_pfx=3Dstr][,manufacturer=3Dstr][,version=3Dstr= ][,serial=3Dstr]\n" " [,asset=3Dstr][,part=3Dstr][,max-speed=3D%d][,current-s= peed=3D%d]\n" + " [,processor-id=3D%d]\n" " specify SMBIOS type 4 fields\n" "-smbios type=3D11[,value=3Dstr][,path=3Dfilename]\n" " specify SMBIOS type 11 fields\n" @@ -2552,7 +2553,7 @@ SRST ``-smbios type=3D3[,manufacturer=3Dstr][,version=3Dstr][,serial=3Dstr][,as= set=3Dstr][,sku=3Dstr]`` Specify SMBIOS type 3 fields =20 -``-smbios type=3D4[,sock_pfx=3Dstr][,manufacturer=3Dstr][,version=3Dstr][,= serial=3Dstr][,asset=3Dstr][,part=3Dstr]`` +``-smbios type=3D4[,sock_pfx=3Dstr][,manufacturer=3Dstr][,version=3Dstr][,= serial=3Dstr][,asset=3Dstr][,part=3Dstr][,processor-id=3D%d]`` Specify SMBIOS type 4 fields =20 ``-smbios type=3D11[,value=3Dstr][,path=3Dfilename]`` --=20 2.35.0.rc0.227.g00780c9af4-goog