From patchwork Thu Jul 11 13:18:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 812063 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp218372wrs; Thu, 11 Jul 2024 06:19:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVBszJeif0Z9je1BrxDuNGjYS0ZL5Acq+c2qkSQzJIUGOebp0wqTk3JsVGlJ1IkKvg9CdSk/xjbseWde5MBY6Lm X-Google-Smtp-Source: AGHT+IE1QZywa0sVN1EVc+hQs4LpBX2UcagkBQx3KOfvS4luPXwt5fZMxN1DgVt0H1R+y9XEE56i X-Received: by 2002:adf:f3cb:0:b0:367:943e:f436 with SMTP id ffacd0b85a97d-367cea95e1emr5403223f8f.30.1720703969798; Thu, 11 Jul 2024 06:19:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720703969; cv=none; d=google.com; s=arc-20160816; b=GW55AnY3DNqEL/xttjnxES6vv4qjHSAz1io/aXin/RvGAzEE49C+HPiWi2dDOVnVnF EdAb3T4MZi+AuA12tujmWNGBea2EcXHn33CkTi3h769fsIg/pdAOhz+71OHgmIZiod6E Sbsy36OyBxta9ywVrwut5SHxIl3SnRqxfvXvHj35Akdne+//BlkZt9/8jbGoB3FwYrc9 arxlIfpR5DhJBPnoBAueMHd9B6lxhvve86gAqQYaZ4searW5DqYHLUcS+CrFbi4d1wOg 3/eS7SbDoHYnmdt92aLCX+3Ugvq23aNtcCJ3dKwLg/HZcZbLRD6M3khseDnxV0K1wFae cbLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Hxdbg1E8swi6ftQgPkWvTdJfdBhoPoWAjPRagQtO7C8=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=uGXWsLAr1m+MliQ0+W6ZzzjE6Eu5/WKjm8bxzKKl82hE15X4eHLDyQX9mqXrBUaEIv pTDidmaQ92/EpGghVE/TlSPPNjJ/ANpGAV+t7oTJVerrYXlY8Dc2qBE+tp7F4s4IYBSA o00dMSlG+EKbXiOz347JA+pj+xqohhb2/Bkr/0c69+CBHFDbGvqkOmh5feIfZwXdTN0p uCbQT73/QF0oWp3oQN3MzoaylNIAZgvND736sKlM/U8Mk0L8ET6PNwrWPsmSEbebYUxs 51K83kAABRjdyI9QplE1+Ql/Juv9frBjl0WijrzwRblwx+y2XlTKFadN2O68dqQ2mycN /3Zw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uFSr8PFo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ffacd0b85a97d-367cdfaf1e7si4010397f8f.541.2024.07.11.06.19.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Jul 2024 06:19:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uFSr8PFo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRthY-0002jw-2L; Thu, 11 Jul 2024 09:19:12 -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 1sRthP-0002ET-BX for qemu-devel@nongnu.org; Thu, 11 Jul 2024 09:19:03 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRth7-00063f-Ay for qemu-devel@nongnu.org; Thu, 11 Jul 2024 09:19:02 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4266ea6a412so6379265e9.1 for ; Thu, 11 Jul 2024 06:18:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720703910; x=1721308710; darn=nongnu.org; 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=Hxdbg1E8swi6ftQgPkWvTdJfdBhoPoWAjPRagQtO7C8=; b=uFSr8PFoUzFX6126L2KP9zoIXRmXmZt8HVdyFDog4S6fUH3894BNqLvg52rzAtOF9H 48SSoGb+pjVnFYf2rK9IpDs/gu+pF/z2N3hzRX7rAp00m3ET7MvnFUAgFQ7bsemXqLL4 z8yGaqdyNvJyRnhxFe3e4d5ZJ9NUfV7tQiU10zvaTkieq0hxsadyQY5nN2x4KJ/HoDPl wnyYsiKAgk5J+ohe6oFVMOjsCMwg5/hT/5y2xCUbnLHGnpEdz9N8grpdyxvIT8Exee8p koKm9JodbbftfSP5BdyvWYaRZhmdl7HKWHzxGkoeJBwJGTjcRhUPaHGK/0OFEE0oe5p0 Et5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720703910; x=1721308710; 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=Hxdbg1E8swi6ftQgPkWvTdJfdBhoPoWAjPRagQtO7C8=; b=SkEwzUu+6Jt+ZOnzQBV3xSxxhrFeSgVK+uhOGCgneNWqoIQ+sWVANk1T5qAgZDyoxc MfzDqO4KX/oMW9zb9Wug/5YPO0971DxPTxMg+9q4l1kZX6bl2035wTfRTL8ZMX5ASyDe ARxTOa2/f1eN4rkmgL9g14gxNcTUikaFkh/zGA3Yspph6+e3vh+A3sfnLNZtRPCA9ZeM dYKhT6+83/0U7/9jDh9sduSMNde1O+LmY/bBpNxaaLaayPAWnvWbq84GfZ8sv2g14BPu e1ya9AonslkdMnwBucP58U0wSwhhDd83VGzwpCWgEJIlRAldM6RY/mTVXUaJRcVNEXAw 0xEA== X-Gm-Message-State: AOJu0YzX8GJRMDCMpK+jCV0nzPLslMiUFRL+K3g9fz3AwdonUURN7T/Y ySuGsBaWS+JjAHOeDH6F74+O6mWc1yvdCSamv+FiwgqH1eXdNDa+JNN6YqwlLscMEH5B1hK+zds Hu1s= X-Received: by 2002:a05:600c:6a85:b0:427:9922:4526 with SMTP id 5b1f17b1804b1-42799224cf5mr16598265e9.7.1720703910356; Thu, 11 Jul 2024 06:18:30 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4266f736939sm119412025e9.37.2024.07.11.06.18.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 06:18:30 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 11/24] hw/misc/bcm2835_thermal: Fix access size handling in bcm2835_thermal_ops Date: Thu, 11 Jul 2024 14:18:09 +0100 Message-Id: <20240711131822.3909903-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240711131822.3909903-1-peter.maydell@linaro.org> References: <20240711131822.3909903-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Zheyu Ma The current implementation of bcm2835_thermal_ops sets impl.max_access_size and valid.min_access_size to 4, but leaves impl.min_access_size and valid.max_access_size unset, defaulting to 1. This causes issues when the memory system is presented with an access of size 2 at an offset of 3, leading to an attempt to synthesize it as a pair of byte accesses at offsets 3 and 4, which trips an assert. Additionally, the lack of valid.max_access_size setting causes another issue: the memory system tries to synthesize a read using a 4-byte access at offset 3 even though the device doesn't allow unaligned accesses. This patch addresses these issues by explicitly setting both impl.min_access_size and valid.max_access_size to 4, ensuring proper handling of access sizes. Error log: ERROR:hw/misc/bcm2835_thermal.c:55:bcm2835_thermal_read: code should not be reached Bail out! ERROR:hw/misc/bcm2835_thermal.c:55:bcm2835_thermal_read: code should not be reached Aborted Reproducer: cat << EOF | qemu-system-aarch64 -display \ none -machine accel=qtest, -m 512M -machine raspi3b -m 1G -qtest stdio readw 0x3f212003 EOF Signed-off-by: Zheyu Ma Message-id: 20240702154042.3018932-1-zheyuma97@gmail.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/misc/bcm2835_thermal.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/misc/bcm2835_thermal.c b/hw/misc/bcm2835_thermal.c index ee7816b8a5d..0c49c088a79 100644 --- a/hw/misc/bcm2835_thermal.c +++ b/hw/misc/bcm2835_thermal.c @@ -80,8 +80,10 @@ static void bcm2835_thermal_write(void *opaque, hwaddr addr, static const MemoryRegionOps bcm2835_thermal_ops = { .read = bcm2835_thermal_read, .write = bcm2835_thermal_write, + .impl.min_access_size = 4, .impl.max_access_size = 4, .valid.min_access_size = 4, + .valid.max_access_size = 4, .endianness = DEVICE_NATIVE_ENDIAN, };