From nobody Sat Nov 23 15:33:29 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1732119779; cv=none; d=zohomail.com; s=zohoarc; b=BQMNf6aW+Odn0VYfUL9n9UFYyzZHxyMbh3TxVIXq2RZynoVXmpNcwVHsY8ywv7AcnMYgsGxpCZJFMOLmS1W2NtNlj4VKdX2D7ztou+zXiEoOWqjDGBu80n0WUHa+fqXCSAY1JUzocd9ooSJshaDRTWSfThiVeAhdmBMeObtGcx0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732119779; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MzVlMmUDCPIXjIQbgRccJwhv6qCFgui1V2oLDukdq90=; b=PhLVTapLuU2jvSLKnOpeGQkCD3aGGWF3mrIMnPm9/MHpI8jjYZrvdhhVmhc4UUXkIPNW5c8qmWNwKHqr1KNmaT2NmmF+7quRI6uS2ZsLvEYA26wwoV1h9H4JHKzVkNXYg0ldn7YrHzQdiZlKiYzNviyKa9dZwxNo317UpT0fYxc= 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 1732119779552760.9461267688287; Wed, 20 Nov 2024 08:22:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDnTG-0005IG-PS; Wed, 20 Nov 2024 11:22:26 -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 1tDmQx-00081d-Ue for qemu-devel@nongnu.org; Wed, 20 Nov 2024 10:16:01 -0500 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tDmQw-0007HG-Ei for qemu-devel@nongnu.org; Wed, 20 Nov 2024 10:15:59 -0500 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-7e6d04f74faso788672a12.1 for ; Wed, 20 Nov 2024 07:15:57 -0800 (PST) Received: from localhost.localdomain ([114.254.47.99]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-212583fccc5sm29352465ad.278.2024.11.20.07.15.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 07:15:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732115756; x=1732720556; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MzVlMmUDCPIXjIQbgRccJwhv6qCFgui1V2oLDukdq90=; b=a2sAsmLcPBAcP+/tWnpyiVTs4kMVxIwcVIvVrrFZ/uvMOyqgKf4NK9wWGk6w9eYORi Kb3/AtzhxLZ6MotWm1wvJKOUiWxdOvkgXOfrWkuDB2isV2saSP5B1erRpAaAWliJqi4h tAjYxOoDqaMU1zWySpCqTdg1B5J7pgo3xnvTtaZgizY8wHdxXnejoCeJ0QNvhXXm2v7Y wTJIQTl6Ge+51y0tu1/rCOTyy1yOIFhwFyu7L37UEUqScVien8YgbBcS5Y9q3DiJMdn1 yjMWzed9j/vV3EniV2MabUkEKcC+pyTED+aZnn7P4i07fL5QlP/+jqJw9lfaAkskGIVe AuyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732115756; x=1732720556; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MzVlMmUDCPIXjIQbgRccJwhv6qCFgui1V2oLDukdq90=; b=XH8Fdslh3r9Lq5e9tsPnfxNG6SyUZs/zU2XuXZJC9YPQqgIRrXJcbY1O2oj1d3rLP9 MHVMcoUSBadmheZFzgyuRu0lt26ZCsa4fVmIGoyt8uVRSvBLEv929cGSt//QMurJA1kR aPJ6Dm9f/xQ2t/6fEFV/MNdauXiW54zasHFDl74FEPo080Ny9J2mqNjDCPVte8SMhAtU PtOHm3IdVU1HJM2cDkLNJlKyAfOr1Hcv/3Y6tqbEcQykciExYI3hQ8OCQhyV1/NNOpJh 9hE4WI35zP1jLgwBup0Tq7rQcpeTIun39qGxduw/AGk2pnEHkRLe8z9tYA1XGCXNthzA 5Waw== X-Gm-Message-State: AOJu0YyxxiS3o7tZM8VCcOedslnwrM3Cxrc9rnGwAp0YWnSjj/aYA73q 7EKIHNsW9DMTgBWXl+J+ekQjWw4bMnDvkgUAtLPlzHP1+TNeIXYAGpLZgUAalWr9PQ== X-Google-Smtp-Source: AGHT+IETk/kFnwmKWsm9TC+Ih9P1k5qTuXgKYpQwg0MrqhQKNn1fQ6JYmV9+UNOJp5ysAANMRrHiQA== X-Received: by 2002:a17:90a:dfc4:b0:2ea:28bc:8b55 with SMTP id 98e67ed59e1d1-2eac83d7bdemr5138063a91.9.1732115755950; Wed, 20 Nov 2024 07:15:55 -0800 (PST) From: Xiong Nandi To: qemu-devel@nongnu.org Cc: Xiong Nandi , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH] system/physmem: Fix cpu_memory_rw_debug for armv7m MPU Date: Wed, 20 Nov 2024 23:15:15 +0800 Message-Id: <20241120151515.56884-2-xndchn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241120151515.56884-1-xndchn@gmail.com> References: <20241120151515.56884-1-xndchn@gmail.com> 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=2607:f8b0:4864:20::52a; envelope-from=xndchn@gmail.com; helo=mail-pg1-x52a.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, FREEMAIL_FROM=0.001, 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-Mailman-Approved-At: Wed, 20 Nov 2024 11:22:25 -0500 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 @gmail.com) X-ZM-MESSAGEID: 1732119781398116600 Content-Type: text/plain; charset="utf-8" The actual page size (region size for MPU) of armv7m may smaller than TARGET_PAGE_SIZE (2^5 vs 2^10). So we should use the actual virtual address to get the phys page address. Signed-off-by: Xiong Nandi --- system/physmem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/system/physmem.c b/system/physmem.c index dc1db3a384..a76b305130 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -3564,11 +3564,12 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr, MemTxResult res; =20 page =3D addr & TARGET_PAGE_MASK; - phys_addr =3D cpu_get_phys_page_attrs_debug(cpu, page, &attrs); + phys_addr =3D cpu_get_phys_page_attrs_debug(cpu, addr, &attrs); asidx =3D cpu_asidx_from_attrs(cpu, attrs); /* if no physical page mapped, return an error */ if (phys_addr =3D=3D -1) return -1; + phys_addr &=3D TARGET_PAGE_MASK; l =3D (page + TARGET_PAGE_SIZE) - addr; if (l > len) l =3D len; --=20 2.25.1