qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH RFC server v2 08/11] vfio-user: handle PCI BAR accesses


From: Jag Raman
Subject: Re: [PATCH RFC server v2 08/11] vfio-user: handle PCI BAR accesses
Date: Fri, 10 Sep 2021 16:36:49 +0000


> On Sep 9, 2021, at 3:37 AM, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> 
> On Fri, Aug 27, 2021 at 01:53:27PM -0400, Jagannathan Raman wrote:
>> +/**
>> + * VFU_OBJECT_BAR_HANDLER - macro for defining handlers for PCI BARs.
>> + *
>> + * To create handler for BAR number 2, VFU_OBJECT_BAR_HANDLER(2) would
>> + * define vfu_object_bar2_handler
>> + */
>> +#define VFU_OBJECT_BAR_HANDLER(BAR_NO)                                      
>>    \
>> +    static ssize_t vfu_object_bar##BAR_NO##_handler(vfu_ctx_t *vfu_ctx,     
>>    \
>> +                                        char * const buf, size_t count,     
>>    \
>> +                                        loff_t offset, const bool is_write) 
>>    \
>> +    {                                                                       
>>    \
>> +        VfuObject *o = vfu_get_private(vfu_ctx);                            
>>    \
>> +        hwaddr addr = (hwaddr)(pci_get_long(o->pci_dev->config +            
>>    \
>> +                                            PCI_BASE_ADDRESS_0 +            
>>    \
>> +                                            (4 * BAR_NO)) + offset);        
>>    \
> 
> Does this handle 64-bit BARs?

It presently only handles 32-bit BARs. We’ll add support for 64-bit BARs in the 
next rev
of this series.

> 
>> +/**
>> + * vfu_object_register_bars - Identify active BAR regions of pdev and setup
>> + *                            callbacks to handle read/write accesses
>> + */
>> +static void vfu_object_register_bars(vfu_ctx_t *vfu_ctx, PCIDevice *pdev)
>> +{
>> +    uint32_t orig_val, new_val;
>> +    int i, size;
>> +
>> +    for (i = 0; i < PCI_NUM_REGIONS; i++) {
>> +        orig_val = pci_default_read_config(pdev,
>> +                                           PCI_BASE_ADDRESS_0 + (4 * i), 4);
> 
> Same question as in an earlier patch: should we call pdev->read_config()?

Sure, will do.

--
Jag


reply via email to

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