Skip to contentSkip to conversation

Windows balloon driver PFN issue

Qemu-devel Peter Xu 2 participants 8 messages Jan 31, 2018 – Feb 27, 2018 1 message not in the archive

lore
Share & tools
lore

Peter Xu

author
#0 lore raw

Hi, Michael and the list,

I observed this on windows 8 enterprise guests, when doing memory ballooning:

[email protected]:virtio_balloon_to_target balloon target: 0x80000000 num_pages: 524288 [email protected]:virtio_balloon_get_config num_pages: 524288 actual: 0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x174604000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460a000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460b000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460c000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460d000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460e000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460f000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0
...

I think it's very possible that these zero addresses (please let me know what the first 4K page is used for if anyone knows, since IIUC that's what we throw away now) are half of the 64bit PFN. Or say, not sure whether this means a windows guest driver bug that is using 64bits for PFN rather than 32bits (and I suppose the protocol is using 32bit for PFNs).

Michael, do you know what to do with this?

Thanks,

Signature · 1 line
Peter Xu
#1 lore raw
Quoted 29 lines · Peter Xu

Hi, Michael and the list,

I observed this on windows 8 enterprise guests, when doing memory ballooning:

[email protected]:virtio_balloon_to_target balloon target: 0x80000000 num_pages: 524288 [email protected]:virtio_balloon_get_config num_pages: 524288 actual: 0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x174604000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460a000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460b000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460c000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460d000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460e000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460f000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0
...

I think it's very possible that these zero addresses (please let me know what the first 4K page is used for if anyone knows, since IIUC that's what we throw away now) are half of the 64bit PFN. Or say, not sure whether this means a windows guest driver bug that is using 64bits for PFN rather than 32bits (and I suppose the protocol is using 32bit for PFNs).

Quoted 3 lines

Michael, do you know what to do with this?

Thanks,

PFN is GPA>>12. Do you have more than 1<<44 bytes of memory in this VM then?

Quoted 2 lines
Signature · 1 line
Peter Xu
author
#2 lore raw
Quoted 30 lines · Michael S. Tsirkin
Quoted 29 lines · Peter Xu

Hi, Michael and the list,

I observed this on windows 8 enterprise guests, when doing memory ballooning:

[email protected]:virtio_balloon_to_target balloon target: 0x80000000 num_pages: 524288 [email protected]:virtio_balloon_get_config num_pages: 524288 actual: 0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x174604000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460a000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460b000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460c000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460d000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460e000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460f000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0
...

I think it's very possible that these zero addresses (please let me know what the first 4K page is used for if anyone knows, since IIUC that's what we throw away now) are half of the 64bit PFN. Or say, not sure whether this means a windows guest driver bug that is using 64bits for PFN rather than 32bits (and I suppose the protocol is using 32bit for PFNs).

Quoted 5 lines
Quoted 3 lines

Michael, do you know what to do with this?

Thanks,

PFN is GPA>>12. Do you have more than 1<<44 bytes of memory in this VM then?

No. But isn't it still not good to drop the page at offset zero (and drop it NNN times)? And I'm not sure what will happen if guest has 1<<44 bytes; then we'll possibly drop very random addresses since a real address will be splitted?

Thanks,

Signature · 1 line
Peter Xu
#3 lore raw
Quoted 31 lines · Peter Xu
Quoted 30 lines · Michael S. Tsirkin
Quoted 29 lines · Peter Xu

Hi, Michael and the list,

I observed this on windows 8 enterprise guests, when doing memory ballooning:

[email protected]:virtio_balloon_to_target balloon target: 0x80000000 num_pages: 524288 [email protected]:virtio_balloon_get_config num_pages: 524288 actual: 0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x174604000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460a000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460b000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460c000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460d000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460e000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460f000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0
...

I think it's very possible that these zero addresses (please let me know what the first 4K page is used for if anyone knows, since IIUC that's what we throw away now) are half of the 64bit PFN. Or say, not sure whether this means a windows guest driver bug that is using 64bits for PFN rather than 32bits (and I suppose the protocol is using 32bit for PFNs).

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Michael, do you know what to do with this?

