qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [Resend RFC PATCH 3/4] Intel iommu: Add Intel IOMMU fau


From: Alex Williamson
Subject: Re: [Qemu-devel] [Resend RFC PATCH 3/4] Intel iommu: Add Intel IOMMU fault event callback
Date: Mon, 20 Feb 2017 14:08:56 -0700

On Mon, 20 Feb 2017 09:28:06 +0800
Lan Tianyu <address@hidden> wrote:

> This patch is to deal with fault event reported from IOMMU driver.
> 
> Signed-off-by: Lan Tianyu <address@hidden>
> ---
>  hw/i386/intel_iommu.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
> index 9b1ba1b..79507d2 100644
> --- a/hw/i386/intel_iommu.c
> +++ b/hw/i386/intel_iommu.c
> @@ -2286,6 +2286,30 @@ static void vtd_iommu_notify_flag_changed(MemoryRegion 
> *iommu,
>      }
>  }
>  
> +static void vtd_iommu_notify_fault_event(MemoryRegion *iommu,
> +                                         IOMMUFaultInfo *info)
> +{
> +    VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu);
> +    IntelIOMMUState *s = vtd_as->iommu_state;
> +    bool is_fpd_set = false;
> +    uint8_t bus_num = pci_bus_num(vtd_as->bus);
> +    uint8_t devfn = vtd_as->devfn;
> +    VTDContextEntry ce;
> +
> +    /* Replace source id with device's vbdf */
> +    info->sid = vtd_make_source_id(bus_num, devfn);
> +
> +    if (!vtd_dev_to_context_entry(s, bus_num, devfn, &ce)) {
> +        is_fpd_set = ce.lo & VTD_CONTEXT_ENTRY_FPD;
> +        if (is_fpd_set) {
> +            trace_vtd_fault_disabled();
> +        } else {
> +            vtd_report_dmar_fault(s, info->sid, info->addr,
> +                                  info->fault_reason, info->is_write);

Convenient that the error structure exactly matches the function
parameters here.  Is fault_reason going to be standardized across all
IOMMU vendors?  If not, how does QEMU know whether the type1 container
is backed by VT-d, AMD-Vi, ARM SMMU, etc?

> +        }
> +    }
> +}
> +
>  static const VMStateDescription vtd_vmstate = {
>      .name = "iommu-intel",
>      .version_id = 1,
> @@ -2816,6 +2840,7 @@ static void vtd_init(IntelIOMMUState *s)
>  
>      s->iommu_ops.translate = vtd_iommu_translate;
>      s->iommu_ops.notify_flag_changed = vtd_iommu_notify_flag_changed;
> +    s->iommu_ops.notify_fault_event = vtd_iommu_notify_fault_event;
>      s->iommu_ops.replay = vtd_iommu_replay;
>      s->root = 0;
>      s->root_extended = false;




reply via email to

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