From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web10.4597.1648545252618292694 for ; Tue, 29 Mar 2022 02:14:12 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NV/dxyuJ; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648545251; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ei1VHCe7i/DXbAoj0sxuz0rP0KoGTqop/jN27kHPNuY=; b=NV/dxyuJMZgBI2rjG4Hz09QEUnmkb7soKiZ2n4aWMwTeJxYKb5UWulnDPg1+oPcPCtI0hQ 2A03I6izCMQs6wek3HQE0GEFq8TUuVGwD7Tunlda6d1bsNjvjY1i8LhH9wChksKBaTQqkC RuNCTH3XrXR4mzYF5tOXxxVsPbbBknU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-510-vF_TrfuoO3yU6Wy7JbWypQ-1; Tue, 29 Mar 2022 05:14:08 -0400 X-MC-Unique: vF_TrfuoO3yU6Wy7JbWypQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 00D908F8D65; Tue, 29 Mar 2022 09:14:08 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.194.10]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BFE2F400F8FD; Tue, 29 Mar 2022 09:14:07 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 4BFD718003A3; Tue, 29 Mar 2022 11:14:06 +0200 (CEST) Date: Tue, 29 Mar 2022 11:14:06 +0200 From: "Gerd Hoffmann" To: devel@edk2.groups.io, c.koehne@beckhoff.com Cc: Ard Biesheuvel , Jiewen Yao , Jordan Justen , Rebecca Cran , Peter Grehan , FreeBSD Virtualization Subject: Re: [edk2-devel] [PATCH 0/1] OvmfPkg/Bhyve: QemuFwCfg support Message-ID: <20220329091406.jp3e4bwdmyre6pnc@sirius.home.kraxel.org> References: <20220329065437.186-1-c.koehne@beckhoff.com> MIME-Version: 1.0 In-Reply-To: <20220329065437.186-1-c.koehne@beckhoff.com> X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Tue, Mar 29, 2022 at 08:54:36AM +0200, Corvin Köhne wrote: > Hi, > > I'm going to add QemuFwCfg support to bhyve. See > https://reviews.freebsd.org/D31578. Therefore, this patch for OVMF is > neccessary to work properly. > > There's one open point on that patch and hopefully one of you has more > insights. Qemu has an item called FW_CFG_MAX_CPUS. It looks very similar to > what we need here, but I'm not sure if we can use it safely as Qemu has a > comment about it: > > https://github.com/qemu/qemu/blob/0021c4765a6b83e5b09409b75d50c6caaa6971b9/hw/i386/fw_cfg.c#L110-L121 > > /* FW_CFG_MAX_CPUS is a bit confusing/problematic on x86: > * > * For machine types prior to 1.8, SeaBIOS needs FW_CFG_MAX_CPUS for > * building MPTable, ACPI MADT, ACPI CPU hotplug and ACPI SRAT table, > * that tables are based on xAPIC ID and QEMU<->SeaBIOS interface > * for CPU hotplug also uses APIC ID and not "CPU index". > * This means that FW_CFG_MAX_CPUS is not the "maximum number of CPUs", > * but the "limit to the APIC ID values SeaBIOS may see". > * > * So for compatibility reasons with old BIOSes we are stuck with > * "etc/max-cpus" actually being apic_id_limit > */ There is FW_CFG_NB_CPUS + FW_CFG_MAX_CPUS. ovmf uses different names, see OvmfPkg/Include/IndustryStandard/QemuFwCfg.h PlatformPei for qemu uses QemuFwCfgItemSmpCpuCount aka FW_CFG_NB_CPUS, which is the number of cpus which are online. I think FW_CFG_MAX_CPUS is basically unused these days. It played a role back when seabios created the acpi tables for cpu hotplug as described in the comment above. In qemu 2.0 & newer the acpi tables are generated by qemu instead. The firmware just downloads them from fw_cfg and installs them for the OS, it doesn't need to know virtual machine configuration details any more. HTH, Gerd