Thanks,

PFN is GPA>>12. Do you have more than 1<<44 bytes of memory in this VM then?

No. But isn't it still not good to drop the page at offset zero (and drop it NNN times)?

Absolutely - looks like a bug. I just don't know why does this happen.

Quoted 5 lines

And I'm not sure what will happen if guest has
1<<44 bytes; then we'll possibly drop very random addresses since a real address will be splitted?

Thanks,

The balloon won't work, period. There was an interface change to fix that but implementation issues remained and contributor seems to be busy with page hints.

Quoted 2 lines
Signature · 1 line
Peter Xu
author
#4 lore raw
Quoted 34 lines · Michael S. Tsirkin
Quoted 33 lines · Peter Xu
Quoted 32 lines · Michael S. Tsirkin
Quoted 31 lines · Peter Xu

Hi, Michael and the list,

I observed this on windows 8 enterprise guests, when doing memory ballooning:

[email protected]:virtio_balloon_to_target balloon target: 0x80000000 num_pages: 524288 [email protected]:virtio_balloon_get_config num_pages: 524288 actual: 0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x174604000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460a000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460b000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460c000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460d000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460e000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460f000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0
...

I think it's very possible that these zero addresses (please let me know what the first 4K page is used for if anyone knows, since IIUC that's what we throw away now) are half of the 64bit PFN. Or say, not sure whether this means a windows guest driver bug that is using 64bits for PFN rather than 32bits (and I suppose the protocol is using 32bit for PFNs).

Michael, do you know what to do with this?

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Thanks,

PFN is GPA>>12. Do you have more than 1<<44 bytes of memory in this VM then?

No. But isn't it still not good to drop the page at offset zero (and drop it NNN times)?

Absolutely - looks like a bug. I just don't know why does this happen.

IMHO if we are using a PFN array like this:

   u64 pfn_array[];

In the windows guest driver, then we'll see this (as mentioned above). But for sure this is wild guess of mine.

Quoted 10 lines
Quoted 6 lines

And I'm not sure what will happen if guest has
1<<44 bytes; then we'll possibly drop very random addresses since a real address will be splitted?

Thanks,

The balloon won't work, period. There was an interface change to fix that but implementation issues remained and contributor seems to be busy with page hints.

Okay. So IIUC this is already a known issue for the driver owner. Then it seems that there's nothing more I can do for now...

Thanks,

Signature · 1 line
Peter Xu
#5 lore raw
Quoted 42 lines · Peter Xu
Quoted 41 lines · Michael S. Tsirkin
Quoted 39 lines · Peter Xu
Quoted 30 lines · Michael S. Tsirkin
Quoted 29 lines · Peter Xu

Hi, Michael and the list,

I observed this on windows 8 enterprise guests, when doing memory ballooning:

[email protected]:virtio_balloon_to_target balloon target: 0x80000000 num_pages: 524288 [email protected]:virtio_balloon_get_config num_pages: 524288 actual: 0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x174604000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460a000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460b000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460c000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460d000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460e000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x17460f000 [email protected]:virtio_balloon_handle_output section name: pc.ram gpa: 0x0
...

I think it's very possible that these zero addresses (please let me know what the first 4K page is used for if anyone knows, since IIUC that's what we throw away now) are half of the 64bit PFN. Or say, not sure whether this means a windows guest driver bug that is using 64bits for PFN rather than 32bits (and I suppose the protocol is using 32bit for PFNs).

Quoted 5 lines
Quoted 3 lines

Michael, do you know what to do with this?

Thanks,

PFN is GPA>>12. Do you have more than 1<<44 bytes of memory in this VM then?

No. But isn't it still not good to drop the page at offset zero (and drop it NNN times)?

Quoted 8 lines
Quoted 1 line

Absolutely - looks like a bug. I just don't know why does this happen.

