From nobody Fri May 3 09:56:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1672821935; cv=none; d=zohomail.com; s=zohoarc; b=eeZfyZx3nDwIkNfRUXr5tMH0klPejGMuY4pmWlCFSMBngwoCAIIqU8guEzImi6SsgVmzamkmF1IUtuW5Rq8BuIHr2q8/xdaqVuST20TpPEzmwZbBakERQ+4vgYq8T7MqZMw9H5MqSZGHvw/6NdADbAr4yJo8yOUNeby1EsG/vA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672821935; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=U41p6PerASg/ei7rzLx/hT3otWDVCdBfixYygyAySwk=; b=SzOstOEpttueK3d3OJ1cosrD7qxQA760xaGh6VZ7g9/fJo68KMy3o/3x53BGsnWzktQSs4vTgEV+f2+y5U9i7pGqk0eAOm7OLXhdvXOtKFJwRNC2lgRp6l2b+mvPt1LfmL3Vt0lQ8B0o8uISx6ne8L8DWbWOCnx3o203yF6ryac= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1672821935549136.32078077030474; Wed, 4 Jan 2023 00:45:35 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.470982.730654 (Exim 4.92) (envelope-from ) id 1pCzOZ-0008Q2-3Z; Wed, 04 Jan 2023 08:45:11 +0000 Received: by outflank-mailman (output) from mailman id 470982.730654; Wed, 04 Jan 2023 08:45:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pCzOZ-0008Pv-0s; Wed, 04 Jan 2023 08:45:11 +0000 Received: by outflank-mailman (input) for mailman id 470982; Wed, 04 Jan 2023 08:45:09 +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 1pCzOX-0008Pe-Qd for xen-devel@lists.xenproject.org; Wed, 04 Jan 2023 08:45:09 +0000 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [2a00:1450:4864:20::62e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 17e4f316-8c0c-11ed-91b6-6bf2151ebd3b; Wed, 04 Jan 2023 09:45:08 +0100 (CET) Received: by mail-ej1-x62e.google.com with SMTP id kw15so80791239ejc.10 for ; Wed, 04 Jan 2023 00:45:08 -0800 (PST) Received: from uni.router.wind (adsl-57.109.242.233.tellas.gr. [109.242.233.57]) by smtp.googlemail.com with ESMTPSA id k22-20020a170906129600b007c10fe64c5dsm15016382ejb.86.2023.01.04.00.45.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 00:45:07 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 17e4f316-8c0c-11ed-91b6-6bf2151ebd3b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=U41p6PerASg/ei7rzLx/hT3otWDVCdBfixYygyAySwk=; b=CAgRsne3K9cYsoKps2JWLBhsdMVSIAip+bDt2+YOPYqa60Nwgh5iMJu69YQh0xbaI8 61pO1+Er9QCvpY2ZfiM8RPYU1eqqYFxaKvpDkmdJvaoPA52aqLQ0KHWkTn1jIc8Z+H7R dEFEZIez3O7qkF4W/2iQ5X8WSpy+XyeMn99Jp0DC4CUj8lKYfsYv4dq4Xra+pEOeU4C8 SJaTT7Q9j3ZZOsPZqsDnEe22RbGD7o2Y3H/JmaYOM7D5Sv6mY3zy5RqMHVGSva6yqO/b zVQLZOTerGCntCmyZzk1NyBdZspKxV/Jum5qWvVGkIlmOQnjZfQqJl6ht5KYUPBtNuVX sibA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U41p6PerASg/ei7rzLx/hT3otWDVCdBfixYygyAySwk=; b=Cetd5oEilMjN4+qysv5IxONRy1hyfKs122I+0/yAR719XsB3dEyqGCRA8n2tGAw3Dv 33IwbdfNcrsjJ8sORzKIOgTY3N2VTRoHDJCy3pG5czjSwkVKUNH6/eJ0jC4dG7t3Buqd 6sowMtCDbcAQYOkW436xIm3P+/yKbfMjAucQfTxjr15I4k7dE8ZBmezjiXiFj2ERi0S/ CX8T/FaixqDCyYf4kFqcXqLzbUmK//Z0H5kGa0V67c9jnCn9CBctU8+48RXu7AqbZCQI eRWjin5ywsjSPdmErvwV2Fl+9kJZB3KGOhD6fYVEKW/3Ov2AHRvxj+gqJn6E+QaUTGVI XjJg== X-Gm-Message-State: AFqh2kr3RNrs2loScO146FnigipSbPcfY/zTdDxuHt5MQ7pkdFA0+BZI miVKnbMD6fi2NnBBu1e8vREeM8tzX38= X-Google-Smtp-Source: AMrXdXs/+Vz7qVltCpOMZdgYin4fHcD0O3cVt2uL1v+aHewb2ycGe0IGJJHzHLbfcfM3tR+DqK94yA== X-Received: by 2002:a17:907:a708:b0:82e:a59a:5c3e with SMTP id vw8-20020a170907a70800b0082ea59a5c3emr52269642ejc.10.1672821908187; Wed, 04 Jan 2023 00:45:08 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Paul Durrant , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v2 1/8] x86/iommu: introduce AMD-Vi and Intel VT-d Kconfig options Date: Wed, 4 Jan 2023 10:44:55 +0200 Message-Id: <20230104084502.61734-2-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230104084502.61734-1-burzalodowa@gmail.com> References: <20230104084502.61734-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1672821936346100006 Content-Type: text/plain; charset="utf-8" Introduce two new Kconfig options, AMD_IOMMU and INTEL_IOMMU, to allow code specific to each IOMMU technology to be separated and, when not required, stripped. AMD_IOMMU will be used to enable IOMMU support for platforms that implement the AMD I/O Virtualization Technology. INTEL_IOMMU will be used to enable IOMMU support for platforms that implement the Intel Virtualization Technology for Directed I/O. Since, at this point, disabling any of them would cause Xen to not compile, the options are not visible to the user and are enabled by default if X86. Signed-off-by: Xenia Ragiadakou Reviewed-by: Jan Beulich --- Changes in v2: - just introduce the new options but not make them selectable by the user - adjust commit message - replace CONFIG_INTEL_VTD with CONFIG_INTEL_IOMMU xen/drivers/passthrough/Kconfig | 6 ++++++ xen/drivers/passthrough/Makefile | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/xen/drivers/passthrough/Kconfig b/xen/drivers/passthrough/Kcon= fig index 479d7de57a..5c65567744 100644 --- a/xen/drivers/passthrough/Kconfig +++ b/xen/drivers/passthrough/Kconfig @@ -37,6 +37,12 @@ config IPMMU_VMSA =20 endif =20 +config AMD_IOMMU + def_bool y if X86 + +config INTEL_IOMMU + def_bool y if X86 + config IOMMU_FORCE_PT_SHARE bool =20 diff --git a/xen/drivers/passthrough/Makefile b/xen/drivers/passthrough/Mak= efile index a5efa22714..a1621540b7 100644 --- a/xen/drivers/passthrough/Makefile +++ b/xen/drivers/passthrough/Makefile @@ -1,5 +1,5 @@ -obj-$(CONFIG_X86) +=3D vtd/ -obj-$(CONFIG_X86) +=3D amd/ +obj-$(CONFIG_INTEL_IOMMU) +=3D vtd/ +obj-$(CONFIG_AMD_IOMMU) +=3D amd/ obj-$(CONFIG_X86) +=3D x86/ obj-$(CONFIG_ARM) +=3D arm/ =20 --=20 2.37.2 From nobody Fri May 3 09:56:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1672821934; cv=none; d=zohomail.com; s=zohoarc; b=NTuuKAVbEbivd/TBobi09887rUYQILAq/yxVVS6TpsjL2+juU5jUVVxovstsQXLwJSjCzevjhnCtsBGu1b+ZnooYE9D5CZuL18QOB5Dwt+MlgRD+1AN8dgGzi21qqFmibaaqcOqCz82x0qq+8yxxeSSyBp0jkiLj+c/Qvbskly8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672821934; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=C2lVOOqFcf6BKXv3+gSDIksJ5cf6q+xOsktrfoPl6c8=; b=PDwnXrtwUg5JhkCyxW7ELU/0mKsbC4OkApBF4KWbP0DqLRv/+HCqGUAY07qE3tP4duUxULn7WF4rc0jY5VY+MMAjJcW4Xdz7Y72nPIOTKsq5Rqyu6VC9gR5RS230hbn7hckiAJlCpjlda/HioLm3dxfZ0e2/PfonyPxgKRZa+Zg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1672821934717635.2415285338928; Wed, 4 Jan 2023 00:45:34 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.470984.730676 (Exim 4.92) (envelope-from ) id 1pCzOa-0000U7-J7; Wed, 04 Jan 2023 08:45:12 +0000 Received: by outflank-mailman (output) from mailman id 470984.730676; Wed, 04 Jan 2023 08:45:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pCzOa-0000Ty-Fb; Wed, 04 Jan 2023 08:45:12 +0000 Received: by outflank-mailman (input) for mailman id 470984; Wed, 04 Jan 2023 08:45:10 +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 1pCzOY-0008Pe-JR for xen-devel@lists.xenproject.org; Wed, 04 Jan 2023 08:45:10 +0000 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [2a00:1450:4864:20::633]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 188b29c4-8c0c-11ed-91b6-6bf2151ebd3b; Wed, 04 Jan 2023 09:45:09 +0100 (CET) Received: by mail-ej1-x633.google.com with SMTP id t17so80776947eju.1 for ; Wed, 04 Jan 2023 00:45:09 -0800 (PST) Received: from uni.router.wind (adsl-57.109.242.233.tellas.gr. [109.242.233.57]) by smtp.googlemail.com with ESMTPSA id k22-20020a170906129600b007c10fe64c5dsm15016382ejb.86.2023.01.04.00.45.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 00:45:08 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 188b29c4-8c0c-11ed-91b6-6bf2151ebd3b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=C2lVOOqFcf6BKXv3+gSDIksJ5cf6q+xOsktrfoPl6c8=; b=QADj/+r42GTlhqcmiLkt+4z4W4FZNfMPjZCt2fEzAMhFmYXlNRG4AeW5EmHS62VS9C deBnM3SUhDLULCartyBVBru9Rvh8jSUoTIzJUi8s+HCpOdNcvXwNp5M6aySNHtEgVHxC j+mdUyZcm71ul1fTmrg6Aj3MISpCAHrmSL0DZieRsixKoYIKfktRA6Xi4CUJKlrgWTj/ Fk/QymbzqFYez7sTp/xE0v5aPg61T3FIiqxaDEl43eiJBV+/oe9HAD4CGQOJ3wsz3Q/W VhHd6TnDqqUFHUJ5nFlG1ICvDrS10E6WOM6A3y1u6tPIFenJ+CxA3jjQG4+tfX+ZRUAO E+rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C2lVOOqFcf6BKXv3+gSDIksJ5cf6q+xOsktrfoPl6c8=; b=bMKwckyJgyQjI04+qh/AL4m67kiVYKuNouIXAQZsLVFcjsQJMZN54deKSrEP7yz7eP PHR9KD6Vibbs3ZYKNrjyWO3NBrBniyxz45do0xSdVezhBp2NW7wso6JX75lvqVHE1uua aUFPaPqEWMEL4F/DXk592LNPzGUVoddeOVd08xZSdFn7yeEqpES15mn/WCjWr5W6GZ7v udswNSW2R+N1JZZ7OkiqJa94k+Cx9EMUx/4+W7NtggasVXf0fvNswgTDayb3Bt6xAh9Q vGfz7uXH1tWhTgUunvl/EcDrcuowjOtYXo6O/7qsvHZ49FG67UKTy7h7o6IbsCUSp8y6 jWkw== X-Gm-Message-State: AFqh2kqlHzlxcE31nuMxw23xO4aC1Ww+b5vobkiBdENoaoV6s7KuBMvH 7E/nbYocRqnp6QHuoDbUgE5nMRF5zLQ= X-Google-Smtp-Source: AMrXdXvItxE5hRpoj+ycvRCaI78Q5RBjmYLhM84Rcmus0xMSC+Kut57gjsLwxguo9onjP5q5CnkkUw== X-Received: by 2002:a17:907:8b89:b0:7c1:6f86:eeb with SMTP id tb9-20020a1709078b8900b007c16f860eebmr36851095ejc.7.1672821909265; Wed, 04 Jan 2023 00:45:09 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Andrew Cooper , Paul Durrant , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v2 2/8] x86/iommu: amd_iommu_perdev_intremap is AMD-Vi specific Date: Wed, 4 Jan 2023 10:44:56 +0200 Message-Id: <20230104084502.61734-3-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230104084502.61734-1-burzalodowa@gmail.com> References: <20230104084502.61734-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1672821936338100005 Content-Type: text/plain; charset="utf-8" Move its definition to the AMD-Vi driver and use CONFIG_AMD_IOMMU to guard its usage in common code. Take the opportunity to replace bool_t with bool, __read_mostly with __ro_after_init and 1 with true. No functional change intended. Signed-off-by: Xenia Ragiadakou --- Changes in v2: - declare amd_iommu_perdev_intremap __ro_after_init - use no_config_param() to print a warning when the user sets an AMD_IOMMU specific string in the iommu boot parameter and AMD_IOMMU is disabled - remove the #ifdef CONFIG_AMD_IOMMU guard from the declaration of amd_iommu_perdev_intremap in xen/iommu.h xen/drivers/passthrough/amd/iommu_init.c | 2 ++ xen/drivers/passthrough/iommu.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/xen/drivers/passthrough/amd/iommu_init.c b/xen/drivers/passthr= ough/amd/iommu_init.c index 1f14aaf49e..9773ccfcb4 100644 --- a/xen/drivers/passthrough/amd/iommu_init.c +++ b/xen/drivers/passthrough/amd/iommu_init.c @@ -36,6 +36,8 @@ static struct radix_tree_root ivrs_maps; LIST_HEAD_READ_MOSTLY(amd_iommu_head); bool_t iommuv2_enabled; =20 +bool __ro_after_init amd_iommu_perdev_intremap =3D true; + static bool iommu_has_ht_flag(struct amd_iommu *iommu, u8 mask) { return iommu->ht_flags & mask; diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iomm= u.c index 5e2a720d29..998dfaf20d 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -58,7 +58,6 @@ bool __read_mostly iommu_hap_pt_share =3D true; #endif =20 bool_t __read_mostly iommu_debug; -bool_t __read_mostly amd_iommu_perdev_intremap =3D 1; =20 DEFINE_PER_CPU(bool_t, iommu_dont_flush_iotlb); =20 @@ -116,7 +115,11 @@ static int __init cf_check parse_iommu_param(const cha= r *s) iommu_verbose =3D 1; } else if ( (val =3D parse_boolean("amd-iommu-perdev-intremap", s, s= s)) >=3D 0 ) +#ifdef CONFIG_AMD_IOMMU amd_iommu_perdev_intremap =3D val; +#else + no_config_param("AMD_IOMMU", "amd-iommu-perdev-intremap", s, s= s); +#endif else if ( (val =3D parse_boolean("dom0-passthrough", s, ss)) >=3D = 0 ) iommu_hwdom_passthrough =3D val; else if ( (val =3D parse_boolean("dom0-strict", s, ss)) >=3D 0 ) --=20 2.37.2 From nobody Fri May 3 09:56:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1672821935; cv=none; d=zohomail.com; s=zohoarc; b=V8yv6KabdE4gwwDALXzKYYPBh/y33StkUQvAiTBVwJA7eN1f4MlVBK9vohQOHciLBdh+Xga7EEnDD5WNBCIx5B7BjIYq1MldyACvsnNKFEXu81SOKFw1y+XSETIdoyLWKBzDJK8yumcGZgRkBxkW1pBKKt55PGrjH2WzWE05px0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672821935; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FErdG0bpTyu0YrAGq/30Jx78fTnJ4dyc3jWhGGqv2No=; b=mCTtpb5cqf96J927gq5pEUdDJP2JOWyWp0WmA7W0mUXa+aK69Ab+WBWpU44RbjuFNCDv3ZyXRMmC10MzGQ/PtnFmk/qQmw8t8euBoj8Mgdo6mQSJnCoHyHUsr9SuqoJb/MnZ3y3ec+yqsLmS+3mj0kahpqfHkB3zxhSEP10bHj0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1672821935768705.8133432053971; Wed, 4 Jan 2023 00:45:35 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.470985.730687 (Exim 4.92) (envelope-from ) id 1pCzOb-0000kE-P5; Wed, 04 Jan 2023 08:45:13 +0000 Received: by outflank-mailman (output) from mailman id 470985.730687; Wed, 04 Jan 2023 08:45:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pCzOb-0000k7-Ln; Wed, 04 Jan 2023 08:45:13 +0000 Received: by outflank-mailman (input) for mailman id 470985; Wed, 04 Jan 2023 08:45:11 +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 1pCzOZ-0008Pe-JT for xen-devel@lists.xenproject.org; Wed, 04 Jan 2023 08:45:11 +0000 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [2a00:1450:4864:20::530]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 192bf692-8c0c-11ed-91b6-6bf2151ebd3b; Wed, 04 Jan 2023 09:45:10 +0100 (CET) Received: by mail-ed1-x530.google.com with SMTP id m21so47531507edc.3 for ; Wed, 04 Jan 2023 00:45:10 -0800 (PST) Received: from uni.router.wind (adsl-57.109.242.233.tellas.gr. [109.242.233.57]) by smtp.googlemail.com with ESMTPSA id k22-20020a170906129600b007c10fe64c5dsm15016382ejb.86.2023.01.04.00.45.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 00:45:10 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 192bf692-8c0c-11ed-91b6-6bf2151ebd3b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FErdG0bpTyu0YrAGq/30Jx78fTnJ4dyc3jWhGGqv2No=; b=qcSJvgIbcIVR8siwzqOdvogq8s0VHZTvIkzMO4poTEVOg2oi34sCvhNjBA68pbp6/c oDYUTImvkzAXzSsv4EEunLBJSB5/Z1RyCpcVyeiopQGkcdFGFVHZOIQGvy4sPsP7dzQ7 oIjr6PInSK5S792qgowN7s9Nkot8vOLo43qTK9FDBWi/p05O6Sex6mx/DpXc0G/1riCB Slw9YvtQRRQm5uxl1zVVddLMM4fWRYsLvX3Dqrbfvy5BG0D4uCCT+B3EL2tg1dlI3Hx9 shVf/l3/rsEHRL14qYRlbC1YAXccLTqlnn6aSv/rlynLQEkp0ECG/O04YL+r6mhV7TeT WcIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FErdG0bpTyu0YrAGq/30Jx78fTnJ4dyc3jWhGGqv2No=; b=WOXSfMjdP0o+diG+ChXXCFPZIz8E98QnYd46Ekcgy/JOTg1iGbPf91eKm3klAI5ifB ZwNOJn3cwxN16wtrStztJbRo7edBRKia0fuST+TVe5aqw3JQR2dcCjJ30VJvvcKSnRoq c4LDxjps/sIqsyXWA5e2voivb9OdWNve6haPaTmZVGsy2qkSBZuTBPjBa4ItnskIWfmE /YtPPSgn6Cok1iYcCJ3qDRvdMgofQBaTmMprUv/HNeGqAhYi5gzrfuCnCIHjLLYG32O+ Ukg2ZoHrttBUVw+j1RaGFXxw5X7Q3+17spA2TGAyy8SEJDaMFjpGIG8DLK3BSTcJqWCD JbmQ== X-Gm-Message-State: AFqh2koky4frLRCSOM61evC5KJjBts9OYBCs7yosFiloSr9rXpO/MpKl Tgbiylzf3xsKwt8/Nty7nsRP5p2A9bY= X-Google-Smtp-Source: AMrXdXtrV1AIwj0GTEIapqRqGaPwRkP//LOEvC89r7CXGAfVOJlmo1Xm/ZybUic50a87TCyZTzoBpQ== X-Received: by 2002:a05:6402:1119:b0:472:46bf:fb3c with SMTP id u25-20020a056402111900b0047246bffb3cmr39919587edv.35.1672821910348; Wed, 04 Jan 2023 00:45:10 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Paul Durrant , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v2 3/8] x86/iommu: iommu_igfx, iommu_qinval and iommu_snoop are VT-d specific Date: Wed, 4 Jan 2023 10:44:57 +0200 Message-Id: <20230104084502.61734-4-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230104084502.61734-1-burzalodowa@gmail.com> References: <20230104084502.61734-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1672821936330100003 Content-Type: text/plain; charset="utf-8" Use CONFIG_INTEL_IOMMU to guard their usage in common code. No functional change intended. Signed-off-by: Xenia Ragiadakou --- Changes in v2: - replace CONFIG_INTEL_VTD with CONFIG_INTEL_IOMMU xen/drivers/passthrough/iommu.c | 4 +++- xen/include/xen/iommu.h | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iomm= u.c index 998dfaf20d..a2c67a17cd 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -82,11 +82,13 @@ static int __init cf_check parse_iommu_param(const char= *s) else if ( ss =3D=3D s + 23 && !strncmp(s, "quarantine=3Dscratch-pa= ge", 23) ) iommu_quarantine =3D IOMMU_quarantine_scratch_page; #endif -#ifdef CONFIG_X86 +#ifdef CONFIG_INTEL_IOMMU else if ( (val =3D parse_boolean("igfx", s, ss)) >=3D 0 ) iommu_igfx =3D val; else if ( (val =3D parse_boolean("qinval", s, ss)) >=3D 0 ) iommu_qinval =3D val; +#endif +#ifdef CONFIG_X86 else if ( (val =3D parse_boolean("superpages", s, ss)) >=3D 0 ) iommu_superpages =3D val; #endif diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 4f22fc1bed..aa924541d5 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -74,9 +74,13 @@ extern enum __packed iommu_intremap { iommu_intremap_restricted, iommu_intremap_full, } iommu_intremap; -extern bool iommu_igfx, iommu_qinval, iommu_snoop; #else # define iommu_intremap false +#endif + +#ifdef CONFIG_INTEL_IOMMU +extern bool iommu_igfx, iommu_qinval, iommu_snoop; +#else # define iommu_snoop false #endif =20 --=20 2.37.2 From nobody Fri May 3 09:56:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1672821936; cv=none; d=zohomail.com; s=zohoarc; b=IUXorAGLPb5vTffWDiv2hbYzXz2COsP/5hVu2QQWZDRsgPODidYpwmq5NUdgTwPcQVAve7XmWSEXfmQwSWf6ohBkeXmVOi/PROrNAJ4a4689zpmjEGFdaghsB5wfhCAkTCANooIJ6gb0R2FhgJaO+jSmKXRSqvL/zmNrPHON0p4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672821936; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mdM0GT8K2NEubn6wx1wh2HmFlgRPGL3ox7yjkbP2cHM=; b=FVmI7b6jBpxa+Tk6y2sHrG8RNGLP3hhpDMtlvQqxg1OPJXBEM/KkQXtXSOdA2S6T65dG2p3IBiE8E358xeUZfbYceH2GOBuw2jqirGHonKpFPwglrS6+anM+Ed4Vx1ITg4TD23W8w+8TB+0yj1tmXkGWc70FJ5JhwQUyc6lHS1M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1672821936406882.5751858920144; Wed, 4 Jan 2023 00:45:36 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.470986.730697 (Exim 4.92) (envelope-from ) id 1pCzOd-000110-1w; Wed, 04 Jan 2023 08:45:15 +0000 Received: by outflank-mailman (output) from mailman id 470986.730697; Wed, 04 Jan 2023 08:45:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pCzOc-00010r-Uz; Wed, 04 Jan 2023 08:45:14 +0000 Received: by outflank-mailman (input) for mailman id 470986; Wed, 04 Jan 2023 08:45:14 +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 1pCzOc-0008Pf-0S for xen-devel@lists.xenproject.org; Wed, 04 Jan 2023 08:45:14 +0000 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [2a00:1450:4864:20::62b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 19fa257a-8c0c-11ed-b8d0-410ff93cb8f0; Wed, 04 Jan 2023 09:45:12 +0100 (CET) Received: by mail-ej1-x62b.google.com with SMTP id u19so80869654ejm.8 for ; Wed, 04 Jan 2023 00:45:12 -0800 (PST) Received: from uni.router.wind (adsl-57.109.242.233.tellas.gr. [109.242.233.57]) by smtp.googlemail.com with ESMTPSA id k22-20020a170906129600b007c10fe64c5dsm15016382ejb.86.2023.01.04.00.45.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 00:45:11 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 19fa257a-8c0c-11ed-b8d0-410ff93cb8f0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mdM0GT8K2NEubn6wx1wh2HmFlgRPGL3ox7yjkbP2cHM=; b=IlyAPSqkdHW7+9UwD5gXGVtDULbpYhhfd0Gx3yvhyrN1hcnLLYpk/M8pLuZh3YGQA5 RsVx5uaz+bOugElYhIBMhtGc3tqbn9YBkmVDrxuCMqWWX/W5oNuPk6DW0mfx8vmvL3HF ENubWWJaVNiyKeqpPIwwuejdwmsFxhgpxr1B0qOLb/mJ/yQinsTqM9N5w7duefO33xzh CxrIrX8vsDWj7A9Pvq8nOW5W7QBLF+SVPuTuHzx+86VaMLDiZtwdhK3Musr1DWA3roXi SaRmbzkQydU5DN5adQlyaJo10MX9fRjb3UDxkTH2wFOytbtjR6qE6Ebm4ZmQd2sZty00 eE/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mdM0GT8K2NEubn6wx1wh2HmFlgRPGL3ox7yjkbP2cHM=; b=ujVkcSyvyXqPUEzNnTKz9NEDyz6evmAWdfIEWrtANAzNhQa+VFsLYIoN81nofZI6hO J9yPis4/OgPsLufkJFyLb8MMX/WTpu4KZX6q6PqcvQBsPHS9G8ApWIu3bFNlNh9aBcMd fpD75xnB0RWP9aD43mDdwSopD5WtKV3ZmHYIV0M8AsCMYzj1EeM+bySilgzzN7SznPnK qFmtD3DAsPVBdvNn9Q28pdP6jYvVofAaBCc8FTsp66rShvPRnHBfgeHrPDc8q+F0mTQ1 mkWNhLyq0c/Ku47e60sy5pQHjEeAVaxuhwAflQrUH/5/94/ASkOcTrN4MPvxXW5kbWYm o7rA== X-Gm-Message-State: AFqh2krDHKuaSvEMjWKXTJOVpOfbxAE0OgnG+FAVj0A6RLn67shxDH7h Lr6frMdaxd8qZBJkYusiGnKOga9DAT8= X-Google-Smtp-Source: AMrXdXsZZgpByDZtDx+HjsyiTiwAs0G3noW3D/xTiatDsGRWMUyXQVuGvHA8kTWk4IDuO3qsJCn9ZA== X-Received: by 2002:a17:907:20b0:b0:7d3:8159:f361 with SMTP id pw16-20020a17090720b000b007d38159f361mr40554936ejb.36.1672821911636; Wed, 04 Jan 2023 00:45:11 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , George Dunlap , Julien Grall , Stefano Stabellini Subject: [PATCH v2 4/8] x86/acpi: separate AMD-Vi and VT-d specific functions Date: Wed, 4 Jan 2023 10:44:58 +0200 Message-Id: <20230104084502.61734-5-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230104084502.61734-1-burzalodowa@gmail.com> References: <20230104084502.61734-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1672821938401100001 Content-Type: text/plain; charset="utf-8" The functions acpi_dmar_init() and acpi_dmar_zap/reinstate() are VT-d specific while the function acpi_ivrs_init() is AMD-Vi specific. To eliminate dead code, they need to be guarded under CONFIG_INTEL_IOMMU and CONFIG_AMD_IOMMU, respectively. Instead of adding #ifdef guards around the function calls, implement them as empty static inline functions. Take the opportunity to move the declarations of acpi_dmar_zap/reinstate() = to the arch specific header. No functional change intended. Signed-off-by: Xenia Ragiadakou --- Changes in v2: - replace CONFIG_INTEL_VTD with CONFIG_INTEL_IOMMU xen/arch/x86/include/asm/acpi.h | 14 ++++++++++++++ xen/include/xen/acpi.h | 3 --- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/include/asm/acpi.h b/xen/arch/x86/include/asm/acp= i.h index c453450a74..ca8529a7c8 100644 --- a/xen/arch/x86/include/asm/acpi.h +++ b/xen/arch/x86/include/asm/acpi.h @@ -140,8 +140,22 @@ extern u32 pmtmr_ioport; extern unsigned int pmtmr_width; =20 void acpi_iommu_init(void); + +#ifdef CONFIG_INTEL_IOMMU int acpi_dmar_init(void); +void acpi_dmar_zap(void); +void acpi_dmar_reinstate(void); +#else +static inline int acpi_dmar_init(void) { return -ENODEV; } +static inline void acpi_dmar_zap(void) {} +static inline void acpi_dmar_reinstate(void) {} +#endif + +#ifdef CONFIG_AMD_IOMMU int acpi_ivrs_init(void); +#else +static inline int acpi_ivrs_init(void) { return -ENODEV; } +#endif =20 void acpi_mmcfg_init(void); =20 diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h index 1b9c75e68f..82b24a5ef0 100644 --- a/xen/include/xen/acpi.h +++ b/xen/include/xen/acpi.h @@ -206,9 +206,6 @@ static inline int acpi_get_pxm(acpi_handle handle) =20 void acpi_reboot(void); =20 -void acpi_dmar_zap(void); -void acpi_dmar_reinstate(void); - #endif /* __ASSEMBLY__ */ =20 #endif /*_LINUX_ACPI_H*/ --=20 2.37.2 From nobody Fri May 3 09:56:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1672821934; cv=none; d=zohomail.com; s=zohoarc; b=ZP9ADfPx3QssJ3REEJpYVH/85ZFttw3ADhoqU5TW/7cxli4YdSx+yWVFXV0Ka3HdlD4llTAHg3s5T/t1PFBgE1hjeyUfryHmU1DkbZMOqgDupBowPBx7FyrTtu+c9cb+ghLg5A6gK89BAShsnsO3C4OWToNRGg+aWDlEC+lsY6Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672821934; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HOiaAsPMwgLoSMJypKuCfvLjyhJsFw19vxzxT5oap4g=; b=g7izaYOhIEOR38rl3rAfywWSSGkhypA6J5ExFVA8rJa1bW8We0AJIMY+mKcXSmoWbWqlad58uEr5Fs9XFY71lZXU/Ta6b4xumizbZtXoAuWqFVzPnqo5EY0jsRZTIdZBTMyPwIGS42sWdmEhViKQELXk+87wvTSnc6Hw5srRjZo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1672821934983995.9592558748116; Wed, 4 Jan 2023 00:45:34 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.470987.730702 (Exim 4.92) (envelope-from ) id 1pCzOd-00015H-GU; Wed, 04 Jan 2023 08:45:15 +0000 Received: by outflank-mailman (output) from mailman id 470987.730702; Wed, 04 Jan 2023 08:45:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pCzOd-00014l-AR; Wed, 04 Jan 2023 08:45:15 +0000 Received: by outflank-mailman (input) for mailman id 470987; Wed, 04 Jan 2023 08:45:14 +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 1pCzOc-0008Pe-2t for xen-devel@lists.xenproject.org; Wed, 04 Jan 2023 08:45:14 +0000 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [2a00:1450:4864:20::636]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1aa4181c-8c0c-11ed-91b6-6bf2151ebd3b; Wed, 04 Jan 2023 09:45:13 +0100 (CET) Received: by mail-ej1-x636.google.com with SMTP id u19so80869748ejm.8 for ; Wed, 04 Jan 2023 00:45:13 -0800 (PST) Received: from uni.router.wind (adsl-57.109.242.233.tellas.gr. [109.242.233.57]) by smtp.googlemail.com with ESMTPSA id k22-20020a170906129600b007c10fe64c5dsm15016382ejb.86.2023.01.04.00.45.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 00:45:12 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 1aa4181c-8c0c-11ed-91b6-6bf2151ebd3b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HOiaAsPMwgLoSMJypKuCfvLjyhJsFw19vxzxT5oap4g=; b=Hd2mClmwGN7qPAVe8jLCBJik7TSu6D1hwPwRA6n95halEdoHOO5XHhWX2UHU6b6QaR apkNmStPd4cT1h/6oOJnkb/2bFDjpD+nmAOI39BHYt1vVWTBte6I0MJLrQghx1ZGKZYH 8FLLbt5b7rEL4BF1k6fB2z7zni+yCr+ZaZgceCAglR7HvjajZ3HZOmmxrNPqPZ+LU0GT kw1GvxZdBd2btMegnuFM25MGAaBAcT7isq8D5DSD4tIGTtaG+dvJykEO446bArRtgd14 euK0j83jYn+YYNEsQoEm5ZKu4sTQXH9HcXbxEdSxRbDJlW3zA0jDLyfElaLsk4WC7okw cAbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HOiaAsPMwgLoSMJypKuCfvLjyhJsFw19vxzxT5oap4g=; b=qhbXC4niQE0bEJMxKLhBskodGjobmlzejTiuJV4czC7QGykh6ttjaAw8/b+FCf0lkZ fu1VHE8/f74MElaSd9napSDwr8UQupq9MS+Fa7U0Jv+uZlMML5yVEbVnv/pJBiWLrMJC VPscnb9hylW09GPGEG66ZS9Lhrzz42CnyVlB2YHvlN0a6GFGvJcROeLE6ouaBJx/GAeG x3oqFueBtv4gCFFWU65JUZMLt24Qf/EWcOsC5wHvcePcySIqKDEmrQBRFpGtLz0lZeyu SkIG519e3guWseIO13uk1D0AYKMjpnUZqCgoDloZXOZEuZot6QpSZJSPnif0OJJH3aqg TytQ== X-Gm-Message-State: AFqh2kr8dDdEDK+mpSxWc960O8835l4OfO9hNzRG25w2SvkBe3wtMXNc vQun9RtDy8q3MR0wmA6wy49NnX57HTU= X-Google-Smtp-Source: AMrXdXs5pE7YUspJLpR94+D/sV7BchYm34JJQ0CbAEWxWKKA/p0spj1+jbTzfVoPYDOubEeR4PhlqA== X-Received: by 2002:a17:906:39d8:b0:847:410:ecff with SMTP id i24-20020a17090639d800b008470410ecffmr34003836eje.16.1672821912776; Wed, 04 Jan 2023 00:45:12 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v2 5/8] x86/iommu: the code addressing CVE-2011-1898 is VT-d specific Date: Wed, 4 Jan 2023 10:44:59 +0200 Message-Id: <20230104084502.61734-6-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230104084502.61734-1-burzalodowa@gmail.com> References: <20230104084502.61734-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1672821936333100004 Content-Type: text/plain; charset="utf-8" The variable untrusted_msi indicates whether the system is vulnerable to CVE-2011-1898. This vulnerablity is VT-d specific. Place the code that addresses the issue under CONFIG_INTEL_IOMMU. No functional change intended. Signed-off-by: Xenia Ragiadakou --- Changes in v2: - replace CONFIG_INTEL_VTD with CONFIG_INTEL_IOMMU xen/arch/x86/include/asm/iommu.h | 2 ++ xen/arch/x86/pv/hypercall.c | 2 ++ xen/arch/x86/x86_64/entry.S | 2 ++ 3 files changed, 6 insertions(+) diff --git a/xen/arch/x86/include/asm/iommu.h b/xen/arch/x86/include/asm/io= mmu.h index fc0afe35bf..fb5fe4e1bf 100644 --- a/xen/arch/x86/include/asm/iommu.h +++ b/xen/arch/x86/include/asm/iommu.h @@ -127,7 +127,9 @@ int iommu_identity_mapping(struct domain *d, p2m_access= _t p2ma, unsigned int flag); void iommu_identity_map_teardown(struct domain *d); =20 +#ifdef CONFIG_INTEL_IOMMU extern bool untrusted_msi; +#endif =20 int pi_update_irte(const struct pi_desc *pi_desc, const struct pirq *pirq, const uint8_t gvec); diff --git a/xen/arch/x86/pv/hypercall.c b/xen/arch/x86/pv/hypercall.c index 2eedfbfae8..9d616a0fc5 100644 --- a/xen/arch/x86/pv/hypercall.c +++ b/xen/arch/x86/pv/hypercall.c @@ -193,8 +193,10 @@ void pv_ring1_init_hypercall_page(void *p) =20 void do_entry_int82(struct cpu_user_regs *regs) { +#ifdef CONFIG_INTEL_IOMMU if ( unlikely(untrusted_msi) ) check_for_unexpected_msi((uint8_t)regs->entry_vector); +#endif =20 _pv_hypercall(regs, true /* compat */); } diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S index ae01285181..8f2fb36770 100644 --- a/xen/arch/x86/x86_64/entry.S +++ b/xen/arch/x86/x86_64/entry.S @@ -406,11 +406,13 @@ ENTRY(int80_direct_trap) .Lint80_cr3_okay: sti =20 +#ifdef CONFIG_INTEL_IOMMU cmpb $0,untrusted_msi(%rip) UNLIKELY_START(ne, msi_check) movl $0x80,%edi call check_for_unexpected_msi UNLIKELY_END(msi_check) +#endif =20 movq STACK_CPUINFO_FIELD(current_vcpu)(%rbx), %rbx =20 --=20 2.37.2 From nobody Fri May 3 09:56:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1672821939; cv=none; d=zohomail.com; s=zohoarc; b=GRaLh3wsx+47r7keWKMt0+jDtMu/PJ+DWUY3dwo5ITnn6GRCQqvj1UfMKwT+38kFxvA1uaePGkp6FCHlQWL9rVX4N1lCtmobl3xeyft3vkc382JV6aPxxxnePuMtfXzk5MRIJxyZyYw9rWLKYSBk0P55Iid+NahjoiQKs6m1pRc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672821939; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Tj9i4k4Po7JyYtPs55wgOJc0qUd+pVBAioCcKA5YDiY=; b=gEZoDWLwAL60F6nP1ySkMGmqNaoRyl/HnEGq8Ri8vFeVXf6pO5ElMFSEeY/UY0ws/ymMZaa9GWUlMu1P0QKg7awNODL2xKRE2nfowJIn02Ddh/kQoaqfo8+FySKgT6pgdu9gVWvkNofw0jjcDA2iJ73MIKY3fT5pZkq1O89hETU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1672821939773182.9815985126986; Wed, 4 Jan 2023 00:45:39 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.470988.730720 (Exim 4.92) (envelope-from ) id 1pCzOg-0001dd-5g; Wed, 04 Jan 2023 08:45:18 +0000 Received: by outflank-mailman (output) from mailman id 470988.730720; Wed, 04 Jan 2023 08:45:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pCzOf-0001dC-Ux; Wed, 04 Jan 2023 08:45:17 +0000 Received: by outflank-mailman (input) for mailman id 470988; Wed, 04 Jan 2023 08:45:15 +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 1pCzOd-0008Pe-LM for xen-devel@lists.xenproject.org; Wed, 04 Jan 2023 08:45:15 +0000 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [2a00:1450:4864:20::631]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1b7c2fdb-8c0c-11ed-91b6-6bf2151ebd3b; Wed, 04 Jan 2023 09:45:14 +0100 (CET) Received: by mail-ej1-x631.google.com with SMTP id qk9so80720802ejc.3 for ; Wed, 04 Jan 2023 00:45:14 -0800 (PST) Received: from uni.router.wind (adsl-57.109.242.233.tellas.gr. [109.242.233.57]) by smtp.googlemail.com with ESMTPSA id k22-20020a170906129600b007c10fe64c5dsm15016382ejb.86.2023.01.04.00.45.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 00:45:13 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 1b7c2fdb-8c0c-11ed-91b6-6bf2151ebd3b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Tj9i4k4Po7JyYtPs55wgOJc0qUd+pVBAioCcKA5YDiY=; b=Zk+2/cbxitpP46T2xli3DDei5RXHSwU29gjuLZrqJIo5izrT20VbUgQPqJsoEFGTOc /W5fc3wv67hCfpm1t12Ko8J8tL1OoAck5uYCQR2rHRD+Y7bobdryX37MXLcS0wGOBinj sfmXg6ZATbhiMJUVaOAjzB9CpCFUWM4eatisjFSKochHLue/OZd2USvw144OzRzASLmc A2+LucMoBQ8V32eCE2nvpI01CKlieGkI7D71enXT+XQSZ/53iB11tE64UfHLtQlA7w9P Pv/+P/8KodQeSpU4MNasky3A6OTEwPnzfs1DPhQrLWke0TvD005GLTE4soIPyEHXtF97 E+DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Tj9i4k4Po7JyYtPs55wgOJc0qUd+pVBAioCcKA5YDiY=; b=R0D6QB90BGTKCxztadvHO2ADWox0M1pWIPjXtjNWIchfPIt9FWvajgtw9xU0JQZ4Px OWktcbtMchdfpmvxslO4NNsY090AgXLbs2XF049xAdPNSr+xKU9f++3MvXKRPrL6c6gk wCg16qd11ztWbwmDdeothjsD09wEywfKqWpZlln8+gtCJN5elwsBc/nG5VfdXwefzQZH DzQGK9rOsFmgtswFT83LB6cOtiO0UIs2EzaBM6boOgCspDVfA642RF09eDhrEfbStIiu IXBfKZBwpEck/0+QNAn1fOvA7fsZug1T0EK4SIfbrsfZfwyIUiyqgDDj9G4vDjo7ybiN O3eQ== X-Gm-Message-State: AFqh2koJAwLtcnLCK288w7AWUjct14CWVQp/mukFLpBCutfiP/GkcsHM C8j5CBlel7B9l7SDCZ0mhCb8HPda4SY= X-Google-Smtp-Source: AMrXdXvYf/Q/hqROtjcI4p728EDt17GV1HrYpbRwl8Wf778r0ZHaKQAZ6Auylm8M+YkwBNQ7HdOJYg== X-Received: by 2002:a17:906:a186:b0:82d:e2a6:4b0d with SMTP id s6-20020a170906a18600b0082de2a64b0dmr40816443ejy.18.1672821914148; Wed, 04 Jan 2023 00:45:14 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Jun Nakajima , Kevin Tian , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , Paul Durrant Subject: [PATCH v2 6/8] x86/iommu: call pi_update_irte through an hvm_function callback Date: Wed, 4 Jan 2023 10:45:00 +0200 Message-Id: <20230104084502.61734-7-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230104084502.61734-1-burzalodowa@gmail.com> References: <20230104084502.61734-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1672821940354100005 Content-Type: text/plain; charset="utf-8" Posted interrupt support in Xen is currently implemented only for the Intel platforms. Instead of calling directly pi_update_irte() from the common hvm code, add a pi_update_irte callback to the hvm_function_table. Then, create a wrapper function hvm_pi_update_irte() to be used by the common hvm code. In the pi_update_irte callback prototype, pass the vcpu as first parameter instead of the posted-interrupt descriptor that is platform specific, and remove the const qualifier from the parameter gvec since it is not needed and because it does not compile with the alternative code patching in use. Move the declaration of pi_update_irte() from asm/iommu.h to asm/hvm/vmx/vm= x.h since it is hvm and Intel specific. No functional change intended. Signed-off-by: Xenia Ragiadakou --- Changes in v2: - remove the definition of hvm_pi_update_irte() for !CONFIG_HVM - replace CONFIG_INTEL_VTD with CONFIG_INTEL_IOMMU xen/arch/x86/hvm/vmx/vmx.c | 10 ++++++++++ xen/arch/x86/include/asm/hvm/hvm.h | 15 +++++++++++++++ xen/arch/x86/include/asm/hvm/vmx/vmx.h | 11 +++++++++++ xen/arch/x86/include/asm/iommu.h | 3 --- xen/drivers/passthrough/x86/hvm.c | 5 ++--- 5 files changed, 38 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 43a4865d1c..cb6b325e41 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -2143,6 +2143,14 @@ static bool cf_check vmx_test_pir(const struct vcpu = *v, uint8_t vec) return pi_test_pir(vec, &v->arch.hvm.vmx.pi_desc); } =20 +static int cf_check vmx_pi_update_irte(const struct vcpu *v, + const struct pirq *pirq, uint8_t gv= ec) +{ + const struct pi_desc *pi_desc =3D v ? &v->arch.hvm.vmx.pi_desc : NULL; + + return pi_update_irte(pi_desc, pirq, gvec); +} + static void cf_check vmx_handle_eoi(uint8_t vector, int isr) { uint8_t old_svi =3D set_svi(isr); @@ -2591,6 +2599,8 @@ static struct hvm_function_table __initdata_cf_clobbe= r vmx_function_table =3D { .tsc_scaling =3D { .max_ratio =3D VMX_TSC_MULTIPLIER_MAX, }, + + .pi_update_irte =3D vmx_pi_update_irte, }; =20 /* Handle VT-d posted-interrupt when VCPU is blocked. */ diff --git a/xen/arch/x86/include/asm/hvm/hvm.h b/xen/arch/x86/include/asm/= hvm/hvm.h index 93254651f2..b3fe0663f9 100644 --- a/xen/arch/x86/include/asm/hvm/hvm.h +++ b/xen/arch/x86/include/asm/hvm/hvm.h @@ -28,6 +28,8 @@ #include #include =20 +struct pirq; /* needed by pi_update_irte */ + #ifdef CONFIG_HVM_FEP /* Permit use of the Forced Emulation Prefix in HVM guests */ extern bool_t opt_hvm_fep; @@ -250,6 +252,9 @@ struct hvm_function_table { /* Architecture function to setup TSC scaling ratio */ void (*setup)(struct vcpu *v); } tsc_scaling; + + int (*pi_update_irte)(const struct vcpu *v, + const struct pirq *pirq, uint8_t gvec); }; =20 extern struct hvm_function_table hvm_funcs; @@ -774,6 +779,16 @@ static inline void hvm_set_nonreg_state(struct vcpu *v, alternative_vcall(hvm_funcs.set_nonreg_state, v, nrs); } =20 +static inline int hvm_pi_update_irte(const struct vcpu *v, + const struct pirq *pirq, uint8_t gvec) +{ + if ( hvm_funcs.pi_update_irte ) + return alternative_call(hvm_funcs.pi_update_irte, v, pirq, gvec); + + return -EOPNOTSUPP; +} + + #else /* CONFIG_HVM */ =20 #define hvm_enabled false diff --git a/xen/arch/x86/include/asm/hvm/vmx/vmx.h b/xen/arch/x86/include/= asm/hvm/vmx/vmx.h index 96a9f07ca5..e827fece07 100644 --- a/xen/arch/x86/include/asm/hvm/vmx/vmx.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmx.h @@ -146,6 +146,17 @@ static inline void pi_clear_sn(struct pi_desc *pi_desc) clear_bit(POSTED_INTR_SN, &pi_desc->control); } =20 +#ifdef CONFIG_INTEL_IOMMU +int pi_update_irte(const struct pi_desc *pi_desc, + const struct pirq *pirq, const uint8_t gvec); +#else +static inline int pi_update_irte(const struct pi_desc *pi_desc, + const struct pirq *pirq, const uint8_t gv= ec) +{ + return -EOPNOTSUPP; +} +#endif + /* * Exit Reasons */ diff --git a/xen/arch/x86/include/asm/iommu.h b/xen/arch/x86/include/asm/io= mmu.h index fb5fe4e1bf..b432790d24 100644 --- a/xen/arch/x86/include/asm/iommu.h +++ b/xen/arch/x86/include/asm/iommu.h @@ -131,9 +131,6 @@ void iommu_identity_map_teardown(struct domain *d); extern bool untrusted_msi; #endif =20 -int pi_update_irte(const struct pi_desc *pi_desc, const struct pirq *pirq, - const uint8_t gvec); - extern bool iommu_non_coherent, iommu_superpages; =20 static inline void iommu_sync_cache(const void *addr, unsigned int size) diff --git a/xen/drivers/passthrough/x86/hvm.c b/xen/drivers/passthrough/x8= 6/hvm.c index a16e0e5344..e720461a14 100644 --- a/xen/drivers/passthrough/x86/hvm.c +++ b/xen/drivers/passthrough/x86/hvm.c @@ -381,8 +381,7 @@ int pt_irq_create_bind( =20 /* Use interrupt posting if it is supported. */ if ( iommu_intpost ) - pi_update_irte(vcpu ? &vcpu->arch.hvm.vmx.pi_desc : NULL, - info, pirq_dpci->gmsi.gvec); + hvm_pi_update_irte(vcpu, info, pirq_dpci->gmsi.gvec); =20 if ( pt_irq_bind->u.msi.gflags & XEN_DOMCTL_VMSI_X86_UNMASKED ) { @@ -672,7 +671,7 @@ int pt_irq_destroy_bind( what =3D "bogus"; } else if ( pirq_dpci && pirq_dpci->gmsi.posted ) - pi_update_irte(NULL, pirq, 0); + hvm_pi_update_irte(NULL, pirq, 0); =20 if ( pirq_dpci && (pirq_dpci->flags & HVM_IRQ_DPCI_MAPPED) && list_empty(&pirq_dpci->digl_list) ) --=20 2.37.2 From nobody Fri May 3 09:56:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1672821933; cv=none; d=zohomail.com; s=zohoarc; b=M5L2P6FC3qkrLiXO8W8S+isc0ugAxAD45aZx4N4HMtCsriJz0Q+2nyILGijAvxqlqk/AoNBllo5cYqd0u1xLpFTo9ecVsq1cdlZO529Nwf2pqNKfEM1P8p1wrVkMLCoS2ShleksjCjyqtXZE4813TKShBxceK8hvI0dCHdUMCLE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672821933; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tqo5/tDlicPu5mCxcbh6Z6IjcPc3BV3fslYWB3OSArs=; b=SRDu0DFHKTjmvaKCfnMWFraymg3UuUrgl/r1HByL1WXq05CKIB2IgFrxT0GcLsa+NlPGi9z7HUGEqhIPAgibf+84EodDJRuwiEhL0NHlFSRc7L+ptA6neqnQAbsL5OrjSzujcNMYnHGLxllyChUCYd+2lab+kK6ARLWQSl5Vt/Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1672821933152256.55150695292934; Wed, 4 Jan 2023 00:45:33 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.470989.730725 (Exim 4.92) (envelope-from ) id 1pCzOg-0001he-J4; Wed, 04 Jan 2023 08:45:18 +0000 Received: by outflank-mailman (output) from mailman id 470989.730725; Wed, 04 Jan 2023 08:45:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pCzOg-0001fz-BE; Wed, 04 Jan 2023 08:45:18 +0000 Received: by outflank-mailman (input) for mailman id 470989; Wed, 04 Jan 2023 08:45:16 +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 1pCzOe-0008Pe-KN for xen-devel@lists.xenproject.org; Wed, 04 Jan 2023 08:45:16 +0000 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [2a00:1450:4864:20::62e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1c29c3f9-8c0c-11ed-91b6-6bf2151ebd3b; Wed, 04 Jan 2023 09:45:15 +0100 (CET) Received: by mail-ej1-x62e.google.com with SMTP id kw15so80791873ejc.10 for ; Wed, 04 Jan 2023 00:45:15 -0800 (PST) Received: from uni.router.wind (adsl-57.109.242.233.tellas.gr. [109.242.233.57]) by smtp.googlemail.com with ESMTPSA id k22-20020a170906129600b007c10fe64c5dsm15016382ejb.86.2023.01.04.00.45.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 00:45:14 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 1c29c3f9-8c0c-11ed-91b6-6bf2151ebd3b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tqo5/tDlicPu5mCxcbh6Z6IjcPc3BV3fslYWB3OSArs=; b=LePRpHzDhHQjRWbDbuAHMYF8Ya6h/Nu3+/MhJyIyz06QAqOF1EVetuhx8mCgZMC887 kH7P9lgSIwn4eWBO93tmf01OzBKP4dDKVIzeOr/DpfVmuLWgRGIvYMUtgTa7YisgLZgP hn4oemUODuBnAQ5fxvN+mIWNSILJQwDbX1t+FNyMouEeOdIpJlDG/9kQdAlAsx80UlJL jTl1vRnFgs+K9AUDdy5LxW2dtzxuLLDtfPFyv45+htKGvvluZ6coAPK+sH8X0xLuVXjg UdP7pHR2LaOY4Om4f1/aSV5nvuxO0okrXOk2pJ/uSDKf7tvvuqVZZc3JdHrSVpAS7xzL yl4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tqo5/tDlicPu5mCxcbh6Z6IjcPc3BV3fslYWB3OSArs=; b=3RCtZm2Kzdh1cL0CLDS7L1jN/eOCXAthuVTJlyTy8YpW94x+Lv/8IhDYau+gKUpocY 55oTEfZMEcTYPRFx8aIqs5uZXWTN387uWzzBqQAyoJHAS3kk73L26WwIgdRnFwyXjBDS WQ2ndI9cOlM+isgbM7/GODZzKnd7Coiufs/emP8KyvNZG6YTI5FOYavD23X8ZCp7m/Bf WxUU6hixUDLhcKx0z2xB7cBrCZCqtXjzyuuj87LVZPovlAdZsCU8NUDaN+bqCP4pQkqY VBJYl4Nv5vWBVDp442llz3ZWej40bvJK3NG+QAfCUxRi0TrEHI5Up8uO8JJHKph4Mij3 cJFA== X-Gm-Message-State: AFqh2kqCh9TZv7AtNxZ8VZf5kWsFO883dmNqY96J8zpgvDz72Sb1G/IO 87pQ5//ssTfCd6fGx5mB5bgLX3BXKzc= X-Google-Smtp-Source: AMrXdXs5y3cNVYlCIU2x42F91fpieCpDGRWVHMwTv5YUoJffv5zEYYp91gCsYfg7Tg8x1q5qUj4dZw== X-Received: by 2002:a17:907:cb85:b0:7c0:f216:cc14 with SMTP id un5-20020a170907cb8500b007c0f216cc14mr40673315ejc.11.1672821915341; Wed, 04 Jan 2023 00:45:15 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Kevin Tian , Jan Beulich , Paul Durrant , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v2 7/8] x86/dpci: move hvm_dpci_isairq_eoi() to generic HVM code Date: Wed, 4 Jan 2023 10:45:01 +0200 Message-Id: <20230104084502.61734-8-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230104084502.61734-1-burzalodowa@gmail.com> References: <20230104084502.61734-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1672821934607100001 Content-Type: text/plain; charset="utf-8" The function hvm_dpci_isairq_eoi() has no dependencies on VT-d driver code and can be moved from xen/drivers/passthrough/vtd/x86/hvm.c to xen/drivers/passthrough/x86/hvm.c, along with the corresponding copyrights. Remove the now empty xen/drivers/passthrough/vtd/x86/hvm.c. Since the funcion is used only in this file, declare it static. No functional change intended. Signed-off-by: Xenia Ragiadakou Reviewed-by: Jan Beulich --- Changes in v2: - update the copyright - declare hvm_dpci_isairq_eoi() static xen/drivers/passthrough/vtd/x86/Makefile | 1 - xen/drivers/passthrough/vtd/x86/hvm.c | 64 ------------------------ xen/drivers/passthrough/x86/hvm.c | 43 ++++++++++++++++ xen/include/xen/iommu.h | 1 - 4 files changed, 43 insertions(+), 66 deletions(-) delete mode 100644 xen/drivers/passthrough/vtd/x86/hvm.c diff --git a/xen/drivers/passthrough/vtd/x86/Makefile b/xen/drivers/passthr= ough/vtd/x86/Makefile index 4ef00a4c5b..fe20a0b019 100644 --- a/xen/drivers/passthrough/vtd/x86/Makefile +++ b/xen/drivers/passthrough/vtd/x86/Makefile @@ -1,3 +1,2 @@ obj-y +=3D ats.o -obj-$(CONFIG_HVM) +=3D hvm.o obj-y +=3D vtd.o diff --git a/xen/drivers/passthrough/vtd/x86/hvm.c b/xen/drivers/passthroug= h/vtd/x86/hvm.c deleted file mode 100644 index bc776cf7da..0000000000 --- a/xen/drivers/passthrough/vtd/x86/hvm.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2008, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License f= or - * more details. - * - * You should have received a copy of the GNU General Public License along= with - * this program; If not, see . - * - * Copyright (C) Allen Kay - * Copyright (C) Weidong Han - */ - -#include -#include -#include - -static int cf_check _hvm_dpci_isairq_eoi( - struct domain *d, struct hvm_pirq_dpci *pirq_dpci, void *arg) -{ - struct hvm_irq *hvm_irq =3D hvm_domain_irq(d); - unsigned int isairq =3D (long)arg; - const struct dev_intx_gsi_link *digl; - - list_for_each_entry ( digl, &pirq_dpci->digl_list, list ) - { - unsigned int link =3D hvm_pci_intx_link(digl->device, digl->intx); - - if ( hvm_irq->pci_link.route[link] =3D=3D isairq ) - { - hvm_pci_intx_deassert(d, digl->device, digl->intx); - if ( --pirq_dpci->pending =3D=3D 0 ) - pirq_guest_eoi(dpci_pirq(pirq_dpci)); - } - } - - return 0; -} - -void hvm_dpci_isairq_eoi(struct domain *d, unsigned int isairq) -{ - struct hvm_irq_dpci *dpci =3D NULL; - - ASSERT(isairq < NR_ISAIRQS); - if ( !is_iommu_enabled(d) ) - return; - - write_lock(&d->event_lock); - - dpci =3D domain_get_irq_dpci(d); - - if ( dpci && test_bit(isairq, dpci->isairq_map) ) - { - /* Multiple mirq may be mapped to one isa irq */ - pt_pirq_iterate(d, _hvm_dpci_isairq_eoi, (void *)(long)isairq); - } - write_unlock(&d->event_lock); -} diff --git a/xen/drivers/passthrough/x86/hvm.c b/xen/drivers/passthrough/x8= 6/hvm.c index e720461a14..5043ecab9c 100644 --- a/xen/drivers/passthrough/x86/hvm.c +++ b/xen/drivers/passthrough/x86/hvm.c @@ -14,6 +14,7 @@ * this program; If not, see . * * Copyright (C) Allen Kay + * Copyright (C) Weidong Han * Copyright (C) Xiaohui Xin */ =20 @@ -924,6 +925,48 @@ static void hvm_gsi_eoi(struct domain *d, unsigned int= gsi) hvm_pirq_eoi(pirq); } =20 +static int cf_check _hvm_dpci_isairq_eoi( + struct domain *d, struct hvm_pirq_dpci *pirq_dpci, void *arg) +{ + struct hvm_irq *hvm_irq =3D hvm_domain_irq(d); + unsigned int isairq =3D (long)arg; + const struct dev_intx_gsi_link *digl; + + list_for_each_entry ( digl, &pirq_dpci->digl_list, list ) + { + unsigned int link =3D hvm_pci_intx_link(digl->device, digl->intx); + + if ( hvm_irq->pci_link.route[link] =3D=3D isairq ) + { + hvm_pci_intx_deassert(d, digl->device, digl->intx); + if ( --pirq_dpci->pending =3D=3D 0 ) + pirq_guest_eoi(dpci_pirq(pirq_dpci)); + } + } + + return 0; +} + +static void hvm_dpci_isairq_eoi(struct domain *d, unsigned int isairq) +{ + struct hvm_irq_dpci *dpci =3D NULL; + + ASSERT(isairq < NR_ISAIRQS); + if ( !is_iommu_enabled(d) ) + return; + + write_lock(&d->event_lock); + + dpci =3D domain_get_irq_dpci(d); + + if ( dpci && test_bit(isairq, dpci->isairq_map) ) + { + /* Multiple mirq may be mapped to one isa irq */ + pt_pirq_iterate(d, _hvm_dpci_isairq_eoi, (void *)(long)isairq); + } + write_unlock(&d->event_lock); +} + void hvm_dpci_eoi(struct domain *d, unsigned int guest_gsi) { const struct hvm_irq_dpci *hvm_irq_dpci; diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index aa924541d5..f08bc2a4a5 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -200,7 +200,6 @@ int hvm_do_IRQ_dpci(struct domain *, struct pirq *); int pt_irq_create_bind(struct domain *, const struct xen_domctl_bind_pt_ir= q *); int pt_irq_destroy_bind(struct domain *, const struct xen_domctl_bind_pt_i= rq *); =20 -void hvm_dpci_isairq_eoi(struct domain *d, unsigned int isairq); struct hvm_irq_dpci *domain_get_irq_dpci(const struct domain *); void free_hvm_irq_dpci(struct hvm_irq_dpci *dpci); =20 --=20 2.37.2 From nobody Fri May 3 09:56:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1672821940; cv=none; d=zohomail.com; s=zohoarc; b=NAInK0IM6ANrnMsOu6ybFomZ88AHNcpCoz9m5XtlMczkBY7ALU3P1pSyW1ziqfu6EW4Go4fiI8RCDi1lVlquTXnwHy0SDUNMReruKdmEjoalaTDtiEIgt585XOFgsmyHYQmWmi992VLPhtlY1htUkECCPmM0Li1JYnmdoGLNmzI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672821940; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DXOzrCrP8CVhczjYbqhFp6hVHdTDovyn5H+grp051f4=; b=AbmieWc9CqF4CjDxOzu/XqGP/mfilOfagIiMenH4Q/dC+H0HxAeuW0SSEZWeT9IELMFyG7PEg+LmC23ZcFVmQDkcPHLo0duers5Q9toqx0cnM/YEcNwqx45S6B1lTdhYEdYJ88kZgyz4uttuxK100k3eefuWIeL033c8PiR512s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1672821940922730.8134284040793; Wed, 4 Jan 2023 00:45:40 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.470990.730742 (Exim 4.92) (envelope-from ) id 1pCzOi-0002Fb-QC; Wed, 04 Jan 2023 08:45:20 +0000 Received: by outflank-mailman (output) from mailman id 470990.730742; Wed, 04 Jan 2023 08:45:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pCzOi-0002FP-Lr; Wed, 04 Jan 2023 08:45:20 +0000 Received: by outflank-mailman (input) for mailman id 470990; Wed, 04 Jan 2023 08:45:18 +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 1pCzOg-0008Pf-OL for xen-devel@lists.xenproject.org; Wed, 04 Jan 2023 08:45:18 +0000 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [2a00:1450:4864:20::633]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1cc9b85c-8c0c-11ed-b8d0-410ff93cb8f0; Wed, 04 Jan 2023 09:45:17 +0100 (CET) Received: by mail-ej1-x633.google.com with SMTP id ud5so81013310ejc.4 for ; Wed, 04 Jan 2023 00:45:17 -0800 (PST) Received: from uni.router.wind (adsl-57.109.242.233.tellas.gr. [109.242.233.57]) by smtp.googlemail.com with ESMTPSA id k22-20020a170906129600b007c10fe64c5dsm15016382ejb.86.2023.01.04.00.45.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 00:45:15 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 1cc9b85c-8c0c-11ed-b8d0-410ff93cb8f0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DXOzrCrP8CVhczjYbqhFp6hVHdTDovyn5H+grp051f4=; b=qeP7xCjifPj0QarjFgSOGJRU4qkTv1zwQ4edK6rTI+eSwqKg+JufxW8DXzH8md0vUK OOfmwgDfA2698SQzUCoM/5O1c3rlhV5lq3nsDZqtyGLrjNzJoKO+o5QRpQcxNdgUjSck 8pz7Y3YcWzIGlbpLWFWTq9L5GXNOVcK1wWg9EyGkQypzwYLtk824AZKDhIMFNHbzaWnZ 68ftp/Tmkt+E39dxup49sKqm1JK2p6me2q8IqsL1sof2c5x7UUqzdDNDtMhUXv64nE9D UzQabCUIHGG6hblKTyrWFfaWVz/ZO15PUiP+3ZAgHUKueM8BE57SN7F8Qr+4CmQjO7l1 Y0Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DXOzrCrP8CVhczjYbqhFp6hVHdTDovyn5H+grp051f4=; b=VK+RU3jJgk7Fahz518Wt6xzeIbT1p5HoHQiqi52dWagfvUP66BXivZ/Y3D50WvvpMa 6erQU8nTMARf6ozWTTGqgPR0mgTAmYIaviDaTh6Ko5B61WMtgoOEsy5eiwL5mjM6OJVa ApqUrF4qxhjP3TNO1DQdR8bdlKGuIumI3X0i32wHAbm8i/Nc99yJ+g7BQUXjOvy2gv1D tU+e+v8lCixSptuRdOSUbbVXXbRNypXe42DihPYm0Mo7dxhSOvLnJYK/Qz2SQmVGeK6e uawVOdmIPwUw4yf4tDDk60hioMMr9yhQU6rHCw4N5Qm6vXY2FsHXdDp96IJMETVv2c3q twtg== X-Gm-Message-State: AFqh2kqNCxHeXJVaqQ3a3bGQSm+P806m2K0IP/OHHJXv8Tz8Yl52bFeR dNQbl1oFfDjGhdbBWQQuA/Nu8fU5r7k= X-Google-Smtp-Source: AMrXdXubp/bxwGlLu0FavJ4su5iF17RcY+AXjEy9frY7aW1SYFUeDfC4LNrgH7JgZHj4KH1yH9TQ+w== X-Received: by 2002:a17:907:d389:b0:7c1:5a37:825 with SMTP id vh9-20020a170907d38900b007c15a370825mr52798189ejc.34.1672821916328; Wed, 04 Jan 2023 00:45:16 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Paul Durrant , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v2 8/8] x86/iommu: make AMD-Vi and Intel VT-d support configurable Date: Wed, 4 Jan 2023 10:45:02 +0200 Message-Id: <20230104084502.61734-9-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230104084502.61734-1-burzalodowa@gmail.com> References: <20230104084502.61734-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1672821942365100007 Content-Type: text/plain; charset="utf-8" Provide the user with configuration control over the IOMMU support by making AMD_IOMMU and INTEL_IOMMU options user selectable and able to be turned off. However, there are cases where the IOMMU support is required, for instance = for a system with more than 254 CPUs. In order to prevent users from unknowingly disabling it and ending up with a broken hypervisor, make the support user selectable only if EXPERT is enabled. To preserve the current default configuration of an x86 system, both options depend on X86 and default to Y. Signed-off-by: Xenia Ragiadakou Acked-by: Jan Beulich --- Changes in v2: - new patch that derives from patch 1/7 of v1=20 - replace --help-- with help - make the options visible if EXPERT is enabled - indicate the cases where the options need to be enabled xen/drivers/passthrough/Kconfig | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/xen/drivers/passthrough/Kconfig b/xen/drivers/passthrough/Kcon= fig index 5c65567744..864fcf3b0c 100644 --- a/xen/drivers/passthrough/Kconfig +++ b/xen/drivers/passthrough/Kconfig @@ -38,10 +38,28 @@ config IPMMU_VMSA endif =20 config AMD_IOMMU - def_bool y if X86 + bool "AMD IOMMU" if EXPERT + depends on X86 + default y + help + Enables I/O virtualization on platforms that implement the + AMD I/O Virtualization Technology (IOMMU). + + If your system includes an IOMMU implementing AMD-Vi, say Y. + This is required if your system has more than 254 CPUs. + If in doubt, say Y. =20 config INTEL_IOMMU - def_bool y if X86 + bool "Intel VT-d" if EXPERT + depends on X86 + default y + help + Enables I/O virtualization on platforms that implement the + Intel Virtualization Technology for Directed I/O (Intel VT-d). + + If your system includes an IOMMU implementing Intel VT-d, say Y. + This is required if your system has more than 254 CPUs. + If in doubt, say Y. =20 config IOMMU_FORCE_PT_SHARE bool --=20 2.37.2