From nobody Tue Nov 26 12:23:59 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1707909809; cv=none; d=zohomail.com; s=zohoarc; b=dnYXdNmawZSnT2+7028hYKnW0ExKMbZikanEhRpaSnABP6zo+xIKSNUsldNdKpSOkh9LG27mx5ur+lbTFnSfvOWYWhduxsXxgZV1/VuroSj/lC4ljrbSSD4NLksHSRtVUnaQAU5f5ryIruBPV4bqzBlIM91aELReN58hMhPmQP8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707909809; h=Content-Type: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=smiDBzm8jjockK0zGaO+moTUtAPPy/TrghQrFfeHPcQ=; b=O88gQUk1i2l5TwWk5eTDclnqwlALBNl8eLPoE+cN+IYvjH8T68CocR78MRPwbPJUf+PY2laoSl8jpTHzNGQADiyxQ6I/YkPsSbiyhsFlgtLXjpLGIRYzw8YmuTMtgpBE0TrhvkhECIc9VaEMOgn3bAL2/QnFSfA7UbfJ1fkYdG0= 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 1707909809345342.30445578309593; Wed, 14 Feb 2024 03:23:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDE0-0002np-5Z; Wed, 14 Feb 2024 06:14:48 -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 1raDDx-0002OS-TL for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDw-0006tr-1U for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:45 -0500 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-412-13pTl0a-PhaJpbtcXOvQZw-1; Wed, 14 Feb 2024 06:14:41 -0500 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a2bc664528fso403710166b.3 for ; Wed, 14 Feb 2024 03:14:41 -0800 (PST) Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id x16-20020a170906441000b00a3d44571dd9sm504245ejo.136.2024.02.14.03.14.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:14:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909283; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=smiDBzm8jjockK0zGaO+moTUtAPPy/TrghQrFfeHPcQ=; b=LkRJGF//g278S5E2UIu4bDdcsy0BsuV/4XnBm90KFzjY849+819q5FXzy/df0T+md/uZum 46aNik42fxXzX4326jn6zIQK48kYS6JBkRA7MWC0mlNl+P4OGy8xVJdp6+4rsqYsb8PAOf 1+WYED8TsYPq28tVGhvfbOX7OGhv700= X-MC-Unique: 13pTl0a-PhaJpbtcXOvQZw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909280; x=1708514080; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=smiDBzm8jjockK0zGaO+moTUtAPPy/TrghQrFfeHPcQ=; b=XSeXYFu5xQkob/sERN6faHhKHwQqKqWf2Z1K1cF6dF4BCUZ3uHuBzMERIi2MTPn0Oz ee8i6pjBCP5xMS1yOyBCRsgA/PDj0MpL321Lt2zLJbNYut/Z5PP2z6fk1X/rgFueAGbC pjW2e85wOWuTWvpU4OBG08+x8MiZGFROiYidQBLcJYHVWZg+35KDBKQlaJAj6QQjnFsw mb5bMputZeT5OmZBBCjkxEz5LbWRlXr1hmNwumb0icU1soxfFGIX3npwh7vgkbOM+oTR zqly+Uh4YK4yRWLhItaep069zLkGCpoZPpl5FbCLuX7UkWB7EzJloMJrGVvRyV9699cf dXFw== X-Gm-Message-State: AOJu0Yy06N1RpQ5KIPm2qURhgNe/uAFZ+wKVgehRVe80hEwkFItKHbC6 bJgq+lnxbwWDeThlwcuUHii7TqLSbaKmTNKTIZC1PE3TckckTBtkbhf23ykVlftiyIjw+Opqt0q lNkrKPmAYDpA2AMIDV5avpO+y4NoHT056qlk0Gw1Xc0rSSlvNIVSWSzmYOCQTKNg66pa3+wCHSA SDZp63Yors8cr/nrhaEkk+p+7hBnSzCg== X-Received: by 2002:a17:906:6809:b0:a3d:6160:fcca with SMTP id k9-20020a170906680900b00a3d6160fccamr463631ejr.69.1707909280212; Wed, 14 Feb 2024 03:14:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZjsSdR+l4A/AMEj2g0dxGAt+tfDD2oxNPbfCTsR93ojeJ4kt5Ig95/isB/NwkQ7W8CWZU/g== X-Received: by 2002:a17:906:6809:b0:a3d:6160:fcca with SMTP id k9-20020a170906680900b00a3d6160fccamr463612ejr.69.1707909279962; Wed, 14 Feb 2024 03:14:39 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVCcIux88zS8EZnjkSw4acOkpebnVTw0Tj1c2ALNA6K7LQXu4YZMmsMvHVsxcQOFK9PqHMc9PFk64IYNLdrXvxN7IrTCcrcVHw+xZybfhiZdpL4luJyy77i+CLdCwY8zGdL3DUO5R2EMG5ZQNKIpL1vBLgjVOS5XZhBTMWWqiIjuKPyZEd+WzIyn+EAc+63 Date: Wed, 14 Feb 2024 06:14:37 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Paolo Bonzini , Peter Xu , David Hildenbrand , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Subject: [PULL 26/60] exec/ioport: Add portio_list_set_address() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1707909810879100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Bernhard Beschow Some SuperI/O devices such as the VIA south bridges or the PC87312 controll= er are able to relocate their SuperI/O functions. Add a convenience function f= or implementing this in the VIA south bridges. This convenience function relies on previous simplifications in exec/ioport which avoids some duplicate synchronization of I/O port base addresses. The naming of the function is inspired by its memory_region_set_address() penda= nt. Signed-off-by: Bernhard Beschow Message-Id: <20240114123911.4877-6-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/exec/ioport.h | 2 ++ system/ioport.c | 19 +++++++++++++++++++ docs/devel/migration/main.rst | 5 +++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/include/exec/ioport.h b/include/exec/ioport.h index 95f1dc30d0..96858e5ac3 100644 --- a/include/exec/ioport.h +++ b/include/exec/ioport.h @@ -54,6 +54,7 @@ typedef struct PortioList { const struct MemoryRegionPortio *ports; Object *owner; struct MemoryRegion *address_space; + uint32_t addr; unsigned nr; struct MemoryRegion **regions; void *opaque; @@ -70,5 +71,6 @@ void portio_list_add(PortioList *piolist, struct MemoryRegion *address_space, uint32_t addr); void portio_list_del(PortioList *piolist); +void portio_list_set_address(PortioList *piolist, uint32_t addr); =20 #endif /* IOPORT_H */ diff --git a/system/ioport.c b/system/ioport.c index a59e58b716..000e0ee1af 100644 --- a/system/ioport.c +++ b/system/ioport.c @@ -133,6 +133,7 @@ void portio_list_init(PortioList *piolist, piolist->nr =3D 0; piolist->regions =3D g_new0(MemoryRegion *, n); piolist->address_space =3D NULL; + piolist->addr =3D 0; piolist->opaque =3D opaque; piolist->owner =3D owner; piolist->name =3D name; @@ -282,6 +283,7 @@ void portio_list_add(PortioList *piolist, unsigned int off_low, off_high, off_last, count; =20 piolist->address_space =3D address_space; + piolist->addr =3D start; =20 /* Handle the first entry specially. */ off_last =3D off_low =3D pio_start->offset; @@ -322,6 +324,23 @@ void portio_list_del(PortioList *piolist) } } =20 +void portio_list_set_address(PortioList *piolist, uint32_t addr) +{ + MemoryRegionPortioList *mrpio; + unsigned i, j; + + for (i =3D 0; i < piolist->nr; ++i) { + mrpio =3D container_of(piolist->regions[i], MemoryRegionPortioList= , mr); + memory_region_set_address(&mrpio->mr, + mrpio->mr.addr - piolist->addr + addr); + for (j =3D 0; mrpio->ports[j].size; ++j) { + mrpio->ports[j].offset +=3D addr - piolist->addr; + } + } + + piolist->addr =3D addr; +} + static void memory_region_portio_list_finalize(Object *obj) { MemoryRegionPortioList *mrpio =3D MEMORY_REGION_PORTIO_LIST(obj); diff --git a/docs/devel/migration/main.rst b/docs/devel/migration/main.rst index 00b9c3d32f..9439adcf66 100644 --- a/docs/devel/migration/main.rst +++ b/docs/devel/migration/main.rst @@ -431,10 +431,10 @@ data doesn't match the stored device data well; it al= lows an intermediate temporary structure to be populated with migration data and then transferred to the main structure. =20 -If you use memory API functions that update memory layout outside +If you use memory or portio_list API functions that update memory layout o= utside initialization (i.e., in response to a guest action), this is a strong indication that you need to call these functions in a ``post_load`` callba= ck. -Examples of such memory API functions are: +Examples of such API functions are: =20 - memory_region_add_subregion() - memory_region_del_subregion() @@ -443,6 +443,7 @@ Examples of such memory API functions are: - memory_region_set_enabled() - memory_region_set_address() - memory_region_set_alias_offset() + - portio_list_set_address() =20 Iterative device migration -------------------------- --=20 MST