Ben-Ami Yassour wrote:
> +#define assigned_dev_ioport_write(suffix)
\
> +static void assigned_dev_ioport_write##suffix(void *opaque,         
> \ +                                         uint32_t addr,
\
> +                                              uint32_t value)
\
> +{
\
> +     assigned_dev_region_t *r_access =
\
> +                  (assigned_dev_region_t *)opaque;
\
> +     uint32_t r_pio = (unsigned long)r_access->r_virtbase
\
> +             + (addr - r_access->e_physbase);
\
> +     if (r_access->debug & DEVICE_ASSIGNMENT_DEBUG_PIO) {
\
> +             fprintf(logfile, "assigned_dev_ioport_write" #suffix
\
> +                     ": r_pio=%08x e_physbase=%08x"
\
> +                     " r_virtbase=%08lx value=%08x\n",
\
> +                     r_pio, (int)r_access->e_physbase,
\
> +                     (unsigned long)r_access->r_virtbase, value);
\
> +     }
\
> +     iopl(3);\
> +     out##suffix(value, r_pio);
\
> +}
> +assigned_dev_ioport_write(b)
> +assigned_dev_ioport_write(w)
> +assigned_dev_ioport_write(l)
> +
> +#define assigned_dev_ioport_read(suffix)
\
> +static uint32_t assigned_dev_ioport_read##suffix(void *opaque,      
> \ +                                                 uint32_t addr)
\
> +{
\
> +     assigned_dev_region_t *r_access =
\
> +                    (assigned_dev_region_t *)opaque;
\
> +     uint32_t r_pio = (addr - r_access->e_physbase)
\
> +             + (unsigned long)r_access->r_virtbase;
\
> +             uint32_t value = in##suffix(r_pio);
\
> +             if (r_access->debug & DEVICE_ASSIGNMENT_DEBUG_PIO) {
\
> +                     fprintf(logfile, "assigned_dev_ioport_read"
\
> +                                #suffix      ": r_pio=%08x "

> \ +                                "e_physbase=%08x r_virtbase=%08lx
> "     \ +                             "value=%08x\n",
\
> +                             r_pio, (int)r_access->e_physbase,
\
> +                             (unsigned long)r_access->r_virtbase,
\
> +                                value);
\
> +             }
\
> +             return value;
\
> +}
> +
> +assigned_dev_ioport_read(b)
> +assigned_dev_ioport_read(w)
> +assigned_dev_ioport_read(l)
> +

Need to add iopl(3) in assigned_dev_ioport_read##suffix(). ioport read
may be before ioport write. When assign USB controller to guest, I found
it read ioport before write. If there is no iopl(3) in
assigned_dev_ioport_read##suffix(), it results in "segmentation fault". 

BTW, code style in assigned_dev_ioport_read##suffix() is not correct,
pls update it.

Randy (Weidong)
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to