From nobody Thu Apr 10 04:49:24 2025 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1642703793; cv=none; d=zohomail.com; s=zohoarc; b=S6V9VhTciwxI+jim7VkTLexjg9NhVOs8o1lwBelzkIozUdeIIUx6vzoOdelhrcfnb2jXT08gMOd89jJtM5Njzt8HNJxbLx6Pu3wq+nHMiPOTgz5Qe7xkLZnfWghaV8DnQ6Og8naS/ZdT7kX6Zewl0vroJcI4nO7GACHcS9vxP7M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642703793; h=Content-Transfer-Encoding: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=j8Qp4NuYu0YJhHUjPY9NQXtXjfHNFnQLrtAOoxiHuYQ=; b=FpW50loMpOIu6Qaat9kZh95sZv3O1ZW+sXbuvgqa5eds8M8/MIgKhHhITmHoyefG8vhoVaLvxIqpCcLB/xQyVQta0Q6HN8KUAOE60aXCuYaUm8zXtjAEAZOBYsF2kxQjIKj1ey08kjT/jjID6SRci4UmIzB00hi93Mq9iwT57Yw= 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 1642703793402484.7752409994516; Thu, 20 Jan 2022 10:36:33 -0800 (PST) Received: from localhost ([::1]:56330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAcIR-0002sD-PX for importer@patchew.org; Thu, 20 Jan 2022 13:36:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42848) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAWgW-0004G4-NF for qemu-devel@nongnu.org; Thu, 20 Jan 2022 07:37:02 -0500 Received: from [2a00:1450:4864:20::335] (port=37566 helo=mail-wm1-x335.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nAWgU-0003HZ-Or for qemu-devel@nongnu.org; Thu, 20 Jan 2022 07:37:00 -0500 Received: by mail-wm1-x335.google.com with SMTP id l12-20020a7bc34c000000b003467c58cbdfso21599637wmj.2 for ; Thu, 20 Jan 2022 04:36:58 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id t8sm7993324wmq.43.2022.01.20.04.36.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jan 2022 04:36:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=j8Qp4NuYu0YJhHUjPY9NQXtXjfHNFnQLrtAOoxiHuYQ=; b=LSNtpn9QM+Uo+XBQ5jseyw8sBh+09dGSBGWCsS1CeiptOIJSd9JoH1of2NDDCc4h9/ L+q2OwBSvJtm8frZ2EQSaoD0QscScN051PecyFGvE3WYHFXLwzrjHmUjd2AAQmSBCfbJ 7XwzyNoHUQryuDL+zTpph9X2NLBytHiuQb0cEJ88Gy2Mku0ww6vCQNic7jB0jpMgeVWV urqQK/Jyhio8GK/n6Cu/73v3KXwEn5jorUFa6TN8DYNwgs3khufeExiEGrFL/Foo74/0 4+Tf3LuGXF1LWvuuQxd2oveKGwTULafQ2t327Yow9etveQzFlyWQRWcI8nTZYd/J+QNH kfJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=j8Qp4NuYu0YJhHUjPY9NQXtXjfHNFnQLrtAOoxiHuYQ=; b=S+s5vvAo0hqvQR9O8Kip3XldNZozdQhQ5q9qGyEBpS9TRPJd6uxXq4bGn6X1T4Sxra b4I6eXoQGDovbdTfGCEB4g9XSIbbo+IVb/4FiXvWE/2rpPeDHN5/H3G0+f3kDln+x+qs vxMuGkRd93ToSQ1Gx+a1HnJwh1LXGkaRT3xD7NawGpp7RDrYzmjgvN8q5LXWw0uc9ix+ p53SzWnaoHczL/gRqtLKKK2wCiTU8oZAdF4qy8avSqbnaIJ0zePaMzNXsa3lT28y9qFI +emHR3LI/mwjEjhvrcyNWA7Wr5GNPkMTeOERIJxGUBlkVDEU75ljjVoBbA4C3YhqqTFM beaQ== X-Gm-Message-State: AOAM531wo3jYxdEZmutPMlQjGc39HXYUrUa0xuqJTSSwLN7ZiZzK1dlp Bn7SzUYx8wzkl3oOS51MMOV3XK7g4AQAiA== X-Google-Smtp-Source: ABdhPJwJaG0RiI+byotdZODeUKzwS8jLAD2v0ndgxvedAYNlRTF3k1JN4fKNzmRxIJU432BGQICjQw== X-Received: by 2002:a5d:5601:: with SMTP id l1mr33999201wrv.213.1642682217519; Thu, 20 Jan 2022 04:36:57 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 20/38] hw/arm/virt: Disable highmem devices that don't fit in the PA range Date: Thu, 20 Jan 2022 12:36:12 +0000 Message-Id: <20220120123630.267975-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220120123630.267975-1-peter.maydell@linaro.org> References: <20220120123630.267975-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::335 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1642703794398100001 Content-Type: text/plain; charset="utf-8" From: Marc Zyngier In order to only keep the highmem devices that actually fit in the PA range, check their location against the range and update highest_gpa if they fit. If they don't, mark them as disabled. Signed-off-by: Marc Zyngier Reviewed-by: Eric Auger Message-id: 20220114140741.1358263-6-maz@kernel.org Signed-off-by: Peter Maydell --- hw/arm/virt.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 8627f5ab953..8d02c2267d0 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1719,21 +1719,43 @@ static void virt_set_memmap(VirtMachineState *vms, = int pa_bits) base =3D vms->memmap[VIRT_MEM].base + LEGACY_RAMLIMIT_BYTES; } =20 + /* We know for sure that at least the memory fits in the PA space */ + vms->highest_gpa =3D memtop - 1; + for (i =3D VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) { hwaddr size =3D extended_memmap[i].size; + bool fits; =20 base =3D ROUND_UP(base, size); vms->memmap[i].base =3D base; vms->memmap[i].size =3D size; + + /* + * Check each device to see if they fit in the PA space, + * moving highest_gpa as we go. + * + * For each device that doesn't fit, disable it. + */ + fits =3D (base + size) <=3D BIT_ULL(pa_bits); + if (fits) { + vms->highest_gpa =3D base + size - 1; + } + + switch (i) { + case VIRT_HIGH_GIC_REDIST2: + vms->highmem_redists &=3D fits; + break; + case VIRT_HIGH_PCIE_ECAM: + vms->highmem_ecam &=3D fits; + break; + case VIRT_HIGH_PCIE_MMIO: + vms->highmem_mmio &=3D fits; + break; + } + base +=3D size; } =20 - /* - * If base fits within pa_bits, all good. If it doesn't, limit it - * to the end of RAM, which is guaranteed to fit within pa_bits. - */ - vms->highest_gpa =3D (base <=3D BIT_ULL(pa_bits) ? base : memtop) - 1; - if (device_memory_size > 0) { ms->device_memory =3D g_malloc0(sizeof(*ms->device_memory)); ms->device_memory->base =3D device_memory_base; --=20 2.25.1