qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Vincent Palatin <vpalatin@chromium.org>,
	qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v2 2/5] target-i386: Add Intel HAX files
Date: Mon, 14 Nov 2016 11:15:02 +0100	[thread overview]
Message-ID: <cb6b1a4c-0780-76cb-af46-55c653529f6d@redhat.com> (raw)
In-Reply-To: <08625798334d3ea3ccead1b40d1068982b40f1d1.1478863621.git.vpalatin@chromium.org>



On 11/11/2016 12:28, Vincent Palatin wrote:
> +
> +    memcpy(env->xmm_regs, fpu.mmx_1, sizeof(fpu.mmx_1));
> +    memcpy((ZMMReg *) (env->xmm_regs) + 8, fpu.mmx_2, sizeof(fpu.mmx_2));

HAX will only support SSE (128-bit) registers, while env->xmm_regs
supports AVX512 (512-bit) so you have to copy registers one by one.

Is there documentation for HAX?  In particular I'm curious as to what
the CPUID information looks like in the guest, and whether there are
ioctls to change it.

> +
> +static int hax_handle_fastmmio(CPUArchState *env, struct hax_fastmmio *hft)
> +{
> +    uint64_t buf = 0;
> +    /*
> +     * With fast MMIO, QEMU need not sync vCPU state with HAXM
> +     * driver because it will only invoke MMIO handler
> +     * However, some MMIO operations utilize virtual address like qemu_pipe
> +     * Thus we need to sync the CR0, CR3 and CR4 so that QEMU
> +     * can translate the guest virtual address to guest physical
> +     * address
> +     */
> +    env->cr[0] = hft->_cr0;
> +    env->cr[2] = hft->_cr2;
> +    env->cr[3] = hft->_cr3;
> +    env->cr[4] = hft->_cr4;

These seem to apply only to some parts of the Android emulator that are
not upstream, so you can remove them.

> +    buf = hft->value;
> +
> +    cpu_physical_memory_rw(hft->gpa, (uint8_t *) &buf, hft->size,
> +                           hft->direction);
> +    if (hft->direction == 0) {
> +        hft->value = buf;
> +    }

No need to use "buf", you can use &hft->value directly.

> +    return 0;
> +}
> +
> +static int hax_handle_io(CPUArchState *env, uint32_t df, uint16_t port,
> +                         int direction, int size, int count, void *buffer)
> +{
> +    uint8_t *ptr;
> +    int i;
> +
> +    if (!df) {
> +        ptr = (uint8_t *) buffer;
> +    } else {
> +        ptr = buffer + size * count - size;
> +    }
> +    for (i = 0; i < count; i++) {
> +        if (direction == HAX_EXIT_IO_IN) {
> +            switch (size) {
> +            case 1:
> +                stb_p(ptr, cpu_inb(port));
> +                break;
> +            case 2:
> +                stw_p(ptr, cpu_inw(port));
> +                break;
> +            case 4:
> +                stl_p(ptr, cpu_inl(port));
> +                break;
> +            }
> +        } else {
> +            switch (size) {
> +            case 1:
> +                cpu_outb(port, ldub_p(ptr));
> +                break;
> +            case 2:
> +                cpu_outw(port, lduw_p(ptr));
> +                break;
> +            case 4:
> +                cpu_outl(port, ldl_p(ptr));
> +                break;
> +            }
> +        }

The whole "if" can be replaced by

    MemTxAttrs = { 0 };
    ...

        address_space_rw(&address_space_io, port, attrs,
                         ptr, size, direction == HAX_EXIT_IO_OUT);

Thanks,

Paolo

> +        if (!df) {
> +            ptr += size;
> +        } else {
> +            ptr -= size;
> +        }
> +    }
> +
> +    return 0;
> +}
> +

  parent reply	other threads:[~2016-11-14 10:15 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-11 11:28 [Qemu-devel] [PATCH v2 0/5] [RFC] Add HAX support Vincent Palatin
2016-11-11 11:28 ` [Qemu-devel] [PATCH v2 1/5] kvm: move cpu synchronization code Vincent Palatin
2016-11-11 11:28 ` [Qemu-devel] [PATCH v2 2/5] target-i386: Add Intel HAX files Vincent Palatin
2016-11-14  9:29   ` Stefan Weil
2016-11-14  9:38     ` Vincent Palatin
2016-11-14 10:15   ` Paolo Bonzini [this message]
2016-11-14 12:07     ` Vincent Palatin
2016-11-14 11:55   ` Paolo Bonzini
2016-11-11 11:28 ` [Qemu-devel] [PATCH v2 3/5] hax: remove non UG code Vincent Palatin
2016-11-11 11:28 ` [Qemu-devel] [PATCH v2 4/5] hax: simplify init Vincent Palatin
2016-11-11 11:28 ` [Qemu-devel] [PATCH v2 5/5] Plumb the HAXM-based hardware acceleration support Vincent Palatin
2016-11-14 11:56   ` Paolo Bonzini
2016-11-14 12:09     ` Vincent Palatin
2016-11-13  3:20 ` [Qemu-devel] [PATCH v2 0/5] [RFC] Add HAX support no-reply
2016-11-14  8:21   ` Vincent Palatin
2016-11-14  8:47     ` Paolo Bonzini
2016-11-14  8:55     ` Stefan Weil
2016-11-14  9:28       ` Vincent Palatin
2016-11-14 12:21 ` Stefan Weil
2016-11-14 12:33   ` Vincent Palatin
2016-11-14 12:38     ` Stefan Weil
2016-11-14 12:36 ` Stefan Weil
2016-11-14 13:09   ` Vincent Palatin
2016-11-17 11:09     ` Vincent Palatin
2016-11-18 10:42       ` Vincent Palatin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cb6b1a4c-0780-76cb-af46-55c653529f6d@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vpalatin@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).