From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:50021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rv9Rb-00013J-3O for qemu-devel@nongnu.org; Wed, 08 Feb 2012 10:28:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rv9RU-00006T-7J for qemu-devel@nongnu.org; Wed, 08 Feb 2012 10:28:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:17222) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rv9RT-00006B-S0 for qemu-devel@nongnu.org; Wed, 08 Feb 2012 10:28:20 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q18FSJtx019723 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 8 Feb 2012 10:28:19 -0500 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q18FSH6l025146 for ; Wed, 8 Feb 2012 10:28:18 -0500 From: Avi Kivity Date: Wed, 8 Feb 2012 17:27:56 +0200 Message-Id: <1328714879-18906-8-git-send-email-avi@redhat.com> In-Reply-To: <1328714879-18906-1-git-send-email-avi@redhat.com> References: <1328714879-18906-1-git-send-email-avi@redhat.com> Subject: [Qemu-devel] [PATCH 07/10] memory: add a readonly attribute to MemoryRegionSection List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org .readonly cannot be obtained from the MemoryRegion, since it is inherited from aliases (so you can have a MemoryRegion mapped RW at one address and RO at another). Record it in a MemoryRegionSection for listeners. Signed-off-by: Avi Kivity --- memory.c | 5 +++++ memory.h | 2 ++ 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/memory.c b/memory.c index e1a31d4..4f37152 100644 --- a/memory.c +++ b/memory.c @@ -112,6 +112,7 @@ static AddrRange addrrange_intersection(AddrRange r1, AddrRange r2) .offset_within_region = (fr)->offset_in_region, \ .size = int128_get64((fr)->addr.size), \ .offset_within_address_space = int128_get64((fr)->addr.start), \ + .readonly = (fr)->readonly, \ }) struct CoalescedMemoryRange { @@ -342,6 +343,7 @@ static void as_memory_range_add(AddressSpace *as, FlatRange *fr) .offset_within_address_space = int128_get64(fr->addr.start), .offset_within_region = fr->offset_in_region, .size = int128_get64(fr->addr.size), + .readonly = fr->readonly, }; cpu_register_physical_memory_log(§ion, fr->readable, fr->readonly); @@ -354,6 +356,7 @@ static void as_memory_range_del(AddressSpace *as, FlatRange *fr) .offset_within_address_space = int128_get64(fr->addr.start), .offset_within_region = int128_get64(fr->addr.start), .size = int128_get64(fr->addr.size), + .readonly = fr->readonly, }; cpu_register_physical_memory_log(§ion, true, false); @@ -1437,6 +1440,7 @@ MemoryRegionSection memory_region_find(MemoryRegion *address_space, fr->addr.start)); ret.size = int128_get64(range.size); ret.offset_within_address_space = int128_get64(range.start); + ret.readonly = fr->readonly; return ret; } @@ -1479,6 +1483,7 @@ static void listener_add_address_space(MemoryListener *listener, .offset_within_region = fr->offset_in_region, .size = int128_get64(fr->addr.size), .offset_within_address_space = int128_get64(fr->addr.start), + .readonly = fr->readonly, }; listener->region_add(listener, §ion); } diff --git a/memory.h b/memory.h index 84bb67c..1d99cee 100644 --- a/memory.h +++ b/memory.h @@ -160,6 +160,7 @@ typedef struct MemoryRegionSection MemoryRegionSection; * @size: the size of the section; will not exceed @mr's boundaries * @offset_within_address_space: the address of the first byte of the section * relative to the region's address space + * @readonly: writes to this section are ignored */ struct MemoryRegionSection { MemoryRegion *mr; @@ -167,6 +168,7 @@ struct MemoryRegionSection { target_phys_addr_t offset_within_region; uint64_t size; target_phys_addr_t offset_within_address_space; + bool readonly; }; typedef struct MemoryListener MemoryListener; -- 1.7.9