From patchwork Mon Jan 10 16:25:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12708947 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 9A92FC433EF for ; Mon, 10 Jan 2022 16:25:55 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.255411.437648 (Exim 4.92) (envelope-from ) id 1n6xUE-00044H-Mq; Mon, 10 Jan 2022 16:25:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 255411.437648; Mon, 10 Jan 2022 16:25:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n6xUE-00044A-Jj; Mon, 10 Jan 2022 16:25:34 +0000 Received: by outflank-mailman (input) for mailman id 255411; Mon, 10 Jan 2022 16:25:33 +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 1n6xUD-000444-B0 for xen-devel@lists.xenproject.org; Mon, 10 Jan 2022 16:25:33 +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 ee7772dc-7231-11ec-81c1-a30af7de8005; Mon, 10 Jan 2022 17:25:32 +0100 (CET) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01lp2057.outbound.protection.outlook.com [104.47.1.57]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-22-D_kf8NK-OCqp2lTDk0p0Yg-1; Mon, 10 Jan 2022 17:25:31 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR0402MB3392.eurprd04.prod.outlook.com (2603:10a6:803:7::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.7; Mon, 10 Jan 2022 16:25:29 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::5951:a489:1cf0:19fe]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::5951:a489:1cf0:19fe%6]) with mapi id 15.20.4867.011; Mon, 10 Jan 2022 16:25:29 +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: ee7772dc-7231-11ec-81c1-a30af7de8005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1641831932; 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=bZDLkEqTer3O17aBOCHdhQ8xeDX9ptV5RIek8aDqpCI=; b=IrFiJhyTHGoKOz6P75OelATBvo2Ev5Of+7mwYlgBc0ofBLwh48Qj2716gQeMvQshV+K3GH L/HoMWQGdk0cDiBuTx6vpakwlaoGsYc3M/bDKjEv9HtCBfOWdslx1JbnwctmQfq3WcwmIY /uU0drBQ6ROkX2GVX769hpQGz39GidE= X-MC-Unique: D_kf8NK-OCqp2lTDk0p0Yg-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OsKngWXwq3HlJ+nCuXgfco1HTxiIWz1hu9Yt2npknBvZb14w0pFELvozv1sZZyq9fhFHccVXDFIxdWCF+EkRYRC5PbF8kSeifA6ZGsJZ+lcCtDzCsJ6T/JJLwEuT1CAZUlc9Qv8X0mOXftBcCNa7O674ZH621u8EV5KUPWyh4wEsaPdICbK5lX/NdJSjHDskgJR0mYc0rVQQnBI6su3W8bX3/XyXnJyZvhzJP4VrXvFOS+lfPPE9NlMetzQmV0CN39wr4+s6MCYfGtf8v4oFu5eBuGbfwkfNJ3THRKlRIhD9Exf3KuXnDMUWbZLwxwt7YGWOerRhXUQmMyYhyPaNvw== 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=LWxKtl2bnXWnDaf7ZhGSGx4BTSmBYb3ptYMsyNa3h1o=; b=C/JTkjBwIZI72zQF0CnxWBMsgeR3vCpyrfeynsFdpf9ndjEnpVq2T/DmOU+iUgdfBrpWui7+ihgm1JU/FdG+fU9HLdf/qqhSU5/dLFb0OgzN+kZFgtjSehNSWbemfVEY8mT+sPeIXCxSCqndkuU79EIm22S/QuWdTkaicGvzZozcCfkRzGJk0WdwW1dAEbXc3Npt3S1OTbQ5Hxasz6Puy4uD5721AZdiT+4B4SLcDaD7R5F2EAmmIWX6zzrQr7Q9ZXJGW8w8fkIysTWdowJOg9WQysPy6x5ugoQXbl6mh/zuk1rQwO6Bw8GvO00fNRqwnxXQDm+7XuWiyjuySRu+jA== 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: Mon, 10 Jan 2022 17:25:27 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 Subject: [PATCH v3 04/23] IOMMU: have vendor code announce supported page sizes Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" CC: Andrew Cooper , Paul Durrant , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Julien Grall , Rahul Singh , Kevin Tian , Bertrand Marquis , Volodymyr Babchuk References: <76cb9f26-e316-98a2-b1ba-e51e3d20f335@suse.com> In-Reply-To: <76cb9f26-e316-98a2-b1ba-e51e3d20f335@suse.com> X-ClientProxiedBy: AM5PR0301CA0032.eurprd03.prod.outlook.com (2603:10a6:206:14::45) 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: d2faa2da-e1b6-4ecf-78f0-08d9d455d0bb X-MS-TrafficTypeDiagnostic: VI1PR0402MB3392:EE_ 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: aZrei+NG9oS0T1oIG9HOCh0ND7jgu6oGoYjkLCpslztiN4368e/G9Clo1sVtvRM7z9pXbHWWvCctoOhyESnCg8ZPgvqAkDsDB/x7OAOds4TyOsNpG5HozA28iXBhjNelIO1b1h0zY0XRaeY+szsAu+VBsowoQ6dztOdAj8c4VkKrtzIqK/dAV55m6om21zakhvEf/n764p+JGF0e70+nxNEyaD2dWIwwzyOJgv6QUZb9ZOHCpMLSLG9zsyyGM0ooH7S+EImil1GAq//6ngG6+lOA1+2cbzg/YM+En5gEFVIpBHx2AbPAy8J+Vi/m0QTXWxV7LFeEnuFnG+waYJRtfZX5fPZzBeT56M3YhUvoMyD3451hgWRTbCgakG9H9I4nFad3TUGeaIf2oAHJyBYsA12A5cZnikx2kthfVHNddUDXPr77193R5JOZv37ClrDoLHrvpYFCRiXscn+zYeb5x+CHvo2Nc2qEVLC9Xzut+GtYRYc4SZfT4I7upXxl3Qm7/4xRFaOBNYdeXEmj4BKfhpIkn57Hv1CyFWivAW7otKFuUzODCMNpwgj52G/tSuWJBCF4ClHDSAvY67QQUmu5rrpKyJ4hiqIIGMGhLlu6uyrBvrMeNoTOWKzo46NiZNQ6zK9lUKjmYbQgbTkNXgnKHubH5UTrS7ec5f0VSY2IOdNGRse9xm2nD7TPl5E/aeZOcD4Inv4uiR4GqInFF4HDqKqXtuW+gdXWnRhn+s4eCTf2tSy6H0STtcCbs5k8WwAZ 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)(6512007)(66476007)(66556008)(66946007)(86362001)(8936002)(2616005)(316002)(5660300002)(508600001)(31686004)(26005)(31696002)(186003)(6916009)(38100700002)(36756003)(6506007)(8676002)(6486002)(2906002)(4326008)(54906003)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: E4Jtw7WFATYM6tldy9SEdGACQDl7iXn7y7sMa9/CO9aZakeZd86Nu5XQrkFs9hrX7pNIUQztMOiXSM53XScLJ96dCbZC1P7oFKnn47IEz6C615BBuf77OOvHUj9NSUsQkKYxyFx+iFEdl3WHK4v09uGaEQpmBRo2mZEmE2X9u0fidciBDkGe6QLjXHJCGme1oiozn+/wfUZLH2q2qN7Y/3v7gYAOS38NsEzPPSbxh0Tks2jPc6P1OK0ShwE516NoLIKUIYQGbXeELPgX9uH0D9qs+vS9Rrhw9TCe3daQPFcXClxLdF2GAPp/JukpQms5d2WJP66VZdqTDbAbLK6UCTZJKIjPvYEMbJnjBeTJztalA9D+H8ohtt2an0dXB+2Jd31MPIEiWHruUyMH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ItwmtJjvRiGVamSiyQstt7l3x9w5qUw5DJgw6pG41YmP+COfK6sMI7ENm+ufBPs+m917lLSIqbGDvd3IxnmZvjiSLkWVhdVOhJoej5vXzrx4xkNryiidv0mo4dRg2HgDEMyrxhM3nvbj8cDWUPo42PY6z5f9CYZg3cHo= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: d2faa2da-e1b6-4ecf-78f0-08d9d455d0bb X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2022 16:25:28.9971 (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: H/Uihs4ccGLLIl65xuPt3a+ZejilkpHNKkm4XvGrbOPY8xFr5NqY6ce0V0dhFFT049P3d5EEsQAubCcn6WMY/Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3392 Generic code will use this information to determine what order values can legitimately be passed to the ->{,un}map_page() hooks. For now all ops structures simply get to announce 4k mappings (as base page size), and there is (and always has been) an assumption that this matches the CPU's MMU base page size (eventually we will want to permit IOMMUs with a base page size smaller than the CPU MMU's). Signed-off-by: Jan Beulich Reviewed-by: Kevin Tian Reviewed-by: Roger Pau Monné Acked-by: Julien Grall Reviewed-by: Rahul Singh --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c @@ -629,6 +629,7 @@ static void amd_dump_page_tables(struct } static const struct iommu_ops __initconstrel _iommu_ops = { + .page_sizes = PAGE_SIZE_4K, .init = amd_iommu_domain_init, .hwdom_init = amd_iommu_hwdom_init, .quarantine_init = amd_iommu_quarantine_init, --- a/xen/drivers/passthrough/arm/ipmmu-vmsa.c +++ b/xen/drivers/passthrough/arm/ipmmu-vmsa.c @@ -1298,6 +1298,7 @@ static void ipmmu_iommu_domain_teardown( static const struct iommu_ops ipmmu_iommu_ops = { + .page_sizes = PAGE_SIZE_4K, .init = ipmmu_iommu_domain_init, .hwdom_init = ipmmu_iommu_hwdom_init, .teardown = ipmmu_iommu_domain_teardown, --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -2873,6 +2873,7 @@ static void arm_smmu_iommu_domain_teardo } static const struct iommu_ops arm_smmu_iommu_ops = { + .page_sizes = PAGE_SIZE_4K, .init = arm_smmu_iommu_domain_init, .hwdom_init = arm_smmu_iommu_hwdom_init, .add_device = arm_smmu_dt_add_device_generic, --- a/xen/drivers/passthrough/arm/smmu-v3.c +++ b/xen/drivers/passthrough/arm/smmu-v3.c @@ -3426,7 +3426,8 @@ static void arm_smmu_iommu_xen_domain_te } static const struct iommu_ops arm_smmu_iommu_ops = { - .init = arm_smmu_iommu_xen_domain_init, + .page_sizes = PAGE_SIZE_4K, + .init = arm_smmu_iommu_xen_domain_init, .hwdom_init = arm_smmu_iommu_hwdom_init, .teardown = arm_smmu_iommu_xen_domain_teardown, .iotlb_flush = arm_smmu_iotlb_flush, --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -470,7 +470,17 @@ int __init iommu_setup(void) if ( iommu_enable ) { + const struct iommu_ops *ops = NULL; + rc = iommu_hardware_setup(); + if ( !rc ) + ops = iommu_get_ops(); + if ( ops && (ops->page_sizes & -ops->page_sizes) != PAGE_SIZE ) + { + printk(XENLOG_ERR "IOMMU: page size mask %lx unsupported\n", + ops->page_sizes); + rc = ops->page_sizes ? -EPERM : -ENODATA; + } iommu_enabled = (rc == 0); } --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -2891,6 +2891,7 @@ static int __init intel_iommu_quarantine } static struct iommu_ops __initdata vtd_ops = { + .page_sizes = PAGE_SIZE_4K, .init = intel_iommu_domain_init, .hwdom_init = intel_iommu_hwdom_init, .quarantine_init = intel_iommu_quarantine_init, --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -231,6 +231,7 @@ struct page_info; typedef int iommu_grdm_t(xen_pfn_t start, xen_ulong_t nr, u32 id, void *ctxt); struct iommu_ops { + unsigned long page_sizes; int (*init)(struct domain *d); void (*hwdom_init)(struct domain *d); int (*quarantine_init)(struct domain *d);