From nobody Tue May 14 05:38:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1669035885; cv=none; d=zohomail.com; s=zohoarc; b=nJF/vTIZfogZoNz28mzVnjTXRNVj6/bAsAzkDcO+cofA8r2OeV0lM0EciJKG5ykohrNTWlWa1Rxybr04OsbAZL2w/68KMC68iUDIm8Jyn5IeM8GgmSuYW0HO6Hi0+FC0iNABycrDyL1GmrtMwMCh+SvpDztHnubFP5VI2vnZQGo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669035885; 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=/fy3otxZw6ZE+oTlIk3wvPM0q4nusXxE65lb2YK8oD0=; b=Z2Jr+QV9gmoPdGpcxLGQk/+S9LRB+9wQ9s9RnGt2H52mLOAo/UOcyqDQ9p+YkR8JhBmOCuPhzPq8YOaMHuQb+4zX8BjW+Pqfix8H/gpYXZ68y4x8tsAfpTYwWWFaO2zl7W3WZnFsvLBrXhaBY55WwdkKu6dXdD2k1lKVWw2aZZ0= 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 1669035885703549.2352321135335; Mon, 21 Nov 2022 05:04:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ox6S7-00055V-9T; Mon, 21 Nov 2022 08:03:11 -0500 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 1ox6Ri-0004sy-FF for qemu-devel@nongnu.org; Mon, 21 Nov 2022 08:02:49 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ox6Rg-0007R5-7y for qemu-devel@nongnu.org; Mon, 21 Nov 2022 08:02:45 -0500 Received: by mail-wr1-x432.google.com with SMTP id l14so865912wrw.13 for ; Mon, 21 Nov 2022 05:02:43 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id t1-20020a1c7701000000b003cf4d99fd2asm13296725wmi.6.2022.11.21.05.02.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 05:02:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=/fy3otxZw6ZE+oTlIk3wvPM0q4nusXxE65lb2YK8oD0=; b=yqOc0S5cXBvQgEkH+qa96NPz8VTW8MFBRWUibWYM8XCUAwqZVKfENnZacduBbPKv1y n2ck2Hnh1QdeshJtmWd5202qqJEq0CkxkCMAdHls0mWSrMgppDW9mbOBJDuPiQZOsvW+ Z2rz0PWFYnp5fe0Te6QL2kQ/iMNf8xPNJClrF9r8U7QItt4dGKs+aR+B/ChGPAs2rh+4 533XB44av4IeLtc4nT28t3uB4TwKMUdueTW2pN946hpiqPFg22/oONUfm3piee2R94iw F1iM0LkwU0EwYg1QDWy3Tr9xJ5ikLboVPtJgWbfYzCRDwskiY311lPvhqNuZoDHozKk4 XhSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/fy3otxZw6ZE+oTlIk3wvPM0q4nusXxE65lb2YK8oD0=; b=kdPMaWmyIoBsQagvkdEeuZV3a+pRVl4+kBPHt2aZumezXtqUZGC7Xbkd0fkEp7G3sJ S22Qv+l8YS0w3FuixZxLF+iyiimxVrn/EuMoWOacd5LK8EXnDdk2cLsQt0+HS22Ap9zo QoN61iepOO2mOCzjp0XP+tmKAwzcq+4Qq7ZTYwU0tQUXni0bsgMN7PDrAvInOk4ro/yo S7khCKrIu/MN4o2uDm+EHwiK1LfMqMifS5yn0y5Eacw9R0IZGHwqqRjl081IdgL3bPrz GhVNU01LhJFMlACDyCrXh4zUM3aLfDGKBK5eJEmsKhUHx6Ft9QDkni0M6HRiUUAHK6R/ cmGg== X-Gm-Message-State: ANoB5pnq2zYNpm5bXJ0731YHHAFG/03ko9JK93P9Fm9VgxvCzNM8d8SO lZr4112prsqEyiRvhb+p9IJf8OAm9yo3/w== X-Google-Smtp-Source: AA0mqf6piFIrdde/YFJww6y2vOGslrCLlnzBkQAKF+s5Cyga2kiSTA2PNjfA9KQebnNrjM3j4GGCZA== X-Received: by 2002:a5d:624c:0:b0:241:c4d2:259 with SMTP id m12-20020a5d624c000000b00241c4d20259mr3206772wrv.539.1669035761997; Mon, 21 Nov 2022 05:02:41 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 1/5] hw/sd: Fix sun4i allwinner-sdhost for U-Boot Date: Mon, 21 Nov 2022 13:02:35 +0000 Message-Id: <20221121130239.1138631-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221121130239.1138631-1-peter.maydell@linaro.org> References: <20221121130239.1138631-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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 @linaro.org) X-ZM-MESSAGEID: 1669035887660100001 Content-Type: text/plain; charset="utf-8" From: Strahinja Jankovic Trying to run U-Boot for Cubieboard (Allwinner A10) fails because it cannot access SD card. The problem is that FIFO register in current allwinner-sdhost implementation is at the address corresponding to Allwinner H3, but not A10. Linux kernel is not affected since Linux driver uses DMA access and does not use FIFO register for reading/writing. This patch adds new class parameter `is_sun4i` and based on that parameter uses register at offset 0x100 either as FIFO register (if sun4i) or as threshold register (if not sun4i; in this case register at 0x200 is FIFO register). Tested with U-Boot and Linux kernel image built for Cubieboard and OrangePi PC. Signed-off-by: Strahinja Jankovic Reviewed-by: Peter Maydell Message-id: 20221112214900.24152-1-strahinja.p.jankovic@gmail.com Signed-off-by: Peter Maydell --- include/hw/sd/allwinner-sdhost.h | 1 + hw/sd/allwinner-sdhost.c | 67 ++++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 21 deletions(-) diff --git a/include/hw/sd/allwinner-sdhost.h b/include/hw/sd/allwinner-sdh= ost.h index bfe08ff4ef2..30c1e604041 100644 --- a/include/hw/sd/allwinner-sdhost.h +++ b/include/hw/sd/allwinner-sdhost.h @@ -130,6 +130,7 @@ struct AwSdHostClass { =20 /** Maximum buffer size in bytes per DMA descriptor */ size_t max_desc_size; + bool is_sun4i; =20 }; =20 diff --git a/hw/sd/allwinner-sdhost.c b/hw/sd/allwinner-sdhost.c index 455d6eabf64..51e5e908307 100644 --- a/hw/sd/allwinner-sdhost.c +++ b/hw/sd/allwinner-sdhost.c @@ -65,7 +65,7 @@ enum { REG_SD_DLBA =3D 0x84, /* Descriptor List Base Address */ REG_SD_IDST =3D 0x88, /* Internal DMA Controller Status */ REG_SD_IDIE =3D 0x8C, /* Internal DMA Controller IRQ Enable */ - REG_SD_THLDC =3D 0x100, /* Card Threshold Control */ + REG_SD_THLDC =3D 0x100, /* Card Threshold Control / FIFO (sun4i o= nly)*/ REG_SD_DSBD =3D 0x10C, /* eMMC DDR Start Bit Detection Control */ REG_SD_RES_CRC =3D 0x110, /* Response CRC from card/eMMC */ REG_SD_DATA7_CRC =3D 0x114, /* CRC Data 7 from card/eMMC */ @@ -415,10 +415,29 @@ static void allwinner_sdhost_dma(AwSdHostState *s) } } =20 +static uint32_t allwinner_sdhost_fifo_read(AwSdHostState *s) +{ + uint32_t res =3D 0; + + if (sdbus_data_ready(&s->sdbus)) { + sdbus_read_data(&s->sdbus, &res, sizeof(uint32_t)); + le32_to_cpus(&res); + allwinner_sdhost_update_transfer_cnt(s, sizeof(uint32_t)); + allwinner_sdhost_auto_stop(s); + allwinner_sdhost_update_irq(s); + } else { + qemu_log_mask(LOG_GUEST_ERROR, "%s: no data ready on SD bus\n", + __func__); + } + + return res; +} + static uint64_t allwinner_sdhost_read(void *opaque, hwaddr offset, unsigned size) { AwSdHostState *s =3D AW_SDHOST(opaque); + AwSdHostClass *sc =3D AW_SDHOST_GET_CLASS(s); uint32_t res =3D 0; =20 switch (offset) { @@ -508,8 +527,12 @@ static uint64_t allwinner_sdhost_read(void *opaque, hw= addr offset, case REG_SD_IDIE: /* Internal DMA Controller Interrupt Enable */ res =3D s->dmac_irq; break; - case REG_SD_THLDC: /* Card Threshold Control */ - res =3D s->card_threshold; + case REG_SD_THLDC: /* Card Threshold Control or FIFO register (sun= 4i) */ + if (sc->is_sun4i) { + res =3D allwinner_sdhost_fifo_read(s); + } else { + res =3D s->card_threshold; + } break; case REG_SD_DSBD: /* eMMC DDR Start Bit Detection Control */ res =3D s->startbit_detect; @@ -531,16 +554,7 @@ static uint64_t allwinner_sdhost_read(void *opaque, hw= addr offset, res =3D s->status_crc; break; case REG_SD_FIFO: /* Read/Write FIFO */ - if (sdbus_data_ready(&s->sdbus)) { - sdbus_read_data(&s->sdbus, &res, sizeof(uint32_t)); - le32_to_cpus(&res); - allwinner_sdhost_update_transfer_cnt(s, sizeof(uint32_t)); - allwinner_sdhost_auto_stop(s); - allwinner_sdhost_update_irq(s); - } else { - qemu_log_mask(LOG_GUEST_ERROR, "%s: no data ready on SD bus\n", - __func__); - } + res =3D allwinner_sdhost_fifo_read(s); break; default: qemu_log_mask(LOG_GUEST_ERROR, "%s: out-of-bounds offset %" @@ -553,11 +567,20 @@ static uint64_t allwinner_sdhost_read(void *opaque, h= waddr offset, return res; } =20 +static void allwinner_sdhost_fifo_write(AwSdHostState *s, uint64_t value) +{ + uint32_t u32 =3D cpu_to_le32(value); + sdbus_write_data(&s->sdbus, &u32, sizeof(u32)); + allwinner_sdhost_update_transfer_cnt(s, sizeof(u32)); + allwinner_sdhost_auto_stop(s); + allwinner_sdhost_update_irq(s); +} + static void allwinner_sdhost_write(void *opaque, hwaddr offset, uint64_t value, unsigned size) { AwSdHostState *s =3D AW_SDHOST(opaque); - uint32_t u32; + AwSdHostClass *sc =3D AW_SDHOST_GET_CLASS(s); =20 trace_allwinner_sdhost_write(offset, value, size); =20 @@ -657,18 +680,18 @@ static void allwinner_sdhost_write(void *opaque, hwad= dr offset, s->dmac_irq =3D value; allwinner_sdhost_update_irq(s); break; - case REG_SD_THLDC: /* Card Threshold Control */ - s->card_threshold =3D value; + case REG_SD_THLDC: /* Card Threshold Control or FIFO (sun4i) */ + if (sc->is_sun4i) { + allwinner_sdhost_fifo_write(s, value); + } else { + s->card_threshold =3D value; + } break; case REG_SD_DSBD: /* eMMC DDR Start Bit Detection Control */ s->startbit_detect =3D value; break; case REG_SD_FIFO: /* Read/Write FIFO */ - u32 =3D cpu_to_le32(value); - sdbus_write_data(&s->sdbus, &u32, sizeof(u32)); - allwinner_sdhost_update_transfer_cnt(s, sizeof(u32)); - allwinner_sdhost_auto_stop(s); - allwinner_sdhost_update_irq(s); + allwinner_sdhost_fifo_write(s, value); break; case REG_SD_RES_CRC: /* Response CRC from card/eMMC */ case REG_SD_DATA7_CRC: /* CRC Data 7 from card/eMMC */ @@ -834,12 +857,14 @@ static void allwinner_sdhost_sun4i_class_init(ObjectC= lass *klass, void *data) { AwSdHostClass *sc =3D AW_SDHOST_CLASS(klass); sc->max_desc_size =3D 8 * KiB; + sc->is_sun4i =3D true; } =20 static void allwinner_sdhost_sun5i_class_init(ObjectClass *klass, void *da= ta) { AwSdHostClass *sc =3D AW_SDHOST_CLASS(klass); sc->max_desc_size =3D 64 * KiB; + sc->is_sun4i =3D false; } =20 static const TypeInfo allwinner_sdhost_info =3D { --=20 2.25.1 From nobody Tue May 14 05:38:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1669035797; cv=none; d=zohomail.com; s=zohoarc; b=W98MbDTOp0GRfz26SMWNaWq1cDVpE1qWzQv9/qoJY4djumdHoMYArLb9/RIVPxngIePdQG4brworQe9NCf08Zu/R6gVYPpjTjxd3l+DR9B50E4SDvN6exbdrbIuKDBQpOaUD++fk0KKRIrXsY/d10bxXVRu/bhNoCS+kNpFC5Qg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669035797; h=Content-Type: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=/Z8xa5pV0nteWKUcNsZsbmwAjwoF7nCHZABgLKiuNBc=; b=bRi+GdsexGEPBRqcKT+k8KEZ0zAFs1xgvxi2nEEAzzXh0nE13TwQnZFaqXEOP0e/0qxFLL+/XvxpuCEk96uzZ2wQWgHtKObDP7UHZcM3tDfGt9MK7GQknzHMRpn/OF/otUt1XGn9ZjO3+BJ3E9oh5R+MXpNKvgvT51d/OCOdicg= 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 1669035797054829.3371224489276; Mon, 21 Nov 2022 05:03:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ox6SA-0005AV-2T; Mon, 21 Nov 2022 08:03:14 -0500 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 1ox6Rj-0004t1-87 for qemu-devel@nongnu.org; Mon, 21 Nov 2022 08:02:51 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ox6Rg-0007RE-RM for qemu-devel@nongnu.org; Mon, 21 Nov 2022 08:02:46 -0500 Received: by mail-wr1-x42b.google.com with SMTP id s5so2547505wru.1 for ; Mon, 21 Nov 2022 05:02:44 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id t1-20020a1c7701000000b003cf4d99fd2asm13296725wmi.6.2022.11.21.05.02.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 05:02:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=/Z8xa5pV0nteWKUcNsZsbmwAjwoF7nCHZABgLKiuNBc=; b=u0vBJY2/GEP6mrpTUgVjizWoyzr5wGdbBlFLK3uvJCUTPN/8eQQfT8PLiImHx8UL/2 7cyE5U8zR9oMFZvlqCcAMFyU64wJriAsr/KBljfLIzbNtpSZ2LfyqxoHeHfTxM/JRHeR 3M7/q4Lx5+eFt0ru+i3+ufeMeWttxPoWdC+tGIc0pbxyDECXpYnO4sUi+sDX78llxb1U wGhEKj64Z7ZxC5N7t+fS6StsEtzeTcCDH2sj0l3LEzRQ2p/NG3Di3NhxX04L0JB7tVwn yJmpsUiPqckFh5EV+d+aVQpGKUpDIpnWqgJgDgRYBCFBLavz5HjQ69lxh8cm/R7nZjgx jInw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/Z8xa5pV0nteWKUcNsZsbmwAjwoF7nCHZABgLKiuNBc=; b=jk1NOg1QASMPzCMcpRt0B2CcYSUJKcUJG00yd9RNmukXxSZ8WayS5JXc9wXfldLVNF 49MXX9dcqw/BayPF6+Ne99MVAVRjugV3C/5eyiij69o9nQCqWKnnsqArEK4Q8TLASHoP E7Wr0ZPA9gGlS9jSUaYYbpOQjUNDVpHxykzd6SaT7ivLS2DsOP487aSlAna4MxTGSOyq rQI1sj4R3cjENXpGuUFMFupSXy4hlWHBykWHtfu9R9H1awidknEM6o8I8C95XmS9SrRk k3aJ+RRPJJxkCjfmUf7hk9uYy3J6XsZ+ILc1/EXpM5WPi/dGQV7Oj1iiTdG0ddglA/9a d0Og== X-Gm-Message-State: ANoB5pmPobg8ogfY4TLJvo9W8LaIVtHFEUCyLO/4XQ2ndhYzrHZyYTck NWZE5pnm+55cdqZLrYZxMjXNrfLT6P2t8Q== X-Google-Smtp-Source: AA0mqf5wIBKsiAst9zmlIvWryiqsQ+d07WCx0c8KvEg4q0XMRbnOCQpAlwmryPBYBkyM4zxQoMCbjw== X-Received: by 2002:a5d:6dd1:0:b0:236:75a8:58d with SMTP id d17-20020a5d6dd1000000b0023675a8058dmr11306719wrz.295.1669035762875; Mon, 21 Nov 2022 05:02:42 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 2/5] hw/intc: clean-up access to GIC multi-byte registers Date: Mon, 21 Nov 2022 13:02:36 +0000 Message-Id: <20221121130239.1138631-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221121130239.1138631-1-peter.maydell@linaro.org> References: <20221121130239.1138631-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::42b; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42b.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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 @linaro.org) X-ZM-MESSAGEID: 1669035798977100003 From: Alex Benn=C3=A9e gic_dist_readb was returning a word value which just happened to work as a result of the way we OR the data together. Lets fix it so only the explicit byte is returned for each part of GICD_TYPER. I've changed the return type to uint8_t although the overflow is only detected with an explicit -Wconversion. Signed-off-by: Alex Benn=C3=A9e Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/intc/arm_gic.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 492b2421ab4..1a04144c38b 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -941,7 +941,7 @@ static void gic_complete_irq(GICState *s, int cpu, int = irq, MemTxAttrs attrs) gic_update(s); } =20 -static uint32_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs att= rs) +static uint8_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs attr= s) { GICState *s =3D (GICState *)opaque; uint32_t res; @@ -955,6 +955,7 @@ static uint32_t gic_dist_readb(void *opaque, hwaddr off= set, MemTxAttrs attrs) cm =3D 1 << cpu; if (offset < 0x100) { if (offset =3D=3D 0) { /* GICD_CTLR */ + /* We rely here on the only non-zero bits being in byte 0 */ if (s->security_extn && !attrs.secure) { /* The NS bank of this register is just an alias of the * EnableGrp1 bit in the S bank version. @@ -964,11 +965,14 @@ static uint32_t gic_dist_readb(void *opaque, hwaddr o= ffset, MemTxAttrs attrs) return s->ctlr; } } - if (offset =3D=3D 4) - /* Interrupt Controller Type Register */ - return ((s->num_irq / 32) - 1) - | ((s->num_cpu - 1) << 5) - | (s->security_extn << 10); + if (offset =3D=3D 4) { + /* GICD_TYPER byte 0 */ + return ((s->num_irq / 32) - 1) | ((s->num_cpu - 1) << 5); + } + if (offset =3D=3D 5) { + /* GICD_TYPER byte 1 */ + return (s->security_extn << 2); + } if (offset < 0x08) return 0; if (offset >=3D 0x80) { --=20 2.25.1 From nobody Tue May 14 05:38:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1669035943; cv=none; d=zohomail.com; s=zohoarc; b=RyMcVJTHNzC0zPaurm8cy+CkffvtDsIj2ZV1Dmd+3vhvVW8DRtmcCEr7OeueiCLawxsg74QIBBQP0lMbYiKksVRB2ko1L/ZI9mc22MKrZSW6FABnI28VVFPaczjUvyIKQ7u5ur7iQqz25ymPgbtwDv4LyFhdgkKldUYCPhtKTjU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669035943; h=Content-Type: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=dfFlEzHVaLMstRWNXLjvHFrz5cabOw805eWOhqpeeRA=; b=Xa/es5dt2HhOcAN8faRr4ZatTp+ZsD2RziTtlB1nPUnrPvPOVqR5RGCGWoT8kdoelXu3NV5FoJBHQNgkpli8UjSZ3BuQnyaZV2B1r9vhxOgV3+9cB3bwBt1kqgoDKHKfnUagPKv+LkZIX85lF+mlefYAPYWWgMZE/45ky2k3YK4= 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 1669035943791478.50940367293856; Mon, 21 Nov 2022 05:05:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ox6S7-00057l-SE; Mon, 21 Nov 2022 08:03:11 -0500 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 1ox6Rj-0004t8-Ql for qemu-devel@nongnu.org; Mon, 21 Nov 2022 08:02:51 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ox6Rh-0007RR-BD for qemu-devel@nongnu.org; Mon, 21 Nov 2022 08:02:47 -0500 Received: by mail-wr1-x429.google.com with SMTP id n3so3199822wrp.5 for ; Mon, 21 Nov 2022 05:02:44 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id t1-20020a1c7701000000b003cf4d99fd2asm13296725wmi.6.2022.11.21.05.02.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 05:02:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=dfFlEzHVaLMstRWNXLjvHFrz5cabOw805eWOhqpeeRA=; b=oRH6dU8H4Z236bsoFAPrx5sEQzZFLRnbWnl3g1h05XS4KMAzWIxLM2aPW+PZuDCbyI Psg1mNbm7Cc42RDyqihS4o6E4M7n87sdshXBdIV8sDuYriXcW24lRYTv7G+af4Ifnxj1 tZ7lqCVKSyfD+ior8v8WirrsqSmPygTi8my2ojI9WMbpCL+XdL/cnFkOaNT1GR++yuS+ kDj8U81Yxr+T3EC7r7KIK1+OvQnzqPRijZWqMqggwOaDobkUnnPAJjPNc8v1JP6/plOa MyfvQckEKzD5Dv4SywbIq7Vmpgtxdb2OeOHNpkkLSmrydDhNyajg28U2WsYhqbT9d9ub C50Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dfFlEzHVaLMstRWNXLjvHFrz5cabOw805eWOhqpeeRA=; b=c0FjH9NLKviS2C7l903Xf2iV+XsblVTiJvbYo1f0dcG8I3pFSeXC4yMen0dQFx9bOw M/0UXKn4gx49WmCEmMi8yUXvR/WUfyNiUovCLR0nNrV747DyEz/4jJbqErCIECEAGuQ6 LulclT0ynJRSWm23U90pYRMjXN3wfwLeUaPvx/W9YrLKELdqcdMFHNpDOpg9bHpkVtC+ C+Gp432RLjVQYVF0YiBRf++P/dcxxi/rPKmYAYA7M1f2Byy7uLgN8lXOYESjP1oUBxsB QzDXWlwKBAiJwUx0TbLxzP/+Xao+u2A3qy/5WgArtVjth/YhzO0yLVCFTTDJNGjomQy7 fz/Q== X-Gm-Message-State: ANoB5pnwedJDnB5L8uPfMMmrdPVwlIDsYsdl/zgpxzLC2/e/oVwKnDR5 N1KVukrijpWH3eGdhG5/uqrYFMGs9J+Byg== X-Google-Smtp-Source: AA0mqf4i/hpLD8r7rFy1suyyXP2UzjDy6IzkfswpybkF0Hboj4GLC8iepvSEP4gnXkOBBSLPr89mFg== X-Received: by 2002:adf:f50c:0:b0:22e:71db:47ba with SMTP id q12-20020adff50c000000b0022e71db47bamr3562016wro.359.1669035763731; Mon, 21 Nov 2022 05:02:43 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 3/5] hw/intc: add implementation of GICD_IIDR to Arm GIC Date: Mon, 21 Nov 2022 13:02:37 +0000 Message-Id: <20221121130239.1138631-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221121130239.1138631-1-peter.maydell@linaro.org> References: <20221121130239.1138631-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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 @linaro.org) X-ZM-MESSAGEID: 1669035946275100001 From: Alex Benn=C3=A9e a66a24585f (hw/intc/arm_gic: Implement read of GICC_IIDR) implemented this for the CPU interface register. The fact we don't implement it shows up when running Xen with -d guest_error which is definitely wrong because the guest is perfectly entitled to read it. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/intc/arm_gic.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 1a04144c38b..7a34bc0998a 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -973,8 +973,18 @@ static uint8_t gic_dist_readb(void *opaque, hwaddr off= set, MemTxAttrs attrs) /* GICD_TYPER byte 1 */ return (s->security_extn << 2); } - if (offset < 0x08) + if (offset =3D=3D 8) { + /* GICD_IIDR byte 0 */ + return 0x3b; /* Arm JEP106 identity */ + } + if (offset =3D=3D 9) { + /* GICD_IIDR byte 1 */ + return 0x04; /* Arm JEP106 identity */ + } + if (offset < 0x0c) { + /* All other bytes in this range are RAZ */ return 0; + } if (offset >=3D 0x80) { /* Interrupt Group Registers: these RAZ/WI if this is an NS * access to a GIC with the security extensions, or if the GIC --=20 2.25.1 From nobody Tue May 14 05:38:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1669035795; cv=none; d=zohomail.com; s=zohoarc; b=JKORTkr+LbMykTUNF6/QS8CoHARMSMXrzlaYITdJMALLhNPvV3ykOIlP8gb2Qj5kRXvSF4jRi/2uoEp9a/BCcFtmw5PcNiBg2toUcLTc5jD2rxkD27zTUn2XRXEHfgE8K/hm9wA1XrzoocMMMvYW9IcIGhfB+GpDnuLcBJ43SD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669035795; h=Content-Type: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=fwMWmQZd9sBU28g/akDXkXxjGE4RWYE++luBOirwphw=; b=VptgFC5qvjgDGdwEqngo7dAYufAQmkq8spvj/mhlQdOddFci3kTy/qKVT6DvglOdGmU+ff3gdf+lg/nrrRXlLj5Fp3SVrrUFgkFOP77R60VWU2RU7XJiayNjWBU4igeL6zDEgiQSHcBJ0dPNN+3zornrVJZaZkEFmqij3dItm+s= 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 1669035795853542.397181779014; Mon, 21 Nov 2022 05:03:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ox6S5-00051Q-GR; Mon, 21 Nov 2022 08:03:09 -0500 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 1ox6Rl-0004tk-CB for qemu-devel@nongnu.org; Mon, 21 Nov 2022 08:02:51 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ox6Ri-0007Rh-7Q for qemu-devel@nongnu.org; Mon, 21 Nov 2022 08:02:48 -0500 Received: by mail-wr1-x42e.google.com with SMTP id bs21so19758966wrb.4 for ; Mon, 21 Nov 2022 05:02:45 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id t1-20020a1c7701000000b003cf4d99fd2asm13296725wmi.6.2022.11.21.05.02.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 05:02:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=fwMWmQZd9sBU28g/akDXkXxjGE4RWYE++luBOirwphw=; b=kAR4MUmoRwrRSU8KC7umHfm4p3QC47OVr1XxAXqvwqUlFM2ZtUMOfqJt3fR21sOTIa gucZ1h6FMdIMUbK34uB8lTXwHuMyZyhXqfQ4zgXamtVbKksqWU2PqjkBaUCV5Dnfj5Cv ZaQdeEhx96OSi5C3WRWWM5dWEmDDF+crTJPJHGNU76rxzVIAS/QndCJgcGuXrSl1hxDA Hdz8PkxN0yFoCAJoDXkeuf6qOtJQHUsczc3YKmBUGMcn4tfZVjQekF5NBtlA8Oepd0rZ IEeGXgFriGiW2SvRWZM3BexfqEMVI91oFtSNOdO+VOHn7dZTR/CmuBqu9Vi0NMCA1hn5 /4Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fwMWmQZd9sBU28g/akDXkXxjGE4RWYE++luBOirwphw=; b=Xf0r/B764GCT49sX9x7vJIPJTiDmaIt/4Re6JHpOED1/DtDebQJ1XkltmQaSFU6ZR0 Rou2iLU4uUZWfBmGNDvukNNJEPRuwFoh6TJG9lFoljlsrqXAuM61F5gCsLJB+FRf/o3/ ulZ4qRS/r2+jEUV51KUAF2kpHtGCsy4J8jvDe+X1K2YO6r2jZFzkl4n/fIoz+Cmz8d0G xTX0Dl04UMDHkyisyQ+Wso9mEK/tVm3Oz2pePlLJzTt5Zg7dCiU807ZGzBGE2BFP1x2i TWdz1vtbnlrehNDD/KJI7Y+7+L7IfMggsHtPMEwh+g+hC6Rs88xnRW8K3G6W6sateBLi LcKg== X-Gm-Message-State: ANoB5pmElcyUsBs3Y/A5/isWiMOnm5ZOxdz6/zAWQIZHFJ1A1rxZcbD9 yMOQCV5OdeNwZTI2MYOPTdF+tLagAHkY/A== X-Google-Smtp-Source: AA0mqf7jSg4BROnamb+MO7AEA8J0mlQO/pWudGy7rk9ZpFkqgIj5p4WLM6PgZYuciNXYDs0frBCOcQ== X-Received: by 2002:adf:d84c:0:b0:236:6f1a:955 with SMTP id k12-20020adfd84c000000b002366f1a0955mr10713977wrl.111.1669035764695; Mon, 21 Nov 2022 05:02:44 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 4/5] tests/avocado/boot_linux.py: Bump aarch64 virt test timeout to 720s Date: Mon, 21 Nov 2022 13:02:38 +0000 Message-Id: <20221121130239.1138631-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221121130239.1138631-1-peter.maydell@linaro.org> References: <20221121130239.1138631-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::42e; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42e.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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 @linaro.org) X-ZM-MESSAGEID: 1669035797946100001 The two tests tests/avocado/boot_linux.py:BootLinuxAarch64.test_virt_tcg_gicv2 tests/avocado/boot_linux.py:BootLinuxAarch64.test_virt_tcg_gicv3 take quite a long time to run, and the current timeout of 240s is not enough for the tests to complete on slow machines: we've seen these tests time out in the gitlab CI in the 'avocado-system-alpine' CI job, for instance. The timeout is also insufficient for running the test with a debug build of QEMU: on my machine the tests take over 10 minutes to run in that config. Push the timeout up to 720s so that the test definitely has enough time to complete. Signed-off-by: Peter Maydell Reviewed-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/avocado/boot_linux.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/avocado/boot_linux.py b/tests/avocado/boot_linux.py index 571d33882ae..32adae6ff6a 100644 --- a/tests/avocado/boot_linux.py +++ b/tests/avocado/boot_linux.py @@ -64,7 +64,7 @@ class BootLinuxAarch64(LinuxTest): :avocado: tags=3Dmachine:virt :avocado: tags=3Dmachine:gic-version=3D2 """ - timeout =3D 240 + timeout =3D 720 =20 def add_common_args(self): self.vm.add_args('-bios', --=20 2.25.1 From nobody Tue May 14 05:38:02 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1669036100; cv=none; d=zohomail.com; s=zohoarc; b=gqFnKqHFy33joItWNFy4aDYUKbk9CY21adJ/h+YQNTTl4FOKcNtE1qwe8+1IX1fhaEi7FUzydFV71y/6Yc6BtCm/XmzKH1zPOAz3KuawXDQHo2LNXYVYiVfCX7lOMdKFCwKufO3oOifTjBxDNY49QHWNuLUAcPia+fQQ9He7Kyk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669036100; h=Content-Type: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=JBNmxcqLBxZag1unF7NOFteCv/IX3kebN57U4uPMAOo=; b=k9SmL9sIhwZyNN0V3OCOebW+IeVmxKtjCc3TU6A4xVWhLKj6BQjt718vZ/pPFzOpSXGxFRktux8kgM0NNmbpMZruLfOMc1NxQyL7uA5Q5XwtJz+QFXTV3lZOjZepiASVKWIJZ6/QaX9DJ+dmOvR3C+I7ACxLGaGXJfGxpNNBUeI= 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 1669036100634241.9590850060814; Mon, 21 Nov 2022 05:08:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ox6S6-00053K-B3; Mon, 21 Nov 2022 08:03:10 -0500 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 1ox6Rl-0004ti-Bt for qemu-devel@nongnu.org; Mon, 21 Nov 2022 08:02:51 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ox6Ri-0007Rw-SZ for qemu-devel@nongnu.org; Mon, 21 Nov 2022 08:02:48 -0500 Received: by mail-wr1-x432.google.com with SMTP id d1so7635095wrs.12 for ; Mon, 21 Nov 2022 05:02:46 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id t1-20020a1c7701000000b003cf4d99fd2asm13296725wmi.6.2022.11.21.05.02.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 05:02:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=JBNmxcqLBxZag1unF7NOFteCv/IX3kebN57U4uPMAOo=; b=iQXSb9MMFfTFM6CRTSJWyLnL0FFXWmI1IBXm1aM31ib39XyRZOR4Qbl99ZlnjMyqyb Z/PpSy7kKbx6YyFa4dbVLBdM25lr0weNPtpmnhD533eR2ZfUK7rt5bwta52d9cxwSn5c exkV+q5a2gKug0k47/p9B50BxiMKa81c2ODPc3V/tZq+by4j9gRxKuIG0CTICZ1e58sm Ofhlx3heaH3J5iEzynSJDL/gXqVf+D7MGgycnLis8Js8L7h5Bba/BvyCD51N8jRC4o+e gmH3ChApaD9KYWuXzkh+hebMF1BorVFR1nxZS29cgI4qHjRtMHMRdpeA5o8r7DE4jGOt dy2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JBNmxcqLBxZag1unF7NOFteCv/IX3kebN57U4uPMAOo=; b=u3cdohJ9GlvCkBAwTuxL+JS6CdfsQQpiJhDFN4wvkxKXsWeICe3mGLusk+Oj+4SKDQ FjogvDfqbaLcz6pbcLKHADB6Rlfd+kJ0vx9fPYUJ7EPBPnlOOgznitCIkYYl26+7fNVl joi8PSCiSebJ62DhUswK08xMULHQFAnF6IpajD/YCLqxHuFvyKy9o9Pka/bvxpEVIFGJ TpVbinUsy4mb5qNsR7/aFlkp2CBGg5Cz6gnqMGo+mtv2tpjNSkDDU3B+RXVlC5CPltbD g+E3WFaNCGidlzzQLGImCaCdnEA/cMn99aH+Bs7AuSzuF0n+n+NTDQBOB1945n5vpIUe jg8g== X-Gm-Message-State: ANoB5plvVvfpTzSDsSUKVe3Fs/pD3X31x8nyONAX1Mqm2r4KWi1PgWih agv1FQ5zwFWQNRXb21epZ1J2+OB7d10bCw== X-Google-Smtp-Source: AA0mqf5JO+jq2N6t3XACrwY3sp9+t1Xi5fm3RswBNRiHSwjFn8mGaTXiHRyXCMDGD2pW7kf322i33A== X-Received: by 2002:a05:6000:114b:b0:241:d199:1a04 with SMTP id d11-20020a056000114b00b00241d1991a04mr3782834wrx.227.1669035765534; Mon, 21 Nov 2022 05:02:45 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 5/5] target/arm: Limit LPA2 effective output address when TCR.DS == 0 Date: Mon, 21 Nov 2022 13:02:39 +0000 Message-Id: <20221121130239.1138631-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221121130239.1138631-1-peter.maydell@linaro.org> References: <20221121130239.1138631-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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 @linaro.org) X-ZM-MESSAGEID: 1669036101476100001 From: Ard Biesheuvel With LPA2, the effective output address size is at most 48 bits when TCR.DS =3D=3D 0. This case is currently unhandled in the page table walker, where we happily assume LVA/64k granule when outputsize > 48 and param.ds =3D=3D 0, resulting in the wrong conversion to be used from a page table descriptor to a physical address. if (outputsize > 48) { if (param.ds) { descaddr |=3D extract64(descriptor, 8, 2) << 50; } else { descaddr |=3D extract64(descriptor, 12, 4) << 48; } So cap the outputsize to 48 when TCR.DS is cleared, as per the architecture. Cc: Peter Maydell Cc: Philippe Mathieu-Daud=C3=A9 Cc: Richard Henderson Signed-off-by: Ard Biesheuvel Reviewed-by: Richard Henderson Message-id: 20221116170316.259695-1-ardb@kernel.org Signed-off-by: Peter Maydell --- target/arm/ptw.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 3745ac97234..9a6277d862f 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1222,6 +1222,14 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1T= ranslate *ptw, ps =3D MIN(ps, param.ps); assert(ps < ARRAY_SIZE(pamax_map)); outputsize =3D pamax_map[ps]; + + /* + * With LPA2, the effective output address (OA) size is at most 48= bits + * unless TCR.DS =3D=3D 1 + */ + if (!param.ds && param.gran !=3D Gran64K) { + outputsize =3D MIN(outputsize, 48); + } } else { param =3D aa32_va_parameters(env, address, mmu_idx); level =3D 1; --=20 2.25.1