From patchwork Wed Dec 1 09:39:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12649619 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E701EC433F5 for ; Wed, 1 Dec 2021 09:39:56 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.235730.408915 (Exim 4.92) (envelope-from ) id 1msM5V-0000pt-VA; Wed, 01 Dec 2021 09:39:41 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 235730.408915; Wed, 01 Dec 2021 09:39:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1msM5V-0000pk-Qv; Wed, 01 Dec 2021 09:39:41 +0000 Received: by outflank-mailman (input) for mailman id 235730; Wed, 01 Dec 2021 09:39:41 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1msM5U-0000op-Qy for xen-devel@lists.xenproject.org; Wed, 01 Dec 2021 09:39:40 +0000 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.109.102]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9aa8efd3-528a-11ec-976b-d102b41d0961; Wed, 01 Dec 2021 10:39:39 +0100 (CET) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04lp2058.outbound.protection.outlook.com [104.47.14.58]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-33-uXMnin7MPoyxtPgGsd-MBA-1; Wed, 01 Dec 2021 10:39:38 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB5471.eurprd04.prod.outlook.com (2603:10a6:803:d0::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23; Wed, 1 Dec 2021 09:39:37 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::5951:a489:1cf0:19fe]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::5951:a489:1cf0:19fe%5]) with mapi id 15.20.4734.024; Wed, 1 Dec 2021 09:39:37 +0000 Received: from [10.156.60.236] (37.24.206.209) by FR2P281CA0029.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.9 via Frontend Transport; Wed, 1 Dec 2021 09:39:36 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 9aa8efd3-528a-11ec-976b-d102b41d0961 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1638351579; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IWiLXoypwdsEAY6kyd1+aV8MaMHsKsQSdAXMXWcxPL4=; b=jX3XFIAMotZgGXPljnI3EYJbK2FEdpActgapowoaK/Q+bvR5QlSMKZYFCwjqfkLVjcJ+ea etfBYh90748paoDIEeU4mQ/iPrSk3A3S35QyNBie3762/ix1TsjRAd11S3vJqyQwgdtXG3 /zsNW5KfYWiGi70aJjzLPebJXzBLbrc= X-MC-Unique: uXMnin7MPoyxtPgGsd-MBA-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zg1p22ww2Mj8PuxNEd6kVkeC6CIraUD2K+mRcgpoECbqODXaSvtfdPjQm9j82D2btGHDlWdQawNrQgtrDdNOQanFXtbwfSQPzrbSPinN0WAKlfAWHmJeQLxLQ+LXXuL0jioEqPnxDfTvyTR0PFkfb9kP8MqgPrfxUh5VFU0HyG5imqpNJJwLH38pXhsreqFW0bJWP22PSAMRbeY31c0A+on2RUfpopM8oCt3suzG5uK2Mai9JJ7zcjyS0AGbfnRSgnB6N+fcX+1dsPmHW78BbdAVlbjA0JXKS1chYUzkf3rhlblfV6hlzDOKDJHpp1p+Q/zQ/4FC0fzm7f4lLVT1MA== 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=IWiLXoypwdsEAY6kyd1+aV8MaMHsKsQSdAXMXWcxPL4=; b=a/VzMlj6WLNbnX7nVqs67SWZgi8drO7Tt2nYQdEDt+ZIn++pnzohHIqMclp0t4supNqPeqBJNExTaYMqokJFxSjtMx1NPwqpJfzm142rHvH/RWjgor0V3V9voQXmhuq3/pRr5bXP1wj/NmOOjOu5XWdm7JhoQgcMeIhaLa/z0qe9eJnUQpQR8IMVnGHEiDLC5+Mspu+UG78PVuBqRK0llAC1zkiCjHCzGd84OBqftLAwNy46wHHjoKz0qzHHtVHNP2R7JOrL58hGLPWFSbm1XNhI0Yd258jBTV6H3GpQjFFIgqgXEcjHvjQFbmcz5MyQOFb7h5R1LN/kXCn+/EB9Kg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Wed, 1 Dec 2021 10:39:35 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: [PATCH 1/4] IOMMU/x86: switch to alternatives-call patching in further instances Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Paul Durrant , Andrew Cooper References: <5d72c629-fabf-3d40-aa19-d177826fdde5@suse.com> In-Reply-To: <5d72c629-fabf-3d40-aa19-d177826fdde5@suse.com> X-ClientProxiedBy: FR2P281CA0029.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::16) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9caa85a3-1e9f-4c7f-fb3d-08d9b4ae7d4b X-MS-TrafficTypeDiagnostic: VI1PR04MB5471: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vrXTh9NIooEEuC4eaWqEdhTcoVz9Kh0HZipCq1Cpr5R3Z6Bg7TzYsMqyePa0gIkoDpGzVB12kq60aHCjSzc5O+PAzD1Mpe75hfqm8M+O8OLcs5aGBS3EGoONIkWNCswOt/17KepgGip7FwzeIjNaV8ZPdafFrkR12RqUTVIqRR8GSEmBLLMxhU6WhU5BhN1M8oPhi3NHUZKEcxTEh6m0Jf7CulAvB41KeITAc3p/IAM8ZuyhD7tHUeDPSIx1uNIQHHTbKlWDVaOltj30dnA2JYrINIPxCvz+JoYVKVZz0c7gsfhWRGCVw0Hra1/tzaZowomR/oSZr/f7AM7n8WLfO8wEDiRkTxeKvDkvllBOMc47YLQKmsAdLQLn2+WpnhpLMc7pAPnECimmoEXAdeC1ItNdxGqsNriXDlt7ohUvry+pDy0b9iTjPeY9bAVTfuaBYVaVvPTNtmBb5o6cci5Ex2xIAtHgC3lrE+bN7IeeeUSXRbULqxfPv8l0d4h4+OKwmW+wJtRfK3N5NgyxncwkGuvG/4AwrEF1fv4sV/QkUqZLrcLG5OW3RoNNmWFjs20hSzyO6nBrPGNQYfF0wnjbSi6bpHzwmbGea8mkYD8A27bUpJnzxqXkO6F4xn0S2p77UhXXyx/3vWbowfjVb1qXDwtCpAR5zf4vFlp7lFqse6hSIGZsnMKFRnU3Edk2xGo9uphsQCzCqsRm5KnCVzeNzJ5lJjRE0Z5Y8E+UoGtK7vThScI27ewxO63VN+aWyxtG X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(2906002)(16576012)(6916009)(66946007)(4326008)(66476007)(5660300002)(508600001)(26005)(66556008)(186003)(54906003)(2616005)(316002)(956004)(38100700002)(83380400001)(8936002)(86362001)(6486002)(36756003)(31686004)(31696002)(8676002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?2JXxP6OqGF4P/FpOAyS/1gZHahnM?= =?utf-8?q?+hidRGhLiu5dx2NGcgVJVcFBhto2NGyghB2XBKxGh2bPrj3LhpodSe+AxQ8M57Awn?= =?utf-8?q?xm8bUOPlKilgpg62FNwgDndkA9aro5JexEyCKjrk1ersFbICqpdnSTFGiKcEo3xSR?= =?utf-8?q?TKtnMPydVCL1ebEXtwFHj46TfxRNz6HWwpY8VMF9ec/7E/pjjgVyk1t2iSlO1aUSM?= =?utf-8?q?rEaXzSZ+ovZb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iNbKX89oFS7kBcggFJjrFRPRj5pNybvK?= =?utf-8?q?rzu2KXIoe1HN6sxkJR1F+mlDFJUPH1L73DY4Al6FxFjoJ8uM0PCJb8zuzw1oFROu9?= =?utf-8?q?+r4bup1ZnywnogKGkpWAkqpToYX469dOiyH66/AdT+KvrvozRnw+pnJ3LZna2mJV5?= =?utf-8?q?cO8+zgqAeE414isD1n/fanroZoXyYaGsrgXoz8vrkBZRD+7lACEOX7pudWENnGJA6?= =?utf-8?q?lAe68KrD0teDMIOz4ANB9F8TQdaX4sJMPy2Qz7qUZ8KBymuJSW6hEpkXIpp9Hy0AS?= =?utf-8?q?m4Q+yVBfgzE/Ue/EQgJ/a1ZS16yrSBjip6h45PYKdnT+aH2HouZTNd49fm5iCUVQm?= =?utf-8?q?j83i0sz4fPI6FkR+zVMdQbEPfeURv67leYVWmqJ8p3AYVLfU6niaF0utyln7PHGqn?= =?utf-8?q?5+Mm10GISNt2qyUpnfBpWwPE8ZFU64EqjeL/Fxeawi5g7ydOQlAH6vU=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9caa85a3-1e9f-4c7f-fb3d-08d9b4ae7d4b X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2021 09:39:37.0415 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cA5etbvuCg52XXzDe7gtqaaLdff4JtzyuoC79iWrzq5XE6b4HV7K1/QfHfIFV4iBXJeYSCUP87SBDdD0k6QvrQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5471 This is, once again, to limit the number of indirect calls as much as possible. The only hook invocation which isn't sensible to convert is setup(). And of course Arm-only use sites are left alone as well. Note regarding the introduction / use of local variables in pci.c: struct pci_dev's involved fields are const. This const propagates, via typeof(), to the local helper variables in the altcall macros. These helper variables are, however, used as outputs (and hence can't be const). In iommu_get_device_group() make use of the new local variables to also simplify some adjacent code. Signed-off-by: Jan Beulich --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -198,7 +198,7 @@ int iommu_domain_init(struct domain *d, return ret; hd->platform_ops = iommu_get_ops(); - ret = hd->platform_ops->init(d); + ret = iommu_call(hd->platform_ops, init, d); if ( ret || is_system_domain(d) ) return ret; @@ -233,7 +233,7 @@ void __hwdom_init iommu_hwdom_init(struc register_keyhandler('o', &iommu_dump_page_tables, "dump iommu page tables", 0); - hd->platform_ops->hwdom_init(d); + iommu_vcall(hd->platform_ops, hwdom_init, d); } static void iommu_teardown(struct domain *d) @@ -576,7 +576,7 @@ int iommu_get_reserved_device_memory(iom if ( !ops->get_reserved_device_memory ) return 0; - return ops->get_reserved_device_memory(func, ctxt); + return iommu_call(ops, get_reserved_device_memory, func, ctxt); } bool_t iommu_has_feature(struct domain *d, enum iommu_feature feature) @@ -603,7 +603,7 @@ static void iommu_dump_page_tables(unsig continue; } - dom_iommu(d)->platform_ops->dump_page_tables(d); + iommu_vcall(dom_iommu(d)->platform_ops, dump_page_tables, d); } rcu_read_unlock(&domlist_read_lock); --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -861,15 +861,15 @@ static int deassign_device(struct domain devfn += pdev->phantom_stride; if ( PCI_SLOT(devfn) != PCI_SLOT(pdev->devfn) ) break; - ret = hd->platform_ops->reassign_device(d, target, devfn, - pci_to_dev(pdev)); + ret = iommu_call(hd->platform_ops, reassign_device, d, target, devfn, + pci_to_dev(pdev)); if ( ret ) goto out; } devfn = pdev->devfn; - ret = hd->platform_ops->reassign_device(d, target, devfn, - pci_to_dev(pdev)); + ret = iommu_call(hd->platform_ops, reassign_device, d, target, devfn, + pci_to_dev(pdev)); if ( ret ) goto out; @@ -1300,7 +1300,7 @@ static int iommu_add_device(struct pci_d { const struct domain_iommu *hd; int rc; - u8 devfn; + unsigned int devfn = pdev->devfn; if ( !pdev->domain ) return -EINVAL; @@ -1311,16 +1311,16 @@ static int iommu_add_device(struct pci_d if ( !is_iommu_enabled(pdev->domain) ) return 0; - rc = hd->platform_ops->add_device(pdev->devfn, pci_to_dev(pdev)); + rc = iommu_call(hd->platform_ops, add_device, devfn, pci_to_dev(pdev)); if ( rc || !pdev->phantom_stride ) return rc; - for ( devfn = pdev->devfn ; ; ) + for ( ; ; ) { devfn += pdev->phantom_stride; if ( PCI_SLOT(devfn) != PCI_SLOT(pdev->devfn) ) return 0; - rc = hd->platform_ops->add_device(devfn, pci_to_dev(pdev)); + rc = iommu_call(hd->platform_ops, add_device, devfn, pci_to_dev(pdev)); if ( rc ) printk(XENLOG_WARNING "IOMMU: add %pp failed (%d)\n", &pdev->sbdf, rc); @@ -1341,7 +1341,7 @@ static int iommu_enable_device(struct pc !hd->platform_ops->enable_device ) return 0; - return hd->platform_ops->enable_device(pci_to_dev(pdev)); + return iommu_call(hd->platform_ops, enable_device, pci_to_dev(pdev)); } static int iommu_remove_device(struct pci_dev *pdev) @@ -1363,7 +1363,8 @@ static int iommu_remove_device(struct pc devfn += pdev->phantom_stride; if ( PCI_SLOT(devfn) != PCI_SLOT(pdev->devfn) ) break; - rc = hd->platform_ops->remove_device(devfn, pci_to_dev(pdev)); + rc = iommu_call(hd->platform_ops, remove_device, devfn, + pci_to_dev(pdev)); if ( !rc ) continue; @@ -1371,7 +1372,9 @@ static int iommu_remove_device(struct pc return rc; } - return hd->platform_ops->remove_device(pdev->devfn, pci_to_dev(pdev)); + devfn = pdev->devfn; + + return iommu_call(hd->platform_ops, remove_device, devfn, pci_to_dev(pdev)); } static int device_assigned(u16 seg, u8 bus, u8 devfn) @@ -1421,7 +1424,8 @@ static int assign_device(struct domain * pdev->fault.count = 0; - if ( (rc = hd->platform_ops->assign_device(d, devfn, pci_to_dev(pdev), flag)) ) + if ( (rc = iommu_call(hd->platform_ops, assign_device, d, devfn, + pci_to_dev(pdev), flag)) ) goto done; for ( ; pdev->phantom_stride; rc = 0 ) @@ -1429,7 +1433,8 @@ static int assign_device(struct domain * devfn += pdev->phantom_stride; if ( PCI_SLOT(devfn) != PCI_SLOT(pdev->devfn) ) break; - rc = hd->platform_ops->assign_device(d, devfn, pci_to_dev(pdev), flag); + rc = iommu_call(hd->platform_ops, assign_device, d, devfn, + pci_to_dev(pdev), flag); } done: @@ -1457,24 +1462,24 @@ static int iommu_get_device_group( if ( !is_iommu_enabled(d) || !ops->get_device_group_id ) return 0; - group_id = ops->get_device_group_id(seg, bus, devfn); + group_id = iommu_call(ops, get_device_group_id, seg, bus, devfn); pcidevs_lock(); for_each_pdev( d, pdev ) { - if ( (pdev->seg != seg) || - ((pdev->bus == bus) && (pdev->devfn == devfn)) ) + unsigned int b = pdev->bus; + unsigned int df = pdev->devfn; + + if ( (pdev->seg != seg) || ((b == bus) && (df == devfn)) ) continue; - if ( xsm_get_device_group(XSM_HOOK, (seg << 16) | (pdev->bus << 8) | pdev->devfn) ) + if ( xsm_get_device_group(XSM_HOOK, (seg << 16) | (b << 8) | df) ) continue; - sdev_id = ops->get_device_group_id(seg, pdev->bus, pdev->devfn); + sdev_id = iommu_call(ops, get_device_group_id, seg, b, df); if ( (sdev_id == group_id) && (i < max_sdevs) ) { - bdf = 0; - bdf |= (pdev->bus & 0xff) << 16; - bdf |= (pdev->devfn & 0xff) << 8; + bdf = (b << 16) | (df << 8); if ( unlikely(copy_to_guest_offset(buf, i, &bdf, 1)) ) { --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -142,7 +142,7 @@ unsigned int iommu_read_apic_from_ire(un int __init iommu_setup_hpet_msi(struct msi_desc *msi) { const struct iommu_ops *ops = iommu_get_ops(); - return ops->setup_hpet_msi ? ops->setup_hpet_msi(msi) : -ENODEV; + return ops->setup_hpet_msi ? iommu_call(ops, setup_hpet_msi, msi) : -ENODEV; } void __hwdom_init arch_iommu_check_autotranslated_hwdom(struct domain *d) @@ -403,7 +403,7 @@ int iommu_free_pgtables(struct domain *d * Pages will be moved to the free list below. So we want to * clear the root page-table to avoid any potential use after-free. */ - hd->platform_ops->clear_root_pgtable(d); + iommu_vcall(hd->platform_ops, clear_root_pgtable, d); while ( (pg = page_list_remove_head(&hd->arch.pgtables.list)) ) { From patchwork Wed Dec 1 09:40:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12649623 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2C1D0C433EF for ; Wed, 1 Dec 2021 09:41:33 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.235742.408937 (Exim 4.92) (envelope-from ) id 1msM79-0002m6-Iy; Wed, 01 Dec 2021 09:41:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 235742.408937; Wed, 01 Dec 2021 09:41:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1msM79-0002lv-Fb; Wed, 01 Dec 2021 09:41:23 +0000 Received: by outflank-mailman (input) for mailman id 235742; Wed, 01 Dec 2021 09:41:21 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1msM77-0002Rt-5a for xen-devel@lists.xenproject.org; Wed, 01 Dec 2021 09:41:21 +0000 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.111.102]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4f5e5d8b-5289-11ec-b945-1df2895da90e; Wed, 01 Dec 2021 10:30:45 +0100 (CET) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04lp2052.outbound.protection.outlook.com [104.47.13.52]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-20-NBdHqzgHMJyJxrDlCcu5cQ-1; Wed, 01 Dec 2021 10:40:34 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB3293.eurprd04.prod.outlook.com (2603:10a6:802:11::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.20; Wed, 1 Dec 2021 09:40:26 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::5951:a489:1cf0:19fe]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::5951:a489:1cf0:19fe%5]) with mapi id 15.20.4734.024; Wed, 1 Dec 2021 09:40:26 +0000 Received: from [10.156.60.236] (37.24.206.209) by FR2P281CA0020.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.9 via Frontend Transport; Wed, 1 Dec 2021 09:40:25 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4f5e5d8b-5289-11ec-b945-1df2895da90e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1638351635; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0t8LMyxHaP2kl7/Dbfr610HjSp+BcW6EUg2e2egGqsk=; b=R8fOljW83adIBWl0iRe2bxkfwXBsng2Vs2rNIDxwsQbvBS6AOddf1kEPYh5RpCsLwZXLi7 YxX6CRCdR4lAxNvs5dbxA5Ok5QFuv0iGB4H4fNTrZb9Xpg4VXSvyOVVVzNO2dCvCorm6xH ZWveT+NZ9KLDVEyxzeebudaaL0RE4qI= X-MC-Unique: NBdHqzgHMJyJxrDlCcu5cQ-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iwHbbjokC0TDYaIwOwb3ZDo0MhQpPxZcg/1TEo2bJ8qCjMuqJCxgYaJpmfgHS4kqiC/jClZRLP5FL7+Hj7xWbE+q4L34C9O9T5exY01Yw0FJEY+cKYl2aDzLVTM7QLcNgKuRjXlo2kfwkgg7iS7Fq1bm6+mnF5MqSckkritbJBbfaEJzODta8QluOEFxgVvRrAmlPkdp+o2p2ExBHmqHuxL2RsimntDNAIt3glh3fXJHeTS01kMOzEHCu28cBGa7y5aJ+xw/xt5E8uYRhi2e7vJLer3ExMF2SXdJBDkLHRYWSzywNdRhLEYo0wGoLZCaWBMRnDOZDQ1wXI4y7IgCng== 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=0t8LMyxHaP2kl7/Dbfr610HjSp+BcW6EUg2e2egGqsk=; b=R4n2TTwGvpE08/kvyoNGT1gvUTq7NDs4o3YiO2UGoLLuBmXrZjOq4F45ciFGLrKeSdxwAdEKQ3SBNmQe75XmEChV3izH82Xe/Uy5RBC2ItV7T7ABnaADKmdXr0trp+SatF4BXLRYxEsmVR4nhjjxRlk38EP+5KFeRq1UnqZhvKgzVGrSN//Uq8TwU+bEe1Lz/fa39md/lkL2+WUJYY8qZl1FUDvXpVun5A9F42Q9kOSWseYhEwd6zIrYONeA8Hek+p3Ofq/T+V713hGFjD2G8QpPQhYgiJr3WVlcqz5G8UpSDLFu30VFlkfjBovMgQHdMH9Ye+FfTXPBGd3qUPlm/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Wed, 1 Dec 2021 10:40:24 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: [PATCH 2/4] VT-d / x86: re-arrange cache syncing Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Paul Durrant , Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Kevin Tian References: <5d72c629-fabf-3d40-aa19-d177826fdde5@suse.com> In-Reply-To: <5d72c629-fabf-3d40-aa19-d177826fdde5@suse.com> X-ClientProxiedBy: FR2P281CA0020.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::7) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1b9d5ddd-7e77-4c67-b398-08d9b4ae9ab2 X-MS-TrafficTypeDiagnostic: VI1PR04MB3293: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vbcnGYpe9bLgLDUKvSGZ2hOcp/dEj/qbF95TeMb364lbYxvcz3G7A60zawJ4Bqc14Z3P3N+QGwRTM6woZie41/uzfVwlKmKOIBEKmwOhpKv9gp+FC2MTPiJ1OrkBgGmbDqKNBSpz0HaFbGZHRwZ0gl0VxVkiNa3GGayJ9dOz1Zb4KNcsr0n/g0pKsM8mmeIBo3Gk5U/zBvbrGoD+jrvw09285v7NDkLYamLCSSdr5BtvSLW2ZJgk8/xoJcUJfhei0Y/lL+MxH0KLzkF3HfAbaQleB/2nkMcY+JVgs3MIdyYPT3yx93tzWFidCIMka7B5xByWGRt8iVanpqMwNrIcPnuuZPYtWeddPYpv/bY5kDzf+JpZFqMuD5WLS3lmRHOEx2XVoA+NB7zEtFtyWJSGhK47EI4qUvuYElocdeMfsHP9EsSVEfELoFMWflIliI30PQG6bc2TLjGZtEUgg67W68+0sQ5RmZmPjvzJxSjqiQqI3xTgCHm9VC6/GxspP+2CybP5J03+qwE37ITTRgAAHuoWIqHDVjS648H8YZovovqXQBj9bW7f+YfzBkWhhw4MU61/P90PpcP74BaDnhZuWAQ09Aoy3Ji6mvLn/cZI3CGZpSFbMYUnR24S0qrP7aiR0WUP/QHK3Q5mkPdwFsx4l2LcueAeMzB+EFsr6Wq4g4KeLErvN0IcgClrr2GJO9603QcYhTMC8DiyWJNOV5l8dwrh1k4YJGhGCV0Bu4bMCiqvb+dcApfyPcEbqYErOct9 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(83380400001)(2906002)(26005)(66946007)(4326008)(2616005)(66476007)(956004)(38100700002)(8676002)(86362001)(186003)(8936002)(5660300002)(31696002)(31686004)(16576012)(66556008)(6916009)(316002)(6486002)(36756003)(54906003)(508600001)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 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8/c/aRHnIzl3X92v42yQXyK1EbzB1nLcmX70kGx71zm23djVdaYKFp/ijmb70n0?= =?utf-8?q?dkukBA96M0aYpiNNj34LYQeJjUjXGRrMWm/2G1JISnIDdDBsO2TBZQeAKZWXAfNMy?= =?utf-8?q?tvJBiPiEyqNvhuMaHWd73V+dE10VXU8NDKIR2OA5f2V5cwFTwm2JZv1ik+1KbXc+U?= =?utf-8?q?PPqDbfeWV50XG7o1FBmtI1DCuMlt/yW3zWBUUmPI/2k04IshqfiJISHq/tPiBY/YN?= =?utf-8?q?5TF4I9xIBumVcIQ0+Nd53E1BNCQv50Rv1CQtPpX6iFfqgHXcaLnlOLubIwaMVrjeo?= =?utf-8?q?884kW/GGGuwWwEmSssPA5EmNiDFQYQsyr+WX1L3zf5UrIRK6DyYCnVuRAaCPtmgzd?= =?utf-8?q?yjfH1zWS0tcS7A9KNpG7uRLIm193859k7NzrqCHUpsGINrDBDDojMjr6WWd24y8ji?= =?utf-8?q?tejuReeeZntw2g2/65fHxthgzShIskrFyot9DcGiP3bh2RdlPX6c5NdyaaWtWTnXx?= =?utf-8?q?Zn7WVpyU3QQ6Hhsm9fTANQM9NpnMBKfZCLpJbfbYKVObVDatM78pc1Nx9NQQI3kRo?= =?utf-8?q?kWhiRdT2uYnNsXPqq1/qwddClvjSxIgxf5U12exT1maCizB01zFw5xCFjzZDEjWg+?= =?utf-8?q?ePGApDw6hLrKh/yk+p7mUPr5AKxqYbipSPzUD6/R5FjS+PUlQbKhlKJ5xa+LplU1c?= =?utf-8?q?nirugcBM7/aOKnlEVUW2Ydr/Lu0mpwU4TAwEg4mRA1rdnAy6TQ7FeT8=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1b9d5ddd-7e77-4c67-b398-08d9b4ae9ab2 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2021 09:40:26.3696 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6Wz+LTp+1WdQ0+SraFh5OHLf18oPjNnt9Vaor7etwSnEJuGV0wXLXc/wAXkC1yrmCEBhEjobtlrO1CpzLCqMJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3293 The actual function should always have lived in core x86 code; move it there, replacing get_cache_line_size() by readily available (except very early during boot; see the code comment) data. Drop the respective IOMMU hook, (re)introducing a respective boolean instead. Replace a true and an almost open-coding instance of iommu_sync_cache(). Signed-off-by: Jan Beulich --- Placing the function next to flush_area_local() exposes a curious asymmetry between the SFENCE placements: sync_cache() has it after the flush, while flush_area_local() has it before it. I think the latter one is misplaced. --- a/xen/arch/x86/flushtlb.c +++ b/xen/arch/x86/flushtlb.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -265,6 +266,57 @@ unsigned int flush_area_local(const void return flags; } +void sync_cache(const void *addr, unsigned int size) +{ + /* + * This function may be called before current_cpu_data is established. + * Hence a fallback is needed to prevent the loop below becoming infinite. + */ + unsigned int clflush_size = current_cpu_data.x86_clflush_size ?: 16; + const void *end = addr + size; + + addr -= (unsigned long)addr & (clflush_size - 1); + for ( ; addr < end; addr += clflush_size ) + { +/* + * The arguments to a macro must not include preprocessor directives. Doing so + * results in undefined behavior, so we have to create some defines here in + * order to avoid it. + */ +#if defined(HAVE_AS_CLWB) +# define CLWB_ENCODING "clwb %[p]" +#elif defined(HAVE_AS_XSAVEOPT) +# define CLWB_ENCODING "data16 xsaveopt %[p]" /* clwb */ +#else +# define CLWB_ENCODING ".byte 0x66, 0x0f, 0xae, 0x30" /* clwb (%%rax) */ +#endif + +#define BASE_INPUT(addr) [p] "m" (*(const char *)(addr)) +#if defined(HAVE_AS_CLWB) || defined(HAVE_AS_XSAVEOPT) +# define INPUT BASE_INPUT +#else +# define INPUT(addr) "a" (addr), BASE_INPUT(addr) +#endif + /* + * Note regarding the use of NOP_DS_PREFIX: it's faster to do a clflush + * + prefix than a clflush + nop, and hence the prefix is added instead + * of letting the alternative framework fill the gap by appending nops. + */ + alternative_io_2(".byte " __stringify(NOP_DS_PREFIX) "; clflush %[p]", + "data16 clflush %[p]", /* clflushopt */ + X86_FEATURE_CLFLUSHOPT, + CLWB_ENCODING, + X86_FEATURE_CLWB, /* no outputs */, + INPUT(addr)); +#undef INPUT +#undef BASE_INPUT +#undef CLWB_ENCODING + } + + alternative_2("", "sfence", X86_FEATURE_CLFLUSHOPT, + "sfence", X86_FEATURE_CLWB); +} + unsigned int guest_flush_tlb_flags(const struct domain *d) { bool shadow = paging_mode_shadow(d); --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -202,54 +202,6 @@ static void check_cleanup_domid_map(stru } } -static void sync_cache(const void *addr, unsigned int size) -{ - static unsigned long clflush_size = 0; - const void *end = addr + size; - - if ( clflush_size == 0 ) - clflush_size = get_cache_line_size(); - - addr -= (unsigned long)addr & (clflush_size - 1); - for ( ; addr < end; addr += clflush_size ) -/* - * The arguments to a macro must not include preprocessor directives. Doing so - * results in undefined behavior, so we have to create some defines here in - * order to avoid it. - */ -#if defined(HAVE_AS_CLWB) -# define CLWB_ENCODING "clwb %[p]" -#elif defined(HAVE_AS_XSAVEOPT) -# define CLWB_ENCODING "data16 xsaveopt %[p]" /* clwb */ -#else -# define CLWB_ENCODING ".byte 0x66, 0x0f, 0xae, 0x30" /* clwb (%%rax) */ -#endif - -#define BASE_INPUT(addr) [p] "m" (*(const char *)(addr)) -#if defined(HAVE_AS_CLWB) || defined(HAVE_AS_XSAVEOPT) -# define INPUT BASE_INPUT -#else -# define INPUT(addr) "a" (addr), BASE_INPUT(addr) -#endif - /* - * Note regarding the use of NOP_DS_PREFIX: it's faster to do a clflush - * + prefix than a clflush + nop, and hence the prefix is added instead - * of letting the alternative framework fill the gap by appending nops. - */ - alternative_io_2(".byte " __stringify(NOP_DS_PREFIX) "; clflush %[p]", - "data16 clflush %[p]", /* clflushopt */ - X86_FEATURE_CLFLUSHOPT, - CLWB_ENCODING, - X86_FEATURE_CLWB, /* no outputs */, - INPUT(addr)); -#undef INPUT -#undef BASE_INPUT -#undef CLWB_ENCODING - - alternative_2("", "sfence", X86_FEATURE_CLFLUSHOPT, - "sfence", X86_FEATURE_CLWB); -} - /* Allocate page table, return its machine address */ uint64_t alloc_pgtable_maddr(unsigned long npages, nodeid_t node) { @@ -268,8 +220,7 @@ uint64_t alloc_pgtable_maddr(unsigned lo clear_page(vaddr); - if ( (iommu_ops.init ? &iommu_ops : &vtd_ops)->sync_cache ) - sync_cache(vaddr, PAGE_SIZE); + iommu_sync_cache(vaddr, PAGE_SIZE); unmap_domain_page(vaddr); cur_pg++; } @@ -1295,7 +1246,7 @@ int __init iommu_alloc(struct acpi_drhd_ iommu->nr_pt_levels = agaw_to_level(agaw); if ( !ecap_coherent(iommu->ecap) ) - vtd_ops.sync_cache = sync_cache; + iommu_non_coherent = true; /* allocate domain id bitmap */ nr_dom = cap_ndoms(iommu->cap); --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -28,6 +28,7 @@ const struct iommu_init_ops *__initdata iommu_init_ops; struct iommu_ops __read_mostly iommu_ops; +bool __read_mostly iommu_non_coherent; enum iommu_intremap __read_mostly iommu_intremap = iommu_intremap_full; @@ -435,8 +436,7 @@ struct page_info *iommu_alloc_pgtable(st p = __map_domain_page(pg); clear_page(p); - if ( hd->platform_ops->sync_cache ) - iommu_vcall(hd->platform_ops, sync_cache, p, PAGE_SIZE); + iommu_sync_cache(p, PAGE_SIZE); unmap_domain_page(p); --- a/xen/include/asm-x86/cache.h +++ b/xen/include/asm-x86/cache.h @@ -11,4 +11,10 @@ #define __read_mostly __section(".data.read_mostly") +#ifndef __ASSEMBLY__ + +void sync_cache(const void *addr, unsigned int size); + +#endif + #endif --- a/xen/include/asm-x86/iommu.h +++ b/xen/include/asm-x86/iommu.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -134,12 +135,13 @@ extern bool untrusted_msi; int pi_update_irte(const struct pi_desc *pi_desc, const struct pirq *pirq, const uint8_t gvec); -#define iommu_sync_cache(addr, size) ({ \ - const struct iommu_ops *ops = iommu_get_ops(); \ - \ - if ( ops->sync_cache ) \ - iommu_vcall(ops, sync_cache, addr, size); \ -}) +extern bool iommu_non_coherent; + +static inline void iommu_sync_cache(const void *addr, unsigned int size) +{ + if ( iommu_non_coherent ) + sync_cache(addr, size); +} int __must_check iommu_free_pgtables(struct domain *d); struct page_info *__must_check iommu_alloc_pgtable(struct domain *d); --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -268,7 +268,6 @@ struct iommu_ops { int (*setup_hpet_msi)(struct msi_desc *); int (*adjust_irq_affinities)(void); - void (*sync_cache)(const void *addr, unsigned int size); void (*clear_root_pgtable)(struct domain *d); int (*update_ire_from_msi)(struct msi_desc *msi_desc, struct msi_msg *msg); #endif /* CONFIG_X86 */ --- a/xen/drivers/passthrough/vtd/extern.h +++ b/xen/drivers/passthrough/vtd/extern.h @@ -76,7 +76,6 @@ int __must_check qinval_device_iotlb_syn struct pci_dev *pdev, u16 did, u16 size, u64 addr); -unsigned int get_cache_line_size(void); void flush_all_cache(void); uint64_t alloc_pgtable_maddr(unsigned long npages, nodeid_t node); --- a/xen/drivers/passthrough/vtd/x86/vtd.c +++ b/xen/drivers/passthrough/vtd/x86/vtd.c @@ -47,11 +47,6 @@ void unmap_vtd_domain_page(const void *v unmap_domain_page(va); } -unsigned int get_cache_line_size(void) -{ - return ((cpuid_ebx(1) >> 8) & 0xff) * 8; -} - void flush_all_cache() { wbinvd(); From patchwork Wed Dec 1 09:41:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12649621 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 28F43C433F5 for ; Wed, 1 Dec 2021 09:41:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.235740.408926 (Exim 4.92) (envelope-from ) id 1msM75-0002Ua-AJ; Wed, 01 Dec 2021 09:41:19 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 235740.408926; Wed, 01 Dec 2021 09:41:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1msM75-0002UT-73; Wed, 01 Dec 2021 09:41:19 +0000 Received: by outflank-mailman (input) for mailman id 235740; Wed, 01 Dec 2021 09:41:18 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1msM74-0002Tk-1m for xen-devel@lists.xenproject.org; Wed, 01 Dec 2021 09:41:18 +0000 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.109.102]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d4e1dd3d-528a-11ec-976b-d102b41d0961; Wed, 01 Dec 2021 10:41:17 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2106.outbound.protection.outlook.com [104.47.17.106]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-9-9ZBsNzQUM6efcr40Flw50g-2; Wed, 01 Dec 2021 10:41:16 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB3293.eurprd04.prod.outlook.com (2603:10a6:802:11::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.20; Wed, 1 Dec 2021 09:41:15 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::5951:a489:1cf0:19fe]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::5951:a489:1cf0:19fe%5]) with mapi id 15.20.4734.024; Wed, 1 Dec 2021 09:41:15 +0000 Received: from [10.156.60.236] (37.24.206.209) by AM6P191CA0085.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:8a::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.20 via Frontend Transport; Wed, 1 Dec 2021 09:41:14 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d4e1dd3d-528a-11ec-976b-d102b41d0961 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1638351677; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YQb8+AjKpTlqHxQEbPICVBl2jBxSIOPQK4afq3ep8dk=; b=gBL7HPi+uQKtp9dggUR45iAuVuYQvjhOSVm9apdaopdjRqfpJC5P342wKduU5vWwaSgX6A bLbNLbjOTygxNOQa/LSjLGweTeaYiSPE1Q/rd2HM6Vc7d/cG62Un7B5ITgCF6FLtdH+8eY 6KgOjOV97CYNveFsD+vdCD4TOfpKkSw= X-MC-Unique: 9ZBsNzQUM6efcr40Flw50g-2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lfoVbzO/ko4dBRljbNZGMp63s2JkDVV+D3nzcuABMVdpmMbCiXb5Ol1VqiDOSRGni2Kn5ShQ2tsxwEmq+EK6DQab6MP/dl8fGLBznyRO/peGaT2HjlZ4txcU9g5Q3v+X2N0JLCBi7qCkug5zxybfXXCoOINLgLuXBVFuoMsYtC1O6ogVPJ46gXdX4x8kKHXMx4bJGOsAgF+17bCEH+z50p/KpdExqzkEdIJqb2b8G/ftW/qdcH3kbvDNB88DV8ee1PlAfv1PtP2+i3aHaiHCne3QSkhm+yeKtz9+H8EFnhgLTO9jG4gYHrAJvAQ1q7ZqTOwiTedgzk4eBd1EeZhPwA== 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=YQb8+AjKpTlqHxQEbPICVBl2jBxSIOPQK4afq3ep8dk=; b=gynYJcla0lZVDrhK7UGm7GJYTZ+pRvk0SzVH6tvyjPHVS7+tBKORaZc53gQnGBY0gD+oBPXz22APCfKt1V+rLeZmiKmDsk/MKE47xKiTmkFLiN99eYNThK8fPZgqLvmYf3f5JRvsuHIeHagDFLajDkYeNOM6Kov+b1bjPQxHqAIaKh0F7NIR1yTLI5DrcbYDPCbUGM91Uearx/tOHwrAkKb/XDsoHsTqoxWt+83COGM5M5q5J+LEw8EhsYF05n3kaug1BMQB5WZPkWWdslbEfo5TjQfA/mR7g0bJ3iEQJbDyuGAutpcC2UiDP0TCF2V/tnchAkkiijCz6qjPvXYE8A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <8a8dd03a-5447-bc45-1554-50fb5b6c075c@suse.com> Date: Wed, 1 Dec 2021 10:41:13 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: [PATCH 3/4] VT-d: replace flush_all_cache() Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Paul Durrant , Kevin Tian References: <5d72c629-fabf-3d40-aa19-d177826fdde5@suse.com> In-Reply-To: <5d72c629-fabf-3d40-aa19-d177826fdde5@suse.com> X-ClientProxiedBy: AM6P191CA0085.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:8a::26) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d9fb6998-eae4-4113-c0bb-08d9b4aeb7b6 X-MS-TrafficTypeDiagnostic: VI1PR04MB3293: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1468; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LZ10LFIP6hF7O5c13TaJATFutts0Ts5fEnannys3tvE19r5VaeVYtz35XOSvdkQFL4JG8QlMesHrggWvr1QFzywSNnn55Js6CJXyQQzSJw40yosuT8DlBSJzvokRf7QBTbT2C9UYt8SlmGI24OpB7y9SV6puroLmdHNJA64w2icuwna9gJkPlzkF5oc2QB3Hkg/cr/V7i8eRJR871uAfyS5oeFSrC4G9Tp1/PDhF3S0CI4nr8wR1633ZoE5T2bd8EkGRhxEwe+GsugcEMiFaXEpGfzvI/h0edOiug6m4hw38LVA7CbrYP9bQE+F7SF6ptULhLlySU0tEqR6VOwGR3/7KzaoymAwyO9ZCDC/+dwaDYF0nznv2j48TmwCL9Uryh5IduDl+vpx3EHQ2GCb2ru6Ps1wgTe5OTXjAHA78LLHF2vTjiaoLK7sYEvhuh6TMYudyZf0a9Es8uZCc0eriPNi5ORt4edON54y3oiDfxlhPwmrb84XROIb4KBEhuceOWCpqDiJ37TzZpIg2tH/MnUo6iMTaQzZHJ5ExkEFEMO/YeSAZkctuqzyigC6Vha7HW0ntS3uM5a/20xV227iz6D+OohOOQjL6IuX921T4rgj8flMFC6yV7/Az6dT1xLjWf/tWfQ9OfDiBC/P667baBD2BTDhL4fUm/KRwh3Ykh2aKy5FSiEHsy9wrzse1dEjoRui91wn3iYXNgQXAh66txyo/gRM/h8Ik9YpIKaGkpu10A84PoW/mvOAiOBTJbpjM X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(2906002)(26005)(66946007)(4326008)(2616005)(66476007)(956004)(38100700002)(8676002)(86362001)(186003)(8936002)(5660300002)(31696002)(31686004)(16576012)(66556008)(6916009)(316002)(6486002)(36756003)(54906003)(508600001)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?qyvs7tKStyA/ZS/gFp6RM62aBJWg?= =?utf-8?q?M7xdTm4lDCdfimow1ce50JZNftVWX9NETc2Oeilz0whJflgrPP5CYbhGcLqVHMWiN?= =?utf-8?q?yp+yuZdnPUy1IAAs/FGHg7fd7jF4zd6ibnGBw+ab5868hlJ0c8ZsIvifODEMZKGEk?= =?utf-8?q?5ezXBG/OGfBAcoWgtqWgqBndRk21KjqQzAz3yvq4v7F/LK1Zet4SM002V96xpZGsq?= =?utf-8?q?V+e7BEwC+7VZ1oLcdf4yyuKvStBUsHT4Er+azGfo6KujO3kCVcui/c/dqPpCRufmo?= =?utf-8?q?rWlRHc/B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ue+21qMEhNwxMRsdDplyJmT3GB8cxSfkyAkatNd/XWRvEFkglLKwgSeA8VKe36YvU?= =?utf-8?q?gfrPtMPYhbArQXzLYwS5jORYxmzb2h9xbDL8EDAxjnUXRLAb6QhvHEbzSEoQxLYcg?= =?utf-8?q?CoY6s6hgSj1gX5AzEse+7nCXMZ8lkicoJWoeBnvSVqfvNICLG9Jwsop/uuFHQt7bJ?= =?utf-8?q?TBdmF7pmtKLYiC5BrW0ozVNyjggdumZzcxD4ljH4zMIcOK2XaSAltNHCW1OuZkfoH?= =?utf-8?q?CRlUpLL/sOkhPmYDZU9Ni032X9CJmS1J1gvSvYJ88ZT8ztqDxmfFc53T6DQmkV7BV?= =?utf-8?q?xwSlG9/ELF4uhYyzdsEqo3oFgsZo9mKvIjGx78eUslk8kDj6dz7coYgvoLiniUbZW?= =?utf-8?q?vLe7fHjAGVgL9ja1S5x4ML/sczfWkAeHn6FJBQ4n/0ad3MkNF9Bd3tQ=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: d9fb6998-eae4-4113-c0bb-08d9b4aeb7b6 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2021 09:41:15.0561 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jkV+1HSBmRRzcgFT1KMfSEMMKF2qrKtlOw7kQBLNxSEkFtv99O8lN7EKS6IeqxWO8QztloK4UazqXbSycM74SQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3293 Let's use infrastructure we have available instead of an open-coded wbinvd() invocation. Signed-off-by: Jan Beulich --- a/xen/drivers/passthrough/vtd/extern.h +++ b/xen/drivers/passthrough/vtd/extern.h @@ -76,8 +76,6 @@ int __must_check qinval_device_iotlb_syn struct pci_dev *pdev, u16 did, u16 size, u64 addr); -void flush_all_cache(void); - uint64_t alloc_pgtable_maddr(unsigned long npages, nodeid_t node); void free_pgtable_maddr(u64 maddr); void *map_vtd_domain_page(u64 maddr); --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -591,7 +591,8 @@ static int __must_check iommu_flush_all( bool_t flush_dev_iotlb; int rc = 0; - flush_all_cache(); + flush_local(FLUSH_CACHE); + for_each_drhd_unit ( drhd ) { int context_rc, iotlb_rc; --- a/xen/drivers/passthrough/vtd/x86/vtd.c +++ b/xen/drivers/passthrough/vtd/x86/vtd.c @@ -46,8 +46,3 @@ void unmap_vtd_domain_page(const void *v { unmap_domain_page(va); } - -void flush_all_cache() -{ - wbinvd(); -} From patchwork Wed Dec 1 09:42:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12649625 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9C508C433F5 for ; Wed, 1 Dec 2021 09:43:03 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.235751.408948 (Exim 4.92) (envelope-from ) id 1msM8R-0003jP-42; Wed, 01 Dec 2021 09:42:43 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 235751.408948; Wed, 01 Dec 2021 09:42:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1msM8R-0003jI-0f; Wed, 01 Dec 2021 09:42:43 +0000 Received: by outflank-mailman (input) for mailman id 235751; Wed, 01 Dec 2021 09:42:41 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1msM8P-0003j4-KW for xen-devel@lists.xenproject.org; Wed, 01 Dec 2021 09:42:41 +0000 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.111.102]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0686af80-528b-11ec-976b-d102b41d0961; Wed, 01 Dec 2021 10:42:40 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2110.outbound.protection.outlook.com [104.47.17.110]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-28-t941qyhqN5yhiYhLe5q79Q-1; Wed, 01 Dec 2021 10:42:39 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB5598.eurprd04.prod.outlook.com (2603:10a6:803:e9::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23; Wed, 1 Dec 2021 09:42:38 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::5951:a489:1cf0:19fe]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::5951:a489:1cf0:19fe%5]) with mapi id 15.20.4734.024; Wed, 1 Dec 2021 09:42:37 +0000 Received: from [10.156.60.236] (37.24.206.209) by AS9PR06CA0180.eurprd06.prod.outlook.com (2603:10a6:20b:45c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.22 via Frontend Transport; Wed, 1 Dec 2021 09:42:37 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 0686af80-528b-11ec-976b-d102b41d0961 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1638351760; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yCxKdOv38xfLsrtBhC68T2KY7VJQHeYtb/l3qTS1wqQ=; b=AFswq5f2MApeqBz8RKrPYv8wqIFThtqZQStl0hXrup1+ULwuNgnPaR+wO2QEgG9bOzPvYO iIvmiP77Ldl5rXJORz6/KVLJ0S8q7BhwWNjlgr0f9ezOI90Ebufgdyivl2BhHnXy+N2S7i pIdjyQxy0Jcpitp0nLM5ICQpNfm2ssI= X-MC-Unique: t941qyhqN5yhiYhLe5q79Q-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A1vCqNXhxuJy11f+B+U5t1B/YsF3LFMrnvY1mCw3ESIDUzJSYlbmylwqxICqZ0tsKzeqeZCGZ4Z9+ot/nNEqo7xrxG6MavhNSEF7fUAifiBEcwMRXeM+mKm2DwFGl6B9Tg/3YGoztdSq2nCdH5BtmH799rvCqbzFSEXfJm1Y14O9Vwqsl2rDkpy/muaVfh3eiXr5aBrTXXAXWSBviHN/ql7m2CbFP9rasXUHMsYJ+SGAzFb1+NgtxtT37dBrtH3Gn/YNVufKHDaLh5Eg90uLrzDrryzKz73Mu4wcjRg9H6+AqOnYjgTJShX7GA4XIfdOJFQNoF33VkJmpvdbXCr8RA== 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=yCxKdOv38xfLsrtBhC68T2KY7VJQHeYtb/l3qTS1wqQ=; b=fOC+V8VD3lwTebnBrLtgPkNWRDMoywZJFKwty34wmbeXI9wZAA1NkjVqZ+yp5M/i9sMySYkJ+vqAYMhbCLig3ny2SWvtHcE84RY42EwG4lrdxOwxOU+FlCDVBWM0scJZPvgz167iyG8w2RldFgZCn5KfY2X6asDXf1boQA4Rjqw4gyLPCQMEOtvgV1bCaaUbH/faELEc6GOgiJTyEZhwJtWNt46pzWe/a+uviTvQwTETeSlt7hqPYtABPIrwFv3mQzQZLVLSU7ery0dv55WZnMTa2pHjY6z1kOGJbsoeHB02g08wumPc67gfYll3BGiVX1vSoqm0PV//GvjsYNGE5A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Wed, 1 Dec 2021 10:42:36 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: [PATCH 4/4] libxc: correct bounce direction in xc_get_device_group() Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Paul Durrant , Ian Jackson , Wei Liu , Juergen Gross References: <5d72c629-fabf-3d40-aa19-d177826fdde5@suse.com> In-Reply-To: <5d72c629-fabf-3d40-aa19-d177826fdde5@suse.com> X-ClientProxiedBy: AS9PR06CA0180.eurprd06.prod.outlook.com (2603:10a6:20b:45c::27) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5fd771e5-7128-4bb5-294f-08d9b4aee90e X-MS-TrafficTypeDiagnostic: VI1PR04MB5598: X-LD-Processed: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba,ExtFwd X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JOKdXrSKNWj89xesVVK+HwIBQC1AR5KXsCBIODEjcjcH8L5Xu/rKG7+aPSBr+QVXH1JZQGus8nqlp7L0ywd3V/vlnnzCw3yMwKeTPLoSuN8QXa5uWhWIMtXTfO9z4el7CgVigrY6Sg8dB9SxLsHZirio6KJ7pOqOudz4+rZZaTnAhT/Ei1kADK6X0xBDBW9tnEN5g2glawh92hkblfHxATQ+AjWdRfaUBPwYgNMWtGWqsMBYhkbyUMTf14Z5etzZxbWMggoNLLeVp8tCEBSjC0qL92N8+pNek52QhA+ZqMl3+udZiXVN7kw0ipObigsr3kED3dylq6y8iE7L+RuJSwhqkGQo0907Rd/+hCHar8Rl1MwCtr2Tzr2/ek53wqrSzQxau0FEmggiy0UUFpnnX6D6DphiFydfNyoqkSHCXOjVGToWzN10Pk/CDXU4xUjyJQuCeUJjbClrKnvDCll52PYi+a4DB27cK5M86Xp+4bgwRvG1x1c4NPJzwgpmH9jxi2DGe3NqqjrroKOlT3Cvz36AEhcpB0kn8dSpdaji33GlRlL+Cn3mDOPTEG2vvFgItYL/PVy8lGNLOor4DLOf2hDgfxU+bq/+amUkZhHFkrVfXbkTL/UrV6DdPbRY6U7c7BeoL6E6yPdAHq7Ral2gsBGv1KVLI3i5c2bVjg+DTMyM/L3vTgVAdJM6mDfKsAHVHmm1gnU6dSCl7eBnNa2h417Kri7qqYOX/VTBvZ4JiMo/wdITI+P3+oD+FMge4oPP X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(2616005)(6916009)(86362001)(31696002)(4744005)(6486002)(38100700002)(54906003)(508600001)(956004)(4326008)(5660300002)(26005)(107886003)(8936002)(66556008)(66946007)(8676002)(31686004)(36756003)(186003)(16576012)(66476007)(2906002)(316002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?CYnJF/hruCCsI8sYiBHngQH5MEe9?= =?utf-8?q?eQNT+G/GzuUXZ2uUVUKhIWtDSnUdjRO8BzwxPsVYv3wLTsscj3l3wHAtYcvjEVKpU?= =?utf-8?q?j5mKCCOpRjprr0hu7ZNPr6OK7+ZmOa4YdRlibFqUx+t6fT1Lo4Lg4ch0OexY0pEOp?= =?utf-8?q?LZZUiayZEWgX1FsaooIcRHyZgLcRsuLVwWE7k66k2Q5Jy4lQ1Dw7CB2XnI63gXnNf?= =?utf-8?q?Zce27S1HIidPy8de3StzCYTOGWJYT2zJvsa69xXUupJfK9WiEtBEp2l383tO4uYyu?= =?utf-8?q?G1VSZulDNE0/oNB1ufLgmcpkLXaaJqLQWAnnZSvUEGZWpK0BBMRKmuWmKfgxP3mnb?= =?utf-8?q?p9073mgM76T6jje732dsuIsWHotNHj9cqhe0MeZXRIrT1ujTpnmYQhv9VDuZhyL/A?= =?utf-8?q?A2Yms93IFuE8TqIZHqfj4Y4M+EmtuwvPF2lkvtRnUN5BjC688Fm4KPRFsvQEOMEqX?= =?utf-8?q?G5gRpkPvVXZXFZ5x73FyVUyzF0ZaG8gsAYZhls+ydgUb1C8w7C4a80vjhiqnIseMm?= =?utf-8?q?HIzcNbbjuIzT3JGDrjxX8A6tZWuOsS9tr3LHZNDjHp5bjOD4x97K9vzfwqkZ+nh2J?= =?utf-8?q?9MACnNwhcdABlNJtZXDNcYgiKTi7iWirT9Mr9qwQh/G3OltYoBXNU7XFFxaiuUr5L?= =?utf-8?q?OkqUWCKFdDFvqrfc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n+8KX0PechsoqlpsnqYeh8iz6FnrSG6suB4eL84=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5fd771e5-7128-4bb5-294f-08d9b4aee90e X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2021 09:42:37.8383 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IGRmUrEbscc16rKpbJKVNAKJmKOOeYvoadll8FfiVuepf/OxNTuD8NreqB7JXp+qKwqq/o4dlPtPmRm2TdEdrw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5598 The array of IDs is an output. Fixes: 79647c5bc9c6 ("libxc: convert domctl interfaces over to hypercall buffers") Signed-off-by: Jan Beulich Reviewed-by: Juergen Gross --- Clearly the function, including its Python wrapper, cannot have been used by anything for many years. I wonder whether that isn't good enough a reason to sanitize the layout of the array elements: Right now they have BDF in bits 8...23, when conventionally this would be bits 0...15. --- a/tools/libs/ctrl/xc_domain.c +++ b/tools/libs/ctrl/xc_domain.c @@ -1546,7 +1546,8 @@ int xc_get_device_group( { int rc; DECLARE_DOMCTL; - DECLARE_HYPERCALL_BOUNCE(sdev_array, max_sdevs * sizeof(*sdev_array), XC_HYPERCALL_BUFFER_BOUNCE_IN); + DECLARE_HYPERCALL_BOUNCE(sdev_array, max_sdevs * sizeof(*sdev_array), + XC_HYPERCALL_BUFFER_BOUNCE_OUT); if ( xc_hypercall_bounce_pre(xch, sdev_array) ) {