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

Re: [RFC XEN PATCH v3 2/3] x86/pvh: Add (un)map_pirq and setup_gsi for PVH dom0


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Date: Mon, 18 Dec 2023 03:25:05 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mEBRPe2MRV/MdybBof27MTjnam7g6tLVZNDdVAm/X3c=; b=kf8T4MQS/sRETf0kPjHn7G9zMYLirng6nmAY2ia/KTJVFw2nPkXXRGWT69ijA5oibQ1R8L5YhTKK/jn6JbsSuMvLmqhzo9vfv4tRMVMBaeJqzIZl9ZXG6wiFTkZb0shYmRBjx1YLxC6omgaBdDeQ+opWjJoBp33TCP5N+IbYfdbisSP5158wWoFwa7HVsUTd0SMYrwyGQk1cb3EPAojUVg96TSfb/oDqmP02sOv54AyhN/pIrKZJ4S0pL/zaOakaqk70MwA9mu5RxIBbqmad2HyrdXpQWW+645yjuLQNOzdUfGAAmI1Qw3qJIuz76HcRDNOpnW9M6VFep+z8fFVahQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VdV4MiJ+0VUVvCLFhI7Be/IO0vb3S4Yqm9rWgbqN6e+y3oM28DVoEtbnz9x1suqjNXpjOPJu6+n7o/DkxrelkpiDQuSHEcvQaVtyxnfpObkCia6SqgA73wLhf8n4K2NsB0p2LFNRvNfx14yeO1z6faXxEW2m6uhZOx/GHdPubk/421sMJ16ovwuEi90q7pOwwNyoggxA4vBdmAQ9HOIs0tkSMS7wKQzWE6GRb89XH8FNBCyG3dn1iWO9IKbB94ScKzB7UPbHI6nrCnTrnjZ9/TGUii/bcpeJoaOlBcFKxKGJqTaNAVMchIGdD8aU3Nin2AXHkNprUqke9Ab9A+2D/g==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, "Daniel P . Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Hildebrand, Stewart" <Stewart.Hildebrand@xxxxxxx>, "Ragiadakou, Xenia" <Xenia.Ragiadakou@xxxxxxx>, "Huang, Ray" <Ray.Huang@xxxxxxx>, "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Delivery-date: Mon, 18 Dec 2023 03:25:30 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHaK4ebBv/EWT+No0GAUR8lU4172LCkNzqAgAGFPID//6gjAIABpqIA///CiwCAAi33AP//lJaAAAAYnAAAAExygAAan/AAACJ1V4D//45vgIAE5d8A
  • Thread-topic: [RFC XEN PATCH v3 2/3] x86/pvh: Add (un)map_pirq and setup_gsi for PVH dom0

On 2023/12/15 16:29, Roger Pau Monné wrote:
> On Fri, Dec 15, 2023 at 07:20:24AM +0000, Chen, Jiqian wrote:
>> diff --git a/tools/libs/light/libxl_pci.c b/tools/libs/light/libxl_pci.c
>> index d3507d13a029..f665d17afbf5 100644
>> --- a/tools/libs/light/libxl_pci.c
>> +++ b/tools/libs/light/libxl_pci.c
>> @@ -1486,6 +1486,7 @@ static void pci_add_dm_done(libxl__egc *egc,
>>          goto out_no_irq;
>>      }
>>      if ((fscanf(f, "%u", &irq) == 1) && irq) {
>> +        int gsi = irq;
>>          r = xc_physdev_map_pirq(ctx->xch, domid, irq, &irq);
>>          if (r < 0) {
>>              LOGED(ERROR, domainid, "xc_physdev_map_pirq irq=%d (error=%d)",
>> @@ -1494,7 +1495,7 @@ static void pci_add_dm_done(libxl__egc *egc,
>>              rc = ERROR_FAIL;
>>              goto out;
>>          }
>> -        r = xc_domain_irq_permission(ctx->xch, domid, irq, 1);
>> +        r = xc_domain_irq_permission(ctx->xch, domid, gsi, 1);
>>          if (r < 0) {
>>              LOGED(ERROR, domainid,
>>                    "xc_domain_irq_permission irq=%d (error=%d)", irq, r);
>> diff --git a/xen/common/domctl.c b/xen/common/domctl.c
>> index f5a71ee5f78d..782c4a7a70a4 100644
>> --- a/xen/common/domctl.c
>> +++ b/xen/common/domctl.c
>> @@ -658,7 +658,12 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) 
>> u_domctl)
>>              ret = -EINVAL;
>>              break;
>>          }
>> -        irq = pirq_access_permitted(current->domain, pirq);
>> +
>> +        if ( is_hvm_domain(current->domain) )
>> +            irq = pirq;
>> +        else
>> +            irq = pirq_access_permitted(current->domain, pirq);
> 
> You are dropping an irq_access_permitted() check here for the HVM
> case, as pirq_access_permitted() translates from pirq to irq and also
> checks for permissions.
> 
> This would need to be something along the lines of:
> 
> irq = 0;
> if ( is_hvm_domain(current->domain) &&
>      irq_access_permitted(current->domain, pirq) )
Oh, yes, it should add this check.

>     irq = pirq;
> else
>     irq = pirq_access_permitted(current->domain, pirq);
> 
> And then I wonder whether it wouldn't be best to uniformly use a GSI
> for both PV and HVM.
If we only look at the value(seems the number of gsi == pirq == irq in PV), it 
seems that gsi can also be used uniformly for PV.
And then here should be. 
if ( irq_access_permitted(current->domain, pirq) )
        irq = pirq;
else
{
        ret = -EPERM;
        break;
}

> 
> Thanks, Roger.

-- 
Best regards,
Jiqian Chen.

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.