Example #1
0
static void red_record_surface_cmd(FILE *fd, RedMemSlotInfo *slots, int group_id,
                            QXLPHYSICAL addr)
{
    QXLSurfaceCmd *qxl;
    size_t size;
    int error;

    qxl = (QXLSurfaceCmd *)get_virt(slots, addr, sizeof(*qxl), group_id,
                                    &error);

    fprintf(fd, "surface_cmd\n");
    fprintf(fd, "surface_id %d\n", qxl->surface_id);
    fprintf(fd, "type %d\n", qxl->type);
    fprintf(fd, "flags %d\n", qxl->flags);

    switch (qxl->type) {
    case QXL_SURFACE_CMD_CREATE:
        fprintf(fd, "u.surface_create.format %d\n", qxl->u.surface_create.format);
        fprintf(fd, "u.surface_create.width %d\n", qxl->u.surface_create.width);
        fprintf(fd, "u.surface_create.height %d\n", qxl->u.surface_create.height);
        fprintf(fd, "u.surface_create.stride %d\n", qxl->u.surface_create.stride);
        size = qxl->u.surface_create.height * abs(qxl->u.surface_create.stride);
        if ((qxl->flags & QXL_SURF_FLAG_KEEP_DATA) != 0) {
            write_binary(fd, "data", size,
                (uint8_t*)get_virt(slots, qxl->u.surface_create.data, size, group_id,
                                   &error));
        }
        break;
    }
}
Example #2
0
static size_t red_record_data_chunks_ptr(FILE *fd, const char *prefix,
                                         RedMemSlotInfo *slots, int group_id,
                                         int memslot_id, QXLDataChunk *qxl)
{
    size_t data_size = qxl->data_size;
    int count_chunks = 0;
    QXLDataChunk *cur = qxl;
    int error;

    while (cur->next_chunk) {
        cur =
            (QXLDataChunk*)get_virt(slots, cur->next_chunk, sizeof(*cur), group_id,
                                    &error);
        data_size += cur->data_size;
        count_chunks++;
    }
    fprintf(fd, "data_chunks %d %ld\n", count_chunks, data_size);
    validate_virt(slots, (intptr_t)qxl->data, memslot_id, qxl->data_size, group_id);
    write_binary(fd, prefix, qxl->data_size, qxl->data);

    while (qxl->next_chunk) {
        memslot_id = get_memslot_id(slots, qxl->next_chunk);
        qxl = (QXLDataChunk*)get_virt(slots, qxl->next_chunk, sizeof(*qxl), group_id,
                                      &error);

        validate_virt(slots, (intptr_t)qxl->data, memslot_id, qxl->data_size, group_id);
        write_binary(fd, prefix, qxl->data_size, qxl->data);
    }

    return data_size;
}
Example #3
0
void red_record_cursor_cmd(FILE *fd, RedMemSlotInfo *slots, int group_id,
                           QXLPHYSICAL addr)
{
    QXLCursorCmd *qxl;
    int error;

    qxl = (QXLCursorCmd *)get_virt(slots, addr, sizeof(*qxl), group_id,
                                   &error);

    fprintf(fd, "cursor_cmd\n");
    fprintf(fd, "type %d\n", qxl->type);
    switch (qxl->type) {
    case QXL_CURSOR_SET:
        red_record_point16_ptr(fd, &qxl->u.set.position);
        fprintf(fd, "u.set.visible %d\n", qxl->u.set.visible);
        red_record_cursor(fd, slots, group_id, qxl->u.set.shape);
        break;
    case QXL_CURSOR_MOVE:
        red_record_point16_ptr(fd, &qxl->u.position);
        break;
    case QXL_CURSOR_TRAIL:
        fprintf(fd, "u.trail.length %d\n", qxl->u.trail.length);
        fprintf(fd, "u.trail.frequency %d\n", qxl->u.trail.frequency);
        break;
    }
}
Example #4
0
static char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned int devfn)
{
	char __iomem *addr;

	addr = get_virt(seg, bus);
	if (!addr)
		return NULL;
 	return addr + ((bus << 20) | (devfn << 12));
}
Example #5
0
static void red_record_virt_data_flat(FILE *fd, const char *prefix,
                                      RedMemSlotInfo *slots, int group_id,
                                      QXLPHYSICAL addr, size_t size)
{
    int error;

    write_binary(fd, prefix,
                 size, (uint8_t*)get_virt(slots, addr, size, group_id,
                                          &error));
}
Example #6
0
static char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned int devfn)
{
	char __iomem *addr;
	if (seg == 0 && bus == 0 && test_bit(PCI_SLOT(devfn), &fallback_slots))
		return NULL;
	addr = get_virt(seg, bus);
	if (!addr)
		return NULL;
 	return addr + ((bus << 20) | (devfn << 12));
}
Example #7
0
static char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned int devfn)
{
	char __iomem *addr;
	if (seg == 0 && bus < PCI_MMCFG_MAX_CHECK_BUS &&
		test_bit(32*bus + PCI_SLOT(devfn), pci_mmcfg_fallback_slots))
		return NULL;
	addr = get_virt(seg, bus);
	if (!addr)
		return NULL;
 	return addr + ((bus << 20) | (devfn << 12));
}
Example #8
0
static void red_record_path(FILE *fd, RedMemSlotInfo *slots, int group_id,
                            QXLPHYSICAL addr)
{
    QXLPath *qxl;
    int error;

    qxl = (QXLPath *)get_virt(slots, addr, sizeof(*qxl), group_id,
                              &error);
    red_record_data_chunks_ptr(fd, "path", slots, group_id,
                                   get_memslot_id(slots, addr),
                                   &qxl->chunk);
}
Example #9
0
static size_t red_record_data_chunks(FILE *fd, const char *prefix,
                                     RedMemSlotInfo *slots, int group_id,
                                     QXLPHYSICAL addr)
{
    QXLDataChunk *qxl;
    int memslot_id = get_memslot_id(slots, addr);
    int error;

    qxl = (QXLDataChunk*)get_virt(slots, addr, sizeof(*qxl), group_id,
                                  &error);
    return red_record_data_chunks_ptr(fd, prefix, slots, group_id, memslot_id, qxl);
}
Example #10
0
static void red_record_clip_rects(FILE *fd, RedMemSlotInfo *slots, int group_id,
                                  QXLPHYSICAL addr)
{
    QXLClipRects *qxl;
    int error;

    qxl = (QXLClipRects *)get_virt(slots, addr, sizeof(*qxl), group_id,
                                   &error);
    fprintf(fd, "num_rects %d\n", qxl->num_rects);
    red_record_data_chunks_ptr(fd, "clip_rects", slots, group_id,
                                   get_memslot_id(slots, addr),
                                   &qxl->chunk);
}
Example #11
0
static void red_record_update_cmd(FILE *fd, RedMemSlotInfo *slots, int group_id,
                                  QXLPHYSICAL addr)
{
    QXLUpdateCmd *qxl;
    int error;

    qxl = (QXLUpdateCmd *)get_virt(slots, addr, sizeof(*qxl), group_id,
                                   &error);

    fprintf(fd, "update\n");
    red_record_rect_ptr(fd, "area", &qxl->area);
    fprintf(fd, "update_id %d\n", qxl->update_id);
    fprintf(fd, "surface_id %d\n", qxl->surface_id);
}
Example #12
0
static void red_record_message(FILE *fd, RedMemSlotInfo *slots, int group_id,
                               QXLPHYSICAL addr)
{
    QXLMessage *qxl;
    int error;

    /*
     * security alert:
     *   qxl->data[0] size isn't specified anywhere -> can't verify
     *   luckily this is for debug logging only,
     *   so we can just ignore it by default.
     */
    qxl = (QXLMessage *)get_virt(slots, addr, sizeof(*qxl), group_id,
                                 &error);
    write_binary(fd, "message", strlen((char*)qxl->data), (uint8_t*)qxl->data);
}
Example #13
0
static void red_record_string(FILE *fd, RedMemSlotInfo *slots, int group_id,
                              QXLPHYSICAL addr)
{
    QXLString *qxl;
    size_t chunk_size;
    int error;

    qxl = (QXLString *)get_virt(slots, addr, sizeof(*qxl), group_id,
                                &error);
    fprintf(fd, "data_size %d\n", qxl->data_size);
    fprintf(fd, "length %d\n", qxl->length);
    fprintf(fd, "flags %d\n", qxl->flags);
    chunk_size = red_record_data_chunks_ptr(fd, "string", slots, group_id,
                                         get_memslot_id(slots, addr),
                                         &qxl->chunk);
    spice_assert(chunk_size == qxl->data_size);
}
Example #14
0
static void red_record_cursor(FILE *fd, RedMemSlotInfo *slots, int group_id,
                              QXLPHYSICAL addr)
{
    QXLCursor *qxl;
    int error;

    qxl = (QXLCursor *)get_virt(slots, addr, sizeof(*qxl), group_id,
                                &error);

    fprintf(fd, "header.unique %ld\n", qxl->header.unique);
    fprintf(fd, "header.type %d\n", qxl->header.type);
    fprintf(fd, "header.width %d\n", qxl->header.width);
    fprintf(fd, "header.height %d\n", qxl->header.height);
    fprintf(fd, "header.hot_spot_x %d\n", qxl->header.hot_spot_x);
    fprintf(fd, "header.hot_spot_y %d\n", qxl->header.hot_spot_y);

    fprintf(fd, "data_size %d\n", qxl->data_size);
    red_record_data_chunks_ptr(fd, "cursor", slots, group_id,
                                   get_memslot_id(slots, addr),
                                   &qxl->chunk);
}
Example #15
0
static void red_record_stroke_ptr(FILE *fd, RedMemSlotInfo *slots, int group_id,
                                  QXLStroke *qxl, uint32_t flags)
{
    int error;

    red_record_path(fd, slots, group_id, qxl->path);
    fprintf(fd, "attr.flags %d\n", qxl->attr.flags);
    if (qxl->attr.flags & SPICE_LINE_FLAGS_STYLED) {
        int style_nseg = qxl->attr.style_nseg;
        uint8_t *buf;

        fprintf(fd, "attr.style_nseg %d\n", qxl->attr.style_nseg);
        spice_assert(qxl->attr.style);
        buf = (uint8_t *)get_virt(slots, qxl->attr.style,
                                  style_nseg * sizeof(QXLFIXED), group_id,
                                  &error);
        write_binary(fd, "style", style_nseg * sizeof(QXLFIXED), buf);
    }
    red_record_brush_ptr(fd, slots, group_id, &qxl->brush, flags);
    fprintf(fd, "fore_mode %d\n", qxl->fore_mode);
    fprintf(fd, "back_mode %d\n", qxl->back_mode);
}
Example #16
0
static void hexdump_qxl(RedMemSlotInfo *slots, int group_id,
                        QXLPHYSICAL addr, uint8_t bytes)
{
    uint8_t *hex;
    int i;
    int error;

    hex = (uint8_t*)get_virt(slots, addr, bytes, group_id,
                             &error);
    for (i = 0; i < bytes; i++) {
        if (0 == i % 16) {
            fprintf(stderr, "%lx: ", addr+i);
        }
        if (0 == i % 4) {
            fprintf(stderr, " ");
        }
        fprintf(stderr, " %02x", hex[i]);
        if (15 == i % 16) {
            fprintf(stderr, "\n");
        }
    }
}
Example #17
0
static void red_record_compat_drawable(FILE *fd, RedMemSlotInfo *slots, int group_id,
                                       QXLPHYSICAL addr, uint32_t flags)
{
    QXLCompatDrawable *qxl;
    int error;

    qxl = (QXLCompatDrawable *)get_virt(slots, addr, sizeof(*qxl), group_id,
                                        &error);

    red_record_rect_ptr(fd, "bbox", &qxl->bbox);
    red_record_clip_ptr(fd, slots, group_id, &qxl->clip);
    fprintf(fd, "effect %d\n", qxl->effect);
    fprintf(fd, "mm_time %d\n", qxl->mm_time);

    fprintf(fd, "bitmap_offset %d\n", qxl->bitmap_offset);
    red_record_rect_ptr(fd, "bitmap_area", &qxl->bitmap_area);

    fprintf(fd, "type %d\n", qxl->type);
    switch (qxl->type) {
    case QXL_DRAW_ALPHA_BLEND:
        red_record_alpha_blend_ptr_compat(fd, slots, group_id,
                                       &qxl->u.alpha_blend, flags);
        break;
    case QXL_DRAW_BLACKNESS:
        red_record_blackness_ptr(fd, slots, group_id,
                              &qxl->u.blackness, flags);
        break;
    case QXL_DRAW_BLEND:
        red_record_blend_ptr(fd, slots, group_id, &qxl->u.blend, flags);
        break;
    case QXL_DRAW_COPY:
        red_record_copy_ptr(fd, slots, group_id, &qxl->u.copy, flags);
        break;
    case QXL_COPY_BITS:
        red_record_point_ptr(fd, &qxl->u.copy_bits.src_pos);
        break;
    case QXL_DRAW_FILL:
        red_record_fill_ptr(fd, slots, group_id, &qxl->u.fill, flags);
        break;
    case QXL_DRAW_OPAQUE:
        red_record_opaque_ptr(fd, slots, group_id, &qxl->u.opaque, flags);
        break;
    case QXL_DRAW_INVERS:
        red_record_invers_ptr(fd, slots, group_id, &qxl->u.invers, flags);
        break;
    case QXL_DRAW_NOP:
        break;
    case QXL_DRAW_ROP3:
        red_record_rop3_ptr(fd, slots, group_id, &qxl->u.rop3, flags);
        break;
    case QXL_DRAW_STROKE:
        red_record_stroke_ptr(fd, slots, group_id, &qxl->u.stroke, flags);
        break;
    case QXL_DRAW_TEXT:
        red_record_text_ptr(fd, slots, group_id, &qxl->u.text, flags);
        break;
    case QXL_DRAW_TRANSPARENT:
        red_record_transparent_ptr(fd, slots, group_id, &qxl->u.transparent, flags);
        break;
    case QXL_DRAW_WHITENESS:
        red_record_whiteness_ptr(fd, slots, group_id, &qxl->u.whiteness, flags);
        break;
    default:
        spice_error("%s: unknown type %d", __FUNCTION__, qxl->type);
        break;
    };
}
Example #18
0
static void red_record_image(FILE *fd, RedMemSlotInfo *slots, int group_id,
                                 QXLPHYSICAL addr, uint32_t flags)
{
    QXLImage *qxl;
    size_t bitmap_size, size;
    uint8_t qxl_flags;
    int error;

    fprintf(fd, "image %d\n", addr ? 1 : 0);
    if (addr == 0) {
        return;
    }

    qxl = (QXLImage *)get_virt(slots, addr, sizeof(*qxl), group_id,
                               &error);
    fprintf(fd, "descriptor.id %ld\n", qxl->descriptor.id);
    fprintf(fd, "descriptor.type %d\n", qxl->descriptor.type);
    fprintf(fd, "descriptor.flags %d\n", qxl->descriptor.flags);
    fprintf(fd, "descriptor.width %d\n", qxl->descriptor.width);
    fprintf(fd, "descriptor.height %d\n", qxl->descriptor.height);

    switch (qxl->descriptor.type) {
    case SPICE_IMAGE_TYPE_BITMAP:
        fprintf(fd, "bitmap.format %d\n", qxl->bitmap.format);
        fprintf(fd, "bitmap.flags %d\n", qxl->bitmap.flags);
        fprintf(fd, "bitmap.x %d\n", qxl->bitmap.x);
        fprintf(fd, "bitmap.y %d\n", qxl->bitmap.y);
        fprintf(fd, "bitmap.stride %d\n", qxl->bitmap.stride);
        qxl_flags = qxl->bitmap.flags;
        fprintf(fd, "has_palette %d\n", qxl->bitmap.palette ? 1 : 0);
        if (qxl->bitmap.palette) {
            QXLPalette *qp;
            int i, num_ents;
            qp = (QXLPalette *)get_virt(slots, qxl->bitmap.palette,
                                        sizeof(*qp), group_id, &error);
            num_ents = qp->num_ents;
            fprintf(fd, "qp.num_ents %d\n", qp->num_ents);
            validate_virt(slots, (intptr_t)qp->ents,
                          get_memslot_id(slots, qxl->bitmap.palette),
                          num_ents * sizeof(qp->ents[0]), group_id);
            fprintf(fd, "unique %ld\n", qp->unique);
            for (i = 0; i < num_ents; i++) {
                fprintf(fd, "ents %d\n", qp->ents[i]);
            }
        }
        bitmap_size = qxl->bitmap.y * abs(qxl->bitmap.stride);
        if (qxl_flags & QXL_BITMAP_DIRECT) {
            red_record_image_data_flat(fd, slots, group_id,
                                                         qxl->bitmap.data,
                                                         bitmap_size);
        } else {
            size = red_record_data_chunks(fd, "bitmap.data", slots, group_id,
                                          qxl->bitmap.data);
            spice_assert(size == bitmap_size);
        }
        break;
    case SPICE_IMAGE_TYPE_SURFACE:
        fprintf(fd, "surface_image.surface_id %d\n", qxl->surface_image.surface_id);
        break;
    case SPICE_IMAGE_TYPE_QUIC:
        fprintf(fd, "quic.data_size %d\n", qxl->quic.data_size);
        size = red_record_data_chunks_ptr(fd, "quic.data", slots, group_id,
                                       get_memslot_id(slots, addr),
                                       (QXLDataChunk *)qxl->quic.data);
        spice_assert(size == qxl->quic.data_size);
        break;
    default:
        spice_error("%s: unknown type %d", __FUNCTION__, qxl->descriptor.type);
    }
}