From patchwork Mon Jan 16 07:04:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xenia Ragiadakou X-Patchwork-Id: 13102668 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 29E55C46467 for ; Mon, 16 Jan 2023 07:05:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.478335.741455 (Exim 4.92) (envelope-from ) id 1pHJY9-00077n-F4; Mon, 16 Jan 2023 07:04:57 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 478335.741455; Mon, 16 Jan 2023 07:04:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pHJY9-00077g-Bg; Mon, 16 Jan 2023 07:04:57 +0000 Received: by outflank-mailman (input) for mailman id 478335; Mon, 16 Jan 2023 07:04:56 +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 1pHJY8-0006sD-22 for xen-devel@lists.xenproject.org; Mon, 16 Jan 2023 07:04:56 +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 13e88359-956c-11ed-b8d0-410ff93cb8f0; Mon, 16 Jan 2023 08:04:54 +0100 (CET) Received: by mail-ej1-x62b.google.com with SMTP id bk15so8323180ejb.9 for ; Sun, 15 Jan 2023 23:04:54 -0800 (PST) Received: from uni.router.wind (adsl-67.109.242.224.tellas.gr. [109.242.224.67]) by smtp.googlemail.com with ESMTPSA id v15-20020a056402184f00b0046c5baa1f58sm10990824edy.97.2023.01.15.23.04.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Jan 2023 23:04:53 -0800 (PST) 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: 13e88359-956c-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=53CNedcl2LpaLrX+og6xiNzpDo61T+Xa5G/+nq0djig=; b=MNH32xpmk7O4JRawfjj/7+WeXgb4/eJew9BrD/cd8foYWnF0gDYh8WQ8C3uRq5AYtk Qfav2j+zCsIOEpVnwniTyBOWWr74Z7+9OtWaUIeq2RjbV7hX9nD5ICoQ75YPwkLu3pJi xJMrTMjPQqBVU/6rloVRHTMKx7nCFUaOl+8h7GJF1dRxLHZ1RHdLZ/HVBcw1AS6+CDKN 63cT+jWdAg6jwsdTUL2Yu8RVUOUWauvqPWf/3u9JA6VXHf2Bluryq49fGSuQcYCLwAuM kBdlSya9+z6pR81KUkAWbI3oQjVVv/D+7t/PiNyY4UsB1YsXH24zJbKNtsJmqO4Ffxs4 UGog== 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=53CNedcl2LpaLrX+og6xiNzpDo61T+Xa5G/+nq0djig=; b=CGyeaM5168WHWwKH1TiKizHBZNfUKN0RQhChrj4A+riRwW94QLx76B/F+iuREbR4b5 rZ+Dd3xcF7Om9NoE036Eo/1M0MachzeTx5q7JAzWlB45Fk9XYJ3iQmo2ey0uIIbK1tyS nTES96qETAXFPTvZArgbRsYoe6Bq/9xShM41ZSKgYQUKzxM3vy4nF1vvZI1f2IxX7emo 7wV3hSVPstuqNSHC2JJh9TKIRgcWt5g27D85xqbN3F2CjgODo9Wb+S5Yelb8MWkIE1re w39WpXmiisrg3Wp4pjBDm4rGxV7i0XLYVofO/sgucStPR6US50GEM9J9VFtVlZqTgbvV 6XKQ== X-Gm-Message-State: AFqh2kpw5YsWbDRNMFbCB1iArIvHfGKXlf0/A6a4VoUKHOSRHRlCLxIs CLuYwoMaKx1bUPmNT6oJ1qwOyzvzM7I= X-Google-Smtp-Source: AMrXdXvYHQUxlrIBRDsIC5Fy1aNpHLbbszebpSlbeaCjwNkQKFFzRNI23dtm/XQgoBdr9Tuia50AsA== X-Received: by 2002:a17:907:1316:b0:863:e08e:2ac3 with SMTP id vj22-20020a170907131600b00863e08e2ac3mr10398478ejb.63.1673852693562; Sun, 15 Jan 2023 23:04:53 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Andrew Cooper , Paul Durrant , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v3 1/8] x86/iommu: amd_iommu_perdev_intremap is AMD-Vi specific Date: Mon, 16 Jan 2023 09:04:24 +0200 Message-Id: <20230116070431.905594-2-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116070431.905594-1-burzalodowa@gmail.com> References: <20230116070431.905594-1-burzalodowa@gmail.com> MIME-Version: 1.0 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 Reviewed-by: Jan Beulich --- Changes in v3: - the second arg of no_config_param() should have been the parameter name, i.e "iommu", and not the boolean suboption "amd-iommu-perdev-intremap" 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/passthrough/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; +bool __ro_after_init amd_iommu_perdev_intremap = 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/iommu.c index 5e2a720d29..9d95fb27d0 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -58,7 +58,6 @@ bool __read_mostly iommu_hap_pt_share = true; #endif bool_t __read_mostly iommu_debug; -bool_t __read_mostly amd_iommu_perdev_intremap = 1; DEFINE_PER_CPU(bool_t, iommu_dont_flush_iotlb); @@ -116,7 +115,11 @@ static int __init cf_check parse_iommu_param(const char *s) iommu_verbose = 1; } else if ( (val = parse_boolean("amd-iommu-perdev-intremap", s, ss)) >= 0 ) +#ifdef CONFIG_AMD_IOMMU amd_iommu_perdev_intremap = val; +#else + no_config_param("AMD_IOMMU", "iommu", s, ss); +#endif else if ( (val = parse_boolean("dom0-passthrough", s, ss)) >= 0 ) iommu_hwdom_passthrough = val; else if ( (val = parse_boolean("dom0-strict", s, ss)) >= 0 ) From patchwork Mon Jan 16 07:04:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xenia Ragiadakou X-Patchwork-Id: 13102672 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CD27CC678D7 for ; Mon, 16 Jan 2023 07:05:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.478336.741464 (Exim 4.92) (envelope-from ) id 1pHJYB-0007Nn-Nk; Mon, 16 Jan 2023 07:04:59 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 478336.741464; Mon, 16 Jan 2023 07:04:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pHJYB-0007Ng-Ka; Mon, 16 Jan 2023 07:04:59 +0000 Received: by outflank-mailman (input) for mailman id 478336; Mon, 16 Jan 2023 07:04:58 +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 1pHJY9-00077f-Su for xen-devel@lists.xenproject.org; Mon, 16 Jan 2023 07:04:58 +0000 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [2a00:1450:4864:20::535]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 154c79fc-956c-11ed-91b6-6bf2151ebd3b; Mon, 16 Jan 2023 08:04:56 +0100 (CET) Received: by mail-ed1-x535.google.com with SMTP id y19so5875906edc.2 for ; Sun, 15 Jan 2023 23:04:56 -0800 (PST) Received: from uni.router.wind (adsl-67.109.242.224.tellas.gr. [109.242.224.67]) by smtp.googlemail.com with ESMTPSA id v15-20020a056402184f00b0046c5baa1f58sm10990824edy.97.2023.01.15.23.04.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Jan 2023 23:04:55 -0800 (PST) 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: 154c79fc-956c-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=U1neDOzq+0HPMCn8Gxw25YMbFizPFUqx82cwaRPbvKM=; b=YOCIbQpk3MkERrpCOGsmLsudRonoBRC3lSPg7RQfcsd9xhfXCk/KBTc+DRSht/tUU6 4pBhqpOIL2L610GIkFzYARa64U0yDQzYqZLoih7RlffrZqM8q5vgK13RnpWMstTwdn2S Bl8uYGk3qQw4JwXGKcKrbTL0iBGVJGbje/wuZHVJWH2bKGdBWRwBpRtjrH1K+dI+YQ0i fc6ipaQ4lkdu/Jq6RYDwcv5yAbcamm1PHHWgUBPIcTN1ea5jWTsIXHssi3BIov31xugU ZsTvaPTvQQPtunNGSCXV6pfEPDmsbgBEZD1fDiY/sAyrIxnN5UUcMYp6Of6+qY/+rCP1 a4eg== 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=U1neDOzq+0HPMCn8Gxw25YMbFizPFUqx82cwaRPbvKM=; b=pJcmf0Kamzb+tSTGZm+tlZeP2P1XwzJepKmZVdN6K53Kle9vc6WjGZFy2qpv3c256d HeYElcArT5zU30p66XVsjhEgIlyPw9ntw7Bekdf4oSeZjHtaUo/84Gc8T1Zu9SPuYamL VyjwXQj5HD3DBkXpK6I0kPyryt+S9g7cuzvT1rtbDdrTUrOvN0ZJQ+oc8L+7p7giLM40 RFaWnQVPSPZmaR6GoIvs9KbgHyRCAHhbuehl8mdOUoLBH1Hc8ghUPSGDj4b4G3w0oEYf +Z1OwQwoiTLiIYns/p8lIl+GbGaF8W4oCvWKBeb7zzH+XGEIGkA6QPw8+bOrZ5hYtkk1 d0ww== X-Gm-Message-State: AFqh2ko3ipfIEnCSWv3u4BYu7HtLC/7hUswzJ+b2ZYqULA2z1k7ooyzz qWK/X43s2x0RTR3hHcP8PxiZyfBhFWo= X-Google-Smtp-Source: AMrXdXs4zO27qoHXCunCPvFvXsJ+dOF/tfY+KglxUAtIxkhOZZxJK9V4h89mHXIwXNl/jGdEx7nhpQ== X-Received: by 2002:a50:ed91:0:b0:48e:c073:9453 with SMTP id h17-20020a50ed91000000b0048ec0739453mr10559134edr.15.1673852695898; Sun, 15 Jan 2023 23:04:55 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Paul Durrant , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v3 2/8] x86/iommu: iommu_igfx and iommu_qinval are Intel VT-d specific Date: Mon, 16 Jan 2023 09:04:25 +0200 Message-Id: <20230116070431.905594-3-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116070431.905594-1-burzalodowa@gmail.com> References: <20230116070431.905594-1-burzalodowa@gmail.com> MIME-Version: 1.0 Use CONFIG_INTEL_IOMMU to guard the usage of iommu_igfx and iommu_qinval in common code. No functional change intended. Signed-off-by: Xenia Ragiadakou Reviewed-by: Jan Beulich --- Changes in v3: - handle iommu_snoop case in a different patch and update commit msg - use no_config_param() to print a warning when the user sets an INTEL_IOMMU specific string in the iommu boot parameter and INTEL_IOMMU is disabled xen/drivers/passthrough/iommu.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c index 9d95fb27d0..b4dfa95dfd 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -82,11 +82,19 @@ static int __init cf_check parse_iommu_param(const char *s) else if ( ss == s + 23 && !strncmp(s, "quarantine=scratch-page", 23) ) iommu_quarantine = IOMMU_quarantine_scratch_page; #endif -#ifdef CONFIG_X86 else if ( (val = parse_boolean("igfx", s, ss)) >= 0 ) +#ifdef CONFIG_INTEL_IOMMU iommu_igfx = val; +#else + no_config_param("INTEL_IOMMU", "iommu", s, ss); +#endif else if ( (val = parse_boolean("qinval", s, ss)) >= 0 ) +#ifdef CONFIG_INTEL_IOMMU iommu_qinval = val; +#else + no_config_param("INTEL_IOMMU", "iommu", s, ss); +#endif +#ifdef CONFIG_X86 else if ( (val = parse_boolean("superpages", s, ss)) >= 0 ) iommu_superpages = val; #endif From patchwork Mon Jan 16 07:04:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xenia Ragiadakou X-Patchwork-Id: 13102671 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 288D9C678D9 for ; Mon, 16 Jan 2023 07:05:14 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.478337.741475 (Exim 4.92) (envelope-from ) id 1pHJYD-0007eB-0a; Mon, 16 Jan 2023 07:05:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 478337.741475; Mon, 16 Jan 2023 07:05:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pHJYC-0007e2-Sq; Mon, 16 Jan 2023 07:05:00 +0000 Received: by outflank-mailman (input) for mailman id 478337; Mon, 16 Jan 2023 07:04:59 +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 1pHJYB-00077f-JL for xen-devel@lists.xenproject.org; Mon, 16 Jan 2023 07:04:59 +0000 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [2a00:1450:4864:20::62d]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 169c8c69-956c-11ed-91b6-6bf2151ebd3b; Mon, 16 Jan 2023 08:04:58 +0100 (CET) Received: by mail-ej1-x62d.google.com with SMTP id vw16so2677358ejc.12 for ; Sun, 15 Jan 2023 23:04:58 -0800 (PST) Received: from uni.router.wind (adsl-67.109.242.224.tellas.gr. [109.242.224.67]) by smtp.googlemail.com with ESMTPSA id v15-20020a056402184f00b0046c5baa1f58sm10990824edy.97.2023.01.15.23.04.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Jan 2023 23:04:57 -0800 (PST) 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: 169c8c69-956c-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=+O7AGGT5LTOYunZyjJAtUCNbg1rumh26m/rUSOWP+V8=; b=gnM2zjMwI7vjjXcR91Diixg4uJGE8qmSsFEfsKbwwi6+E2kDsroPHUbkT2WaxxsabD Tbidyx9PPeoClqRjDP27m/p8My0YU7dKan3BpKj2uQ9B4aJDM6q5yLWiYm7DG0MEphs4 SDROHxYu3s7hrjwGO2VQLG8H5VJEK0KGT437bcUPVmMrl8aj/2wRFWLiXCttsBHolqpD /Tdq0VuhCBrLgprdHm3/s/kjsT3/jaQHRGVVKQEEldb0BtJqf+xxdY9nFDoQRV/cdier AlkKUaFuHNBeFYwTeCbowm0DDoL5oP707cfJAPAFHl+mplYSpBDv7glfdXIyo1XadSiU RAsQ== 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=+O7AGGT5LTOYunZyjJAtUCNbg1rumh26m/rUSOWP+V8=; b=7S6d+JPBO1QUHb4blDIlPswuH9l0JwpeR8LuH6K1Ww9jbbHFqr+GeWmLcNeX77QP4B ima42rQ1ECjTc8fmV4Hxwpqo/x+g4wUJgiuyV05wwNm7+SuYo6NC757lb9phl9+YnUtN oN2tR8D4oeOXbeatUahySggkIRV9w4xXfRfER0mI8oz/KicLR/e7LLF4Q0KqOJEbc5Hz Ft14um3KDVhH7iNE2XmTuwvt35zXG/uDmvZ1EV4rJk7BoTQ2EMgZNTtTOi4yUSGMS3MY GW/xcqyab9HynnP4md5YfztS2PJcu+bc7JDiwjzMAJjLI9XFizPJ0QZcZnE82YcR1wfn j0pA== X-Gm-Message-State: AFqh2kpb3R516uz3xJZ0A3KAKB8759y4Hcfd40d5JCwcky7GFG5zCauB vCKfPTtIxF2IW2ncqS4k220ikEx9e9o= X-Google-Smtp-Source: AMrXdXsY8LEvyZQR6oxAA9fjTrWKYEuTodFSVjB2DHBN0suWBigssqmyj0d1Y0tw44Rtk8L47jiHhQ== X-Received: by 2002:a17:906:bc44:b0:870:95b6:94a4 with SMTP id s4-20020a170906bc4400b0087095b694a4mr2595244ejv.48.1673852698028; Sun, 15 Jan 2023 23:04:58 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Paul Durrant , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v3 3/8] x86/iommu: snoop control is allowed only by Intel VT-d Date: Mon, 16 Jan 2023 09:04:26 +0200 Message-Id: <20230116070431.905594-4-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116070431.905594-1-burzalodowa@gmail.com> References: <20230116070431.905594-1-burzalodowa@gmail.com> MIME-Version: 1.0 The AMD-Vi driver forces coherent accesses by hardwiring the FC bit to 1. Therefore, given that iommu_snoop is used only when the iommu is enabled, when Xen is configured with only the AMD iommu enabled, iommu_snoop can be reduced to a #define to true. No functional change intended. Signed-off-by: Xenia Ragiadakou Reviewed-by: Jan Beulich --- Changes in v3: - new patch This patch depends on Jan's patch "x86/shadow: sanitize iommu_snoop usage" to ensure that iommu_snoop is used only when the iommu is enabled xen/include/xen/iommu.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 4f22fc1bed..626731941b 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -74,7 +74,12 @@ extern enum __packed iommu_intremap { iommu_intremap_restricted, iommu_intremap_full, } iommu_intremap; -extern bool iommu_igfx, iommu_qinval, iommu_snoop; +extern bool iommu_igfx, iommu_qinval; +#ifdef CONFIG_INTEL_IOMMU +extern bool iommu_snoop; +#else +# define iommu_snoop true +#endif /* CONFIG_INTEL_IOMMU */ #else # define iommu_intremap false # define iommu_snoop false From patchwork Mon Jan 16 07:04:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xenia Ragiadakou X-Patchwork-Id: 13102673 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7FD77C54EBE for ; Mon, 16 Jan 2023 07:05:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.478338.741484 (Exim 4.92) (envelope-from ) id 1pHJYF-0007wz-91; Mon, 16 Jan 2023 07:05:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 478338.741484; Mon, 16 Jan 2023 07:05:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pHJYF-0007wq-5v; Mon, 16 Jan 2023 07:05:03 +0000 Received: by outflank-mailman (input) for mailman id 478338; Mon, 16 Jan 2023 07:05:02 +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 1pHJYD-00077f-Vk for xen-devel@lists.xenproject.org; Mon, 16 Jan 2023 07:05:02 +0000 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [2a00:1450:4864:20::52c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 17fe312e-956c-11ed-91b6-6bf2151ebd3b; Mon, 16 Jan 2023 08:05:01 +0100 (CET) Received: by mail-ed1-x52c.google.com with SMTP id v30so39457275edb.9 for ; Sun, 15 Jan 2023 23:05:01 -0800 (PST) Received: from uni.router.wind (adsl-67.109.242.224.tellas.gr. [109.242.224.67]) by smtp.googlemail.com with ESMTPSA id v15-20020a056402184f00b0046c5baa1f58sm10990824edy.97.2023.01.15.23.04.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Jan 2023 23:05:00 -0800 (PST) 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: 17fe312e-956c-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=PpFKQyBz/d1EHnJYrbWB9uWY4J6FRm55N2ci72k9mak=; b=fstejPwJ4VDhCtYQDIAR7deIFG0CNd1qnz8sEUjV7iOuZNi9W+tIlxax5FWBDgQchi vl4Kncwjg+M40qUwzCErbWQcWY05Blp5f5b6wwuLPKzstAUfIEihspP86vQz0n05GEWC HSwxPkZwfOzTewVGX6qlB8adj6V3IRPesaTqtqM65B2efVWY1nu59l8Tbq3fVaG6pWhr G36ReBaRw25wXJ5/KGNQS9zmjFo8peHj6YBLHWdpY3zFHJfnX+h4WXoZd80jiyiWmE17 zreqbFNUT5Tq//YPa8x8uDHpN2EN3ui7tUdoL3VwAikkoLJ98U04zJXmTY0vRN+1rLkU NGcQ== 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=PpFKQyBz/d1EHnJYrbWB9uWY4J6FRm55N2ci72k9mak=; b=oSJfZJ6vT0FHf3wzf+9MJM2J8MzncoXXPiv5N6FBlzwF15QJ1c11IHiUjgzdyUcb3/ ppCyysmfSo+9L6lCXwAIJHHpz8M074A6KTloOifsomayxTFWqm7FXbe7HBpzHjYI449S yucjDBONT3jlotKVsxqDRt0w7dxv2Rztv0/DTqr8WbEtS4SfQVKtjdqyU/BTlxJW8+bm 685z8Jz2u/WyZh6TKhxSUrbmwaa3p3zAyVg4NdUmZkxfBvCDVrrQ1rsWIpjSAJcW3YSe iqfLwLSTHFJN/x8vi6BuCaTqqCcYYrM+hUIatfNWQsNdrOcx5y99cNP5RaMsXythjGOQ GMuw== X-Gm-Message-State: AFqh2kpyktgq5fepoC71nP0yhbLndfjLS3sherXvZ8Erkdw1OnKWt87H dl/wgs1Z6kV9pBRcUHZlRr8utDb1JyU= X-Google-Smtp-Source: AMrXdXuf/XxEfoHGwGw1ENaSPe9IGLDSq5yqMvSGhWEq+9x088+3yFDlog7T3dGMjfvZh4IoOt02Yw== X-Received: by 2002:aa7:cb94:0:b0:496:6a20:6b61 with SMTP id r20-20020aa7cb94000000b004966a206b61mr29625347edt.22.1673852700440; Sun, 15 Jan 2023 23:05:00 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu , George Dunlap , Julien Grall , Stefano Stabellini Subject: [PATCH v3 4/8] x86/acpi: separate AMD-Vi and VT-d specific functions Date: Mon, 16 Jan 2023 09:04:27 +0200 Message-Id: <20230116070431.905594-5-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116070431.905594-1-burzalodowa@gmail.com> References: <20230116070431.905594-1-burzalodowa@gmail.com> MIME-Version: 1.0 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 declaration of acpi_dmar_init from the x86 arch-specific header to the common header, since Intel VT-d has been also used on IA-64 platforms. No functional change intended. Signed-off-by: Xenia Ragiadakou Reviewed-by: Jan Beulich --- Changes in v3: - move the declarations of Intel VT-d functions to the common header, because Intel VT-d has been also used on IA-64 platforms, and update the commit log accordingly xen/arch/x86/include/asm/acpi.h | 6 +++++- xen/include/xen/acpi.h | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/include/asm/acpi.h b/xen/arch/x86/include/asm/acpi.h index c453450a74..6ce79ce465 100644 --- a/xen/arch/x86/include/asm/acpi.h +++ b/xen/arch/x86/include/asm/acpi.h @@ -140,8 +140,12 @@ extern u32 pmtmr_ioport; extern unsigned int pmtmr_width; void acpi_iommu_init(void); -int acpi_dmar_init(void); + +#ifdef CONFIG_AMD_IOMMU int acpi_ivrs_init(void); +#else +static inline int acpi_ivrs_init(void) { return -ENODEV; } +#endif void acpi_mmcfg_init(void); diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h index 1b9c75e68f..352f27f6a7 100644 --- a/xen/include/xen/acpi.h +++ b/xen/include/xen/acpi.h @@ -206,8 +206,15 @@ static inline int acpi_get_pxm(acpi_handle handle) void acpi_reboot(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 #endif /* __ASSEMBLY__ */ From patchwork Mon Jan 16 07:04:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xenia Ragiadakou X-Patchwork-Id: 13102669 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BCAC7C67871 for ; Mon, 16 Jan 2023 07:05:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.478339.741494 (Exim 4.92) (envelope-from ) id 1pHJYI-0008IF-Iq; Mon, 16 Jan 2023 07:05:06 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 478339.741494; Mon, 16 Jan 2023 07:05:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pHJYI-0008I6-EW; Mon, 16 Jan 2023 07:05:06 +0000 Received: by outflank-mailman (input) for mailman id 478339; Mon, 16 Jan 2023 07:05:05 +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 1pHJYH-0006sD-G2 for xen-devel@lists.xenproject.org; Mon, 16 Jan 2023 07:05:05 +0000 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [2a00:1450:4864:20::52c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 19843c94-956c-11ed-b8d0-410ff93cb8f0; Mon, 16 Jan 2023 08:05:03 +0100 (CET) Received: by mail-ed1-x52c.google.com with SMTP id x10so36565834edd.10 for ; Sun, 15 Jan 2023 23:05:03 -0800 (PST) Received: from uni.router.wind (adsl-67.109.242.224.tellas.gr. [109.242.224.67]) by smtp.googlemail.com with ESMTPSA id v15-20020a056402184f00b0046c5baa1f58sm10990824edy.97.2023.01.15.23.05.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Jan 2023 23:05:02 -0800 (PST) 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: 19843c94-956c-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=7dy2BgTNKVXOkcEoPRHI+Qc+RIk111AGiSJu7FgSGxM=; b=JavYjN879rVFqWYTMfx5K7T7u+VhhAZtIXkySIIz3B+qj6EJzd+Nzv34MpCwey9i5M ZZ7w3kI9WnYByK1t1wC3JITstU/8mIyys9/jlHrXaUscW155uUIIQpSSc7eRcd3rnMBi Vu+YyQhjpdDMqB1OwDPuS/ycjiBxIoHu1aqoNPD4W7GjJLGNOzhRwy/54TStKoK6BTMb PLD9fAFgyU8x/jf6YUUPhx6xRw2wo0m/TUFMZNKsx9oHQsXdNUr/H45H2XnegiuzM4jB 2cg74rgunfLVgnjCMAyAHW67rYG3GGBvHWxh50h8xs5xnSI8cMTKoSLKFBxSWP2T37Pg AWXg== 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=7dy2BgTNKVXOkcEoPRHI+Qc+RIk111AGiSJu7FgSGxM=; b=i/AyL56Wt+aacBTWWt6s+MVQVJo7j8EOK6MQ4r4cKmVIyAXw1F0TkpCjzc3U/fzha9 vqgBkYC6lhyFT2HZgO9ypcJf9TZMcUl30kXTrobBzGsixofMEIyvO5u/1l3OzMuiTUHU FuF9PKLE3smDh6JpJCVv6Z6c/nWYcbPY+yd08zNsV68FMlopv0IAU5yvuEjUmreG0VoZ 1kVwnM5XRjmKCUCvumuBCBVuirnkADbmyZ9GiDo8YcNuOvxCiH7AY9zJAZ2Mrb6QKjzs vXVThq6ut6MD2T0wlBddGrmY8siYqKZ/oyY0J4C1LLgs2sPAk9oAMT2dkg+JmCOtoNL7 ZfwQ== X-Gm-Message-State: AFqh2kqFHhZv8xnHpebKtNSJGWV0DUlXvAfSWMGrm1f/bFWmOG5uOIDo C1Rmr/dc1U03bHJdFLOdK4h5rk/V2iY= X-Google-Smtp-Source: AMrXdXsD39gY8491njMzdZaxfuDf6M6qULTZ1eY93Aw31t7bwSMmoksTT7XyzW2FArG1yunOZoa3nQ== X-Received: by 2002:a05:6402:b55:b0:49d:d8ec:cbd3 with SMTP id bx21-20020a0564020b5500b0049dd8eccbd3mr6984361edb.16.1673852702961; Sun, 15 Jan 2023 23:05:02 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Kevin Tian , Jan Beulich , Paul Durrant , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v3 5/8] x86/iommu: make code addressing CVE-2011-1898 no VT-d specific Date: Mon, 16 Jan 2023 09:04:28 +0200 Message-Id: <20230116070431.905594-6-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116070431.905594-1-burzalodowa@gmail.com> References: <20230116070431.905594-1-burzalodowa@gmail.com> MIME-Version: 1.0 The variable untrusted_msi indicates whether the system is vulnerable to CVE-2011-1898 due to the absence of interrupt remapping support. AMD iommus with interrupt remapping disabled are also exposed. Therefore move the definition of the variable to the common x86 iommu code. Also, since the current implementation assumes that only PV guests are prone to this attack, take the opportunity to define untrusted_msi only when PV is enabled. No functional change intended. Signed-off-by: Xenia Ragiadakou Reviewed-by: Jan Beulich --- Changes in v3: - change untrusted_msi from being VT-d specific to PV specific and update commit log accordingly - remove unnecessary #ifdef guard from its declaration xen/drivers/passthrough/vtd/iommu.c | 3 --- xen/drivers/passthrough/x86/iommu.c | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index 62e143125d..dae2426cb9 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -54,9 +54,6 @@ ? dom_iommu(d)->arch.vtd.pgd_maddr \ : (pdev)->arch.vtd.pgd_maddr) -/* Possible unfiltered LAPIC/MSI messages from untrusted sources? */ -bool __read_mostly untrusted_msi; - bool __read_mostly iommu_igfx = true; bool __read_mostly iommu_qinval = true; #ifndef iommu_snoop diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/x86/iommu.c index f671b0f2bb..c5021ea023 100644 --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -36,6 +36,11 @@ bool __initdata iommu_superpages = true; enum iommu_intremap __read_mostly iommu_intremap = iommu_intremap_full; +#ifdef CONFIG_PV +/* Possible unfiltered LAPIC/MSI messages from untrusted sources? */ +bool __read_mostly untrusted_msi; +#endif + #ifndef iommu_intpost /* * In the current implementation of VT-d posted interrupts, in some extreme From patchwork Mon Jan 16 07:04:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xenia Ragiadakou X-Patchwork-Id: 13102674 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7B84FC54EBE for ; Mon, 16 Jan 2023 07:05:18 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.478340.741504 (Exim 4.92) (envelope-from ) id 1pHJYL-0000EA-Sy; Mon, 16 Jan 2023 07:05:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 478340.741504; Mon, 16 Jan 2023 07:05:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pHJYL-0000Ds-PZ; Mon, 16 Jan 2023 07:05:09 +0000 Received: by outflank-mailman (input) for mailman id 478340; Mon, 16 Jan 2023 07:05:08 +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 1pHJYK-0006sD-40 for xen-devel@lists.xenproject.org; Mon, 16 Jan 2023 07:05:08 +0000 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [2a00:1450:4864:20::52c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1b087e99-956c-11ed-b8d0-410ff93cb8f0; Mon, 16 Jan 2023 08:05:06 +0100 (CET) Received: by mail-ed1-x52c.google.com with SMTP id x10so36565942edd.10 for ; Sun, 15 Jan 2023 23:05:06 -0800 (PST) Received: from uni.router.wind (adsl-67.109.242.224.tellas.gr. [109.242.224.67]) by smtp.googlemail.com with ESMTPSA id v15-20020a056402184f00b0046c5baa1f58sm10990824edy.97.2023.01.15.23.05.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Jan 2023 23:05:05 -0800 (PST) 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: 1b087e99-956c-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=5xQjSd77lIkGjcOqGsMIhqf/ThCEh+wIVWJkvdxosCY=; b=GZGC3XrcSwMB5M67O/4zd6fZu5sD6S/kwnQuEK7AavL3QHbLS845CkzH0/sfI63DmA tqMMt88aIK6SshHlWB90WGuvZeo0NOSXYn7KgqcDCuEJ7yWgCbX4Rz9VBG8n4LdeCCFw S0vOuFXJIX0cXvNDL2spIC3H/bZiz/3+0R8ANCLAgJPV1334l/ibYXECVnwmEhXQ4nMQ 7DJQLCcofqHgGKlbGKQgG1n3IF2tHF2m66eFgfgWgU50TeoVd2isuRuiQPjxY2VpZbIx A0HOwMo4PIrFyN9MSJb/YbDiIIFSFHPgQ/RFx+9BWHJT7tC64SHxbvTqUlsL5Uj0Lntc C41g== 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=5xQjSd77lIkGjcOqGsMIhqf/ThCEh+wIVWJkvdxosCY=; b=y3hEE0A/QnpZ2R75DaDAK5Ob5Dvft85vayHVkjIQ53lHrWr737OYzFdXi7BdB9JfH7 ExrzkpDcLXdefVf3tQZMKgTd+plJE8mZFek5j4cNe2wiC1dOlJrxpe+DpP4JhB0jY3YS rQw40tBvDDOSKjTOL6k1dj7Pn9Ekz15J0r6wNsIn3uPIUyIR6FeeviB6mY5K+R4vpZdH m9WEgZKcJ0rorTnzr68Yw5xG3eUVHwv8L+H/4ZOpK6Cnu9hOCDT7s/kqulgC6wBlUdSv BPNNVU+GRJXfmw4cc6ghmONb7LsIwahSTmGoCQlAOWFG12wsSHW4mfpNzB1yexvnnjaf gc+A== X-Gm-Message-State: AFqh2kqIRVhj8T4xa2nrT/Eo+Ul3DOqsDAHXmUDFJ6P6/goBssM/ZXlo PtWYcZfChgeGs0D+BXQ+XarcMRZg+40= X-Google-Smtp-Source: AMrXdXuoO4AAYEqAhjXlKKR6+QSqoRZBbFqFzEdZfUMVTjxLLbRArYeoLMqNQE9/nB+xMfvoxv81jw== X-Received: by 2002:a05:6402:201:b0:497:4311:59c7 with SMTP id t1-20020a056402020100b00497431159c7mr8700190edv.18.1673852705406; Sun, 15 Jan 2023 23:05:05 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Jun Nakajima , Kevin Tian , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu , Paul Durrant Subject: [PATCH v3 6/8] x86/iommu: call pi_update_irte through an hvm_function callback Date: Mon, 16 Jan 2023 09:04:29 +0200 Message-Id: <20230116070431.905594-7-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116070431.905594-1-burzalodowa@gmail.com> References: <20230116070431.905594-1-burzalodowa@gmail.com> MIME-Version: 1.0 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. Since the posted interrupt descriptor is Intel VT-x specific while msi_msg_write_remap_rte is iommu specific, open code pi_update_irte() inside vmx_pi_update_irte() but replace msi_msg_write_remap_rte() with generic iommu_update_ire_from_msi(). That way vmx_pi_update_irte() is not bound to Intel VT-d anymore. Remove the now unused pi_update_irte() implementation. No functional change intended. Signed-off-by: Xenia Ragiadakou --- Changes in v3: - open code pi_update_irte() in vmx_pi_update_irte() but instead of using the VT-d specific function msi_msg_write_remap_rte() use the generic iommu_update_ire_from_msi() - delete pi_update_irte() from vtd/intremap.c - move the initialization of vmx pi_update_irte stub to start_vmx() and perform it only if iommu_intpost is enabled. - move pi_update_irte right after handle_eoi xen/arch/x86/hvm/vmx/vmx.c | 41 ++++++++++++++++++++++++++ xen/arch/x86/include/asm/hvm/hvm.h | 10 +++++++ xen/arch/x86/include/asm/iommu.h | 3 -- xen/drivers/passthrough/vtd/intremap.c | 36 ---------------------- xen/drivers/passthrough/x86/hvm.c | 5 ++-- 5 files changed, 53 insertions(+), 42 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 15a07933ee..a5355dbac2 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -396,6 +396,43 @@ void vmx_pi_hooks_deassign(struct domain *d) domain_unpause(d); } +/* + * This function is used to update the IRTE for posted-interrupt + * when guest changes MSI/MSI-X information. + */ +static int cf_check vmx_pi_update_irte(const struct vcpu *v, + const struct pirq *pirq, uint8_t gvec) +{ + const struct pi_desc *pi_desc = v ? &v->arch.hvm.vmx.pi_desc : NULL; + struct irq_desc *desc; + struct msi_desc *msi_desc; + int rc; + + desc = pirq_spin_lock_irq_desc(pirq, NULL); + if ( !desc ) + return -EINVAL; + + msi_desc = desc->msi_desc; + if ( !msi_desc ) + { + rc = -ENODEV; + goto unlock_out; + } + msi_desc->pi_desc = pi_desc; + msi_desc->gvec = gvec; + + spin_unlock_irq(&desc->lock); + + ASSERT(pcidevs_locked()); + + return iommu_update_ire_from_msi(msi_desc, &msi_desc->msg); + + unlock_out: + spin_unlock_irq(&desc->lock); + + return rc; +} + static const struct lbr_info { u32 base, count; } p4_lbr[] = { @@ -2969,8 +3006,12 @@ const struct hvm_function_table * __init start_vmx(void) { alloc_direct_apic_vector(&posted_intr_vector, pi_notification_interrupt); if ( iommu_intpost ) + { alloc_direct_apic_vector(&pi_wakeup_vector, pi_wakeup_interrupt); + vmx_function_table.pi_update_irte = vmx_pi_update_irte; + } + vmx_function_table.deliver_posted_intr = vmx_deliver_posted_intr; vmx_function_table.sync_pir_to_irr = vmx_sync_pir_to_irr; vmx_function_table.test_pir = vmx_test_pir; diff --git a/xen/arch/x86/include/asm/hvm/hvm.h b/xen/arch/x86/include/asm/hvm/hvm.h index 93254651f2..b1990a047c 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 +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; @@ -213,6 +215,8 @@ struct hvm_function_table { void (*sync_pir_to_irr)(struct vcpu *v); bool (*test_pir)(const struct vcpu *v, uint8_t vector); void (*handle_eoi)(uint8_t vector, int isr); + int (*pi_update_irte)(const struct vcpu *v, const struct pirq *pirq, + uint8_t gvec); /*Walk nested p2m */ int (*nhvm_hap_walk_L1_p2m)(struct vcpu *v, paddr_t L2_gpa, @@ -774,6 +778,12 @@ static inline void hvm_set_nonreg_state(struct vcpu *v, alternative_vcall(hvm_funcs.set_nonreg_state, v, nrs); } +static inline int hvm_pi_update_irte(const struct vcpu *v, + const struct pirq *pirq, uint8_t gvec) +{ + return alternative_call(hvm_funcs.pi_update_irte, v, pirq, gvec); +} + #else /* CONFIG_HVM */ #define hvm_enabled false diff --git a/xen/arch/x86/include/asm/iommu.h b/xen/arch/x86/include/asm/iommu.h index fc0afe35bf..4794e72cf1 100644 --- a/xen/arch/x86/include/asm/iommu.h +++ b/xen/arch/x86/include/asm/iommu.h @@ -129,9 +129,6 @@ void iommu_identity_map_teardown(struct domain *d); extern bool untrusted_msi; -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; static inline void iommu_sync_cache(const void *addr, unsigned int size) diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers/passthrough/vtd/intremap.c index 1512e4866b..b39bc83282 100644 --- a/xen/drivers/passthrough/vtd/intremap.c +++ b/xen/drivers/passthrough/vtd/intremap.c @@ -866,39 +866,3 @@ void cf_check intel_iommu_disable_eim(void) for_each_drhd_unit ( drhd ) disable_qinval(drhd->iommu); } - -/* - * This function is used to update the IRTE for posted-interrupt - * when guest changes MSI/MSI-X information. - */ -int pi_update_irte(const struct pi_desc *pi_desc, const struct pirq *pirq, - const uint8_t gvec) -{ - struct irq_desc *desc; - struct msi_desc *msi_desc; - int rc; - - desc = pirq_spin_lock_irq_desc(pirq, NULL); - if ( !desc ) - return -EINVAL; - - msi_desc = desc->msi_desc; - if ( !msi_desc ) - { - rc = -ENODEV; - goto unlock_out; - } - msi_desc->pi_desc = pi_desc; - msi_desc->gvec = gvec; - - spin_unlock_irq(&desc->lock); - - ASSERT(pcidevs_locked()); - - return msi_msg_write_remap_rte(msi_desc, &msi_desc->msg); - - unlock_out: - spin_unlock_irq(&desc->lock); - - return rc; -} diff --git a/xen/drivers/passthrough/x86/hvm.c b/xen/drivers/passthrough/x86/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( /* 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); if ( pt_irq_bind->u.msi.gflags & XEN_DOMCTL_VMSI_X86_UNMASKED ) { @@ -672,7 +671,7 @@ int pt_irq_destroy_bind( what = "bogus"; } else if ( pirq_dpci && pirq_dpci->gmsi.posted ) - pi_update_irte(NULL, pirq, 0); + hvm_pi_update_irte(NULL, pirq, 0); if ( pirq_dpci && (pirq_dpci->flags & HVM_IRQ_DPCI_MAPPED) && list_empty(&pirq_dpci->digl_list) ) From patchwork Mon Jan 16 07:04:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xenia Ragiadakou X-Patchwork-Id: 13102675 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 419C8C46467 for ; Mon, 16 Jan 2023 07:05:19 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.478342.741514 (Exim 4.92) (envelope-from ) id 1pHJYN-0000ZO-8T; Mon, 16 Jan 2023 07:05:11 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 478342.741514; Mon, 16 Jan 2023 07:05: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 1pHJYN-0000Yr-3r; Mon, 16 Jan 2023 07:05:11 +0000 Received: by outflank-mailman (input) for mailman id 478342; Mon, 16 Jan 2023 07:05: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 1pHJYL-00077f-Sj for xen-devel@lists.xenproject.org; Mon, 16 Jan 2023 07:05:10 +0000 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [2a00:1450:4864:20::52d]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1c6aa1c2-956c-11ed-91b6-6bf2151ebd3b; Mon, 16 Jan 2023 08:05:08 +0100 (CET) Received: by mail-ed1-x52d.google.com with SMTP id v13so5336401eda.11 for ; Sun, 15 Jan 2023 23:05:08 -0800 (PST) Received: from uni.router.wind (adsl-67.109.242.224.tellas.gr. [109.242.224.67]) by smtp.googlemail.com with ESMTPSA id v15-20020a056402184f00b0046c5baa1f58sm10990824edy.97.2023.01.15.23.05.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Jan 2023 23:05:07 -0800 (PST) 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: 1c6aa1c2-956c-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=FGOhxxftnqS09dviAWeYBv4kGOGjyoGhBUYO7YzYbYs=; b=OZ6V5vdKz7FFRoISBZXF7APZzMyRs4Dekxlt/ZX8BMBYrEh9WNRKmjL+QRljNKO3YV IaT96mDVLeZW/4wHYy7Qx7XBIiEI4KM+5YpmCWLF12pEMxZnWVjQVH1uj0FO7OIh6KTF rj4L8ACmVVW3qs7SvlizAVUqOIdk4UrGpoNy8DpoesdH7WcU4mvpCOYSA4PXXQ9AuI3D anOIST4FrAyPAi2WGg1Xk7da7jc4tiYWrEnkQZTE7Grqzju18zj614RSq1/tbe0ymxw2 gvK3YlSxyoHoozQI1p3PNQIlmvTCswMYIpAdI4PFgWutfntmKHNBgzFcE9f6054bip0A IKXw== 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=FGOhxxftnqS09dviAWeYBv4kGOGjyoGhBUYO7YzYbYs=; b=47CVnAnDJ0ud8fpXuaJ9XIrnLTOhdta/EU2mJAqg8Wj52m4qjYKId3mny5Kkp+yoIS Sq9S6lQ8auooEhOA0f1hIWTeFQLGRI6kN0LSE+lBwm0AgVb4+nwj1D00CpxcE0C4JjU3 NcTOT71BvwriiRuv2fiPllnshyEhZMjve8KS/iTxrBTwdWCjS6Kb+0ZshmPcPXG+Px0K IWYJtNeaT7fydUmQmTgx/7wl9NnZ6JFDVoae6EYyJ7CcvyLYOUZuBknEpEOmjxTMgzv0 4fgCvK/e2N9FQNOS9Z5Bgx+ghDO20AOBMFBYd1gkhBVW3TDc51NHPvI0kiEWnSfTn+NP hRgQ== X-Gm-Message-State: AFqh2krxDxJdWwi/9eM/hzhU2oyKCZIjFBkLhInfgO3NIzvADJzAHtns jhQi34lfh3WozIWZ678NaBOKipKqbUA= X-Google-Smtp-Source: AMrXdXsvE+JsU2LZw6kyJBg/vfrH3k7HKGQmR4l10D1ovSVMoTnbGcwDyIItl91Muq+VqxxBPZzpmw== X-Received: by 2002:a05:6402:b02:b0:499:e564:a1c with SMTP id bm2-20020a0564020b0200b00499e5640a1cmr7513207edb.11.1673852707760; Sun, 15 Jan 2023 23:05:07 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Kevin Tian , Jan Beulich , Paul Durrant , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v3 7/8] x86/dpci: move hvm_dpci_isairq_eoi() to generic HVM code Date: Mon, 16 Jan 2023 09:04:30 +0200 Message-Id: <20230116070431.905594-8-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116070431.905594-1-burzalodowa@gmail.com> References: <20230116070431.905594-1-burzalodowa@gmail.com> MIME-Version: 1.0 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 function is used only in this file, declare it static. No functional change intended. Signed-off-by: Xenia Ragiadakou Reviewed-by: Jan Beulich --- Changes in v3: - in _hvm_dpci_isairq_eoi(), make hvm_irq pointer to const - in hvm_dpci_isairq_eoi(), make dpci pointer to const, add a blank line after ASSERT(isairq < NR_ISAIRQS), add a blank line before write_unlock() - fix typo in commit log, s/funcion/function/ - add Jan's Reviewed-by tag xen/drivers/passthrough/vtd/x86/Makefile | 1 - xen/drivers/passthrough/vtd/x86/hvm.c | 64 ------------------------ xen/drivers/passthrough/x86/hvm.c | 45 +++++++++++++++++ xen/include/xen/iommu.h | 1 - 4 files changed, 45 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/passthrough/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 += ats.o -obj-$(CONFIG_HVM) += hvm.o obj-y += vtd.o diff --git a/xen/drivers/passthrough/vtd/x86/hvm.c b/xen/drivers/passthrough/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 for - * 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 = hvm_domain_irq(d); - unsigned int isairq = (long)arg; - const struct dev_intx_gsi_link *digl; - - list_for_each_entry ( digl, &pirq_dpci->digl_list, list ) - { - unsigned int link = hvm_pci_intx_link(digl->device, digl->intx); - - if ( hvm_irq->pci_link.route[link] == isairq ) - { - hvm_pci_intx_deassert(d, digl->device, digl->intx); - if ( --pirq_dpci->pending == 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 = NULL; - - ASSERT(isairq < NR_ISAIRQS); - if ( !is_iommu_enabled(d) ) - return; - - write_lock(&d->event_lock); - - dpci = 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/x86/hvm.c index e720461a14..6bbd04bf3d 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 */ @@ -924,6 +925,50 @@ static void hvm_gsi_eoi(struct domain *d, unsigned int gsi) hvm_pirq_eoi(pirq); } +static int cf_check _hvm_dpci_isairq_eoi( + struct domain *d, struct hvm_pirq_dpci *pirq_dpci, void *arg) +{ + const struct hvm_irq *hvm_irq = hvm_domain_irq(d); + unsigned int isairq = (long)arg; + const struct dev_intx_gsi_link *digl; + + list_for_each_entry ( digl, &pirq_dpci->digl_list, list ) + { + unsigned int link = hvm_pci_intx_link(digl->device, digl->intx); + + if ( hvm_irq->pci_link.route[link] == isairq ) + { + hvm_pci_intx_deassert(d, digl->device, digl->intx); + if ( --pirq_dpci->pending == 0 ) + pirq_guest_eoi(dpci_pirq(pirq_dpci)); + } + } + + return 0; +} + +static void hvm_dpci_isairq_eoi(struct domain *d, unsigned int isairq) +{ + const struct hvm_irq_dpci *dpci = NULL; + + ASSERT(isairq < NR_ISAIRQS); + + if ( !is_iommu_enabled(d) ) + return; + + write_lock(&d->event_lock); + + dpci = 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 626731941b..405db59971 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -201,7 +201,6 @@ int hvm_do_IRQ_dpci(struct domain *, struct pirq *); int pt_irq_create_bind(struct domain *, const struct xen_domctl_bind_pt_irq *); int pt_irq_destroy_bind(struct domain *, const struct xen_domctl_bind_pt_irq *); -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); From patchwork Mon Jan 16 07:04:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xenia Ragiadakou X-Patchwork-Id: 13102676 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4931DC46467 for ; Mon, 16 Jan 2023 07:05:22 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.478344.741525 (Exim 4.92) (envelope-from ) id 1pHJYP-00015Z-Me; Mon, 16 Jan 2023 07:05:13 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 478344.741525; Mon, 16 Jan 2023 07:05: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 1pHJYP-000155-HQ; Mon, 16 Jan 2023 07:05:13 +0000 Received: by outflank-mailman (input) for mailman id 478344; Mon, 16 Jan 2023 07:05: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 1pHJYN-00077f-Nx for xen-devel@lists.xenproject.org; Mon, 16 Jan 2023 07:05:11 +0000 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [2a00:1450:4864:20::535]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1dcc2f81-956c-11ed-91b6-6bf2151ebd3b; Mon, 16 Jan 2023 08:05:10 +0100 (CET) Received: by mail-ed1-x535.google.com with SMTP id w14so22136567edi.5 for ; Sun, 15 Jan 2023 23:05:10 -0800 (PST) Received: from uni.router.wind (adsl-67.109.242.224.tellas.gr. [109.242.224.67]) by smtp.googlemail.com with ESMTPSA id v15-20020a056402184f00b0046c5baa1f58sm10990824edy.97.2023.01.15.23.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Jan 2023 23:05:09 -0800 (PST) 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: 1dcc2f81-956c-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=iFtAIFWagelWwYtF1JcxxpIotxhdCnsB0YtD2VA9RRo=; b=RT//jZDLvmix66SORRWgKClrn5/Rfa9SfWfdd01NqS2+KeNxcbUjgD3ynhoeDOC9FN 8cH7b0b0SImNbTWC/H4xsCDsBPMVp8kXunVuILoXAhGyRBUlYaGXpvsSOUeWOWGJWgLh v5VkLHYur8nQMtheKKXu5/v9FkBWpwDUshk6X12qLiGKgU+JICuO+8dSoYH/GySQQ5RL HsbRWRphVQcSKP7y3m6RbWVXV5sRa0/v54n6BVf/+i0UrZRHT5jYnfmO0sfZxnR1teaY w+BL6m1tHsR2Wnl6Jh+nRkR5OI2OpVJ6DRGi456WAbapgq/Vo+gcREbkB+bv3mCZIX6T JMwQ== 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=iFtAIFWagelWwYtF1JcxxpIotxhdCnsB0YtD2VA9RRo=; b=E6ngn+JYNwQLOVfKCgPLIjqieR8j3XFFtQam0Zc4mwe6RP2zjUmHku6XEiiZq4oTFi XGX7V9xhONDYSaKn1Y5tivg13ZHj09V5DQRPCVFoJzzWX+epp/N/Ek1+XQKqRFM9LTMS 9EICp8nDSWqTbhVgiljXfZJMplmg9cMPmRWZQ9h8jkg046v9CFJV6X5mkFlkKq12d3sj ECJmNBICsEcYQsJV0NmUSyA8cUw6Tv4cu2yDW69fiFgyK9vfR90rKavtlU+gUh+rrMXl Iwm7JD8hy8F6hoByhFIYtQK4EGWelDsAkR7AHejQCFDnZSKbzn5Ov2Te1z/eu3gR9IR0 8dPQ== X-Gm-Message-State: AFqh2kogGiOtgvq8pym3I49bUEwfvUbBzSr+HDP61VE36wVEZ9d1IG9f EEzA20RYSb6Ab+P7toO1AtukoEGktW4= X-Google-Smtp-Source: AMrXdXt1cCRLvVR7hwmgT7ueBnmamvx7LubZMuPwhQ4tixWhuyn7PeJawKU0VJYORkt4+PIMEiOKkA== X-Received: by 2002:aa7:c946:0:b0:496:4d2f:1b4b with SMTP id h6-20020aa7c946000000b004964d2f1b4bmr9099920edt.7.1673852710095; Sun, 15 Jan 2023 23:05:10 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Paul Durrant , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v3 8/8] x86/iommu: make AMD-Vi and Intel VT-d support configurable Date: Mon, 16 Jan 2023 09:04:31 +0200 Message-Id: <20230116070431.905594-9-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116070431.905594-1-burzalodowa@gmail.com> References: <20230116070431.905594-1-burzalodowa@gmail.com> MIME-Version: 1.0 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 v3: - add Jan's Acked-by tag xen/drivers/passthrough/Kconfig | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/xen/drivers/passthrough/Kconfig b/xen/drivers/passthrough/Kconfig index 5c65567744..864fcf3b0c 100644 --- a/xen/drivers/passthrough/Kconfig +++ b/xen/drivers/passthrough/Kconfig @@ -38,10 +38,28 @@ config IPMMU_VMSA endif 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. 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. config IOMMU_FORCE_PT_SHARE bool