All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Henrique Barboza <danielhb413@gmail.com>
To: qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org, danielhb413@gmail.com,
	peter.maydell@linaro.org, richard.henderson@linaro.org,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"BALATON Zoltan" <balaton@eik.bme.hu>,
	"Cédric Le Goater" <clg@kaod.org>
Subject: [PULL 09/15] ppc: fix boot with sam460ex
Date: Tue, 21 Jun 2022 06:43:54 -0300	[thread overview]
Message-ID: <20220621094400.122800-10-danielhb413@gmail.com> (raw)
In-Reply-To: <20220621094400.122800-1-danielhb413@gmail.com>

From: "Michael S. Tsirkin" <mst@redhat.com>

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 PPC 4xx actually allows guest to configure different sizes, and some
firmwares seem to set it to 1 << 29.

This caused e.g. qemu-system-ppc -M sam460ex to exit with an assert when
the guest writes a value to CFGMSK register when trying to map config
space. This is done in the board firmware in ppc4xx_init_pcie_port() in
roms/u-boot-sam460ex/arch/powerpc/cpu/ppc4xx/4xx_pcie.c

It's not clear what the proper fix should be but for now let's force the
size to 256MB, so anything outside the expected address range is
ignored.

Fixes: commit 1f1a7b2269 ("include/hw/pci/pcie_host: Correct PCIE_MMCFG_SIZE_MAX")
Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu>
Tested-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20220526224229.95183-1-mst@redhat.com>
[danielhb: changed commit msg as BALATON Zoltan suggested]
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 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, uint32_t val)
     case PEGPL_CFGMSK:
         s->cfg_mask = val;
         size = ~(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 = PCIE_MMCFG_SIZE_MAX;
+        }
         pcie_host_mmcfg_update(PCIE_HOST_BRIDGE(s), val & 1, s->cfg_base, size);
         break;
     case PEGPL_MSGBAH:
-- 
2.36.1



  parent reply	other threads:[~2022-06-21  9:50 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-21  9:43 [PULL 00/15] ppc queue Daniel Henrique Barboza
2022-06-21  9:43 ` [PULL 01/15] target/ppc: Implemented vector divide instructions Daniel Henrique Barboza
2022-06-21  9:43 ` [PULL 02/15] target/ppc: Implemented vector divide quadword Daniel Henrique Barboza
2022-06-21  9:43 ` [PULL 03/15] target/ppc: Implemented vector divide extended word Daniel Henrique Barboza
2022-06-21  9:43 ` [PULL 04/15] host-utils: Implemented unsigned 256-by-128 division Daniel Henrique Barboza
2022-06-21  9:43 ` [PULL 05/15] host-utils: Implemented signed " Daniel Henrique Barboza
2022-06-21  9:43 ` [PULL 06/15] target/ppc: Implemented remaining vector divide extended Daniel Henrique Barboza
2022-06-21  9:43 ` [PULL 07/15] target/ppc: Implemented vector module word/doubleword Daniel Henrique Barboza
2022-06-21  9:43 ` [PULL 08/15] target/ppc: Implemented vector module quadword Daniel Henrique Barboza
2022-06-21  9:43 ` Daniel Henrique Barboza [this message]
2022-06-21  9:43 ` [PULL 10/15] target/ppc: fix vbpermd in big endian hosts Daniel Henrique Barboza
2022-06-21  9:43 ` [PULL 11/15] pnv/xive2: Access direct mapped thread contexts from all chips Daniel Henrique Barboza
2022-06-21  9:43 ` [PULL 12/15] ppc/pnv: fix extra indent spaces with DEFINE_PROP* Daniel Henrique Barboza
2022-06-21  9:43 ` [PULL 13/15] target/ppc: avoid int32 multiply overflow in int_helper.c Daniel Henrique Barboza
2022-06-21  9:43 ` [PULL 14/15] target/ppc: fix unreachable code in fpu_helper.c Daniel Henrique Barboza
2022-06-21  9:44 ` [PULL 15/15] target/ppc: cpu_init: Clean up stop state on cpu reset Daniel Henrique Barboza
2022-06-21 18:30 ` [PULL 00/15] ppc queue Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220621094400.122800-10-danielhb413@gmail.com \
    --to=danielhb413@gmail.com \
    --cc=balaton@eik.bme.hu \
    --cc=clg@kaod.org \
    --cc=mst@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.