From nobody Mon May 13 06:34:09 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 1692867501018765.4357389844727; Thu, 24 Aug 2023 01:58:21 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id B2FAD21447; Thu, 24 Aug 2023 08:58:16 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 15C3C208B9 for ; Thu, 24 Aug 2023 08:58:02 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-517--UABpUiMPomgKqhkaaAKLg-1; Thu, 24 Aug 2023 04:57:58 -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 4523A2808B2F; Thu, 24 Aug 2023 08:57:58 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EEE80140E91D; Thu, 24 Aug 2023 08:57:57 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id B1BEE1800627; Thu, 24 Aug 2023 10:57:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692867481; 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=FejcfvmcyBS10KS1IwKQD1UjRIW+u81CbUOC29wnz6Q=; b=Qnv+dBxaXGl8U8DFOAkojdO5XIeeogXWexbH3b56AzEMn8Fd3Yk/kvD5ivHhDwIm6liDsy NffwfIsLxby4/34oExV1Qjlwir7u3Kz2FTspXvJ3dhOk7Vfiw3kM5XtEkAHDFZNTTpm5/j 6shstDakg4CXJlJOWRTs73hjYdGvifU= X-MC-Unique: -UABpUiMPomgKqhkaaAKLg-1 From: Gerd Hoffmann To: seabios@seabios.org Date: Thu, 24 Aug 2023 10:57:51 +0200 Message-ID: <20230824085756.66732-2-kraxel@redhat.com> In-Reply-To: <20230824085756.66732-1-kraxel@redhat.com> References: <20230824085756.66732-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Spam-Level: ** Message-ID-Hash: HALHZLG3WVF73AQG4UITTCJONZDHDOMQ X-Message-ID-Hash: HALHZLG3WVF73AQG4UITTCJONZDHDOMQ 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 v4 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: 1692867501564100001 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 | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/fw/paravirt.c b/src/fw/paravirt.c index fba4e52db684..42abac8460c5 100644 --- a/src/fw/paravirt.c +++ b/src/fw/paravirt.c @@ -53,23 +53,35 @@ inline int qemu_cfg_dma_enabled(void) * should be used to determine that a VM is running under KVM. */ #define KVM_CPUID_SIGNATURE 0x40000000 +static unsigned int kvm_cpuid_base =3D 0; =20 static void kvm_detect(void) { + unsigned int i, 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) { + kvm_cpuid_base =3D i; + max =3D eax; + } + } =20 - if (strcmp(signature, "KVMKVMKVM") =3D=3D 0) { + if (kvm_cpuid_base) { 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 kvm_cpuid_base + 0x10) { + cpuid(kvm_cpuid_base + 0x10, &eax, &ebx, &ecx, &edx); dprintf(1, "kvm: have invtsc, freq %u kHz\n", eax); tsctimer_setfreq(eax, "invtsc"); } @@ -93,7 +105,7 @@ static void kvmclock_init(void) if (!runningOnKVM()) return; =20 - cpuid(KVM_CPUID_SIGNATURE + 0x01, &eax, &ebx, &ecx, &edx); + cpuid(kvm_cpuid_base + 0x01, &eax, &ebx, &ecx, &edx); if (eax & (1 << KVM_FEATURE_CLOCKSOURCE2)) msr =3D MSR_KVM_SYSTEM_TIME_NEW; else if (eax & (1 << KVM_FEATURE_CLOCKSOURCE)) --=20 2.41.0 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org From nobody Mon May 13 06:34:09 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=1692867513; cv=none; d=zohomail.com; s=zohoarc; b=Pjh8lTjeGuSgGEGINM658YDS6kKjYcOjWenNu8CqIOUD7Cz7/zt4mUXPErutbSMjPVwl4MfTO5C3+V6qvXAebuk09J/8sMY0Vip4EE2NY2wsQcPnePgvrTS3auhmAWm44KQa8TUHB4k/rFzFaNoqybohanEpep37dXerYZBJBOw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692867513; 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=+INQJt6rBrSed828xMroy0Krb0dhJ4qJKWssCfCbKWQ=; b=mCqrROryVwn6DiCdUC65Le50S3fsM2drllErIJtxdvQIpfzJi1v3pd+PeURbZMbErUkFCMpznVC9yeBIoR1Ga6G+xZbI3/9Ly05h1W+Tp1Zos1nmoTvZyhpHVk4/gfVJxc6ALWwowsYKWrNDZ+rp8VsGUu9rRqgCOGzjb9qRZMc= 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 1692867513058351.862694347545; Thu, 24 Aug 2023 01:58:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZ6AL-0007Ls-J9; Thu, 24 Aug 2023 04:58:09 -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 1qZ6AJ-0007JC-EK for qemu-devel@nongnu.org; Thu, 24 Aug 2023 04:58:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZ6AG-0003ia-Lf for qemu-devel@nongnu.org; Thu, 24 Aug 2023 04:58:07 -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-523-v3ZjMGuEMG2ZfS5sO7-HKA-1; Thu, 24 Aug 2023 04:57:59 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7C9C8185A7A4; Thu, 24 Aug 2023 08:57:59 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.155]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 46DF1492C13; Thu, 24 Aug 2023 08:57:59 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id B6E941800632; Thu, 24 Aug 2023 10:57:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692867484; 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=+INQJt6rBrSed828xMroy0Krb0dhJ4qJKWssCfCbKWQ=; b=Bqt8nekOscncFpqOKca3fwBE5ejwoq5Adip9jf3yLI1+OS06ZcrzmjIV+0pLSUlNAN15gZ 2zWBcfhBf4NxHjKs/Su+g8Fla2ybTon9n7AYp0niZX6ovj7IGGDDvEXP6LcJ4fdnmvdVPV XiRiRAMoWFHVCdHk3YJxX1DImGPY9aM= X-MC-Unique: v3ZjMGuEMG2ZfS5sO7-HKA-1 From: Gerd Hoffmann To: seabios@seabios.org Cc: qemu-devel@nongnu.org, Gerd Hoffmann Subject: [PATCH v4 2/6] detect physical address space size Date: Thu, 24 Aug 2023 10:57:52 +0200 Message-ID: <20230824085756.66732-3-kraxel@redhat.com> In-Reply-To: <20230824085756.66732-1-kraxel@redhat.com> References: <20230824085756.66732-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1692867513317100003 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 42abac8460c5..3aee4c0d4e6b 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 @@ -130,6 +134,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) @@ -162,6 +218,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.41.0 From nobody Mon May 13 06:34:09 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=1692867514; cv=none; d=zohomail.com; s=zohoarc; b=HXLax5NBmMMtSXBlz5jHOHIonxKOPq3w0Op9QgnMA17IAiTTnUlbTapXDZN+Pibd4gP915QlWBk76To8zTGDlQFb2nXNHvHIOw8WRw2NZxNVPc0qWPKGVOQZKKS2DU8nWoxq+oDOUk7uCdCW1aTtzSHSqRHtb1+Zc+ea+JQSmjw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692867514; 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=Q5ciGi8+YCWcfxM0oo0hyNfFkpG3lCKNRIUnrSuHoVg=; b=Nb38jJl4M0yd6bDWJy4xtXbCSKmqngsdt65XYAVQa9S5L4Y06FiBd4sDTKc4GcBWGQBAz2JUE8fRk+jIFwB4Z3Fek8MfTYoP8Mc6CNX9KVyo8v9oVAUj3dIQOmks9akhyMzXL3ArMARMNvvG43v37QHguiwubY9MiQVGZlOIxvU= 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 16928675143049.584615609997286; Thu, 24 Aug 2023 01:58:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZ6AK-0007Kq-Qb; Thu, 24 Aug 2023 04:58:08 -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 1qZ6AI-0007IN-Qq for qemu-devel@nongnu.org; Thu, 24 Aug 2023 04:58:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZ6AE-0003hi-T7 for qemu-devel@nongnu.org; Thu, 24 Aug 2023 04:58:06 -0400 Received: from mimecast-mx02.redhat.com (66.187.233.73 [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-523-ogQXnQlbO56cuxVgwjYcyQ-1; Thu, 24 Aug 2023 04:57:59 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 953E73801F68; Thu, 24 Aug 2023 08:57:59 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.155]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 62C1E1121315; Thu, 24 Aug 2023 08:57:59 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id BB2961800639; Thu, 24 Aug 2023 10:57:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692867481; 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=Q5ciGi8+YCWcfxM0oo0hyNfFkpG3lCKNRIUnrSuHoVg=; b=S0m4lefhKpMB159EKfCXhQnooQpqr24WSdMc483jXc0AfsL3ngRfqU53SSWd2y3s0Am7/3 KkrbrXeV36B7GxOMt3bh3uvJedR8+4qZAqqgHH1rSOHAwE9cgdXa6+md+GBvUh6GCw010f mNrqX9qKzRf42RnZJMaqJ8m/rbZm/MI= X-MC-Unique: ogQXnQlbO56cuxVgwjYcyQ-1 From: Gerd Hoffmann To: seabios@seabios.org Cc: qemu-devel@nongnu.org, Gerd Hoffmann Subject: [PATCH v4 3/6] move 64bit pci window to end of address space Date: Thu, 24 Aug 2023 10:57:53 +0200 Message-ID: <20230824085756.66732-4-kraxel@redhat.com> In-Reply-To: <20230824085756.66732-1-kraxel@redhat.com> References: <20230824085756.66732-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1692867514629100007 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.41.0 From nobody Mon May 13 06:34:09 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=1692867559; cv=none; d=zohomail.com; s=zohoarc; b=Eb8IvEq2WL9UARKJEAhc61F0QwiGUGA7NKWLTBXBmUZXVF3ci5ixrJpTgDpEEJL8r3fTjMxORZZ1Rg8vyEnBKY+CpvnHr/0IG5BVdJ0npshnxxeG1oS8XJVOcrpJyxgMcWDvSJ1AvvEdhWJKO5rXcjf8oXveeqc8tsKc+7yBN6I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692867559; 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=mFoz8pFygAnd8HjNAOMgarx4ONt0soHWY8cYtfArawE=; b=YvusBxsMKLORTMvLGlAL5AzhMoWdZFA+6FPXGtsxq5IpEVAgz0y2yRLq5v1PXBoZGTqjZ4o8GtgbTTZsSnUvuM2miaJnfMAhSI349HhiP1S0ufD8XhDMk2Y4itCe0PClC9GyXvbyYZW4IKe5RaAtTJO9BJBlLJPgyDynUDYG5dg= 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 169286755966019.67699268458955; Thu, 24 Aug 2023 01:59:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZ6AN-0007Mj-4t; Thu, 24 Aug 2023 04:58:11 -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 1qZ6AJ-0007J5-9F for qemu-devel@nongnu.org; Thu, 24 Aug 2023 04:58:07 -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 1qZ6AF-0003i6-Nn for qemu-devel@nongnu.org; Thu, 24 Aug 2023 04:58:07 -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-472-OsqQBBlNPWmS3S9ngnxBjQ-1; Thu, 24 Aug 2023 04:58:01 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D52978D40A1; Thu, 24 Aug 2023 08:58:00 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.155]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A10492026D68; Thu, 24 Aug 2023 08:58:00 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id BE864180063D; Thu, 24 Aug 2023 10:57:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692867483; 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=mFoz8pFygAnd8HjNAOMgarx4ONt0soHWY8cYtfArawE=; b=AnPG0jIkkr1+3Lhsr6UNK96ORmSWJbgXCoRFlW57j9hAkcB0Ul2MVQl9EQqBSyWndUAt2C VN9k+jBjH4DaUY0TvgvB1aATXfSq1jVzJdC4fHsP4tG69eVM3OQoRxFM0v2GG+4z0cFw9d VzU0iH6DM4VpbdqEIjEAKD8SBynVleo= X-MC-Unique: OsqQBBlNPWmS3S9ngnxBjQ-1 From: Gerd Hoffmann To: seabios@seabios.org Cc: qemu-devel@nongnu.org, Gerd Hoffmann Subject: [PATCH v4 4/6] be less conservative with the 64bit pci io window Date: Thu, 24 Aug 2023 10:57:54 +0200 Message-ID: <20230824085756.66732-5-kraxel@redhat.com> In-Reply-To: <20230824085756.66732-1-kraxel@redhat.com> References: <20230824085756.66732-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1692867561641100001 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 | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c index 0fcd2be598a2..b52bd1d5054b 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; @@ -960,10 +961,14 @@ static int pci_bios_check_devices(struct pci_bus *bus= ses) if (pci_region_align(&s->r[type]) > align) align =3D pci_region_align(&s->r[type]); u64 sum =3D pci_region_sum(&s->r[type]); + int is64 =3D pci_bios_bridge_region_is64(&s->r[type], + s->bus_dev, type); int resource_optional =3D 0; if (hotplug_support =3D=3D HOTPLUG_PCIE) resource_optional =3D pcie_cap && (type =3D=3D PCI_REGION_= TYPE_IO); - if (!sum && hotplug_support && !resource_optional) + if (hotplug_support && pci_use_64bit && is64 && (type =3D=3D P= CI_REGION_TYPE_PREFMEM)) + align =3D (u64)1 << (CPUPhysBits - 11); + if (align > sum && hotplug_support && !resource_optional) sum =3D align; /* reserve min size for hot-plug */ if (size > sum) { dprintf(1, "PCI: QEMU resource reserve cap: " @@ -975,8 +980,6 @@ static int pci_bios_check_devices(struct pci_bus *busse= s) } else { size =3D ALIGN(sum, align); } - int is64 =3D pci_bios_bridge_region_is64(&s->r[type], - s->bus_dev, type); // entry->bar is -1 if the entry represents a bridge region struct pci_region_entry *entry =3D pci_region_create_entry( parent, s->bus_dev, -1, size, align, type, is64); @@ -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.41.0 From nobody Mon May 13 06:34:09 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=1692867511; cv=none; d=zohomail.com; s=zohoarc; b=I47+RguQVQzoKJzPLI+UVaN2gwPP9y+2JOnCUdmkUgeYTn1S1c+X3Dip3rJZLbDfk5WJs3nDVod7ktcZYsMYrtFVYccoKai2W+vNFnF4AcCknfJyaaVK7XtOBiB21Ew8I1sR//V+TYjWc40fQcWeBbYns6FIkN+k120JwXWfiFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692867511; 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=k5sAtDEYg+mO6cON5OI5+MehGdtsWzoCUYJ9hGXaCQY=; b=kD1245Co8+44HvJN1ipc3ojd1cv2DqleEO+V7aK0t3nzFY54Efg7ePJhNsYTuwJf53jhdi8AYoX7T1ZVKA9j0J9vQIvJgxvvj4VqMEtINGa2Cmil+kDo72jYd9XnIyBlApP6vA2Js9FD/4n8yAhkdiojGRqfE9imkjdXfGQ/X80= 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 1692867511686878.4955395045589; Thu, 24 Aug 2023 01:58:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZ6AK-0007Ko-QT; Thu, 24 Aug 2023 04:58:08 -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 1qZ6AJ-0007J0-5m for qemu-devel@nongnu.org; Thu, 24 Aug 2023 04:58:07 -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 1qZ6AG-0003iO-AD for qemu-devel@nongnu.org; Thu, 24 Aug 2023 04:58:06 -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-210-oAhONjC8Npqrw8hFloPX4A-1; Thu, 24 Aug 2023 04:58:01 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E59F3800CB4; Thu, 24 Aug 2023 08:58:00 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.155]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B28B4C1602B; Thu, 24 Aug 2023 08:58:00 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C1E9B180092F; Thu, 24 Aug 2023 10:57:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692867483; 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=k5sAtDEYg+mO6cON5OI5+MehGdtsWzoCUYJ9hGXaCQY=; b=QWmY5m4BaNZt8KJymkdgQaJ1+pxh/w4xijoWYYj9zvxoNld0S1T/siN6M5HAq6RtJle9DT PZkLKuxOI1IoiWEeo0X3nBFKFWTcMVgHGfT1Ca2aVDT+nUF2ElI2WhENd6IBvNdJv68NPA gow2kzQxSoXruT9uH1yT+nb6/ZTSGHI= X-MC-Unique: oAhONjC8Npqrw8hFloPX4A-1 From: Gerd Hoffmann To: seabios@seabios.org Cc: qemu-devel@nongnu.org, Gerd Hoffmann Subject: [PATCH v4 5/6] qemu: log reservations in fw_cfg e820 table Date: Thu, 24 Aug 2023 10:57:55 +0200 Message-ID: <20230824085756.66732-6-kraxel@redhat.com> In-Reply-To: <20230824085756.66732-1-kraxel@redhat.com> References: <20230824085756.66732-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1692867513319100004 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 3aee4c0d4e6b..e5d4eca0cb5a 100644 --- a/src/fw/paravirt.c +++ b/src/fw/paravirt.c @@ -765,7 +765,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.41.0 From nobody Mon May 13 06:34:09 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=1692867565; cv=none; d=zohomail.com; s=zohoarc; b=YajmgPZBiMjtv3QntrMpXr6+W0SftOb/i8byxkQV2eSRczTTe51cku/mjYTQz5+RkNtM4UXs4QkF5IpQ8NGswpXdUkjcBpXCukjmhDv079DN+5oU9fzKGWv+7IDq23T8OV+fuC1MsHScc8lgoRYymdYNZ9SwYG2ji6riPNpUdkY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692867565; 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=1tKonvgasUB+hKKDkSYEjkN5CNR2JzmcxLIKxvnV7XI=; b=h3s3TTqsoAlixelVcu+EKAljYCT2lKZGXf8jbWpWyKAN3SAo0gnrBqiooiglchLC6GrRzVJh9a1e1PljtB5PQ5Fy5gtl3tu4KCbL/behAkvLu7sO/cc/WSsAxOw3uWcgvtUYXUxyhzDB7AQX8dfF8y+mNZE4psFs3FpTupT6JlM= 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 1692867565062864.3265820896722; Thu, 24 Aug 2023 01:59:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZ6BU-0001cf-MI; Thu, 24 Aug 2023 04:59:20 -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 1qZ6BF-0001Bt-3R for qemu-devel@nongnu.org; Thu, 24 Aug 2023 04:59:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZ6BC-00045M-Dt for qemu-devel@nongnu.org; Thu, 24 Aug 2023 04:59:04 -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-198-GfWia7PbPfe3v8KFe1NdCA-1; Thu, 24 Aug 2023 04:58:02 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2DE6485CCE0; Thu, 24 Aug 2023 08:58:02 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.155]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F24702026D35; Thu, 24 Aug 2023 08:58:01 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C528118009BC; Thu, 24 Aug 2023 10:57:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692867541; 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=1tKonvgasUB+hKKDkSYEjkN5CNR2JzmcxLIKxvnV7XI=; b=A1LAIQo2ejBKo7mfLjCaDQPXBnCzaYoKnCnUE3d/I9AbYIqkU4akGu/Lw6VwtT++3rmjB6 ZJKAYHN/VCrjOAVEQus4CUBlnzGh/uk116k/wwtOD+Qi8FRqrbus1y6Un86aax0k7pvgec H/W7UcyX+KnnIU/M9WfKIurXLLNdzOI= X-MC-Unique: GfWia7PbPfe3v8KFe1NdCA-1 From: Gerd Hoffmann To: seabios@seabios.org Cc: qemu-devel@nongnu.org, Gerd Hoffmann Subject: [PATCH v4 6/6] check for e820 conflict Date: Thu, 24 Aug 2023 10:57:56 +0200 Message-ID: <20230824085756.66732-7-kraxel@redhat.com> In-Reply-To: <20230824085756.66732-1-kraxel@redhat.com> References: <20230824085756.66732-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1692867566852100001 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 b52bd1d5054b..c7084f5e397e 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.41.0