mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-01-09 22:36:29 +00:00
server/red_memslots: don't assume 64 bit environment
assumption that unsigned long == QXLPHYSICAL causes get_virt to compute the wrong slot. Fix by replacing addr variables to be of type QXLPHYSICAL.
This commit is contained in:
parent
07f55e49f5
commit
aef7eaf9bb
@ -19,10 +19,12 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "red_common.h"
|
||||
#include "red_memslots.h"
|
||||
|
||||
static unsigned long __get_clean_virt(RedMemSlotInfo *info, unsigned long addr)
|
||||
static unsigned long __get_clean_virt(RedMemSlotInfo *info, QXLPHYSICAL addr)
|
||||
{
|
||||
return addr & info->memslot_clean_virt_mask;
|
||||
}
|
||||
@ -46,7 +48,7 @@ static void print_memslots(RedMemSlotInfo *info)
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long get_virt_delta(RedMemSlotInfo *info, unsigned long addr, int group_id)
|
||||
unsigned long get_virt_delta(RedMemSlotInfo *info, QXLPHYSICAL addr, int group_id)
|
||||
{
|
||||
MemSlot *slot;
|
||||
int slot_id;
|
||||
@ -107,7 +109,7 @@ unsigned long get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t add_size
|
||||
slot_id = get_memslot_id(info, addr);
|
||||
if (slot_id > info->num_memslots) {
|
||||
print_memslots(info);
|
||||
PANIC("slot_id too big, addr=%lx", addr);
|
||||
PANIC("slot_id too big, addr=%" PRIx64, addr);
|
||||
}
|
||||
|
||||
slot = &info->mem_slots[group_id][slot_id];
|
||||
@ -165,10 +167,11 @@ void red_memslot_info_init(RedMemSlotInfo *info,
|
||||
info->mem_slots[i] = spice_new0(MemSlot, num_slots);
|
||||
}
|
||||
|
||||
/* TODO: use QXLPHYSICAL_BITS */
|
||||
info->memslot_id_shift = 64 - info->mem_slot_bits;
|
||||
info->memslot_gen_shift = 64 - (info->mem_slot_bits + info->generation_bits);
|
||||
info->memslot_gen_mask = ~((unsigned long)-1 << info->generation_bits);
|
||||
info->memslot_clean_virt_mask = (((unsigned long)(-1)) >>
|
||||
info->memslot_gen_mask = ~((QXLPHYSICAL)-1 << info->generation_bits);
|
||||
info->memslot_clean_virt_mask = (((QXLPHYSICAL)(-1)) >>
|
||||
(info->mem_slot_bits + info->generation_bits));
|
||||
}
|
||||
|
||||
|
||||
@ -53,10 +53,10 @@ static inline int get_generation(RedMemSlotInfo *info, uint64_t addr)
|
||||
return (addr >> info->memslot_gen_shift) & info->memslot_gen_mask;
|
||||
}
|
||||
|
||||
unsigned long get_virt_delta(RedMemSlotInfo *info, unsigned long addr, int group_id);
|
||||
unsigned long get_virt_delta(RedMemSlotInfo *info, QXLPHYSICAL addr, int group_id);
|
||||
void validate_virt(RedMemSlotInfo *info, unsigned long virt, int slot_id,
|
||||
uint32_t add_size, uint32_t group_id);
|
||||
unsigned long get_virt(RedMemSlotInfo *info, unsigned long addr, uint32_t add_size,
|
||||
unsigned long get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t add_size,
|
||||
int group_id);
|
||||
|
||||
void *validate_chunk (RedMemSlotInfo *info, QXLPHYSICAL data, uint32_t group_id, uint32_t *data_size_out, QXLPHYSICAL *next_out);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user