From nobody Sat May 4 23:12:07 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=1671431756; cv=none; d=zohomail.com; s=zohoarc; b=D0Qq8qN9ZO27Qmb8KAFuPs9GMONzHVIMRKYeW9ewnurNobetO5HjVNFeiAFnVAhY5KiJOnWT4QpkXn5l4SYNwPxpGyc306rot+CNHch759RXk4L2YlwFfIcXYaa7KHQWkXeviJgRx2lA1FL/CbffywmR0atZ7L60rNmjfd023SE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671431756; 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=LTjDMyYZ2FC8KMfcNmUoTcsSKJ98IQZ5VWKAYZsCZM0=; b=bXzlJRAu19Bp5MQ9yO4yG73Q9I60v6FDCbWsTHN/rIci8o/RyYCMDks8rqFYjRl41fsqg815+LtOpcl7a6j09DNr9+WF4XeEihN0fODLqVJpwicvLV8FhCM05WBuqDcZtOMaTGV13TOQDCqkOiZBucLy4FYfzXygHSZH1WGLvfw= 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 1671431756332128.51806942041333; Sun, 18 Dec 2022 22:35:56 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.465756.724541 (Exim 4.92) (envelope-from ) id 1p79kC-0003Bn-Uv; Mon, 19 Dec 2022 06:35:24 +0000 Received: by outflank-mailman (output) from mailman id 465756.724541; Mon, 19 Dec 2022 06:35:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p79kC-0003B3-QU; Mon, 19 Dec 2022 06:35:24 +0000 Received: by outflank-mailman (input) for mailman id 465756; Mon, 19 Dec 2022 06:35:23 +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 1p79kB-000383-ON for xen-devel@lists.xenproject.org; Mon, 19 Dec 2022 06:35:23 +0000 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [2a00:1450:4864:20::62e]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 50071648-7f67-11ed-8fd4-01056ac49cbb; Mon, 19 Dec 2022 07:35:22 +0100 (CET) Received: by mail-ej1-x62e.google.com with SMTP id gh17so19141369ejb.6 for ; Sun, 18 Dec 2022 22:35:22 -0800 (PST) Received: from uni.router.wind (adsl-211.109.242.226.tellas.gr. [109.242.226.211]) by smtp.googlemail.com with ESMTPSA id q14-20020a17090676ce00b008302732f569sm77062ejn.78.2022.12.18.22.35.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 22:35:21 -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: 50071648-7f67-11ed-8fd4-01056ac49cbb 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=LTjDMyYZ2FC8KMfcNmUoTcsSKJ98IQZ5VWKAYZsCZM0=; b=hy0njpW+wNyVtXhc+Ee8W/5rsUt4CJq/mQhD5wYluvHVJzMQhUwcoh97Y6byogVf46 7a0dy1snJdukii0fZId/jrUnTK5Hcoo9xtnd3yPYCjSOVTOn3E3hayJz6uoJWwhzY4HN ehwplQcV1TYQ9w5hv3pl07GzIkpzkQEWkEHyL65phyg0VBPI7Gz76Gj3ID7DlYzIzPY8 gVFDuYHJLtI4YHHZUqtrubA9oVj/tc1R0jQx2QAqY8fzM3rKEU6s3HGfuDtK6ZS3tOdc zcLTqGv1DX1vdq43Kc5LAp6ZMQ/RD7fzWrdHqX/LT23V2oncegxCWmnGZLR4Dn0Jcj++ /5GA== 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=LTjDMyYZ2FC8KMfcNmUoTcsSKJ98IQZ5VWKAYZsCZM0=; b=HEvVwgP+u8qQvn/rvK/ilB1Akqajg9UTeSpvxyZiLgh0t5Z6TBp4jcnJggo7bSfflD gpJ7YovRO1iVd360hKaEwxwjaPMEeu+/EotSojItUA1MmokHItUQ5cSVQU3h5n7ofaOT 1arVn/aYzsQAJXYwCIfbzW8TyzW3ilrdLMRY0yAet1UgoGr85iXOTNHCjds5EfvhWMqO FBk6IPJt5F3JJwAm44d/GmkVT4HNkCbRKasI+SequhQ8mlKx18keWnJ8Y0SnvL53+X8J s3sZHPK83mQeJI734kpLrYURmB068dCI8HkSRh9s7U8E+oR3oonjYTs2kUSnJYCsNkrN EHUw== X-Gm-Message-State: ANoB5pnjMv3HIsF4JyATKEIRCJ+qurfl/J+nhuYF5Los9McWDuCTd6b+ GPbunERF9J/WZBwCfN0+wxK+aiQLZ9E= X-Google-Smtp-Source: AA0mqf6MN4kcF11s0TKqySAj6gHdfUpldWz3YfzclcD6iKya4IRmWW77oO5q0NR41jNZMMfaevFPyw== X-Received: by 2002:a17:906:f8cd:b0:7c0:e7ad:5296 with SMTP id lh13-20020a170906f8cd00b007c0e7ad5296mr32665117ejb.55.1671431721502; Sun, 18 Dec 2022 22:35:21 -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: [RFC 1/7] x86/iommu: make AMD-Vi and Intel VT-d support configurable Date: Mon, 19 Dec 2022 08:34:50 +0200 Message-Id: <20221219063456.2017996-2-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221219063456.2017996-1-burzalodowa@gmail.com> References: <20221219063456.2017996-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1671431758701100002 Content-Type: text/plain; charset="utf-8" Currently, for x86 platforms, Xen does not provide to the users any configuration control over the IOMMU support and can only be built with both AMD and Intel IOMMU drivers enabled. However, there are use cases, e.g in safety-critical systems, that require Xen to be able to be configured to exclude unused code. A smaller tailored configuration would help Xen to meet faster certification requirements for individual platforms. Introduce two new Kconfig options, AMD_IOMMU and INTEL_VTD, to allow code specific to each IOMMU technology to be separated and, when not required, stripped. AMD_IOMMU enables IOMMU support for platforms that implement the AMD I/O Virtualization Technology. INTEL_VTD enables IOMMU support for platforms that implement the Intel Virtualization Technology for Directed I= /O. Since no functional change is intended regarding the default configuration of an x86 system, both options depend on x86 and default to 'y'. Signed-off-by: Xenia Ragiadakou --- xen/drivers/passthrough/Kconfig | 16 ++++++++++++++++ xen/drivers/passthrough/Makefile | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/xen/drivers/passthrough/Kconfig b/xen/drivers/passthrough/Kcon= fig index 479d7de57a..82465aa627 100644 --- a/xen/drivers/passthrough/Kconfig +++ b/xen/drivers/passthrough/Kconfig @@ -37,6 +37,22 @@ config IPMMU_VMSA =20 endif =20 +config AMD_IOMMU + bool "AMD IOMMU" + depends on X86 + default y + ---help--- + Enables I/O virtualization on platforms that implement the + AMD I/O Virtualization Technology (IOMMU). + +config INTEL_VTD + bool "Intel VT-d" + 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). + config IOMMU_FORCE_PT_SHARE bool =20 diff --git a/xen/drivers/passthrough/Makefile b/xen/drivers/passthrough/Mak= efile index a5efa22714..d4fc7a3ddc 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_VTD) +=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 Sat May 4 23:12:07 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=1671431750; cv=none; d=zohomail.com; s=zohoarc; b=GZgGt6cGUq9/YfwSruOBaCxyqVRJ6eBknUem8JtPZ9PqqdIs69huIOW5y0SZni8lCBOB4VFWXqVX+irWoMQPxaACx4JomMZCBt7QitZ5rwyBodEwK+srApDbkzO5vDGCapON3Oo5IzRIZM87QCNwgmVPUJ91O7rmXs9m1B/M+kw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671431750; 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=80ZpLAZLQqNuZgUmUutfeY71usyNtY5k5j9A+SPx2to=; b=hOPtfcZoAPS3OfaS24bhn1rpLnR2+JH9ZugYpoUjV8a//QxTKahqCPLlIRw9hBE35ukbiiELxmcufLPGlx5k/AMTLt2tqBzS8dC+s+2WjO17TUlNKMhYFHlXn+IAvLNs9ezEzsfG64K1KrEgyEclWUfbvuMGJySIsJ34GaiwwtA= 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 1671431750403847.3635766886932; Sun, 18 Dec 2022 22:35:50 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.465757.724557 (Exim 4.92) (envelope-from ) id 1p79kF-0003dL-88; Mon, 19 Dec 2022 06:35:27 +0000 Received: by outflank-mailman (output) from mailman id 465757.724557; Mon, 19 Dec 2022 06:35:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p79kF-0003dE-4w; Mon, 19 Dec 2022 06:35:27 +0000 Received: by outflank-mailman (input) for mailman id 465757; Mon, 19 Dec 2022 06:35:24 +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 1p79kC-000383-81 for xen-devel@lists.xenproject.org; Mon, 19 Dec 2022 06:35:24 +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 50cf3775-7f67-11ed-8fd4-01056ac49cbb; Mon, 19 Dec 2022 07:35:23 +0100 (CET) Received: by mail-ej1-x633.google.com with SMTP id ud5so19149841ejc.4 for ; Sun, 18 Dec 2022 22:35:23 -0800 (PST) Received: from uni.router.wind (adsl-211.109.242.226.tellas.gr. [109.242.226.211]) by smtp.googlemail.com with ESMTPSA id q14-20020a17090676ce00b008302732f569sm77062ejn.78.2022.12.18.22.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 22:35:22 -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: 50cf3775-7f67-11ed-8fd4-01056ac49cbb 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=80ZpLAZLQqNuZgUmUutfeY71usyNtY5k5j9A+SPx2to=; b=gVk9UDmfQbQncVBdtYx4cLWqd0Ht6rE7Z1HkpQymC4w74/GcSix53WlbG4nVBjzL9p Ldwq9/aoZdJb1MhMJmoNUJfZt9VmMc0axVhjeZXDyNmqhYJ+z/W19RimnqHghicR3sK0 sWuI6lZGiIQzHOT0rlo/sAq+/XS7uXgJ9bUvpsn2P2Ml7S6NNFX2LYFw/bM4gH8XCixG Mx0rV5Gve85/j4nzAeiJ1gwnvReLogaSsEBAqrg90RjMv6DdmiN2DAXX3X4uMql5u7oG WiojAQYJdoxytf19LwPzsfGsPPuF3ExR0kHljutGpBf+b4N20BCOsNFHMky1zgP5KSAs 9mxQ== 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=80ZpLAZLQqNuZgUmUutfeY71usyNtY5k5j9A+SPx2to=; b=DywuTsUj43h2qFlaVNPOplA0ZxxMYAUkRw0IN6CkdMlY3Miuq9pHuvp8O931JzWOfc aN9N54NvfJS6pbbSjDuQzcAsKW7eJpKkBFGxHb1uFNYoLZXSszQd6y0MkDXTODpXSeDv X3QN7H9fa+LO5VkuJ4/GWp9TnxVxb+O9H+m9+UjZj3+TuJJy72ZRZ8zadZxGaWIeS7n+ ewAbBvQ+73iC2RQ7bhLS9m1AjOIKRea5id8XfQQ3byWlLPfW4ww+tooZ/HYRvaEDuyyo yT2vY6Wd6mIJ+jKszxROKB2furtrhOur80KVqObN+RADvlS4vlry6ijjb/9bsJuhYEup moNg== X-Gm-Message-State: ANoB5pn4nq4oMAdpMLfvHeqWK1X+HG9HmrVubkZE2rXIJPrUt/fQ2awR hWdq5Lv9tR1A674jEYwfzS4dWOXwD9E= X-Google-Smtp-Source: AA0mqf5J1elLvocK/Jvfp9+6inR60vFTgMRDu7J1Mc4W50gcC0qsLz/dE1X2Xxw0QJBt8Eo/vQN45g== X-Received: by 2002:a17:907:970b:b0:7c1:9462:2dd3 with SMTP id jg11-20020a170907970b00b007c194622dd3mr23090216ejc.70.1671431722829; Sun, 18 Dec 2022 22:35:22 -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: [RFC 2/7] x86/iommu: amd_iommu_perdev_intremap is AMD-Vi specific Date: Mon, 19 Dec 2022 08:34:51 +0200 Message-Id: <20221219063456.2017996-3-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221219063456.2017996-1-burzalodowa@gmail.com> References: <20221219063456.2017996-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1671431752806100001 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 and 1 with true. No functional change intended. Signed-off-by: Xenia Ragiadakou --- xen/drivers/passthrough/amd/iommu_init.c | 2 ++ xen/drivers/passthrough/iommu.c | 3 ++- xen/include/xen/iommu.h | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/xen/drivers/passthrough/amd/iommu_init.c b/xen/drivers/passthr= ough/amd/iommu_init.c index 1f14aaf49e..c4a41630e5 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 __read_mostly 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..1a02fdc453 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 @@ -115,8 +114,10 @@ static int __init cf_check parse_iommu_param(const cha= r *s) if ( val ) iommu_verbose =3D 1; } +#ifdef CONFIG_AMD_IOMMU else if ( (val =3D parse_boolean("amd-iommu-perdev-intremap", s, s= s)) >=3D 0 ) amd_iommu_perdev_intremap =3D val; +#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 ) diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 4f22fc1bed..6b06732792 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -104,7 +104,9 @@ static inline void clear_iommu_hap_pt_share(void) } =20 extern bool_t iommu_debug; -extern bool_t amd_iommu_perdev_intremap; +#ifdef CONFIG_AMD_IOMMU +extern bool amd_iommu_perdev_intremap; +#endif =20 extern bool iommu_hwdom_strict, iommu_hwdom_passthrough, iommu_hwdom_inclu= sive; extern int8_t iommu_hwdom_reserved; --=20 2.37.2 From nobody Sat May 4 23:12:07 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=1671431756; cv=none; d=zohomail.com; s=zohoarc; b=QOvvTF9aI9BtJ2AR5P3J68ZSjzpf4ct/T/ngLfuHhs4WkOGn+m8rSncSHGMH+KC9jD6oXNXuXVvecpnpEIiN1UkAQbbXm6N3Q8MK6fZkn54lo8Jo8DiO6aZO36FyypvP265FemS0BQmjPf3hwZHq8DTBEWr3MbbL8WP3hG1gLEQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671431756; 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=XmiLQ17qWs8UoQg0QXOFkwzdMxwKqjmh4/5E65N65dA=; b=GfQde7x0LhKMal1ufL+vAl6goiWi/fq82zxJl6UOV6AKBA2ZvKrMSBm2NdjNvfFjdDRLYU2L7CR79yxNXHDszPWnjCijBZYOHa7hwImzLUt5AJ0c92l3O1C510H767ndIycA4mlnr/llGuqGUNEDlI9Z+XhRGEdUGMSeyuQN2Ds= 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 167143175691863.195501286048625; Sun, 18 Dec 2022 22:35:56 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.465758.724564 (Exim 4.92) (envelope-from ) id 1p79kF-0003gt-Jw; Mon, 19 Dec 2022 06:35:27 +0000 Received: by outflank-mailman (output) from mailman id 465758.724564; Mon, 19 Dec 2022 06:35:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p79kF-0003fp-CS; Mon, 19 Dec 2022 06:35:27 +0000 Received: by outflank-mailman (input) for mailman id 465758; Mon, 19 Dec 2022 06:35:25 +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 1p79kD-000383-CO for xen-devel@lists.xenproject.org; Mon, 19 Dec 2022 06:35:25 +0000 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [2a00:1450:4864:20::629]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 51929e85-7f67-11ed-8fd4-01056ac49cbb; Mon, 19 Dec 2022 07:35:24 +0100 (CET) Received: by mail-ej1-x629.google.com with SMTP id n20so19253695ejh.0 for ; Sun, 18 Dec 2022 22:35:24 -0800 (PST) Received: from uni.router.wind (adsl-211.109.242.226.tellas.gr. [109.242.226.211]) by smtp.googlemail.com with ESMTPSA id q14-20020a17090676ce00b008302732f569sm77062ejn.78.2022.12.18.22.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 22:35:23 -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: 51929e85-7f67-11ed-8fd4-01056ac49cbb 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=XmiLQ17qWs8UoQg0QXOFkwzdMxwKqjmh4/5E65N65dA=; b=WyPTmXR5gBKo9Tt3/PPPQ/O2Qq/NENBf8C6ZeIBcgx1HaWblaj8RJwjoMi1Agk1+n4 j8hWANySials13BIHnH/F38dJsI6lBe/qMsRp715PYk6j5KnI+UZ2iTHk8fQMfAkfWGS gjVklc3Pn15ivC7xwKk/klEUVYqAJ4QrV42GIrJ4oZ4V9PBo1GlI+ipD+xB85axDwk25 fkGJqOJvuwOX9XmRihsNK8Gmq7VAsFnne11eRZTxgk16DeEpkEvZWey0F6+MzrNWSUPg f1PNO4wn5Q4m4gAMhhiCS0KBRoqfGKDxDJH7U3S7HEVFXtgt5XVxjtO198we+3yNpdSQ Z+WQ== 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=XmiLQ17qWs8UoQg0QXOFkwzdMxwKqjmh4/5E65N65dA=; b=AFoNzS3myLw60/8n6VNEXeAWWFrqiazvK0lSDYnbYKrcHpiug5upVFwPfy4vGLLMQo uXJ2Y1dIAlC/s/QeO7M1za53Dr1AiTKME0TaRAvPMzWs5c/nhOf6Sjz00trOkJg/jmr4 8BcFE74sSTpW3ra2FO4e78AoRuc2BH7nb+oGRcyDal3hiwsq45ox8R/WDiNHexO16UTm KS5NmKYvMLEXFxLfXsh96QzpxNXN05fMNgKLPfP6lXSdkqeCzru9I0tXh/ZckWVe9ztL ooELew7qppGvw87IVrTLDnW/qukTyzEEwuqyIRzJnW9Vd+xUQQX01XoRMl7zykyAWlSK 3yzA== X-Gm-Message-State: ANoB5pk2Efp84FI1rS2NPYBOqVNs8paJSPUWSFoGeFeOeZU69reJJO+0 NyKOEmDtzoDuDFVjf16n0GwW0I8qKWw= X-Google-Smtp-Source: AA0mqf6m3Yv/zHFs8eKQjoyja6xQDkdrHpT2OHFjWXRpxV7Yyd8NQg1UDqxZkZJ1df88n7sklZ8Umg== X-Received: by 2002:a17:906:7751:b0:7ae:df97:c020 with SMTP id o17-20020a170906775100b007aedf97c020mr33346832ejn.13.1671431724016; Sun, 18 Dec 2022 22:35:24 -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: [RFC 3/7] x86/iommu: iommu_igfx, iommu_qinval and iommu_snoop are VT-d specific Date: Mon, 19 Dec 2022 08:34:52 +0200 Message-Id: <20221219063456.2017996-4-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221219063456.2017996-1-burzalodowa@gmail.com> References: <20221219063456.2017996-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1671431758691100001 Content-Type: text/plain; charset="utf-8" Use CONFIG_INTEL_VTD to guard their usage in common code. No functional change intended. Signed-off-by: Xenia Ragiadakou --- 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 1a02fdc453..dcb5ec49ac 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_VTD 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 6b06732792..d9285a7760 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_VTD +extern bool iommu_igfx, iommu_qinval, iommu_snoop; +#else # define iommu_snoop false #endif =20 --=20 2.37.2 From nobody Sat May 4 23:12:07 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=1671431755; cv=none; d=zohomail.com; s=zohoarc; b=Xo7AgG2KIse8Fro5E9B2bz3+QUL9l+IgEuR3ASa4OgvJZUAnvaF7/9GoXVXWn2sh3uaa/q3xYS7MLeAIuqT3IszzlZN76DM5RvGJTRUqK/HujQeMyVpSMyLxAcc8mnbFq38doeQ7sAxKCSGVVjZIcZP06KI8AJetT/4ED1C9ygc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671431755; 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=Hz6FjXGAr1BW2zW8+8ubXkVLUxQBru6jBVid1iAt+4Y=; b=f8uEfMkn8BcYS3XXMLeShN5h0k5kurD1JoPUZArOw0Q0v7FlGeWxn0iizQQ5wqZPPPXjGVDljMBwMKEcfTEle7GQ3Zrzw5i8Q/9CJfHo1RnESkLtxeeXZUaU/SqqPfkbL/H4hDaEmFNwi/9YRMhFRtwTQhiVu/7Qc7/LlwiXC5k= 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 1671431755830180.25454453612258; Sun, 18 Dec 2022 22:35:55 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.465759.724581 (Exim 4.92) (envelope-from ) id 1p79kG-00047N-Qk; Mon, 19 Dec 2022 06:35:28 +0000 Received: by outflank-mailman (output) from mailman id 465759.724581; Mon, 19 Dec 2022 06:35:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p79kG-00046W-KI; Mon, 19 Dec 2022 06:35:28 +0000 Received: by outflank-mailman (input) for mailman id 465759; Mon, 19 Dec 2022 06:35:26 +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 1p79kE-000383-NZ for xen-devel@lists.xenproject.org; Mon, 19 Dec 2022 06:35:26 +0000 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [2a00:1450:4864:20::629]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 5279adf6-7f67-11ed-8fd4-01056ac49cbb; Mon, 19 Dec 2022 07:35:26 +0100 (CET) Received: by mail-ej1-x629.google.com with SMTP id n20so19253809ejh.0 for ; Sun, 18 Dec 2022 22:35:26 -0800 (PST) Received: from uni.router.wind (adsl-211.109.242.226.tellas.gr. [109.242.226.211]) by smtp.googlemail.com with ESMTPSA id q14-20020a17090676ce00b008302732f569sm77062ejn.78.2022.12.18.22.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 22:35:25 -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: 5279adf6-7f67-11ed-8fd4-01056ac49cbb 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=Hz6FjXGAr1BW2zW8+8ubXkVLUxQBru6jBVid1iAt+4Y=; b=WnPUpU31tyKyu2mpU+g9qT6bVaV1EyK7U1Z4E7qK8G5RdEjVy9bY91qdGaKJMK7vBw KxHnDUgIbC6Gv+CzwZ5D4BzIatxhUjsfKM77HUI/pPSudBepnHvpfakHNVjh+UF7yEsk canNx4uwc08BaDoIuL1x6aYugWExozjtcroREW+g8OaBpbZ4xiMdFCoF80FjDg2R3BkM BzCVm+fcl+9RdbMlZ7w56x0njm9C+X5kGIPxtVD+0fbT6B2R04uVzLPycwPEJIaqiIu6 3li/eese5o2xY3hIEU/wdkZ8Zu8wWkBNqPme4CQ2wSCcoDLjnX8EL8bjluZ8nwvWHn5v U73Q== 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=Hz6FjXGAr1BW2zW8+8ubXkVLUxQBru6jBVid1iAt+4Y=; b=VxPqV2gq8KQ9PawGF3ovkZc4JJtOKmhDL51BQfW/aLAiXP5e2cotqGBsb+yuP4BAIK Qb669DWlAMdsulVrNK3+G3dwsQhjih1xJ5lPV+CKaixYrvH35CNrbieYfnZItMdg/HN7 3PRgJ+YCcsTA358tRedBT4ruBuzYM5iGnMqpiqmwG2Urw0fc24tZ+tdQFposhYDIfOj8 e9Vz/xlZypB82073tuiGDNPU2l41b4ExwO510FhkvMsFuaLPwe79KjgL6JuTIKDOH1Hg GkQTGoo9wNZ20v0j9jAOIFxPaYwzeDkwxwrz3vp/QGKo7PXxvgup09oYfA6XAcuyj9MO HQKA== X-Gm-Message-State: ANoB5pmqmLdZsqK5NtjGddS228jkvNWK3fI9ykLzCQj1CUtBuErDbquM 81DxeDgWTPXv4aLSFGTSNDpk3qwjMko= X-Google-Smtp-Source: AA0mqf7VJiC5mzrg3SfScK5+c+ET7ex4QMswiUfB28YApmHzHpbuaN/BUrPUXFIJ76mx4KKc0ah2/g== X-Received: by 2002:a17:907:1dc8:b0:7c0:dd4e:b383 with SMTP id og8-20020a1709071dc800b007c0dd4eb383mr38803215ejc.3.1671431725606; Sun, 18 Dec 2022 22:35:25 -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: [RFC 4/7] x86/acpi: separate AMD-Vi and VT-d specific functions Date: Mon, 19 Dec 2022 08:34:53 +0200 Message-Id: <20221219063456.2017996-5-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221219063456.2017996-1-burzalodowa@gmail.com> References: <20221219063456.2017996-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1671431756473100005 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_VTD 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 Reviewed-by: Jan Beulich --- 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..06461fedcd 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_VTD 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 Sat May 4 23:12:07 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=1671431753; cv=none; d=zohomail.com; s=zohoarc; b=jMyWneUzPbwwekxLXLVEq6rTclAJp13CZVEUtV9NMYm0dXM7wb1r4zS3GK2X3xTo7BguZuA1pgNKpSX3Qtb4XFvCOasrIvDJNyomWOo8WmUVo6ASljHjhF3c6OeTzhCrdnO7O1Y1YXxiCOtKYT+DPrD+FEyxZ23gIfwn4OUEiiY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671431753; 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=U7GANqKS3y9roRizIFR0E30IuGDIVnJH0Nb9jg1Y7lU=; b=bU1cFnKoFoum18drZD+egoFFL+lZUvwca49HSq3Oh69fgOKadOur8UcFcg1sfOZizCrDA3huN5UdpfBX64ikUf+kdeFg+bnyH2pRrzv9d61imivf5izXYSrqUPfXRaplJkph4P0FwDDXzbt6pYWEwFjHxhj829cOKSsLZHuAc64= 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 1671431753865499.78938351514944; Sun, 18 Dec 2022 22:35:53 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.465760.724586 (Exim 4.92) (envelope-from ) id 1p79kH-0004Cr-5r; Mon, 19 Dec 2022 06:35:29 +0000 Received: by outflank-mailman (output) from mailman id 465760.724586; Mon, 19 Dec 2022 06:35:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p79kG-0004CW-W0; Mon, 19 Dec 2022 06:35:28 +0000 Received: by outflank-mailman (input) for mailman id 465760; Mon, 19 Dec 2022 06:35:28 +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 1p79kG-000383-5w for xen-devel@lists.xenproject.org; Mon, 19 Dec 2022 06:35:28 +0000 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [2a00:1450:4864:20::62e]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 533b17df-7f67-11ed-8fd4-01056ac49cbb; Mon, 19 Dec 2022 07:35:27 +0100 (CET) Received: by mail-ej1-x62e.google.com with SMTP id tz12so19094138ejc.9 for ; Sun, 18 Dec 2022 22:35:27 -0800 (PST) Received: from uni.router.wind (adsl-211.109.242.226.tellas.gr. [109.242.226.211]) by smtp.googlemail.com with ESMTPSA id q14-20020a17090676ce00b008302732f569sm77062ejn.78.2022.12.18.22.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 22:35:26 -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: 533b17df-7f67-11ed-8fd4-01056ac49cbb 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=U7GANqKS3y9roRizIFR0E30IuGDIVnJH0Nb9jg1Y7lU=; b=aWj21hAh9rHIirDqXtfU/rS6HxFwLAQ3LUkiadoo1ZVHcK3qndjp1Khb6gn/OquW7i 8nShyPFT7j6tb2Czd/aK4p8+H76N23FVCJE2m7e+veS2DotGlFIIn347Vjc6r2HEV/Vc 6BVF73k7aLRqoM6RVqn6W2Pdl08bS8bgV+GOk0nTvqk/px3YJo+4gFY6yR9S4h0IxEQ7 ZbskFnNgFjKtB9uKdE0TQC26KnrnaYxa7hf/9BAwrqYYWQ7ep2Beu+Pab/N3tAt8wjX2 2PeoPgnGiBTEJfmTqqad4xHDMQknydA5SyYAq0k69QkmzbYIE83+G9sdTs82CSAvJhkc vpHQ== 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=U7GANqKS3y9roRizIFR0E30IuGDIVnJH0Nb9jg1Y7lU=; b=yFcaKceauTC3TrhxVAXbTEj4x6px46TogkpjTyLZyppDVOHIAJ+uAFv3dTk1jsyHK5 o8WtZFYL10c9W9eWeA9TBN10UYQCWSF/4l/WJwRVgWpF0FQNqCBPaVx1vLSFv5e3Wkyb 3WM4Baj2z43bpXC/MVxHK+8liGwU8ECoS2wuHIUk2KF8++pb1z9HOgx95G7xFcd1tfQN ZVo4xAGk83nxOpEVBQ6JT1rea8NsnCP3cvx4FUMfxri67p19Yiy3fZMuK3zxOsv6/JMR 3f1XAymSwKA25nJGRIigeIzbh6ryy97Rr4Rjmy6X7nfTGLXpNXmzTQoX9xLy0fv6YKte ptig== X-Gm-Message-State: ANoB5pkFaR6tNirdKqzUaqA3rJnYjz0GGGFNBLw0Npi2buWd1OhjSU6k 46BMTDjSYgAkGU5OgcrSDG7C/5onqXE= X-Google-Smtp-Source: AA0mqf5zB+h+LxU7GhtH4zxnbUiL5C3o+j5jM7oadw8rgP0B7te/JGT9Zy5x7olW3q/b5ZsI4eGBCQ== X-Received: by 2002:a17:906:7751:b0:7ae:df97:c020 with SMTP id o17-20020a170906775100b007aedf97c020mr33346918ejn.13.1671431726888; Sun, 18 Dec 2022 22:35:26 -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: [RFC 5/7] x86/iommu: the code addressing CVE-2011-1898 is VT-d specific Date: Mon, 19 Dec 2022 08:34:54 +0200 Message-Id: <20221219063456.2017996-6-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221219063456.2017996-1-burzalodowa@gmail.com> References: <20221219063456.2017996-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1671431754470100003 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_VTD. No functional change intended. Signed-off-by: Xenia Ragiadakou --- 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..41bd1b9e05 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_VTD 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..0e1b03904c 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_VTD 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..2e06c0a6c1 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_VTD 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 Sat May 4 23:12:07 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=1671431757; cv=none; d=zohomail.com; s=zohoarc; b=T3/qfKk1n1l+DDX2sF9wP6YeqCh/kqpqc8kEqJtTpK3tyw2lS4SWVD5SkFWMnI6sDDdfUuUB4mh92IzMVztSWf+fJzTCz09tl6uUcitJtLdHHMdsWmPRbLWZJcNNGCQjSY6A7DKQ9hHi3iqgNMtKPfuusVV0RbTXcvFdd9PBnaM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671431757; 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=QDHt9Muga8jj18B99Ku3Es7TSomj917F0qX6vAjIB5g=; b=WIdhyWEFMarUOp9kaQ2M5wAQlXXCGdm2fUpYG6Z993Zy6Pft5p8kBJ7vSc8h+ftUB/N7IWPXLWADjYeCZqJBmb/hJ7gUkqVupJNe2gUoUGAteq92KC0Mb6ne0Efl+j7LclcyBqMWoKumv43FylTVMFijTJ8fg/I09wUXg+LGAzI= 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 1671431757046849.0473541212889; Sun, 18 Dec 2022 22:35:57 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.465761.724602 (Exim 4.92) (envelope-from ) id 1p79kJ-0004iH-GE; Mon, 19 Dec 2022 06:35:31 +0000 Received: by outflank-mailman (output) from mailman id 465761.724602; Mon, 19 Dec 2022 06:35:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p79kJ-0004i0-C5; Mon, 19 Dec 2022 06:35:31 +0000 Received: by outflank-mailman (input) for mailman id 465761; Mon, 19 Dec 2022 06:35:30 +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 1p79kH-000383-WF for xen-devel@lists.xenproject.org; Mon, 19 Dec 2022 06:35:30 +0000 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [2a00:1450:4864:20::62a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 542d0c26-7f67-11ed-8fd4-01056ac49cbb; Mon, 19 Dec 2022 07:35:29 +0100 (CET) Received: by mail-ej1-x62a.google.com with SMTP id fc4so19039032ejc.12 for ; Sun, 18 Dec 2022 22:35:29 -0800 (PST) Received: from uni.router.wind (adsl-211.109.242.226.tellas.gr. [109.242.226.211]) by smtp.googlemail.com with ESMTPSA id q14-20020a17090676ce00b008302732f569sm77062ejn.78.2022.12.18.22.35.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 22:35:28 -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: 542d0c26-7f67-11ed-8fd4-01056ac49cbb 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=QDHt9Muga8jj18B99Ku3Es7TSomj917F0qX6vAjIB5g=; b=BRMFmUfPzlOVRvLBZelGfWoA4csOXoqK7RcIuPHysgTsZdx6bLeS9Ug3Uhiuh09sQF mu8nWcfqNUN9+vKfrWazttPpWT2bJXW5RrUVTFabCUQQw0DeME/MgnzQVjDYToAA+KKl FhWQMd1b21iGCHGHJH+Hs7SdVh/eAO7YdWGKRXbzszcD2rqdFzW+CfzzWLOh+SZJPtb/ yUz9Mk5jflw7KIhgqp/Y6qM5TVzbxKu/o4KYuEW5QDK4QmGeMmazWuPu5bD5RxlUQ2mM Z4brmiYF7bR/QswtWFITnVlnU1HiDQTpJnzZrc+FIkNniJHrhPDvD00h2kjP294xVKHL mq7Q== 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=QDHt9Muga8jj18B99Ku3Es7TSomj917F0qX6vAjIB5g=; b=oH04Oj/jpQSDGUfRCHSvHK1T5TIMssNfOYzxMJHMCarbxMlYTU5Y1eXFBbX1cU4prT CmicEMk9sLPHe1LR32gHo2QuFKHlDWOdB3k6XTMXxoIkBMy3Sr8tWjNR7OTLSw31mmTZ RLmAJTAvwIsL0J+XQWuHx1Pb/Kmh9T1sER/8diy65YTB3kFWdwiv04lHZ0TptGdGQQCr Ku48yx6Pbku2jnSFl9ETwFn84QvdUiK1Phha66AGY1QRoE5Pe2+yLCOC6dKw+MHwO6En w9xZrKeJqVYjbS0S2lUA+izBB3SZscP1QsPJlDJTuNOYcy9KeqPtvrDDETfoYeqw1qz/ Nldg== X-Gm-Message-State: ANoB5pn05+Kmix0Iykx2UbjFblI8D67hDod5lCK5LOskivSlVUUH/oBt qRh219+KFemu/KusZKzbABhKm9ts4yU= X-Google-Smtp-Source: AA0mqf4rjpoUPOhdC/CaBehe4Uk70e90bXRw6GgEKYKuRFfJA3CO+fVb56q4mdcvu+JPIiGII6c6uQ== X-Received: by 2002:a17:907:20ce:b0:7c1:6344:845 with SMTP id qq14-20020a17090720ce00b007c163440845mr27269843ejb.34.1671431728334; Sun, 18 Dec 2022 22:35:28 -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: [RFC 6/7] x86/iommu: call pi_update_irte through an hvm_function callback Date: Mon, 19 Dec 2022 08:34:55 +0200 Message-Id: <20221219063456.2017996-7-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221219063456.2017996-1-burzalodowa@gmail.com> References: <20221219063456.2017996-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1671431758717100003 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 --- xen/arch/x86/hvm/vmx/vmx.c | 10 ++++++++++ xen/arch/x86/include/asm/hvm/hvm.h | 22 ++++++++++++++++++++++ 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, 45 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 7c81b80710..3080f1ef41 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -2134,6 +2134,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); @@ -2582,6 +2590,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..f16b9edeaf 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 @@ -893,6 +908,13 @@ static inline void hvm_set_reg(struct vcpu *v, unsigne= d int reg, uint64_t val) ASSERT_UNREACHABLE(); } =20 +static inline int hvm_pi_update_irte(const struct vcpu *v, + const struct pirq *pirq, uint8_t gvec) +{ + ASSERT_UNREACHABLE(); + return -EOPNOTSUPP; +} + #define is_viridian_domain(d) ((void)(d), false) #define is_viridian_vcpu(v) ((void)(v), false) #define has_viridian_time_ref_count(d) ((void)(d), false) diff --git a/xen/arch/x86/include/asm/hvm/vmx/vmx.h b/xen/arch/x86/include/= asm/hvm/vmx/vmx.h index 8eedf59155..17f13e79a0 100644 --- a/xen/arch/x86/include/asm/hvm/vmx/vmx.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmx.h @@ -155,6 +155,17 @@ static inline void pi_clear_sn(struct pi_desc *pi_desc) clear_bit(POSTED_INTR_SN, &pi_desc->control); } =20 +#ifdef CONFIG_INTEL_VTD +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 41bd1b9e05..c433c75b76 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 Sat May 4 23:12:07 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=1671431754; cv=none; d=zohomail.com; s=zohoarc; b=CMv5WYa3bGK9vBO8yqUHh9wjqZ7jEGQIWG+PkzjjI3V4tEEIKs0GtNwbilxz/7uAJdNrt8qHgpK12TvKVqu7MyL3ROQV9ZSsPfcMKSFprh9v54IWv/Leo8vN2MDuxck+Ptfyv6dYyds2CncUh8zeI3YVI1HjZ4b0jDc8HtgPfSM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671431754; 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=eKxCBs5CR8gwNTFWB5aXerKwnJpGPquUnlinCcVM5FA=; b=j16nHyBb4tS9TDqfvNTzJ2KJrpajaaigvBUlzwAzbmaPirfLP5ZfQ1izrHTiSMzXk5494X4l2tapwJ6PBMBl8rnRqe1kNnd8MqQSK98F/DgFw2m+fFw5hitUXl82NeDgkU0CPRX8NwHLCzUOqHlFWKKiia4qNEEDwrmc4ErIlhI= 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 1671431754372415.3550598376286; Sun, 18 Dec 2022 22:35:54 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.465762.724613 (Exim 4.92) (envelope-from ) id 1p79kK-00050n-UW; Mon, 19 Dec 2022 06:35:32 +0000 Received: by outflank-mailman (output) from mailman id 465762.724613; Mon, 19 Dec 2022 06:35:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p79kK-0004zU-Ps; Mon, 19 Dec 2022 06:35:32 +0000 Received: by outflank-mailman (input) for mailman id 465762; Mon, 19 Dec 2022 06:35:31 +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 1p79kJ-000383-EC for xen-devel@lists.xenproject.org; Mon, 19 Dec 2022 06:35:31 +0000 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [2a00:1450:4864:20::636]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 550595ca-7f67-11ed-8fd4-01056ac49cbb; Mon, 19 Dec 2022 07:35:30 +0100 (CET) Received: by mail-ej1-x636.google.com with SMTP id kw15so19071425ejc.10 for ; Sun, 18 Dec 2022 22:35:30 -0800 (PST) Received: from uni.router.wind (adsl-211.109.242.226.tellas.gr. [109.242.226.211]) by smtp.googlemail.com with ESMTPSA id q14-20020a17090676ce00b008302732f569sm77062ejn.78.2022.12.18.22.35.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 22:35:29 -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: 550595ca-7f67-11ed-8fd4-01056ac49cbb 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=eKxCBs5CR8gwNTFWB5aXerKwnJpGPquUnlinCcVM5FA=; b=Uo5w3wXObfuiN5tRzjP0JoRHi1FVdKzGEU7MsGY9as6vCBHEfqCY2R1y9abHaueSvI VTOdGg3K+AEjmyfAaekLlNaAcIBWzm5oBVCUcurGYbIBvpYjq+anjr8whlA6v52YLPQ1 goVSFwW6NaRwWIEtK8/jowcF6R6o1q+AuVpESXgAm3cDlhudbRqYSOSYztdTvY8KDvvp RasP3krz/BJ9oWu+JMN0DHK/E86j+VH6Kd+opgX4esWcVDSLZyUW1zSHAKf/W/0ut64N xjKDmRo1rMISxNY6AL0xOgHcrIR7JwBKCsavOCjBjxNoUO5VR1Ul16VXikEjcFsO74XS QU7w== 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=eKxCBs5CR8gwNTFWB5aXerKwnJpGPquUnlinCcVM5FA=; b=etkoqA9shtpYKdWQGcc3tD6ZTnEy+FmTPIsHHcKJFQZXiSH2vCrDJr54W7XxpWR+G4 btXTS/k3jkELajxrEauCQeYKGwbqU4A+LgjcZAUigQpzT10eD6abWBUbIkw3U1MKEbUH 3rpwgHLhnUnoQ2mfJEFE+aEphDFqlF3OBdvh+cH4xN2skgPnH3tY38G4lCIljl6Ivit8 MajBTAbCpBtW5YBjdLS7W+cac4krDymfYDfL1dsIbyVcnHNc5WMlfDTNxiYeEwWA0Obs 7qM6C4OPT9qAAj2Prka+VjzmcxuCJkaaLdfFd6mcRQLhW3fOFeaMT9UaTvCVNV2bPZ7x BBAg== X-Gm-Message-State: ANoB5plbJvkkj7BUCoXLg47a8x8p8JDCuNoyWy9rOh8u02ii8wn5BUf/ CjDhuiluUTmnTpv0YLvS+156/F/grVs= X-Google-Smtp-Source: AA0mqf6Gummy9mqukj5QeKi01nMnG1vJjThOo+agSusjb1/LeCt1yFFbaPAnNRG23PSksLfeaoPITg== X-Received: by 2002:a17:906:2a0e:b0:7be:9340:b3e6 with SMTP id j14-20020a1709062a0e00b007be9340b3e6mr50460978eje.43.1671431729850; Sun, 18 Dec 2022 22:35:29 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , Kevin Tian Subject: [RFC 7/7] x86/dpci: move hvm_dpci_isairq_eoi() to generic HVM code Date: Mon, 19 Dec 2022 08:34:56 +0200 Message-Id: <20221219063456.2017996-8-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221219063456.2017996-1-burzalodowa@gmail.com> References: <20221219063456.2017996-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1671431756493100006 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. Remove the now empty xen/drivers/passthrough/vtd/x86/hvm.c. Since the funcion is hvm specific, move its declaration from xen/iommu.h to asm/hvm/io.h. No functional change intended. Signed-off-by: Xenia Ragiadakou --- I was not sure how to handle the copyright. I assume that I have to retain the copyright of Weidong Han , right? xen/arch/x86/include/asm/hvm/io.h | 1 + xen/drivers/passthrough/vtd/x86/Makefile | 1 - xen/drivers/passthrough/vtd/x86/hvm.c | 64 ------------------------ xen/drivers/passthrough/x86/hvm.c | 42 ++++++++++++++++ xen/include/xen/iommu.h | 1 - 5 files changed, 43 insertions(+), 66 deletions(-) delete mode 100644 xen/drivers/passthrough/vtd/x86/hvm.c diff --git a/xen/arch/x86/include/asm/hvm/io.h b/xen/arch/x86/include/asm/h= vm/io.h index 54e0161b49..5e1071b798 100644 --- a/xen/arch/x86/include/asm/hvm/io.h +++ b/xen/arch/x86/include/asm/hvm/io.h @@ -102,6 +102,7 @@ bool handle_mmio_with_translation(unsigned long gla, un= signed long gpfn, bool handle_pio(uint16_t port, unsigned int size, int dir); void hvm_interrupt_post(struct vcpu *v, int vector, int type); void hvm_dpci_eoi(struct domain *d, unsigned int guest_irq); +void hvm_dpci_isairq_eoi(struct domain *d, unsigned int isairq); void msix_write_completion(struct vcpu *); =20 #ifdef CONFIG_HVM 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..94cc1646c0 100644 --- a/xen/drivers/passthrough/x86/hvm.c +++ b/xen/drivers/passthrough/x86/hvm.c @@ -924,6 +924,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; +} + +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 d9285a7760..b9e1288de8 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -202,7 +202,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