From nobody Sun Feb 8 13:50:47 2026 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=1653605120; cv=none; d=zohomail.com; s=zohoarc; b=CwSMjhKx1H3LLOMKvkR9jbk97ON0G4Smno4YJEF3g7cFQHZRZXFsQQIeEbWdva5jzw1EubEBsHrS+v3Kj1bKaGGDxITfxr86AGffZpWd6NVrLpJUIESfciCDLGQzGjd72o/tRyRX4YEoe7CuFSFtbsmykH+eKijmfgmRkYMBg24= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653605120; h=Content-Type:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=DHI9Ww5YYmOhzi49jaGrBH7kwws0GhGaMNiclxcdSlQ=; b=AaQM8rjUZGpvsSC3Tode+Ld4PzA7STt3cFSj4rZPbNRk7xyzWoDUPxT8KhrFaAqMxUMWyPuqIHQfLg6WOxNfzBypXYc0Ulr0TTUHk/UBHsJF0e+FkYYCmYmB5UDJLESDdGJP4N6SVG9dEQ388m5elkL6MDU00G9WtUyr3G/wOUA= 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 1653605120459500.30537972736226; Thu, 26 May 2022 15:45:20 -0700 (PDT) Received: from localhost ([::1]:48662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nuMEI-00005j-3G for importer@patchew.org; Thu, 26 May 2022 18:45:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35992) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuMCv-0007Lx-6h for qemu-devel@nongnu.org; Thu, 26 May 2022 18:43:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:24073) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuMCs-0002Si-7L for qemu-devel@nongnu.org; Thu, 26 May 2022 18:43:51 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-653-XY6CggGdMdqj54hOtdBq_A-1; Thu, 26 May 2022 18:43:48 -0400 Received: by mail-ej1-f72.google.com with SMTP id k7-20020a1709062a4700b006fe92440164so1486353eje.23 for ; Thu, 26 May 2022 15:43:47 -0700 (PDT) Received: from redhat.com ([2.55.29.191]) by smtp.gmail.com with ESMTPSA id me2-20020a170906aec200b006f3ef214dd0sm897867ejb.54.2022.05.26.15.43.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 15:43:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653605029; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=DHI9Ww5YYmOhzi49jaGrBH7kwws0GhGaMNiclxcdSlQ=; b=PqT3y3OMq/lSj2MFdmtxqXJujvlN8q+1BdEYjRG61ZSwS3E+Nr/6t28YBDw8dabP+pFkHf PhJtvAqyDJAgjij1oZyH9s8AMknhAcL8p8el/NQkDztB5Z9ZxBApAgSpkzxWmaQntsNAc6 /oNz6y2jqF2dmL6Yg9FuugQypwP5i0w= X-MC-Unique: XY6CggGdMdqj54hOtdBq_A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=DHI9Ww5YYmOhzi49jaGrBH7kwws0GhGaMNiclxcdSlQ=; b=hzmc2otd7NOxn+NJtl+IDXhdAE8XD9lWIW+9tBdhpiYXK/inUFxWzT02Ocm6spp8Xv s3ihCu9yPrJAyWHqGhMlvJ301EBzXseLBTqTaVnEm2Z40bLetsWvM4i7AQ4mayUNZc68 J4cB3A8i/tgz+aKC6aoOSGLxj3RYitF6tKOVzU8ui94vs/WIeuXuKSy8P/sRyGNPxU7S 7HPOfLZ2jxtEDl2qsfkMr7TxXr37CNhwgQsiJeNdtZQERtPIAvYyIA5eOsg2v9i8Ldhf 0dIF/rrVEx0DcS4de3zUrHu1Mdw5+LuTjT7C7J/GHGCN0rqpysoQCFPAyqW/HA6iPlgL b1ew== X-Gm-Message-State: AOAM5312dh88xus/g3pwmIT+lSHEpFK7DF9oNpfx+5jkdbCC6r8zPPpv /E6feDCYy66VFVmaQpwlU6tq9On+tIwsFk0uZGKTruvParBrOFa/UlROd8G9ZQH+eLhEj2Wz4Rt TufDWPMS7osChMqOgLxUh5cK5X5EbWTow3EbbKbCUUyqlhoU5tyISkt5jQ81A X-Received: by 2002:a05:6402:2994:b0:42b:7c29:dcb with SMTP id eq20-20020a056402299400b0042b7c290dcbmr18450234edb.182.1653605026702; Thu, 26 May 2022 15:43:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+dglzmQuRkU9n5u+fWHRtGGr3WCVd3hTQOwocR2w4kaDJD0EjHnpnbPNqAhFGDVUSAvoShw== X-Received: by 2002:a05:6402:2994:b0:42b:7c29:dcb with SMTP id eq20-20020a056402299400b0042b7c290dcbmr18450211edb.182.1653605026298; Thu, 26 May 2022 15:43:46 -0700 (PDT) Date: Thu, 26 May 2022 18:43:43 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: BALATON Zoltan , qemu-ppc@nongnu.org Subject: [PATCH] ppc: fix boot with sam460ex Message-ID: <20220526224229.95183-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @redhat.com) X-ZM-MESSAGEID: 1653605121045100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Recent changes to pcie_host corrected size of its internal region to match what it expects - only the low 28 bits are ever decoded. Previous code just ignored bit 29 (if size was 1 << 29) in the address which does not make much sense. We are now asserting on size > 1 << 28 instead, but it so happened that ppc actually allows guest to configure as large a size as it wants to, and current firmware set it to 1 << 29. With just qemu-system-ppc -M sam460ex this triggers an assert which seems to happen when the guest (board firmware?) writes a value to CFGMSK reg: (gdb) bt This is done in the board firmware here: https://git.qemu.org/?p=3Du-boot-sam460ex.git;a=3Dblob;f=3Darch/powerpc/cpu= /ppc4xx/4xx_pcie.c;h=3D13348be93dccc74c13ea043d6635a7f8ece4b5f0;hb=3DHEAD when trying to map config space. Note that what firmware does matches https://www.hardware.com.br/comunidade/switch-cisco/1128380/ So it's not clear what the proper fix should be. However, allowing guest to trigger an assert in qemu is not good practice a= nyway. For now let's just force the mask to 256MB on guest write, this way anything outside the expected address range is ignored. Fixes: commit 1f1a7b2269 ("include/hw/pci/pcie_host: Correct PCIE_MMCFG_SIZ= E_MAX") Reviewed-by: BALATON Zoltan Tested-by: BALATON Zoltan Signed-off-by: Michael S. Tsirkin Acked-by: C=C3=A9dric Le Goater --- Affected system is orphan so I guess I will merge the patch unless someone objects. hw/ppc/ppc440_uc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/ppc/ppc440_uc.c b/hw/ppc/ppc440_uc.c index 993e3ba955..a1ecf6dd1c 100644 --- a/hw/ppc/ppc440_uc.c +++ b/hw/ppc/ppc440_uc.c @@ -1180,6 +1180,14 @@ static void dcr_write_pcie(void *opaque, int dcrn, u= int32_t val) case PEGPL_CFGMSK: s->cfg_mask =3D val; size =3D ~(val & 0xfffffffe) + 1; + /* + * Firmware sets this register to E0000001. Why we are not sure, + * but the current guess is anything above PCIE_MMCFG_SIZE_MAX is + * ignored. + */ + if (size > PCIE_MMCFG_SIZE_MAX) { + size =3D PCIE_MMCFG_SIZE_MAX; + } pcie_host_mmcfg_update(PCIE_HOST_BRIDGE(s), val & 1, s->cfg_base, = size); break; case PEGPL_MSGBAH: --=20 MST