qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Questions about 'emulated_config_bits' in vfio pci
@ 2019-08-31  1:31 Li Qiang
  2019-08-31  2:23 ` Alex Williamson
  0 siblings, 1 reply; 3+ messages in thread
From: Li Qiang @ 2019-08-31  1:31 UTC (permalink / raw)
  To: Alex Williamson, qemu-devel

Hi Alex and all,

My understanding for ‘emulated_config_bits’ in ‘VFIOPCIDevice’ is that this is the mask for PCI config space. If the bits is set in ‘ emulated_config_bits’ then we can just use the qemu’s ‘vdev->pdev.config’, it the bits is not set, we need to ask the physical device. 

But there are two places I got confused in ‘vfio_realize’.

Here in ‘vfio_realize’
    /* QEMU can change multi-function devices to single function, or reverse */
    vdev->emulated_config_bits[PCI_HEADER_TYPE] =
                                              PCI_HEADER_TYPE_MULTI_FUNCTION;

In ‘vfio_add_std_cap’

        /* Begin the rebuild, use QEMU emulated list bits */
        pdev->config[PCI_CAPABILITY_LIST] = 0;
        vdev->emulated_config_bits[PCI_CAPABILITY_LIST] = 0xff;
        vdev->emulated_config_bits[PCI_STATUS] |= PCI_STATUS_CAP_LIST;


Per my understanding, I think ‘emulated_config_bits’ should be set to 0xff just as other places. But here use ‘PCI_HEADER_TYPE_MULTI_FUNCTION’ and ‘PCI_STATUS_CAP_LIST’. In fact, this doesn’t affect the results, but it’s confusion.
Just a typo? Or other reasons.


Thanks,
Li Qiang

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] Questions about 'emulated_config_bits' in vfio pci
  2019-08-31  1:31 [Qemu-devel] Questions about 'emulated_config_bits' in vfio pci Li Qiang
@ 2019-08-31  2:23 ` Alex Williamson
  2019-08-31  2:44   ` [Qemu-devel] 答复: " Li Qiang
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Williamson @ 2019-08-31  2:23 UTC (permalink / raw)
  To: Li Qiang; +Cc: Alex Williamson, qemu-devel

On Sat, 31 Aug 2019 09:31:59 +0800
Li Qiang <liq3ea@163.com> wrote:

> Hi Alex and all,
> 
> My understanding for ‘emulated_config_bits’ in ‘VFIOPCIDevice’ is
> that this is the mask for PCI config space. If the bits is set in ‘
> emulated_config_bits’ then we can just use the qemu’s
> ‘vdev->pdev.config’, it the bits is not set, we need to ask the
> physical device. 

Yes.

> But there are two places I got confused in ‘vfio_realize’.
> 
> Here in ‘vfio_realize’
>     /* QEMU can change multi-function devices to single function, or
> reverse */ vdev->emulated_config_bits[PCI_HEADER_TYPE] =
>                                               PCI_HEADER_TYPE_MULTI_FUNCTION;
> 
> In ‘vfio_add_std_cap’
> 
>         /* Begin the rebuild, use QEMU emulated list bits */
>         pdev->config[PCI_CAPABILITY_LIST] = 0;
>         vdev->emulated_config_bits[PCI_CAPABILITY_LIST] = 0xff;
>         vdev->emulated_config_bits[PCI_STATUS] |= PCI_STATUS_CAP_LIST;
> 
> 
> Per my understanding, I think ‘emulated_config_bits’ should be set to
> 0xff just as other places. But here use
> ‘PCI_HEADER_TYPE_MULTI_FUNCTION’ and ‘PCI_STATUS_CAP_LIST’. In fact,
> this doesn’t affect the results, but it’s confusion. Just a typo? Or
> other reasons.

I'm not sure I understand the question.  We're only trying to emulate
the multi-function bit of the header-type register and the capability
list bit of the status register, therefore we set only these bits in
the emulated bits mask.  The header type is static, so it doesn't make
much difference if we emulate the entire 8-bit register or only this
bit (I don't think it's worth the optimization and doing so potentially
masks what we're trying to accomplish).  The status register though is
partially static and partially dynamic, some bits are reporting the
current device status.  So I don't see that we'd ever want to emulate
all of the bits in that register.  emulate_config_bits has bit level
granularity to which bits of config space are emulated in QEMU, so
we're not always going to set a full byte for emulation.  Thanks,

Alex


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Qemu-devel] 答复:  Questions about 'emulated_config_bits' in vfio pci
  2019-08-31  2:23 ` Alex Williamson
@ 2019-08-31  2:44   ` Li Qiang
  0 siblings, 0 replies; 3+ messages in thread
From: Li Qiang @ 2019-08-31  2:44 UTC (permalink / raw)
  To: Alex Williamson; +Cc: Alex Williamson, qemu-devel

So detailed explanation, I got the point.

Thank you Alex!

Li Qiang


发件人: Alex Williamson
发送时间: 2019年8月31日 10:23
收件人: Li Qiang
抄送: Alex Williamson; qemu-devel@nongnu.org
主题: Re: [Qemu-devel] Questions about 'emulated_config_bits' in vfio pci

On Sat, 31 Aug 2019 09:31:59 +0800
Li Qiang <liq3ea@163.com> wrote:

> Hi Alex and all,
> 
> My understanding for ‘emulated_config_bits’ in ‘VFIOPCIDevice’ is
> that this is the mask for PCI config space. If the bits is set in ‘
> emulated_config_bits’ then we can just use the qemu’s
> ‘vdev->pdev.config’, it the bits is not set, we need to ask the
> physical device. 

Yes.

> But there are two places I got confused in ‘vfio_realize’.
> 
> Here in ‘vfio_realize’
>     /* QEMU can change multi-function devices to single function, or
> reverse */ vdev->emulated_config_bits[PCI_HEADER_TYPE] =
>                                               PCI_HEADER_TYPE_MULTI_FUNCTION;
> 
> In ‘vfio_add_std_cap’
> 
>         /* Begin the rebuild, use QEMU emulated list bits */
>         pdev->config[PCI_CAPABILITY_LIST] = 0;
>         vdev->emulated_config_bits[PCI_CAPABILITY_LIST] = 0xff;
>         vdev->emulated_config_bits[PCI_STATUS] |= PCI_STATUS_CAP_LIST;
> 
> 
> Per my understanding, I think ‘emulated_config_bits’ should be set to
> 0xff just as other places. But here use
> ‘PCI_HEADER_TYPE_MULTI_FUNCTION’ and ‘PCI_STATUS_CAP_LIST’. In fact,
> this doesn’t affect the results, but it’s confusion. Just a typo? Or
> other reasons.

I'm not sure I understand the question.  We're only trying to emulate
the multi-function bit of the header-type register and the capability
list bit of the status register, therefore we set only these bits in
the emulated bits mask.  The header type is static, so it doesn't make
much difference if we emulate the entire 8-bit register or only this
bit (I don't think it's worth the optimization and doing so potentially
masks what we're trying to accomplish).  The status register though is
partially static and partially dynamic, some bits are reporting the
current device status.  So I don't see that we'd ever want to emulate
all of the bits in that register.  emulate_config_bits has bit level
granularity to which bits of config space are emulated in QEMU, so
we're not always going to set a full byte for emulation.  Thanks,

Alex


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-08-31  2:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-31  1:31 [Qemu-devel] Questions about 'emulated_config_bits' in vfio pci Li Qiang
2019-08-31  2:23 ` Alex Williamson
2019-08-31  2:44   ` [Qemu-devel] 答复: " Li Qiang

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).