From nobody Fri Apr 19 10:49:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1683270703071423.7319741644127; Fri, 5 May 2023 00:11:43 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 2847D22F67; Fri, 5 May 2023 07:11:38 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id D3BE322A8A for ; Fri, 5 May 2023 07:11:23 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) [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-179-rGMpx1XXMNmUxuFZU7NaWQ-1; Fri, 05 May 2023 03:11:19 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 460EE185A79C; Fri, 5 May 2023 07:11:19 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F1EFD1121331; Fri, 5 May 2023 07:11:18 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id BCF8118003BA; Fri, 5 May 2023 09:11:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683270682; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ILIkb92YfjNdVPvNemK23NPzdxpIvUqcxZkOvQcuD1w=; b=coQWAQRKtbeH9a9aEjVcadZdDsSB2dGSrBbYKR+0sn9+OZXObJG629O+j6O5DR+kOpGxsg YrauZizXs2cWxK6B+vsaOyPRXZw4aSjOkkTkvGAz+yWcFNKWfsKv3AtYlLBRhztHjvY8Td yyPEePHhcWBcAPLVlEqLT5OszRQKSDA= X-MC-Unique: rGMpx1XXMNmUxuFZU7NaWQ-1 From: Gerd Hoffmann To: seabios@seabios.org Date: Fri, 5 May 2023 09:11:12 +0200 Message-Id: <20230505071117.369471-2-kraxel@redhat.com> In-Reply-To: <20230505071117.369471-1-kraxel@redhat.com> References: <20230505071117.369471-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Spam-Level: ** Message-ID-Hash: YWJLQ43AJOT2EBLU44MYKUHTM4LI5TZL X-Message-ID-Hash: YWJLQ43AJOT2EBLU44MYKUHTM4LI5TZL X-MailFrom: kraxel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: qemu-devel@nongnu.org, Gerd Hoffmann X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [SeaBIOS] [PATCH v3 1/6] better kvm detection List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: - X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1683270703774100001 Content-Type: text/plain; charset="utf-8" In case kvm emulates features of another hypervisor (for example hyperv) two VMM CPUID blocks will be present, one for the emulated hypervisor and one for kvm itself. This patch makes seabios loop over the VMM CPUID blocks to make sure it will properly detect kvm when multiple blocks are present. Signed-off-by: Gerd Hoffmann --- src/fw/paravirt.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/fw/paravirt.c b/src/fw/paravirt.c index fba4e52db684..c880cb10a1bc 100644 --- a/src/fw/paravirt.c +++ b/src/fw/paravirt.c @@ -56,20 +56,31 @@ inline int qemu_cfg_dma_enabled(void) =20 static void kvm_detect(void) { + unsigned int i, kvmbase =3D 0, max =3D 0; unsigned int eax, ebx, ecx, edx; char signature[13]; =20 - cpuid(KVM_CPUID_SIGNATURE, &eax, &ebx, &ecx, &edx); - memcpy(signature + 0, &ebx, 4); - memcpy(signature + 4, &ecx, 4); - memcpy(signature + 8, &edx, 4); - signature[12] =3D 0; + for (i =3D KVM_CPUID_SIGNATURE;; i +=3D 0x100) { + eax =3D 0; + cpuid(i, &eax, &ebx, &ecx, &edx); + if (eax < i) + break; + memcpy(signature + 0, &ebx, 4); + memcpy(signature + 4, &ecx, 4); + memcpy(signature + 8, &edx, 4); + signature[12] =3D 0; + dprintf(1, "cpuid 0x%x: eax %x, signature '%s'\n", i, eax, signatu= re); + if (strcmp(signature, "KVMKVMKVM") =3D=3D 0) { + kvmbase =3D i; + max =3D eax; + } + } =20 - if (strcmp(signature, "KVMKVMKVM") =3D=3D 0) { + if (kvmbase) { dprintf(1, "Running on KVM\n"); PlatformRunningOn |=3D PF_KVM; - if (eax >=3D KVM_CPUID_SIGNATURE + 0x10) { - cpuid(KVM_CPUID_SIGNATURE + 0x10, &eax, &ebx, &ecx, &edx); + if (max >=3D kvmbase + 0x10) { + cpuid(kvmbase + 0x10, &eax, &ebx, &ecx, &edx); dprintf(1, "kvm: have invtsc, freq %u kHz\n", eax); tsctimer_setfreq(eax, "invtsc"); } --=20 2.40.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org From nobody Fri Apr 19 10:49:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 16832707734469.886151489583654; Fri, 5 May 2023 00:12:53 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 9755827462; Fri, 5 May 2023 07:12:49 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 4439B22F67 for ; Fri, 5 May 2023 07:11:25 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-349-jEEDYcpxNWutIkrtl8jEWw-1; Fri, 05 May 2023 03:11:21 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9655E3806062; Fri, 5 May 2023 07:11:20 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B12E492C13; Fri, 5 May 2023 07:11:20 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id C066C1800986; Fri, 5 May 2023 09:11:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683270684; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CXPCS+kJxlRKApXWmifHvPqleJ4x39uVxri/m9e/MXc=; b=SqrSHaX3mxY1qGv1Yiz5HTN2Hn4BNP1XtSDL7QwtjOjadrSKNY0rGciKd6BRK3F9Jskznf QndOdhbyYz0Ejx0GFPL2wrjEqUJO3wS2dBVLfmwyrSjN/17nI3Kl7EBBmKO6t6dLH/Xiqr Q7b4YFCg42uZUE5XgoyA6F9eL5J7aSI= X-MC-Unique: jEEDYcpxNWutIkrtl8jEWw-1 From: Gerd Hoffmann To: seabios@seabios.org Date: Fri, 5 May 2023 09:11:13 +0200 Message-Id: <20230505071117.369471-3-kraxel@redhat.com> In-Reply-To: <20230505071117.369471-1-kraxel@redhat.com> References: <20230505071117.369471-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Spam-Level: ** Message-ID-Hash: J2FIKVRPQFWEMJEOX2SRIZBQWYVDZXCP X-Message-ID-Hash: J2FIKVRPQFWEMJEOX2SRIZBQWYVDZXCP X-MailFrom: kraxel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: qemu-devel@nongnu.org, Gerd Hoffmann X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [SeaBIOS] [PATCH v3 2/6] detect physical address space size List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: --- X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1683270775249100001 Content-Type: text/plain; charset="utf-8" Check for pae and long mode using cpuid. If present also read the physical address bits. Apply some qemu sanity checks (see below). Record results in PhysBits and LongMode variables. In case we are not sure what the address space size is leave the PhysBits variable unset. On qemu we have the problem that for historical reasons x86_64 processors advertise 40 physical address space bits by default, even in case the host supports less than that so actually using the whole address space will not work. Because of that the code applies some extra sanity checks in case we find 40 (or less) physical address space bits advertised. Only known-good values (which is 40 for amd processors and 36+39 for intel processors) will be accepted as valid. Recommendation is to use 'qemu -cpu ${name},host-phys-bits=3Don' to advertise valid physical address space bits to the guest. Some distro builds enable this by default, and most likely the qemu default will change in near future too. Signed-off-by: Gerd Hoffmann --- src/fw/paravirt.h | 2 ++ src/fw/paravirt.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/src/fw/paravirt.h b/src/fw/paravirt.h index 4e2e993ba9d3..62a2cd075d2b 100644 --- a/src/fw/paravirt.h +++ b/src/fw/paravirt.h @@ -31,6 +31,8 @@ typedef struct QemuCfgDmaAccess { extern u32 RamSize; extern u64 RamSizeOver4G; extern int PlatformRunningOn; +extern u8 CPUPhysBits; +extern u8 CPULongMode; =20 static inline int runningOnQEMU(void) { return CONFIG_QEMU || ( diff --git a/src/fw/paravirt.c b/src/fw/paravirt.c index c880cb10a1bc..fc308bf1ef1d 100644 --- a/src/fw/paravirt.c +++ b/src/fw/paravirt.c @@ -32,6 +32,10 @@ u32 RamSize; // Amount of continuous ram >4Gig u64 RamSizeOver4G; +// physical address space bits +u8 CPUPhysBits; +// 64bit processor +u8 CPULongMode; // Type of emulator platform. int PlatformRunningOn VARFSEG; // cfg enabled @@ -129,6 +133,58 @@ static void kvmclock_init(void) tsctimer_setfreq(MHz * 1000, "kvmclock"); } =20 +static void physbits(int qemu_quirk) +{ + unsigned int max, eax, ebx, ecx, edx; + unsigned int physbits; + char signature[13]; + int pae =3D 0, valid =3D 0; + + cpuid(0, &eax, &ebx, &ecx, &edx); + memcpy(signature + 0, &ebx, 4); + memcpy(signature + 4, &edx, 4); + memcpy(signature + 8, &ecx, 4); + signature[12] =3D 0; + if (eax >=3D 1) { + cpuid(1, &eax, &ebx, &ecx, &edx); + pae =3D (edx & (1 << 6)); + } + + cpuid(0x80000000, &eax, &ebx, &ecx, &edx); + max =3D eax; + + if (max >=3D 0x80000001) { + cpuid(0x80000001, &eax, &ebx, &ecx, &edx); + CPULongMode =3D !!(edx & (1 << 29)); + } + + if (pae && CPULongMode && max >=3D 0x80000008) { + cpuid(0x80000008, &eax, &ebx, &ecx, &edx); + physbits =3D (u8)eax; + if (!qemu_quirk) { + valid =3D 1; + } else if (physbits >=3D 41) { + valid =3D 1; + } else if (strcmp(signature, "GenuineIntel") =3D=3D 0) { + if ((physbits =3D=3D 36) || (physbits =3D=3D 39)) + valid =3D 1; + } else if (strcmp(signature, "AuthenticAMD") =3D=3D 0) { + if (physbits =3D=3D 40) + valid =3D 1; + } + } else { + physbits =3D pae ? 36 : 32; + valid =3D 1; + } + + dprintf(1, "%s: signature=3D\"%s\", pae=3D%s, lm=3D%s, phys-bits=3D%d,= valid=3D%s\n", + __func__, signature, pae ? "yes" : "no", CPULongMode ? "yes" := "no", + physbits, valid ? "yes" : "no"); + + if (valid) + CPUPhysBits =3D physbits; +} + static void qemu_detect(void) { if (!CONFIG_QEMU_HARDWARE) @@ -161,6 +217,7 @@ static void qemu_detect(void) dprintf(1, "Running on QEMU (unknown nb: %04x:%04x)\n", v, d); break; } + physbits(1); } =20 static int qemu_early_e820(void); --=20 2.40.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org From nobody Fri Apr 19 10:49:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1683270758530212.1541818221981; Fri, 5 May 2023 00:12:38 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 81678220A3; Fri, 5 May 2023 07:12:34 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 2C48B22A8A for ; Fri, 5 May 2023 07:11:25 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) [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-618-jbST49ghO-CAaWscygLTJw-1; Fri, 05 May 2023 03:11:20 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8D28580080E; Fri, 5 May 2023 07:11:20 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5D76AC15BA0; Fri, 5 May 2023 07:11:20 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id C3E6F180099D; Fri, 5 May 2023 09:11:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683270684; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Hnbw/1xdXtcYTeMJ6hzBbi7QP8BTZHfCWmXXBwn82Jg=; b=aDvrQ4RkfKhPcu5VogW318klIEw8YsD5xCfTiyyDDmj5+5Ct3QEmlk1/5UIeYK2AUIzrbe ERCSrQIBEkBXC0ETNAsWCSCVHOT5NcAAJAwk3hq/uGW+xpQwLePZmnpznxVhfPY7TdQKtV u5x5eqGpHSl3KVnUrXaPpyQJySZizsg= X-MC-Unique: jbST49ghO-CAaWscygLTJw-1 From: Gerd Hoffmann To: seabios@seabios.org Date: Fri, 5 May 2023 09:11:14 +0200 Message-Id: <20230505071117.369471-4-kraxel@redhat.com> In-Reply-To: <20230505071117.369471-1-kraxel@redhat.com> References: <20230505071117.369471-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Spam-Level: ** Message-ID-Hash: ZBNMEUCVN266PTO47EKHVP3QLC57NVLB X-Message-ID-Hash: ZBNMEUCVN266PTO47EKHVP3QLC57NVLB X-MailFrom: kraxel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: qemu-devel@nongnu.org, Gerd Hoffmann X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [SeaBIOS] [PATCH v3 3/6] move 64bit pci window to end of address space List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: ---- X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1683270760548100001 Content-Type: text/plain; charset="utf-8" When the size of the physical address space is known (PhysBits is not zero) move the 64bit pci io window to the end of the address space. Signed-off-by: Gerd Hoffmann --- src/fw/pciinit.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c index badf13d3233b..0fcd2be598a2 100644 --- a/src/fw/pciinit.c +++ b/src/fw/pciinit.c @@ -1128,6 +1128,14 @@ static void pci_bios_map_devices(struct pci_bus *bus= ses) r64_mem.base =3D le64_to_cpu(romfile_loadint("etc/reserved-memory-= end", 0)); if (r64_mem.base < 0x100000000LL + RamSizeOver4G) r64_mem.base =3D 0x100000000LL + RamSizeOver4G; + if (CPUPhysBits) { + u64 top =3D 1LL << CPUPhysBits; + u64 size =3D (ALIGN(sum_mem, (1LL<<30)) + + ALIGN(sum_pref, (1LL<<30))); + if (r64_mem.base < top - size) { + r64_mem.base =3D top - size; + } + } r64_mem.base =3D ALIGN(r64_mem.base, align_mem); r64_mem.base =3D ALIGN(r64_mem.base, (1LL<<30)); // 1G hugepage r64_pref.base =3D r64_mem.base + sum_mem; --=20 2.40.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org From nobody Fri Apr 19 10:49:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1683270742920450.8869210261885; Fri, 5 May 2023 00:12:22 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 6FFA5220A3; Fri, 5 May 2023 07:12:19 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 0F9AF22A61 for ; Fri, 5 May 2023 07:11:25 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) [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-43-hqkWumDROCWII-tQW30O-Q-1; Fri, 05 May 2023 03:11:22 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E9393811E7C; Fri, 5 May 2023 07:11:21 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A8C46C15BA0; Fri, 5 May 2023 07:11:21 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id C774618011EC; Fri, 5 May 2023 09:11:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683270683; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Rlu4Dbr7nV6FubMH9YcoNGq9K+JqpiH6IUzURmGHJAM=; b=NgZf65zkF4N3yvH1HW42QRgULOhwlcuoecn+8xpK2PhxlzMIrUBYxUd+vrGv3dtyyVVF/r 30ufKuZgCmT9+nyYNXU/YwD0N4sarPVtbMYTIbXLNHEHfA2DIaedacwaBzQIL+eyHaGeKv 2pzXOKXO9RMEObky42QEPI2pyV5aD6o= X-MC-Unique: hqkWumDROCWII-tQW30O-Q-1 From: Gerd Hoffmann To: seabios@seabios.org Date: Fri, 5 May 2023 09:11:15 +0200 Message-Id: <20230505071117.369471-5-kraxel@redhat.com> In-Reply-To: <20230505071117.369471-1-kraxel@redhat.com> References: <20230505071117.369471-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Spam-Level: ** Message-ID-Hash: EC5SBJNFVYGFPHUOS3QWN4YAG5B33Z63 X-Message-ID-Hash: EC5SBJNFVYGFPHUOS3QWN4YAG5B33Z63 X-MailFrom: kraxel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: qemu-devel@nongnu.org, Gerd Hoffmann X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [SeaBIOS] [PATCH v3 4/6] be less conservative with the 64bit pci io window List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: --- X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1683270744563100001 Content-Type: text/plain; charset="utf-8" Current seabios code will only enable and use the 64bit pci io window in case it runs out of space in the 32bit pci mmio window below 4G. This patch will also enable the 64bit pci io window when (a) RAM above 4G is present, and (b) the physical address space size is known, and (c) seabios is running on a 64bit capable processor. This operates with the assumption that guests which are ok with memory above 4G most likely can handle mmio above 4G too. In case the 64bit pci io window is enabled also assign more memory to prefetchable pci bridge windows and the complete 64bit pci io window. The total mmio window size is 1/8 of the physical address space. Minimum bridge windows size is 1/256 of the total mmio window size. Signed-off-by: Gerd Hoffmann --- src/fw/pciinit.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c index 0fcd2be598a2..a6b5dff12bd3 100644 --- a/src/fw/pciinit.c +++ b/src/fw/pciinit.c @@ -51,6 +51,7 @@ u64 pcimem_end =3D BUILD_PCIMEM_END; u64 pcimem64_start =3D BUILD_PCIMEM64_START; u64 pcimem64_end =3D BUILD_PCIMEM64_END; u64 pci_io_low_end =3D 0xa000; +u32 pci_use_64bit =3D 0; =20 struct pci_region_entry { struct pci_device *dev; @@ -920,6 +921,8 @@ static int pci_bios_check_devices(struct pci_bus *busse= s) for (type =3D 0; type < PCI_REGION_TYPE_COUNT; type++) { u64 align =3D (type =3D=3D PCI_REGION_TYPE_IO) ? PCI_BRIDGE_IO_MIN : PCI_BRIDGE_MEM_MIN; + if (pci_use_64bit && (type =3D=3D PCI_REGION_TYPE_PREFMEM)) + align =3D (u64)1 << (CPUPhysBits - 11); if (!pci_bridge_has_region(s->bus_dev, type)) continue; u64 size =3D 0; @@ -1108,7 +1111,7 @@ static void pci_bios_map_devices(struct pci_bus *buss= es) panic("PCI: out of I/O address space\n"); =20 dprintf(1, "PCI: 32: %016llx - %016llx\n", pcimem_start, pcimem_end); - if (pci_bios_init_root_regions_mem(busses)) { + if (pci_use_64bit || pci_bios_init_root_regions_mem(busses)) { struct pci_region r64_mem, r64_pref; r64_mem.list.first =3D NULL; r64_pref.list.first =3D NULL; @@ -1132,6 +1135,8 @@ static void pci_bios_map_devices(struct pci_bus *buss= es) u64 top =3D 1LL << CPUPhysBits; u64 size =3D (ALIGN(sum_mem, (1LL<<30)) + ALIGN(sum_pref, (1LL<<30))); + if (pci_use_64bit) + size =3D ALIGN(size, (1LL<<(CPUPhysBits-3))); if (r64_mem.base < top - size) { r64_mem.base =3D top - size; } @@ -1174,6 +1179,9 @@ pci_setup(void) =20 dprintf(3, "pci setup\n"); =20 + if (CPUPhysBits >=3D 36 && CPULongMode && RamSizeOver4G) + pci_use_64bit =3D 1; + dprintf(1, "=3D=3D=3D PCI bus & bridge init =3D=3D=3D\n"); if (pci_probe_host() !=3D 0) { return; --=20 2.40.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org From nobody Fri Apr 19 10:49:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1683270729708512.8973687732165; Fri, 5 May 2023 00:12:09 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 3A53D27438; Fri, 5 May 2023 07:12:05 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 99B7322F67 for ; Fri, 5 May 2023 07:11:24 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-427-UNZRdrcENpCLTHh6j0zD4w-1; Fri, 05 May 2023 03:11:22 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EC20D3806062; Fri, 5 May 2023 07:11:21 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AB0F12026D16; Fri, 5 May 2023 07:11:21 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id CAE7118012E0; Fri, 5 May 2023 09:11:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683270683; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B/t7UcD8DC0shzbA+m7RqcSGtgUOMGokV2Dyf5qhc5E=; b=WufIz8NyzX92sQHPtIJjwbZ6jDF5WanjlQhI8I+bhTV9kQsdze/+nAsKrIdjN0Gul1y1PL x1huQEoGhJlAGUb7tW39BxRnRQ3EUMO4C73yUQChOvUYtWxoQEfw2cI/inMmeCn+c/4mTS 9vFqcPx59D21nDq4jX+SMs/2nGqt+2s= X-MC-Unique: UNZRdrcENpCLTHh6j0zD4w-1 From: Gerd Hoffmann To: seabios@seabios.org Date: Fri, 5 May 2023 09:11:16 +0200 Message-Id: <20230505071117.369471-6-kraxel@redhat.com> In-Reply-To: <20230505071117.369471-1-kraxel@redhat.com> References: <20230505071117.369471-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Spam-Level: ** Message-ID-Hash: J6CUMWCKS3M5OANCIUNQE327NV3YTL5D X-Message-ID-Hash: J6CUMWCKS3M5OANCIUNQE327NV3YTL5D X-MailFrom: kraxel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: qemu-devel@nongnu.org, Gerd Hoffmann X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [SeaBIOS] [PATCH v3 5/6] qemu: log reservations in fw_cfg e820 table List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: ------ X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1683270729969100001 Content-Type: text/plain; charset="utf-8" With loglevel 1 (same we use for RAM entries), so it is included in the firmware log by default. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- src/fw/paravirt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fw/paravirt.c b/src/fw/paravirt.c index fc308bf1ef1d..02351b24caea 100644 --- a/src/fw/paravirt.c +++ b/src/fw/paravirt.c @@ -764,7 +764,7 @@ static int qemu_early_e820(void) switch (table.type) { case E820_RESERVED: e820_add(table.address, table.length, table.type); - dprintf(3, "qemu/e820: addr 0x%016llx len 0x%016llx [reserved]= \n", + dprintf(1, "qemu/e820: addr 0x%016llx len 0x%016llx [reserved]= \n", table.address, table.length); break; case E820_RAM: --=20 2.40.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org From nobody Fri Apr 19 10:49:57 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683270797; cv=none; d=zohomail.com; s=zohoarc; b=f4QnuyWB+psdhyq/Wm3wHOb53XKvGMOYA1yX6kZ4N9MkSaAEh1oOTs3KXDzTXGNRD3Cm8xUcc53Ag+gRAWHa8rG7nAUKUlphrwSzcIghWhKwEY0t7DB0iCEJvTre6fF5SJAyknvdSQ8/3qr6Jt0OBQhgzlIPAD/zfg7gT6f43Zc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683270797; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jNvSqf9QPsEssFcNpRNgyESFGm56zOR8mpMAesar58E=; b=FZbNfZhAd7a+9aO+iuzaPcUoxiY5cR7cbDmlKz8bD/9fS/lLaCrvDIk2ef8hx3tE5C4IHoOitJKoPhs2sCVGuPX723FsOVTxa0UUF0vzpc52y39Rn3oIJqKVjsQWo+l3I1GPAqk8E6JZoZZqiQWEb/hZitgptty2ju816zdibvg= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683270797655887.4635545314469; Fri, 5 May 2023 00:13:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pupbH-0004ml-M7; Fri, 05 May 2023 03:11:31 -0400 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 1pupbE-0004lW-8z for qemu-devel@nongnu.org; Fri, 05 May 2023 03:11:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pupbC-0000fc-Gg for qemu-devel@nongnu.org; Fri, 05 May 2023 03:11:28 -0400 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-104-syOOQgklPr-cGy1-NtcFRQ-1; Fri, 05 May 2023 03:11:24 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6DE6A185A7A2; Fri, 5 May 2023 07:11:23 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.60]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3CE1663F5B; Fri, 5 May 2023 07:11:23 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id CE635180157C; Fri, 5 May 2023 09:11:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683270686; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jNvSqf9QPsEssFcNpRNgyESFGm56zOR8mpMAesar58E=; b=JFcrEE6DhefPE7mWIgSc15uCb7GhSnF3NEolVr5dsRMVPsr6TZ2LSruEYMmqF96QeJpaRo Y0oSW1sSnUE2StuCW2V1LvJICyllz2quikrlPmPlN1OyVAF01lNOzSTGIr+uU87cWR/I9b J8+1nSk6lGUbiT7A+SK1hl+RKQuZVmw= X-MC-Unique: syOOQgklPr-cGy1-NtcFRQ-1 From: Gerd Hoffmann To: seabios@seabios.org Cc: qemu-devel@nongnu.org, Gerd Hoffmann Subject: [PATCH v3 6/6] check for e820 conflict Date: Fri, 5 May 2023 09:11:17 +0200 Message-Id: <20230505071117.369471-7-kraxel@redhat.com> In-Reply-To: <20230505071117.369471-1-kraxel@redhat.com> References: <20230505071117.369471-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.161, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683270799616100003 Content-Type: text/plain; charset="utf-8" Add support to check for overlaps with e820 entries. In case the 64bit pci io window has conflicts move it down. The only known case where this happens is AMD processors with 1TB address space which has some space just below 1TB reserved for HT. Signed-off-by: Gerd Hoffmann --- src/e820map.h | 1 + src/e820map.c | 15 +++++++++++++++ src/fw/pciinit.c | 2 ++ 3 files changed, 18 insertions(+) diff --git a/src/e820map.h b/src/e820map.h index de8b523003c5..07ce16ec213f 100644 --- a/src/e820map.h +++ b/src/e820map.h @@ -18,6 +18,7 @@ struct e820entry { void e820_add(u64 start, u64 size, u32 type); void e820_remove(u64 start, u64 size); void e820_prepboot(void); +int e820_is_used(u64 start, u64 size); =20 // e820 map storage extern struct e820entry e820_list[]; diff --git a/src/e820map.c b/src/e820map.c index 39445cf6399d..c761e5e98a75 100644 --- a/src/e820map.c +++ b/src/e820map.c @@ -150,3 +150,18 @@ e820_prepboot(void) { dump_map(); } + +int +e820_is_used(u64 start, u64 size) +{ + int i; + for (i=3D0; istart) + continue; + if (start >=3D e->start + e->size) + continue; + return 1; + } + return 0; +} diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c index a6b5dff12bd3..1e56ee47fa86 100644 --- a/src/fw/pciinit.c +++ b/src/fw/pciinit.c @@ -1140,6 +1140,8 @@ static void pci_bios_map_devices(struct pci_bus *buss= es) if (r64_mem.base < top - size) { r64_mem.base =3D top - size; } + if (e820_is_used(r64_mem.base, size)) + r64_mem.base -=3D size; } r64_mem.base =3D ALIGN(r64_mem.base, align_mem); r64_mem.base =3D ALIGN(r64_mem.base, (1LL<<30)); // 1G hugepage --=20 2.40.1