IMHO if we are using a PFN array like this:

   u64 pfn_array[];

In the windows guest driver, then we'll see this (as mentioned above). But for sure this is wild guess of mine.

I don't see code like this anywhere in the windows balloon driver. It's here:
https://github.com/virtio-win/kvm-guest-drivers-windows.git

Quoted 18 lines
Quoted 10 lines
Quoted 6 lines

And I'm not sure what will happen if guest has
1<<44 bytes; then we'll possibly drop very random addresses since a real address will be splitted?

Thanks,

The balloon won't work, period. There was an interface change to fix that but implementation issues remained and contributor seems to be busy with page hints.

Okay. So IIUC this is already a known issue for the driver owner. Then it seems that there's nothing more I can do for now...

Thanks,

Signature · 1 line
Peter Xu
author
#6 lore raw

On Thu, Feb 01, 2018 at 02:48:20PM +0200, Michael S. Tsirkin wrote:

[...]

Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

PFN is GPA>>12. Do you have more than 1<<44 bytes of memory in this VM then?

No. But isn't it still not good to drop the page at offset zero (and drop it NNN times)?

Absolutely - looks like a bug. I just don't know why does this happen.

IMHO if we are using a PFN array like this:

Quoted 8 lines
Quoted 4 lines
   u64 pfn_array[];

In the windows guest driver, then we'll see this (as mentioned above). But for sure this is wild guess of mine.

I don't see code like this anywhere in the windows balloon driver. It's here:
https://github.com/virtio-win/kvm-guest-drivers-windows.git

Thanks for the pointer. I had a quick glance, the PFN array is defined as:

    PPFN_NUMBER             pfns_table;

But I don't know what's sizeof(PPFN_NUMBER). :(

Signature · 1 line
Peter Xu
author
#8 lore raw
In reply to a message not in the archive
Quoted 30 lines · Gal Hammer

Hi Peter,

Quoted 27 lines · Peter Xu

On Thu, Feb 01, 2018 at 02:48:20PM +0200, Michael S. Tsirkin wrote:

[...]

Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

PFN is GPA>>12. Do you have more than 1<<44 bytes of memory in this VM then?

No. But isn't it still not good to drop the page at offset zero (and drop it NNN times)?

Absolutely - looks like a bug. I just don't know why does this happen.

IMHO if we are using a PFN array like this:

Quoted 8 lines
Quoted 4 lines
   u64 pfn_array[];

In the windows guest driver, then we'll see this (as mentioned above). But for sure this is wild guess of mine.

I don't see code like this anywhere in the windows balloon driver. It's here:
https://github.com/virtio-win/kvm-guest-drivers-windows.git

Thanks for the pointer. I had a quick glance, the PFN array is defined as:

    PPFN_NUMBER             pfns_table;
Quoted 7 lines
Quoted 1 line

But I don't know what's sizeof(PPFN_NUMBER). :(

sizeof(PPFN_NUMBER) = sizeof(void*)

PFN_NUMBER is of an unsigned long type. Although it doesn't matter, as a pointer to it is always the same size, 4 bytes in a 32-bit CPU and 8 bytes in 64-bit one.

Ah, it's not really PPFN_NUMBER that matters, it should be PFN_NUMBER. This is how the PFNs are copied in windows driver:

    RtlCopyMemory(ctx->pfns_table, MmGetMdlPfnArray(pPageMdl),
        ctx->num_pfns * sizeof(PFN_NUMBER));

I don't know these APIs, but it looks like MmGetMdlPfnArray() is returning an PFN_NUMBER array.

And I don't know how the balloon spec says, but in QEMU it's always using uint32_t as PFN. See virtio_balloon_handle_output():

    while (iov_to_buf(elem->out_sg, elem->out_num, offset, &pfn, 4) == 4)

So I guess only if sizeof(PFN_NUMBER)==4 is true on both 32/64 bits platforms of windows, otherwise there might be a problem.

Thanks,

Signature · 1 line
Peter Xu