From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PULL 4/9] qxl: store memory region and offset instead of pointer for guest slots
Date: Wed, 6 Jul 2016 12:04:37 +0200 [thread overview]
Message-ID: <1467799482-26420-5-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1467799482-26420-1-git-send-email-kraxel@redhat.com>
Store MemoryRegion and offset instead of a pointer for each qxl memory
slot, so we can easily figure in which memory region an qxl object
stored.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 1466597244-5938-2-git-send-email-kraxel@redhat.com
---
hw/display/qxl.c | 15 +++++++++++----
hw/display/qxl.h | 3 ++-
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index 2ea4e3b..8101f69 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -1244,6 +1244,7 @@ static int qxl_add_memslot(PCIQXLDevice *d, uint32_t slot_id, uint64_t delta,
int pci_region;
pcibus_t pci_start;
pcibus_t pci_end;
+ MemoryRegion *mr;
intptr_t virt_start;
QXLDevMemSlot memslot;
int i;
@@ -1290,11 +1291,11 @@ static int qxl_add_memslot(PCIQXLDevice *d, uint32_t slot_id, uint64_t delta,
switch (pci_region) {
case QXL_RAM_RANGE_INDEX:
- virt_start = (intptr_t)memory_region_get_ram_ptr(&d->vga.vram);
+ mr = &d->vga.vram;
break;
case QXL_VRAM_RANGE_INDEX:
case 4 /* vram 64bit */:
- virt_start = (intptr_t)memory_region_get_ram_ptr(&d->vram_bar);
+ mr = &d->vram_bar;
break;
default:
/* should not happen */
@@ -1302,6 +1303,7 @@ static int qxl_add_memslot(PCIQXLDevice *d, uint32_t slot_id, uint64_t delta,
return 1;
}
+ virt_start = (intptr_t)memory_region_get_ram_ptr(mr);
memslot.slot_id = slot_id;
memslot.slot_group_id = MEMSLOT_GROUP_GUEST; /* guest group */
memslot.virt_start = virt_start + (guest_start - pci_start);
@@ -1311,7 +1313,8 @@ static int qxl_add_memslot(PCIQXLDevice *d, uint32_t slot_id, uint64_t delta,
qxl_rom_set_dirty(d);
qemu_spice_add_memslot(&d->ssd, &memslot, async);
- d->guest_slots[slot_id].ptr = (void*)memslot.virt_start;
+ d->guest_slots[slot_id].mr = mr;
+ d->guest_slots[slot_id].offset = memslot.virt_start - virt_start;
d->guest_slots[slot_id].size = memslot.virt_end - memslot.virt_start;
d->guest_slots[slot_id].delta = delta;
d->guest_slots[slot_id].active = 1;
@@ -1378,6 +1381,7 @@ void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL pqxl, int group_id)
{
uint64_t offset;
uint32_t slot;
+ void *ptr;
switch (group_id) {
case MEMSLOT_GROUP_HOST:
@@ -1387,7 +1391,10 @@ void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL pqxl, int group_id)
if (!qxl_get_check_slot_offset(qxl, pqxl, &slot, &offset)) {
return NULL;
}
- return qxl->guest_slots[slot].ptr + offset;
+ ptr = memory_region_get_ram_ptr(qxl->guest_slots[slot].mr);
+ ptr += qxl->guest_slots[slot].offset;
+ ptr += offset;
+ return ptr;
}
return NULL;
}
diff --git a/hw/display/qxl.h b/hw/display/qxl.h
index 39ff004..fdb619d 100644
--- a/hw/display/qxl.h
+++ b/hw/display/qxl.h
@@ -53,7 +53,8 @@ typedef struct PCIQXLDevice {
struct guest_slots {
QXLMemSlot slot;
- void *ptr;
+ MemoryRegion *mr;
+ uint64_t offset;
uint64_t size;
uint64_t delta;
uint32_t active;
--
1.8.3.1
next prev parent reply other threads:[~2016-07-06 10:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-06 10:04 [Qemu-devel] [PULL 0/9] spice and qxl bugfixes Gerd Hoffmann
2016-07-06 10:04 ` [Qemu-devel] [PULL 1/9] qxl: use uint64_t for vram size Gerd Hoffmann
2016-07-06 10:04 ` [Qemu-devel] [PULL 2/9] qxl: handle no updates in interface_update_area_complete Gerd Hoffmann
2016-07-06 10:04 ` [Qemu-devel] [PULL 3/9] qxl: factor out qxl_get_check_slot_offset Gerd Hoffmann
2016-07-06 10:04 ` Gerd Hoffmann [this message]
2016-07-06 10:04 ` [Qemu-devel] [PULL 5/9] qxl: fix surface migration Gerd Hoffmann
2016-07-06 10:04 ` [Qemu-devel] [PULL 6/9] spice: avoid .set_mm_time on >= 0.12.6 Gerd Hoffmann
2016-07-06 10:04 ` [Qemu-devel] [PULL 7/9] virgl: count the calls to gl_block Gerd Hoffmann
2016-07-06 10:04 ` [Qemu-devel] [PULL 8/9] spice: use the right head for multi-monitor Gerd Hoffmann
2016-07-06 10:04 ` [Qemu-devel] [PULL 9/9] virgl: pass whole GL scanout dimensions Gerd Hoffmann
2016-07-06 13:07 ` [Qemu-devel] [PULL 0/9] spice and qxl bugfixes Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1467799482-26420-5-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).