qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] 答复: Questions about 'emulated_config_bits' in vfio pci


From: Li Qiang
Subject: [Qemu-devel] 答复: Questions about 'emulated_config_bits' in vfio pci
Date: Sat, 31 Aug 2019 10:44:22 +0800

So detailed explanation, I got the point.

Thank you Alex!

Li Qiang


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

On Sat, 31 Aug 2019 09:31:59 +0800
Li Qiang <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]