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: Stefan Hajnoczi
Subject: Re: [PATCH RFC server v2 08/11] vfio-user: handle PCI BAR accesses
Date: Thu, 9 Sep 2021 08:37:34 +0100

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?

> +/**
> + * 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()?

Attachment: signature.asc
Description: PGP signature


reply via email to

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