From nobody Tue Nov 26 22:35:09 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=1704575255; cv=none; d=zohomail.com; s=zohoarc; b=n3m27kh0p0Cv3IMojcTz9rlHwHXiWQIZkZCP8NOoAxrXqdeirmezIkFyosAZGxDxjENkn3veIAVmPKN5LOzKnzfaK/QSZ7T9zRxc6FmKxS0l62r585s/jIMruTQq3xV/QHtJ2MpSKlBe7Pa7n9eN20sAIZkrHEScsBV9/q0degI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704575255; 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=LzCBxca0nCRHR665JCCwURJqMXPSu7RYmWln7L2TOQo=; b=SfIlH0icW6XYZAckyDyL6QEV8GHDKUXCrUqMz/8a8NCQLY8EVObrV8A4vCB9ktUp6eiTUesceyjIaGicYsufFeoNXSx6POONEPGD19wTQ+0eerk+45k0juK82rpRondXkFy1c+DLbHgYAJMx/SH3PeTyEMyE7jIUZ1JfKDF2ejg= 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 1704575255227990.5585546060665; Sat, 6 Jan 2024 13:07:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rMDri-0005d8-Q5; Sat, 06 Jan 2024 16:05:58 -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 1rMDrg-0005bp-RS; Sat, 06 Jan 2024 16:05:56 -0500 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rMDrf-00019M-1Y; Sat, 06 Jan 2024 16:05:56 -0500 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2ccabf5a4beso5467971fa.2; Sat, 06 Jan 2024 13:05:54 -0800 (PST) Received: from archlinux.. (dynamic-077-011-174-094.77.11.pool.telefonica.de. [77.11.174.94]) by smtp.gmail.com with ESMTPSA id f20-20020a056402195400b005576f4471besm624922edz.42.2024.01.06.13.05.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 13:05:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704575152; x=1705179952; 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=LzCBxca0nCRHR665JCCwURJqMXPSu7RYmWln7L2TOQo=; b=XEIb5HsFdQquUOCJ5vytLm0aBmLn5nH+8ng6zYlv9+kASKNmHFNeTv5CptW9f0PTMW B4ECioAmBbxrWmIX4CtJlrp5+Ln4iiUIJ2gExVIdv1/WYBvs7FUCJhFcXCKYmn+LLymo Ff3aIiQHI7ZEdv2i/oTzbYFqrSF6x61o5EBL4uhluqOrjlw5bWcOPa4DAg3ET1bXf9Qn hDOuUf8oBd16IPu71FLmtTkveldI8QPzDrjH9mDihnOj/U7aW9KJFGxUnCD39FdbhTmv MF8JMv415wOUkVasPPpsdeTCrdWLLllHWXVjWf4CW9wlVpsQ4+EP3i27rfYC/AXrSxS8 LfJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704575152; x=1705179952; 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=LzCBxca0nCRHR665JCCwURJqMXPSu7RYmWln7L2TOQo=; b=Q9Ys+hjXW/eKBBUpp26FtEUadoi2lzXDrXPpHJdi0aLBzp9lpWzRbfUgjtzNIN7Vo8 APEPJ4ZEDQL9nFtrfEyGokKSkL4JyMZyjyKeV6tzGCtSpnYbGfW0Aqm/UX4clpImmu/W 3R7fcMXWvJOFo9huBlGJFOvp/NX+mZKqCHnT5rl/aAIvtDoj0bu7ofBZFI1gh9HNGRRn 2tAYlVrQta062h2Ozn4XgZtCRLUrhpJNPI6HWmLwaenw6XQNvgUW1ppwOlXobvDk5Qez Kt2Kga+qvKqv8tfbgqUnggG0NXYvbjd6vinpzbsDik0ZNUS/XC8hpHJ3fmWlyhjY5G9d 2jEA== X-Gm-Message-State: AOJu0YzW7qE+5bmMISMgcsW9IdKSBsDk3/Cg26sWmbf3ijFgOPeGoKHE oPV/TCS8upNOvEQdgQHRE0SFGIr1Fto= X-Google-Smtp-Source: AGHT+IFNjD5sQIPeMGd/1cWzvaGT9Us26llRzYnA3++xOIZ5ZxXphK1jYmYK41FgbR+YQ72FxNzjjw== X-Received: by 2002:a2e:848d:0:b0:2cd:475:18f3 with SMTP id b13-20020a2e848d000000b002cd047518f3mr270134ljh.126.1704575151810; Sat, 06 Jan 2024 13:05:51 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Artyom Tarasenko , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Fabiano Rosas , Jiaxun Yang , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , John Snow , qemu-block@nongnu.org, Kevin Wolf , Thomas Huth , Richard Henderson , Nicholas Piggin , Aleksandar Rikalo , Peter Xu , BALATON Zoltan , Leonardo Bras , Paolo Bonzini , "Michael S. Tsirkin" , Juan Quintela , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, David Hildenbrand , Marcel Apfelbaum , Sergio Lopez , Hanna Reitz , Mark Cave-Ayland , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Bernhard Beschow Subject: [PATCH v4 04/11] exec/ioport: Resolve redundant .base attribute in struct MemoryRegionPortio Date: Sat, 6 Jan 2024 22:05:24 +0100 Message-ID: <20240106210531.140542-5-shentey@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240106210531.140542-1-shentey@gmail.com> References: <20240106210531.140542-1-shentey@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=2a00:1450:4864:20::233; envelope-from=shentey@gmail.com; helo=mail-lj1-x233.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @gmail.com) X-ZM-MESSAGEID: 1704575256454100003 Content-Type: text/plain; charset="utf-8" portio_list_add_1() creates a MemoryRegionPortioList instance which holds a MemoryRegion `mr` and an array of MemoryRegionPortio elements named `ports`. Each element in the array gets assigned the same value for its .base attrib= ute. The same value also ends up as the .addr attribute of `mr` due to the memory_region_add_subregion() call. This means that all .base attributes are the same as `mr.addr`. The only usages of MemoryRegionPortio::base were in portio_read() and portio_write(). Both functions get above MemoryRegionPortioList as their opaque parameter. In both cases find_portio() can only return one of the MemoryRegionPortio elements of the `ports` array. Due to above observation = any element will have the same .base value equal to `mr.addr` which is also accessible. Hence, `mrpio->mr.addr` is equivalent to `mrp->base` and MemoryRegionPortio::base is redundant and can be removed. Signed-off-by: Bernhard Beschow --- include/exec/ioport.h | 1 - system/ioport.c | 13 ++++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/include/exec/ioport.h b/include/exec/ioport.h index e34f668998..95f1dc30d0 100644 --- a/include/exec/ioport.h +++ b/include/exec/ioport.h @@ -35,7 +35,6 @@ typedef struct MemoryRegionPortio { unsigned size; uint32_t (*read)(void *opaque, uint32_t address); void (*write)(void *opaque, uint32_t address, uint32_t data); - uint32_t base; /* private field */ } MemoryRegionPortio; =20 #define PORTIO_END_OF_LIST() { } diff --git a/system/ioport.c b/system/ioport.c index 1824aa808c..a59e58b716 100644 --- a/system/ioport.c +++ b/system/ioport.c @@ -181,13 +181,13 @@ static uint64_t portio_read(void *opaque, hwaddr addr= , unsigned size) =20 data =3D ((uint64_t)1 << (size * 8)) - 1; if (mrp) { - data =3D mrp->read(mrpio->portio_opaque, mrp->base + addr); + data =3D mrp->read(mrpio->portio_opaque, mrpio->mr.addr + addr); } else if (size =3D=3D 2) { mrp =3D find_portio(mrpio, addr, 1, false); if (mrp) { - data =3D mrp->read(mrpio->portio_opaque, mrp->base + addr); + data =3D mrp->read(mrpio->portio_opaque, mrpio->mr.addr + addr= ); if (addr + 1 < mrp->offset + mrp->len) { - data |=3D mrp->read(mrpio->portio_opaque, mrp->base + addr= + 1) << 8; + data |=3D mrp->read(mrpio->portio_opaque, mrpio->mr.addr += addr + 1) << 8; } else { data |=3D 0xff00; } @@ -203,13 +203,13 @@ static void portio_write(void *opaque, hwaddr addr, u= int64_t data, const MemoryRegionPortio *mrp =3D find_portio(mrpio, addr, size, true); =20 if (mrp) { - mrp->write(mrpio->portio_opaque, mrp->base + addr, data); + mrp->write(mrpio->portio_opaque, mrpio->mr.addr + addr, data); } else if (size =3D=3D 2) { mrp =3D find_portio(mrpio, addr, 1, true); if (mrp) { - mrp->write(mrpio->portio_opaque, mrp->base + addr, data & 0xff= ); + mrp->write(mrpio->portio_opaque, mrpio->mr.addr + addr, data &= 0xff); if (addr + 1 < mrp->offset + mrp->len) { - mrp->write(mrpio->portio_opaque, mrp->base + addr + 1, dat= a >> 8); + mrp->write(mrpio->portio_opaque, mrpio->mr.addr + addr + 1= , data >> 8); } } } @@ -244,7 +244,6 @@ static void portio_list_add_1(PortioList *piolist, /* Adjust the offsets to all be zero-based for the region. */ for (i =3D 0; i < count; ++i) { mrpio->ports[i].offset -=3D off_low; - mrpio->ports[i].base =3D start + off_low; } =20 /* --=20 2.43.0