From nobody Mon Sep 16 19:34:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683270750; cv=none; d=zohomail.com; s=zohoarc; b=UsPm3Eit+4bfQqhN9tPiAkJz2RycxVQT0zvukCcE2z1CTyNoqwOVFLzn3XXqFGyVOjbdyQ5liLDHL5yi619gXZXgtWO/bhUoWIQ06Dk1+GYaK6WvXzKyTz2jgKzh6OEEwPXThotk8JJhhf2L7+542Jm7meYQyS70pPtDAEE4aFQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683270750; 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=ILIkb92YfjNdVPvNemK23NPzdxpIvUqcxZkOvQcuD1w=; b=UhqC2POXTj1rPFkg3PENkQTpdBoWeiFCFAnPyMDvD3EZ9Qyi/hKwG1MuaSiuCOBNQrjhVADlao1zaH3q041U7G8J04eI0Y6gu+jOLGRV1dST6HguFFPN0X7UyLceegazyOEKWMlh5C4PtbBXKn+EvVrWHR6xZdwMPEpyReov7i4= 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+importer2=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 16832707500481017.0454739227956; Fri, 5 May 2023 00:12:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pupbG-0004mF-IQ; Fri, 05 May 2023 03:11:30 -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 1pupbC-0004lM-2t for qemu-devel@nongnu.org; Fri, 05 May 2023 03:11:29 -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 1pupbA-0000ec-3S for qemu-devel@nongnu.org; Fri, 05 May 2023 03:11:25 -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-179-rGMpx1XXMNmUxuFZU7NaWQ-1; Fri, 05 May 2023 03:11:19 -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 460EE185A79C; Fri, 5 May 2023 07:11:19 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.60]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F1EFD1121331; Fri, 5 May 2023 07:11:18 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) 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=1683270681; 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=DOV1chC7svV93bdmPy1cpzI6MdsPsARLM0ZnGNOn3aTlpOxD67cono+MewuXhY/NgDrdmB MzkOIVQRh9yywwQTAz3VwBBvgRQ6JYdnyhzbc3qfa5bE8mc9D/r8thY3+OoDcW343mElSQ sYmga58vEKyGqwk+I5bbcup7ZbJY4fI= X-MC-Unique: rGMpx1XXMNmUxuFZU7NaWQ-1 From: Gerd Hoffmann To: seabios@seabios.org Cc: qemu-devel@nongnu.org, Gerd Hoffmann Subject: [PATCH v3 1/6] better kvm detection 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 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+importer2=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: -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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683270751270100005 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 From nobody Mon Sep 16 19:34:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683270803; cv=none; d=zohomail.com; s=zohoarc; b=hrXfVn2OAqbKg46OdpCRzd2pV63X7LbHju5WAMozQU9a1iXi2RZyDZMV08r3e2YjbubYwTYWDqQhoitl6fI4p21z7uH6hM9rbf0sBsmRNzdJwNDTwgxl/OsYH5xJfe32hBWHuanN9IVzZnXJibMrAfDFlYRUN/r0lkVICq17SqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683270803; 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=CXPCS+kJxlRKApXWmifHvPqleJ4x39uVxri/m9e/MXc=; b=loaU4aDJfitVHlZCF35lI0SIAAor7jMov3nFnLWgrwCkIUwf/+rNi+tc0KsjEOGFXYTc8j27cVc3euQVn86rnJz72et+W0BNcSGepuLoTH/rZuTtrwAq6lDY3lNuJFk3Qd89+r5/SgKjrUqIMV8bDbnqGvSbQsIF9Rny8lVvYzE= 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+importer2=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 1683270803440134.93774090490012; Fri, 5 May 2023 00:13:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pupbH-0004mX-Fa; 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 1pupbD-0004lQ-MA for qemu-devel@nongnu.org; Fri, 05 May 2023 03:11:29 -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 1pupbA-0000f8-6U for qemu-devel@nongnu.org; Fri, 05 May 2023 03:11:27 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [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 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 9655E3806062; Fri, 5 May 2023 07:11:20 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.60]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B12E492C13; Fri, 5 May 2023 07:11:20 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) 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=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=CXPCS+kJxlRKApXWmifHvPqleJ4x39uVxri/m9e/MXc=; b=CWSVdE1ckorRQP7ShFShC3DvuyHgV/1lRsxr3z894Ccp2H7B4T+QF3RAu6bxw2reL4/vNS zQsNO2bL0uybwsLEfFChPKrQ3jyUroP02bKSTRVqN7PdI+5atlTpmcfGBcLQ2sAohU+3oZ x0gdmj5VMzAqoQbnI+GlaBbB9fcBWfA= X-MC-Unique: jEEDYcpxNWutIkrtl8jEWw-1 From: Gerd Hoffmann To: seabios@seabios.org Cc: qemu-devel@nongnu.org, Gerd Hoffmann Subject: [PATCH v3 2/6] detect physical address space size 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 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+importer2=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: -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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683270804599100001 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 From nobody Mon Sep 16 19:34:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683270756; cv=none; d=zohomail.com; s=zohoarc; b=MQsJ7mChcgbiFEqsU9ev4L99fDhczjAyG04MXFM0dSNw3+pBYCOxJbepmfSelq5wiL8Ng9WZuLa55NfV9xKTBS8HtcKdhewoUF/cQN7nSsCqLrD+wM6wI0unn5N9b6kebnFEQFgsFs8cw0G1qX832sje9+9HBTLgYPY+Dww8Ddo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683270756; 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=Hnbw/1xdXtcYTeMJ6hzBbi7QP8BTZHfCWmXXBwn82Jg=; b=KqNT2O9M5cCLvr+pp8hSPwSWylNfJ1emEE6b+NACkLZRsq50odDMur3PF6qlcSQrCnscY0+LHfXNXO2sF9bRQoPqXSX40pGXHc53KYTVqt7pn1xjvhvelILF9XkAWk6x+tptJcGOyhUdNS5mQD7WqF7Q4QXxYDaZeLE8+wi7wL4= 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+importer2=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 168327075661095.48080806563394; Fri, 5 May 2023 00:12:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pupbK-0004ns-Ji; Fri, 05 May 2023 03:11:34 -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 1pupbF-0004lY-1q 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 1pupbA-0000f6-3J 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-618-jbST49ghO-CAaWscygLTJw-1; Fri, 05 May 2023 03:11:20 -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 8D28580080E; Fri, 5 May 2023 07:11:20 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.60]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5D76AC15BA0; Fri, 5 May 2023 07:11:20 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) 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=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=Hnbw/1xdXtcYTeMJ6hzBbi7QP8BTZHfCWmXXBwn82Jg=; b=Sw67x8iVilhFs+CUg2uiVtMriI0PLHsNxNJMh2sqEHhC6yBJzcOBhit11/p5ziQ5C3svd5 LbE3TM6a0iY/5rWl1NYafOMplKlkjFGK2vZT0s96YIGQAXuybnX0NCZbGQ0ZKBzubRo1jn sLgcWGd+anxS3aFX1mKn21ySbx9V1fo= X-MC-Unique: jbST49ghO-CAaWscygLTJw-1 From: Gerd Hoffmann To: seabios@seabios.org Cc: qemu-devel@nongnu.org, Gerd Hoffmann Subject: [PATCH v3 3/6] move 64bit pci window to end of address space 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 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+importer2=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: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=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=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683270757014100001 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 From nobody Mon Sep 16 19:34:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683270787; cv=none; d=zohomail.com; s=zohoarc; b=a9Xz9ZrM3Q/RADW9tbSd4QXdp770LTGq86xZkLTT56+P0icLQ0dbeD1BhlcbkwA5I/VPIDrTo3EpASnjUUQ1+0bT0KIBB4oCqt+HgDbxhCVWp0OH0XceZwiY8bHfP7++TSk8qrwZqauDAQVi/pld9mnm5ltr2H8CQCtLfCsAgps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683270787; 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=Rlu4Dbr7nV6FubMH9YcoNGq9K+JqpiH6IUzURmGHJAM=; b=f7YwHkJPU7Gx4+gyShk834FbjXy/CQPfYLZSqyJ8e5cxt9lXVD/Nx6sQcfYrcugJFF5lDQyTo/jBzsPJSOixTiC5LUZknNQ+NvlJWrdNYD5LxvYal97zUCPeR5M8KBS81uJe05wQxJja71RbmtmusIHDlKHuJZTeYKxk5DJvxFs= 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+importer2=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 1683270787544700.6803571932667; Fri, 5 May 2023 00:13:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pupbH-0004mg-Eg; 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-0004lX-GH for qemu-devel@nongnu.org; Fri, 05 May 2023 03:11:29 -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 1pupbC-0000fZ-H1 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-43-hqkWumDROCWII-tQW30O-Q-1; Fri, 05 May 2023 03:11:22 -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 E9393811E7C; Fri, 5 May 2023 07:11:21 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.60]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A8C46C15BA0; Fri, 5 May 2023 07:11:21 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) 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=1683270685; 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=JdUczE0sg5R1qbxbgSfx2AXDJkhHOpvFUiQI0d8Vn3pkzondc9ESsNBPfavYVOOrRoKEF9 eGIAobrkvNRY1ENdj3q0V2rIXLEIy/VHR50VdbrMLRYZ4ET1OmuKt060vo74O6dWsNhqr4 qPvznEcnTOrE1z1yMIAYzSeAz7gZlNo= X-MC-Unique: hqkWumDROCWII-tQW30O-Q-1 From: Gerd Hoffmann To: seabios@seabios.org Cc: qemu-devel@nongnu.org, Gerd Hoffmann Subject: [PATCH v3 4/6] be less conservative with the 64bit pci io window 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 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+importer2=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: -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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683270788146100001 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 From nobody Mon Sep 16 19:34:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683270782; cv=none; d=zohomail.com; s=zohoarc; b=m38PECnxpr7JQvh6t1QW2Y4C0h4zVX+OcLRDZqbKh757nkxiGSiiZUtqDz4sLfnJA2HASKxtA1xgTUArLKwhUb87Y07U3ZWHGbSaskAcED4w5/RHdMC86CKXy5dk4EXGaD58kJMSw8md6FFl+AEKC88xChG9h5NzkVmWWY06Z9o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683270782; 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=B/t7UcD8DC0shzbA+m7RqcSGtgUOMGokV2Dyf5qhc5E=; b=EIXEn6bMfqgOGPIb17W+BfN5w86bDAFncTUxRKz2sLWAx8ccSTZrun5vy3LqbKMSCF9UkP5Wa+1oeNBQHREzeu4FRrZ6AfTKr6yao00ixJT/dINymhQQWbMLEEqnNEGzIUzybs3i9QzGGaZOVVQ4bPXD3jZkMJBMZF7qDQRjabk= 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+importer2=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 1683270782136258.3713944086387; Fri, 5 May 2023 00:13:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pupbW-0004tw-56; Fri, 05 May 2023 03:11:47 -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 1pupbR-0004sN-As for qemu-devel@nongnu.org; Fri, 05 May 2023 03:11:41 -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 1pupbC-0000fT-IV for qemu-devel@nongnu.org; Fri, 05 May 2023 03:11:41 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [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 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 EC20D3806062; Fri, 5 May 2023 07:11:21 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.60]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AB0F12026D16; Fri, 5 May 2023 07:11:21 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) 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=1683270685; 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=WOV1MSBWVvxitV49bXhNWkC0H/sp7lwx3F3iFu/nznb1v/F9U/RvoixraKpbOBf59Lvt0V tKid/Sk+2AmeG9GvB1IK8CsfzlSuppC0r3v4grKBqusBZI00ddE9kQXnoBisdDneiz472z QJ3+DO7+K2sTqseUnxuh9yAoKb3UW+k= X-MC-Unique: UNZRdrcENpCLTHh6j0zD4w-1 From: Gerd Hoffmann To: seabios@seabios.org Cc: qemu-devel@nongnu.org, Gerd Hoffmann Subject: [PATCH v3 5/6] qemu: log reservations in fw_cfg e820 table 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 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+importer2=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: -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, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683270782479100003 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 From nobody Mon Sep 16 19:34:28 2024 Delivered-To: importer2@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+importer2=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=DY7annIIG+3xuUX/bg+H2Kk9P2PfXbISkWBaRv8cCemp+JfG6bWbyE/27yQhhxxJR3S6gXyX+lChCPSFzkmAjLfIIxmKIeawz+g4DF8zVlQqyRMWK8hAdJTDZ74Z2Z9qBbdbaVQvShEZhg8bWOOP8AaXi7rrlLNpqHQ955mx+G4= 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=fe627ewkmTEHCbf9W38rLvlsUJrB2uaYeuEhRn5bs1gtkuq+kFwG9F5ZV6+JCn/jr19nXAc5uw/P2HzAKcE4D0dmH7l0AcpXsycZXb/PMQ/2lvb0NXgE5GlWIhYvmVoOUkHxpBOXLK2jAngXlKQk0c3w3WTADW9zlJBCNAi1Rzo= 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+importer2=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 1683270797696643.3691499258005; 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+importer2=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683270799481100001 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