[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 2/5] target-i386: Add Intel HAX files
From: |
Vincent Palatin |
Subject: |
Re: [Qemu-devel] [PATCH v2 2/5] target-i386: Add Intel HAX files |
Date: |
Mon, 14 Nov 2016 13:07:24 +0100 |
On Mon, Nov 14, 2016 at 11:15 AM, Paolo Bonzini <address@hidden> wrote:
>
>
> 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.
Good point,
I will fix this
>
> Is there documentation for HAX?
No developer doc I know of,
both Intel website and the download packages contain only installation
documentations as far as I can tell.
I will ask Intel when I have the chance.
> In particular I'm curious as to what
> the CPUID information looks like in the guest, and whether there are
> ioctls to change it.
No idea for the interface, but I have put an example below if you are
interested.
> In particular I would expect XSAVE to be disabled.
For EAX=1 I'm seeing ECX = 00d82201 => [26] = 0 && [27] = 0.
We should be fine for XSAVE.
On the Intel Core i5-6200U CPU I was running my tests on, I have
dumped the CPUID inside the emulator with HAX and on the Windows host:
========== emulation with HAX ==========
eax in eax ebx ecx edx
00000000 00000004 756e6547 6c65746e 49656e69
00000001 000106f1 00010400 00d82201 1f88fbff
00000002 03020101 00000000 00000000 0c040844
00000003 00000000 00000000 00000000 00000000
00000004 00000000 00000000 00000000 00000000
00000005 00000040 00000040 00000003 11142120
00000006 000027f7 00000002 00000009 00000000
00000007 00000000 029c67af 00000000 00000000
00000008 00000000 00000000 00000000 00000000
00000009 00000000 00000000 00000000 00000000
0000000a 07300404 00000000 00000000 00000603
0000000b 00000001 00000002 00000100 00000001
0000000c 00000000 00000000 00000000 00000000
0000000d 0000001f 00000440 00000440 00000000
0000000e 00000000 00000000 00000000 00000000
0000000f 00000000 00000000 00000000 00000000
00000010 00000000 00000000 00000000 00000000
00000011 00000000 00000000 00000000 00000000
00000012 00000000 00000000 00000000 00000000
00000013 00000000 00000000 00000000 00000000
00000014 00000001 0000000f 00000007 00000000
00000015 00000002 000000c8 00000000 00000000
00000016 00000960 00000af0 00000064 00000000
80000000 80000008 00000000 00000000 00000000
80000001 00000000 00000000 00000000 20000800
80000002 74726956 206c6175 20555043 00000000
80000003 00000000 00000000 00000000 00000000
80000004 00000000 00000000 00000000 00000000
80000005 00000000 00000000 00000000 00000000
80000006 00000000 00000000 04008040 00000000
80000007 00000000 00000000 00000000 00000000
80000008 00003027 00000000 00000000 00000000
========== Windows host ==========
eax in eax ebx ecx edx
00000000 00000016 756e6547 6c65746e 49656e69
00000001 000406e3 00100800 7ffafbbf bfebfbff
00000002 76036301 00f0b5ff 00000000 00c30000
00000003 00000000 00000000 00000000 00000000
00000004 00000000 00000000 00000000 00000000
00000005 00000040 00000040 00000003 11142120
00000006 000027f7 00000002 00000009 00000000
00000007 00000000 00000000 00000000 00000000
00000008 00000000 00000000 00000000 00000000
00000009 00000000 00000000 00000000 00000000
0000000a 07300404 00000000 00000000 00000603
0000000b 00000000 00000000 000000c3 00000000
0000000c 00000000 00000000 00000000 00000000
0000000d 00000000 00000000 00000000 00000000
0000000e 00000000 00000000 00000000 00000000
0000000f 00000000 00000000 00000000 00000000
00000010 00000000 00000000 00000000 00000000
00000011 00000000 00000000 00000000 00000000
00000012 00000000 00000000 00000000 00000000
00000013 00000000 00000000 00000000 00000000
00000014 00000000 00000000 00000000 00000000
00000015 00000002 000000c8 00000000 00000000
00000016 00000960 00000af0 00000064 00000000
80000000 80000008 00000000 00000000 00000000
80000001 00000000 00000000 00000121 2c100000
80000002 65746e49 2952286c 726f4320 4d542865
80000003 35692029 3032362d 43205530 40205550
80000004 332e3220 7a484730 00000000 00000000
80000005 00000000 00000000 00000000 00000000
80000006 00000000 00000000 01006040 00000000
80000007 00000000 00000000 00000000 00000100
80000008 00003027 00000000 00000000 00000000
>
>> +
>> +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.
Ok, removed.
Re-tested my own image still works ...
>
>> + 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.
Updated.
>
>> + 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);
>
Nice, updated and queued for my V3 series.
>
>> + if (!df) {
>> + ptr += size;
>> + } else {
>> + ptr -= size;
>> + }
>> + }
>> +
>> + return 0;
>> +}
>> +
- [Qemu-devel] [PATCH v2 0/5] [RFC] Add HAX support, Vincent Palatin, 2016/11/11
- [Qemu-devel] [PATCH v2 1/5] kvm: move cpu synchronization code, Vincent Palatin, 2016/11/11
- [Qemu-devel] [PATCH v2 3/5] hax: remove non UG code, Vincent Palatin, 2016/11/11
- [Qemu-devel] [PATCH v2 4/5] hax: simplify init, Vincent Palatin, 2016/11/11
- [Qemu-devel] [PATCH v2 2/5] target-i386: Add Intel HAX files, Vincent Palatin, 2016/11/11
- [Qemu-devel] [PATCH v2 5/5] Plumb the HAXM-based hardware acceleration support, Vincent Palatin, 2016/11/11
- Re: [Qemu-devel] [PATCH v2 0/5] [RFC] Add HAX support, no-reply, 2016/11/12
- Re: [Qemu-devel] [PATCH v2 0/5] [RFC] Add HAX support, Stefan Weil, 2016/11/14