diff mbox series

[RFC,XEN,v4,3/5] x86/pvh: Add PHYSDEVOP_setup_gsi for PVH dom0

Message ID 20240105070920.350113-4-Jiqian.Chen@amd.com (mailing list archive)
State Superseded
Headers show
Series Support device passthrough when dom0 is PVH on Xen | expand

Commit Message

Chen, Jiqian Jan. 5, 2024, 7:09 a.m. UTC
On PVH dom0, the gsis don't get registered, but
the gsi of a passthrough device must be configured for it to
be able to be mapped into a hvm domU.
On Linux kernel side, it calles PHYSDEVOP_setup_gsi for
passthrough devices to register gsi when dom0 is PVH.
So, add PHYSDEVOP_setup_gsi for above purpose.

Co-developed-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Jiqian Chen <Jiqian.Chen@amd.com>
---
 xen/arch/x86/hvm/hypercall.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Stefano Stabellini Jan. 6, 2024, 12:54 a.m. UTC | #1
On Fri, 5 Jan 2024, Jiqian Chen wrote:
> On PVH dom0, the gsis don't get registered, but
> the gsi of a passthrough device must be configured for it to
> be able to be mapped into a hvm domU.
> On Linux kernel side, it calles PHYSDEVOP_setup_gsi for
> passthrough devices to register gsi when dom0 is PVH.
> So, add PHYSDEVOP_setup_gsi for above purpose.
> 
> Co-developed-by: Huang Rui <ray.huang@amd.com>
> Signed-off-by: Jiqian Chen <Jiqian.Chen@amd.com>
> ---
>  xen/arch/x86/hvm/hypercall.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c
> index 632a68be3cc4..e27d3ca15185 100644
> --- a/xen/arch/x86/hvm/hypercall.c
> +++ b/xen/arch/x86/hvm/hypercall.c
> @@ -97,6 +97,12 @@ long hvm_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
>          break;
>      }
>  
> +    case PHYSDEVOP_setup_gsi:
> +        if ( is_hardware_domain(currd) && !has_pirq(currd) )
> +            break;
> +        else
> +            return -ENOSYS;

I am not sure what is the best "if" check for this situation but I am
guessing we don't need has_pirq(currd). Maybe this is sufficient:

if ( is_hardware_domain(currd) )
    break;
else
    return -ENOSYS;


This is another one for the x86 maintainers.


>      case PHYSDEVOP_eoi:
>      case PHYSDEVOP_irq_status_query:
>      case PHYSDEVOP_get_free_pirq:
> -- 
> 2.34.1
>
Jan Beulich Jan. 8, 2024, 8:50 a.m. UTC | #2
On 06.01.2024 01:54, Stefano Stabellini wrote:
> On Fri, 5 Jan 2024, Jiqian Chen wrote:
>> On PVH dom0, the gsis don't get registered, but
>> the gsi of a passthrough device must be configured for it to
>> be able to be mapped into a hvm domU.
>> On Linux kernel side, it calles PHYSDEVOP_setup_gsi for
>> passthrough devices to register gsi when dom0 is PVH.
>> So, add PHYSDEVOP_setup_gsi for above purpose.
>>
>> Co-developed-by: Huang Rui <ray.huang@amd.com>
>> Signed-off-by: Jiqian Chen <Jiqian.Chen@amd.com>
>> ---
>>  xen/arch/x86/hvm/hypercall.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c
>> index 632a68be3cc4..e27d3ca15185 100644
>> --- a/xen/arch/x86/hvm/hypercall.c
>> +++ b/xen/arch/x86/hvm/hypercall.c
>> @@ -97,6 +97,12 @@ long hvm_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
>>          break;
>>      }
>>  
>> +    case PHYSDEVOP_setup_gsi:
>> +        if ( is_hardware_domain(currd) && !has_pirq(currd) )
>> +            break;
>> +        else
>> +            return -ENOSYS;
> 
> I am not sure what is the best "if" check for this situation but I am
> guessing we don't need has_pirq(currd). Maybe this is sufficient:
> 
> if ( is_hardware_domain(currd) )
>     break;
> else
>     return -ENOSYS;

Maybe

    if ( !is_hardware_domain(currd) )
        return -EOPNOTSUPP;
    ASSERT(!has_pirq(currd));
    break;

? What I primarily dislike in both earlier proposals is the (imo
confusing) use of "else".

Jan
Chen, Jiqian Jan. 9, 2024, 8:01 a.m. UTC | #3
On 2024/1/8 16:50, Jan Beulich wrote:
> On 06.01.2024 01:54, Stefano Stabellini wrote:
>> On Fri, 5 Jan 2024, Jiqian Chen wrote:
>>> On PVH dom0, the gsis don't get registered, but
>>> the gsi of a passthrough device must be configured for it to
>>> be able to be mapped into a hvm domU.
>>> On Linux kernel side, it calles PHYSDEVOP_setup_gsi for
>>> passthrough devices to register gsi when dom0 is PVH.
>>> So, add PHYSDEVOP_setup_gsi for above purpose.
>>>
>>> Co-developed-by: Huang Rui <ray.huang@amd.com>
>>> Signed-off-by: Jiqian Chen <Jiqian.Chen@amd.com>
>>> ---
>>>  xen/arch/x86/hvm/hypercall.c | 6 ++++++
>>>  1 file changed, 6 insertions(+)
>>>
>>> diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c
>>> index 632a68be3cc4..e27d3ca15185 100644
>>> --- a/xen/arch/x86/hvm/hypercall.c
>>> +++ b/xen/arch/x86/hvm/hypercall.c
>>> @@ -97,6 +97,12 @@ long hvm_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
>>>          break;
>>>      }
>>>  
>>> +    case PHYSDEVOP_setup_gsi:
>>> +        if ( is_hardware_domain(currd) && !has_pirq(currd) )
>>> +            break;
>>> +        else
>>> +            return -ENOSYS;
>>
>> I am not sure what is the best "if" check for this situation but I am
>> guessing we don't need has_pirq(currd). Maybe this is sufficient:
>>
>> if ( is_hardware_domain(currd) )
>>     break;
>> else
>>     return -ENOSYS;
> 
> Maybe
> 
>     if ( !is_hardware_domain(currd) )
>         return -EOPNOTSUPP;
>     ASSERT(!has_pirq(currd));
>     break;
> 
> ? What I primarily dislike in both earlier proposals is the (imo
> confusing) use of "else".
It looks like more reasonable. I will change to as this in next version if there are no other guys have different opinions.

> 
> Jan
diff mbox series

Patch

diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c
index 632a68be3cc4..e27d3ca15185 100644
--- a/xen/arch/x86/hvm/hypercall.c
+++ b/xen/arch/x86/hvm/hypercall.c
@@ -97,6 +97,12 @@  long hvm_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         break;
     }
 
+    case PHYSDEVOP_setup_gsi:
+        if ( is_hardware_domain(currd) && !has_pirq(currd) )
+            break;
+        else
+            return -ENOSYS;
+
     case PHYSDEVOP_eoi:
     case PHYSDEVOP_irq_status_query:
     case PHYSDEVOP_get_free_pirq: