diff mbox

[V3,16/29] x86/vvtd: decode interrupt attribute from IRTE

Message ID 1506049330-11196-17-git-send-email-tianyu.lan@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

lan,Tianyu Sept. 22, 2017, 3:01 a.m. UTC
From: Chao Gao <chao.gao@intel.com>

Without interrupt remapping, interrupt attributes can be extracted from
msi message or IOAPIC RTE. However, with interrupt remapping enabled,
the attributes are enclosed in the associated IRTE. This callback is
for cases in which the caller wants to acquire interrupt attributes, for
example:
1. vioapic_get_vector(). With vIOMMU, the RTE may don't contain vector.
2. perform EOI which is always based on the interrupt vector.

Signed-off-by: Chao Gao <chao.gao@intel.com>
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
v3:
 - add example cases in which we will use this function.
---
 xen/drivers/passthrough/vtd/vvtd.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

Comments

Roger Pau Monné Oct. 19, 2017, 2:39 p.m. UTC | #1
On Thu, Sep 21, 2017 at 11:01:57PM -0400, Lan Tianyu wrote:
> From: Chao Gao <chao.gao@intel.com>
> 
> Without interrupt remapping, interrupt attributes can be extracted from
> msi message or IOAPIC RTE. However, with interrupt remapping enabled,
> the attributes are enclosed in the associated IRTE. This callback is
> for cases in which the caller wants to acquire interrupt attributes, for
> example:
> 1. vioapic_get_vector(). With vIOMMU, the RTE may don't contain vector.
                                                    ^ not
> 2. perform EOI which is always based on the interrupt vector.
> 
> Signed-off-by: Chao Gao <chao.gao@intel.com>
> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
> ---
> v3:
>  - add example cases in which we will use this function.
> ---
>  xen/drivers/passthrough/vtd/vvtd.c | 23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/drivers/passthrough/vtd/vvtd.c b/xen/drivers/passthrough/vtd/vvtd.c
> index 90c00f5..5e22ace 100644
> --- a/xen/drivers/passthrough/vtd/vvtd.c
> +++ b/xen/drivers/passthrough/vtd/vvtd.c
> @@ -516,6 +516,26 @@ static int vvtd_handle_irq_request(struct domain *d,
>                           irte.remap.tm);
>  }
>  
> +static int vvtd_get_irq_info(struct domain *d,
> +                             struct arch_irq_remapping_request *irq,
> +                             struct arch_irq_remapping_info *info)
> +{
> +    int ret;
> +    struct iremap_entry irte;
> +    struct vvtd *vvtd = domain_vvtd(d);

I've realized that some of the helpers perform a if (!vvtd ) return
check, while others don't (like this one). Are some handlers expected
to be called without a vIOMMU? If so it would be good to list them
clearly.

Thanks, Roger.
Chao Gao Oct. 20, 2017, 5:22 a.m. UTC | #2
On Thu, Oct 19, 2017 at 03:39:44PM +0100, Roger Pau Monné wrote:
>On Thu, Sep 21, 2017 at 11:01:57PM -0400, Lan Tianyu wrote:
>> From: Chao Gao <chao.gao@intel.com>
>> 
>> Without interrupt remapping, interrupt attributes can be extracted from
>> msi message or IOAPIC RTE. However, with interrupt remapping enabled,
>> the attributes are enclosed in the associated IRTE. This callback is
>> for cases in which the caller wants to acquire interrupt attributes, for
>> example:
>> 1. vioapic_get_vector(). With vIOMMU, the RTE may don't contain vector.
>                                                    ^ not
>> 2. perform EOI which is always based on the interrupt vector.
>> 
>> Signed-off-by: Chao Gao <chao.gao@intel.com>
>> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
>> ---
>> v3:
>>  - add example cases in which we will use this function.
>> ---
>>  xen/drivers/passthrough/vtd/vvtd.c | 23 ++++++++++++++++++++++-
>>  1 file changed, 22 insertions(+), 1 deletion(-)
>> 
>> diff --git a/xen/drivers/passthrough/vtd/vvtd.c b/xen/drivers/passthrough/vtd/vvtd.c
>> index 90c00f5..5e22ace 100644
>> --- a/xen/drivers/passthrough/vtd/vvtd.c
>> +++ b/xen/drivers/passthrough/vtd/vvtd.c
>> @@ -516,6 +516,26 @@ static int vvtd_handle_irq_request(struct domain *d,
>>                           irte.remap.tm);
>>  }
>>  
>> +static int vvtd_get_irq_info(struct domain *d,
>> +                             struct arch_irq_remapping_request *irq,
>> +                             struct arch_irq_remapping_info *info)
>> +{
>> +    int ret;
>> +    struct iremap_entry irte;
>> +    struct vvtd *vvtd = domain_vvtd(d);
>
>I've realized that some of the helpers perform a if (!vvtd ) return
>check, while others don't (like this one). Are some handlers expected
>to be called without a vIOMMU?

No. I forgot to check the existence of a vIOMMU here.

Thanks
chao
diff mbox

Patch

diff --git a/xen/drivers/passthrough/vtd/vvtd.c b/xen/drivers/passthrough/vtd/vvtd.c
index 90c00f5..5e22ace 100644
--- a/xen/drivers/passthrough/vtd/vvtd.c
+++ b/xen/drivers/passthrough/vtd/vvtd.c
@@ -516,6 +516,26 @@  static int vvtd_handle_irq_request(struct domain *d,
                          irte.remap.tm);
 }
 
+static int vvtd_get_irq_info(struct domain *d,
+                             struct arch_irq_remapping_request *irq,
+                             struct arch_irq_remapping_info *info)
+{
+    int ret;
+    struct iremap_entry irte;
+    struct vvtd *vvtd = domain_vvtd(d);
+
+    ret = vvtd_get_entry(vvtd, irq, &irte, false);
+    if ( ret )
+        return ret;
+
+    info->vector = irte.remap.vector;
+    info->dest = irte_dest(vvtd, irte.remap.dst);
+    info->dest_mode = irte.remap.dm;
+    info->delivery_mode = irte.remap.dlm;
+
+    return 0;
+}
+
 static void vvtd_reset(struct vvtd *vvtd, uint64_t capability)
 {
     uint64_t cap = cap_set_num_fault_regs(1ULL) |
@@ -586,7 +606,8 @@  static int vvtd_destroy(struct viommu *viommu)
 struct viommu_ops vvtd_hvm_vmx_ops = {
     .create = vvtd_create,
     .destroy = vvtd_destroy,
-    .handle_irq_request = vvtd_handle_irq_request
+    .handle_irq_request = vvtd_handle_irq_request,
+    .get_irq_info = vvtd_get_irq_info
 };
 
 static int vvtd_register(void)