From nobody Thu May 9 08:31:03 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=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1706118270; cv=none; d=zohomail.com; s=zohoarc; b=baEP2vBZOsGLbEKdt0m95aYF5cENbKfdFTLISYqZVgoai8scrLMjPYjIThLtOA7ikxPFex0sk1EqVzfWF6g9zf/8chIuZHlzbncWoxDUG0ph/QUsy0T434G91pk86o7+3/cWVE3oOu9uIgf4DBEctLrFZ8V54KJUa1cUhRcTiG4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706118270; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PRRTVoMsffBaeCx7H0UZfS7Un0PKaRloiBABlVU/CRw=; b=jKmZuFtDCsmCXjhUCPGe8PeyyOJWIiYw0dFg1/qUjbe9b0vURLqJ5jIBuaHMFSFgHZ+dz6Y/MiVEpA1L849erwS3FP2bxo+JZFjQwMaFkInz4OVbEcxSyTq17cymCQ9fukoIxt34YnYrbzHeUa0QBzAB+ETI65JIKL+ap9LWv7k= 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=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1706118270085497.8429699804193; Wed, 24 Jan 2024 09:44:30 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.671178.1044399 (Exim 4.92) (envelope-from ) id 1rShHs-0003tD-GQ; Wed, 24 Jan 2024 17:43:44 +0000 Received: by outflank-mailman (output) from mailman id 671178.1044399; Wed, 24 Jan 2024 17:43:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rShHs-0003t6-DY; Wed, 24 Jan 2024 17:43:44 +0000 Received: by outflank-mailman (input) for mailman id 671178; Wed, 24 Jan 2024 17:43:42 +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 1rShHq-0003ef-KQ for xen-devel@lists.xenproject.org; Wed, 24 Jan 2024 17:43:42 +0000 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [2a00:1450:4864:20::436]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1c73fa59-bae0-11ee-9b0f-b553b5be7939; Wed, 24 Jan 2024 18:43:40 +0100 (CET) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3394b892691so774377f8f.1 for ; Wed, 24 Jan 2024 09:43:40 -0800 (PST) Received: from localhost ([213.195.118.74]) by smtp.gmail.com with ESMTPSA id k2-20020a5d6282000000b0033838c2c169sm14419901wru.108.2024.01.24.09.43.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 09:43:39 -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: 1c73fa59-bae0-11ee-9b0f-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1706118220; x=1706723020; darn=lists.xenproject.org; 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=PRRTVoMsffBaeCx7H0UZfS7Un0PKaRloiBABlVU/CRw=; b=lwbha7if0VIQZ69f6ardj89bG4ml+2dzseawo9iXDe2N4ln2mqEypb5zKQXmxgjVie Sv78gMHQHiBDZ+AzaDnXwct8GsmKiEG4m0iDkJzsmMOSIjQ5zStna5ekkcnkp6lhYbMB M1OY3uthjW8wJFcC3lUhX0GvVPfQQfEpKamtg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706118220; x=1706723020; 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=PRRTVoMsffBaeCx7H0UZfS7Un0PKaRloiBABlVU/CRw=; b=wA+aRJBfPZOL20aj8YMMDvtPzCUhzIJmiVXm3ZpAYtZV5FkHvLfnbGh7MPZ/VGf4kr 7KCOLw5PtqKpXguFpa+ZZDlZRSkBYQ8trzZfFQ6oY/M9z7z2Qx40wEo7R151cJTl+8Rx R32qopjgz4ZZCtI2CLrmehub/nnNbdrj0SRYLAuzB0/G1IWrFiATyOd32cwC8pMAl5Rg 88aWL43So2xKUYiXWxBgC6N0RWe6ek+StaTM75yfuqZLCbl5Wg+ectELK0jOGwP2nHB4 s1ZjZz5EBM1q5z+tVwdE+W0ukaLQzD+HmOKe32Liz7RsUl2p1mzmE5WyqWksT85sYF1N 0H0Q== X-Gm-Message-State: AOJu0Yxaq9DdFMaWKT1yPK4gmMkkiIyoRyiupdY5oFkmjbPqtmIO4Ot4 oM6G62DT9VKEiV1sG1yrWxbdUqHzKJRfE5lxY1E1bvvtMwhe5BgSNxbtmMe2mYbwd4KxHp022V5 o X-Google-Smtp-Source: AGHT+IH6TMMY4cg2huxFvd8qdL8Ao0BquEAyYm67Y1uR33w8uMPyTRzFYILSedvn+lTN+7cJPzFDZQ== X-Received: by 2002:a5d:4592:0:b0:337:7cda:f60f with SMTP id p18-20020a5d4592000000b003377cdaf60fmr695501wrq.26.1706118219684; Wed, 24 Jan 2024 09:43:39 -0800 (PST) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Paul Durrant , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH v5 1/3] x86/iommu: remove regions not to be mapped Date: Wed, 24 Jan 2024 18:29:51 +0100 Message-ID: <20240124172953.29814-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240124172953.29814-1-roger.pau@citrix.com> References: <20240124172953.29814-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1706118271645100001 Introduce the code to remove regions not to be mapped from the rangeset that will be used to setup the IOMMU page tables for the hardware domain. This change also introduces two new functions: remove_xen_ranges() and vpci_subtract_mmcfg() that copy the logic in xen_in_range() and vpci_is_mmcfg_address() respectively and remove the ranges that would other= wise be intercepted by the original functions. Note that the rangeset is still not populated. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- Changes since v4: - Fix off-by-one when removing the Xen used ranges, as the rangesets are inclusive. Changes since v3: - Remove unnecessary line wrapping. Changes since v1: - Split from bigger patch. --- xen/arch/x86/hvm/io.c | 16 ++++++++ xen/arch/x86/include/asm/hvm/io.h | 3 ++ xen/arch/x86/include/asm/setup.h | 1 + xen/arch/x86/setup.c | 48 +++++++++++++++++++++++ xen/drivers/passthrough/x86/iommu.c | 61 +++++++++++++++++++++++++++++ 5 files changed, 129 insertions(+) diff --git a/xen/arch/x86/hvm/io.c b/xen/arch/x86/hvm/io.c index d75af83ad01f..a42854c52b65 100644 --- a/xen/arch/x86/hvm/io.c +++ b/xen/arch/x86/hvm/io.c @@ -369,6 +369,22 @@ bool vpci_is_mmcfg_address(const struct domain *d, pad= dr_t addr) return vpci_mmcfg_find(d, addr); } =20 +int __hwdom_init vpci_subtract_mmcfg(const struct domain *d, struct ranges= et *r) +{ + const struct hvm_mmcfg *mmcfg; + + list_for_each_entry ( mmcfg, &d->arch.hvm.mmcfg_regions, next ) + { + int rc =3D rangeset_remove_range(r, PFN_DOWN(mmcfg->addr), + PFN_DOWN(mmcfg->addr + mmcfg->size = - 1)); + + if ( rc ) + return rc; + } + + return 0; +} + static unsigned int vpci_mmcfg_decode_addr(const struct hvm_mmcfg *mmcfg, paddr_t addr, pci_sbdf_t *sbdf) { diff --git a/xen/arch/x86/include/asm/hvm/io.h b/xen/arch/x86/include/asm/h= vm/io.h index a97731657801..e1e5e6fe7491 100644 --- a/xen/arch/x86/include/asm/hvm/io.h +++ b/xen/arch/x86/include/asm/hvm/io.h @@ -156,6 +156,9 @@ void destroy_vpci_mmcfg(struct domain *d); /* Check if an address is between a MMCFG region for a domain. */ bool vpci_is_mmcfg_address(const struct domain *d, paddr_t addr); =20 +/* Remove MMCFG regions from a given rangeset. */ +int vpci_subtract_mmcfg(const struct domain *d, struct rangeset *r); + #endif /* __ASM_X86_HVM_IO_H__ */ =20 =20 diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/se= tup.h index 9a460e4db8f4..cd07d98101d8 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -37,6 +37,7 @@ void discard_initial_images(void); void *bootstrap_map(const module_t *mod); =20 int xen_in_range(unsigned long mfn); +int remove_xen_ranges(struct rangeset *r); =20 extern uint8_t kbd_shift_flags; =20 diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 897b7e92082e..c9f65c3a70b8 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -2138,6 +2138,54 @@ int __hwdom_init xen_in_range(unsigned long mfn) return 0; } =20 +int __hwdom_init remove_xen_ranges(struct rangeset *r) +{ + paddr_t start, end; + int rc; + + /* S3 resume code (and other real mode trampoline code) */ + rc =3D rangeset_remove_range(r, PFN_DOWN(bootsym_phys(trampoline_start= )), + PFN_DOWN(bootsym_phys(trampoline_end)) - 1); + if ( rc ) + return rc; + + /* + * This needs to remain in sync with the uses of the same symbols in + * - __start_xen() + * - is_xen_fixed_mfn() + * - tboot_shutdown() + */ + /* hypervisor .text + .rodata */ + rc =3D rangeset_remove_range(r, PFN_DOWN(__pa(&_stext)), + PFN_DOWN(__pa(&__2M_rodata_end)) - 1); + if ( rc ) + return rc; + + /* hypervisor .data + .bss */ + if ( efi_boot_mem_unused(&start, &end) ) + { + ASSERT(__pa(start) >=3D __pa(&__2M_rwdata_start)); + rc =3D rangeset_remove_range(r, PFN_DOWN(__pa(&__2M_rwdata_start)), + PFN_DOWN(__pa(start)) - 1); + if ( rc ) + return rc; + ASSERT(__pa(end) <=3D __pa(&__2M_rwdata_end)); + rc =3D rangeset_remove_range(r, PFN_DOWN(__pa(end)), + PFN_DOWN(__pa(&__2M_rwdata_end)) - 1); + if ( rc ) + return rc; + } + else + { + rc =3D rangeset_remove_range(r, PFN_DOWN(__pa(&__2M_rwdata_start)), + PFN_DOWN(__pa(&__2M_rwdata_end)) - 1); + if ( rc ) + return rc; + } + + return 0; +} + static int __hwdom_init cf_check io_bitmap_cb( unsigned long s, unsigned long e, void *ctx) { diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/= x86/iommu.c index 59b0c7e980ca..fc5215a9dc40 100644 --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -370,6 +370,14 @@ static unsigned int __hwdom_init hwdom_iommu_map(const= struct domain *d, return perms; } =20 +static int __hwdom_init cf_check map_subtract(unsigned long s, unsigned lo= ng e, + void *data) +{ + struct rangeset *map =3D data; + + return rangeset_remove_range(map, s, e); +} + struct map_data { struct domain *d; unsigned int flush_flags; @@ -533,6 +541,59 @@ void __hwdom_init arch_iommu_hwdom_init(struct domain = *d) goto commit; } =20 + /* Remove any areas in-use by Xen. */ + rc =3D remove_xen_ranges(map); + if ( rc ) + panic("IOMMU failed to remove Xen ranges: %d\n", rc); + + /* Remove any overlap with the Interrupt Address Range. */ + rc =3D rangeset_remove_range(map, 0xfee00, 0xfeeff); + if ( rc ) + panic("IOMMU failed to remove Interrupt Address Range: %d\n", rc); + + /* If emulating IO-APIC(s) make sure the base address is unmapped. */ + if ( has_vioapic(d) ) + { + for ( i =3D 0; i < d->arch.hvm.nr_vioapics; i++ ) + { + rc =3D rangeset_remove_singleton(map, + PFN_DOWN(domain_vioapic(d, i)->base_address)); + if ( rc ) + panic("IOMMU failed to remove IO-APIC: %d\n", rc); + } + } + + if ( is_pv_domain(d) ) + { + /* + * Be consistent with CPU mappings: Dom0 is permitted to establish= r/o + * ones there (also for e.g. HPET in certain cases), so it should = also + * have such established for IOMMUs. Remove any read-only ranges = here, + * since ranges in mmio_ro_ranges are already explicitly mapped be= low + * in read-only mode. + */ + rc =3D rangeset_report_ranges(mmio_ro_ranges, 0, ~0UL, map_subtrac= t, map); + if ( rc ) + panic("IOMMU failed to remove read-only regions: %d\n", rc); + } + + if ( has_vpci(d) ) + { + /* + * TODO: runtime added MMCFG regions are not checked to make sure = they + * don't overlap with already mapped regions, thus preventing trap= ping. + */ + rc =3D vpci_subtract_mmcfg(d, map); + if ( rc ) + panic("IOMMU unable to remove MMCFG areas: %d\n", rc); + } + + /* Remove any regions past the last address addressable by the domain.= */ + rc =3D rangeset_remove_range(map, PFN_DOWN(1UL << domain_max_paddr_bit= s(d)), + ~0UL); + if ( rc ) + panic("IOMMU unable to remove unaddressable ranges: %d\n", rc); + if ( iommu_verbose ) printk(XENLOG_INFO "%pd: identity mappings for IOMMU:\n", d); =20 --=20 2.43.0 From nobody Thu May 9 08:31:03 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=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1706118261; cv=none; d=zohomail.com; s=zohoarc; b=YXwkZ/c0Pn5wFUTYGZngWGnDad9pKbVSYCyvD6GndTcuQjYaSFSwabWXsCxNCLqpy53HAVbcG0zaUd/iNoFSPS+9FA2n77tctPzEp0VpJ60uz1StvwqUwAHgu5u9Kt8HpSrYU3edpmchpl+IXO3/kU4V2Pxdb+SCqxNmRenBUIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706118261; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zJJnNGbJJMDiPLfKGkoshyel4WrLYy7Bf15l7HNG1jU=; b=THwNJAKiI531jajHnQXef6ycO+bePgTuZT5VRwT8vBRvVB8JJtBDN6Q/va5JokvUxMgkPae3t3IjLJAp/7G4F2TE6E+khdOPJfhl/4FlG48cT9zcpRT/Y1erieL7oRCjAQol45rOFf3vU6I6SvqzLCy63pbGfgTlo3s892VqTJs= 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=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1706118261933820.5713877867255; Wed, 24 Jan 2024 09:44:21 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.671179.1044409 (Exim 4.92) (envelope-from ) id 1rShHt-00047u-ML; Wed, 24 Jan 2024 17:43:45 +0000 Received: by outflank-mailman (output) from mailman id 671179.1044409; Wed, 24 Jan 2024 17:43:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rShHt-00047n-Jg; Wed, 24 Jan 2024 17:43:45 +0000 Received: by outflank-mailman (input) for mailman id 671179; Wed, 24 Jan 2024 17:43:43 +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 1rShHr-0003ef-Gl for xen-devel@lists.xenproject.org; Wed, 24 Jan 2024 17:43:43 +0000 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [2a00:1450:4864:20::32d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1ce3a92c-bae0-11ee-9b0f-b553b5be7939; Wed, 24 Jan 2024 18:43:41 +0100 (CET) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-40eb0836f8dso31423565e9.2 for ; Wed, 24 Jan 2024 09:43:41 -0800 (PST) Received: from localhost ([213.195.118.74]) by smtp.gmail.com with ESMTPSA id t3-20020a05600c450300b0040d5ae2906esm327184wmo.30.2024.01.24.09.43.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 09:43:40 -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: 1ce3a92c-bae0-11ee-9b0f-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1706118221; x=1706723021; darn=lists.xenproject.org; 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=zJJnNGbJJMDiPLfKGkoshyel4WrLYy7Bf15l7HNG1jU=; b=N5lqyTIycGwVSAIb3W7MA3JS3OWPKiHBtXd881KSATskCDEYraFWyctZnwvKew6mef Bv7A+uIrsIaCdjJp5qP5KL2Q7x9FmvwIhWUNcTtPtrDhe3PBY8OBrpVoN6ELH9JFEH4t RaZFaR5iXnwZZwLWLEaX91fZJEk8/dMUsaCrI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706118221; x=1706723021; 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=zJJnNGbJJMDiPLfKGkoshyel4WrLYy7Bf15l7HNG1jU=; b=jQK8MjsbTlo1nwWm+cd/IXAItTeNTLim+HZHl4OrJs197j8MoSq+3fcWIM4v0HTVne RNZttSGw6XIwmKs1HGquycH5x0VJdxYRR0IT61H7JsLMyXMpCyu6LgfcvX9gD6nShwHr xqrkvVII+8+1V22Lskslrjsb7Hr/4IuWnsy/zSYTaD7flIT6F/Dzqm+B6tDxIzmzGACH LN3fKPs3KvhQUbwXMMsZ9PHJkpuZFzZ2c+5P536dElgzmIkTa6//fEcXw8zN7sTgSm4S pJOuP9L55a0leT1jTNS1PD00Ry4b7QOfJhxaIBJEEwWaB+aroEiDG7WMCVGw7nc2zA1i P8aw== X-Gm-Message-State: AOJu0YyAbuMePNlk1lNEW4QWvMFHa66vJR2S6ATaJvb1wynXlNIpQJja 3YufBKbrZ4Freu4lWbzJw2TlXNrrpC/TG3d006GeRahw+OrMLjnDaFAl7F5y+opD0dyNjNP6S6r F X-Google-Smtp-Source: AGHT+IHw8o2+5Td5uIeu9JZ/ycI6dcz5hmMjUeBh/8s7ZUz6E1YbHcxF8gi6kT+opFj/AgCaiyaD2g== X-Received: by 2002:a7b:cb96:0:b0:40e:7597:42bb with SMTP id m22-20020a7bcb96000000b0040e759742bbmr1312051wmi.181.1706118220923; Wed, 24 Jan 2024 09:43:40 -0800 (PST) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Oleksii Kurochko , Community Manager , Jan Beulich , Paul Durrant Subject: [PATCH v5 2/3] x86/iommu: switch hwdom IOMMU to use a rangeset Date: Wed, 24 Jan 2024 18:29:52 +0100 Message-ID: <20240124172953.29814-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240124172953.29814-1-roger.pau@citrix.com> References: <20240124172953.29814-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1706118263578100001 The current loop that iterates from 0 to the maximum RAM address in order to setup the IOMMU mappings is highly inefficient, and it will get worse as the amount of RAM increases. It's also not accounting for any reserved regions past the last RAM address. Instead of iterating over memory addresses, iterate over the memory map reg= ions and use a rangeset in order to keep track of which ranges need to be identi= ty mapped in the hardware domain physical address space. On an AMD EPYC 7452 with 512GiB of RAM, the time to execute arch_iommu_hwdom_init() in nanoseconds is: x old + new N Min Max Median Avg Stddev x 5 2.2364154e+10 2.338244e+10 2.2474685e+10 2.2622409e+10 4.2949869e+08 + 5 1025012 1033036 1026188 1028276.2 3623.1194 Difference at 95.0% confidence -2.26214e+10 +/- 4.42931e+08 -99.9955% +/- 9.05152e-05% (Student's t, pooled s =3D 3.03701e+08) Execution time of arch_iommu_hwdom_init() goes down from ~22s to ~0.001s. Note there's a change for HVM domains (ie: PVH dom0) that get switched to create the p2m mappings using map_mmio_regions() instead of p2m_add_identity_entry(), so that ranges can be mapped with a single functi= on call if possible. Note that the interface of map_mmio_regions() doesn't allow creating read-only mappings, but so far there are no such mappings created for PVH dom0 in arch_iommu_hwdom_init(). No change intended in the resulting mappings that a hardware domain gets. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich Reviewed-by: Paul Durrant --- Changes since v4: - Add default case to handle ACPI and NVS regions (which are not mapped) unless in the low 4GB and when inclusive mode is set. - Add changelog entry. - Dropped Jans RB. Changes since v3: - Remove unnecessary line wraps. Changes since v2: - Simplify a bit the logic related to inclusive option, at the cost of mak= ing some no-op calls on some cases. Changes since v1: - Split from bigger patch. - Remove unneeded default case. x86/iommu: add CHANGELOG entry for hwdom setup time improvements Signed-off-by: Roger Pau Monn=C3=A9 --- CHANGELOG.md | 2 + xen/drivers/passthrough/x86/iommu.c | 149 ++++++---------------------- 2 files changed, 35 insertions(+), 116 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 723d06425431..3e8b996e4718 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ The format is based on [Keep a Changelog](https://keepachan= gelog.com/en/1.0.0/) ### Changed - Changed flexible array definitions in public I/O interface headers to n= ot use "1" as the number of array elements. + - On x86: + - Reduce IOMMU setup time for hardware domain. =20 ### Added - On x86: diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/= x86/iommu.c index fc5215a9dc40..c90755ff58fa 100644 --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -300,76 +300,6 @@ void iommu_identity_map_teardown(struct domain *d) } } =20 -static unsigned int __hwdom_init hwdom_iommu_map(const struct domain *d, - unsigned long pfn, - unsigned long max_pfn) -{ - mfn_t mfn =3D _mfn(pfn); - unsigned int i, type, perms =3D IOMMUF_readable | IOMMUF_writable; - - /* - * Set up 1:1 mapping for dom0. Default to include only conventional R= AM - * areas and let RMRRs include needed reserved regions. When set, the - * inclusive mapping additionally maps in every pfn up to 4GB except t= hose - * that fall in unusable ranges for PV Dom0. - */ - if ( (pfn > max_pfn && !mfn_valid(mfn)) || xen_in_range(pfn) ) - return 0; - - switch ( type =3D page_get_ram_type(mfn) ) - { - case RAM_TYPE_UNUSABLE: - return 0; - - case RAM_TYPE_CONVENTIONAL: - if ( iommu_hwdom_strict ) - return 0; - break; - - default: - if ( type & RAM_TYPE_RESERVED ) - { - if ( !iommu_hwdom_inclusive && !iommu_hwdom_reserved ) - perms =3D 0; - } - else if ( is_hvm_domain(d) ) - return 0; - else if ( !iommu_hwdom_inclusive || pfn > max_pfn ) - perms =3D 0; - } - - /* Check that it doesn't overlap with the Interrupt Address Range. */ - if ( pfn >=3D 0xfee00 && pfn <=3D 0xfeeff ) - return 0; - /* ... or the IO-APIC */ - if ( has_vioapic(d) ) - { - for ( i =3D 0; i < d->arch.hvm.nr_vioapics; i++ ) - if ( pfn =3D=3D PFN_DOWN(domain_vioapic(d, i)->base_address) ) - return 0; - } - else if ( is_pv_domain(d) ) - { - /* - * Be consistent with CPU mappings: Dom0 is permitted to establish= r/o - * ones there (also for e.g. HPET in certain cases), so it should = also - * have such established for IOMMUs. - */ - if ( iomem_access_permitted(d, pfn, pfn) && - rangeset_contains_singleton(mmio_ro_ranges, pfn) ) - perms =3D IOMMUF_readable; - } - /* - * ... or the PCIe MCFG regions. - * TODO: runtime added MMCFG regions are not checked to make sure they - * don't overlap with already mapped regions, thus preventing trapping. - */ - if ( has_vpci(d) && vpci_is_mmcfg_address(d, pfn_to_paddr(pfn)) ) - return 0; - - return perms; -} - static int __hwdom_init cf_check map_subtract(unsigned long s, unsigned lo= ng e, void *data) { @@ -455,8 +385,7 @@ static int __hwdom_init cf_check identity_map(unsigned = long s, unsigned long e, =20 void __hwdom_init arch_iommu_hwdom_init(struct domain *d) { - unsigned long i, top, max_pfn, start, count; - unsigned int start_perms =3D 0; + unsigned int i; struct rangeset *map; struct map_data map_data =3D { .d =3D d }; int rc; @@ -487,58 +416,46 @@ void __hwdom_init arch_iommu_hwdom_init(struct domain= *d) if ( !map ) panic("IOMMU init: unable to allocate rangeset\n"); =20 - max_pfn =3D (GB(4) >> PAGE_SHIFT) - 1; - top =3D max(max_pdx, pfn_to_pdx(max_pfn) + 1); + if ( iommu_hwdom_inclusive ) + { + /* Add the whole range below 4GB, UNUSABLE regions will be removed= . */ + rc =3D rangeset_add_range(map, 0, PFN_DOWN(GB(4)) - 1); + if ( rc ) + panic("IOMMU inclusive mappings can't be added: %d\n", rc); + } =20 - for ( i =3D 0, start =3D 0, count =3D 0; i < top; ) + for ( i =3D 0; i < e820.nr_map; i++ ) { - unsigned long pfn =3D pdx_to_pfn(i); - unsigned int perms =3D hwdom_iommu_map(d, pfn, max_pfn); + const struct e820entry entry =3D e820.map[i]; =20 - if ( !perms ) - /* nothing */; - else if ( paging_mode_translate(d) ) + switch ( entry.type ) { - int rc; - - rc =3D p2m_add_identity_entry(d, pfn, - perms & IOMMUF_writable ? p2m_acce= ss_rw - : p2m_acce= ss_r, - 0); + case E820_UNUSABLE: + /* Only relevant for inclusive mode, otherwise this is a no-op= . */ + rc =3D rangeset_remove_range(map, PFN_DOWN(entry.addr), + PFN_DOWN(entry.addr + entry.size - = 1)); if ( rc ) - printk(XENLOG_WARNING - "%pd: identity mapping of %lx failed: %d\n", - d, pfn, rc); - } - else if ( pfn !=3D start + count || perms !=3D start_perms ) - { - long rc; + panic("IOMMU failed to remove unusable memory: %d\n", rc); + continue; =20 - commit: - while ( (rc =3D iommu_map(d, _dfn(start), _mfn(start), count, - start_perms | IOMMUF_preempt, - &map_data.flush_flags)) > 0 ) - { - start +=3D rc; - count -=3D rc; - process_pending_softirqs(); - } - if ( rc ) - printk(XENLOG_WARNING - "%pd: IOMMU identity mapping of [%lx,%lx) failed: %= ld\n", - d, start, start + count, rc); - start =3D pfn; - count =3D 1; - start_perms =3D perms; - } - else - ++count; + case E820_RESERVED: + if ( !iommu_hwdom_inclusive && !iommu_hwdom_reserved ) + continue; + break; =20 - if ( !(++i & 0xfffff) ) - process_pending_softirqs(); + case E820_RAM: + if ( iommu_hwdom_strict ) + continue; + break; =20 - if ( i =3D=3D top && count ) - goto commit; + default: + continue; + } + + rc =3D rangeset_add_range(map, PFN_DOWN(entry.addr), + PFN_DOWN(entry.addr + entry.size - 1)); + if ( rc ) + panic("IOMMU failed to add identity range: %d\n", rc); } =20 /* Remove any areas in-use by Xen. */ --=20 2.43.0 From nobody Thu May 9 08:31:03 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=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1706118259; cv=none; d=zohomail.com; s=zohoarc; b=TUlQW6rOMAeJqWJzbphBP1pFERqFgSrLd4dJBnARQMRGNetT1DOxLrC6139+8SY/SuHEQGyX2U5WYDNafBZEM8H4X4YdRJ4QBcEqD+lsvK76pLRO99BcW6AOUJxzoqN00lc2Mw/4vL7szY991sITdoyC8fzn5sdJ6QiAmz0Y8bY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706118259; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2ZrLEkQUk8aM9B2yvHvaZ4PCpBx3ctjQNdrs96yJVB0=; b=LgM/ApEgNNzffHFe1jeRrAZyKb+DuEVSUuRJutR200tgKGlSJG95o+tv/pSlXoiST8I2XQuFWgZJLgFQCrw90xNVh4y2dUuPp7z03qXGzjrtiYrZ70Wb18XKmeO3lRfUDr50r9SWIMDTcie/pAC9BmYNqGMyUTBJi20BC3sLdno= 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=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1706118259110173.80304230678883; Wed, 24 Jan 2024 09:44:19 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.671180.1044414 (Exim 4.92) (envelope-from ) id 1rShHu-0004AK-1s; Wed, 24 Jan 2024 17:43:46 +0000 Received: by outflank-mailman (output) from mailman id 671180.1044414; Wed, 24 Jan 2024 17:43:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rShHt-00049V-Qw; Wed, 24 Jan 2024 17:43:45 +0000 Received: by outflank-mailman (input) for mailman id 671180; Wed, 24 Jan 2024 17:43:44 +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 1rShHs-0003pm-LT for xen-devel@lists.xenproject.org; Wed, 24 Jan 2024 17:43:44 +0000 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [2a00:1450:4864:20::32c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1dc0bf3c-bae0-11ee-98f5-6d05b1d4d9a1; Wed, 24 Jan 2024 18:43:43 +0100 (CET) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-40ec048e0c1so16821445e9.2 for ; Wed, 24 Jan 2024 09:43:43 -0800 (PST) Received: from localhost ([213.195.118.74]) by smtp.gmail.com with ESMTPSA id dq15-20020a0560000ccf00b00339336660d4sm8910859wrb.9.2024.01.24.09.43.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 09:43:41 -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: 1dc0bf3c-bae0-11ee-98f5-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1706118222; x=1706723022; darn=lists.xenproject.org; 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=2ZrLEkQUk8aM9B2yvHvaZ4PCpBx3ctjQNdrs96yJVB0=; b=TokWcNMy5fWzHUmBb+mEg7FeSoO4Lhpn/yy2p4UguAO2BI4NjlrjcQYTr++nEo9v3H oPueGI6t3VpgVfR7h1pF8k5j2wQOyusWz5cI5AIyCW+5CG+tudyYVPPB4+zcYnjjHvHc S3h8G+DEf09GAtrFvTU0XeAlzI2FZ/YKk7kyk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706118222; x=1706723022; 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=2ZrLEkQUk8aM9B2yvHvaZ4PCpBx3ctjQNdrs96yJVB0=; b=P6rIPMOzVHU+XKjnQ64bvlMZm6Ieq0FZ3M+IooKK+9X46PFkXsRhBtv8kjeEI92j3c PkA/EH0ivF3jA+C90672ZXKyQA6bgRiPQSEsJ6YDUQ0l3wa4dR3qFNBE7iLMwfazUz3W YW1bXrJpWVSJP2DwyYS89NZ4P5xO1Ocgaomq6iieRp6Rj0Gybx00AP0xgoG6UlaHPy6C 5aFK5n6APjAKGGG1lfsZL7ZPifx778s/4DblS2Y+kJ2D7xzcbsrgKqHVKX1REk86pfzR TVM1JFG8h+PaDoZHhVp2VZWKX54Ttl5zj61PRFSWNFKjdndTCHBeA5Czy8M/dPRHOXnO NvPw== X-Gm-Message-State: AOJu0YwL8f3EIuhWQQN7BrzHO0h2iIhXad6w7fWOb3UQ98Tn6jujhU1h JmuNhdxsRRiZNPX6SlpZGGry7Nll15Ly02EIo2Yxqal7ElLxshwHD4Mw2M7Io5ahKVxCzyL8yfp 1 X-Google-Smtp-Source: AGHT+IH5AzWiSaq4eLMTqR/LLEusMUTSCBemKLBGdhiYMc57QJ3dIHk4Rw9lEyiuHT68bhBymEyUrg== X-Received: by 2002:a05:600c:314d:b0:40e:53ef:8ecb with SMTP id h13-20020a05600c314d00b0040e53ef8ecbmr2041557wmo.5.1706118221947; Wed, 24 Jan 2024 09:43:41 -0800 (PST) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Paul Durrant , Jan Beulich , Andrew Cooper , Wei Liu , Lukasz Hawrylko , "Daniel P. Smith" , =?UTF-8?q?Mateusz=20M=C3=B3wka?= Subject: [PATCH v5 3/3] x86/iommu: cleanup unused functions Date: Wed, 24 Jan 2024 18:29:53 +0100 Message-ID: <20240124172953.29814-4-roger.pau@citrix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240124172953.29814-1-roger.pau@citrix.com> References: <20240124172953.29814-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1706118259552100002 Remove xen_in_range() and vpci_is_mmcfg_address() now that hey are unused. Adjust comments to point to the new functions that replace the existing one= s. No functional change. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich Reviewed-by: Paul Durrant --- Changes since v2: - Do remove vpci_is_mmcfg_address(). --- Can be squashed with the previous patch if desired, split as a separate pat= ch for clarity. --- xen/arch/x86/hvm/io.c | 5 --- xen/arch/x86/include/asm/hvm/io.h | 3 -- xen/arch/x86/include/asm/setup.h | 1 - xen/arch/x86/setup.c | 53 ++----------------------------- xen/arch/x86/tboot.c | 2 +- 5 files changed, 3 insertions(+), 61 deletions(-) diff --git a/xen/arch/x86/hvm/io.c b/xen/arch/x86/hvm/io.c index a42854c52b65..06283b41c463 100644 --- a/xen/arch/x86/hvm/io.c +++ b/xen/arch/x86/hvm/io.c @@ -364,11 +364,6 @@ static const struct hvm_mmcfg *vpci_mmcfg_find(const s= truct domain *d, return NULL; } =20 -bool vpci_is_mmcfg_address(const struct domain *d, paddr_t addr) -{ - return vpci_mmcfg_find(d, addr); -} - int __hwdom_init vpci_subtract_mmcfg(const struct domain *d, struct ranges= et *r) { const struct hvm_mmcfg *mmcfg; diff --git a/xen/arch/x86/include/asm/hvm/io.h b/xen/arch/x86/include/asm/h= vm/io.h index e1e5e6fe7491..24d1b6134f02 100644 --- a/xen/arch/x86/include/asm/hvm/io.h +++ b/xen/arch/x86/include/asm/hvm/io.h @@ -153,9 +153,6 @@ int register_vpci_mmcfg_handler(struct domain *d, paddr= _t addr, /* Destroy tracked MMCFG areas. */ void destroy_vpci_mmcfg(struct domain *d); =20 -/* Check if an address is between a MMCFG region for a domain. */ -bool vpci_is_mmcfg_address(const struct domain *d, paddr_t addr); - /* Remove MMCFG regions from a given rangeset. */ int vpci_subtract_mmcfg(const struct domain *d, struct rangeset *r); =20 diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/se= tup.h index cd07d98101d8..1ced1299c77b 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -36,7 +36,6 @@ unsigned long initial_images_nrpages(nodeid_t node); void discard_initial_images(void); void *bootstrap_map(const module_t *mod); =20 -int xen_in_range(unsigned long mfn); int remove_xen_ranges(struct rangeset *r); =20 extern uint8_t kbd_shift_flags; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index c9f65c3a70b8..8082aac303e0 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1343,7 +1343,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) relocated =3D true; =20 /* - * This needs to remain in sync with xen_in_range() and the + * This needs to remain in sync with remove_xen_ranges() and the * respective reserve_e820_ram() invocation below. No need to * query efi_boot_mem_unused() here, though. */ @@ -1495,7 +1495,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) if ( using_2M_mapping() ) efi_boot_mem_unused(NULL, NULL); =20 - /* This needs to remain in sync with xen_in_range(). */ + /* This needs to remain in sync with remove_xen_ranges(). */ if ( efi_boot_mem_unused(&eb_start, &eb_end) ) { reserve_e820_ram(&boot_e820, __pa(_stext), __pa(eb_start)); @@ -2089,55 +2089,6 @@ void arch_get_xen_caps(xen_capabilities_info_t *info) } } =20 -int __hwdom_init xen_in_range(unsigned long mfn) -{ - paddr_t start, end; - int i; - - enum { region_s3, region_ro, region_rw, region_bss, nr_regions }; - static struct { - paddr_t s, e; - } xen_regions[nr_regions] __hwdom_initdata; - - /* initialize first time */ - if ( !xen_regions[0].s ) - { - /* S3 resume code (and other real mode trampoline code) */ - xen_regions[region_s3].s =3D bootsym_phys(trampoline_start); - xen_regions[region_s3].e =3D bootsym_phys(trampoline_end); - - /* - * This needs to remain in sync with the uses of the same symbols = in - * - __start_xen() (above) - * - is_xen_fixed_mfn() - * - tboot_shutdown() - */ - - /* hypervisor .text + .rodata */ - xen_regions[region_ro].s =3D __pa(&_stext); - xen_regions[region_ro].e =3D __pa(&__2M_rodata_end); - /* hypervisor .data + .bss */ - xen_regions[region_rw].s =3D __pa(&__2M_rwdata_start); - xen_regions[region_rw].e =3D __pa(&__2M_rwdata_end); - if ( efi_boot_mem_unused(&start, &end) ) - { - ASSERT(__pa(start) >=3D xen_regions[region_rw].s); - ASSERT(__pa(end) <=3D xen_regions[region_rw].e); - xen_regions[region_rw].e =3D __pa(start); - xen_regions[region_bss].s =3D __pa(end); - xen_regions[region_bss].e =3D __pa(&__2M_rwdata_end); - } - } - - start =3D (paddr_t)mfn << PAGE_SHIFT; - end =3D start + PAGE_SIZE; - for ( i =3D 0; i < nr_regions; i++ ) - if ( (start < xen_regions[i].e) && (end > xen_regions[i].s) ) - return 1; - - return 0; -} - int __hwdom_init remove_xen_ranges(struct rangeset *r) { paddr_t start, end; diff --git a/xen/arch/x86/tboot.c b/xen/arch/x86/tboot.c index 86c4c22cacb8..4c254b4e34b4 100644 --- a/xen/arch/x86/tboot.c +++ b/xen/arch/x86/tboot.c @@ -321,7 +321,7 @@ void tboot_shutdown(uint32_t shutdown_type) =20 /* * Xen regions for tboot to MAC. This needs to remain in sync with - * xen_in_range(). + * remove_xen_ranges(). */ g_tboot_shared->num_mac_regions =3D 3; /* S3 resume code (and other real mode trampoline code) */ --=20 2.43.0