mirror of
https://github.com/utmapp/qemu.git
synced 2026-12-02 06:32:54 -10:00
Compare commits
70
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
161e1f22b8 | ||
|
|
2e0e234272 | ||
|
|
c221208352 | ||
|
|
3218890da4 | ||
|
|
dda57509e9 | ||
|
|
73a11e3723 | ||
|
|
b6abbe6250 | ||
|
|
b57641e907 | ||
|
|
d9bb73d8e3 | ||
|
|
c74cba8362 | ||
|
|
a3f531cee6 | ||
|
|
5d4218f0b2 | ||
|
|
248aa3deb6 | ||
|
|
d8592b05be | ||
|
|
5d42bf6c57 | ||
|
|
ad2f459ce0 | ||
|
|
17b032c659 | ||
|
|
a3c6cd83e3 | ||
|
|
a2efa1fac4 | ||
|
|
b209cc4556 | ||
|
|
5bfbcc3faa | ||
|
|
099e8cd9ea | ||
|
|
32b8913f72 | ||
|
|
e807a1c29f | ||
|
|
9d46d348f6 | ||
|
|
7c8a67ed46 | ||
|
|
b05232a256 | ||
|
|
f6d602d078 | ||
|
|
2529bbf4a7 | ||
|
|
6cf13d9d01 | ||
|
|
a7485cdca7 | ||
|
|
e2672ec498 | ||
|
|
c21a2456b6 | ||
|
|
0546b42bce | ||
|
|
5a1c74097e | ||
|
|
b8db116da1 | ||
|
|
b5be595c62 | ||
|
|
fd4bf2632c | ||
|
|
b3f36e52ac | ||
|
|
99fb11df6f | ||
|
|
814c0b185d | ||
|
|
8faaaf1bcd | ||
|
|
851de2751f | ||
|
|
538c8180c3 | ||
|
|
1ca37b7ef6 | ||
|
|
856a67cade | ||
|
|
f163cf6be4 | ||
|
|
c45d10f655 | ||
|
|
6809dbc5c5 | ||
|
|
8d3c9fc439 | ||
|
|
93ff84d4c0 | ||
|
|
2c0fdb4ed3 | ||
|
|
6e0c910904 | ||
|
|
eca533b60a | ||
|
|
ee2ec0ac52 | ||
|
|
f759e33000 | ||
|
|
75ecd0872f | ||
|
|
c3ea5ef558 | ||
|
|
de605876eb | ||
|
|
f549ee8c25 | ||
|
|
4e98327e14 | ||
|
|
9d86da9e07 | ||
|
|
6a3aa014c5 | ||
|
|
e05827b632 | ||
|
|
6647b6edea | ||
|
|
305c0f8c54 | ||
|
|
a2093dd6fe | ||
|
|
5f43c7786e | ||
|
|
f16011abc1 | ||
|
|
e34f86a2f9 |
No files matched your search
@@ -58,9 +58,6 @@
|
||||
[submodule "roms/vbootrom"]
|
||||
path = roms/vbootrom
|
||||
url = https://gitlab.com/qemu-project/vbootrom.git
|
||||
[submodule "libucontext"]
|
||||
path = subprojects/libucontext
|
||||
url = https://github.com/utmapp/libucontext.git
|
||||
[submodule "tests/lcitool/libvirt-ci"]
|
||||
path = tests/lcitool/libvirt-ci
|
||||
url = https://gitlab.com/libvirt/libvirt-ci.git
|
||||
|
||||
+92
-311
@@ -57,34 +57,25 @@
|
||||
#include "sysemu/hvf_int.h"
|
||||
#include "sysemu/runstate.h"
|
||||
#include "qemu/guest-random.h"
|
||||
#include "hw/boards.h"
|
||||
#include "exec/memory-remap.h"
|
||||
#include "exec/ram_addr.h"
|
||||
|
||||
HVFState *hvf_state;
|
||||
|
||||
/* Memory slots */
|
||||
|
||||
#define HVF_MAX_SLOTS 512
|
||||
#ifdef DEBUG_HVF
|
||||
#define DPRINTF(fmt, ...) \
|
||||
do { fprintf(stdout, fmt, ## __VA_ARGS__); } while (0)
|
||||
#else
|
||||
#define DPRINTF(fmt, ...) \
|
||||
do { } while (0)
|
||||
#ifdef __aarch64__
|
||||
#define HV_VM_DEFAULT NULL
|
||||
#endif
|
||||
|
||||
#define qemu_abort(...) do { g_error(__VA_ARGS__); g_abort(); } while (0)
|
||||
/* Memory slots */
|
||||
|
||||
pthread_rwlock_t mem_lock = PTHREAD_RWLOCK_INITIALIZER;
|
||||
|
||||
hvf_slot *hvf_find_overlap_slot(uint64_t start, uint64_t end) {
|
||||
hvf_slot *hvf_find_overlap_slot(uint64_t start, uint64_t size)
|
||||
{
|
||||
hvf_slot *slot;
|
||||
int x;
|
||||
for (x = 0; x < hvf_state->num_slots; ++x) {
|
||||
slot = &hvf_state->slots[x];
|
||||
if (slot->size && start < (slot->start + slot->size) && end > slot->start)
|
||||
if (slot->size && start < (slot->start + slot->size) &&
|
||||
(start + size) > slot->start) {
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -94,236 +85,22 @@ struct mac_slot {
|
||||
uint64_t size;
|
||||
uint64_t gpa_start;
|
||||
uint64_t gva;
|
||||
void* hva;
|
||||
};
|
||||
|
||||
struct mac_slot mac_slots[HVF_MAX_SLOTS];
|
||||
struct mac_slot mac_slots[32];
|
||||
|
||||
#define ALIGN(x, y) (((x)+(y)-1) & ~((y)-1))
|
||||
|
||||
void* hvf_gpa2hva(uint64_t gpa, bool* found) {
|
||||
struct mac_slot *mslot;
|
||||
*found = false;
|
||||
|
||||
for (uint32_t i = 0; i < HVF_MAX_SLOTS; i++) {
|
||||
mslot = &mac_slots[i];
|
||||
if (!mslot->present) continue;
|
||||
if (gpa >= mslot->gpa_start &&
|
||||
gpa < mslot->gpa_start + mslot->size) {
|
||||
*found = true;
|
||||
return (void*)((char*)(mslot->hva) + (gpa - mslot->gpa_start));
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||
int hvf_hva2gpa(void* hva, uint64_t length, int array_size,
|
||||
uint64_t* gpa, uint64_t* size) {
|
||||
struct mac_slot *mslot;
|
||||
int count = 0;
|
||||
|
||||
for (uint32_t i = 0; i < HVF_MAX_SLOTS; i++) {
|
||||
mslot = &mac_slots[i];
|
||||
if (!mslot->present) continue;
|
||||
|
||||
uintptr_t hva_start_num = (uintptr_t)mslot->hva;
|
||||
uintptr_t hva_num = (uintptr_t)hva;
|
||||
// Start of this hva region is in this slot.
|
||||
if (hva_num >= hva_start_num &&
|
||||
hva_num < hva_start_num + mslot->size) {
|
||||
if (count < array_size) {
|
||||
gpa[count] = mslot->gpa_start + (hva_num - hva_start_num);
|
||||
size[count] = min(length,
|
||||
mslot->size - (hva_num - hva_start_num));
|
||||
}
|
||||
count++;
|
||||
// End of this hva region is in this slot.
|
||||
// Its start is outside of this slot.
|
||||
} else if (hva_num + length <= hva_start_num + mslot->size &&
|
||||
hva_num + length > hva_start_num) {
|
||||
if (count < array_size) {
|
||||
gpa[count] = mslot->gpa_start;
|
||||
size[count] = hva_num + length - hva_start_num;
|
||||
}
|
||||
count++;
|
||||
// This slot belongs to this hva region completely.
|
||||
} else if (hva_num + length > hva_start_num + mslot->size &&
|
||||
hva_num < hva_start_num) {
|
||||
if (count < array_size) {
|
||||
gpa[count] = mslot->gpa_start;
|
||||
size[count] = mslot->size;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static hvf_slot* hvf_next_free_slot() {
|
||||
hvf_slot* mem = 0;
|
||||
int x;
|
||||
|
||||
for (x = 0; x < hvf_state->num_slots; ++x) {
|
||||
mem = &hvf_state->slots[x];
|
||||
if (!mem->size) {
|
||||
return mem;
|
||||
}
|
||||
}
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
int __hvf_set_memory(hvf_slot *slot);
|
||||
int __hvf_set_memory_with_flags_locked(hvf_slot *slot, hv_memory_flags_t flags);
|
||||
|
||||
int hvf_map_safe(void* hva, uint64_t gpa, uint64_t size, uint64_t flags) {
|
||||
pthread_rwlock_wrlock(&mem_lock);
|
||||
DPRINTF("%s: hva: [%p 0x%llx] gpa: [0x%llx 0x%llx]\n", __func__,
|
||||
hva, (unsigned long long)(uintptr_t)(((char*)hva) + size),
|
||||
(unsigned long long)gpa,
|
||||
(unsigned long long)gpa + size);
|
||||
|
||||
hvf_slot *mem;
|
||||
mem = hvf_find_overlap_slot(gpa, gpa + size);
|
||||
|
||||
if (mem &&
|
||||
mem->mem == hva &&
|
||||
mem->start == gpa &&
|
||||
mem->size == size) {
|
||||
|
||||
pthread_rwlock_unlock(&mem_lock);
|
||||
return HV_SUCCESS;
|
||||
} else if (mem &&
|
||||
mem->start == gpa &&
|
||||
mem->size == size) {
|
||||
// unmap existing mapping, but only if it coincides
|
||||
mem->size = 0;
|
||||
__hvf_set_memory_with_flags_locked(mem, 0);
|
||||
} else if (mem) {
|
||||
// TODO: Manage and support partially-overlapping user-backed RAM mappings.
|
||||
// for now, consider it fatal.
|
||||
pthread_rwlock_unlock(&mem_lock);
|
||||
qemu_abort("%s: FATAL: tried to map [0x%llx 0x%llx) to %p "
|
||||
"while it was mapped to [0x%llx 0x%llx), %p",
|
||||
__func__,
|
||||
(unsigned long long)gpa,
|
||||
(unsigned long long)gpa + size,
|
||||
hva,
|
||||
(unsigned long long)mem->start,
|
||||
(unsigned long long)mem->start + mem->size,
|
||||
mem->mem);
|
||||
}
|
||||
|
||||
mem = hvf_next_free_slot();
|
||||
|
||||
if (mem->size) {
|
||||
qemu_abort("%s: no free slots\n", __func__);
|
||||
}
|
||||
|
||||
mem->mem = (uint8_t*)hva;
|
||||
mem->start = gpa;
|
||||
mem->size = size;
|
||||
|
||||
int res = __hvf_set_memory_with_flags_locked(mem, (hv_memory_flags_t)flags);
|
||||
|
||||
pthread_rwlock_unlock(&mem_lock);
|
||||
return res;
|
||||
}
|
||||
|
||||
int hvf_unmap_safe(uint64_t gpa, uint64_t size) {
|
||||
DPRINTF("%s: gpa: [0x%llx 0x%llx]\n", __func__,
|
||||
(unsigned long long)gpa,
|
||||
(unsigned long long)gpa + size);
|
||||
pthread_rwlock_wrlock(&mem_lock);
|
||||
|
||||
hvf_slot *mem;
|
||||
int res = 0;
|
||||
mem = hvf_find_overlap_slot(gpa, gpa + size);
|
||||
|
||||
if (mem &&
|
||||
(mem->start != gpa ||
|
||||
mem->size != size)) {
|
||||
|
||||
pthread_rwlock_unlock(&mem_lock);
|
||||
|
||||
qemu_abort("%s: tried to unmap [0x%llx 0x%llx) but partially overlapping "
|
||||
"[0x%llx 0x%llx), %p was encountered",
|
||||
__func__, gpa, gpa + size,
|
||||
mem->start, mem->start + mem->size, mem->mem);
|
||||
} else if (mem) {
|
||||
mem->size = 0;
|
||||
res = __hvf_set_memory_with_flags_locked(mem, 0);
|
||||
} else {
|
||||
// fall through, allow res to be 0 still if slot was not found.
|
||||
}
|
||||
|
||||
pthread_rwlock_unlock(&mem_lock);
|
||||
return res;
|
||||
}
|
||||
|
||||
int hvf_protect_safe(uint64_t gpa, uint64_t size, uint64_t flags) {
|
||||
pthread_rwlock_wrlock(&mem_lock);
|
||||
int res = hv_vm_protect(gpa, size, flags);
|
||||
pthread_rwlock_unlock(&mem_lock);
|
||||
return res;
|
||||
}
|
||||
|
||||
int hvf_remap_safe(void* hva, uint64_t gpa, uint64_t size, uint64_t flags) {
|
||||
pthread_rwlock_wrlock(&mem_lock);
|
||||
int res = hv_vm_unmap(gpa, size);
|
||||
assert_hvf_ok(res);
|
||||
res = hv_vm_map(hva, gpa, size, flags);
|
||||
assert_hvf_ok(res);
|
||||
pthread_rwlock_unlock(&mem_lock);
|
||||
return res;
|
||||
}
|
||||
|
||||
// API for adding and removing mappings of guest RAM and host addrs.
|
||||
// Implementation depends on the hypervisor.
|
||||
static hv_memory_flags_t user_backed_flags_to_hvf_flags(int flags) {
|
||||
hv_memory_flags_t hvf_flags = 0;
|
||||
if (flags & USER_BACKED_RAM_FLAGS_READ) {
|
||||
hvf_flags |= HV_MEMORY_READ;
|
||||
}
|
||||
if (flags & USER_BACKED_RAM_FLAGS_WRITE) {
|
||||
hvf_flags |= HV_MEMORY_WRITE;
|
||||
}
|
||||
if (flags & USER_BACKED_RAM_FLAGS_EXEC) {
|
||||
hvf_flags |= HV_MEMORY_EXEC;
|
||||
}
|
||||
return hvf_flags;
|
||||
}
|
||||
|
||||
static void hvf_user_backed_ram_map(uint64_t gpa, void* hva, uint64_t size, int flags) {
|
||||
hvf_map_safe(hva, gpa, size, user_backed_flags_to_hvf_flags(flags));
|
||||
}
|
||||
|
||||
static void hvf_user_backed_ram_unmap(uint64_t gpa, uint64_t size) {
|
||||
hvf_unmap_safe(gpa, size);
|
||||
}
|
||||
|
||||
int __hvf_set_memory(hvf_slot *slot) {
|
||||
pthread_rwlock_wrlock(&mem_lock);
|
||||
int res = __hvf_set_memory_with_flags_locked(slot, HV_MEMORY_READ | HV_MEMORY_WRITE | HV_MEMORY_EXEC);
|
||||
pthread_rwlock_unlock(&mem_lock);
|
||||
return res;
|
||||
}
|
||||
|
||||
int __hvf_set_memory_with_flags_locked(hvf_slot *slot, hv_memory_flags_t flags) {
|
||||
static int do_hvf_set_memory(hvf_slot *slot, hv_memory_flags_t flags)
|
||||
{
|
||||
struct mac_slot *macslot;
|
||||
hv_return_t ret;
|
||||
|
||||
macslot = &mac_slots[slot->slot_id];
|
||||
|
||||
if (macslot->present) {
|
||||
if (macslot->size != slot->size) {
|
||||
macslot->present = 0;
|
||||
DPRINTF("%s: hv_vm_unmap for gpa [0x%llx 0x%llx]\n", __func__,
|
||||
(unsigned long long)macslot->gpa_start,
|
||||
(unsigned long long)(macslot->gpa_start + macslot->size));
|
||||
int unmapres = hv_vm_unmap(macslot->gpa_start, macslot->size);
|
||||
assert_hvf_ok(unmapres);
|
||||
ret = hv_vm_unmap(macslot->gpa_start, macslot->size);
|
||||
assert_hvf_ok(ret);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,58 +111,93 @@ int __hvf_set_memory_with_flags_locked(hvf_slot *slot, hv_memory_flags_t flags)
|
||||
macslot->present = 1;
|
||||
macslot->gpa_start = slot->start;
|
||||
macslot->size = slot->size;
|
||||
macslot->hva = slot->mem;
|
||||
DPRINTF("%s: hv_vm_map for hva 0x%llx gpa [0x%llx 0x%llx]\n", __func__,
|
||||
(unsigned long long)(slot->mem),
|
||||
(unsigned long long)macslot->gpa_start,
|
||||
(unsigned long long)(macslot->gpa_start + macslot->size));
|
||||
int mapres = (hv_vm_map(slot->mem, slot->start, slot->size, flags));
|
||||
assert_hvf_ok(mapres);
|
||||
ret = hv_vm_map(slot->mem, slot->start, slot->size, flags);
|
||||
assert_hvf_ok(ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void hvf_set_phys_mem(MemoryRegionSection* section, bool add) {
|
||||
static void hvf_set_phys_mem(MemoryRegionSection *section, bool add)
|
||||
{
|
||||
hvf_slot *mem;
|
||||
MemoryRegion *area = section->mr;
|
||||
bool writable = !area->readonly && !area->rom_device;
|
||||
hv_memory_flags_t flags;
|
||||
uint64_t page_size = qemu_real_host_page_size();
|
||||
|
||||
if (!memory_region_is_ram(area)) return;
|
||||
if (memory_region_is_user_backed(area)) return;
|
||||
|
||||
mem = hvf_find_overlap_slot(
|
||||
section->offset_within_address_space,
|
||||
section->offset_within_address_space + int128_get64(section->size));
|
||||
|
||||
if (mem && add) {
|
||||
if (mem->size == int128_get64(section->size) &&
|
||||
mem->start == section->offset_within_address_space &&
|
||||
mem->mem == (memory_region_get_ram_ptr(area) + section->offset_within_region))
|
||||
return; // Same region was attempted to register, go away.
|
||||
}
|
||||
|
||||
// Region needs to be reset. set the size to 0 and remap it.
|
||||
if (mem) {
|
||||
mem->size = 0;
|
||||
if (__hvf_set_memory(mem)) {
|
||||
qemu_abort("%s: Failed to reset overlapping slot\n", __func__);
|
||||
if (!memory_region_is_ram(area)) {
|
||||
if (writable) {
|
||||
return;
|
||||
} else if (!memory_region_is_romd(area)) {
|
||||
/*
|
||||
* If the memory device is not in romd_mode, then we actually want
|
||||
* to remove the hvf memory slot so all accesses will trap.
|
||||
*/
|
||||
add = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!add) return;
|
||||
if (!QEMU_IS_ALIGNED(int128_get64(section->size), page_size) ||
|
||||
!QEMU_IS_ALIGNED(section->offset_within_address_space, page_size)) {
|
||||
/* Not page aligned, so we can not map as RAM */
|
||||
add = false;
|
||||
}
|
||||
|
||||
// Now make a new slot.
|
||||
mem = hvf_find_overlap_slot(
|
||||
section->offset_within_address_space,
|
||||
int128_get64(section->size));
|
||||
|
||||
mem = hvf_next_free_slot();
|
||||
if (mem && add) {
|
||||
if (mem->size == int128_get64(section->size) &&
|
||||
mem->start == section->offset_within_address_space &&
|
||||
mem->mem == (memory_region_get_ram_ptr(area) +
|
||||
section->offset_within_region)) {
|
||||
return; /* Same region was attempted to register, go away. */
|
||||
}
|
||||
}
|
||||
|
||||
if (!mem) {
|
||||
qemu_abort("%s: no free slots\n", __func__);
|
||||
/* Region needs to be reset. set the size to 0 and remap it. */
|
||||
if (mem) {
|
||||
mem->size = 0;
|
||||
if (do_hvf_set_memory(mem, 0)) {
|
||||
error_report("Failed to reset overlapping slot");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
if (!add) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (area->readonly ||
|
||||
(!memory_region_is_ram(area) && memory_region_is_romd(area))) {
|
||||
flags = HV_MEMORY_READ | HV_MEMORY_EXEC;
|
||||
} else {
|
||||
flags = HV_MEMORY_READ | HV_MEMORY_WRITE | HV_MEMORY_EXEC;
|
||||
}
|
||||
|
||||
/* Now make a new slot. */
|
||||
int x;
|
||||
|
||||
for (x = 0; x < hvf_state->num_slots; ++x) {
|
||||
mem = &hvf_state->slots[x];
|
||||
if (!mem->size) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (x == hvf_state->num_slots) {
|
||||
error_report("No free slots");
|
||||
abort();
|
||||
}
|
||||
|
||||
mem->size = int128_get64(section->size);
|
||||
mem->mem = memory_region_get_ram_ptr(area) + section->offset_within_region;
|
||||
mem->start = section->offset_within_address_space;
|
||||
mem->region = area;
|
||||
|
||||
if (__hvf_set_memory(mem)) {
|
||||
qemu_abort("%s: error regsitering new memory slot\n", __func__);
|
||||
if (do_hvf_set_memory(mem, flags)) {
|
||||
error_report("Error registering new memory slot");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -507,47 +319,25 @@ bool hvf_allowed;
|
||||
|
||||
static int hvf_accel_init(MachineState *ms)
|
||||
{
|
||||
int x;
|
||||
hv_return_t ret;
|
||||
HVFState *s = HVF_STATE(ms->accelerator);
|
||||
HVFState *s;
|
||||
|
||||
ret = hvf_arch_vm_create(s);
|
||||
ret = hv_vm_create(HV_VM_DEFAULT);
|
||||
assert_hvf_ok(ret);
|
||||
|
||||
hvf_state = s;
|
||||
memory_listener_register(&hvf_memory_listener, &address_space_memory);
|
||||
qemu_set_user_backed_mapping_funcs(
|
||||
hvf_user_backed_ram_map,
|
||||
hvf_user_backed_ram_unmap);
|
||||
|
||||
return hvf_arch_init();
|
||||
}
|
||||
|
||||
#if defined(CONFIG_HVF_PRIVATE) && defined(__aarch64__)
|
||||
|
||||
static bool hvf_get_tso(Object *obj, Error **errp)
|
||||
{
|
||||
HVFState *s = HVF_STATE(obj);
|
||||
return s->tso_mode;
|
||||
}
|
||||
|
||||
static void hvf_set_tso(Object *obj, bool value, Error **errp)
|
||||
{
|
||||
HVFState *s = HVF_STATE(obj);
|
||||
s->tso_mode = value;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void hvf_accel_instance_init(Object *obj)
|
||||
{
|
||||
int x;
|
||||
HVFState *s = HVF_STATE(obj);
|
||||
s = g_new0(HVFState, 1);
|
||||
|
||||
s->num_slots = ARRAY_SIZE(s->slots);
|
||||
for (x = 0; x < s->num_slots; ++x) {
|
||||
s->slots[x].size = 0;
|
||||
s->slots[x].slot_id = x;
|
||||
}
|
||||
|
||||
hvf_state = s;
|
||||
memory_listener_register(&hvf_memory_listener, &address_space_memory);
|
||||
|
||||
return hvf_arch_init();
|
||||
}
|
||||
|
||||
static void hvf_accel_class_init(ObjectClass *oc, void *data)
|
||||
@@ -556,21 +346,12 @@ static void hvf_accel_class_init(ObjectClass *oc, void *data)
|
||||
ac->name = "HVF";
|
||||
ac->init_machine = hvf_accel_init;
|
||||
ac->allowed = &hvf_allowed;
|
||||
|
||||
#if defined(CONFIG_HVF_PRIVATE) && defined(__aarch64__)
|
||||
object_class_property_add_bool(oc, "tso",
|
||||
hvf_get_tso, hvf_set_tso);
|
||||
object_class_property_set_description(oc, "tso",
|
||||
"Set on/off to enable/disable total store ordering mode");
|
||||
#endif
|
||||
}
|
||||
|
||||
static const TypeInfo hvf_accel_type = {
|
||||
.name = TYPE_HVF_ACCEL,
|
||||
.parent = TYPE_ACCEL,
|
||||
.instance_init = hvf_accel_instance_init,
|
||||
.class_init = hvf_accel_class_init,
|
||||
.instance_size = sizeof(HVFState),
|
||||
};
|
||||
|
||||
static void hvf_type_init(void)
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "disas/disas.h"
|
||||
#include "exec/exec-all.h"
|
||||
#include "tcg/tcg.h"
|
||||
#include "tcg/tcg-apple-jit.h"
|
||||
#include "qemu/atomic.h"
|
||||
#include "qemu/compiler.h"
|
||||
#include "qemu/timer.h"
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "exec/translate-all.h"
|
||||
#include "sysemu/tcg.h"
|
||||
#include "tcg/tcg.h"
|
||||
#include "tcg/tcg-apple-jit.h"
|
||||
#include "tb-hash.h"
|
||||
#include "tb-context.h"
|
||||
#include "internal.h"
|
||||
|
||||
@@ -47,11 +47,6 @@ void tcg_cpu_init_cflags(CPUState *cpu, bool parallel)
|
||||
uint32_t cflags = cpu->cluster_index << CF_CLUSTER_SHIFT;
|
||||
cflags |= parallel ? CF_PARALLEL : 0;
|
||||
cflags |= icount_enabled() ? CF_USE_ICOUNT : 0;
|
||||
#if defined(CONFIG_TCG_THREADED_INTERPRETER)
|
||||
// GOTO_PTR is too complex to emit a simple gadget for.
|
||||
// We'll let C handle it, since the overhead is similar.
|
||||
cflags |= CF_NO_GOTO_PTR;
|
||||
#endif
|
||||
cpu->tcg_cflags = cflags;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "disas/disas.h"
|
||||
#include "exec/exec-all.h"
|
||||
#include "tcg/tcg.h"
|
||||
#include "tcg/tcg-apple-jit.h"
|
||||
#if defined(CONFIG_USER_ONLY)
|
||||
#include "qemu.h"
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
|
||||
+6
-24
@@ -1409,21 +1409,12 @@ void audio_run(AudioState *s, const char *msg)
|
||||
#endif
|
||||
}
|
||||
|
||||
void audio_generic_initialize_buffer_in(HWVoiceIn *hw)
|
||||
{
|
||||
if (hw->buf_emul) {
|
||||
g_free(hw->buf_emul);
|
||||
}
|
||||
|
||||
hw->size_emul = hw->samples * hw->info.bytes_per_frame;
|
||||
hw->buf_emul = g_malloc(hw->size_emul);
|
||||
hw->pos_emul = hw->pending_emul = 0;
|
||||
}
|
||||
|
||||
void audio_generic_run_buffer_in(HWVoiceIn *hw)
|
||||
{
|
||||
if (unlikely(!hw->buf_emul)) {
|
||||
audio_generic_initialize_buffer_in(hw);
|
||||
hw->size_emul = hw->samples * hw->info.bytes_per_frame;
|
||||
hw->buf_emul = g_malloc(hw->size_emul);
|
||||
hw->pos_emul = hw->pending_emul = 0;
|
||||
}
|
||||
|
||||
while (hw->pending_emul < hw->size_emul) {
|
||||
@@ -1457,17 +1448,6 @@ void audio_generic_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size)
|
||||
hw->pending_emul -= size;
|
||||
}
|
||||
|
||||
void audio_generic_initialize_buffer_out(HWVoiceOut *hw)
|
||||
{
|
||||
if (hw->buf_emul) {
|
||||
g_free(hw->buf_emul);
|
||||
}
|
||||
|
||||
hw->size_emul = hw->samples * hw->info.bytes_per_frame;
|
||||
hw->buf_emul = g_malloc(hw->size_emul);
|
||||
hw->pos_emul = hw->pending_emul = 0;
|
||||
}
|
||||
|
||||
size_t audio_generic_buffer_get_free(HWVoiceOut *hw)
|
||||
{
|
||||
if (hw->buf_emul) {
|
||||
@@ -1499,7 +1479,9 @@ void audio_generic_run_buffer_out(HWVoiceOut *hw)
|
||||
void *audio_generic_get_buffer_out(HWVoiceOut *hw, size_t *size)
|
||||
{
|
||||
if (unlikely(!hw->buf_emul)) {
|
||||
audio_generic_initialize_buffer_out(hw);
|
||||
hw->size_emul = hw->samples * hw->info.bytes_per_frame;
|
||||
hw->buf_emul = g_malloc(hw->size_emul);
|
||||
hw->pos_emul = hw->pending_emul = 0;
|
||||
}
|
||||
|
||||
*size = MIN(hw->size_emul - hw->pending_emul,
|
||||
|
||||
@@ -190,11 +190,9 @@ struct audio_pcm_ops {
|
||||
void (*volume_in)(HWVoiceIn *hw, Volume *vol);
|
||||
};
|
||||
|
||||
void audio_generic_initialize_buffer_in(HWVoiceIn *hw);
|
||||
void audio_generic_run_buffer_in(HWVoiceIn *hw);
|
||||
void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size);
|
||||
void audio_generic_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size);
|
||||
void audio_generic_initialize_buffer_out(HWVoiceOut *hw);
|
||||
void audio_generic_run_buffer_out(HWVoiceOut *hw);
|
||||
size_t audio_generic_buffer_get_free(HWVoiceOut *hw);
|
||||
void *audio_generic_get_buffer_out(HWVoiceOut *hw, size_t *size);
|
||||
|
||||
+22
-28
@@ -360,10 +360,7 @@ static OSStatus audioDeviceIOProc(
|
||||
static OSStatus init_out_device(coreaudioVoiceOut *core)
|
||||
{
|
||||
OSStatus status;
|
||||
AudioDeviceID deviceID;
|
||||
AudioValueRange frameRange;
|
||||
UInt32 audioDevicePropertyBufferFrameSize;
|
||||
AudioDeviceIOProcID ioprocid;
|
||||
|
||||
AudioStreamBasicDescription streamBasicDescription = {
|
||||
.mBitsPerChannel = core->hw.info.bits,
|
||||
@@ -376,19 +373,20 @@ static OSStatus init_out_device(coreaudioVoiceOut *core)
|
||||
.mSampleRate = core->hw.info.freq
|
||||
};
|
||||
|
||||
status = coreaudio_get_voice(&deviceID);
|
||||
status = coreaudio_get_voice(&core->outputDeviceID);
|
||||
if (status != kAudioHardwareNoError) {
|
||||
coreaudio_playback_logerr (status,
|
||||
"Could not get default output Device\n");
|
||||
return status;
|
||||
}
|
||||
if (deviceID == kAudioDeviceUnknown) {
|
||||
if (core->outputDeviceID == kAudioDeviceUnknown) {
|
||||
dolog ("Could not initialize playback - Unknown Audiodevice\n");
|
||||
return status;
|
||||
}
|
||||
|
||||
/* get minimum and maximum buffer frame sizes */
|
||||
status = coreaudio_get_framesizerange(deviceID, &frameRange);
|
||||
status = coreaudio_get_framesizerange(core->outputDeviceID,
|
||||
&frameRange);
|
||||
if (status == kAudioHardwareBadObjectError) {
|
||||
return 0;
|
||||
}
|
||||
@@ -399,31 +397,31 @@ static OSStatus init_out_device(coreaudioVoiceOut *core)
|
||||
}
|
||||
|
||||
if (frameRange.mMinimum > core->frameSizeSetting) {
|
||||
audioDevicePropertyBufferFrameSize = (UInt32) frameRange.mMinimum;
|
||||
core->audioDevicePropertyBufferFrameSize = (UInt32) frameRange.mMinimum;
|
||||
dolog ("warning: Upsizing Buffer Frames to %f\n", frameRange.mMinimum);
|
||||
} else if (frameRange.mMaximum < core->frameSizeSetting) {
|
||||
audioDevicePropertyBufferFrameSize = (UInt32) frameRange.mMaximum;
|
||||
core->audioDevicePropertyBufferFrameSize = (UInt32) frameRange.mMaximum;
|
||||
dolog ("warning: Downsizing Buffer Frames to %f\n", frameRange.mMaximum);
|
||||
} else {
|
||||
audioDevicePropertyBufferFrameSize = core->frameSizeSetting;
|
||||
core->audioDevicePropertyBufferFrameSize = core->frameSizeSetting;
|
||||
}
|
||||
|
||||
/* set Buffer Frame Size */
|
||||
status = coreaudio_set_framesize(deviceID,
|
||||
&audioDevicePropertyBufferFrameSize);
|
||||
status = coreaudio_set_framesize(core->outputDeviceID,
|
||||
&core->audioDevicePropertyBufferFrameSize);
|
||||
if (status == kAudioHardwareBadObjectError) {
|
||||
return 0;
|
||||
}
|
||||
if (status != kAudioHardwareNoError) {
|
||||
coreaudio_playback_logerr (status,
|
||||
"Could not set device buffer frame size %" PRIu32 "\n",
|
||||
(uint32_t)audioDevicePropertyBufferFrameSize);
|
||||
(uint32_t)core->audioDevicePropertyBufferFrameSize);
|
||||
return status;
|
||||
}
|
||||
|
||||
/* get Buffer Frame Size */
|
||||
status = coreaudio_get_framesize(deviceID,
|
||||
&audioDevicePropertyBufferFrameSize);
|
||||
status = coreaudio_get_framesize(core->outputDeviceID,
|
||||
&core->audioDevicePropertyBufferFrameSize);
|
||||
if (status == kAudioHardwareBadObjectError) {
|
||||
return 0;
|
||||
}
|
||||
@@ -432,9 +430,11 @@ static OSStatus init_out_device(coreaudioVoiceOut *core)
|
||||
"Could not get device buffer frame size\n");
|
||||
return status;
|
||||
}
|
||||
core->hw.samples = core->bufferCount * core->audioDevicePropertyBufferFrameSize;
|
||||
|
||||
/* set Samplerate */
|
||||
status = coreaudio_set_streamformat(deviceID, &streamBasicDescription);
|
||||
status = coreaudio_set_streamformat(core->outputDeviceID,
|
||||
&streamBasicDescription);
|
||||
if (status == kAudioHardwareBadObjectError) {
|
||||
return 0;
|
||||
}
|
||||
@@ -442,6 +442,7 @@ static OSStatus init_out_device(coreaudioVoiceOut *core)
|
||||
coreaudio_playback_logerr (status,
|
||||
"Could not set samplerate %lf\n",
|
||||
streamBasicDescription.mSampleRate);
|
||||
core->outputDeviceID = kAudioDeviceUnknown;
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -455,25 +456,20 @@ static OSStatus init_out_device(coreaudioVoiceOut *core)
|
||||
* Therefore, the specified callback must be designed to avoid a deadlock
|
||||
* with the callers of AudioObjectGetPropertyData.
|
||||
*/
|
||||
ioprocid = NULL;
|
||||
status = AudioDeviceCreateIOProcID(deviceID,
|
||||
core->ioprocid = NULL;
|
||||
status = AudioDeviceCreateIOProcID(core->outputDeviceID,
|
||||
audioDeviceIOProc,
|
||||
&core->hw,
|
||||
&ioprocid);
|
||||
&core->ioprocid);
|
||||
if (status == kAudioHardwareBadDeviceError) {
|
||||
return 0;
|
||||
}
|
||||
if (status != kAudioHardwareNoError || ioprocid == NULL) {
|
||||
if (status != kAudioHardwareNoError || core->ioprocid == NULL) {
|
||||
coreaudio_playback_logerr (status, "Could not set IOProc\n");
|
||||
core->outputDeviceID = kAudioDeviceUnknown;
|
||||
return status;
|
||||
}
|
||||
|
||||
core->outputDeviceID = deviceID;
|
||||
core->audioDevicePropertyBufferFrameSize = audioDevicePropertyBufferFrameSize;
|
||||
core->hw.samples = core->bufferCount * core->audioDevicePropertyBufferFrameSize;
|
||||
audio_generic_initialize_buffer_out(&core->hw);
|
||||
core->ioprocid = ioprocid;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -557,9 +553,7 @@ static OSStatus handle_voice_change(
|
||||
fini_out_device(core);
|
||||
}
|
||||
|
||||
init_out_device(core);
|
||||
|
||||
if (core->outputDeviceID) {
|
||||
if (!init_out_device(core)) {
|
||||
update_device_playback_state(core);
|
||||
}
|
||||
|
||||
|
||||
+37
-7
@@ -37,8 +37,15 @@
|
||||
|
||||
// #define DEBUG_VERBOSE
|
||||
|
||||
/* CURL 7.85.0 switches to a string based API for specifying
|
||||
* the desired protocols.
|
||||
*/
|
||||
#if LIBCURL_VERSION_NUM >= 0x075500
|
||||
#define PROTOCOLS "HTTP,HTTPS,FTP,FTPS"
|
||||
#else
|
||||
#define PROTOCOLS (CURLPROTO_HTTP | CURLPROTO_HTTPS | \
|
||||
CURLPROTO_FTP | CURLPROTO_FTPS)
|
||||
#endif
|
||||
|
||||
#define CURL_NUM_STATES 8
|
||||
#define CURL_NUM_ACB 8
|
||||
@@ -509,9 +516,18 @@ static int curl_init_state(BDRVCURLState *s, CURLState *state)
|
||||
* obscure protocols. For example, do not allow POP3/SMTP/IMAP see
|
||||
* CVE-2013-0249.
|
||||
*
|
||||
* Restricting protocols is only supported from 7.19.4 upwards.
|
||||
* Restricting protocols is only supported from 7.19.4 upwards. Note:
|
||||
* version 7.85.0 deprecates CURLOPT_*PROTOCOLS in favour of a string
|
||||
* based CURLOPT_*PROTOCOLS_STR API.
|
||||
*/
|
||||
#if LIBCURL_VERSION_NUM >= 0x071304
|
||||
#if LIBCURL_VERSION_NUM >= 0x075500
|
||||
if (curl_easy_setopt(state->curl,
|
||||
CURLOPT_PROTOCOLS_STR, PROTOCOLS) ||
|
||||
curl_easy_setopt(state->curl,
|
||||
CURLOPT_REDIR_PROTOCOLS_STR, PROTOCOLS)) {
|
||||
goto err;
|
||||
}
|
||||
#elif LIBCURL_VERSION_NUM >= 0x071304
|
||||
if (curl_easy_setopt(state->curl, CURLOPT_PROTOCOLS, PROTOCOLS) ||
|
||||
curl_easy_setopt(state->curl, CURLOPT_REDIR_PROTOCOLS, PROTOCOLS)) {
|
||||
goto err;
|
||||
@@ -669,7 +685,12 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
const char *file;
|
||||
const char *cookie;
|
||||
const char *cookie_secret;
|
||||
double d;
|
||||
/* CURL >= 7.55.0 uses curl_off_t for content length instead of a double */
|
||||
#if LIBCURL_VERSION_NUM >= 0x073700
|
||||
curl_off_t cl;
|
||||
#else
|
||||
double cl;
|
||||
#endif
|
||||
const char *secretid;
|
||||
const char *protocol_delimiter;
|
||||
int ret;
|
||||
@@ -796,27 +817,36 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
}
|
||||
if (curl_easy_perform(state->curl))
|
||||
goto out;
|
||||
if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d)) {
|
||||
/* CURL 7.55.0 deprecates CURLINFO_CONTENT_LENGTH_DOWNLOAD in favour of
|
||||
* the *_T version which returns a more sensible type for content length.
|
||||
*/
|
||||
#if LIBCURL_VERSION_NUM >= 0x073700
|
||||
if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &cl)) {
|
||||
goto out;
|
||||
}
|
||||
#else
|
||||
if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl)) {
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
/* Prior CURL 7.19.4 return value of 0 could mean that the file size is not
|
||||
* know or the size is zero. From 7.19.4 CURL returns -1 if size is not
|
||||
* known and zero if it is really zero-length file. */
|
||||
#if LIBCURL_VERSION_NUM >= 0x071304
|
||||
if (d < 0) {
|
||||
if (cl < 0) {
|
||||
pstrcpy(state->errmsg, CURL_ERROR_SIZE,
|
||||
"Server didn't report file size.");
|
||||
goto out;
|
||||
}
|
||||
#else
|
||||
if (d <= 0) {
|
||||
if (cl <= 0) {
|
||||
pstrcpy(state->errmsg, CURL_ERROR_SIZE,
|
||||
"Unknown file size or zero-length file.");
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
|
||||
s->len = d;
|
||||
s->len = cl;
|
||||
|
||||
if ((!strncasecmp(s->url, "http://", strlen("http://"))
|
||||
|| !strncasecmp(s->url, "https://", strlen("https://")))
|
||||
|
||||
+2
-19
@@ -43,10 +43,10 @@
|
||||
|
||||
#if defined(__APPLE__) && (__MACH__)
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#if defined(HAVE_HOST_BLOCK_DEVICE)
|
||||
#include <paths.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#include <IOKit/IOKitLib.h>
|
||||
#include <IOKit/IOBSD.h>
|
||||
#include <IOKit/storage/IOMediaBSDClient.h>
|
||||
@@ -130,14 +130,6 @@
|
||||
#define RAW_LOCK_PERM_BASE 100
|
||||
#define RAW_LOCK_SHARED_BASE 200
|
||||
|
||||
/*
|
||||
* qemu_lock_fd_test always returns 0 when fd is not open for writing and
|
||||
* exclusive is true on macOS 11.3.1.
|
||||
*/
|
||||
#ifdef __APPLE__
|
||||
#define RAW_LOCK_WRITES
|
||||
#endif
|
||||
|
||||
typedef struct BDRVRawState {
|
||||
int fd;
|
||||
bool use_lock;
|
||||
@@ -681,11 +673,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
|
||||
false);
|
||||
|
||||
s->open_flags = open_flags;
|
||||
#ifdef RAW_LOCK_WRITES
|
||||
raw_parse_flags(bdrv_flags, &s->open_flags, s->use_lock);
|
||||
#else
|
||||
raw_parse_flags(bdrv_flags, &s->open_flags, false);
|
||||
#endif
|
||||
|
||||
s->fd = -1;
|
||||
fd = qemu_open(filename, s->open_flags, errp);
|
||||
@@ -1050,11 +1038,6 @@ static int raw_reconfigure_getfd(BlockDriverState *bs, int flags,
|
||||
bool has_writers = perm &
|
||||
(BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED | BLK_PERM_RESIZE);
|
||||
int fcntl_flags = O_APPEND | O_NONBLOCK;
|
||||
#ifdef RAW_LOCK_WRITES
|
||||
if (s->use_lock) {
|
||||
has_writers = true;
|
||||
}
|
||||
#endif
|
||||
#ifdef O_NOATIME
|
||||
fcntl_flags |= O_NOATIME;
|
||||
#endif
|
||||
|
||||
@@ -2087,6 +2087,9 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
|
||||
if (bs->detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP) {
|
||||
flags |= BDRV_REQ_MAY_UNMAP;
|
||||
}
|
||||
|
||||
/* Can't use optimization hint with bufferless zero write */
|
||||
flags &= ~BDRV_REQ_REGISTERED_BUF;
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
|
||||
@@ -268,6 +268,7 @@ iscsi_co_generic_cb(struct iscsi_context *iscsi, int status,
|
||||
timer_mod(&iTask->retry_timer,
|
||||
qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + retry_time);
|
||||
iTask->do_retry = 1;
|
||||
return;
|
||||
} else if (status == SCSI_STATUS_CHECK_CONDITION) {
|
||||
int error = iscsi_translate_sense(&task->sense);
|
||||
if (error == EAGAIN) {
|
||||
|
||||
@@ -115,7 +115,7 @@ static int update_header_sync(BlockDriverState *bs)
|
||||
return bdrv_flush(bs->file->bs);
|
||||
}
|
||||
|
||||
static inline void bitmap_table_to_be(uint64_t *bitmap_table, size_t size)
|
||||
static inline void bitmap_table_bswap_be(uint64_t *bitmap_table, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
@@ -1401,9 +1401,10 @@ static int store_bitmap(BlockDriverState *bs, Qcow2Bitmap *bm, Error **errp)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
bitmap_table_to_be(tb, tb_size);
|
||||
bitmap_table_bswap_be(tb, tb_size);
|
||||
ret = bdrv_pwrite(bs->file, tb_offset, tb_size * sizeof(tb[0]), tb, 0);
|
||||
if (ret < 0) {
|
||||
bitmap_table_bswap_be(tb, tb_size);
|
||||
error_setg_errno(errp, -ret, "Failed to write bitmap '%s' to file",
|
||||
bm_name);
|
||||
goto fail;
|
||||
|
||||
+1
-1
@@ -980,7 +980,7 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVVHDXState *s,
|
||||
sector_write = merged_sector;
|
||||
} else if (i == sectors - 1 && trailing_length) {
|
||||
/* partial sector at the end of the buffer */
|
||||
ret = bdrv_pread(bs->file, file_offset,
|
||||
ret = bdrv_pread(bs->file, file_offset + trailing_length,
|
||||
VHDX_LOG_SECTOR_SIZE - trailing_length,
|
||||
merged_sector + trailing_length, 0);
|
||||
if (ret < 0) {
|
||||
|
||||
@@ -1065,6 +1065,7 @@ static void char_socket_finalize(Object *obj)
|
||||
qio_net_listener_set_client_func_full(s->listener, NULL, NULL,
|
||||
NULL, chr->gcontext);
|
||||
object_unref(OBJECT(s->listener));
|
||||
s->listener = NULL;
|
||||
}
|
||||
if (s->tls_creds) {
|
||||
object_unref(OBJECT(s->tls_creds));
|
||||
|
||||
@@ -290,7 +290,6 @@ meson=""
|
||||
ninja=""
|
||||
bindir="bin"
|
||||
skip_meson=no
|
||||
shared_lib="no"
|
||||
vfio_user_server="disabled"
|
||||
|
||||
# The following Meson options are handled manually (still they
|
||||
@@ -897,12 +896,6 @@ for opt do
|
||||
;;
|
||||
--enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc
|
||||
;;
|
||||
--enable-shared-lib)
|
||||
shared_lib="yes"
|
||||
plugins="no"
|
||||
;;
|
||||
--disable-shared-lib) shared_lib="no"
|
||||
;;
|
||||
# everything else has the same name in configure and meson
|
||||
--*) meson_option_parse "$opt" "$optarg"
|
||||
;;
|
||||
@@ -914,10 +907,6 @@ if test "$plugins" = "yes" -a "$tcg" = "disabled"; then
|
||||
error_exit "Can't enable plugins on non-TCG builds"
|
||||
fi
|
||||
|
||||
if test "$plugins" = "yes" -a "$shared_lib" = "yes"; then
|
||||
error_exit "Can't enable plugins on shared library builds"
|
||||
fi
|
||||
|
||||
case $git_submodules_action in
|
||||
update|validate)
|
||||
if test ! -e "$source_path/.git"; then
|
||||
@@ -1042,7 +1031,7 @@ Advanced options (experts only):
|
||||
--disable-stack-protector disable compiler-provided stack protection
|
||||
--cpu=CPU Build for host CPU [$cpu]
|
||||
--with-coroutine=BACKEND coroutine backend. Supported options:
|
||||
ucontext, libucontext, sigaltstack, windows
|
||||
ucontext, sigaltstack, windows
|
||||
--enable-plugins
|
||||
enable plugins via shared library loading
|
||||
--disable-containers don't use containers for cross-building
|
||||
@@ -1606,26 +1595,12 @@ else
|
||||
error_exit "only the 'windows' coroutine backend is valid for Windows"
|
||||
fi
|
||||
;;
|
||||
libucontext)
|
||||
;;
|
||||
*)
|
||||
error_exit "unknown coroutine backend $coroutine"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case $coroutine in
|
||||
libucontext)
|
||||
git_submodules="${git_submodules} subprojects/libucontext"
|
||||
coroutine_impl=ucontext
|
||||
libucontext="enabled"
|
||||
;;
|
||||
*)
|
||||
coroutine_impl=$coroutine
|
||||
libucontext="disabled"
|
||||
;;
|
||||
esac
|
||||
|
||||
##################################################
|
||||
# SafeStack
|
||||
|
||||
@@ -2403,7 +2378,7 @@ if [ "$bsd" = "yes" ] ; then
|
||||
echo "CONFIG_BSD=y" >> $config_host_mak
|
||||
fi
|
||||
|
||||
echo "CONFIG_COROUTINE_BACKEND=$coroutine_impl" >> $config_host_mak
|
||||
echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
|
||||
|
||||
if test "$have_asan_iface_fiber" = "yes" ; then
|
||||
echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
|
||||
@@ -2417,10 +2392,6 @@ if test "$plugins" = "yes" ; then
|
||||
echo "CONFIG_PLUGIN=y" >> $config_host_mak
|
||||
fi
|
||||
|
||||
if test "$shared_lib" = "yes" ; then
|
||||
echo "CONFIG_SHARED_LIBRARY_BUILD=y" >> $config_host_mak
|
||||
fi
|
||||
|
||||
if test -n "$gdb_bin"; then
|
||||
gdb_version=$($gdb_bin --version | head -n 1)
|
||||
if version_ge ${gdb_version##* } 9.1; then
|
||||
@@ -2445,7 +2416,7 @@ echo "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak
|
||||
echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
|
||||
echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
|
||||
echo "GLIB_BINDIR=$glib_bindir" >> $config_host_mak
|
||||
echo "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak
|
||||
echo "GLIB_VERSION=$($pkg_config --modversion glib-2.0)" >> $config_host_mak
|
||||
echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
|
||||
echo "EXESUF=$EXESUF" >> $config_host_mak
|
||||
|
||||
@@ -2587,11 +2558,7 @@ if test "$skip_meson" = no; then
|
||||
if has $sdl2_config; then
|
||||
echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
|
||||
fi
|
||||
if test "$shared_lib" = "yes"; then
|
||||
echo "strip = [$(meson_quote $strip), '-x']" >> $cross
|
||||
else
|
||||
echo "strip = [$(meson_quote $strip)]" >> $cross
|
||||
fi
|
||||
echo "strip = [$(meson_quote $strip)]" >> $cross
|
||||
echo "widl = [$(meson_quote $widl)]" >> $cross
|
||||
echo "windres = [$(meson_quote $windres)]" >> $cross
|
||||
if test "$cross_compile" = "yes"; then
|
||||
|
||||
@@ -323,7 +323,7 @@ virgl_cmd_set_scanout(VuGpu *g,
|
||||
struct virtio_gpu_ctrl_command *cmd)
|
||||
{
|
||||
struct virtio_gpu_set_scanout ss;
|
||||
struct virgl_renderer_texture_info info;
|
||||
struct virgl_renderer_resource_info info;
|
||||
int ret;
|
||||
|
||||
VUGPU_FILL_CMD(ss);
|
||||
@@ -338,7 +338,7 @@ virgl_cmd_set_scanout(VuGpu *g,
|
||||
memset(&info, 0, sizeof(info));
|
||||
|
||||
if (ss.resource_id && ss.r.width && ss.r.height) {
|
||||
ret = virgl_renderer_borrow_texture_for_scanout(ss.resource_id, &info);
|
||||
ret = virgl_renderer_resource_get_info(ss.resource_id, &info);
|
||||
if (ret == -1) {
|
||||
g_critical("%s: illegal resource specified %d\n",
|
||||
__func__, ss.resource_id);
|
||||
|
||||
@@ -151,8 +151,6 @@ static void initialize_debug_host(CPUDebug *s)
|
||||
#endif
|
||||
#if defined(CONFIG_TCG_INTERPRETER)
|
||||
s->info.print_insn = print_insn_tci;
|
||||
#elif defined(CONFIG_TCG_THREADED_INTERPRETER)
|
||||
s->info.print_insn = print_insn_tcti;
|
||||
#elif defined(__i386__)
|
||||
s->info.mach = bfd_mach_i386_i386;
|
||||
s->info.cap_arch = CS_ARCH_X86;
|
||||
|
||||
@@ -52,6 +52,9 @@ static const MemoryRegionOps AcpiCpuHotplug_ops = {
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
.valid = {
|
||||
.min_access_size = 1,
|
||||
.max_access_size = 4,
|
||||
},
|
||||
.impl = {
|
||||
.max_access_size = 1,
|
||||
},
|
||||
};
|
||||
|
||||
+4
-1
@@ -686,7 +686,10 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
|
||||
qemu_register_reset_nosnapshotload(qemu_fdt_randomize_seeds,
|
||||
rom_ptr_for_as(as, addr, size));
|
||||
|
||||
g_free(fdt);
|
||||
if (fdt != ms->fdt) {
|
||||
g_free(ms->fdt);
|
||||
ms->fdt = fdt;
|
||||
}
|
||||
|
||||
return size;
|
||||
|
||||
|
||||
@@ -1713,11 +1713,7 @@ static void virt_set_memmap(VirtMachineState *vms, int pa_bits)
|
||||
* irrespective of the underlying capabilities of the HW.
|
||||
*/
|
||||
if (!vms->highmem) {
|
||||
#ifdef CONFIG_DARWIN
|
||||
pa_bits = 36;
|
||||
#else
|
||||
pa_bits = 32;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -47,6 +47,3 @@ config PL041
|
||||
|
||||
config CS4231
|
||||
bool
|
||||
|
||||
config SCREAMER
|
||||
bool
|
||||
@@ -12,4 +12,3 @@ softmmu_ss.add(when: 'CONFIG_PL041', if_true: files('pl041.c', 'lm4549.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_SB16', if_true: files('sb16.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_VT82C686', if_true: files('via-ac97.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_WM8750', if_true: files('wm8750.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_SCREAMER', if_true: files('screamer.c'))
|
||||
@@ -1,986 +0,0 @@
|
||||
/*
|
||||
* File: Screamer.c
|
||||
* Description: Implement the Screamer sound chip used in Apple Macintoshes.
|
||||
* It works by filling a buffer, then playing the buffer.
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "audio/audio.h"
|
||||
#include "hw/hw.h"
|
||||
#include "hw/irq.h"
|
||||
#include <inttypes.h>
|
||||
#include "hw/ppc/mac_dbdma.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "migration/vmstate.h"
|
||||
#include "include/hw/audio/screamer.h"
|
||||
|
||||
#define DEBUG_SCREAMER 0
|
||||
#define DPRINTF(fmt, ...) \
|
||||
do { if (DEBUG_SCREAMER) { printf(fmt , ## __VA_ARGS__); } } while (0)
|
||||
|
||||
#define SOUND_CONTROL_REG 0
|
||||
#define CODEC_CONTROL_REG 1
|
||||
#define CODEC_STATUS_REG 2
|
||||
#define CLIP_COUNT_REG 3
|
||||
#define BYTE_SWAP_REG 4
|
||||
#define FRAME_COUNT_REG 5
|
||||
|
||||
#define AWACS_BUSY 0x01000000
|
||||
|
||||
/* Used with AWACS register 1 */
|
||||
#define RECALIBRATE 0x004
|
||||
#define LOOPTHRU 0x040
|
||||
#define SPEAKER_MUTE 0x080
|
||||
#define HEADPHONE_MUTE 0x200
|
||||
#define OUTPUT_ZERO 0x400
|
||||
#define OUTPUT_ONE 0x800
|
||||
#define PARALLEL_OUTPUT 0xc00
|
||||
|
||||
/* Function prototypes */
|
||||
static uint32_t set_busy_bit(uint32_t value, int bit);
|
||||
static uint32_t set_part_ready_bit(uint32_t value, int bit_value);
|
||||
static uint32_t set_revision(uint32_t input_value);
|
||||
static uint32_t set_manufacturer(uint32_t input_value);
|
||||
static int get_sampling_rate(ScreamerState *s);
|
||||
static uint32_t get_frame_count_reg(ScreamerState *s);
|
||||
static void add_to_speaker_buffer(DBDMA_io *io);
|
||||
static void dma_request(DBDMA_io *io);
|
||||
|
||||
|
||||
/**************************** Getters *************************/
|
||||
|
||||
/* Returns the codec control register's encoded AWACS address */
|
||||
static uint8_t get_codec_control_address(uint32_t value)
|
||||
{
|
||||
uint8_t return_value;
|
||||
return_value = (value >> 12) & 0x00000fff;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
static uint32_t get_sound_control_reg(ScreamerState *s)
|
||||
{
|
||||
DPRINTF("%s() called - returned 0x%x\n", __func__, s->sound_control);
|
||||
return s->sound_control;
|
||||
}
|
||||
|
||||
/* The AWACS registers are accessed thru this register */
|
||||
static uint32_t get_codec_control_reg(ScreamerState *s)
|
||||
{
|
||||
int awacs_register = get_codec_control_address(s->codec_control);
|
||||
uint32_t return_value = s->awacs[awacs_register];
|
||||
return_value = set_busy_bit(return_value, 0); /* Tell CPU we are ready */
|
||||
DPRINTF("%s() called - returned 0x%x\tAWACS register: %d\n", __func__,
|
||||
return_value, awacs_register);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Determines if the readback bit is set.
|
||||
* It is used by the Codec Control register.
|
||||
*/
|
||||
static bool readback_enabled(ScreamerState *s)
|
||||
{
|
||||
/* Note: bit zero is the readback enabled bit */
|
||||
if (s->awacs[7] & 1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t get_codec_status_reg(ScreamerState *s)
|
||||
{
|
||||
uint32_t return_value;
|
||||
|
||||
/* if in readback mode - return AWACS register value */
|
||||
if (readback_enabled(s)) {
|
||||
int awacs_register = (s->awacs[7] & 0xe) >> 1;
|
||||
s->awacs[7] = s->awacs[7] & 0xfffffffe; /* turn off readback mode */
|
||||
return_value = s->awacs[awacs_register] << 4;
|
||||
DPRINTF("readback enable bit is set, returning AWACS register %d\t"
|
||||
"value:0x%x\n", awacs_register, return_value);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/* Tell CPU we are ready */
|
||||
return_value = set_part_ready_bit(s->codec_status, 1);
|
||||
|
||||
/* Set Revision to Screamer */
|
||||
return_value = set_revision(return_value);
|
||||
|
||||
/* Set the Manufacturer to Crystal */
|
||||
return_value = set_manufacturer(return_value);
|
||||
DPRINTF("%s() called - returned 0x%x\n", __func__, return_value);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
static uint32_t get_clip_count_reg(ScreamerState *s)
|
||||
{
|
||||
DPRINTF("%s() called - returned 0x%x\n", __func__, s->clip_count);
|
||||
uint32_t return_value;
|
||||
return_value = s->clip_count;
|
||||
/* This is reset everytime it is read */
|
||||
s->clip_count = 0;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
static uint32_t get_byte_swap_reg(ScreamerState *s)
|
||||
{
|
||||
DPRINTF("%s() called - returned 0x%x\n", __func__, s->byte_swap);
|
||||
/*
|
||||
* If all you hear is noise, it could be this register reporting the
|
||||
* wrong value.
|
||||
*/
|
||||
return s->byte_swap ? 0 : 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the frame (sample) count
|
||||
*/
|
||||
static uint32_t get_frame_count_reg(ScreamerState *s)
|
||||
{
|
||||
DPRINTF("%s() called - returned 0x%x\n", __func__, s->frame_count);
|
||||
return s->frame_count;
|
||||
}
|
||||
|
||||
static uint8_t get_left_vol(uint32_t value)
|
||||
{
|
||||
return value & 0xf;
|
||||
}
|
||||
|
||||
static uint8_t get_right_vol(uint32_t value)
|
||||
{
|
||||
return value & 0x3c0 >> 6;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the sampling rate.
|
||||
* If the audio is playing back too fast or too slow, this function may be the
|
||||
* cause.
|
||||
*/
|
||||
static int get_sampling_rate(ScreamerState *s)
|
||||
{
|
||||
uint32_t screamer_rate = s->sound_control & 0x700;
|
||||
int return_value;
|
||||
|
||||
/* All return values are in Hertz */
|
||||
switch (screamer_rate) {
|
||||
case 0x0:
|
||||
return_value = 44100;
|
||||
break;
|
||||
case 0x100:
|
||||
return_value = 29400;
|
||||
break;
|
||||
case 0x200:
|
||||
return_value = 22050;
|
||||
break;
|
||||
case 0x300:
|
||||
return_value = 17640;
|
||||
break;
|
||||
case 0x400:
|
||||
return_value = 14700;
|
||||
break;
|
||||
case 0x500:
|
||||
return_value = 11025;
|
||||
break;
|
||||
case 0x600:
|
||||
return_value = 8820;
|
||||
break;
|
||||
case 0x700:
|
||||
return_value = 7350;
|
||||
break;
|
||||
default:
|
||||
DPRINTF("get_sampling_rate() unknown value: 0x%x\nDefaulting to"
|
||||
" 44100 Hz.\n", screamer_rate);
|
||||
return 44100;
|
||||
}
|
||||
DPRINTF("%s() called - returning %dHz\n", __func__, return_value);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/**************************** End of getters *************************/
|
||||
|
||||
/***************************** Speaker call back *************************/
|
||||
|
||||
/* resets the play and buffer position markers */
|
||||
static void reset_markers(ScreamerState *s)
|
||||
{
|
||||
s->spk_play_position = 0;
|
||||
s->spk_buffer_position = 0;
|
||||
}
|
||||
|
||||
|
||||
/* Sends the samples to the host for playing */
|
||||
static void send_samples_to_host(ScreamerState *s, int max_samples)
|
||||
{
|
||||
int write_length, requested_length;
|
||||
requested_length = MIN(max_samples, (s->spk_buffer_position -
|
||||
s->spk_play_position));
|
||||
write_length = AUD_write(s->speaker_voice,
|
||||
&s->spk_buffer[s->spk_play_position],
|
||||
requested_length);
|
||||
DPRINTF("requested length: %d\twrite length: %d\t",
|
||||
requested_length, write_length);
|
||||
s->spk_play_position += write_length;
|
||||
DPRINTF("AUD_write %d/%d\n", s->spk_play_position, s->spk_buffer_position);
|
||||
s->frame_count += write_length;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called by QEMU's audio system to tell the output backend to send samples
|
||||
* from the buffer to the host sound system.
|
||||
* opaque: a pointer to the ScreamerState instance.
|
||||
* max_samples: the number of samples that can be sent to the hardware buffer.
|
||||
*/
|
||||
static void speaker_callback(void *opaque, int max_samples)
|
||||
{
|
||||
ScreamerState *s = (ScreamerState *) opaque;
|
||||
|
||||
/* if we have more samples to play */
|
||||
if (s->spk_buffer_position > 0) {
|
||||
if (s->spk_buffer_position > s->spk_play_position) {
|
||||
DPRINTF("%s() called - max_samples: %d\n", __func__, max_samples);
|
||||
send_samples_to_host(s, max_samples);
|
||||
}
|
||||
if (s->spk_play_position >= s->spk_buffer_position) {
|
||||
DPRINTF("done playing buffer\n");
|
||||
DPRINTF("pp: %d\tbp: %d\n", s->spk_play_position,
|
||||
s->spk_buffer_position);
|
||||
if (s->spk_play_position > s->spk_buffer_position) {
|
||||
DPRINTF("Error detected! - pp > bp\n\a");
|
||||
}
|
||||
reset_markers(s);
|
||||
/* play postponed samples */
|
||||
if (s->dma_io.len > 0) {
|
||||
DPRINTF("playing postponed samples\n");
|
||||
add_to_speaker_buffer(&s->dma_io);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/************************* End of speaker call back *************************/
|
||||
|
||||
|
||||
/* Opens the speaker's voice */
|
||||
static void open_speaker_voice(ScreamerState *s)
|
||||
{
|
||||
DPRINTF("%s() called\n", __func__);
|
||||
|
||||
/* if voice is already open return from function */
|
||||
if (s->speaker_voice != NULL) {
|
||||
DPRINTF("closing speaker voice\n");
|
||||
AUD_close_out(&s->card, s->speaker_voice);
|
||||
s->speaker_voice = NULL;
|
||||
}
|
||||
struct audsettings audio_settings;
|
||||
audio_settings.freq = get_sampling_rate(s); /* in hertz */
|
||||
audio_settings.nchannels = 2; /* stereo output */
|
||||
audio_settings.fmt = AUDIO_FORMAT_S16; /* signed 16 bit */
|
||||
audio_settings.endianness = get_byte_swap_reg(s); /* endianness */
|
||||
s->speaker_voice = AUD_open_out(&s->card, s->speaker_voice, SOUND_CHIP_NAME
|
||||
" speaker", s, speaker_callback,
|
||||
&audio_settings);
|
||||
if (!s->speaker_voice) {
|
||||
AUD_log(SOUND_CHIP_NAME, "Out voice could not be opened\n");
|
||||
} else {
|
||||
AUD_set_active_out(s->speaker_voice, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/******************************* Setters *************************************/
|
||||
|
||||
|
||||
/* Updates QEMU's audio backend settings */
|
||||
static void set_QEMU_audio_settings(ScreamerState *s)
|
||||
{
|
||||
DPRINTF("%s() called\n", __func__);
|
||||
open_speaker_voice(s);
|
||||
}
|
||||
|
||||
|
||||
/* Return value: 1 = muted 0 = not muted */
|
||||
static int is_muted(ScreamerState *s)
|
||||
{
|
||||
int mute_state = s->awacs[1] & SPEAKER_MUTE ? 1 : 0;
|
||||
if (s->awacs[1] & SPEAKER_MUTE) {
|
||||
DPRINTF("speaker is muted\n");
|
||||
} else {
|
||||
DPRINTF("speaker is unmuted\n");
|
||||
}
|
||||
|
||||
if (s->awacs[1] & HEADPHONE_MUTE) {
|
||||
DPRINTF("headphone is muted\n");
|
||||
} else {
|
||||
DPRINTF("headphone is unmuted\n");
|
||||
}
|
||||
return mute_state;
|
||||
}
|
||||
|
||||
|
||||
/* Converts Screamer's volume system to QEMU's system */
|
||||
static int screamer_to_qemu_volume(int x)
|
||||
{
|
||||
return -16 * x + 240;
|
||||
}
|
||||
|
||||
|
||||
/* Sets QEMU's volume. */
|
||||
static void set_volume(ScreamerState *s)
|
||||
{
|
||||
int should_mute = is_muted(s);
|
||||
|
||||
/* Get Screamer volume values */
|
||||
uint8_t left_vol = get_left_vol(s->awacs[4]);
|
||||
uint8_t right_vol = get_right_vol(s->awacs[4]);
|
||||
DPRINTF("set_volume() called - M:%d\tL:%d\tR:%d\n", should_mute, left_vol,
|
||||
right_vol);
|
||||
|
||||
/* Convert Screamer to QEMU volume values */
|
||||
left_vol = screamer_to_qemu_volume(left_vol);
|
||||
right_vol = screamer_to_qemu_volume(right_vol);
|
||||
DPRINTF("QEMU volume: L:%d\tR:%d\n", left_vol, right_vol);
|
||||
AUD_set_volume_out(s->speaker_voice, should_mute, left_vol, right_vol);
|
||||
}
|
||||
|
||||
|
||||
/* Sets the sound control register */
|
||||
static void set_sound_control_reg(ScreamerState *s, uint32_t value)
|
||||
{
|
||||
DPRINTF("set_sound_control_reg() called - value: 0x%x\n", value);
|
||||
s->sound_control = value;
|
||||
set_QEMU_audio_settings(s);
|
||||
}
|
||||
|
||||
|
||||
/* Used for input gain only - can be ignored for now. */
|
||||
static void set_awacs_0_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("Settings AWACS register 0 to 0x%x\n", s->awacs[0]);
|
||||
s->awacs[0] = new_value;
|
||||
}
|
||||
|
||||
|
||||
static void set_awacs_1_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("Settings AWACS register 1 to 0x%x\n", new_value);
|
||||
|
||||
s->awacs[1] = new_value;
|
||||
|
||||
/* If recalibration requested */
|
||||
if (new_value & RECALIBRATE) {
|
||||
DPRINTF("Recalibration requested - unimplemented\n");
|
||||
new_value = new_value ^ RECALIBRATE; /* Turn off recalibrate bit */
|
||||
}
|
||||
|
||||
/* If loop thru set - what does this mean? */
|
||||
if (new_value & LOOPTHRU) {
|
||||
DPRINTF("Loopthru enabled - doing nothing\n");
|
||||
}
|
||||
|
||||
/* Set headphone jack mute state */
|
||||
if (new_value & HEADPHONE_MUTE) {
|
||||
DPRINTF("Headphone muted\n");
|
||||
}
|
||||
|
||||
else {
|
||||
DPRINTF("Headphone unmuted\n");
|
||||
}
|
||||
|
||||
if (new_value & SPEAKER_MUTE) {
|
||||
DPRINTF("Speaker muted\n");
|
||||
}
|
||||
|
||||
else {
|
||||
DPRINTF("Speaker unmuted\n");
|
||||
}
|
||||
|
||||
if (new_value & OUTPUT_ZERO) {
|
||||
DPRINTF("output zero set - not sure what this means\n");
|
||||
}
|
||||
|
||||
if (new_value & OUTPUT_ONE) {
|
||||
DPRINTF("output one set - not sure what this means\n");
|
||||
}
|
||||
|
||||
if (new_value & PARALLEL_OUTPUT) {
|
||||
DPRINTF("parallel port enabled - but no parallel port here\n");
|
||||
}
|
||||
|
||||
set_volume(s);
|
||||
}
|
||||
|
||||
|
||||
/* This is used for headphone volume - not needed */
|
||||
static void set_awacs_2_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("Settings AWACS register 2 to 0x%x\n"
|
||||
"Ignoring change in headphone volume.\n", s->awacs[2]);
|
||||
s->awacs[2] = new_value;
|
||||
}
|
||||
|
||||
|
||||
/* Unknown register purpose */
|
||||
static void set_awacs_3_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("Settings AWACS register 3 to 0x%x\n"
|
||||
"This register has an unknown purpose and does not do anything\n",
|
||||
s->awacs[3]);
|
||||
s->awacs[3] = new_value;
|
||||
}
|
||||
|
||||
|
||||
/* Mostly deals with speaker volume */
|
||||
static void set_awacs_4_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("AWACS register 4 write: 0x%x\n", new_value);
|
||||
s->awacs[4] = new_value;
|
||||
set_volume(s);
|
||||
}
|
||||
|
||||
|
||||
/* This register is about loop thru stuff I don't understand */
|
||||
static void set_awacs_5_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("Settings AWACS register 5 to 0x%x\n"
|
||||
"Loop thru update ignored.\n", s->awacs[5]);
|
||||
s->awacs[5] = new_value;
|
||||
}
|
||||
|
||||
|
||||
/* Prints the states of the AWACS power register */
|
||||
static void print_power_reg_values(uint32_t value)
|
||||
{
|
||||
if ((value & 0x3) == 0) {
|
||||
printf("Screamer run state set\n");
|
||||
}
|
||||
if ((value & 0x3) == 1) {
|
||||
printf("Screamer doze state set\n");
|
||||
}
|
||||
if ((value & 0x3) == 2) {
|
||||
printf("Screamer idle state set\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Power Magement register */
|
||||
static void set_awacs_6_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("Settings AWACS register 6 to 0x%x\n"
|
||||
"Power management update ignored.\n", s->awacs[6]);
|
||||
if (DEBUG_SCREAMER) {
|
||||
print_power_reg_values(new_value);
|
||||
}
|
||||
s->awacs[6] = new_value;
|
||||
}
|
||||
|
||||
|
||||
/* Read Back - repeating something that was sent to this chip? */
|
||||
static void set_awacs_7_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("Settings AWACS register 7 to 0x%x\n", new_value);
|
||||
s->awacs[7] = new_value;
|
||||
}
|
||||
|
||||
|
||||
/* Sets the AWACs registers - a.k.a. shadow registers */
|
||||
static void set_awacs_register(ScreamerState *s, uint32_t value)
|
||||
{
|
||||
int the_register = get_codec_control_address(value);
|
||||
|
||||
switch (the_register) {
|
||||
case 0:
|
||||
set_awacs_0_reg(s, value);
|
||||
break;
|
||||
case 1:
|
||||
set_awacs_1_reg(s, value);
|
||||
break;
|
||||
case 2:
|
||||
set_awacs_2_reg(s, value);
|
||||
break;
|
||||
case 3:
|
||||
set_awacs_3_reg(s, value);
|
||||
break;
|
||||
case 4:
|
||||
set_awacs_4_reg(s, value);
|
||||
break;
|
||||
case 5:
|
||||
set_awacs_5_reg(s, value);
|
||||
break;
|
||||
case 6:
|
||||
set_awacs_6_reg(s, value);
|
||||
break;
|
||||
case 7:
|
||||
set_awacs_7_reg(s, value);
|
||||
break;
|
||||
default:
|
||||
DPRINTF("Unhandled awacs registers %d\n", the_register);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Used to set the AWACS registers */
|
||||
static void set_codec_control_reg(ScreamerState *s, uint32_t value)
|
||||
{
|
||||
DPRINTF("set_codec_control_reg() called - value: 0x%x\n", value);
|
||||
s->codec_control = value;
|
||||
set_awacs_register(s, value);
|
||||
}
|
||||
|
||||
static void set_codec_status_reg(ScreamerState *s, uint32_t value)
|
||||
{
|
||||
DPRINTF("set_codec_status_reg() called - value: 0x%x\n", value);
|
||||
s->codec_status = value;
|
||||
}
|
||||
|
||||
static void set_clip_count_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("set_clip_count_reg() called - value: 0x%x\n", new_value);
|
||||
s->clip_count = new_value;
|
||||
}
|
||||
|
||||
static void set_byte_swap_reg(ScreamerState *s, uint32_t value)
|
||||
{
|
||||
DPRINTF("set_byte_swap_reg() called - value: 0x%x\n", value);
|
||||
s->byte_swap = value;
|
||||
}
|
||||
|
||||
static void set_frame_count_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("%s() called - value: 0x%x\n", __func__, new_value);
|
||||
s->frame_count = new_value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the busy bit of codec control register.
|
||||
* It is used to tell the CPU to wait.
|
||||
* value: the codec control register's value
|
||||
* bit_value: used to set or disable the busy bit
|
||||
*/
|
||||
static uint32_t set_busy_bit(uint32_t value, int bit_value)
|
||||
{
|
||||
const int busy_bit = 0x01000000;
|
||||
uint32_t return_value;
|
||||
if (bit_value == 1) /* Set this bit */
|
||||
return_value = (value | busy_bit);
|
||||
else /* bit_value == 0 Disable this bit */
|
||||
return_value = (value & ~busy_bit);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Sets the part ready bit of the codec status register
|
||||
* value: the codec status register's value
|
||||
* bit_value: used to set or disable the part ready bit
|
||||
*/
|
||||
static uint32_t set_part_ready_bit(uint32_t value, int bit_value)
|
||||
{
|
||||
const int part_ready_bit = 0x00400000;
|
||||
uint32_t return_value;
|
||||
if (bit_value == 1) /* Set this bit */
|
||||
return_value = (value | part_ready_bit);
|
||||
else /* bit_value == 0 Disable this bit */
|
||||
return_value = (value & ~part_ready_bit);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/* Sets bits 12 and 13 to 1 to indicate the Screamer revision */
|
||||
static uint32_t set_revision(uint32_t input_value)
|
||||
{
|
||||
uint32_t return_value;
|
||||
return_value = input_value | 0x3000;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/* Sets bit 8 to indicate Crystal as the manufacturer */
|
||||
static uint32_t set_manufacturer(uint32_t input_value)
|
||||
{
|
||||
uint32_t return_value;
|
||||
return_value = input_value | 0x100;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
/************************** End of Setters *********************************/
|
||||
|
||||
|
||||
/*************************** DMA functions *********************************/
|
||||
|
||||
/*
|
||||
* Sends audio samples from a microphone or line-in to memory.
|
||||
* Used for sound input.
|
||||
* Currently only prevents a deadlock condition with Mac OS 9.
|
||||
*/
|
||||
static void screamer_to_dma(DBDMA_io *io)
|
||||
{
|
||||
DPRINTF("%s() called\n", __func__);
|
||||
ScreamerState *s = (ScreamerState *)io->opaque;
|
||||
DBDMAState *dbs = s->dbdma;
|
||||
DBDMA_channel *ch = &dbs->channels[0x12];
|
||||
ch->regs[DBDMA_STATUS] |= DEAD;
|
||||
ch->regs[DBDMA_STATUS] &= ~ACTIVE;
|
||||
io->dma_end(io);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static void print_dma_info(DBDMA_io *io)
|
||||
{
|
||||
#define RUN 0x8000
|
||||
#define PAUSE 0x4000
|
||||
#define FLUSH 0x2000
|
||||
#define WAKE 0x1000
|
||||
#define DEAD 0x0800
|
||||
#define ACTIVE 0x0400
|
||||
#define BT 0x0100
|
||||
#define DEVSTAT 0x00ff
|
||||
|
||||
/*
|
||||
* RUN and PAUSE are bits under software control only.
|
||||
* FLUSH and WAKE are set by SW and cleared by hardware.
|
||||
* DEAD, ACTIVE and BT are only under hardware control.
|
||||
*/
|
||||
|
||||
DBDMA_channel *ch = io->channel;
|
||||
printf("DMA FLAGS: ");
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & RUN) {
|
||||
printf("RUN ");
|
||||
}
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & ACTIVE) {
|
||||
printf("ACTIVE ");
|
||||
}
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & PAUSE) {
|
||||
printf("PAUSE ");
|
||||
}
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & DEAD) {
|
||||
printf("DEAD ");
|
||||
}
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & WAKE) {
|
||||
printf("WAKE ");
|
||||
}
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & BT) {
|
||||
printf("BT ");
|
||||
}
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & DEVSTAT) {
|
||||
printf("DEVSTAT ");
|
||||
}
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & FLUSH) {
|
||||
printf("FLUSH ");
|
||||
}
|
||||
|
||||
if (ch->io.processing == true) {
|
||||
printf("processing ");
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/* Tell the DMA controller we request more samples */
|
||||
static void dma_request(DBDMA_io *io)
|
||||
{
|
||||
DPRINTF("%s() called\n", __func__);
|
||||
if (DEBUG_SCREAMER) {
|
||||
print_dma_info(io);
|
||||
}
|
||||
io->len = 0;
|
||||
io->dma_end(io);
|
||||
}
|
||||
|
||||
|
||||
/* Adds sample data to the buffer */
|
||||
static void add_to_speaker_buffer(DBDMA_io *io)
|
||||
{
|
||||
ScreamerState *s = (ScreamerState *) io->opaque;
|
||||
|
||||
if (s->spk_buffer_position + io->len > MAX_BUFFER_SIZE) {
|
||||
/* postpone calling these samples until the buffer has been emptied */
|
||||
memcpy(&s->dma_io, io, sizeof(DBDMA_io));
|
||||
return;
|
||||
}
|
||||
dma_memory_read(&address_space_memory, io->addr,
|
||||
&s->spk_buffer[s->spk_buffer_position], io->len,
|
||||
MEMTXATTRS_UNSPECIFIED);
|
||||
s->spk_buffer_position += io->len;
|
||||
DPRINTF("%s() called - len: %d pos: %d/%d\n", __func__, io->len,
|
||||
s->spk_buffer_position, MAX_BUFFER_SIZE);
|
||||
|
||||
dma_request(io);
|
||||
}
|
||||
|
||||
/*
|
||||
* Called by the DMA chip to transfer samples from memory to the
|
||||
* Screamer chip.
|
||||
* Used for sound output.
|
||||
*/
|
||||
static void dma_to_screamer(DBDMA_io *io)
|
||||
{
|
||||
add_to_speaker_buffer(io);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This will flush the audio buffer of previous audio - eliminating previous
|
||||
* audio playback.
|
||||
*/
|
||||
static void send_silence_to_speaker(ScreamerState *s)
|
||||
{
|
||||
DPRINTF("Silencing audio buffer...\n");
|
||||
int length = MAX_BUFFER_SIZE;
|
||||
s->spk_buffer_position = length;
|
||||
s->spk_play_position = 0;
|
||||
memset(s->spk_buffer, 0, length);
|
||||
s->dma_io.len = 0; /* stop any postponed samples from playing */
|
||||
}
|
||||
|
||||
|
||||
/* This is called after audio stops playing */
|
||||
static void dma_send_flush(DBDMA_io *io)
|
||||
{
|
||||
DPRINTF("dma_send_flush() called\n");
|
||||
if (DEBUG_SCREAMER) {
|
||||
print_dma_info(io);
|
||||
}
|
||||
ScreamerState *s = (ScreamerState *)io->opaque;
|
||||
reset_markers(s);
|
||||
send_silence_to_speaker(s);
|
||||
if (io->len > 0) {
|
||||
dma_request(io);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void dma_receive_flush(DBDMA_io *io)
|
||||
{
|
||||
DPRINTF("dma_receive_flush() called\n");
|
||||
}
|
||||
|
||||
|
||||
/* Set the functions the DMA system will call */
|
||||
void screamer_register_dma_functions(ScreamerState *s, void *dbdma,
|
||||
int send_channel, int receive_channel)
|
||||
{
|
||||
DPRINTF("%s() called\n", __func__);
|
||||
DPRINTF("send channel: %d\treceive channel: %d\n", send_channel,
|
||||
receive_channel);
|
||||
s->dbdma = dbdma;
|
||||
|
||||
/* Setup the DMA send system */
|
||||
DBDMA_register_channel(s->dbdma, send_channel, s->dma_send_irq,
|
||||
dma_to_screamer, dma_send_flush, s);
|
||||
|
||||
/* Setup the DMA receive system */
|
||||
DBDMA_register_channel(s->dbdma, receive_channel, s->dma_receive_irq,
|
||||
screamer_to_dma, dma_receive_flush, s);
|
||||
}
|
||||
|
||||
/************************* End of DMA functions **************************/
|
||||
|
||||
/* Resets this sound chip */
|
||||
static void screamer_reset(DeviceState *d)
|
||||
{
|
||||
DPRINTF("screamer_reset() called\n");
|
||||
ScreamerState *s = SCREAMER(d);
|
||||
set_sound_control_reg(s, 0);
|
||||
set_codec_control_reg(s, 0);
|
||||
set_codec_status_reg(s, 0);
|
||||
set_clip_count_reg(s, 0);
|
||||
set_byte_swap_reg(s, 0);
|
||||
set_frame_count_reg(s, 0);
|
||||
int i, num_awacs_regs = 8;
|
||||
for (i = 0; i < num_awacs_regs; i++) {
|
||||
s->awacs[i] = 0;
|
||||
}
|
||||
set_QEMU_audio_settings(s);
|
||||
reset_markers(s);
|
||||
s->dma_io.len = 0;
|
||||
}
|
||||
|
||||
/* Called when the CPU reads the memory addresses assigned to Screamer */
|
||||
static uint64_t screamer_mmio_read(void *opaque, hwaddr addr, unsigned size)
|
||||
{
|
||||
ScreamerState *state = opaque;
|
||||
uint32_t return_value;
|
||||
|
||||
addr = addr >> 4;
|
||||
switch (addr) {
|
||||
case SOUND_CONTROL_REG:
|
||||
return_value = get_sound_control_reg(state);
|
||||
break;
|
||||
case CODEC_CONTROL_REG:
|
||||
return_value = get_codec_control_reg(state);
|
||||
break;
|
||||
case CODEC_STATUS_REG:
|
||||
return_value = get_codec_status_reg(state);
|
||||
break;
|
||||
case CLIP_COUNT_REG:
|
||||
return_value = get_clip_count_reg(state);
|
||||
break;
|
||||
case BYTE_SWAP_REG:
|
||||
return_value = get_byte_swap_reg(state);
|
||||
break;
|
||||
case FRAME_COUNT_REG:
|
||||
return_value = get_frame_count_reg(state);
|
||||
break;
|
||||
default:
|
||||
DPRINTF("Unknown register read - addr:%" HWADDR_PRIx "\tsize:%d\n",
|
||||
addr, size);
|
||||
return_value = 12021981; /* Value used for debugging purposes */
|
||||
}
|
||||
DPRINTF("screamer_mmio_read() called addr: %" HWADDR_PRIx " size: %d",
|
||||
addr >> 4, size);
|
||||
DPRINTF(" returning 0x%x\n", return_value);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
/* Called when the CPU writes to the memory addresses assigned to Screamer */
|
||||
static void screamer_mmio_write(void *opaque, hwaddr addr, uint64_t raw_value,
|
||||
unsigned size)
|
||||
{
|
||||
DPRINTF("screamer_mmio_write() called - size: %d\n", size);
|
||||
ScreamerState *state = opaque;
|
||||
uint32_t value = raw_value & 0xffffffff;
|
||||
addr = addr >> 4;
|
||||
|
||||
switch (addr) {
|
||||
case SOUND_CONTROL_REG:
|
||||
set_sound_control_reg(state, value);
|
||||
break;
|
||||
case CODEC_CONTROL_REG:
|
||||
set_codec_control_reg(state, value);
|
||||
break;
|
||||
case CODEC_STATUS_REG:
|
||||
set_codec_status_reg(state, value);
|
||||
break;
|
||||
case CLIP_COUNT_REG:
|
||||
set_clip_count_reg(state, value);
|
||||
break;
|
||||
case BYTE_SWAP_REG:
|
||||
set_byte_swap_reg(state, value);
|
||||
break;
|
||||
case FRAME_COUNT_REG:
|
||||
set_frame_count_reg(state, value);
|
||||
break;
|
||||
default:
|
||||
DPRINTF("Unknown register write - addr:%" HWADDR_PRIx "\tvalue:%d\n",
|
||||
addr, value);
|
||||
}
|
||||
}
|
||||
|
||||
/* Used for memory_region_init_io() for memory mapped I/O */
|
||||
static const MemoryRegionOps screamer_ops = {
|
||||
.read = screamer_mmio_read,
|
||||
.write = screamer_mmio_write,
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
.valid = {
|
||||
.min_access_size = 4,
|
||||
.max_access_size = 4
|
||||
}
|
||||
};
|
||||
|
||||
/* Called when the device has become active */
|
||||
static void screamer_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
DPRINTF("screamer_realize() called\n");
|
||||
screamer_reset(dev);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called when an instance of the Screamer device is created.
|
||||
* Also called when this HMP command is called: device_add screamer
|
||||
*/
|
||||
static void screamer_init(Object *obj)
|
||||
{
|
||||
DPRINTF("screamer_init() called\n");
|
||||
|
||||
ScreamerState *s = (ScreamerState *)obj;
|
||||
SysBusDevice *d = SYS_BUS_DEVICE(obj);
|
||||
const int region_size = 5 * 32;
|
||||
|
||||
/* Makes the read and write ops work */
|
||||
memory_region_init_io(&s->io_memory_region, OBJECT(s),
|
||||
&screamer_ops, s, SOUND_CHIP_NAME, region_size);
|
||||
|
||||
/* Sets the SysBusDevice's memory property */
|
||||
sysbus_init_mmio(d, &s->io_memory_region);
|
||||
|
||||
/* Setup all the interrupt requests */
|
||||
sysbus_init_irq(d, &s->irq);
|
||||
sysbus_init_irq(d, &s->dma_send_irq);
|
||||
sysbus_init_irq(d, &s->dma_receive_irq);
|
||||
|
||||
/* Registers Screamer with QEMU's audio system */
|
||||
AUD_register_card(SOUND_CHIP_NAME, &s->card);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* When saving and restoring the state of the VM, this is used to save and
|
||||
* restore the registers.
|
||||
*/
|
||||
static const VMStateDescription vmstate_screamer = {
|
||||
.name = "Screamer",
|
||||
.version_id = 1,
|
||||
.minimum_version_id = 1,
|
||||
.fields = (VMStateField[]) {
|
||||
VMSTATE_UINT16_ARRAY(awacs, ScreamerState, 8), /* 8 AWACS registers */
|
||||
VMSTATE_UINT32(sound_control, ScreamerState),
|
||||
VMSTATE_UINT32(codec_control, ScreamerState),
|
||||
VMSTATE_UINT32(codec_status, ScreamerState),
|
||||
VMSTATE_UINT32(clip_count, ScreamerState),
|
||||
VMSTATE_UINT32(byte_swap, ScreamerState),
|
||||
VMSTATE_UINT32(frame_count, ScreamerState),
|
||||
VMSTATE_END_OF_LIST()
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Sets the class data. It is like polymorphism and inheritance in object
|
||||
* oriented languages.
|
||||
*/
|
||||
static void screamer_class_init(ObjectClass *class, void *data)
|
||||
{
|
||||
DPRINTF("screamer_class_init() called\n");
|
||||
DeviceClass *dc = DEVICE_CLASS(class);
|
||||
dc->realize = screamer_realize;
|
||||
dc->reset = screamer_reset;
|
||||
dc->desc = "Apple Screamer";
|
||||
dc->vmsd = &vmstate_screamer;
|
||||
dc->hotpluggable = false;
|
||||
}
|
||||
|
||||
/* Used for QOM function registration */
|
||||
static const TypeInfo screamer_info = {
|
||||
.name = "screamer",
|
||||
.parent = TYPE_SYS_BUS_DEVICE,
|
||||
.instance_size = sizeof(ScreamerState),
|
||||
.instance_init = screamer_init,
|
||||
.class_init = screamer_class_init,
|
||||
};
|
||||
|
||||
/* QOM registration of above functions for calling */
|
||||
static void screamer_register_types(void)
|
||||
{
|
||||
DPRINTF("screamer_register_types() called\n");
|
||||
type_register_static(&screamer_info);
|
||||
}
|
||||
|
||||
/* QEMU Object Model (QOM) stuff */
|
||||
type_init(screamer_register_types)
|
||||
@@ -42,6 +42,9 @@
|
||||
|
||||
GlobalProperty hw_compat_7_1[] = {
|
||||
{ "virtio-device", "queue_reset", "false" },
|
||||
{ "virtio-rng-pci", "vectors", "0" },
|
||||
{ "virtio-rng-pci-transitional", "vectors", "0" },
|
||||
{ "virtio-rng-pci-non-transitional", "vectors", "0" },
|
||||
};
|
||||
const size_t hw_compat_7_1_len = G_N_ELEMENTS(hw_compat_7_1);
|
||||
|
||||
|
||||
@@ -79,16 +79,6 @@ if config_all_devices.has_key('CONFIG_VIRTIO_GPU')
|
||||
hw_display_modules += {'virtio-gpu-gl': virtio_gpu_gl_ss}
|
||||
endif
|
||||
|
||||
if config_all_devices.has_key('CONFIG_FW_CFG_DMA')
|
||||
virtio_ramfb_ss = ss.source_set()
|
||||
virtio_ramfb_ss.add(when: 'CONFIG_FW_CFG_DMA', if_true: files('virtio-ramfb.c'))
|
||||
hw_display_modules += {'virtio-ramfb': virtio_ramfb_ss}
|
||||
virtio_ramfb_gl_ss = ss.source_set()
|
||||
virtio_ramfb_gl_ss.add(when: ['CONFIG_FW_CFG_DMA', virgl, opengl],
|
||||
if_true: files('virtio-ramfb-gl.c'))
|
||||
hw_display_modules += {'virtio-ramfb-gl': virtio_ramfb_gl_ss}
|
||||
endif
|
||||
|
||||
if config_all_devices.has_key('CONFIG_VIRTIO_PCI')
|
||||
virtio_gpu_pci_ss = ss.source_set()
|
||||
virtio_gpu_pci_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRTIO_PCI'],
|
||||
|
||||
@@ -165,8 +165,7 @@ virtio_gpu_base_device_realize(DeviceState *qdev,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (virtio_gpu_virgl_enabled(g->conf) &&
|
||||
!virtio_gpu_goldfish_pipe_enabled(g->conf)) {
|
||||
if (virtio_gpu_virgl_enabled(g->conf)) {
|
||||
error_setg(&g->migration_blocker, "virgl is not yet migratable");
|
||||
if (migrate_add_blocker(g->migration_blocker, errp) < 0) {
|
||||
error_free(g->migration_blocker);
|
||||
|
||||
@@ -18,25 +18,21 @@
|
||||
#include "qapi/error.h"
|
||||
#include "sysemu/sysemu.h"
|
||||
#include "hw/virtio/virtio.h"
|
||||
#ifdef CONFIG_ANDROID
|
||||
#include "hw/virtio/virtio-goldfish-pipe.h"
|
||||
#endif
|
||||
#include "hw/virtio/virtio-gpu.h"
|
||||
#include "hw/virtio/virtio-gpu-bswap.h"
|
||||
#include "hw/virtio/virtio-gpu-pixman.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
|
||||
#include "hw/virtio/virtio-gpu-virgl.h"
|
||||
#include <virglrenderer.h>
|
||||
|
||||
static void virtio_gpu_gl_update_cursor_data(VirtIOGPU *g,
|
||||
struct virtio_gpu_scanout *s,
|
||||
uint32_t resource_id)
|
||||
{
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
uint32_t width, height;
|
||||
uint32_t pixels, *data;
|
||||
|
||||
data = gl->virgl->virgl_renderer_get_cursor_data(resource_id, &width, &height);
|
||||
data = virgl_renderer_get_cursor_data(resource_id, &width, &height);
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
@@ -108,46 +104,9 @@ static void virtio_gpu_gl_reset(VirtIODevice *vdev)
|
||||
}
|
||||
}
|
||||
|
||||
static int virtio_gpu_gl_save(QEMUFile *f, void *opaque, size_t size,
|
||||
const VMStateField *field, JSONWriter *vmdesc)
|
||||
{
|
||||
VirtIOGPU *g = opaque;
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
|
||||
if (gl->virgl->virgl_renderer_save_snapshot) {
|
||||
// First save the renderer state, then the ram slots, because when we
|
||||
// load, the renderer state and host pointers backing blob resources
|
||||
// need to be restored first before the ram slots corresponding to the
|
||||
// blob resources themselves.
|
||||
gl->virgl->virgl_renderer_save_snapshot(f);
|
||||
#ifdef CONFIG_ANDROID
|
||||
virtio_gpu_save_ram_slots(f, g);
|
||||
#endif
|
||||
}
|
||||
|
||||
return virtio_gpu_save(f, opaque, size, field, vmdesc);
|
||||
}
|
||||
|
||||
static int virtio_gpu_gl_load(QEMUFile *f, void *opaque, size_t size,
|
||||
const VMStateField *field)
|
||||
{
|
||||
VirtIOGPU *g = opaque;
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
|
||||
if (gl->virgl->virgl_renderer_load_snapshot) {
|
||||
gl->virgl->virgl_renderer_load_snapshot(f);
|
||||
#ifdef CONFIG_ANDROID
|
||||
virtio_gpu_load_ram_slots(f, g);
|
||||
#endif
|
||||
}
|
||||
|
||||
return virtio_gpu_load(f, opaque, size, field);
|
||||
}
|
||||
|
||||
static void virtio_gpu_gl_device_realize(DeviceState *qdev, Error **errp)
|
||||
{
|
||||
VirtIOGPU *g = VIRTIO_GPU(qdev);
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(qdev);
|
||||
|
||||
#if HOST_BIG_ENDIAN
|
||||
error_setg(errp, "virgl is not supported on bigendian platforms");
|
||||
@@ -164,15 +123,6 @@ static void virtio_gpu_gl_device_realize(DeviceState *qdev, Error **errp)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ANDROID
|
||||
if (virtio_gpu_goldfish_pipe_enabled(g->parent_obj.conf)) {
|
||||
gl->virgl = get_goldfish_pipe_virgl_renderer_virtio_interface();
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
gl->virgl = get_default_virtio_interface();
|
||||
}
|
||||
|
||||
g->parent_obj.conf.flags |= (1 << VIRTIO_GPU_FLAG_VIRGL_ENABLED);
|
||||
VIRTIO_GPU_BASE(g)->virtio_config.num_capsets =
|
||||
virtio_gpu_virgl_get_num_capsets(g);
|
||||
@@ -183,10 +133,6 @@ static void virtio_gpu_gl_device_realize(DeviceState *qdev, Error **errp)
|
||||
static Property virtio_gpu_gl_properties[] = {
|
||||
DEFINE_PROP_BIT("stats", VirtIOGPU, parent_obj.conf.flags,
|
||||
VIRTIO_GPU_FLAG_STATS_ENABLED, false),
|
||||
#ifdef CONFIG_ANDROID
|
||||
DEFINE_PROP_BIT("goldfish-pipe", VirtIOGPU, parent_obj.conf.flags,
|
||||
VIRTIO_GPU_FLAG_GOLDFISH_PIPE_ENABLED, false),
|
||||
#endif
|
||||
DEFINE_PROP_END_OF_LIST(),
|
||||
};
|
||||
|
||||
@@ -201,8 +147,6 @@ static void virtio_gpu_gl_class_init(ObjectClass *klass, void *data)
|
||||
vgc->handle_ctrl = virtio_gpu_gl_handle_ctrl;
|
||||
vgc->process_cmd = virtio_gpu_virgl_process_cmd;
|
||||
vgc->update_cursor_data = virtio_gpu_gl_update_cursor_data;
|
||||
vgc->gpu_save = virtio_gpu_gl_save;
|
||||
vgc->gpu_load = virtio_gpu_gl_load;
|
||||
|
||||
vdc->realize = virtio_gpu_gl_device_realize;
|
||||
vdc->reset = virtio_gpu_gl_reset;
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include "hw/virtio/virtio-bus.h"
|
||||
#include "hw/virtio/virtio-gpu-pci.h"
|
||||
#include "qom/object.h"
|
||||
#include "standard-headers/linux/virtio_pci.h"
|
||||
|
||||
#define TYPE_VIRTIO_GPU_GL_PCI "virtio-gpu-gl-pci"
|
||||
typedef struct VirtIOGPUGLPCI VirtIOGPUGLPCI;
|
||||
@@ -32,88 +31,6 @@ struct VirtIOGPUGLPCI {
|
||||
VirtIOGPUGL vdev;
|
||||
};
|
||||
|
||||
static void virtio_gpu_pci_gl_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
|
||||
{
|
||||
VirtIOGPUGLPCI *vgpu = VIRTIO_GPU_GL_PCI(vpci_dev);
|
||||
VirtIOGPUGL *gl = &vgpu->vdev;
|
||||
VirtIOGPUBase *g = &gl->parent_obj.parent_obj;
|
||||
DeviceState *vdev = DEVICE(&vgpu->vdev);
|
||||
int i;
|
||||
|
||||
// Cool way to lay things out that should not affect stuff
|
||||
// and is compat with the current android11-5.4 kernel:
|
||||
// | 0 1 : modern | 2 msix | 4 5 hostshm |
|
||||
//
|
||||
// This is similar to the crosvm
|
||||
// virtio gpu pci bar layout, same except maybe for different msix bar #.
|
||||
vpci_dev->modern_mem_bar_idx = 0; // Overwritten: legacy io bar idx
|
||||
vpci_dev->msix_bar_idx = 2;
|
||||
// Not considered: modern io bar idx (only used in MODERN_PIO_NOTIFY,
|
||||
// which doesn't seem to be used in virtio-gpu)
|
||||
vpci_dev->hostshm_mem_bar_idx = 4;
|
||||
// Note that in future versions of Linux kernels, the bar may be negotiated
|
||||
// via some other mechanism based off the shm_cap logic below.
|
||||
|
||||
#define VIRTIO_GPU_PCI_HOST_COHERENT_BAR_SIZE (1ULL << 32ULL)
|
||||
|
||||
memory_region_init_ram_user_backed(
|
||||
&gl->host_coherent_memory, OBJECT(gl),
|
||||
"virtio-gpu-host-coherent",
|
||||
VIRTIO_GPU_PCI_HOST_COHERENT_BAR_SIZE);
|
||||
|
||||
// Add shm cap to the guest
|
||||
// (Doesn't seem to be used in 5.4, but is a way to be fwd compatible
|
||||
// with newer kernels)
|
||||
struct virtio_pci_cap64 shm_cap;
|
||||
uint32_t mask32 = ~0;
|
||||
|
||||
shm_cap.cap.cap_len = sizeof(shm_cap);
|
||||
shm_cap.cap.cfg_type = 8; // PciCapabilityType::SharedMemoryConfig
|
||||
shm_cap.cap.bar = vpci_dev->hostshm_mem_bar_idx;
|
||||
|
||||
shm_cap.cap.length =
|
||||
cpu_to_le32(mask32 & (int128_get64(gl->host_coherent_memory.size)));
|
||||
shm_cap.length_hi =
|
||||
cpu_to_le32(mask32 & (int128_get64(gl->host_coherent_memory.size) >> 32ULL));
|
||||
|
||||
shm_cap.cap.offset = mask32 & 0;
|
||||
shm_cap.offset_hi = mask32 & 0;
|
||||
|
||||
#define VIRTIO_GPU_PCI_CAP_HOSTSHM_ID 1
|
||||
|
||||
shm_cap.cap.id = VIRTIO_GPU_PCI_CAP_HOSTSHM_ID;
|
||||
|
||||
pci_register_bar(&vpci_dev->pci_dev, vpci_dev->hostshm_mem_bar_idx,
|
||||
PCI_BASE_ADDRESS_SPACE_MEMORY |
|
||||
PCI_BASE_ADDRESS_MEM_TYPE_64, &gl->host_coherent_memory);
|
||||
|
||||
int offset = pci_add_capability(
|
||||
&vpci_dev->pci_dev, PCI_CAP_ID_VNDR, 0,
|
||||
shm_cap.cap.cap_len, &error_abort);
|
||||
|
||||
// Add the mem cap to virtio-gpu-pci proxy's configuration.
|
||||
memcpy(vpci_dev->pci_dev.config + offset + PCI_CAP_FLAGS,
|
||||
&shm_cap.cap.cap_len,
|
||||
shm_cap.cap.cap_len - PCI_CAP_FLAGS);
|
||||
|
||||
virtio_pci_force_virtio_1(vpci_dev);
|
||||
if (!qdev_realize(vdev, BUS(&vpci_dev->bus), errp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < g->conf.max_outputs; i++) {
|
||||
object_property_set_link(OBJECT(g->scanout[i].con), "device",
|
||||
OBJECT(vpci_dev), &error_abort);
|
||||
}
|
||||
}
|
||||
|
||||
static void virtio_gpu_pci_gl_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
|
||||
|
||||
k->realize = virtio_gpu_pci_gl_realize;
|
||||
}
|
||||
|
||||
static void virtio_gpu_gl_initfn(Object *obj)
|
||||
{
|
||||
VirtIOGPUGLPCI *dev = VIRTIO_GPU_GL_PCI(obj);
|
||||
@@ -128,7 +45,6 @@ static const VirtioPCIDeviceTypeInfo virtio_gpu_gl_pci_info = {
|
||||
.parent = TYPE_VIRTIO_GPU_PCI_BASE,
|
||||
.instance_size = sizeof(VirtIOGPUGLPCI),
|
||||
.instance_init = virtio_gpu_gl_initfn,
|
||||
.class_init = virtio_gpu_pci_gl_class_init,
|
||||
};
|
||||
module_obj(TYPE_VIRTIO_GPU_GL_PCI);
|
||||
module_kconfig(VIRTIO_PCI);
|
||||
|
||||
+72
-461
@@ -16,17 +16,14 @@
|
||||
#include "trace.h"
|
||||
#include "hw/virtio/virtio.h"
|
||||
#include "hw/virtio/virtio-gpu.h"
|
||||
#include "exec/memory-remap.h"
|
||||
#include "migration/qemu-file-types.h"
|
||||
|
||||
#include "hw/virtio/virtio-gpu-virgl.h"
|
||||
#include <virglrenderer.h>
|
||||
|
||||
static struct virgl_renderer_callbacks virtio_gpu_3d_cbs;
|
||||
|
||||
static void virgl_cmd_create_resource_2d(VirtIOGPU *g,
|
||||
struct virtio_gpu_ctrl_command *cmd)
|
||||
{
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
struct virtio_gpu_resource_create_2d c2d;
|
||||
struct virgl_renderer_resource_create_args args;
|
||||
|
||||
@@ -45,13 +42,12 @@ static void virgl_cmd_create_resource_2d(VirtIOGPU *g,
|
||||
args.last_level = 0;
|
||||
args.nr_samples = 0;
|
||||
args.flags = VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP;
|
||||
gl->virgl->virgl_renderer_resource_create(&args, NULL, 0);
|
||||
virgl_renderer_resource_create(&args, NULL, 0);
|
||||
}
|
||||
|
||||
static void virgl_cmd_create_resource_3d(VirtIOGPU *g,
|
||||
struct virtio_gpu_ctrl_command *cmd)
|
||||
{
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
struct virtio_gpu_resource_create_3d c3d;
|
||||
struct virgl_renderer_resource_create_args args;
|
||||
|
||||
@@ -70,13 +66,12 @@ static void virgl_cmd_create_resource_3d(VirtIOGPU *g,
|
||||
args.last_level = c3d.last_level;
|
||||
args.nr_samples = c3d.nr_samples;
|
||||
args.flags = c3d.flags;
|
||||
gl->virgl->virgl_renderer_resource_create(&args, NULL, 0);
|
||||
virgl_renderer_resource_create(&args, NULL, 0);
|
||||
}
|
||||
|
||||
static void virgl_cmd_resource_unref(VirtIOGPU *g,
|
||||
struct virtio_gpu_ctrl_command *cmd)
|
||||
{
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
struct virtio_gpu_resource_unref unref;
|
||||
struct iovec *res_iovs = NULL;
|
||||
int num_iovs = 0;
|
||||
@@ -84,39 +79,37 @@ static void virgl_cmd_resource_unref(VirtIOGPU *g,
|
||||
VIRTIO_GPU_FILL_CMD(unref);
|
||||
trace_virtio_gpu_cmd_res_unref(unref.resource_id);
|
||||
|
||||
gl->virgl->virgl_renderer_resource_detach_iov(unref.resource_id,
|
||||
virgl_renderer_resource_detach_iov(unref.resource_id,
|
||||
&res_iovs,
|
||||
&num_iovs);
|
||||
if (res_iovs != NULL && num_iovs != 0) {
|
||||
virtio_gpu_cleanup_mapping_iov(g, res_iovs, num_iovs);
|
||||
}
|
||||
gl->virgl->virgl_renderer_resource_unref(unref.resource_id);
|
||||
virgl_renderer_resource_unref(unref.resource_id);
|
||||
}
|
||||
|
||||
static void virgl_cmd_context_create(VirtIOGPU *g,
|
||||
struct virtio_gpu_ctrl_command *cmd)
|
||||
{
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
struct virtio_gpu_ctx_create cc;
|
||||
|
||||
VIRTIO_GPU_FILL_CMD(cc);
|
||||
trace_virtio_gpu_cmd_ctx_create(cc.hdr.ctx_id,
|
||||
cc.debug_name);
|
||||
|
||||
gl->virgl->virgl_renderer_context_create(cc.hdr.ctx_id, cc.nlen,
|
||||
cc.debug_name);
|
||||
virgl_renderer_context_create(cc.hdr.ctx_id, cc.nlen,
|
||||
cc.debug_name);
|
||||
}
|
||||
|
||||
static void virgl_cmd_context_destroy(VirtIOGPU *g,
|
||||
struct virtio_gpu_ctrl_command *cmd)
|
||||
{
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
struct virtio_gpu_ctx_destroy cd;
|
||||
|
||||
VIRTIO_GPU_FILL_CMD(cd);
|
||||
trace_virtio_gpu_cmd_ctx_destroy(cd.hdr.ctx_id);
|
||||
|
||||
gl->virgl->virgl_renderer_context_destroy(cd.hdr.ctx_id);
|
||||
virgl_renderer_context_destroy(cd.hdr.ctx_id);
|
||||
}
|
||||
|
||||
static void virtio_gpu_rect_update(VirtIOGPU *g, int idx, int x, int y,
|
||||
@@ -126,9 +119,7 @@ static void virtio_gpu_rect_update(VirtIOGPU *g, int idx, int x, int y,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!virtio_gpu_goldfish_pipe_enabled(g->parent_obj.conf)) {
|
||||
dpy_gl_update(g->parent_obj.scanout[idx].con, x, y, width, height);
|
||||
}
|
||||
dpy_gl_update(g->parent_obj.scanout[idx].con, x, y, width, height);
|
||||
}
|
||||
|
||||
static void virgl_cmd_resource_flush(VirtIOGPU *g,
|
||||
@@ -146,50 +137,15 @@ static void virgl_cmd_resource_flush(VirtIOGPU *g,
|
||||
continue;
|
||||
}
|
||||
virtio_gpu_rect_update(g, i, rf.r.x, rf.r.y, rf.r.width, rf.r.height);
|
||||
#ifdef CONFIG_ANDROID
|
||||
if (i == 0 && virtio_gpu_goldfish_pipe_enabled(g->parent_obj.conf)) {
|
||||
stream_renderer_flush_resource_and_readback(rf.resource_id, rf.r.x, rf.r.y,
|
||||
rf.r.width, rf.r.height,
|
||||
NULL, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static GLuint virgl_borrow_texture_for_scanout(uint32_t id, bool *y_0_top,
|
||||
uint32_t *width,
|
||||
uint32_t *height)
|
||||
{
|
||||
struct virgl_renderer_texture_info info;
|
||||
int ret;
|
||||
|
||||
memset(&info, 0, sizeof(info));
|
||||
|
||||
ret = virgl_renderer_borrow_texture_for_scanout(id, &info);
|
||||
if (ret == -1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (y_0_top) {
|
||||
*y_0_top = info.flags & VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP;
|
||||
}
|
||||
|
||||
if (width) {
|
||||
*width = info.width;
|
||||
}
|
||||
|
||||
if (height) {
|
||||
*height = info.height;
|
||||
}
|
||||
|
||||
return info.tex_id;
|
||||
}
|
||||
|
||||
static void virgl_cmd_set_scanout(VirtIOGPU *g,
|
||||
struct virtio_gpu_ctrl_command *cmd)
|
||||
{
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
struct virtio_gpu_set_scanout ss;
|
||||
struct virgl_renderer_resource_info info;
|
||||
int ret;
|
||||
|
||||
VIRTIO_GPU_FILL_CMD(ss);
|
||||
trace_virtio_gpu_cmd_set_scanout(ss.scanout_id, ss.resource_id,
|
||||
@@ -203,17 +159,26 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g,
|
||||
}
|
||||
g->parent_obj.enable = 1;
|
||||
|
||||
memset(&info, 0, sizeof(info));
|
||||
|
||||
if (ss.resource_id && ss.r.width && ss.r.height) {
|
||||
ret = virgl_renderer_resource_get_info(ss.resource_id, &info);
|
||||
if (ret == -1) {
|
||||
qemu_log_mask(LOG_GUEST_ERROR,
|
||||
"%s: illegal resource specified %d\n",
|
||||
__func__, ss.resource_id);
|
||||
cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;
|
||||
return;
|
||||
}
|
||||
qemu_console_resize(g->parent_obj.scanout[ss.scanout_id].con,
|
||||
ss.r.width, ss.r.height);
|
||||
gl->virgl->virgl_renderer_force_ctx_0();
|
||||
if (!virtio_gpu_goldfish_pipe_enabled(g->parent_obj.conf)) {
|
||||
dpy_gl_scanout_texture(
|
||||
g->parent_obj.scanout[ss.scanout_id].con, ss.resource_id,
|
||||
virgl_borrow_texture_for_scanout,
|
||||
ss.r.x, ss.r.y, ss.r.width, ss.r.height);
|
||||
}
|
||||
} else if (!virtio_gpu_goldfish_pipe_enabled(g->parent_obj.conf)) {
|
||||
virgl_renderer_force_ctx_0();
|
||||
dpy_gl_scanout_texture(
|
||||
g->parent_obj.scanout[ss.scanout_id].con, info.tex_id,
|
||||
info.flags & VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP,
|
||||
info.width, info.height,
|
||||
ss.r.x, ss.r.y, ss.r.width, ss.r.height);
|
||||
} else {
|
||||
dpy_gfx_replace_surface(
|
||||
g->parent_obj.scanout[ss.scanout_id].con, NULL);
|
||||
dpy_gl_scanout_disable(g->parent_obj.scanout[ss.scanout_id].con);
|
||||
@@ -224,7 +189,6 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g,
|
||||
static void virgl_cmd_submit_3d(VirtIOGPU *g,
|
||||
struct virtio_gpu_ctrl_command *cmd)
|
||||
{
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
struct virtio_gpu_cmd_submit cs;
|
||||
void *buf;
|
||||
size_t s;
|
||||
@@ -247,7 +211,7 @@ static void virgl_cmd_submit_3d(VirtIOGPU *g,
|
||||
g->stats.bytes_3d += cs.size;
|
||||
}
|
||||
|
||||
gl->virgl->virgl_renderer_submit_cmd(buf, cs.hdr.ctx_id, cs.size / 4);
|
||||
virgl_renderer_submit_cmd(buf, cs.hdr.ctx_id, cs.size / 4);
|
||||
|
||||
out:
|
||||
g_free(buf);
|
||||
@@ -256,7 +220,6 @@ out:
|
||||
static void virgl_cmd_transfer_to_host_2d(VirtIOGPU *g,
|
||||
struct virtio_gpu_ctrl_command *cmd)
|
||||
{
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
struct virtio_gpu_transfer_to_host_2d t2d;
|
||||
struct virtio_gpu_box box;
|
||||
|
||||
@@ -270,75 +233,71 @@ static void virgl_cmd_transfer_to_host_2d(VirtIOGPU *g,
|
||||
box.h = t2d.r.height;
|
||||
box.d = 1;
|
||||
|
||||
gl->virgl->virgl_renderer_transfer_write_iov(t2d.resource_id,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
(struct virgl_box *)&box,
|
||||
t2d.offset, NULL, 0);
|
||||
virgl_renderer_transfer_write_iov(t2d.resource_id,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
(struct virgl_box *)&box,
|
||||
t2d.offset, NULL, 0);
|
||||
}
|
||||
|
||||
static void virgl_cmd_transfer_to_host_3d(VirtIOGPU *g,
|
||||
struct virtio_gpu_ctrl_command *cmd)
|
||||
{
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
struct virtio_gpu_transfer_host_3d t3d;
|
||||
|
||||
VIRTIO_GPU_FILL_CMD(t3d);
|
||||
trace_virtio_gpu_cmd_res_xfer_toh_3d(t3d.resource_id);
|
||||
|
||||
gl->virgl->virgl_renderer_transfer_write_iov(t3d.resource_id,
|
||||
t3d.hdr.ctx_id,
|
||||
t3d.level,
|
||||
t3d.stride,
|
||||
t3d.layer_stride,
|
||||
(struct virgl_box *)&t3d.box,
|
||||
t3d.offset, NULL, 0);
|
||||
virgl_renderer_transfer_write_iov(t3d.resource_id,
|
||||
t3d.hdr.ctx_id,
|
||||
t3d.level,
|
||||
t3d.stride,
|
||||
t3d.layer_stride,
|
||||
(struct virgl_box *)&t3d.box,
|
||||
t3d.offset, NULL, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
virgl_cmd_transfer_from_host_3d(VirtIOGPU *g,
|
||||
struct virtio_gpu_ctrl_command *cmd)
|
||||
{
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
struct virtio_gpu_transfer_host_3d tf3d;
|
||||
|
||||
VIRTIO_GPU_FILL_CMD(tf3d);
|
||||
trace_virtio_gpu_cmd_res_xfer_fromh_3d(tf3d.resource_id);
|
||||
|
||||
gl->virgl->virgl_renderer_transfer_read_iov(tf3d.resource_id,
|
||||
tf3d.hdr.ctx_id,
|
||||
tf3d.level,
|
||||
tf3d.stride,
|
||||
tf3d.layer_stride,
|
||||
(struct virgl_box *)&tf3d.box,
|
||||
tf3d.offset, NULL, 0);
|
||||
virgl_renderer_transfer_read_iov(tf3d.resource_id,
|
||||
tf3d.hdr.ctx_id,
|
||||
tf3d.level,
|
||||
tf3d.stride,
|
||||
tf3d.layer_stride,
|
||||
(struct virgl_box *)&tf3d.box,
|
||||
tf3d.offset, NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
static void virgl_resource_attach_backing(VirtIOGPU *g,
|
||||
struct virtio_gpu_ctrl_command *cmd)
|
||||
{
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
struct virtio_gpu_resource_attach_backing att_rb;
|
||||
struct iovec *res_iovs;
|
||||
uint32_t res_niov;
|
||||
int ret;
|
||||
uint64_t* addrs;
|
||||
|
||||
VIRTIO_GPU_FILL_CMD(att_rb);
|
||||
trace_virtio_gpu_cmd_res_back_attach(att_rb.resource_id);
|
||||
|
||||
ret = virtio_gpu_create_mapping_iov(g, att_rb.nr_entries, sizeof(att_rb),
|
||||
cmd, &addrs, &res_iovs, &res_niov);
|
||||
cmd, NULL, &res_iovs, &res_niov);
|
||||
if (ret != 0) {
|
||||
cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
|
||||
return;
|
||||
}
|
||||
|
||||
ret = gl->virgl->virgl_renderer_resource_attach_iov_with_addrs(att_rb.resource_id,
|
||||
res_iovs, res_niov, addrs);
|
||||
ret = virgl_renderer_resource_attach_iov(att_rb.resource_id,
|
||||
res_iovs, res_niov);
|
||||
|
||||
if (ret != 0)
|
||||
virtio_gpu_cleanup_mapping_iov(g, res_iovs, res_niov);
|
||||
@@ -347,7 +306,6 @@ static void virgl_resource_attach_backing(VirtIOGPU *g,
|
||||
static void virgl_resource_detach_backing(VirtIOGPU *g,
|
||||
struct virtio_gpu_ctrl_command *cmd)
|
||||
{
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
struct virtio_gpu_resource_detach_backing detach_rb;
|
||||
struct iovec *res_iovs = NULL;
|
||||
int num_iovs = 0;
|
||||
@@ -355,9 +313,9 @@ static void virgl_resource_detach_backing(VirtIOGPU *g,
|
||||
VIRTIO_GPU_FILL_CMD(detach_rb);
|
||||
trace_virtio_gpu_cmd_res_back_detach(detach_rb.resource_id);
|
||||
|
||||
gl->virgl->virgl_renderer_resource_detach_iov(detach_rb.resource_id,
|
||||
&res_iovs,
|
||||
&num_iovs);
|
||||
virgl_renderer_resource_detach_iov(detach_rb.resource_id,
|
||||
&res_iovs,
|
||||
&num_iovs);
|
||||
if (res_iovs == NULL || num_iovs == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -368,33 +326,30 @@ static void virgl_resource_detach_backing(VirtIOGPU *g,
|
||||
static void virgl_cmd_ctx_attach_resource(VirtIOGPU *g,
|
||||
struct virtio_gpu_ctrl_command *cmd)
|
||||
{
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
struct virtio_gpu_ctx_resource att_res;
|
||||
|
||||
VIRTIO_GPU_FILL_CMD(att_res);
|
||||
trace_virtio_gpu_cmd_ctx_res_attach(att_res.hdr.ctx_id,
|
||||
att_res.resource_id);
|
||||
|
||||
gl->virgl->virgl_renderer_ctx_attach_resource(att_res.hdr.ctx_id, att_res.resource_id);
|
||||
virgl_renderer_ctx_attach_resource(att_res.hdr.ctx_id, att_res.resource_id);
|
||||
}
|
||||
|
||||
static void virgl_cmd_ctx_detach_resource(VirtIOGPU *g,
|
||||
struct virtio_gpu_ctrl_command *cmd)
|
||||
{
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
struct virtio_gpu_ctx_resource det_res;
|
||||
|
||||
VIRTIO_GPU_FILL_CMD(det_res);
|
||||
trace_virtio_gpu_cmd_ctx_res_detach(det_res.hdr.ctx_id,
|
||||
det_res.resource_id);
|
||||
|
||||
gl->virgl->virgl_renderer_ctx_detach_resource(det_res.hdr.ctx_id, det_res.resource_id);
|
||||
virgl_renderer_ctx_detach_resource(det_res.hdr.ctx_id, det_res.resource_id);
|
||||
}
|
||||
|
||||
static void virgl_cmd_get_capset_info(VirtIOGPU *g,
|
||||
struct virtio_gpu_ctrl_command *cmd)
|
||||
{
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
struct virtio_gpu_get_capset_info info;
|
||||
struct virtio_gpu_resp_capset_info resp;
|
||||
|
||||
@@ -403,14 +358,14 @@ static void virgl_cmd_get_capset_info(VirtIOGPU *g,
|
||||
memset(&resp, 0, sizeof(resp));
|
||||
if (info.capset_index == 0) {
|
||||
resp.capset_id = VIRTIO_GPU_CAPSET_VIRGL;
|
||||
gl->virgl->virgl_renderer_get_cap_set(resp.capset_id,
|
||||
&resp.capset_max_version,
|
||||
&resp.capset_max_size);
|
||||
virgl_renderer_get_cap_set(resp.capset_id,
|
||||
&resp.capset_max_version,
|
||||
&resp.capset_max_size);
|
||||
} else if (info.capset_index == 1) {
|
||||
resp.capset_id = VIRTIO_GPU_CAPSET_VIRGL2;
|
||||
gl->virgl->virgl_renderer_get_cap_set(resp.capset_id,
|
||||
&resp.capset_max_version,
|
||||
&resp.capset_max_size);
|
||||
virgl_renderer_get_cap_set(resp.capset_id,
|
||||
&resp.capset_max_version,
|
||||
&resp.capset_max_size);
|
||||
} else {
|
||||
resp.capset_max_version = 0;
|
||||
resp.capset_max_size = 0;
|
||||
@@ -422,13 +377,12 @@ static void virgl_cmd_get_capset_info(VirtIOGPU *g,
|
||||
static void virgl_cmd_get_capset(VirtIOGPU *g,
|
||||
struct virtio_gpu_ctrl_command *cmd)
|
||||
{
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
struct virtio_gpu_get_capset gc;
|
||||
struct virtio_gpu_resp_capset *resp;
|
||||
uint32_t max_ver, max_size;
|
||||
VIRTIO_GPU_FILL_CMD(gc);
|
||||
|
||||
gl->virgl->virgl_renderer_get_cap_set(gc.capset_id, &max_ver,
|
||||
virgl_renderer_get_cap_set(gc.capset_id, &max_ver,
|
||||
&max_size);
|
||||
if (!max_size) {
|
||||
cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;
|
||||
@@ -437,183 +391,19 @@ static void virgl_cmd_get_capset(VirtIOGPU *g,
|
||||
|
||||
resp = g_malloc0(sizeof(*resp) + max_size);
|
||||
resp->hdr.type = VIRTIO_GPU_RESP_OK_CAPSET;
|
||||
gl->virgl->virgl_renderer_fill_caps(gc.capset_id,
|
||||
gc.capset_version,
|
||||
(void *)resp->capset_data);
|
||||
virgl_renderer_fill_caps(gc.capset_id,
|
||||
gc.capset_version,
|
||||
(void *)resp->capset_data);
|
||||
virtio_gpu_ctrl_response(g, cmd, &resp->hdr, sizeof(*resp) + max_size);
|
||||
g_free(resp);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ANDROID
|
||||
|
||||
static void virgl_cmd_resource_create_blob(VirtIOGPU *g,
|
||||
struct virtio_gpu_ctrl_command* cmd)
|
||||
{
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
struct virtio_gpu_resource_create_blob cb;
|
||||
VIRTIO_GPU_FILL_CMD(cb);
|
||||
|
||||
if (!gl->virgl->virgl_renderer_resource_create_v2) {
|
||||
fprintf(stderr, "%s: not supported\n", __func__);
|
||||
cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
|
||||
return;
|
||||
}
|
||||
|
||||
gl->virgl->virgl_renderer_resource_create_v2(
|
||||
cb.resource_id,
|
||||
cb.blob_id);
|
||||
}
|
||||
|
||||
#define VIRTIO_GPU_MAX_RAM_SLOTS 2048
|
||||
|
||||
struct VirtioGpuRamSlotInfo {
|
||||
int used;
|
||||
uint64_t gpa;
|
||||
uint64_t offset;
|
||||
uint64_t size;
|
||||
uint32_t resource_id;
|
||||
};
|
||||
|
||||
struct VirtioGpuRamSlotTable {
|
||||
struct VirtioGpuRamSlotInfo slots[VIRTIO_GPU_MAX_RAM_SLOTS];
|
||||
};
|
||||
|
||||
static struct VirtioGpuRamSlotTable* virtio_gpu_ram_slot_table_get(void) {
|
||||
static struct VirtioGpuRamSlotTable* s_table;
|
||||
if (!s_table) {
|
||||
struct VirtioGpuRamSlotTable* table =
|
||||
(struct VirtioGpuRamSlotTable*)malloc(sizeof(*table));
|
||||
memset(table, 0, sizeof(*table));
|
||||
s_table = table;
|
||||
}
|
||||
return s_table;
|
||||
}
|
||||
|
||||
static int virtio_gpu_ram_slot_infos_first_free_slot() {
|
||||
struct VirtioGpuRamSlotTable* table = virtio_gpu_ram_slot_table_get();
|
||||
|
||||
for (int i = 0; i < VIRTIO_GPU_MAX_RAM_SLOTS; ++i) {
|
||||
if (0 == table->slots[i].used) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void virtio_gpu_map_slot(
|
||||
MemoryRegion* parent, uint32_t resource_id,
|
||||
uint64_t gpa, uint64_t offset, void *hva, uint64_t size, int flags) {
|
||||
|
||||
struct VirtioGpuRamSlotTable* table = virtio_gpu_ram_slot_table_get();
|
||||
int slot = virtio_gpu_ram_slot_infos_first_free_slot();
|
||||
|
||||
if (slot < 0) {
|
||||
fprintf(stderr, "%s: error: no free slots to "
|
||||
"map hva %p -> gpa [0x%llx 0x%llx)\n", __func__,
|
||||
hva, (unsigned long long)gpa, (unsigned long long)gpa + size);
|
||||
return;
|
||||
}
|
||||
|
||||
qemu_user_backed_ram_map(gpa, hva, size, USER_BACKED_RAM_FLAGS_READ | USER_BACKED_RAM_FLAGS_WRITE);
|
||||
|
||||
table->slots[slot].gpa = gpa;
|
||||
table->slots[slot].offset = offset;
|
||||
table->slots[slot].size = size;
|
||||
table->slots[slot].used = 1;
|
||||
table->slots[slot].resource_id = resource_id;
|
||||
}
|
||||
|
||||
static void virtio_gpu_unmap_slot(
|
||||
MemoryRegion* parent, uint32_t resource_id) {
|
||||
|
||||
struct VirtioGpuRamSlotTable* table = virtio_gpu_ram_slot_table_get();
|
||||
|
||||
for (int i = 0; i < VIRTIO_GPU_MAX_RAM_SLOTS; ++i) {
|
||||
if (0 == table->slots[i].used) continue;
|
||||
if (resource_id != table->slots[i].resource_id) continue;
|
||||
|
||||
qemu_user_backed_ram_unmap(table->slots[i].gpa, table->slots[i].size);
|
||||
table->slots[i].used = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void virgl_cmd_resource_map(VirtIOGPU *g,
|
||||
struct virtio_gpu_ctrl_command* cmd) {
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
struct virtio_gpu_resource_map_blob m;
|
||||
struct virtio_gpu_resp_map_info resp;
|
||||
|
||||
VIRTIO_GPU_FILL_CMD(m);
|
||||
|
||||
void* hva;
|
||||
uint64_t size;
|
||||
uint64_t offset = m.offset;
|
||||
|
||||
if (!gl->virgl->virgl_renderer_resource_map) {
|
||||
fprintf(stderr, "%s: not supported\n", __func__);
|
||||
cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
|
||||
return;
|
||||
}
|
||||
|
||||
gl->virgl->virgl_renderer_resource_map(m.resource_id, &hva, &size);
|
||||
|
||||
if (!hva || !size) {
|
||||
fprintf(stderr, "%s: failed for resource %u\n", __func__, m.resource_id);
|
||||
cmd->error = VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY;
|
||||
return;
|
||||
}
|
||||
|
||||
uint64_t host_coherent_start =
|
||||
object_property_get_uint(OBJECT(&gl->host_coherent_memory), "addr", NULL);
|
||||
|
||||
uint64_t phys_addr =
|
||||
host_coherent_start + offset;
|
||||
|
||||
virtio_gpu_map_slot(
|
||||
&gl->host_coherent_memory,
|
||||
m.resource_id,
|
||||
phys_addr,
|
||||
offset,
|
||||
hva,
|
||||
size,
|
||||
0xff /* flags, unused */);
|
||||
|
||||
memset(&resp, 0, sizeof(resp));
|
||||
resp.hdr.type = VIRTIO_GPU_RESP_OK_MAP_INFO;
|
||||
resp.map_info = 0x3;
|
||||
resp.padding = 0;
|
||||
virtio_gpu_ctrl_response(g, cmd, &resp.hdr, sizeof(resp));
|
||||
}
|
||||
|
||||
static void virgl_cmd_resource_unmap(VirtIOGPU *g,
|
||||
struct virtio_gpu_ctrl_command* cmd) {
|
||||
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
struct virtio_gpu_resource_unmap_blob u;
|
||||
VIRTIO_GPU_FILL_CMD(u);
|
||||
|
||||
if (!gl->virgl->virgl_renderer_resource_unmap) {
|
||||
fprintf(stderr, "%s: not supported\n", __func__);
|
||||
cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
|
||||
return;
|
||||
}
|
||||
|
||||
virtio_gpu_unmap_slot(
|
||||
&gl->host_coherent_memory,
|
||||
u.resource_id);
|
||||
|
||||
gl->virgl->virgl_renderer_resource_unmap(u.resource_id);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ANDROID */
|
||||
|
||||
void virtio_gpu_virgl_process_cmd(VirtIOGPU *g,
|
||||
struct virtio_gpu_ctrl_command *cmd)
|
||||
{
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
VIRTIO_GPU_FILL_CMD(cmd->cmd_hdr);
|
||||
|
||||
gl->virgl->virgl_renderer_force_ctx_0();
|
||||
virgl_renderer_force_ctx_0();
|
||||
switch (cmd->cmd_hdr.type) {
|
||||
case VIRTIO_GPU_CMD_CTX_CREATE:
|
||||
virgl_cmd_context_create(g, cmd);
|
||||
@@ -674,17 +464,6 @@ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g,
|
||||
case VIRTIO_GPU_CMD_GET_EDID:
|
||||
virtio_gpu_get_edid(g, cmd);
|
||||
break;
|
||||
#ifdef CONFIG_ANDROID
|
||||
case VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB:
|
||||
virgl_cmd_resource_create_blob(g, cmd);
|
||||
break;
|
||||
case VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB:
|
||||
virgl_cmd_resource_map(g, cmd);
|
||||
break;
|
||||
case VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB:
|
||||
virgl_cmd_resource_unmap(g, cmd);
|
||||
break;
|
||||
#endif /* CONFIG_ANDROID */
|
||||
default:
|
||||
cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
|
||||
break;
|
||||
@@ -705,7 +484,7 @@ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g,
|
||||
}
|
||||
|
||||
trace_virtio_gpu_fence_ctrl(cmd->cmd_hdr.fence_id, cmd->cmd_hdr.type);
|
||||
gl->virgl->virgl_renderer_create_fence(cmd->cmd_hdr.fence_id, cmd->cmd_hdr.type);
|
||||
virgl_renderer_create_fence(cmd->cmd_hdr.fence_id, cmd->cmd_hdr.type);
|
||||
}
|
||||
|
||||
static void virgl_write_fence(void *opaque, uint32_t fence)
|
||||
@@ -743,12 +522,6 @@ virgl_create_context(void *opaque, int scanout_idx,
|
||||
qparams.major_ver = params->major_ver;
|
||||
qparams.minor_ver = params->minor_ver;
|
||||
|
||||
if (virtio_gpu_goldfish_pipe_enabled(g->parent_obj.conf)) {
|
||||
fprintf(stderr, "%s: error: tried to use "
|
||||
"standard 3d cbs in proxy mode\n", __func__);
|
||||
abort();
|
||||
}
|
||||
|
||||
ctx = dpy_gl_ctx_create(g->parent_obj.scanout[scanout_idx].con, &qparams);
|
||||
return (virgl_renderer_gl_context)ctx;
|
||||
}
|
||||
@@ -758,12 +531,6 @@ static void virgl_destroy_context(void *opaque, virgl_renderer_gl_context ctx)
|
||||
VirtIOGPU *g = opaque;
|
||||
QEMUGLContext qctx = (QEMUGLContext)ctx;
|
||||
|
||||
if (virtio_gpu_goldfish_pipe_enabled(g->parent_obj.conf)) {
|
||||
fprintf(stderr, "%s: error: tried to use "
|
||||
"standard 3d cbs in proxy mode\n", __func__);
|
||||
abort();
|
||||
}
|
||||
|
||||
dpy_gl_ctx_destroy(g->parent_obj.scanout[0].con, qctx);
|
||||
}
|
||||
|
||||
@@ -773,12 +540,6 @@ static int virgl_make_context_current(void *opaque, int scanout_idx,
|
||||
VirtIOGPU *g = opaque;
|
||||
QEMUGLContext qctx = (QEMUGLContext)ctx;
|
||||
|
||||
if (virtio_gpu_goldfish_pipe_enabled(g->parent_obj.conf)) {
|
||||
fprintf(stderr, "%s: error: tried to use "
|
||||
"standard 3d cbs in proxy mode\n", __func__);
|
||||
abort();
|
||||
}
|
||||
|
||||
return dpy_gl_ctx_make_current(g->parent_obj.scanout[scanout_idx].con,
|
||||
qctx);
|
||||
}
|
||||
@@ -814,9 +575,8 @@ static void virtio_gpu_print_stats(void *opaque)
|
||||
static void virtio_gpu_fence_poll(void *opaque)
|
||||
{
|
||||
VirtIOGPU *g = opaque;
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
|
||||
gl->virgl->virgl_renderer_poll();
|
||||
virgl_renderer_poll();
|
||||
virtio_gpu_process_cmdq(g);
|
||||
if (!QTAILQ_EMPTY(&g->cmdq) || !QTAILQ_EMPTY(&g->fenceq)) {
|
||||
timer_mod(g->fence_poll, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 10);
|
||||
@@ -832,10 +592,6 @@ void virtio_gpu_virgl_reset_scanout(VirtIOGPU *g)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (virtio_gpu_goldfish_pipe_enabled(g->parent_obj.conf)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < g->parent_obj.conf.max_outputs; i++) {
|
||||
dpy_gfx_replace_surface(g->parent_obj.scanout[i].con, NULL);
|
||||
dpy_gl_scanout_disable(g->parent_obj.scanout[i].con);
|
||||
@@ -847,22 +603,11 @@ void virtio_gpu_virgl_reset(VirtIOGPU *g)
|
||||
virgl_renderer_reset();
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ANDROID
|
||||
static struct virgl_renderer_callbacks proxy_3d_cbs;
|
||||
#endif
|
||||
|
||||
int virtio_gpu_virgl_init(VirtIOGPU *g)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#ifdef CONFIG_ANDROID
|
||||
if (virtio_gpu_goldfish_pipe_enabled(g->parent_obj.conf)) {
|
||||
ret = virgl_renderer_init(g, 0, &proxy_3d_cbs);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
ret = virgl_renderer_init(g, 0, &virtio_gpu_3d_cbs);
|
||||
}
|
||||
ret = virgl_renderer_init(g, 0, &virtio_gpu_3d_cbs);
|
||||
if (ret != 0) {
|
||||
error_report("virgl could not be initialized: %d", ret);
|
||||
return ret;
|
||||
@@ -888,137 +633,3 @@ int virtio_gpu_virgl_get_num_capsets(VirtIOGPU *g)
|
||||
|
||||
return capset2_max_ver ? 2 : 1;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ANDROID
|
||||
void virtio_gpu_save_ram_slots(void* qemufile, VirtIOGPU* g) {
|
||||
struct VirtioGpuRamSlotTable* table = virtio_gpu_ram_slot_table_get();
|
||||
QEMUFile* file = (QEMUFile*)qemufile;
|
||||
|
||||
qemu_put_be32(file, VIRTIO_GPU_MAX_RAM_SLOTS);
|
||||
for (int i = 0 ; i < VIRTIO_GPU_MAX_RAM_SLOTS; ++i) {
|
||||
qemu_put_be32(file, table->slots[i].used);
|
||||
qemu_put_be64(file, table->slots[i].gpa);
|
||||
qemu_put_be64(file, table->slots[i].offset);
|
||||
qemu_put_be64(file, table->slots[i].size);
|
||||
qemu_put_be32(file, table->slots[i].resource_id);
|
||||
}
|
||||
}
|
||||
|
||||
static void virtio_gpu_clear_slots() {
|
||||
struct VirtioGpuRamSlotTable* table = virtio_gpu_ram_slot_table_get();
|
||||
|
||||
for (int i = 0; i < VIRTIO_GPU_MAX_RAM_SLOTS; ++i) {
|
||||
if (0 == table->slots[i].used) continue;
|
||||
qemu_user_backed_ram_unmap(table->slots[i].gpa, table->slots[i].size);
|
||||
table->slots[i].used = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void virtio_gpu_load_ram_slots(void* qemufile, VirtIOGPU* g) {
|
||||
VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
|
||||
QEMUFile* file = (QEMUFile*)qemufile;
|
||||
struct VirtioGpuRamSlotTable* table = virtio_gpu_ram_slot_table_get();
|
||||
|
||||
virtio_gpu_clear_slots();
|
||||
|
||||
uint32_t count = qemu_get_be32(file);
|
||||
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
table->slots[i].used = qemu_get_be32(file);
|
||||
table->slots[i].gpa = qemu_get_be64(file);
|
||||
table->slots[i].offset = qemu_get_be64(file);
|
||||
table->slots[i].size = qemu_get_be64(file);
|
||||
table->slots[i].resource_id = qemu_get_be32(file);
|
||||
|
||||
if (!table->slots[i].used) continue;
|
||||
|
||||
void* hva;
|
||||
uint64_t size;
|
||||
|
||||
gl->virgl->virgl_renderer_resource_map(table->slots[i].resource_id, &hva, &size);
|
||||
|
||||
if (size != table->slots[i].size) {
|
||||
fprintf(stderr, "%s: resource %u: fatal: size in renderer (0x%llx) did not match slot size (0x%llx)\n", __func__,
|
||||
table->slots[i].resource_id,
|
||||
(unsigned long long)size,
|
||||
(unsigned long long)table->slots[i].size);
|
||||
abort();
|
||||
}
|
||||
qemu_user_backed_ram_map(
|
||||
table->slots[i].gpa,
|
||||
hva, size, USER_BACKED_RAM_FLAGS_READ | USER_BACKED_RAM_FLAGS_WRITE);
|
||||
}
|
||||
}
|
||||
|
||||
static void proxy_virgl_write_fence(void *opaque, uint32_t fence) {
|
||||
VirtIOGPU *g = opaque;
|
||||
struct virtio_gpu_ctrl_command *cmd, *tmp;
|
||||
|
||||
QTAILQ_FOREACH_SAFE(cmd, &g->fenceq, next, tmp) {
|
||||
/*
|
||||
* the guest can end up emitting fences out of order
|
||||
* so we should check all fenced cmds not just the first one.
|
||||
*/
|
||||
if (cmd->cmd_hdr.fence_id > fence) {
|
||||
continue;
|
||||
}
|
||||
trace_virtio_gpu_fence_resp(cmd->cmd_hdr.fence_id);
|
||||
virtio_gpu_ctrl_response_nodata(g, cmd, VIRTIO_GPU_RESP_OK_NODATA);
|
||||
QTAILQ_REMOVE(&g->fenceq, cmd, next);
|
||||
g_free(cmd);
|
||||
g->inflight--;
|
||||
if (virtio_gpu_stats_enabled(g->parent_obj.conf)) {
|
||||
fprintf(stderr, "inflight: %3d (-)\r", g->inflight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static virgl_renderer_gl_context
|
||||
proxy_virgl_create_context(void *opaque, int scanout_idx,
|
||||
struct virgl_renderer_gl_ctx_param *params)
|
||||
{
|
||||
return (virgl_renderer_gl_context)0;
|
||||
}
|
||||
|
||||
static void proxy_virgl_destroy_context(
|
||||
void *opaque, virgl_renderer_gl_context ctx) { }
|
||||
|
||||
static int proxy_virgl_make_context_current(
|
||||
void *opaque, int scanout_idx, virgl_renderer_gl_context ctx) { return 0; }
|
||||
|
||||
static struct virgl_renderer_callbacks proxy_3d_cbs = {
|
||||
.version = 1,
|
||||
.write_fence = proxy_virgl_write_fence,
|
||||
.create_gl_context = proxy_virgl_create_context,
|
||||
.destroy_gl_context = proxy_virgl_destroy_context,
|
||||
.make_current = proxy_virgl_make_context_current,
|
||||
#ifdef VIRGL_RENDERER_UNSTABLE_APIS
|
||||
.write_context_fence = NULL,
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
static struct virgl_renderer_virtio_interface default_virtio_interface = {
|
||||
.virgl_renderer_init = virgl_renderer_init,
|
||||
.virgl_renderer_poll = virgl_renderer_poll,
|
||||
.virgl_renderer_get_cursor_data = virgl_renderer_get_cursor_data,
|
||||
.virgl_renderer_resource_create = virgl_renderer_resource_create,
|
||||
.virgl_renderer_resource_unref = virgl_renderer_resource_unref,
|
||||
.virgl_renderer_context_create = virgl_renderer_context_create,
|
||||
.virgl_renderer_context_destroy = virgl_renderer_context_destroy,
|
||||
.virgl_renderer_submit_cmd = virgl_renderer_submit_cmd,
|
||||
.virgl_renderer_transfer_read_iov = virgl_renderer_transfer_read_iov,
|
||||
.virgl_renderer_transfer_write_iov = virgl_renderer_transfer_write_iov,
|
||||
.virgl_renderer_get_cap_set = virgl_renderer_get_cap_set,
|
||||
.virgl_renderer_fill_caps = virgl_renderer_fill_caps,
|
||||
.virgl_renderer_resource_attach_iov = virgl_renderer_resource_attach_iov,
|
||||
.virgl_renderer_resource_detach_iov = virgl_renderer_resource_detach_iov,
|
||||
.virgl_renderer_create_fence = virgl_renderer_create_fence,
|
||||
.virgl_renderer_force_ctx_0 = virgl_renderer_force_ctx_0,
|
||||
.virgl_renderer_ctx_attach_resource = virgl_renderer_ctx_attach_resource,
|
||||
.virgl_renderer_ctx_detach_resource = virgl_renderer_ctx_detach_resource,
|
||||
};
|
||||
|
||||
struct virgl_renderer_virtio_interface* get_default_virtio_interface() {
|
||||
return &default_virtio_interface;
|
||||
}
|
||||
+27
-49
@@ -1174,17 +1174,8 @@ static const VMStateDescription vmstate_virtio_gpu_scanouts = {
|
||||
},
|
||||
};
|
||||
|
||||
static int _virtio_gpu_save(QEMUFile *f, void *opaque, size_t size,
|
||||
const VMStateField *field, JSONWriter *vmdesc)
|
||||
{
|
||||
VirtIOGPU *g = opaque;
|
||||
VirtIOGPUClass *vgc = VIRTIO_GPU_GET_CLASS(g);
|
||||
|
||||
return vgc->gpu_save(f, opaque, size, field, vmdesc);
|
||||
}
|
||||
|
||||
int virtio_gpu_save(QEMUFile *f, void *opaque, size_t size,
|
||||
const VMStateField *field, JSONWriter *vmdesc)
|
||||
static int virtio_gpu_save(QEMUFile *f, void *opaque, size_t size,
|
||||
const VMStateField *field, JSONWriter *vmdesc)
|
||||
{
|
||||
VirtIOGPU *g = opaque;
|
||||
struct virtio_gpu_simple_resource *res;
|
||||
@@ -1211,17 +1202,8 @@ int virtio_gpu_save(QEMUFile *f, void *opaque, size_t size,
|
||||
return vmstate_save_state(f, &vmstate_virtio_gpu_scanouts, g, NULL);
|
||||
}
|
||||
|
||||
static int _virtio_gpu_load(QEMUFile *f, void *opaque, size_t size,
|
||||
const VMStateField *field)
|
||||
{
|
||||
VirtIOGPU *g = opaque;
|
||||
VirtIOGPUClass *vgc = VIRTIO_GPU_GET_CLASS(g);
|
||||
|
||||
return vgc->gpu_load(f, opaque, size, field);
|
||||
}
|
||||
|
||||
int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size,
|
||||
const VMStateField *field)
|
||||
static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size,
|
||||
const VMStateField *field)
|
||||
{
|
||||
VirtIOGPU *g = opaque;
|
||||
struct virtio_gpu_simple_resource *res;
|
||||
@@ -1304,31 +1286,29 @@ int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size,
|
||||
resource_id = qemu_get_be32(f);
|
||||
}
|
||||
|
||||
/* load scanout state */
|
||||
/* load & apply scanout state */
|
||||
vmstate_load_state(f, &vmstate_virtio_gpu_scanouts, g, 1);
|
||||
for (i = 0; i < g->parent_obj.conf.max_outputs; i++) {
|
||||
scanout = &g->parent_obj.scanout[i];
|
||||
if (!scanout->resource_id) {
|
||||
continue;
|
||||
}
|
||||
res = virtio_gpu_find_resource(g, scanout->resource_id);
|
||||
if (!res) {
|
||||
return -EINVAL;
|
||||
}
|
||||
scanout->ds = qemu_create_displaysurface_pixman(res->image);
|
||||
if (!scanout->ds) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
// TODO: Figure out why this hangs the emulator display and causes ANR in the current app.
|
||||
// for (i = 0; i < g->conf.max_outputs; i++) {
|
||||
// scanout = &g->scanout[i];
|
||||
// if (!scanout->resource_id) {
|
||||
// continue;
|
||||
// }
|
||||
// res = virtio_gpu_find_resource(g, scanout->resource_id);
|
||||
// if (!res) {
|
||||
// return -EINVAL;
|
||||
// }
|
||||
// scanout->ds = qemu_create_displaysurface_pixman(res->image);
|
||||
// if (!scanout->ds) {
|
||||
// return -EINVAL;
|
||||
// }
|
||||
|
||||
// dpy_gfx_replace_surface(scanout->con, scanout->ds);
|
||||
// dpy_gfx_update(scanout->con, 0, 0, scanout->width, scanout->height);
|
||||
// if (scanout->cursor.resource_id) {
|
||||
// update_cursor(g, &scanout->cursor);
|
||||
// }
|
||||
// res->scanout_bitmask |= (1 << i);
|
||||
// }
|
||||
dpy_gfx_replace_surface(scanout->con, scanout->ds);
|
||||
dpy_gfx_update_full(scanout->con);
|
||||
if (scanout->cursor.resource_id) {
|
||||
update_cursor(g, &scanout->cursor);
|
||||
}
|
||||
res->scanout_bitmask |= (1 << i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1430,8 +1410,8 @@ static const VMStateDescription vmstate_virtio_gpu = {
|
||||
.name = "virtio-gpu",
|
||||
.info = &(const VMStateInfo) {
|
||||
.name = "virtio-gpu",
|
||||
.get = _virtio_gpu_load,
|
||||
.put = _virtio_gpu_save,
|
||||
.get = virtio_gpu_load,
|
||||
.put = virtio_gpu_save,
|
||||
},
|
||||
.flags = VMS_SINGLE,
|
||||
} /* device */,
|
||||
@@ -1458,8 +1438,6 @@ static void virtio_gpu_class_init(ObjectClass *klass, void *data)
|
||||
vgc->handle_ctrl = virtio_gpu_handle_ctrl;
|
||||
vgc->process_cmd = virtio_gpu_simple_process_cmd;
|
||||
vgc->update_cursor_data = virtio_gpu_update_cursor_data;
|
||||
vgc->gpu_save = virtio_gpu_save;
|
||||
vgc->gpu_load = virtio_gpu_load;
|
||||
vgbc->gl_flushed = virtio_gpu_handle_gl_flushed;
|
||||
|
||||
vdc->realize = virtio_gpu_device_realize;
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "hw/pci/pci.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "hw/virtio/virtio-gpu.h"
|
||||
#include "hw/display/vga.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qemu/module.h"
|
||||
#include "virtio-ramfb.h"
|
||||
#include "qom/object.h"
|
||||
|
||||
#define TYPE_VIRTIO_RAMFB_GL "virtio-ramfb-gl"
|
||||
|
||||
typedef struct VirtIORAMFBGL VirtIORAMFBGL;
|
||||
DECLARE_INSTANCE_CHECKER(VirtIORAMFBGL, VIRTIO_RAMFB_GL,
|
||||
TYPE_VIRTIO_RAMFB_GL)
|
||||
|
||||
struct VirtIORAMFBGL {
|
||||
VirtIORAMFBBase parent_obj;
|
||||
|
||||
VirtIOGPUGL vdev;
|
||||
};
|
||||
|
||||
static void virtio_ramfb_gl_inst_initfn(Object *obj)
|
||||
{
|
||||
VirtIORAMFBGL *dev = VIRTIO_RAMFB_GL(obj);
|
||||
|
||||
virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
|
||||
TYPE_VIRTIO_GPU_GL);
|
||||
VIRTIO_RAMFB_BASE(dev)->vgpu = VIRTIO_GPU_BASE(&dev->vdev);
|
||||
}
|
||||
|
||||
|
||||
static VirtioPCIDeviceTypeInfo virtio_ramfb_gl_info = {
|
||||
.generic_name = TYPE_VIRTIO_RAMFB_GL,
|
||||
.parent = TYPE_VIRTIO_RAMFB_BASE,
|
||||
.instance_size = sizeof(VirtIORAMFBGL),
|
||||
.instance_init = virtio_ramfb_gl_inst_initfn,
|
||||
};
|
||||
module_obj(TYPE_VIRTIO_RAMFB_GL);
|
||||
|
||||
static void virtio_ramfb_register_types(void)
|
||||
{
|
||||
if (have_vga) {
|
||||
virtio_pci_types_register(&virtio_ramfb_gl_info);
|
||||
}
|
||||
}
|
||||
|
||||
type_init(virtio_ramfb_register_types)
|
||||
|
||||
module_dep("hw-display-virtio-ramfb");
|
||||
@@ -1,191 +0,0 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "sysemu/sysemu.h"
|
||||
#include "hw/pci/pci.h"
|
||||
#include "ui/console.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "virtio-ramfb.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qom/object.h"
|
||||
|
||||
static int virtio_ramfb_get_flags(void *opaque)
|
||||
{
|
||||
VirtIORAMFBBase *vramfb = opaque;
|
||||
VirtIOGPUBase *g = vramfb->vgpu;
|
||||
|
||||
if (g->hw_ops->get_flags) {
|
||||
return g->hw_ops->get_flags(g);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void virtio_ramfb_invalidate_display(void *opaque)
|
||||
{
|
||||
VirtIORAMFBBase *vramfb = opaque;
|
||||
VirtIOGPUBase *g = vramfb->vgpu;
|
||||
|
||||
if (g->enable) {
|
||||
g->hw_ops->invalidate(g);
|
||||
}
|
||||
}
|
||||
|
||||
static void virtio_ramfb_text_update(void *opaque, console_ch_t *chardata)
|
||||
{
|
||||
VirtIORAMFBBase *vramfb = opaque;
|
||||
VirtIOGPUBase *g = vramfb->vgpu;
|
||||
|
||||
if (g->hw_ops->text_update) {
|
||||
g->hw_ops->text_update(g, chardata);
|
||||
}
|
||||
}
|
||||
|
||||
static void virtio_ramfb_update_display(void *opaque)
|
||||
{
|
||||
VirtIORAMFBBase *vramfb = opaque;
|
||||
VirtIOGPUBase *g = vramfb->vgpu;
|
||||
|
||||
if (g->enable) {
|
||||
g->hw_ops->gfx_update(g);
|
||||
} else {
|
||||
ramfb_display_update(g->scanout[0].con, vramfb->ramfb);
|
||||
}
|
||||
}
|
||||
|
||||
static void virtio_ramfb_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info)
|
||||
{
|
||||
VirtIORAMFBBase *vramfb = opaque;
|
||||
VirtIOGPUBase *g = vramfb->vgpu;
|
||||
|
||||
if (g->hw_ops->ui_info) {
|
||||
g->hw_ops->ui_info(g, idx, info);
|
||||
}
|
||||
}
|
||||
|
||||
static void virtio_ramfb_gl_block(void *opaque, bool block)
|
||||
{
|
||||
VirtIORAMFBBase *vramfb = opaque;
|
||||
VirtIOGPUBase *g = vramfb->vgpu;
|
||||
|
||||
if (g->hw_ops->gl_block) {
|
||||
g->hw_ops->gl_block(g, block);
|
||||
}
|
||||
}
|
||||
|
||||
static const GraphicHwOps virtio_ramfb_ops = {
|
||||
.get_flags = virtio_ramfb_get_flags,
|
||||
.invalidate = virtio_ramfb_invalidate_display,
|
||||
.gfx_update = virtio_ramfb_update_display,
|
||||
.text_update = virtio_ramfb_text_update,
|
||||
.ui_info = virtio_ramfb_ui_info,
|
||||
.gl_block = virtio_ramfb_gl_block,
|
||||
};
|
||||
|
||||
static const VMStateDescription vmstate_virtio_ramfb = {
|
||||
.name = "virtio-ramfb",
|
||||
.version_id = 2,
|
||||
.minimum_version_id = 2,
|
||||
.fields = (VMStateField[]) {
|
||||
/* no pci stuff here, saving the virtio device will handle that */
|
||||
/* FIXME */
|
||||
VMSTATE_END_OF_LIST()
|
||||
}
|
||||
};
|
||||
|
||||
/* RAMFB device wrapper around PCI device around virtio GPU */
|
||||
static void virtio_ramfb_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
|
||||
{
|
||||
VirtIORAMFBBase *vramfb = VIRTIO_RAMFB_BASE(vpci_dev);
|
||||
VirtIOGPUBase *g = vramfb->vgpu;
|
||||
int i;
|
||||
|
||||
/* init virtio bits */
|
||||
virtio_pci_force_virtio_1(vpci_dev);
|
||||
if (!qdev_realize(DEVICE(g), BUS(&vpci_dev->bus), errp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* init ramfb */
|
||||
vramfb->ramfb = ramfb_setup(errp);
|
||||
graphic_console_set_hwops(g->scanout[0].con, &virtio_ramfb_ops, vramfb);
|
||||
|
||||
for (i = 0; i < g->conf.max_outputs; i++) {
|
||||
object_property_set_link(OBJECT(g->scanout[i].con), "device",
|
||||
OBJECT(vpci_dev), &error_abort);
|
||||
}
|
||||
}
|
||||
|
||||
static void virtio_ramfb_reset(DeviceState *dev)
|
||||
{
|
||||
VirtIORAMFBBaseClass *klass = VIRTIO_RAMFB_BASE_GET_CLASS(dev);
|
||||
|
||||
/* reset virtio-gpu */
|
||||
klass->parent_reset(dev);
|
||||
}
|
||||
|
||||
static Property virtio_ramfb_base_properties[] = {
|
||||
DEFINE_VIRTIO_GPU_PCI_PROPERTIES(VirtIOPCIProxy),
|
||||
DEFINE_PROP_END_OF_LIST(),
|
||||
};
|
||||
|
||||
static void virtio_ramfb_base_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
|
||||
VirtIORAMFBBaseClass *v = VIRTIO_RAMFB_BASE_CLASS(klass);
|
||||
PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
|
||||
|
||||
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
|
||||
device_class_set_props(dc, virtio_ramfb_base_properties);
|
||||
dc->vmsd = &vmstate_virtio_ramfb;
|
||||
dc->hotpluggable = false;
|
||||
device_class_set_parent_reset(dc, virtio_ramfb_reset,
|
||||
&v->parent_reset);
|
||||
|
||||
k->realize = virtio_ramfb_realize;
|
||||
pcidev_k->class_id = PCI_CLASS_DISPLAY_OTHER;
|
||||
}
|
||||
|
||||
static const TypeInfo virtio_ramfb_base_info = {
|
||||
.name = TYPE_VIRTIO_RAMFB_BASE,
|
||||
.parent = TYPE_VIRTIO_PCI,
|
||||
.instance_size = sizeof(VirtIORAMFBBase),
|
||||
.class_size = sizeof(VirtIORAMFBBaseClass),
|
||||
.class_init = virtio_ramfb_base_class_init,
|
||||
.abstract = true,
|
||||
};
|
||||
|
||||
#define TYPE_VIRTIO_RAMFB "virtio-ramfb"
|
||||
|
||||
typedef struct VirtIORAMFB VirtIORAMFB;
|
||||
DECLARE_INSTANCE_CHECKER(VirtIORAMFB, VIRTIO_RAMFB,
|
||||
TYPE_VIRTIO_RAMFB)
|
||||
|
||||
struct VirtIORAMFB {
|
||||
VirtIORAMFBBase parent_obj;
|
||||
|
||||
VirtIOGPU vdev;
|
||||
};
|
||||
|
||||
static void virtio_ramfb_inst_initfn(Object *obj)
|
||||
{
|
||||
VirtIORAMFB *dev = VIRTIO_RAMFB(obj);
|
||||
|
||||
virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
|
||||
TYPE_VIRTIO_GPU);
|
||||
VIRTIO_RAMFB_BASE(dev)->vgpu = VIRTIO_GPU_BASE(&dev->vdev);
|
||||
}
|
||||
|
||||
static VirtioPCIDeviceTypeInfo virtio_ramfb_info = {
|
||||
.generic_name = TYPE_VIRTIO_RAMFB,
|
||||
.parent = TYPE_VIRTIO_RAMFB_BASE,
|
||||
.instance_size = sizeof(VirtIORAMFB),
|
||||
.instance_init = virtio_ramfb_inst_initfn,
|
||||
};
|
||||
|
||||
static void virtio_ramfb_register_types(void)
|
||||
{
|
||||
type_register_static(&virtio_ramfb_base_info);
|
||||
virtio_pci_types_register(&virtio_ramfb_info);
|
||||
}
|
||||
|
||||
type_init(virtio_ramfb_register_types)
|
||||
@@ -1,28 +0,0 @@
|
||||
#ifndef VIRTIO_RAMFB_H
|
||||
#define VIRTIO_RAMFB_H
|
||||
|
||||
#include "hw/virtio/virtio-gpu-pci.h"
|
||||
#include "hw/display/ramfb.h"
|
||||
#include "qom/object.h"
|
||||
|
||||
/*
|
||||
* virtio-ramfb-base: This extends VirtioPCIProxy.
|
||||
*/
|
||||
#define TYPE_VIRTIO_RAMFB_BASE "virtio-ramfb-base"
|
||||
OBJECT_DECLARE_TYPE(VirtIORAMFBBase, VirtIORAMFBBaseClass,
|
||||
VIRTIO_RAMFB_BASE)
|
||||
|
||||
struct VirtIORAMFBBase {
|
||||
VirtIOPCIProxy parent_obj;
|
||||
|
||||
VirtIOGPUBase *vgpu;
|
||||
RAMFBState *ramfb;
|
||||
};
|
||||
|
||||
struct VirtIORAMFBBaseClass {
|
||||
VirtioPCIClass parent_class;
|
||||
|
||||
DeviceReset parent_reset;
|
||||
};
|
||||
|
||||
#endif /* VIRTIO_RAMFB_H */
|
||||
@@ -3179,6 +3179,7 @@ static int vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,
|
||||
{
|
||||
VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu);
|
||||
IntelIOMMUState *s = vtd_as->iommu_state;
|
||||
X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(s);
|
||||
|
||||
/* TODO: add support for VFIO and vhost users */
|
||||
if (s->snoop_control) {
|
||||
@@ -3186,6 +3187,20 @@ static int vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,
|
||||
"Snoop Control with vhost or VFIO is not supported");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
if (!s->caching_mode && (new & IOMMU_NOTIFIER_MAP)) {
|
||||
error_setg_errno(errp, ENOTSUP,
|
||||
"device %02x.%02x.%x requires caching mode",
|
||||
pci_bus_num(vtd_as->bus), PCI_SLOT(vtd_as->devfn),
|
||||
PCI_FUNC(vtd_as->devfn));
|
||||
return -ENOTSUP;
|
||||
}
|
||||
if (!x86_iommu->dt_supported && (new & IOMMU_NOTIFIER_DEVIOTLB_UNMAP)) {
|
||||
error_setg_errno(errp, ENOTSUP,
|
||||
"device %02x.%02x.%x requires device IOTLB mode",
|
||||
pci_bus_num(vtd_as->bus), PCI_SLOT(vtd_as->devfn),
|
||||
PCI_FUNC(vtd_as->devfn));
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
/* Update per-address-space notifier flags */
|
||||
vtd_as->notifier_flags = new;
|
||||
|
||||
+1
-1
@@ -330,7 +330,7 @@ static void microvm_memory_init(MicrovmMachineState *mms)
|
||||
rom_set_fw(fw_cfg);
|
||||
|
||||
if (machine->kernel_filename != NULL) {
|
||||
x86_load_linux(x86ms, fw_cfg, 0, true, false);
|
||||
x86_load_linux(x86ms, fw_cfg, 0, true);
|
||||
}
|
||||
|
||||
if (mms->option_roms) {
|
||||
|
||||
+2
-2
@@ -799,7 +799,7 @@ void xen_load_linux(PCMachineState *pcms)
|
||||
rom_set_fw(fw_cfg);
|
||||
|
||||
x86_load_linux(x86ms, fw_cfg, pcmc->acpi_data_size,
|
||||
pcmc->pvh_enabled, pcmc->legacy_no_rng_seed);
|
||||
pcmc->pvh_enabled);
|
||||
for (i = 0; i < nb_option_roms; i++) {
|
||||
assert(!strcmp(option_rom[i].name, "linuxboot.bin") ||
|
||||
!strcmp(option_rom[i].name, "linuxboot_dma.bin") ||
|
||||
@@ -1119,7 +1119,7 @@ void pc_memory_init(PCMachineState *pcms,
|
||||
|
||||
if (linux_boot) {
|
||||
x86_load_linux(x86ms, fw_cfg, pcmc->acpi_data_size,
|
||||
pcmc->pvh_enabled, pcmc->legacy_no_rng_seed);
|
||||
pcmc->pvh_enabled);
|
||||
}
|
||||
|
||||
for (i = 0; i < nb_option_roms; i++) {
|
||||
|
||||
@@ -449,11 +449,9 @@ DEFINE_I440FX_MACHINE(v7_2, "pc-i440fx-7.2", NULL,
|
||||
|
||||
static void pc_i440fx_7_1_machine_options(MachineClass *m)
|
||||
{
|
||||
PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
|
||||
pc_i440fx_7_2_machine_options(m);
|
||||
m->alias = NULL;
|
||||
m->is_default = false;
|
||||
pcmc->legacy_no_rng_seed = true;
|
||||
compat_props_add(m->compat_props, hw_compat_7_1, hw_compat_7_1_len);
|
||||
compat_props_add(m->compat_props, pc_compat_7_1, pc_compat_7_1_len);
|
||||
}
|
||||
|
||||
@@ -383,10 +383,8 @@ DEFINE_Q35_MACHINE(v7_2, "pc-q35-7.2", NULL,
|
||||
|
||||
static void pc_q35_7_1_machine_options(MachineClass *m)
|
||||
{
|
||||
PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
|
||||
pc_q35_7_2_machine_options(m);
|
||||
m->alias = NULL;
|
||||
pcmc->legacy_no_rng_seed = true;
|
||||
compat_props_add(m->compat_props, hw_compat_7_1, hw_compat_7_1_len);
|
||||
compat_props_add(m->compat_props, pc_compat_7_1, pc_compat_7_1_len);
|
||||
}
|
||||
|
||||
+17
-71
@@ -26,7 +26,6 @@
|
||||
#include "qemu/cutils.h"
|
||||
#include "qemu/units.h"
|
||||
#include "qemu/datadir.h"
|
||||
#include "qemu/guest-random.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/qmp/qerror.h"
|
||||
#include "qapi/qapi-visit-common.h"
|
||||
@@ -37,7 +36,6 @@
|
||||
#include "sysemu/whpx.h"
|
||||
#include "sysemu/numa.h"
|
||||
#include "sysemu/replay.h"
|
||||
#include "sysemu/reset.h"
|
||||
#include "sysemu/sysemu.h"
|
||||
#include "sysemu/cpu-timers.h"
|
||||
#include "sysemu/xen.h"
|
||||
@@ -657,12 +655,12 @@ DeviceState *ioapic_init_secondary(GSIState *gsi_state)
|
||||
return dev;
|
||||
}
|
||||
|
||||
typedef struct SetupData {
|
||||
struct setup_data {
|
||||
uint64_t next;
|
||||
uint32_t type;
|
||||
uint32_t len;
|
||||
uint8_t data[];
|
||||
} __attribute__((packed)) SetupData;
|
||||
} __attribute__((packed));
|
||||
|
||||
|
||||
/*
|
||||
@@ -769,35 +767,10 @@ static bool load_elfboot(const char *kernel_filename,
|
||||
return true;
|
||||
}
|
||||
|
||||
typedef struct SetupDataFixup {
|
||||
void *pos;
|
||||
hwaddr orig_val, new_val;
|
||||
uint32_t addr;
|
||||
} SetupDataFixup;
|
||||
|
||||
static void fixup_setup_data(void *opaque)
|
||||
{
|
||||
SetupDataFixup *fixup = opaque;
|
||||
stq_p(fixup->pos, fixup->new_val);
|
||||
}
|
||||
|
||||
static void reset_setup_data(void *opaque)
|
||||
{
|
||||
SetupDataFixup *fixup = opaque;
|
||||
stq_p(fixup->pos, fixup->orig_val);
|
||||
}
|
||||
|
||||
static void reset_rng_seed(void *opaque)
|
||||
{
|
||||
SetupData *setup_data = opaque;
|
||||
qemu_guest_getrandom_nofail(setup_data->data, le32_to_cpu(setup_data->len));
|
||||
}
|
||||
|
||||
void x86_load_linux(X86MachineState *x86ms,
|
||||
FWCfgState *fw_cfg,
|
||||
int acpi_data_size,
|
||||
bool pvh_enabled,
|
||||
bool legacy_no_rng_seed)
|
||||
bool pvh_enabled)
|
||||
{
|
||||
bool linuxboot_dma_enabled = X86_MACHINE_GET_CLASS(x86ms)->fwcfg_dma_enabled;
|
||||
uint16_t protocol;
|
||||
@@ -805,17 +778,16 @@ void x86_load_linux(X86MachineState *x86ms,
|
||||
int dtb_size, setup_data_offset;
|
||||
uint32_t initrd_max;
|
||||
uint8_t header[8192], *setup, *kernel;
|
||||
hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr = 0, first_setup_data = 0;
|
||||
hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr = 0;
|
||||
FILE *f;
|
||||
char *vmode;
|
||||
MachineState *machine = MACHINE(x86ms);
|
||||
SetupData *setup_data;
|
||||
struct setup_data *setup_data;
|
||||
const char *kernel_filename = machine->kernel_filename;
|
||||
const char *initrd_filename = machine->initrd_filename;
|
||||
const char *dtb_filename = machine->dtb;
|
||||
const char *kernel_cmdline = machine->kernel_cmdline;
|
||||
SevKernelLoaderContext sev_load_ctx = {};
|
||||
enum { RNG_SEED_LENGTH = 32 };
|
||||
|
||||
/* Align to 16 bytes as a paranoia measure */
|
||||
cmdline_size = (strlen(kernel_cmdline) + 16) & ~15;
|
||||
@@ -1092,41 +1064,19 @@ void x86_load_linux(X86MachineState *x86ms,
|
||||
}
|
||||
|
||||
setup_data_offset = QEMU_ALIGN_UP(kernel_size, 16);
|
||||
kernel_size = setup_data_offset + sizeof(SetupData) + dtb_size;
|
||||
kernel_size = setup_data_offset + sizeof(struct setup_data) + dtb_size;
|
||||
kernel = g_realloc(kernel, kernel_size);
|
||||
|
||||
stq_p(header + 0x250, prot_addr + setup_data_offset);
|
||||
|
||||
setup_data = (SetupData *)(kernel + setup_data_offset);
|
||||
setup_data->next = cpu_to_le64(first_setup_data);
|
||||
first_setup_data = prot_addr + setup_data_offset;
|
||||
setup_data = (struct setup_data *)(kernel + setup_data_offset);
|
||||
setup_data->next = 0;
|
||||
setup_data->type = cpu_to_le32(SETUP_DTB);
|
||||
setup_data->len = cpu_to_le32(dtb_size);
|
||||
|
||||
load_image_size(dtb_filename, setup_data->data, dtb_size);
|
||||
}
|
||||
|
||||
if (!legacy_no_rng_seed) {
|
||||
setup_data_offset = QEMU_ALIGN_UP(kernel_size, 16);
|
||||
kernel_size = setup_data_offset + sizeof(SetupData) + RNG_SEED_LENGTH;
|
||||
kernel = g_realloc(kernel, kernel_size);
|
||||
setup_data = (SetupData *)(kernel + setup_data_offset);
|
||||
setup_data->next = cpu_to_le64(first_setup_data);
|
||||
first_setup_data = prot_addr + setup_data_offset;
|
||||
setup_data->type = cpu_to_le32(SETUP_RNG_SEED);
|
||||
setup_data->len = cpu_to_le32(RNG_SEED_LENGTH);
|
||||
qemu_guest_getrandom_nofail(setup_data->data, RNG_SEED_LENGTH);
|
||||
qemu_register_reset_nosnapshotload(reset_rng_seed, setup_data);
|
||||
fw_cfg_add_bytes_callback(fw_cfg, FW_CFG_KERNEL_DATA, reset_rng_seed, NULL,
|
||||
setup_data, kernel, kernel_size, true);
|
||||
} else {
|
||||
fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, kernel, kernel_size);
|
||||
}
|
||||
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, prot_addr);
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
|
||||
sev_load_ctx.kernel_data = (char *)kernel;
|
||||
sev_load_ctx.kernel_size = kernel_size;
|
||||
|
||||
/*
|
||||
* If we're starting an encrypted VM, it will be OVMF based, which uses the
|
||||
* efi stub for booting and doesn't require any values to be placed in the
|
||||
@@ -1135,20 +1085,16 @@ void x86_load_linux(X86MachineState *x86ms,
|
||||
* file the user passed in.
|
||||
*/
|
||||
if (!sev_enabled()) {
|
||||
SetupDataFixup *fixup = g_malloc(sizeof(*fixup));
|
||||
|
||||
memcpy(setup, header, MIN(sizeof(header), setup_size));
|
||||
/* Offset 0x250 is a pointer to the first setup_data link. */
|
||||
fixup->pos = setup + 0x250;
|
||||
fixup->orig_val = ldq_p(fixup->pos);
|
||||
fixup->new_val = first_setup_data;
|
||||
fixup->addr = cpu_to_le32(real_addr);
|
||||
fw_cfg_add_bytes_callback(fw_cfg, FW_CFG_SETUP_ADDR, fixup_setup_data, NULL,
|
||||
fixup, &fixup->addr, sizeof(fixup->addr), true);
|
||||
qemu_register_reset(reset_setup_data, fixup);
|
||||
} else {
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_ADDR, real_addr);
|
||||
}
|
||||
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, prot_addr);
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
|
||||
fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, kernel, kernel_size);
|
||||
sev_load_ctx.kernel_data = (char *)kernel;
|
||||
sev_load_ctx.kernel_size = kernel_size;
|
||||
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_ADDR, real_addr);
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_SIZE, setup_size);
|
||||
fw_cfg_add_bytes(fw_cfg, FW_CFG_SETUP_DATA, setup, setup_size);
|
||||
sev_load_ctx.setup_data = (char *)setup;
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "hw/misc/macio/macio.h"
|
||||
#include "hw/intc/heathrow_pic.h"
|
||||
#include "trace.h"
|
||||
#include "include/hw/audio/screamer.h"
|
||||
|
||||
#define ESCC_CLOCK 3686400
|
||||
|
||||
@@ -105,17 +104,6 @@ static void macio_common_realize(PCIDevice *d, Error **errp)
|
||||
sysbus_dev = SYS_BUS_DEVICE(&s->dbdma);
|
||||
memory_region_add_subregion(&s->bar, 0x08000,
|
||||
sysbus_mmio_get_region(sysbus_dev, 0));
|
||||
if (!qdev_realize(DEVICE(&s->screamer), BUS(&s->macio_bus), errp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Add the screamer sound chip */
|
||||
sysbus_dev = SYS_BUS_DEVICE(&s->screamer);
|
||||
const int offset = 0x14000; /* Offset from base address register (bar) */
|
||||
const int region_number = 0; /* which memory region to use */
|
||||
memory_region_add_subregion(&s->bar, offset,
|
||||
sysbus_mmio_get_region(sysbus_dev,
|
||||
region_number));
|
||||
|
||||
qdev_prop_set_uint32(DEVICE(&s->escc), "disabled", 0);
|
||||
qdev_prop_set_uint32(DEVICE(&s->escc), "frequency", ESCC_CLOCK);
|
||||
@@ -376,19 +364,6 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp)
|
||||
memory_region_add_subregion(&s->bar, 0x16000,
|
||||
sysbus_mmio_get_region(sysbus_dev, 0));
|
||||
}
|
||||
|
||||
/* Screamer Sound Chip */
|
||||
const int gpio_0 = 0;
|
||||
const int gpio_1 = 1;
|
||||
const int transmit_channel = 0x10;
|
||||
const int receive_channel = 0x12;
|
||||
sysbus_dev = SYS_BUS_DEVICE(&s->screamer);
|
||||
sysbus_connect_irq(sysbus_dev, gpio_0, qdev_get_gpio_in(pic_dev,
|
||||
NEWWORLD_SCREAMER_IRQ));
|
||||
sysbus_connect_irq(sysbus_dev, gpio_1, qdev_get_gpio_in(pic_dev,
|
||||
NEWWORLD_SCREAMER_DMA_IRQ));
|
||||
screamer_register_dma_functions(SCREAMER(sysbus_dev), &s->dbdma,
|
||||
transmit_channel, receive_channel);
|
||||
}
|
||||
|
||||
static void macio_newworld_init(Object *obj)
|
||||
@@ -418,9 +393,6 @@ static void macio_instance_init(Object *obj)
|
||||
object_initialize_child(OBJECT(s), "dbdma", &s->dbdma, TYPE_MAC_DBDMA);
|
||||
|
||||
object_initialize_child(OBJECT(s), "escc", &s->escc, TYPE_ESCC);
|
||||
|
||||
object_initialize_child(OBJECT(s), SOUND_CHIP_NAME, &s->screamer,
|
||||
TYPE_SCREAMER);
|
||||
}
|
||||
|
||||
static const VMStateDescription vmstate_macio_oldworld = {
|
||||
|
||||
+1
-1
@@ -1441,7 +1441,7 @@ static void vmxnet3_activate_device(VMXNET3State *s)
|
||||
vmxnet3_setup_rx_filtering(s);
|
||||
/* Cache fields from shared memory */
|
||||
s->mtu = VMXNET3_READ_DRV_SHARED32(d, s->drv_shmem, devRead.misc.mtu);
|
||||
assert(VMXNET3_MIN_MTU <= s->mtu && s->mtu < VMXNET3_MAX_MTU);
|
||||
assert(VMXNET3_MIN_MTU <= s->mtu && s->mtu <= VMXNET3_MAX_MTU);
|
||||
VMW_CFPRN("MTU is %u", s->mtu);
|
||||
|
||||
s->max_rx_frags =
|
||||
|
||||
+29
-6
@@ -1331,10 +1331,23 @@ static inline void nvme_blk_write(BlockBackend *blk, int64_t offset,
|
||||
}
|
||||
}
|
||||
|
||||
static void nvme_update_cq_eventidx(const NvmeCQueue *cq)
|
||||
{
|
||||
uint32_t v = cpu_to_le32(cq->head);
|
||||
|
||||
//not in 7.2: trace_pci_nvme_update_cq_eventidx(cq->cqid, cq->head);
|
||||
|
||||
pci_dma_write(PCI_DEVICE(cq->ctrl), cq->ei_addr, &v, sizeof(v));
|
||||
}
|
||||
|
||||
static void nvme_update_cq_head(NvmeCQueue *cq)
|
||||
{
|
||||
pci_dma_read(&cq->ctrl->parent_obj, cq->db_addr, &cq->head,
|
||||
sizeof(cq->head));
|
||||
uint32_t v;
|
||||
|
||||
pci_dma_read(&cq->ctrl->parent_obj, cq->db_addr, &v, sizeof(v));
|
||||
|
||||
cq->head = le32_to_cpu(v);
|
||||
|
||||
trace_pci_nvme_shadow_doorbell_cq(cq->cqid, cq->head);
|
||||
}
|
||||
|
||||
@@ -1351,6 +1364,7 @@ static void nvme_post_cqes(void *opaque)
|
||||
hwaddr addr;
|
||||
|
||||
if (n->dbbuf_enabled) {
|
||||
nvme_update_cq_eventidx(cq);
|
||||
nvme_update_cq_head(cq);
|
||||
}
|
||||
|
||||
@@ -2477,6 +2491,9 @@ static uint16_t nvme_dsm(NvmeCtrl *n, NvmeRequest *req)
|
||||
status = nvme_h2c(n, (uint8_t *)iocb->range, sizeof(NvmeDsmRange) * nr,
|
||||
req);
|
||||
if (status) {
|
||||
g_free(iocb->range);
|
||||
qemu_aio_unref(iocb);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -6141,15 +6158,21 @@ static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeRequest *req)
|
||||
|
||||
static void nvme_update_sq_eventidx(const NvmeSQueue *sq)
|
||||
{
|
||||
pci_dma_write(&sq->ctrl->parent_obj, sq->ei_addr, &sq->tail,
|
||||
sizeof(sq->tail));
|
||||
uint32_t v = cpu_to_le32(sq->tail);
|
||||
|
||||
pci_dma_write(&sq->ctrl->parent_obj, sq->ei_addr, &v, sizeof(v));
|
||||
|
||||
trace_pci_nvme_eventidx_sq(sq->sqid, sq->tail);
|
||||
}
|
||||
|
||||
static void nvme_update_sq_tail(NvmeSQueue *sq)
|
||||
{
|
||||
pci_dma_read(&sq->ctrl->parent_obj, sq->db_addr, &sq->tail,
|
||||
sizeof(sq->tail));
|
||||
uint32_t v;
|
||||
|
||||
pci_dma_read(&sq->ctrl->parent_obj, sq->db_addr, &v, sizeof(v));
|
||||
|
||||
sq->tail = le32_to_cpu(v);
|
||||
|
||||
trace_pci_nvme_shadow_doorbell_sq(sq->sqid, sq->tail);
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -693,12 +693,12 @@ static const VMStateDescription vmstate_fw_cfg = {
|
||||
}
|
||||
};
|
||||
|
||||
void fw_cfg_add_bytes_callback(FWCfgState *s, uint16_t key,
|
||||
FWCfgCallback select_cb,
|
||||
FWCfgWriteCallback write_cb,
|
||||
void *callback_opaque,
|
||||
void *data, size_t len,
|
||||
bool read_only)
|
||||
static void fw_cfg_add_bytes_callback(FWCfgState *s, uint16_t key,
|
||||
FWCfgCallback select_cb,
|
||||
FWCfgWriteCallback write_cb,
|
||||
void *callback_opaque,
|
||||
void *data, size_t len,
|
||||
bool read_only)
|
||||
{
|
||||
int arch = !!(key & FW_CFG_ARCH_LOCAL);
|
||||
|
||||
|
||||
@@ -117,7 +117,6 @@ config MAC_NEWWORLD
|
||||
select MAC_PMU
|
||||
select UNIN_PCI
|
||||
select FW_CFG_PPC
|
||||
select SCREAMER
|
||||
|
||||
config E500
|
||||
bool
|
||||
|
||||
@@ -796,6 +796,12 @@ int pvrdma_exec_cmd(PVRDMADev *dev)
|
||||
|
||||
dsr_info = &dev->dsr_info;
|
||||
|
||||
if (!dsr_info->dsr) {
|
||||
/* Buggy or malicious guest driver */
|
||||
rdma_error_report("Exec command without dsr, req or rsp buffers");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (dsr_info->req->hdr.cmd >= sizeof(cmd_handlers) /
|
||||
sizeof(struct cmd_handler)) {
|
||||
rdma_error_report("Unsupported command");
|
||||
|
||||
+5
-3
@@ -749,14 +749,16 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance)
|
||||
t->core_count = (ms->smp.cores > 255) ? 0xFF : ms->smp.cores;
|
||||
t->core_enabled = t->core_count;
|
||||
|
||||
t->core_count2 = t->core_enabled2 = cpu_to_le16(ms->smp.cores);
|
||||
|
||||
t->thread_count = (ms->smp.threads > 255) ? 0xFF : ms->smp.threads;
|
||||
t->thread_count2 = cpu_to_le16(ms->smp.threads);
|
||||
|
||||
t->processor_characteristics = cpu_to_le16(0x02); /* Unknown */
|
||||
t->processor_family2 = cpu_to_le16(0x01); /* Other */
|
||||
|
||||
if (tbl_len == SMBIOS_TYPE_4_LEN_V30) {
|
||||
t->core_count2 = t->core_enabled2 = cpu_to_le16(ms->smp.cores);
|
||||
t->thread_count2 = cpu_to_le16(ms->smp.threads);
|
||||
}
|
||||
|
||||
SMBIOS_BUILD_TABLE_POST;
|
||||
smbios_type4_count++;
|
||||
}
|
||||
|
||||
+13
-6
@@ -352,6 +352,16 @@ static const VMStateDescription vmstate_hpet = {
|
||||
}
|
||||
};
|
||||
|
||||
static void hpet_arm(HPETTimer *t, uint64_t ticks)
|
||||
{
|
||||
if (ticks < ns_to_ticks(INT64_MAX / 2)) {
|
||||
timer_mod(t->qemu_timer,
|
||||
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + ticks_to_ns(ticks));
|
||||
} else {
|
||||
timer_del(t->qemu_timer);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* timer expiration callback
|
||||
*/
|
||||
@@ -374,13 +384,11 @@ static void hpet_timer(void *opaque)
|
||||
}
|
||||
}
|
||||
diff = hpet_calculate_diff(t, cur_tick);
|
||||
timer_mod(t->qemu_timer,
|
||||
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + (int64_t)ticks_to_ns(diff));
|
||||
hpet_arm(t, diff);
|
||||
} else if (t->config & HPET_TN_32BIT && !timer_is_periodic(t)) {
|
||||
if (t->wrap_flag) {
|
||||
diff = hpet_calculate_diff(t, cur_tick);
|
||||
timer_mod(t->qemu_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
|
||||
(int64_t)ticks_to_ns(diff));
|
||||
hpet_arm(t, diff);
|
||||
t->wrap_flag = 0;
|
||||
}
|
||||
}
|
||||
@@ -407,8 +415,7 @@ static void hpet_set_timer(HPETTimer *t)
|
||||
t->wrap_flag = 1;
|
||||
}
|
||||
}
|
||||
timer_mod(t->qemu_timer,
|
||||
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + (int64_t)ticks_to_ns(diff));
|
||||
hpet_arm(t, diff);
|
||||
}
|
||||
|
||||
static void hpet_del_timer(HPETTimer *t)
|
||||
|
||||
+1
-2
@@ -1280,8 +1280,7 @@ static void usbredir_create_parser(USBRedirDevice *dev)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (runstate_check(RUN_STATE_INMIGRATE) ||
|
||||
runstate_check(RUN_STATE_RESTORE_VM)) {
|
||||
if (runstate_check(RUN_STATE_INMIGRATE)) {
|
||||
flags |= usbredirparser_fl_no_hello;
|
||||
}
|
||||
usbredirparser_init(dev->parser, VERSION, caps, USB_REDIR_CAPS_SIZE,
|
||||
|
||||
@@ -522,7 +522,7 @@ static void vhost_svq_flush(VhostShadowVirtqueue *svq,
|
||||
size_t vhost_svq_poll(VhostShadowVirtqueue *svq)
|
||||
{
|
||||
int64_t start_us = g_get_monotonic_time();
|
||||
uint32_t len;
|
||||
uint32_t len = 0;
|
||||
|
||||
do {
|
||||
if (vhost_svq_more_used(svq)) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "trace.h"
|
||||
|
||||
#define REALIZE_CONNECTION_RETRIES 3
|
||||
#define VHOST_NVQS 2
|
||||
|
||||
/* Features required from VirtIO */
|
||||
static const int feature_bits[] = {
|
||||
@@ -198,8 +199,7 @@ static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserGPIO *gpio)
|
||||
{
|
||||
virtio_delete_queue(gpio->command_vq);
|
||||
virtio_delete_queue(gpio->interrupt_vq);
|
||||
g_free(gpio->vhost_dev.vqs);
|
||||
gpio->vhost_dev.vqs = NULL;
|
||||
g_free(gpio->vhost_vqs);
|
||||
virtio_cleanup(vdev);
|
||||
vhost_user_cleanup(&gpio->vhost_user);
|
||||
}
|
||||
@@ -219,6 +219,9 @@ static int vu_gpio_connect(DeviceState *dev, Error **errp)
|
||||
vhost_dev_set_config_notifier(vhost_dev, &gpio_ops);
|
||||
gpio->vhost_user.supports_config = true;
|
||||
|
||||
gpio->vhost_dev.nvqs = VHOST_NVQS;
|
||||
gpio->vhost_dev.vqs = gpio->vhost_vqs;
|
||||
|
||||
ret = vhost_dev_init(vhost_dev, &gpio->vhost_user,
|
||||
VHOST_BACKEND_TYPE_USER, 0, errp);
|
||||
if (ret < 0) {
|
||||
@@ -337,10 +340,9 @@ static void vu_gpio_device_realize(DeviceState *dev, Error **errp)
|
||||
|
||||
virtio_init(vdev, VIRTIO_ID_GPIO, sizeof(gpio->config));
|
||||
|
||||
gpio->vhost_dev.nvqs = 2;
|
||||
gpio->command_vq = virtio_add_queue(vdev, 256, vu_gpio_handle_output);
|
||||
gpio->interrupt_vq = virtio_add_queue(vdev, 256, vu_gpio_handle_output);
|
||||
gpio->vhost_dev.vqs = g_new0(struct vhost_virtqueue, gpio->vhost_dev.nvqs);
|
||||
gpio->vhost_vqs = g_new0(struct vhost_virtqueue, VHOST_NVQS);
|
||||
|
||||
gpio->connected = false;
|
||||
|
||||
|
||||
@@ -143,8 +143,6 @@ static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserI2C *i2c)
|
||||
vhost_user_cleanup(&i2c->vhost_user);
|
||||
virtio_delete_queue(i2c->vq);
|
||||
virtio_cleanup(vdev);
|
||||
g_free(i2c->vhost_dev.vqs);
|
||||
i2c->vhost_dev.vqs = NULL;
|
||||
}
|
||||
|
||||
static int vu_i2c_connect(DeviceState *dev)
|
||||
@@ -228,6 +226,7 @@ static void vu_i2c_device_realize(DeviceState *dev, Error **errp)
|
||||
ret = vhost_dev_init(&i2c->vhost_dev, &i2c->vhost_user,
|
||||
VHOST_BACKEND_TYPE_USER, 0, errp);
|
||||
if (ret < 0) {
|
||||
g_free(i2c->vhost_dev.vqs);
|
||||
do_vhost_user_cleanup(vdev, i2c);
|
||||
}
|
||||
|
||||
@@ -239,10 +238,12 @@ static void vu_i2c_device_unrealize(DeviceState *dev)
|
||||
{
|
||||
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
|
||||
VHostUserI2C *i2c = VHOST_USER_I2C(dev);
|
||||
struct vhost_virtqueue *vhost_vqs = i2c->vhost_dev.vqs;
|
||||
|
||||
/* This will stop vhost backend if appropriate. */
|
||||
vu_i2c_set_status(vdev, 0);
|
||||
vhost_dev_cleanup(&i2c->vhost_dev);
|
||||
g_free(vhost_vqs);
|
||||
do_vhost_user_cleanup(vdev, i2c);
|
||||
}
|
||||
|
||||
|
||||
@@ -229,6 +229,7 @@ static void vu_rng_device_realize(DeviceState *dev, Error **errp)
|
||||
return;
|
||||
|
||||
vhost_dev_init_failed:
|
||||
g_free(rng->vhost_dev.vqs);
|
||||
virtio_delete_queue(rng->req_vq);
|
||||
virtio_add_queue_failed:
|
||||
virtio_cleanup(vdev);
|
||||
@@ -239,12 +240,12 @@ static void vu_rng_device_unrealize(DeviceState *dev)
|
||||
{
|
||||
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
|
||||
VHostUserRNG *rng = VHOST_USER_RNG(dev);
|
||||
struct vhost_virtqueue *vhost_vqs = rng->vhost_dev.vqs;
|
||||
|
||||
vu_rng_set_status(vdev, 0);
|
||||
|
||||
vhost_dev_cleanup(&rng->vhost_dev);
|
||||
g_free(rng->vhost_dev.vqs);
|
||||
rng->vhost_dev.vqs = NULL;
|
||||
g_free(vhost_vqs);
|
||||
virtio_delete_queue(rng->req_vq);
|
||||
virtio_cleanup(vdev);
|
||||
vhost_user_cleanup(&rng->vhost_user);
|
||||
|
||||
+2
-15
@@ -707,26 +707,11 @@ static int vhost_vdpa_get_device_id(struct vhost_dev *dev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void vhost_vdpa_reset_svq(struct vhost_vdpa *v)
|
||||
{
|
||||
if (!v->shadow_vqs_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < v->shadow_vqs->len; ++i) {
|
||||
VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
|
||||
vhost_svq_stop(svq);
|
||||
}
|
||||
}
|
||||
|
||||
static int vhost_vdpa_reset_device(struct vhost_dev *dev)
|
||||
{
|
||||
struct vhost_vdpa *v = dev->opaque;
|
||||
int ret;
|
||||
uint8_t status = 0;
|
||||
|
||||
vhost_vdpa_reset_svq(v);
|
||||
|
||||
ret = vhost_vdpa_call(dev, VHOST_VDPA_SET_STATUS, &status);
|
||||
trace_vhost_vdpa_reset_device(dev, status);
|
||||
return ret;
|
||||
@@ -1088,6 +1073,8 @@ static void vhost_vdpa_svqs_stop(struct vhost_dev *dev)
|
||||
|
||||
for (unsigned i = 0; i < v->shadow_vqs->len; ++i) {
|
||||
VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
|
||||
|
||||
vhost_svq_stop(svq);
|
||||
vhost_vdpa_svq_unmap_rings(dev, svq);
|
||||
}
|
||||
}
|
||||
|
||||
+64
-20
@@ -20,6 +20,7 @@
|
||||
#include "qemu/range.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "qemu/memfd.h"
|
||||
#include "qemu/log.h"
|
||||
#include "standard-headers/linux/vhost_types.h"
|
||||
#include "hw/virtio/virtio-bus.h"
|
||||
#include "hw/virtio/virtio-access.h"
|
||||
@@ -106,6 +107,24 @@ static void vhost_dev_sync_region(struct vhost_dev *dev,
|
||||
}
|
||||
}
|
||||
|
||||
static bool vhost_dev_has_iommu(struct vhost_dev *dev)
|
||||
{
|
||||
VirtIODevice *vdev = dev->vdev;
|
||||
|
||||
/*
|
||||
* For vhost, VIRTIO_F_IOMMU_PLATFORM means the backend support
|
||||
* incremental memory mapping API via IOTLB API. For platform that
|
||||
* does not have IOMMU, there's no need to enable this feature
|
||||
* which may cause unnecessary IOTLB miss/update transactions.
|
||||
*/
|
||||
if (vdev) {
|
||||
return virtio_bus_device_iommu_enabled(vdev) &&
|
||||
virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static int vhost_sync_dirty_bitmap(struct vhost_dev *dev,
|
||||
MemoryRegionSection *section,
|
||||
hwaddr first,
|
||||
@@ -137,8 +156,51 @@ static int vhost_sync_dirty_bitmap(struct vhost_dev *dev,
|
||||
continue;
|
||||
}
|
||||
|
||||
vhost_dev_sync_region(dev, section, start_addr, end_addr, vq->used_phys,
|
||||
range_get_last(vq->used_phys, vq->used_size));
|
||||
if (vhost_dev_has_iommu(dev)) {
|
||||
IOMMUTLBEntry iotlb;
|
||||
hwaddr used_phys = vq->used_phys, used_size = vq->used_size;
|
||||
hwaddr phys, s, offset;
|
||||
|
||||
while (used_size) {
|
||||
rcu_read_lock();
|
||||
iotlb = address_space_get_iotlb_entry(dev->vdev->dma_as,
|
||||
used_phys,
|
||||
true,
|
||||
MEMTXATTRS_UNSPECIFIED);
|
||||
rcu_read_unlock();
|
||||
|
||||
if (!iotlb.target_as) {
|
||||
qemu_log_mask(LOG_GUEST_ERROR, "translation "
|
||||
"failure for used_iova %"PRIx64"\n",
|
||||
used_phys);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
offset = used_phys & iotlb.addr_mask;
|
||||
phys = iotlb.translated_addr + offset;
|
||||
|
||||
/*
|
||||
* Distance from start of used ring until last byte of
|
||||
* IOMMU page.
|
||||
*/
|
||||
s = iotlb.addr_mask - offset;
|
||||
/*
|
||||
* Size of used ring, or of the part of it until end
|
||||
* of IOMMU page. To avoid zero result, do the adding
|
||||
* outside of MIN().
|
||||
*/
|
||||
s = MIN(s, used_size - 1) + 1;
|
||||
|
||||
vhost_dev_sync_region(dev, section, start_addr, end_addr, phys,
|
||||
range_get_last(phys, s));
|
||||
used_size -= s;
|
||||
used_phys += s;
|
||||
}
|
||||
} else {
|
||||
vhost_dev_sync_region(dev, section, start_addr,
|
||||
end_addr, vq->used_phys,
|
||||
range_get_last(vq->used_phys, vq->used_size));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -306,24 +368,6 @@ static inline void vhost_dev_log_resize(struct vhost_dev *dev, uint64_t size)
|
||||
dev->log_size = size;
|
||||
}
|
||||
|
||||
static bool vhost_dev_has_iommu(struct vhost_dev *dev)
|
||||
{
|
||||
VirtIODevice *vdev = dev->vdev;
|
||||
|
||||
/*
|
||||
* For vhost, VIRTIO_F_IOMMU_PLATFORM means the backend support
|
||||
* incremental memory mapping API via IOTLB API. For platform that
|
||||
* does not have IOMMU, there's no need to enable this feature
|
||||
* which may cause unnecessary IOTLB miss/update transactions.
|
||||
*/
|
||||
if (vdev) {
|
||||
return virtio_bus_device_iommu_enabled(vdev) &&
|
||||
virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static void *vhost_memory_map(struct vhost_dev *dev, hwaddr addr,
|
||||
hwaddr *plen, bool is_write)
|
||||
{
|
||||
|
||||
@@ -235,7 +235,7 @@ static int virtio_mem_for_each_plugged_section(const VirtIOMEM *vmem,
|
||||
uint64_t offset, size;
|
||||
int ret = 0;
|
||||
|
||||
first_bit = s->offset_within_region / vmem->bitmap_size;
|
||||
first_bit = s->offset_within_region / vmem->block_size;
|
||||
first_bit = find_next_bit(vmem->bitmap, vmem->bitmap_size, first_bit);
|
||||
while (first_bit < vmem->bitmap_size) {
|
||||
MemoryRegionSection tmp = *s;
|
||||
@@ -267,7 +267,7 @@ static int virtio_mem_for_each_unplugged_section(const VirtIOMEM *vmem,
|
||||
uint64_t offset, size;
|
||||
int ret = 0;
|
||||
|
||||
first_bit = s->offset_within_region / vmem->bitmap_size;
|
||||
first_bit = s->offset_within_region / vmem->block_size;
|
||||
first_bit = find_next_zero_bit(vmem->bitmap, vmem->bitmap_size, first_bit);
|
||||
while (first_bit < vmem->bitmap_size) {
|
||||
MemoryRegionSection tmp = *s;
|
||||
@@ -341,7 +341,7 @@ static int virtio_mem_notify_plug(VirtIOMEM *vmem, uint64_t offset,
|
||||
if (ret) {
|
||||
/* Notify all already-notified listeners. */
|
||||
QLIST_FOREACH(rdl2, &vmem->rdl_list, next) {
|
||||
MemoryRegionSection tmp = *rdl->section;
|
||||
MemoryRegionSection tmp = *rdl2->section;
|
||||
|
||||
if (rdl2 == rdl) {
|
||||
break;
|
||||
|
||||
@@ -416,7 +416,6 @@ typedef struct disassemble_info {
|
||||
typedef int (*disassembler_ftype) (bfd_vma, disassemble_info *);
|
||||
|
||||
int print_insn_tci(bfd_vma, disassemble_info*);
|
||||
int print_insn_tcti(bfd_vma, disassemble_info*);
|
||||
int print_insn_big_mips (bfd_vma, disassemble_info*);
|
||||
int print_insn_little_mips (bfd_vma, disassemble_info*);
|
||||
int print_insn_nanomips (bfd_vma, disassemble_info*);
|
||||
|
||||
@@ -657,11 +657,7 @@ void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr);
|
||||
#if defined(CONFIG_TCG_INTERPRETER)
|
||||
extern __thread uintptr_t tci_tb_ptr;
|
||||
# define GETPC() tci_tb_ptr
|
||||
#elif defined(CONFIG_TCG_THREADED_INTERPRETER)
|
||||
extern __thread uintptr_t tcti_call_return_address;
|
||||
# define GETPC() tcti_call_return_address
|
||||
#else
|
||||
/* Note that this is correct for TCTI also; whose gadget behaves like native code. */
|
||||
# define GETPC() \
|
||||
((uintptr_t)__builtin_extract_return_addr(__builtin_return_address(0)))
|
||||
#endif
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#ifndef EXEC_MEMORY_REMAH_H_INCLUDED
|
||||
#define EXEC_MEMORY_REMAH_H_INCLUDED
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
* API for adding and removing mappings of guest RAM and host addrs.
|
||||
* Implementation depends on the hypervisor.
|
||||
*/
|
||||
#define USER_BACKED_RAM_FLAGS_NONE 0x0
|
||||
#define USER_BACKED_RAM_FLAGS_READ 0x1
|
||||
#define USER_BACKED_RAM_FLAGS_WRITE 0x2
|
||||
#define USER_BACKED_RAM_FLAGS_EXEC 0x4
|
||||
void qemu_user_backed_ram_map(uint64_t gpa, void* hva, uint64_t size, int flags);
|
||||
void qemu_user_backed_ram_unmap(uint64_t gpa, uint64_t size);
|
||||
|
||||
#endif /* EXEC_MEMORY_REMAH_H_INCLUDED */
|
||||
@@ -188,8 +188,6 @@ typedef struct IOMMUTLBEvent {
|
||||
/* RAM is a persistent kind memory */
|
||||
#define RAM_PMEM (1 << 5)
|
||||
|
||||
/* RAM backing is managed by user */
|
||||
#define RAM_USER_BACKED (1 << 6)
|
||||
|
||||
/*
|
||||
* UFFDIO_WRITEPROTECT is used on this RAMBlock to
|
||||
@@ -739,7 +737,6 @@ struct MemoryRegion {
|
||||
bool nonvolatile;
|
||||
bool rom_device;
|
||||
bool flush_coalesced_mmio;
|
||||
bool user_backed;
|
||||
uint8_t dirty_log_mask;
|
||||
bool is_iommu;
|
||||
RAMBlock *ram_block;
|
||||
@@ -1512,16 +1509,6 @@ void memory_region_init_ram(MemoryRegion *mr,
|
||||
uint64_t size,
|
||||
Error **errp);
|
||||
|
||||
/**
|
||||
* memory_region_init_ram_user_backed - Initialize RAM memory region where
|
||||
* the allocation is dynamically managed by the user.
|
||||
* Accesses into the region will modify memory directly.
|
||||
*/
|
||||
void memory_region_init_ram_user_backed(MemoryRegion *mr,
|
||||
Object *owner,
|
||||
const char *name,
|
||||
uint64_t size);
|
||||
|
||||
/**
|
||||
* memory_region_init_rom: Initialize a ROM memory region.
|
||||
*
|
||||
@@ -1609,21 +1596,6 @@ static inline bool memory_region_is_ram(MemoryRegion *mr)
|
||||
return mr->ram;
|
||||
}
|
||||
|
||||
/**
|
||||
* memory_region_is_user_backed: check whether a memory region is random access
|
||||
*
|
||||
* Returns %true if a memory region's backing
|
||||
* is user managed. This allows hypervisor to avoid
|
||||
* directly adding the region on initialization,
|
||||
* which can be a fatal error.
|
||||
*
|
||||
* @mr: the memory region being queried
|
||||
*/
|
||||
static inline bool memory_region_is_user_backed(MemoryRegion *mr)
|
||||
{
|
||||
return mr->user_backed;
|
||||
}
|
||||
|
||||
/**
|
||||
* memory_region_is_ram_device: check whether a memory region is a ram device
|
||||
*
|
||||
|
||||
@@ -133,15 +133,6 @@ RAMBlock *qemu_ram_alloc_resizeable(ram_addr_t size, ram_addr_t max_size,
|
||||
uint64_t length,
|
||||
void *host),
|
||||
MemoryRegion *mr, Error **errp);
|
||||
RAMBlock *qemu_ram_alloc_user_backed(ram_addr_t size, MemoryRegion *mr,
|
||||
Error **errp);
|
||||
|
||||
typedef void (*QemuUserBackedRamMapFunc)(uint64_t gpa, void* hva, uint64_t size, int flags);
|
||||
typedef void (*QemuUserBackedRamUnmapFunc)(uint64_t gpa, uint64_t size);
|
||||
|
||||
void qemu_set_user_backed_mapping_funcs(QemuUserBackedRamMapFunc mapFunc,
|
||||
QemuUserBackedRamUnmapFunc unmapFunc);
|
||||
|
||||
void qemu_ram_free(RAMBlock *block);
|
||||
|
||||
int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp);
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* File: screamer.h
|
||||
* Description: header file to the hw/audio/screamer.c file
|
||||
*/
|
||||
|
||||
#ifndef screamer_h
|
||||
#define screamer_h
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "audio/audio.h"
|
||||
#include "hw/ppc/mac_dbdma.h"
|
||||
|
||||
#define TYPE_SCREAMER "screamer"
|
||||
#define SCREAMER(obj) OBJECT_CHECK(ScreamerState, (obj), TYPE_SCREAMER)
|
||||
#define SOUND_CHIP_NAME "Screamer Sound Chip"
|
||||
#define MAX_BUFFER_SIZE (128 * 64)
|
||||
|
||||
typedef struct ScreamerState {
|
||||
SysBusDevice parent_obj;
|
||||
uint16_t awacs[8]; /* Shadow/awacs registers */
|
||||
uint32_t sound_control;
|
||||
uint32_t codec_control;
|
||||
uint32_t codec_status;
|
||||
uint32_t clip_count;
|
||||
uint32_t byte_swap;
|
||||
uint32_t frame_count;
|
||||
SWVoiceOut *speaker_voice;
|
||||
DBDMAState *dbdma;
|
||||
qemu_irq dma_send_irq;
|
||||
qemu_irq dma_receive_irq;
|
||||
qemu_irq irq;
|
||||
QEMUSoundCard card;
|
||||
MemoryRegion io_memory_region;
|
||||
uint8_t spk_buffer[MAX_BUFFER_SIZE];
|
||||
uint16_t spk_buffer_position, spk_play_position;
|
||||
DBDMA_io dma_io;
|
||||
} ScreamerState;
|
||||
|
||||
void screamer_register_dma_functions(ScreamerState *s, void *dbdma,
|
||||
int send_channel, int receive_channel);
|
||||
|
||||
#endif /* screamer_h */
|
||||
@@ -128,9 +128,6 @@ struct PCMachineClass {
|
||||
|
||||
/* create kvmclock device even when KVM PV features are not exposed */
|
||||
bool kvmclock_create_always;
|
||||
|
||||
/* skip passing an rng seed for legacy machines */
|
||||
bool legacy_no_rng_seed;
|
||||
};
|
||||
|
||||
#define TYPE_PC_MACHINE "generic-pc-machine"
|
||||
|
||||
@@ -126,8 +126,7 @@ void x86_bios_rom_init(MachineState *ms, const char *default_firmware,
|
||||
void x86_load_linux(X86MachineState *x86ms,
|
||||
FWCfgState *fw_cfg,
|
||||
int acpi_data_size,
|
||||
bool pvh_enabled,
|
||||
bool legacy_no_rng_seed);
|
||||
bool pvh_enabled);
|
||||
|
||||
bool x86_machine_is_smm_enabled(const X86MachineState *x86ms);
|
||||
bool x86_machine_is_acpi_enabled(const X86MachineState *x86ms);
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#include "hw/nvram/mac_nvram.h"
|
||||
#include "hw/ppc/mac_dbdma.h"
|
||||
#include "hw/ppc/openpic.h"
|
||||
#include "hw/audio/screamer.h"
|
||||
#include "qom/object.h"
|
||||
|
||||
/* Old World IRQs */
|
||||
@@ -59,9 +58,6 @@
|
||||
#define NEWWORLD_IDE1_DMA_IRQ 0x3
|
||||
#define NEWWORLD_EXTING_GPIO1 0x2f
|
||||
#define NEWWORLD_EXTING_GPIO9 0x37
|
||||
#define NEWWORLD_SCREAMER_IRQ 0x18
|
||||
#define NEWWORLD_SCREAMER_DMA_IRQ 0x9
|
||||
#define NEWWORLD_SCREAMER_RX_IRQ 0xa
|
||||
|
||||
/* MacIO virtual bus */
|
||||
#define TYPE_MACIO_BUS "macio-bus"
|
||||
@@ -113,7 +109,6 @@ struct MacIOState {
|
||||
PMUState pmu;
|
||||
DBDMAState dbdma;
|
||||
ESCCState escc;
|
||||
ScreamerState screamer;
|
||||
uint64_t frequency;
|
||||
};
|
||||
|
||||
|
||||
@@ -117,28 +117,6 @@ struct FWCfgMemState {
|
||||
*/
|
||||
void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_t len);
|
||||
|
||||
/**
|
||||
* fw_cfg_add_bytes_callback:
|
||||
* @s: fw_cfg device being modified
|
||||
* @key: selector key value for new fw_cfg item
|
||||
* @select_cb: callback function when selecting
|
||||
* @write_cb: callback function after a write
|
||||
* @callback_opaque: argument to be passed into callback function
|
||||
* @data: pointer to start of item data
|
||||
* @len: size of item data
|
||||
* @read_only: is file read only
|
||||
*
|
||||
* Add a new fw_cfg item, available by selecting the given key, as a raw
|
||||
* "blob" of the given size. The data referenced by the starting pointer
|
||||
* is only linked, NOT copied, into the data structure of the fw_cfg device.
|
||||
*/
|
||||
void fw_cfg_add_bytes_callback(FWCfgState *s, uint16_t key,
|
||||
FWCfgCallback select_cb,
|
||||
FWCfgWriteCallback write_cb,
|
||||
void *callback_opaque,
|
||||
void *data, size_t len,
|
||||
bool read_only);
|
||||
|
||||
/**
|
||||
* fw_cfg_add_string:
|
||||
* @s: fw_cfg device being modified
|
||||
|
||||
@@ -23,7 +23,7 @@ struct VHostUserGPIO {
|
||||
VirtIODevice parent_obj;
|
||||
CharBackend chardev;
|
||||
struct virtio_gpio_config config;
|
||||
struct vhost_virtqueue *vhost_vq;
|
||||
struct vhost_virtqueue *vhost_vqs;
|
||||
struct vhost_dev vhost_dev;
|
||||
VhostUserState vhost_user;
|
||||
VirtQueue *command_vq;
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
#ifndef VIRTIO_GOLDFISH_PIPE
|
||||
#define VIRTIO_GOLDFISH_PIPE
|
||||
|
||||
/* An override of virtio-gpu-3d (virgl) that runs goldfish pipe. One could
|
||||
* implement an actual virtio goldfish pipe, but this hijacking of virgl is
|
||||
* done in order to avoid any guest kernel changes. */
|
||||
|
||||
#include <virglrenderer.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
typedef uint32_t VirtioGpuCtxId;
|
||||
typedef uint8_t VirtioGpuRingIdx;
|
||||
struct virgl_renderer_virtio_interface*
|
||||
get_goldfish_pipe_virgl_renderer_virtio_interface(void);
|
||||
|
||||
/* Needed for goldfish pipe */
|
||||
void virgl_write_fence(void *opaque, uint32_t fence);
|
||||
|
||||
void virtio_goldfish_pipe_reset(void* hwpipe, void* hostpipe);
|
||||
|
||||
#define VIRTIO_GOLDFISH_EXPORT_API
|
||||
#ifdef VIRTIO_GOLDFISH_EXPORT_API
|
||||
|
||||
#ifdef _WIN32
|
||||
#define VG_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define VG_EXPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
VG_EXPORT int pipe_virgl_renderer_init(void *cookie,
|
||||
int flags,
|
||||
struct virgl_renderer_callbacks *cb);
|
||||
VG_EXPORT void pipe_virgl_renderer_poll(void);
|
||||
VG_EXPORT void* pipe_virgl_renderer_get_cursor_data(
|
||||
uint32_t resource_id, uint32_t *width, uint32_t *height);
|
||||
VG_EXPORT int pipe_virgl_renderer_resource_create(
|
||||
struct virgl_renderer_resource_create_args *args,
|
||||
struct iovec *iov, uint32_t num_iovs);
|
||||
VG_EXPORT void pipe_virgl_renderer_resource_unref(uint32_t res_handle);
|
||||
VG_EXPORT int pipe_virgl_renderer_context_create(
|
||||
uint32_t handle, uint32_t nlen, const char *name);
|
||||
VG_EXPORT void pipe_virgl_renderer_context_destroy(uint32_t handle);
|
||||
VG_EXPORT int pipe_virgl_renderer_submit_cmd(void *buffer,
|
||||
int ctx_id,
|
||||
int bytes);
|
||||
VG_EXPORT int pipe_virgl_renderer_transfer_read_iov(
|
||||
uint32_t handle, uint32_t ctx_id,
|
||||
uint32_t level, uint32_t stride,
|
||||
uint32_t layer_stride,
|
||||
struct virgl_box *box,
|
||||
uint64_t offset, struct iovec *iov,
|
||||
int iovec_cnt);
|
||||
VG_EXPORT int pipe_virgl_renderer_transfer_write_iov(
|
||||
uint32_t handle,
|
||||
uint32_t ctx_id,
|
||||
int level,
|
||||
uint32_t stride,
|
||||
uint32_t layer_stride,
|
||||
struct virgl_box *box,
|
||||
uint64_t offset,
|
||||
struct iovec *iovec,
|
||||
unsigned int iovec_cnt);
|
||||
VG_EXPORT void pipe_virgl_renderer_get_cap_set(uint32_t, uint32_t*, uint32_t*);
|
||||
VG_EXPORT void pipe_virgl_renderer_fill_caps(uint32_t, uint32_t, void *caps);
|
||||
|
||||
VG_EXPORT int pipe_virgl_renderer_resource_attach_iov(
|
||||
int res_handle, struct iovec *iov,
|
||||
int num_iovs);
|
||||
VG_EXPORT void pipe_virgl_renderer_resource_detach_iov(
|
||||
int res_handle, struct iovec **iov, int *num_iovs);
|
||||
VG_EXPORT int pipe_virgl_renderer_create_fence(
|
||||
int client_fence_id, uint32_t cmd_type);
|
||||
VG_EXPORT void pipe_virgl_renderer_force_ctx_0(void);
|
||||
VG_EXPORT void pipe_virgl_renderer_ctx_attach_resource(
|
||||
int ctx_id, int res_handle);
|
||||
VG_EXPORT void pipe_virgl_renderer_ctx_detach_resource(
|
||||
int ctx_id, int res_handle);
|
||||
VG_EXPORT int pipe_virgl_renderer_resource_get_info(
|
||||
int res_handle,
|
||||
struct virgl_renderer_resource_info *info);
|
||||
|
||||
VG_EXPORT void stream_renderer_flush_resource_and_readback(
|
||||
uint32_t res_handle, uint32_t x, uint32_t y, uint32_t width, uint32_t height,
|
||||
void* pixels, uint32_t max_bytes);
|
||||
|
||||
VG_EXPORT void stream_renderer_resource_create_v2(
|
||||
uint32_t res_handle, uint64_t hvaId);
|
||||
VG_EXPORT uint64_t stream_renderer_resource_get_hva(uint32_t res_handle);
|
||||
VG_EXPORT uint64_t stream_renderer_resource_get_hva_size(uint32_t res_handle);
|
||||
VG_EXPORT void stream_renderer_resource_set_hv_slot(uint32_t res_handle, uint32_t slot);
|
||||
VG_EXPORT uint32_t stream_renderer_resource_get_hv_slot(uint32_t res_handle);
|
||||
VG_EXPORT int stream_renderer_resource_map(uint32_t res_handle, void** hvaOut, uint64_t* sizeOut);
|
||||
VG_EXPORT int stream_renderer_resource_unmap(uint32_t res_handle);
|
||||
VG_EXPORT int stream_renderer_context_create_fence(
|
||||
uint64_t fence_id, uint32_t ctx_id, uint8_t ring_idx);
|
||||
|
||||
// Platform resources and contexts support
|
||||
#define STREAM_RENDERER_PLATFORM_RESOURCE_TYPE_EGL_NATIVE_PIXMAP 0x01
|
||||
#define STREAM_RENDERER_PLATFORM_RESOURCE_TYPE_EGL_IMAGE 0x02
|
||||
|
||||
VG_EXPORT int stream_renderer_platform_import_resource(int res_handle, int res_type, void* resource);
|
||||
VG_EXPORT int stream_renderer_platform_resource_info(int res_handle, int* width, int* height, int* internal_format);
|
||||
VG_EXPORT void* stream_renderer_platform_create_shared_egl_context(void);
|
||||
VG_EXPORT int stream_renderer_platform_destroy_shared_egl_context(void*);
|
||||
|
||||
#else
|
||||
|
||||
#define VG_EXPORT
|
||||
|
||||
#endif // !VIRTIO_GOLDFISH_EXPORT_API
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
// based on VIRGL_RENDERER_USE* and friends
|
||||
enum RendererFlags {
|
||||
GFXSTREAM_RENDERER_FLAGS_USE_EGL_BIT = 1 << 0,
|
||||
GFXSTREAM_RENDERER_FLAGS_THREAD_SYNC = 1 << 1,
|
||||
GFXSTREAM_RENDERER_FLAGS_USE_GLX_BIT = 1 << 2,
|
||||
GFXSTREAM_RENDERER_FLAGS_USE_SURFACELESS_BIT = 1 << 3,
|
||||
GFXSTREAM_RENDERER_FLAGS_USE_GLES_BIT = 1 << 4,
|
||||
GFXSTREAM_RENDERER_FLAGS_NO_VK_BIT = 1 << 5, // for disabling vk
|
||||
GFXSTREAM_RENDERER_FLAGS_ENABLE_GLES31_BIT =
|
||||
1 << 9, // disables the PlayStoreImage flag
|
||||
GFXSTREAM_RENDERER_FLAGS_GUEST_USES_ANGLE = 1 << 21,
|
||||
GFXSTREAM_RENDERER_FLAGS_VULKAN_NATIVE_SWAPCHAIN_BIT = 1 << 22,
|
||||
GFXSTREAM_RENDERER_FLAGS_ASYNC_FENCE_CB = 1 << 23,
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -34,7 +34,6 @@ struct VirtIOGPUPCIBase {
|
||||
#define DEFINE_VIRTIO_GPU_PCI_PROPERTIES(_state) \
|
||||
DEFINE_PROP_BIT("ioeventfd", _state, flags, \
|
||||
VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, false), \
|
||||
DEFINE_PROP_BIT("hostshm", _state, flags, VIRTIO_PCI_FLAG_HOSTSHM_BIT, true), \
|
||||
DEFINE_PROP_UINT32("vectors", _state, nvectors, 3)
|
||||
|
||||
#endif /* HW_VIRTIO_GPU_PCI_H */
|
||||
@@ -1,114 +0,0 @@
|
||||
#ifndef HW_VIRTIO_GPU_VIRGL_H
|
||||
#define HW_VIRTIO_GPU_VIRGL_H
|
||||
|
||||
#include <virglrenderer.h>
|
||||
|
||||
struct virgl_renderer_resource_info;
|
||||
|
||||
/* Struct of virglrenderer API calls in order to be able to switch between
|
||||
* different virgl API impls, or different devices altogether that use
|
||||
* the virglrenderer API (e.g., goldfish pipe) */
|
||||
|
||||
typedef int (*virgl_renderer_init_t)(
|
||||
void *cookie, int flags, struct virgl_renderer_callbacks *cb);
|
||||
typedef void (*virgl_renderer_poll_t)(void); /* force fences */
|
||||
typedef void* (*virgl_renderer_get_cursor_data_t)(
|
||||
uint32_t resource_id, uint32_t *width, uint32_t *height);
|
||||
typedef int (*virgl_renderer_resource_create_t)(
|
||||
struct virgl_renderer_resource_create_args *args,
|
||||
struct iovec *iov, uint32_t num_iovs);
|
||||
typedef void (*virgl_renderer_resource_unref_t)(uint32_t res_handle);
|
||||
typedef int (*virgl_renderer_context_create_t)(
|
||||
uint32_t handle, uint32_t nlen, const char *name);
|
||||
typedef void (*virgl_renderer_context_destroy_t)(uint32_t handle);
|
||||
typedef int (*virgl_renderer_submit_cmd_t)(void *buffer,
|
||||
int ctx_id,
|
||||
int ndw);
|
||||
typedef int (*virgl_renderer_transfer_read_iov_t)(
|
||||
uint32_t handle, uint32_t ctx_id,
|
||||
uint32_t level, uint32_t stride,
|
||||
uint32_t layer_stride,
|
||||
struct virgl_box *box,
|
||||
uint64_t offset, struct iovec *iov,
|
||||
int iovec_cnt);
|
||||
typedef int (*virgl_renderer_transfer_write_iov_t)(
|
||||
uint32_t handle,
|
||||
uint32_t ctx_id,
|
||||
int level,
|
||||
uint32_t stride,
|
||||
uint32_t layer_stride,
|
||||
struct virgl_box *box,
|
||||
uint64_t offset,
|
||||
struct iovec *iovec,
|
||||
unsigned int iovec_cnt);
|
||||
typedef void (*virgl_renderer_get_cap_set_t)(uint32_t set, uint32_t *max_ver,
|
||||
uint32_t *max_size);
|
||||
|
||||
typedef void (*virgl_renderer_fill_caps_t)(uint32_t set, uint32_t version,
|
||||
void *caps);
|
||||
|
||||
typedef int (*virgl_renderer_resource_attach_iov_t)(
|
||||
int res_handle, struct iovec *iov,
|
||||
int num_iovs);
|
||||
typedef void (*virgl_renderer_resource_detach_iov_t)(
|
||||
int res_handle, struct iovec **iov, int *num_iovs);
|
||||
|
||||
typedef int (*virgl_renderer_create_fence_t)(
|
||||
int client_fence_id, uint32_t ctx_id);
|
||||
|
||||
typedef void (*virgl_renderer_force_ctx_0_t)(void);
|
||||
|
||||
typedef void (*virgl_renderer_ctx_attach_resource_t)(
|
||||
int ctx_id, int res_handle);
|
||||
typedef void (*virgl_renderer_ctx_detach_resource_t)(
|
||||
int ctx_id, int res_handle);
|
||||
typedef int (*virgl_renderer_resource_get_info_t)(
|
||||
int res_handle,
|
||||
struct virgl_renderer_resource_info *info);
|
||||
typedef int (*virgl_renderer_resource_create_v2_t)(unsigned int res_handle, uint64_t hvaId);
|
||||
typedef int (*virgl_renderer_resource_map_t)(unsigned int res_handle, void** hvaOut, uint64_t* sizeOut);
|
||||
typedef int (*virgl_renderer_resource_unmap_t)(unsigned int res_handle);
|
||||
typedef void (*virgl_renderer_save_snapshot_t)(void* qemufile);
|
||||
typedef void (*virgl_renderer_load_snapshot_t)(void* qemufile);
|
||||
typedef int (*virgl_renderer_resource_attach_iov_with_addrs_t)(
|
||||
int res_handle, struct iovec *iov, int num_iovs, uint64_t* addrs);
|
||||
|
||||
#define LIST_VIRGLRENDERER_API(f) \
|
||||
f(virgl_renderer_init) \
|
||||
f(virgl_renderer_poll) \
|
||||
f(virgl_renderer_get_cursor_data) \
|
||||
f(virgl_renderer_resource_create) \
|
||||
f(virgl_renderer_resource_unref) \
|
||||
f(virgl_renderer_context_create) \
|
||||
f(virgl_renderer_context_destroy) \
|
||||
f(virgl_renderer_submit_cmd) \
|
||||
f(virgl_renderer_transfer_read_iov) \
|
||||
f(virgl_renderer_transfer_write_iov) \
|
||||
f(virgl_renderer_get_cap_set) \
|
||||
f(virgl_renderer_fill_caps) \
|
||||
f(virgl_renderer_resource_attach_iov) \
|
||||
f(virgl_renderer_resource_detach_iov) \
|
||||
f(virgl_renderer_create_fence) \
|
||||
f(virgl_renderer_force_ctx_0) \
|
||||
f(virgl_renderer_ctx_attach_resource) \
|
||||
f(virgl_renderer_ctx_detach_resource) \
|
||||
f(virgl_renderer_resource_get_info) \
|
||||
f(virgl_renderer_resource_create_v2) \
|
||||
f(virgl_renderer_resource_map) \
|
||||
f(virgl_renderer_resource_unmap) \
|
||||
f(virgl_renderer_save_snapshot) \
|
||||
f(virgl_renderer_load_snapshot) \
|
||||
f(virgl_renderer_resource_attach_iov_with_addrs) \
|
||||
|
||||
#define VIRGLRENDERER_API_DEFINE_STRUCT_FIELD(api) \
|
||||
api##_t api;
|
||||
|
||||
struct virgl_renderer_virtio_interface {
|
||||
LIST_VIRGLRENDERER_API(VIRGLRENDERER_API_DEFINE_STRUCT_FIELD)
|
||||
};
|
||||
|
||||
struct virgl_renderer_virtio_interface* get_default_virtio_interface(void);
|
||||
|
||||
extern struct virgl_renderer_virtio_interface *get_goldfish_pipe_virgl_renderer_virtio_interface(void);
|
||||
|
||||
#endif /* HW_VIRTIO_GPU_VIRGL_H */
|
||||
@@ -90,7 +90,6 @@ enum virtio_gpu_base_conf_flags {
|
||||
VIRTIO_GPU_FLAG_EDID_ENABLED,
|
||||
VIRTIO_GPU_FLAG_DMABUF_ENABLED,
|
||||
VIRTIO_GPU_FLAG_BLOB_ENABLED,
|
||||
VIRTIO_GPU_FLAG_GOLDFISH_PIPE_ENABLED,
|
||||
};
|
||||
|
||||
#define virtio_gpu_virgl_enabled(_cfg) \
|
||||
@@ -103,8 +102,6 @@ enum virtio_gpu_base_conf_flags {
|
||||
(_cfg.flags & (1 << VIRTIO_GPU_FLAG_DMABUF_ENABLED))
|
||||
#define virtio_gpu_blob_enabled(_cfg) \
|
||||
(_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED))
|
||||
#define virtio_gpu_goldfish_pipe_enabled(_cfg) \
|
||||
(_cfg.flags & (1 << VIRTIO_GPU_FLAG_GOLDFISH_PIPE_ENABLED))
|
||||
|
||||
struct virtio_gpu_base_conf {
|
||||
uint32_t max_outputs;
|
||||
@@ -202,10 +199,6 @@ struct VirtIOGPUClass {
|
||||
void (*update_cursor_data)(VirtIOGPU *g,
|
||||
struct virtio_gpu_scanout *s,
|
||||
uint32_t resource_id);
|
||||
int (*gpu_save)(QEMUFile *f, void *opaque, size_t size,
|
||||
const VMStateField *field, JSONWriter *vmdesc);
|
||||
int (*gpu_load)(QEMUFile *f, void *opaque, size_t size,
|
||||
const VMStateField *field);
|
||||
};
|
||||
|
||||
struct VirtIOGPUGL {
|
||||
@@ -213,8 +206,6 @@ struct VirtIOGPUGL {
|
||||
|
||||
bool renderer_inited;
|
||||
bool renderer_reset;
|
||||
struct virgl_renderer_virtio_interface* virgl;
|
||||
MemoryRegion host_coherent_memory;
|
||||
};
|
||||
|
||||
struct VhostUserGPU {
|
||||
@@ -274,10 +265,6 @@ void virtio_gpu_simple_process_cmd(VirtIOGPU *g, struct virtio_gpu_ctrl_command
|
||||
void virtio_gpu_update_cursor_data(VirtIOGPU *g,
|
||||
struct virtio_gpu_scanout *s,
|
||||
uint32_t resource_id);
|
||||
int virtio_gpu_save(QEMUFile *f, void *opaque, size_t size,
|
||||
const VMStateField *field, JSONWriter *vmdesc);
|
||||
int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size,
|
||||
const VMStateField *field);
|
||||
|
||||
/* virtio-gpu-udmabuf.c */
|
||||
bool virtio_gpu_have_udmabuf(void);
|
||||
@@ -298,9 +285,4 @@ void virtio_gpu_virgl_reset(VirtIOGPU *g);
|
||||
int virtio_gpu_virgl_init(VirtIOGPU *g);
|
||||
int virtio_gpu_virgl_get_num_capsets(VirtIOGPU *g);
|
||||
|
||||
#ifdef CONFIG_ANDROID
|
||||
void virtio_gpu_save_ram_slots(void* qemufile, VirtIOGPU* g);
|
||||
void virtio_gpu_load_ram_slots(void* qemufile, VirtIOGPU* g);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -43,7 +43,6 @@ enum {
|
||||
VIRTIO_PCI_FLAG_INIT_FLR_BIT,
|
||||
VIRTIO_PCI_FLAG_AER_BIT,
|
||||
VIRTIO_PCI_FLAG_ATS_PAGE_ALIGNED_BIT,
|
||||
VIRTIO_PCI_FLAG_HOSTSHM_BIT,
|
||||
};
|
||||
|
||||
/* Need to activate work-arounds for buggy guests at vmstate load. */
|
||||
@@ -90,9 +89,6 @@ enum {
|
||||
#define VIRTIO_PCI_FLAG_ATS_PAGE_ALIGNED \
|
||||
(1 << VIRTIO_PCI_FLAG_ATS_PAGE_ALIGNED_BIT)
|
||||
|
||||
/* Host coherent shared memory */
|
||||
#define VIRTIO_PCI_FLAG_HOSTSHM (1 << VIRTIO_PCI_FLAG_HOSTSHM_BIT)
|
||||
|
||||
typedef struct {
|
||||
MSIMessage msg;
|
||||
int virq;
|
||||
@@ -146,12 +142,10 @@ struct VirtIOPCIProxy {
|
||||
};
|
||||
MemoryRegion modern_bar;
|
||||
MemoryRegion io_bar;
|
||||
MemoryRegion hostshm_bar;
|
||||
uint32_t legacy_io_bar_idx;
|
||||
uint32_t msix_bar_idx;
|
||||
uint32_t modern_io_bar_idx;
|
||||
uint32_t modern_mem_bar_idx;
|
||||
uint32_t hostshm_mem_bar_idx;
|
||||
int config_cap;
|
||||
uint32_t flags;
|
||||
bool disable_modern;
|
||||
|
||||
+21
-1
@@ -177,7 +177,7 @@ extern "C" {
|
||||
* supports QEMU_ERROR, this will be reported at compile time; otherwise
|
||||
* this will be reported at link time due to the missing symbol.
|
||||
*/
|
||||
extern G_NORETURN
|
||||
G_NORETURN extern
|
||||
void QEMU_ERROR("code path is reachable")
|
||||
qemu_build_not_reached_always(void);
|
||||
#if defined(__OPTIMIZE__) && !defined(__NO_INLINE__)
|
||||
@@ -673,6 +673,26 @@ int qemu_msync(void *addr, size_t length, int fd);
|
||||
*/
|
||||
size_t qemu_get_host_physmem(void);
|
||||
|
||||
/*
|
||||
* Toggle write/execute on the pages marked MAP_JIT
|
||||
* for the current thread.
|
||||
*/
|
||||
#if defined(MAC_OS_VERSION_11_0) && \
|
||||
MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_11_0
|
||||
static inline void qemu_thread_jit_execute(void)
|
||||
{
|
||||
pthread_jit_write_protect_np(true);
|
||||
}
|
||||
|
||||
static inline void qemu_thread_jit_write(void)
|
||||
{
|
||||
pthread_jit_write_protect_np(false);
|
||||
}
|
||||
#else
|
||||
static inline void qemu_thread_jit_write(void) {}
|
||||
static inline void qemu_thread_jit_execute(void) {}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Platforms which do not support system() return ENOSYS
|
||||
*/
|
||||
|
||||
@@ -28,15 +28,6 @@ extern bool hvf_allowed;
|
||||
#define hvf_get_supported_cpuid(func, idx, reg) 0
|
||||
#endif /* !CONFIG_HVF */
|
||||
|
||||
void* hvf_gpa2hva(uint64_t gpa, bool* found);
|
||||
int hvf_hva2gpa(void* hva, uint64_t length, int max,
|
||||
uint64_t* gpa, uint64_t* size);
|
||||
|
||||
int hvf_map_safe(void* hva, uint64_t gpa, uint64_t size, uint64_t flags);
|
||||
int hvf_unmap_safe(uint64_t gpa, uint64_t size);
|
||||
int hvf_protect_safe(uint64_t gpa, uint64_t size, uint64_t flags);
|
||||
int hvf_remap_safe(void* hva, uint64_t gpa, uint64_t size, uint64_t flags);
|
||||
|
||||
#endif /* NEED_CPU_H */
|
||||
|
||||
#define TYPE_HVF_ACCEL ACCEL_CLASS_NAME("hvf")
|
||||
|
||||
@@ -17,15 +17,6 @@
|
||||
#include <Hypervisor/hv.h>
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_HVF_PRIVATE) && defined(__aarch64__)
|
||||
extern hv_return_t _hv_vm_config_set_isa(hv_vm_config_t config, uint32_t isa);
|
||||
extern hv_return_t _hv_vcpu_get_actlr(hv_vcpu_t vcpu, uint64_t* value);
|
||||
extern hv_return_t _hv_vcpu_set_actlr(hv_vcpu_t vcpu, uint64_t value);
|
||||
|
||||
#define HV_VM_CONFIG_ISA_PRIVATE (3)
|
||||
#define ACTLR_EL1_TSO_ENABLE_MASK ((1 << 1) | (1 << 9))
|
||||
#endif
|
||||
|
||||
/* hvf_slot flags */
|
||||
#define HVF_SLOT_LOG (1 << 0)
|
||||
|
||||
@@ -54,9 +45,6 @@ struct HVFState {
|
||||
|
||||
hvf_vcpu_caps *hvf_caps;
|
||||
uint64_t vtimer_offset;
|
||||
#if defined(CONFIG_HVF_PRIVATE) && defined(__aarch64__)
|
||||
bool tso_mode;
|
||||
#endif
|
||||
};
|
||||
extern HVFState *hvf_state;
|
||||
|
||||
@@ -68,7 +56,6 @@ struct hvf_vcpu_state {
|
||||
};
|
||||
|
||||
void assert_hvf_ok(hv_return_t ret);
|
||||
hv_return_t hvf_arch_vm_create(HVFState *s);
|
||||
int hvf_arch_init(void);
|
||||
int hvf_arch_init_vcpu(CPUState *cpu);
|
||||
void hvf_arch_vcpu_destroy(CPUState *cpu);
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
/*
|
||||
* Apple Silicon functions for JIT handling
|
||||
*
|
||||
* Copyright (c) 2020 osy
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TCG_APPLE_JIT_H
|
||||
#define TCG_APPLE_JIT_H
|
||||
|
||||
/*
|
||||
* APRR handling
|
||||
* Credits to: https://siguza.github.io/APRR/
|
||||
* Reversed from /usr/lib/system/libsystem_pthread.dylib
|
||||
*/
|
||||
|
||||
#if defined(__aarch64__) && defined(CONFIG_DARWIN)
|
||||
|
||||
#define _COMM_PAGE_START_ADDRESS (0x0000000FFFFFC000ULL) /* In TTBR0 */
|
||||
#define _COMM_PAGE_APRR_SUPPORT (_COMM_PAGE_START_ADDRESS + 0x10C)
|
||||
#define _COMM_PAGE_APPR_WRITE_ENABLE (_COMM_PAGE_START_ADDRESS + 0x110)
|
||||
#define _COMM_PAGE_APRR_WRITE_DISABLE (_COMM_PAGE_START_ADDRESS + 0x118)
|
||||
|
||||
static __attribute__((__always_inline__)) bool jit_write_protect_supported(void)
|
||||
{
|
||||
/* Access shared kernel page at fixed memory location. */
|
||||
uint8_t aprr_support = *(volatile uint8_t *)_COMM_PAGE_APRR_SUPPORT;
|
||||
return aprr_support > 0;
|
||||
}
|
||||
|
||||
/* write protect enable = write disable */
|
||||
static __attribute__((__always_inline__)) void jit_write_protect(int enabled)
|
||||
{
|
||||
/* Access shared kernel page at fixed memory location. */
|
||||
uint8_t aprr_support = *(volatile uint8_t *)_COMM_PAGE_APRR_SUPPORT;
|
||||
if (aprr_support == 0 || aprr_support > 3) {
|
||||
return;
|
||||
} else if (aprr_support == 1) {
|
||||
__asm__ __volatile__ (
|
||||
"mov x0, %0\n"
|
||||
"ldr x0, [x0]\n"
|
||||
"msr S3_4_c15_c2_7, x0\n"
|
||||
"isb sy\n"
|
||||
:: "r" (enabled ? _COMM_PAGE_APRR_WRITE_DISABLE
|
||||
: _COMM_PAGE_APPR_WRITE_ENABLE)
|
||||
: "memory", "x0"
|
||||
);
|
||||
} else {
|
||||
__asm__ __volatile__ (
|
||||
"mov x0, %0\n"
|
||||
"ldr x0, [x0]\n"
|
||||
"msr S3_6_c15_c1_5, x0\n"
|
||||
"isb sy\n"
|
||||
:: "r" (enabled ? _COMM_PAGE_APRR_WRITE_DISABLE
|
||||
: _COMM_PAGE_APPR_WRITE_ENABLE)
|
||||
: "memory", "x0"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#else /* defined(__aarch64__) && defined(CONFIG_DARWIN) */
|
||||
|
||||
static __attribute__((__always_inline__)) bool jit_write_protect_supported(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static __attribute__((__always_inline__)) void jit_write_protect(int enabled)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static inline void qemu_thread_jit_execute(void)
|
||||
{
|
||||
if (jit_write_protect_supported()) {
|
||||
jit_write_protect(true);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void qemu_thread_jit_write(void)
|
||||
{
|
||||
if (jit_write_protect_supported()) {
|
||||
jit_write_protect(false);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* define TCG_APPLE_JIT_H */
|
||||
@@ -194,11 +194,7 @@ DEF(insn_start, 0, 0, TLADDR_ARGS * TARGET_INSN_START_WORDS,
|
||||
TCG_OPF_NOT_PRESENT)
|
||||
DEF(exit_tb, 0, 0, 1, TCG_OPF_BB_EXIT | TCG_OPF_BB_END)
|
||||
DEF(goto_tb, 0, 0, 1, TCG_OPF_BB_EXIT | TCG_OPF_BB_END)
|
||||
#if defined(CONFIG_TCG_THREADED_INTERPRETER)
|
||||
DEF(goto_ptr, 0, 1, 0, TCG_OPF_BB_EXIT | TCG_OPF_BB_END | TCG_OPF_NOT_PRESENT)
|
||||
#else
|
||||
DEF(goto_ptr, 0, 1, 0, TCG_OPF_BB_EXIT | TCG_OPF_BB_END)
|
||||
#endif
|
||||
|
||||
DEF(plugin_cb_start, 0, 0, 3, TCG_OPF_NOT_PRESENT)
|
||||
DEF(plugin_cb_end, 0, 0, 0, TCG_OPF_NOT_PRESENT)
|
||||
|
||||
+1
-1
@@ -1199,7 +1199,7 @@ static inline size_t tcg_current_code_size(TCGContext *s)
|
||||
#define TB_EXIT_IDXMAX 1
|
||||
#define TB_EXIT_REQUESTED 3
|
||||
|
||||
#if defined(CONFIG_TCG_INTERPRETER) || defined(CONFIG_TCG_THREADED_INTERPRETER)
|
||||
#ifdef CONFIG_TCG_INTERPRETER
|
||||
uintptr_t tcg_qemu_tb_exec(CPUArchState *env, const void *tb_ptr);
|
||||
#else
|
||||
typedef uintptr_t tcg_prologue_fn(CPUArchState *env, const void *tb_ptr);
|
||||
|
||||
@@ -1,141 +0,0 @@
|
||||
/*
|
||||
* QEMU Cocoa CG display driver
|
||||
*
|
||||
* Copyright (c) 2008 Mike Kronenberg
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef UI_COCOA_H
|
||||
#define UI_COCOA_H
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "ui/clipboard.h"
|
||||
#include "ui/console.h"
|
||||
#include "ui/kbd-state.h"
|
||||
#include "qemu/main-loop.h"
|
||||
#include "qemu/thread.h"
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
#ifdef DEBUG
|
||||
#define COCOA_DEBUG(...) { (void) fprintf (stdout, __VA_ARGS__); }
|
||||
#else
|
||||
#define COCOA_DEBUG(...) ((void) 0)
|
||||
#endif
|
||||
|
||||
typedef struct CocoaListener {
|
||||
DisplayChangeListener dcl;
|
||||
QEMUCursor *cursor;
|
||||
int mouse_x;
|
||||
int mouse_y;
|
||||
int mouse_on;
|
||||
#ifdef CONFIG_OPENGL
|
||||
uint32_t gl_scanout_id;
|
||||
DisplayGLTextureBorrower gl_scanout_borrow;
|
||||
bool gl_scanout_y0_top;
|
||||
#endif
|
||||
} CocoaListener;
|
||||
|
||||
typedef struct {
|
||||
CocoaListener *active_listener;
|
||||
CocoaListener *listeners;
|
||||
size_t listeners_count;
|
||||
DisplaySurface *surface;
|
||||
QemuMutex draw_mutex;
|
||||
QKbdState *kbd;
|
||||
CGImageRef cursor_cgimage;
|
||||
int cursor_show;
|
||||
bool left_command_key_disabled;
|
||||
bool swap_opt_cmd;
|
||||
bool inited;
|
||||
} QEMUScreen;
|
||||
|
||||
typedef struct {
|
||||
QemuClipboardInfo *info;
|
||||
QemuEvent event;
|
||||
} QemuCocoaClipboard;
|
||||
|
||||
@interface QemuCocoaView : NSView
|
||||
{
|
||||
NSTextField *pauseLabel;
|
||||
NSTrackingArea *trackingArea;
|
||||
QEMUScreen *screen;
|
||||
int screen_width;
|
||||
int screen_height;
|
||||
BOOL isMouseGrabbed;
|
||||
BOOL isAbsoluteEnabled;
|
||||
CFMachPortRef eventsTap;
|
||||
}
|
||||
- (id)initWithFrame:(NSRect)frameRect
|
||||
screen:(QEMUScreen *)given_screen;
|
||||
- (void) frameUpdated;
|
||||
- (void) selectConsoleLocked:(unsigned int)index;
|
||||
- (NSSize) computeUnzoomedSize;
|
||||
- (NSSize) fixZoomedFullScreenSize:(NSSize)proposedSize;
|
||||
- (void) resizeWindow;
|
||||
- (void) updateUIInfo;
|
||||
- (void) updateScreenWidth:(int)w height:(int)h;
|
||||
- (void) grabMouse;
|
||||
- (void) ungrabMouse;
|
||||
- (void) setFullGrab:(id)sender;
|
||||
- (bool) handleEvent:(NSEvent *)event;
|
||||
- (void) setAbsoluteEnabled:(BOOL)tIsAbsoluteEnabled;
|
||||
/* The state surrounding mouse grabbing is potentially confusing.
|
||||
* isAbsoluteEnabled tracks qemu_input_is_absolute() [ie "is the emulated
|
||||
* pointing device an absolute-position one?"], but is only updated on
|
||||
* next refresh.
|
||||
* isMouseGrabbed tracks whether GUI events are directed to the guest;
|
||||
* it controls whether special keys like Cmd get sent to the guest,
|
||||
* and whether we capture the mouse when in non-absolute mode.
|
||||
*/
|
||||
- (BOOL) isMouseGrabbed;
|
||||
- (BOOL) isAbsoluteEnabled;
|
||||
- (void) setNeedsDisplayForCursorX:(int)x
|
||||
y:(int)y
|
||||
width:(int)width
|
||||
height:(int)height
|
||||
screenHeight:(int)screen_height;
|
||||
- (void)displayPause;
|
||||
- (void)removePause;
|
||||
@end
|
||||
|
||||
@interface QemuCocoaAppController : NSObject
|
||||
<NSWindowDelegate, NSApplicationDelegate>
|
||||
{
|
||||
QemuCocoaView *cocoaView;
|
||||
}
|
||||
- (id) initWithScreen:(QEMUScreen *)screen;
|
||||
- (QemuCocoaView *)cocoaView;
|
||||
@end
|
||||
|
||||
@interface QemuCocoaPasteboardTypeOwner : NSObject<NSPasteboardTypeOwner>
|
||||
{
|
||||
QemuCocoaClipboard *cb;
|
||||
}
|
||||
- (id) initWith:(QemuCocoaClipboard *)aCb;
|
||||
@end
|
||||
|
||||
void cocoa_listener_select(size_t index);
|
||||
|
||||
typedef void (^CodeBlock)(void);
|
||||
typedef bool (^BoolCodeBlock)(void);
|
||||
|
||||
#endif
|
||||
+11
-10
@@ -94,6 +94,7 @@ void hmp_mouse_set(Monitor *mon, const QDict *qdict);
|
||||
void kbd_put_keysym_console(QemuConsole *s, int keysym);
|
||||
bool kbd_put_qcode_console(QemuConsole *s, int qcode, bool ctrl);
|
||||
void kbd_put_string_console(QemuConsole *s, const char *str, int len);
|
||||
void kbd_put_keysym(int keysym);
|
||||
|
||||
/* consoles */
|
||||
|
||||
@@ -108,13 +109,11 @@ struct QemuConsoleClass {
|
||||
#define QEMU_ALLOCATED_FLAG 0x01
|
||||
#define QEMU_PLACEHOLDER_FLAG 0x02
|
||||
|
||||
typedef uint32_t (* DisplayGLTextureBorrower)(uint32_t id, bool *y_0_top,
|
||||
uint32_t *width,
|
||||
uint32_t *height);
|
||||
|
||||
typedef struct ScanoutTexture {
|
||||
uint32_t backing_id;
|
||||
DisplayGLTextureBorrower backing_borrow;
|
||||
bool backing_y_0_top;
|
||||
uint32_t backing_width;
|
||||
uint32_t backing_height;
|
||||
uint32_t x;
|
||||
uint32_t y;
|
||||
uint32_t width;
|
||||
@@ -129,7 +128,6 @@ typedef struct DisplaySurface {
|
||||
GLenum glformat;
|
||||
GLenum gltype;
|
||||
GLuint texture;
|
||||
bool glswapped;
|
||||
#endif
|
||||
} DisplaySurface;
|
||||
|
||||
@@ -250,7 +248,9 @@ typedef struct DisplayChangeListenerOps {
|
||||
/* required if GL */
|
||||
void (*dpy_gl_scanout_texture)(DisplayChangeListener *dcl,
|
||||
uint32_t backing_id,
|
||||
DisplayGLTextureBorrower backing_borrow,
|
||||
bool backing_y_0_top,
|
||||
uint32_t backing_width,
|
||||
uint32_t backing_height,
|
||||
uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h);
|
||||
/* optional (default to true if has dpy_gl_scanout_dmabuf) */
|
||||
@@ -353,8 +353,9 @@ bool dpy_gfx_check_format(QemuConsole *con,
|
||||
pixman_format_code_t format);
|
||||
|
||||
void dpy_gl_scanout_disable(QemuConsole *con);
|
||||
void dpy_gl_scanout_texture(QemuConsole *con, uint32_t backing_id,
|
||||
DisplayGLTextureBorrower backing_borrow,
|
||||
void dpy_gl_scanout_texture(QemuConsole *con,
|
||||
uint32_t backing_id, bool backing_y_0_top,
|
||||
uint32_t backing_width, uint32_t backing_height,
|
||||
uint32_t x, uint32_t y, uint32_t w, uint32_t h);
|
||||
void dpy_gl_scanout_dmabuf(QemuConsole *con,
|
||||
QemuDmaBuf *dmabuf);
|
||||
@@ -454,7 +455,6 @@ void qemu_console_early_init(void);
|
||||
|
||||
void qemu_console_set_display_gl_ctx(QemuConsole *con, DisplayGLCtx *ctx);
|
||||
|
||||
QemuConsole *qemu_console_lookup_first_graphic_console(void);
|
||||
QemuConsole *qemu_console_lookup_by_index(unsigned int index);
|
||||
QemuConsole *qemu_console_lookup_by_device(DeviceState *dev, uint32_t head);
|
||||
QemuConsole *qemu_console_lookup_by_device_name(const char *device_id,
|
||||
@@ -475,6 +475,7 @@ int qemu_console_get_window_id(QemuConsole *con);
|
||||
/* Set the low-level window id for the console */
|
||||
void qemu_console_set_window_id(QemuConsole *con, int window_id);
|
||||
|
||||
void console_select(unsigned int index);
|
||||
void qemu_console_resize(QemuConsole *con, int width, int height);
|
||||
DisplaySurface *qemu_console_surface(QemuConsole *con);
|
||||
|
||||
|
||||
@@ -6,9 +6,6 @@
|
||||
#ifdef CONFIG_GBM
|
||||
#include <gbm.h>
|
||||
#endif
|
||||
#ifdef CONFIG_ANGLE
|
||||
#include <EGL/eglext_angle.h>
|
||||
#endif
|
||||
#include "ui/console.h"
|
||||
#include "ui/shader.h"
|
||||
|
||||
@@ -20,7 +17,6 @@ typedef struct egl_fb {
|
||||
int width;
|
||||
int height;
|
||||
GLuint texture;
|
||||
GLenum texture_target;
|
||||
GLuint framebuffer;
|
||||
bool delete_texture;
|
||||
QemuDmaBuf *dmabuf;
|
||||
@@ -28,18 +24,15 @@ typedef struct egl_fb {
|
||||
|
||||
void egl_fb_destroy(egl_fb *fb);
|
||||
void egl_fb_setup_default(egl_fb *fb, int width, int height);
|
||||
void egl_fb_setup_for_tex_target(egl_fb *fb, int width, int height,
|
||||
GLuint texture, GLenum target, bool delete);
|
||||
void egl_fb_setup_for_tex(egl_fb *fb, int width, int height,
|
||||
GLuint texture, bool delete);
|
||||
void egl_fb_setup_new_tex_target(egl_fb *fb, int width, int height, GLenum target);
|
||||
void egl_fb_setup_new_tex(egl_fb *fb, int width, int height);
|
||||
void egl_fb_blit(egl_fb *dst, egl_fb *src, bool flip);
|
||||
void egl_fb_read(DisplaySurface *dst, egl_fb *src);
|
||||
|
||||
void egl_texture_blit(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip, bool swap);
|
||||
void egl_texture_blit(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip);
|
||||
void egl_texture_blend(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip,
|
||||
bool swap, int x, int y, double scale_x, double scale_y);
|
||||
int x, int y, double scale_x, double scale_y);
|
||||
|
||||
#ifdef CONFIG_GBM
|
||||
|
||||
@@ -58,13 +51,7 @@ void egl_dmabuf_create_fence(QemuDmaBuf *dmabuf);
|
||||
|
||||
#endif
|
||||
|
||||
EGLSurface qemu_egl_init_surface(EGLContext ectx, EGLNativeWindowType win);
|
||||
EGLSurface qemu_egl_init_buffer_surface(EGLContext ectx, EGLenum buftype,
|
||||
EGLClientBuffer buffer, const EGLint *attrib_list);
|
||||
bool qemu_egl_destroy_surface(EGLSurface surface);
|
||||
|
||||
int qemu_egl_init_dpy_cocoa(DisplayGLMode mode);
|
||||
int qemu_egl_init_dpy_surfaceless(DisplayGLMode mode);
|
||||
EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType win);
|
||||
|
||||
#if defined(CONFIG_X11) || defined(CONFIG_GBM)
|
||||
|
||||
@@ -73,12 +60,6 @@ int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, DisplayGLMode mode);
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ANGLE)
|
||||
|
||||
int qemu_egl_init_dpy_angle(DisplayGLMode mode);
|
||||
|
||||
#endif
|
||||
|
||||
EGLContext qemu_egl_init_ctx(void);
|
||||
bool qemu_egl_has_dmabuf(void);
|
||||
|
||||
|
||||
+6
-2
@@ -171,7 +171,9 @@ QEMUGLContext gd_egl_create_context(DisplayGLCtx *dgc,
|
||||
void gd_egl_scanout_disable(DisplayChangeListener *dcl);
|
||||
void gd_egl_scanout_texture(DisplayChangeListener *dcl,
|
||||
uint32_t backing_id,
|
||||
DisplayGLTextureBorrower backing_borrow,
|
||||
bool backing_y_0_top,
|
||||
uint32_t backing_width,
|
||||
uint32_t backing_height,
|
||||
uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h);
|
||||
void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl,
|
||||
@@ -205,7 +207,9 @@ void gd_gl_area_scanout_dmabuf(DisplayChangeListener *dcl,
|
||||
QemuDmaBuf *dmabuf);
|
||||
void gd_gl_area_scanout_texture(DisplayChangeListener *dcl,
|
||||
uint32_t backing_id,
|
||||
DisplayGLTextureBorrower backing_borrow,
|
||||
bool backing_y_0_top,
|
||||
uint32_t backing_width,
|
||||
uint32_t backing_height,
|
||||
uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h);
|
||||
void gd_gl_area_scanout_disable(DisplayChangeListener *dcl);
|
||||
|
||||
+5
-3
@@ -22,7 +22,7 @@
|
||||
#endif
|
||||
|
||||
#include "ui/kbd-state.h"
|
||||
#if defined(CONFIG_OPENGL)
|
||||
#ifdef CONFIG_OPENGL
|
||||
# include "ui/egl-helpers.h"
|
||||
#endif
|
||||
|
||||
@@ -44,7 +44,7 @@ struct sdl2_console {
|
||||
int ignore_hotkeys;
|
||||
SDL_GLContext winctx;
|
||||
QKbdState *kbd;
|
||||
#if defined(CONFIG_OPENGL)
|
||||
#ifdef CONFIG_OPENGL
|
||||
QemuGLShader *gls;
|
||||
egl_fb guest_fb;
|
||||
egl_fb win_fb;
|
||||
@@ -86,7 +86,9 @@ int sdl2_gl_make_context_current(DisplayGLCtx *dgc,
|
||||
void sdl2_gl_scanout_disable(DisplayChangeListener *dcl);
|
||||
void sdl2_gl_scanout_texture(DisplayChangeListener *dcl,
|
||||
uint32_t backing_id,
|
||||
DisplayGLTextureBorrower backing_borrow,
|
||||
bool backing_y_0_top,
|
||||
uint32_t backing_width,
|
||||
uint32_t backing_height,
|
||||
uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h);
|
||||
void sdl2_gl_scanout_flush(DisplayChangeListener *dcl,
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
typedef struct QemuGLShader QemuGLShader;
|
||||
|
||||
void qemu_gl_run_texture_blit(QemuGLShader *gls, bool flip, bool swapped);
|
||||
void qemu_gl_run_texture_blit(QemuGLShader *gls, bool flip);
|
||||
|
||||
QemuGLShader *qemu_gl_init_shader(void);
|
||||
void qemu_gl_fini_shader(QemuGLShader *gls);
|
||||
|
||||
@@ -27,12 +27,7 @@
|
||||
#include "ui/qemu-pixman.h"
|
||||
#include "ui/console.h"
|
||||
|
||||
#if defined(CONFIG_IOSURFACE)
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <IOSurface/IOSurfaceRef.h>
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_OPENGL)
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_GBM)
|
||||
# if SPICE_SERVER_VERSION >= 0x000d01 /* release 0.13.1 */
|
||||
# define HAVE_SPICE_GL 1
|
||||
# include "ui/egl-helpers.h"
|
||||
@@ -132,20 +127,8 @@ struct SimpleSpiceDisplay {
|
||||
bool have_scanout;
|
||||
bool have_surface;
|
||||
|
||||
#if defined(CONFIG_GBM)
|
||||
QemuDmaBuf *guest_dmabuf;
|
||||
bool guest_dmabuf_refresh;
|
||||
#endif
|
||||
#if defined(CONFIG_IOSURFACE)
|
||||
IOSurfaceRef iosurface;
|
||||
int surface_send_fd;
|
||||
#endif
|
||||
#if defined(CONFIG_ANGLE)
|
||||
EGLSurface esurface;
|
||||
egl_fb iosurface_fb;
|
||||
DisplayGLTextureBorrower backing_borrow;
|
||||
uint32_t backing_id;
|
||||
#endif
|
||||
bool render_cursor;
|
||||
|
||||
egl_fb guest_fb;
|
||||
|
||||
@@ -74,6 +74,9 @@ qio_channel_tls_new_server(QIOChannel *master,
|
||||
ioc = QIO_CHANNEL_TLS(object_new(TYPE_QIO_CHANNEL_TLS));
|
||||
|
||||
ioc->master = master;
|
||||
if (qio_channel_has_feature(master, QIO_CHANNEL_FEATURE_SHUTDOWN)) {
|
||||
qio_channel_set_feature(QIO_CHANNEL(ioc), QIO_CHANNEL_FEATURE_SHUTDOWN);
|
||||
}
|
||||
object_ref(OBJECT(master));
|
||||
|
||||
ioc->session = qcrypto_tls_session_new(
|
||||
|
||||
@@ -1622,7 +1622,7 @@ TargetFdTrans target_signalfd_trans = {
|
||||
.host_to_target_data = host_to_target_data_signalfd,
|
||||
};
|
||||
|
||||
static abi_long swap_data_eventfd(void *buf, size_t len)
|
||||
static abi_long swap_data_u64(void *buf, size_t len)
|
||||
{
|
||||
uint64_t *counter = buf;
|
||||
int i;
|
||||
@@ -1640,8 +1640,12 @@ static abi_long swap_data_eventfd(void *buf, size_t len)
|
||||
}
|
||||
|
||||
TargetFdTrans target_eventfd_trans = {
|
||||
.host_to_target_data = swap_data_eventfd,
|
||||
.target_to_host_data = swap_data_eventfd,
|
||||
.host_to_target_data = swap_data_u64,
|
||||
.target_to_host_data = swap_data_u64,
|
||||
};
|
||||
|
||||
TargetFdTrans target_timerfd_trans = {
|
||||
.host_to_target_data = swap_data_u64,
|
||||
};
|
||||
|
||||
#if defined(CONFIG_INOTIFY) && (defined(TARGET_NR_inotify_init) || \
|
||||
|
||||
@@ -130,6 +130,7 @@ extern TargetFdTrans target_netlink_route_trans;
|
||||
extern TargetFdTrans target_netlink_audit_trans;
|
||||
extern TargetFdTrans target_signalfd_trans;
|
||||
extern TargetFdTrans target_eventfd_trans;
|
||||
extern TargetFdTrans target_timerfd_trans;
|
||||
#if (defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)) || \
|
||||
(defined(CONFIG_INOTIFY1) && defined(TARGET_NR_inotify_init1) && \
|
||||
defined(__NR_inotify_init1))
|
||||
|
||||
@@ -12,8 +12,8 @@ struct target_rlimit {
|
||||
};
|
||||
|
||||
struct target_rlimit64 {
|
||||
uint64_t rlim_cur;
|
||||
uint64_t rlim_max;
|
||||
abi_ullong rlim_cur;
|
||||
abi_ullong rlim_max;
|
||||
};
|
||||
|
||||
#define TARGET_RLIM_INFINITY ((abi_ulong)-1)
|
||||
|
||||
+15
-6
@@ -1755,6 +1755,11 @@ static inline abi_long target_to_host_sockaddr(int fd, struct sockaddr *addr,
|
||||
lladdr = (struct target_sockaddr_ll *)addr;
|
||||
lladdr->sll_ifindex = tswap32(lladdr->sll_ifindex);
|
||||
lladdr->sll_hatype = tswap16(lladdr->sll_hatype);
|
||||
} else if (sa_family == AF_INET6) {
|
||||
struct sockaddr_in6 *in6addr;
|
||||
|
||||
in6addr = (struct sockaddr_in6 *)addr;
|
||||
in6addr->sin6_scope_id = tswap32(in6addr->sin6_scope_id);
|
||||
}
|
||||
unlock_user(target_saddr, target_addr, 0);
|
||||
|
||||
@@ -12883,8 +12888,8 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
|
||||
if (!lock_user_struct(VERIFY_READ, target_rnew, arg3, 1)) {
|
||||
return -TARGET_EFAULT;
|
||||
}
|
||||
rnew.rlim_cur = tswap64(target_rnew->rlim_cur);
|
||||
rnew.rlim_max = tswap64(target_rnew->rlim_max);
|
||||
__get_user(rnew.rlim_cur, &target_rnew->rlim_cur);
|
||||
__get_user(rnew.rlim_max, &target_rnew->rlim_max);
|
||||
unlock_user_struct(target_rnew, arg3, 0);
|
||||
rnewp = &rnew;
|
||||
}
|
||||
@@ -12894,8 +12899,8 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
|
||||
if (!lock_user_struct(VERIFY_WRITE, target_rold, arg4, 1)) {
|
||||
return -TARGET_EFAULT;
|
||||
}
|
||||
target_rold->rlim_cur = tswap64(rold.rlim_cur);
|
||||
target_rold->rlim_max = tswap64(rold.rlim_max);
|
||||
__put_user(rold.rlim_cur, &target_rold->rlim_cur);
|
||||
__put_user(rold.rlim_max, &target_rold->rlim_max);
|
||||
unlock_user_struct(target_rold, arg4, 1);
|
||||
}
|
||||
return ret;
|
||||
@@ -13115,8 +13120,12 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
|
||||
|
||||
#if defined(TARGET_NR_timerfd_create) && defined(CONFIG_TIMERFD)
|
||||
case TARGET_NR_timerfd_create:
|
||||
return get_errno(timerfd_create(arg1,
|
||||
target_to_host_bitmask(arg2, fcntl_flags_tbl)));
|
||||
ret = get_errno(timerfd_create(arg1,
|
||||
target_to_host_bitmask(arg2, fcntl_flags_tbl)));
|
||||
if (ret >= 0) {
|
||||
fd_trans_register(ret, &target_timerfd_trans);
|
||||
}
|
||||
return ret;
|
||||
#endif
|
||||
|
||||
#if defined(TARGET_NR_timerfd_gettime) && defined(CONFIG_TIMERFD)
|
||||
|
||||
+8
-79
@@ -50,7 +50,6 @@ bsd_oses = ['gnu/kfreebsd', 'freebsd', 'netbsd', 'openbsd', 'dragonfly', 'darwin
|
||||
supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux']
|
||||
supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv', 'x86', 'x86_64',
|
||||
'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc64']
|
||||
tcti_supported_cpus = ['aarch64']
|
||||
|
||||
cpu = host_machine.cpu_family()
|
||||
|
||||
@@ -382,7 +381,6 @@ socket = []
|
||||
version_res = []
|
||||
coref = []
|
||||
iokit = []
|
||||
iosurface = not_found
|
||||
emulator_link_args = []
|
||||
nvmm =not_found
|
||||
hvf = not_found
|
||||
@@ -405,7 +403,6 @@ if targetos == 'windows'
|
||||
elif targetos == 'darwin'
|
||||
coref = dependency('appleframeworks', modules: 'CoreFoundation')
|
||||
iokit = dependency('appleframeworks', modules: 'IOKit', required: false)
|
||||
iosurface = dependency('appleframeworks', modules: 'IOSurface', required: false)
|
||||
host_dsosuf = '.dylib'
|
||||
elif targetos == 'sunos'
|
||||
socket = [cc.find_library('socket'),
|
||||
@@ -440,7 +437,6 @@ if get_option('hvf').allowed()
|
||||
required: get_option('hvf'))
|
||||
if hvf.found()
|
||||
accelerators += 'CONFIG_HVF'
|
||||
config_host_data.set('CONFIG_HVF_PRIVATE', get_option('hvf_private'))
|
||||
endif
|
||||
endif
|
||||
if get_option('hax').allowed()
|
||||
@@ -473,24 +469,6 @@ if get_option('tcg').allowed()
|
||||
endif
|
||||
if get_option('tcg_interpreter')
|
||||
tcg_arch = 'tci'
|
||||
elif get_option('tcg_threaded_interpreter')
|
||||
if cpu not in tcti_supported_cpus
|
||||
error('Unsupported CPU @0@ for TCTI, try --enable-tcg-interpreter'.format(cpu))
|
||||
else
|
||||
warning('TCTI is extremely experimental and incomplete! Things might break!')
|
||||
tcg_arch = '@0@-tcti'.format(cpu)
|
||||
endif
|
||||
|
||||
# Tell our compiler how to generate our TCTI gadgets.
|
||||
gadget_generator = 'tcg/@0@/tcti-gadget-gen.py'.format(tcg_arch)
|
||||
tcti_gadgets = custom_target('tcti-gadgets.c.inc',
|
||||
output: 'tcti-gadgets.c.inc',
|
||||
input: gadget_generator,
|
||||
command: [find_program(gadget_generator), '@OUTPUT@'],
|
||||
build_by_default: true,
|
||||
build_always_stale: false)
|
||||
|
||||
genh += tcti_gadgets
|
||||
elif host_arch == 'x86_64'
|
||||
tcg_arch = 'i386'
|
||||
elif host_arch == 'ppc64'
|
||||
@@ -1936,7 +1914,6 @@ config_host_data.set('CONFIG_SPICE', spice.found())
|
||||
config_host_data.set('CONFIG_X11', x11.found())
|
||||
config_host_data.set('CONFIG_DBUS_DISPLAY', dbus_display)
|
||||
config_host_data.set('CONFIG_CFI', get_option('cfi'))
|
||||
config_host_data.set('CONFIG_IOSURFACE', iosurface.found())
|
||||
config_host_data.set('CONFIG_SELINUX', selinux.found())
|
||||
config_host_data.set('CONFIG_XEN_BACKEND', xen.found())
|
||||
if xen.found()
|
||||
@@ -1978,7 +1955,6 @@ config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h'))
|
||||
config_host_data.set('HAVE_SYS_DISK_H', cc.has_header('sys/disk.h'))
|
||||
config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h'))
|
||||
config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h'))
|
||||
config_host_data.set('CONFIG_ANGLE', cc.has_header('EGL/eglext_angle.h'))
|
||||
if targetos == 'windows'
|
||||
config_host_data.set('HAVE_AFUNIX_H', cc.has_header('afunix.h'))
|
||||
endif
|
||||
@@ -2571,8 +2547,6 @@ foreach target : target_dirs
|
||||
config_all += { sym: 'y' }
|
||||
if sym == 'CONFIG_TCG' and tcg_arch == 'tci'
|
||||
config_target += { 'CONFIG_TCG_INTERPRETER': 'y' }
|
||||
elif sym == 'CONFIG_TCG' and tcg_arch.endswith('tcti')
|
||||
config_target += { 'CONFIG_TCG_THREADED_INTERPRETER': 'y' }
|
||||
endif
|
||||
if target in modular_tcg
|
||||
config_target += { 'CONFIG_TCG_MODULAR': 'y' }
|
||||
@@ -2792,18 +2766,9 @@ if not fdt.found() and fdt_required.length() > 0
|
||||
error('fdt not available but required by targets ' + ', '.join(fdt_required))
|
||||
endif
|
||||
|
||||
ucontext = dependency('libucontext', kwargs: static_kwargs, required : false)
|
||||
if not ucontext.found() and get_option('ucontext').enabled()
|
||||
libucontext_proj = subproject('libucontext',
|
||||
default_options: ['default_library=static',
|
||||
'freestanding=true'])
|
||||
ucontext = libucontext_proj.get_variable('libucontext_dep')
|
||||
endif
|
||||
|
||||
config_host_data.set('CONFIG_CAPSTONE', capstone.found())
|
||||
config_host_data.set('CONFIG_FDT', fdt.found())
|
||||
config_host_data.set('CONFIG_SLIRP', slirp.found())
|
||||
config_host_data.set('CONFIG_LIBUCONTEXT', ucontext.found())
|
||||
|
||||
#####################
|
||||
# Generated sources #
|
||||
@@ -2812,7 +2777,7 @@ config_host_data.set('CONFIG_LIBUCONTEXT', ucontext.found())
|
||||
genh += configure_file(output: 'config-host.h', configuration: config_host_data)
|
||||
|
||||
hxtool = find_program('scripts/hxtool')
|
||||
shaderinclude = find_program('scripts/shaderinclude.pl')
|
||||
shaderinclude = find_program('scripts/shaderinclude.py')
|
||||
qapi_gen = find_program('scripts/qapi-gen.py')
|
||||
qapi_gen_depends = [ meson.current_source_dir() / 'scripts/qapi/__init__.py',
|
||||
meson.current_source_dir() / 'scripts/qapi/commands.py',
|
||||
@@ -3084,7 +3049,7 @@ util_ss.add_all(trace_ss)
|
||||
util_ss = util_ss.apply(config_all, strict: false)
|
||||
libqemuutil = static_library('qemuutil',
|
||||
sources: util_ss.sources() + stub_ss.sources() + genh,
|
||||
dependencies: [util_ss.dependencies(), libm, threads, glib, socket, malloc, pixman, ucontext])
|
||||
dependencies: [util_ss.dependencies(), libm, threads, glib, socket, malloc, pixman])
|
||||
qemuutil = declare_dependency(link_with: libqemuutil,
|
||||
sources: genh + version_res,
|
||||
dependencies: [event_loop_base])
|
||||
@@ -3497,32 +3462,14 @@ foreach target : target_dirs
|
||||
arch_srcs += target_specific.sources()
|
||||
arch_deps += target_specific.dependencies()
|
||||
|
||||
if config_all.has_key('CONFIG_SHARED_LIBRARY_BUILD')
|
||||
build_lib_args = {
|
||||
'target_type': 'shared_library',
|
||||
'install': true,
|
||||
'dependencies': arch_deps + deps,
|
||||
'link_language': link_language,
|
||||
'link_depends': [block_syms, qemu_syms],
|
||||
'link_args': link_args + cc.get_supported_link_arguments(['-Wl,-U,_qemu_main']),
|
||||
'gnu_symbol_visibility': 'default'
|
||||
}
|
||||
else
|
||||
build_lib_args = {
|
||||
'target_type': 'static_library',
|
||||
'install': false,
|
||||
'dependencies': arch_deps,
|
||||
'name_suffix': 'fa'
|
||||
}
|
||||
endif
|
||||
|
||||
lib = build_target('qemu-' + target,
|
||||
lib = static_library('qemu-' + target,
|
||||
sources: arch_srcs + genh,
|
||||
dependencies: arch_deps,
|
||||
objects: objects,
|
||||
include_directories: target_inc,
|
||||
c_args: c_args,
|
||||
build_by_default: false,
|
||||
kwargs: build_lib_args)
|
||||
name_suffix: 'fa')
|
||||
|
||||
if target.endswith('-softmmu')
|
||||
execs = [{
|
||||
@@ -3556,17 +3503,6 @@ foreach target : target_dirs
|
||||
'dependencies': []
|
||||
}]
|
||||
endif
|
||||
if config_all.has_key('CONFIG_SHARED_LIBRARY_BUILD')
|
||||
build_exe_args = {
|
||||
'link_with': lib,
|
||||
'link_args': link_args + cc.get_supported_link_arguments(['-Wl,--exclude-libs,ALL'])
|
||||
}
|
||||
else
|
||||
build_exe_args = {
|
||||
'objects': lib.extract_all_objects(recursive: true),
|
||||
'link_args': link_args
|
||||
}
|
||||
endif
|
||||
foreach exe: execs
|
||||
exe_name = exe['name']
|
||||
if targetos == 'darwin'
|
||||
@@ -3577,10 +3513,11 @@ foreach target : target_dirs
|
||||
install: true,
|
||||
c_args: c_args,
|
||||
dependencies: arch_deps + deps + exe['dependencies'],
|
||||
objects: lib.extract_all_objects(recursive: true),
|
||||
link_language: link_language,
|
||||
link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []),
|
||||
win_subsystem: exe['win_subsystem'],
|
||||
kwargs: build_exe_args)
|
||||
link_args: link_args,
|
||||
win_subsystem: exe['win_subsystem'])
|
||||
|
||||
if targetos == 'darwin'
|
||||
icon = 'pc-bios/qemu.rsrc'
|
||||
@@ -3651,10 +3588,6 @@ if xkbcommon.found()
|
||||
endif
|
||||
|
||||
if have_tools
|
||||
if config_all.has_key('CONFIG_SHARED_LIBRARY_BUILD')
|
||||
qemu_img_lib = shared_library('qemu-img', [files('qemu-img.c'), hxdep],
|
||||
dependencies: [authz, block, crypto, io, qom, qemuutil], install: true)
|
||||
endif
|
||||
qemu_img = executable('qemu-img', [files('qemu-img.c'), hxdep],
|
||||
dependencies: [authz, block, crypto, io, qom, qemuutil], install: true)
|
||||
qemu_io = executable('qemu-io', files('qemu-io.c'),
|
||||
@@ -3756,7 +3689,6 @@ endif
|
||||
summary_info += {'Doc directory': get_option('prefix') / get_option('docdir')}
|
||||
summary_info += {'Build directory': meson.current_build_dir()}
|
||||
summary_info += {'Source path': meson.current_source_dir()}
|
||||
summary_info += {'build shared lib': config_all.has_key('CONFIG_SHARED_LIBRARY_BUILD')}
|
||||
summary_info += {'GIT submodules': config_host['GIT_SUBMODULES']}
|
||||
summary(summary_info, bool_yn: true, section: 'Directories')
|
||||
|
||||
@@ -3901,8 +3833,6 @@ summary_info += {'TCG support': config_all.has_key('CONFIG_TCG')}
|
||||
if config_all.has_key('CONFIG_TCG')
|
||||
if get_option('tcg_interpreter')
|
||||
summary_info += {'TCG backend': 'TCI (TCG with bytecode interpreter, slow)'}
|
||||
elif get_option('tcg_threaded_interpreter')
|
||||
summary_info += {'TCG backend': 'TCTI (TCG with threaded-dispatch bytecode interpreter, experimental and slow; but faster than TCI)'}
|
||||
else
|
||||
summary_info += {'TCG backend': 'native (@0@)'.format(cpu)}
|
||||
endif
|
||||
@@ -3919,7 +3849,6 @@ summary(summary_info, bool_yn: true, section: 'Targets and accelerators')
|
||||
|
||||
# Block layer
|
||||
summary_info = {}
|
||||
summary_info += {'libucontext support': ucontext.found()}
|
||||
summary_info += {'coroutine backend': config_host['CONFIG_COROUTINE_BACKEND']}
|
||||
summary_info += {'coroutine pool': have_coroutine_pool}
|
||||
if have_block
|
||||
|
||||
@@ -72,8 +72,6 @@ option('whpx', type: 'feature', value: 'auto',
|
||||
description: 'WHPX acceleration support')
|
||||
option('hvf', type: 'feature', value: 'auto',
|
||||
description: 'HVF acceleration support')
|
||||
option('hvf_private', type: 'boolean', value: 'false',
|
||||
description: 'HVF private features (entitlements required)')
|
||||
option('nvmm', type: 'feature', value: 'auto',
|
||||
description: 'NVMM acceleration support')
|
||||
option('xen', type: 'feature', value: 'auto',
|
||||
@@ -84,8 +82,6 @@ option('tcg', type: 'feature', value: 'enabled',
|
||||
description: 'TCG support')
|
||||
option('tcg_interpreter', type: 'boolean', value: false,
|
||||
description: 'TCG with bytecode interpreter (slow)')
|
||||
option('tcg_threaded_interpreter', type: 'boolean', value: false,
|
||||
description: 'TCG with threaded-dispatch bytecode interpreter (experimental and slow, but less slow than TCI)')
|
||||
option('cfi', type: 'boolean', value: false,
|
||||
description: 'Control-Flow Integrity (CFI)')
|
||||
option('cfi_debug', type: 'boolean', value: false,
|
||||
@@ -238,8 +234,6 @@ option('fuse', type: 'feature', value: 'auto',
|
||||
description: 'FUSE block device export')
|
||||
option('fuse_lseek', type : 'feature', value : 'auto',
|
||||
description: 'SEEK_HOLE/SEEK_DATA support for FUSE exports')
|
||||
option('ucontext', type : 'feature', value : 'disabled',
|
||||
description: 'libucontext support')
|
||||
|
||||
option('trace_backends', type: 'array', value: ['log'],
|
||||
choices: ['dtrace', 'ftrace', 'log', 'nop', 'simple', 'syslog', 'ust'],
|
||||
|
||||
+6
-3
@@ -1765,13 +1765,15 @@ out:
|
||||
static inline void populate_read_range(RAMBlock *block, ram_addr_t offset,
|
||||
ram_addr_t size)
|
||||
{
|
||||
const ram_addr_t end = offset + size;
|
||||
|
||||
/*
|
||||
* We read one byte of each page; this will preallocate page tables if
|
||||
* required and populate the shared zeropage on MAP_PRIVATE anonymous memory
|
||||
* where no page was populated yet. This might require adaption when
|
||||
* supporting other mappings, like shmem.
|
||||
*/
|
||||
for (; offset < size; offset += block->page_size) {
|
||||
for (; offset < end; offset += block->page_size) {
|
||||
char tmp = *((char *)block->host + offset);
|
||||
|
||||
/* Don't optimize the read out */
|
||||
@@ -1885,13 +1887,14 @@ int ram_write_tracking_start(void)
|
||||
block->max_length, UFFDIO_REGISTER_MODE_WP, NULL)) {
|
||||
goto fail;
|
||||
}
|
||||
block->flags |= RAM_UF_WRITEPROTECT;
|
||||
memory_region_ref(block->mr);
|
||||
|
||||
/* Apply UFFD write protection to the block memory range */
|
||||
if (uffd_change_protection(rs->uffdio_fd, block->host,
|
||||
block->max_length, true, false)) {
|
||||
goto fail;
|
||||
}
|
||||
block->flags |= RAM_UF_WRITEPROTECT;
|
||||
memory_region_ref(block->mr);
|
||||
|
||||
trace_ram_write_tracking_ramblock_start(block->idstr, block->page_size,
|
||||
block->host, block->max_length);
|
||||
|
||||
+14
-15
@@ -88,16 +88,15 @@ static bool validate_options(const Netdev *netdev, Error **errp)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (__builtin_available(macOS 11, *)) {
|
||||
// clang requires a true branch
|
||||
} else {
|
||||
if (options->has_isolated) {
|
||||
error_setg(errp,
|
||||
"vmnet-bridged.isolated feature is "
|
||||
"unavailable: outdated vmnet.framework API");
|
||||
return false;
|
||||
}
|
||||
#if !defined(MAC_OS_VERSION_11_0) || \
|
||||
MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_11_0
|
||||
if (options->has_isolated) {
|
||||
error_setg(errp,
|
||||
"vmnet-bridged.isolated feature is "
|
||||
"unavailable: outdated vmnet.framework API");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -116,12 +115,12 @@ static xpc_object_t build_if_desc(const Netdev *netdev)
|
||||
vmnet_shared_interface_name_key,
|
||||
options->ifname);
|
||||
|
||||
if (__builtin_available(macOS 11, *)) {
|
||||
xpc_dictionary_set_bool(if_desc,
|
||||
vmnet_enable_isolation_key,
|
||||
options->isolated);
|
||||
}
|
||||
|
||||
#if defined(MAC_OS_VERSION_11_0) && \
|
||||
MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_11_0
|
||||
xpc_dictionary_set_bool(if_desc,
|
||||
vmnet_enable_isolation_key,
|
||||
options->isolated);
|
||||
#endif
|
||||
return if_desc;
|
||||
}
|
||||
|
||||
|
||||
+13
-35
@@ -17,7 +17,6 @@
|
||||
#include "clients.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "qapi/error.h"
|
||||
#include "sysemu/runstate.h"
|
||||
|
||||
#include <vmnet/vmnet.h>
|
||||
#include <dispatch/dispatch.h>
|
||||
@@ -243,35 +242,6 @@ static void vmnet_bufs_init(VmnetState *s)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on state change to un-register/re-register handlers
|
||||
*/
|
||||
static void vmnet_vm_state_change_cb(void *opaque, bool running, RunState state)
|
||||
{
|
||||
VmnetState *s = opaque;
|
||||
|
||||
if (running) {
|
||||
vmnet_interface_set_event_callback(
|
||||
s->vmnet_if,
|
||||
VMNET_INTERFACE_PACKETS_AVAILABLE,
|
||||
s->if_queue,
|
||||
^(interface_event_t event_id, xpc_object_t event) {
|
||||
assert(event_id == VMNET_INTERFACE_PACKETS_AVAILABLE);
|
||||
/*
|
||||
* This function is being called from a non qemu thread, so
|
||||
* we only schedule a BH, and do the rest of the io completion
|
||||
* handling from vmnet_send_bh() which runs in a qemu context.
|
||||
*/
|
||||
qemu_bh_schedule(s->send_bh);
|
||||
});
|
||||
} else {
|
||||
vmnet_interface_set_event_callback(
|
||||
s->vmnet_if,
|
||||
VMNET_INTERFACE_PACKETS_AVAILABLE,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
int vmnet_if_create(NetClientState *nc,
|
||||
xpc_object_t if_desc,
|
||||
@@ -359,9 +329,19 @@ int vmnet_if_create(NetClientState *nc,
|
||||
s->packets_send_current_pos = 0;
|
||||
s->packets_send_end_pos = 0;
|
||||
|
||||
vmnet_vm_state_change_cb(s, 1, RUN_STATE_RUNNING);
|
||||
|
||||
s->change = qemu_add_vm_change_state_handler(vmnet_vm_state_change_cb, s);
|
||||
vmnet_interface_set_event_callback(
|
||||
s->vmnet_if,
|
||||
VMNET_INTERFACE_PACKETS_AVAILABLE,
|
||||
s->if_queue,
|
||||
^(interface_event_t event_id, xpc_object_t event) {
|
||||
assert(event_id == VMNET_INTERFACE_PACKETS_AVAILABLE);
|
||||
/*
|
||||
* This function is being called from a non qemu thread, so
|
||||
* we only schedule a BH, and do the rest of the io completion
|
||||
* handling from vmnet_send_bh() which runs in a qemu context.
|
||||
*/
|
||||
qemu_bh_schedule(s->send_bh);
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -376,8 +356,6 @@ void vmnet_cleanup_common(NetClientState *nc)
|
||||
return;
|
||||
}
|
||||
|
||||
vmnet_vm_state_change_cb(s, 0, RUN_STATE_SHUTDOWN);
|
||||
qemu_del_vm_change_state_handler(s->change);
|
||||
if_stopped_sem = dispatch_semaphore_create(0);
|
||||
vmnet_stop_interface(
|
||||
s->vmnet_if,
|
||||
|
||||
+35
-31
@@ -22,28 +22,30 @@ static bool validate_options(const Netdev *netdev, Error **errp)
|
||||
{
|
||||
const NetdevVmnetHostOptions *options = &(netdev->u.vmnet_host);
|
||||
|
||||
if (__builtin_available(macOS 11, *)) {
|
||||
QemuUUID net_uuid;
|
||||
if (options->has_net_uuid &&
|
||||
qemu_uuid_parse(options->net_uuid, &net_uuid) < 0) {
|
||||
error_setg(errp, "Invalid UUID provided in 'net-uuid'");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (options->has_isolated) {
|
||||
error_setg(errp,
|
||||
"vmnet-host.isolated feature is "
|
||||
"unavailable: outdated vmnet.framework API");
|
||||
return false;
|
||||
}
|
||||
#if defined(MAC_OS_VERSION_11_0) && \
|
||||
MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_11_0
|
||||
|
||||
if (options->has_net_uuid) {
|
||||
error_setg(errp,
|
||||
"vmnet-host.net-uuid feature is "
|
||||
"unavailable: outdated vmnet.framework API");
|
||||
return false;
|
||||
}
|
||||
QemuUUID net_uuid;
|
||||
if (options->has_net_uuid &&
|
||||
qemu_uuid_parse(options->net_uuid, &net_uuid) < 0) {
|
||||
error_setg(errp, "Invalid UUID provided in 'net-uuid'");
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
if (options->has_isolated) {
|
||||
error_setg(errp,
|
||||
"vmnet-host.isolated feature is "
|
||||
"unavailable: outdated vmnet.framework API");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (options->has_net_uuid) {
|
||||
error_setg(errp,
|
||||
"vmnet-host.net-uuid feature is "
|
||||
"unavailable: outdated vmnet.framework API");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((options->has_start_address ||
|
||||
options->has_end_address ||
|
||||
@@ -69,19 +71,21 @@ static xpc_object_t build_if_desc(const Netdev *netdev)
|
||||
vmnet_operation_mode_key,
|
||||
VMNET_HOST_MODE);
|
||||
|
||||
if (__builtin_available(macOS 11, *)) {
|
||||
xpc_dictionary_set_bool(if_desc,
|
||||
vmnet_enable_isolation_key,
|
||||
options->isolated);
|
||||
#if defined(MAC_OS_VERSION_11_0) && \
|
||||
MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_11_0
|
||||
|
||||
QemuUUID net_uuid;
|
||||
if (options->has_net_uuid) {
|
||||
qemu_uuid_parse(options->net_uuid, &net_uuid);
|
||||
xpc_dictionary_set_uuid(if_desc,
|
||||
vmnet_network_identifier_key,
|
||||
net_uuid.data);
|
||||
}
|
||||
xpc_dictionary_set_bool(if_desc,
|
||||
vmnet_enable_isolation_key,
|
||||
options->isolated);
|
||||
|
||||
QemuUUID net_uuid;
|
||||
if (options->has_net_uuid) {
|
||||
qemu_uuid_parse(options->net_uuid, &net_uuid);
|
||||
xpc_dictionary_set_uuid(if_desc,
|
||||
vmnet_network_identifier_key,
|
||||
net_uuid.data);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (options->has_start_address) {
|
||||
xpc_dictionary_set_string(if_desc,
|
||||
|
||||
+16
-16
@@ -21,16 +21,15 @@ static bool validate_options(const Netdev *netdev, Error **errp)
|
||||
{
|
||||
const NetdevVmnetSharedOptions *options = &(netdev->u.vmnet_shared);
|
||||
|
||||
if (__builtin_available(macOS 11, *)) {
|
||||
// clang requires a true branch
|
||||
} else {
|
||||
if (options->has_isolated) {
|
||||
error_setg(errp,
|
||||
"vmnet-shared.isolated feature is "
|
||||
"unavailable: outdated vmnet.framework API");
|
||||
return false;
|
||||
}
|
||||
#if !defined(MAC_OS_VERSION_11_0) || \
|
||||
MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_11_0
|
||||
if (options->has_isolated) {
|
||||
error_setg(errp,
|
||||
"vmnet-shared.isolated feature is "
|
||||
"unavailable: outdated vmnet.framework API");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((options->has_start_address ||
|
||||
options->has_end_address ||
|
||||
@@ -77,13 +76,14 @@ static xpc_object_t build_if_desc(const Netdev *netdev)
|
||||
options->subnet_mask);
|
||||
}
|
||||
|
||||
if (__builtin_available(macOS 11, *)) {
|
||||
xpc_dictionary_set_bool(
|
||||
if_desc,
|
||||
vmnet_enable_isolation_key,
|
||||
options->isolated
|
||||
);
|
||||
}
|
||||
#if defined(MAC_OS_VERSION_11_0) && \
|
||||
MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_11_0
|
||||
xpc_dictionary_set_bool(
|
||||
if_desc,
|
||||
vmnet_enable_isolation_key,
|
||||
options->isolated
|
||||
);
|
||||
#endif
|
||||
|
||||
return if_desc;
|
||||
}
|
||||
|
||||
@@ -46,8 +46,6 @@ typedef struct VmnetState {
|
||||
int packets_send_end_pos;
|
||||
|
||||
struct iovec iov_buf[VMNET_PACKETS_LIMIT];
|
||||
|
||||
VMChangeStateEntry *change;
|
||||
} VmnetState;
|
||||
|
||||
const char *vmnet_status_map_str(vmnet_return_t status);
|
||||
|
||||
Loaded 100 of 177 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user