From patchwork Wed Dec 21 13:24:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13078748 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 741C1C4332F for ; Wed, 21 Dec 2022 13:24:54 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.467874.726923 (Exim 4.92) (envelope-from ) id 1p7z5Q-0003Dw-HF; Wed, 21 Dec 2022 13:24:44 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 467874.726923; Wed, 21 Dec 2022 13:24: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 1p7z5Q-0003Dp-DC; Wed, 21 Dec 2022 13:24:44 +0000 Received: by outflank-mailman (input) for mailman id 467874; Wed, 21 Dec 2022 13:24:42 +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 1p7z5O-0003Di-Qs for xen-devel@lists.xenproject.org; Wed, 21 Dec 2022 13:24:42 +0000 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2078.outbound.protection.outlook.com [40.107.249.78]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d22cd1c3-8132-11ed-91b6-6bf2151ebd3b; Wed, 21 Dec 2022 14:24:40 +0100 (CET) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AS8PR04MB8610.eurprd04.prod.outlook.com (2603:10a6:20b:425::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Wed, 21 Dec 2022 13:24:37 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::4da2:ea8b:e71e:b8d8]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::4da2:ea8b:e71e:b8d8%4]) with mapi id 15.20.5924.016; Wed, 21 Dec 2022 13:24:37 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d22cd1c3-8132-11ed-91b6-6bf2151ebd3b ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S3oPNtpEZPc7CUjPI33oFsWSAU09vLntPVW+2nGh+g6ny1/QvsZuZRAAo+QkGt8mvl3P1IameSYqj4+m1h8E78/xPAsnNgo//bd1298apdurXwBuZMHQCpcvbaxogAbftL/nZKimhIJiaeK+HiZjjNs20ZrYsfyyBI8pE6HWBhnkzaOsipG4Qgl1rYUqR/YzeVib2CqG4qbe2eBJhv1nEPIv1zkAhZESnEAgGRPYsBYVf0FknyN9LlalnuzV1/pdM3eW0eqNAGFIeduO1SC4gXryjwasKL2QlYhwmCCOuNqzwwJfA9ncvzD17AJSDjXh6QB4gjjBKqb0pn3Nal8bKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HEn4wFY2piqkVwEmqMEYH4wgW0zCNIYSpO4zFCRXgEw=; b=n4h9MrLskiw3URvwI78R+6xIf4yDtEogyBORsWRIsWEdz4DJNCla6cz1cw+vXHOC5E+/DYM80auhwxojN8+AvMhCxxQipdIY6Gc6acEa9tIHIk+w6sy7s9SZ0yZcma6Hu9hAJ1M0z/mttziJmaooiGWHZlDL3xLS2A/wXObJUyNv949nf8GAee/6PZfabozwRPuRvNdx+zEuNVO0X77BVSaZDeIEbZ7DrYmaPLwcZ/XbrHIUkSGks7Mgm4mxTMIeNJN4vqR+mCvbMo7Bt7aV9bUUAWelshTF8fhkXM4+TkegBSpbG0zAaAHPTeCwabBkQJjioAJYsAICWN2FMg1J2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HEn4wFY2piqkVwEmqMEYH4wgW0zCNIYSpO4zFCRXgEw=; b=cRQqGTYQTnMC4eFmoMYKPX33yjXY3V6wnUTRJI7Vh1ddj+glADLxorgbB1bFkkKZOeGAtrJQNu0kAErYBYJHNqDgFdOXc56qq/QTjnhqHqly7obWD2CMj3PliyPCPCtJR1CVGQ3XuPts5b7xgwRuUwf/nSejDhw50s7GIQs86f9TOEA21cHolyP6UQM2/nuXscaav9tY2TuDeUnGvxDksNhh1R2W0D3WOtlT8mKbBkTgbXu5UVd1HuSEHMWY7I6NN1YlZPKzfCB3KKkOfRe/9r2m5MaFwdS4smkadF+QRpFGeiyLLJMOjLovbF6idsOFe/dpVud2OjYqRgI0T2J7Gw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <660507f9-87fd-1061-1fa0-2aeb42ac2eef@suse.com> Date: Wed, 21 Dec 2022 14:24:35 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: [PATCH 1/8] x86/paging: fold HAP and shadow memory alloc related fields Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Tim Deegan References: In-Reply-To: X-ClientProxiedBy: FR2P281CA0041.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:92::12) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AS8PR04MB8610:EE_ X-MS-Office365-Filtering-Correlation-Id: 36ea6951-5f20-4d28-a184-08dae356b527 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qqf7vqyiawR0rcgHIH/Ox8Z2A8EPSMLSE7/Gd3OfuyUETmh0ZqIskLrMLHUrxFF6FCrUquJgy9m/nSWj/9O1F6PWv3tEx0szkEjNuKzCdXBvnqr0T4S3No0nK7CaduHMzj25WkrGVjaxQN0AQljzsg/cqL0IryiFkRSJAVU3TJbilBSpmsUvg++zafLlDlbdYG0WfHhBwYnEKb5apjZ+gjCF4QCdyw1JCjCw+t6mOi5mJ66VzLmmDircDek0L/3NrP8BVx2zQ/k5BrDfAfAGDjXmcICvqDNFfTjzsPSJJ6mhVi6tyKeiGjyXUx+e7WYsa2BD9WONQ4tf8fGaRCVjKhYZcPHTo67GymgL9hUcRNV0rNTVZXLsfqnFVHdOYtqZid6+uRuPm5ZjsFk+umYCZ8O6//qHjY35wx7vJIoBrExresWcv4okcpeJwCLft2rktOAZfYz8RuE+pfIz015p9cWRSmpdVYJ2c2X+oavsCFl+9dRzaKKLbOeQWFuEMRBTBftyCYb2wdn/aw1xb1+6182M80lRrw3ZDjzg2lUnsleQTmYI4B99DrOBIReHeuuj9BvXla1/1r1Gca1t7m4mSJJKYVy+zdvHbk/QKXCb+ooNdedtdnocK77xGT/lbONABEyOzKuMXx6SB+5oXPDvC9gmnV2BgbMnD18gsRb907jGmd8knkVMaschpZYHgqFMPZDcCxxDEYv78GmSXW+jTDcpMXQW2qMLH7oy9j+dEGs= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(346002)(136003)(396003)(376002)(39860400002)(366004)(451199015)(31686004)(8936002)(8676002)(66476007)(86362001)(4326008)(66556008)(5660300002)(66946007)(316002)(30864003)(2906002)(41300700001)(6916009)(54906003)(2616005)(83380400001)(31696002)(6512007)(186003)(6506007)(26005)(38100700002)(6486002)(478600001)(36756003)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?i/tgwcgAX9w29Du0LBp1I6agdX4B?= =?utf-8?q?CdrcpXs694YBdydzpmqQMNOqLNGC6VCwDs05cBahSSi7iqqK7j/9CdsJE81xS/Y/h?= =?utf-8?q?cNM7tiqxPYk/sDActbaP1er/BcSQtclzn/RClw6tHsFHsVeZLCh10V2FdndpyOUZN?= =?utf-8?q?jOVH+RQ03U4yQBZf/JSlC/PtKTNNLriIpKmhMYtmZRy8Fb6gfwoc3upRqfwVy32K/?= =?utf-8?q?zVDnfpm3jb3aeUhZWbNUFhw82K93Gv8qQEIkGQVDahVrEhL7bJnbCISCvEmmAmZKl?= =?utf-8?q?L7vhhK2brPJdHBqgrOj7vgvCxJZb2Bxpr+dJyvKJ01nGmkRHqoczMHWt5qKB85Pju?= =?utf-8?q?SpQa1bmGkCE/Ak7pT/DT947DKXoI2tFDKlZcJHbFJjsP2xanU/xEYvZ4BPkPGs9To?= =?utf-8?q?6xX7xH/ga8kBSHspQlNH78VZUgRS+5qek2OTcqF8AB8ZHJe82QTNoMOy+d0rnmHnB?= =?utf-8?q?cNu7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qQZvIO9CHWf8NkhLctzrlYRhR9bl44DfNrBYkwLajnZlkZ5?= =?utf-8?q?k5cDM4ciPT3ftaNU5fYsduTVrD360o59zzt7y83NDlvNqKm65xhl8DGVh+6xGBQPV?= =?utf-8?q?LIgzIfwh6LzBNN/MthA/ySqnKE3I5ZOhv3yf095zpkxB7bCFhwP8LA87t08npQ9mk?= =?utf-8?q?wNN8po84Mnq6?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36ea6951-5f20-4d28-a184-08dae356b527 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2022 13:24:37.3249 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: eU/9Da6T9+KNFspDPZOlWN7P34KY6PWgALYkXF9LSmoaf1/OFK/snyHTRKzvTB6GaKKBjeSbcNuMze13TMfRsA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8610 Especially with struct shadow_domain and struct hap_domain not living in a union inside struct paging_domain, let's avoid the duplication: The fields are named and used in identical ways, and only one of HAP or shadow can be in use for a domain. This then also renders involved expressions slightly more legible. Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper , with two minor --- Quite likely more folding of code is possible with this. For example {hap,shadow}_set_allocation() are now yet more similar than they already were. --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -99,12 +99,6 @@ struct shadow_domain { unsigned int opt_flags; /* runtime tunable optimizations on/off */ struct page_list_head pinned_shadows; - /* Memory allocation */ - struct page_list_head freelist; - unsigned int total_pages; /* number of pages allocated */ - unsigned int free_pages; /* number of pages on freelists */ - unsigned int p2m_pages; /* number of pages allocated to p2m */ - /* 1-to-1 map for use when HVM vcpus have paging disabled */ pagetable_t unpaged_pagetable; @@ -179,10 +173,6 @@ struct shadow_vcpu { /* hardware assisted paging */ /************************************************/ struct hap_domain { - struct page_list_head freelist; - unsigned int total_pages; /* number of pages allocated */ - unsigned int free_pages; /* number of pages on freelists */ - unsigned int p2m_pages; /* number of pages allocated to p2m */ }; /************************************************/ @@ -218,6 +208,13 @@ struct paging_domain { struct shadow_domain shadow; /* extension for hardware-assited paging */ struct hap_domain hap; + + /* Memory allocation (common to shadow and HAP) */ + struct page_list_head freelist; + unsigned int total_pages; /* number of pages allocated */ + unsigned int free_pages; /* number of pages on freelists */ + unsigned int p2m_pages; /* number of pages allocated to p2m */ + /* log dirty support */ struct log_dirty_domain log_dirty; --- a/xen/arch/x86/include/asm/hap.h +++ b/xen/arch/x86/include/asm/hap.h @@ -47,7 +47,6 @@ int hap_track_dirty_vram(struct domain extern const struct paging_mode *hap_paging_get_mode(struct vcpu *); int hap_set_allocation(struct domain *d, unsigned int pages, bool *preempted); unsigned int hap_get_allocation(struct domain *d); -int hap_get_allocation_bytes(struct domain *d, uint64_t *size); #endif /* XEN_HAP_H */ --- a/xen/arch/x86/include/asm/shadow.h +++ b/xen/arch/x86/include/asm/shadow.h @@ -97,8 +97,6 @@ void shadow_blow_tables_per_domain(struc int shadow_set_allocation(struct domain *d, unsigned int pages, bool *preempted); -int shadow_get_allocation_bytes(struct domain *d, uint64_t *size); - #else /* !CONFIG_SHADOW_PAGING */ #define shadow_vcpu_teardown(v) ASSERT(is_pv_vcpu(v)) @@ -110,8 +108,6 @@ int shadow_get_allocation_bytes(struct d ({ ASSERT_UNREACHABLE(); -EOPNOTSUPP; }) #define shadow_set_allocation(d, pages, preempted) \ ({ ASSERT_UNREACHABLE(); -EOPNOTSUPP; }) -#define shadow_get_allocation_bytes(d, size) \ - ({ ASSERT_UNREACHABLE(); -EOPNOTSUPP; }) static inline void sh_remove_shadows(struct domain *d, mfn_t gmfn, int fast, int all) {} --- a/xen/arch/x86/mm/hap/hap.c +++ b/xen/arch/x86/mm/hap/hap.c @@ -249,11 +249,11 @@ static struct page_info *hap_alloc(struc if ( unlikely(d->is_dying) ) return NULL; - pg = page_list_remove_head(&d->arch.paging.hap.freelist); + pg = page_list_remove_head(&d->arch.paging.freelist); if ( unlikely(!pg) ) return NULL; - d->arch.paging.hap.free_pages--; + d->arch.paging.free_pages--; clear_domain_page(page_to_mfn(pg)); @@ -274,12 +274,12 @@ static void hap_free(struct domain *d, m if ( unlikely(d->is_dying) ) { free_domheap_page(pg); - d->arch.paging.hap.total_pages--; + d->arch.paging.total_pages--; return; } - d->arch.paging.hap.free_pages++; - page_list_add_tail(pg, &d->arch.paging.hap.freelist); + d->arch.paging.free_pages++; + page_list_add_tail(pg, &d->arch.paging.freelist); } static struct page_info *cf_check hap_alloc_p2m_page(struct domain *d) @@ -293,8 +293,8 @@ static struct page_info *cf_check hap_al if ( likely(pg != NULL) ) { - d->arch.paging.hap.total_pages--; - d->arch.paging.hap.p2m_pages++; + d->arch.paging.total_pages--; + d->arch.paging.p2m_pages++; ASSERT(!page_get_owner(pg) && !(pg->count_info & PGC_count_mask)); } else if ( !d->arch.paging.p2m_alloc_failed && !d->is_dying ) @@ -328,8 +328,8 @@ static void cf_check hap_free_p2m_page(s pg->count_info &= ~PGC_count_mask; page_set_owner(pg, NULL); } - d->arch.paging.hap.p2m_pages--; - d->arch.paging.hap.total_pages++; + d->arch.paging.p2m_pages--; + d->arch.paging.total_pages++; hap_free(d, page_to_mfn(pg)); paging_unlock(d); @@ -338,24 +338,13 @@ static void cf_check hap_free_p2m_page(s /* Return the size of the pool, rounded up to the nearest MB */ unsigned int hap_get_allocation(struct domain *d) { - unsigned int pg = d->arch.paging.hap.total_pages - + d->arch.paging.hap.p2m_pages; + unsigned int pg = d->arch.paging.total_pages + + d->arch.paging.p2m_pages; return ((pg >> (20 - PAGE_SHIFT)) + ((pg & ((1 << (20 - PAGE_SHIFT)) - 1)) ? 1 : 0)); } -int hap_get_allocation_bytes(struct domain *d, uint64_t *size) -{ - unsigned long pages = d->arch.paging.hap.total_pages; - - pages += d->arch.paging.hap.p2m_pages; - - *size = pages << PAGE_SHIFT; - - return 0; -} - /* Set the pool of pages to the required number of pages. * Returns 0 for success, non-zero for failure. */ int hap_set_allocation(struct domain *d, unsigned int pages, bool *preempted) @@ -364,14 +353,14 @@ int hap_set_allocation(struct domain *d, ASSERT(paging_locked_by_me(d)); - if ( pages < d->arch.paging.hap.p2m_pages ) + if ( pages < d->arch.paging.p2m_pages ) pages = 0; else - pages -= d->arch.paging.hap.p2m_pages; + pages -= d->arch.paging.p2m_pages; for ( ; ; ) { - if ( d->arch.paging.hap.total_pages < pages ) + if ( d->arch.paging.total_pages < pages ) { /* Need to allocate more memory from domheap */ pg = alloc_domheap_page(d, MEMF_no_owner); @@ -380,22 +369,22 @@ int hap_set_allocation(struct domain *d, HAP_PRINTK("failed to allocate hap pages.\n"); return -ENOMEM; } - d->arch.paging.hap.free_pages++; - d->arch.paging.hap.total_pages++; - page_list_add_tail(pg, &d->arch.paging.hap.freelist); + d->arch.paging.free_pages++; + d->arch.paging.total_pages++; + page_list_add_tail(pg, &d->arch.paging.freelist); } - else if ( d->arch.paging.hap.total_pages > pages ) + else if ( d->arch.paging.total_pages > pages ) { /* Need to return memory to domheap */ - if ( page_list_empty(&d->arch.paging.hap.freelist) ) + if ( page_list_empty(&d->arch.paging.freelist) ) { HAP_PRINTK("failed to free enough hap pages.\n"); return -ENOMEM; } - pg = page_list_remove_head(&d->arch.paging.hap.freelist); + pg = page_list_remove_head(&d->arch.paging.freelist); ASSERT(pg); - d->arch.paging.hap.free_pages--; - d->arch.paging.hap.total_pages--; + d->arch.paging.free_pages--; + d->arch.paging.total_pages--; free_domheap_page(pg); } else @@ -462,8 +451,6 @@ void hap_domain_init(struct domain *d) .clean = hap_clean_dirty_bitmap, }; - INIT_PAGE_LIST_HEAD(&d->arch.paging.hap.freelist); - /* Use HAP logdirty mechanism. */ paging_log_dirty_init(d, &hap_ops); } @@ -484,7 +471,7 @@ int hap_enable(struct domain *d, u32 mod domain_pause(d); - old_pages = d->arch.paging.hap.total_pages; + old_pages = d->arch.paging.total_pages; if ( old_pages == 0 ) { paging_lock(d); @@ -566,16 +553,16 @@ void hap_final_teardown(struct domain *d p2m_teardown(d->arch.nested_p2m[i], true, NULL); } - if ( d->arch.paging.hap.total_pages != 0 ) + if ( d->arch.paging.total_pages != 0 ) hap_teardown(d, NULL); p2m_teardown(p2m_get_hostp2m(d), true, NULL); /* Free any memory that the p2m teardown released */ paging_lock(d); hap_set_allocation(d, 0, NULL); - ASSERT(d->arch.paging.hap.p2m_pages == 0); - ASSERT(d->arch.paging.hap.free_pages == 0); - ASSERT(d->arch.paging.hap.total_pages == 0); + ASSERT(d->arch.paging.p2m_pages == 0); + ASSERT(d->arch.paging.free_pages == 0); + ASSERT(d->arch.paging.total_pages == 0); paging_unlock(d); } @@ -644,14 +631,14 @@ void hap_teardown(struct domain *d, bool paging_lock(d); /* Keep various asserts happy */ - if ( d->arch.paging.hap.total_pages != 0 ) + if ( d->arch.paging.total_pages != 0 ) { hap_set_allocation(d, 0, preempted); if ( preempted && *preempted ) goto out; - ASSERT(d->arch.paging.hap.total_pages == 0); + ASSERT(d->arch.paging.total_pages == 0); } d->arch.paging.mode &= ~PG_log_dirty; --- a/xen/arch/x86/mm/paging.c +++ b/xen/arch/x86/mm/paging.c @@ -651,6 +651,7 @@ int paging_domain_init(struct domain *d) if ( (rc = p2m_init(d)) != 0 ) return rc; + INIT_PAGE_LIST_HEAD(&d->arch.paging.freelist); mm_lock_init(&d->arch.paging.lock); /* This must be initialized separately from the rest of the @@ -979,17 +980,17 @@ int __init paging_set_allocation(struct int arch_get_paging_mempool_size(struct domain *d, uint64_t *size) { - int rc; + unsigned long pages; if ( is_pv_domain(d) ) /* TODO: Relax in due course */ return -EOPNOTSUPP; - if ( hap_enabled(d) ) - rc = hap_get_allocation_bytes(d, size); - else - rc = shadow_get_allocation_bytes(d, size); + pages = d->arch.paging.total_pages; + pages += d->arch.paging.p2m_pages; - return rc; + *size = pages << PAGE_SHIFT; + + return 0; } int arch_set_paging_mempool_size(struct domain *d, uint64_t size) --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -55,7 +55,6 @@ int shadow_domain_init(struct domain *d) .clean = sh_clean_dirty_bitmap, }; - INIT_PAGE_LIST_HEAD(&d->arch.paging.shadow.freelist); INIT_PAGE_LIST_HEAD(&d->arch.paging.shadow.pinned_shadows); /* Use shadow pagetables for log-dirty support */ @@ -936,7 +935,7 @@ static bool __must_check _shadow_preallo mfn_t smfn; int i; - if ( d->arch.paging.shadow.free_pages >= pages ) + if ( d->arch.paging.free_pages >= pages ) return true; if ( unlikely(d->is_dying) ) @@ -958,7 +957,7 @@ static bool __must_check _shadow_preallo sh_unpin(d, smfn); /* See if that freed up enough space */ - if ( d->arch.paging.shadow.free_pages >= pages ) + if ( d->arch.paging.free_pages >= pages ) return true; } @@ -979,7 +978,7 @@ static bool __must_check _shadow_preallo 0); /* See if that freed up enough space */ - if ( d->arch.paging.shadow.free_pages >= pages ) + if ( d->arch.paging.free_pages >= pages ) { guest_flush_tlb_mask(d, d->dirty_cpumask); return true; @@ -991,10 +990,8 @@ static bool __must_check _shadow_preallo * hold Xen mappings for some vcpu. This can never happen. */ printk(XENLOG_ERR "Can't pre-allocate %u shadow pages!\n" " shadow pages total = %u, free = %u, p2m=%u\n", - pages, - d->arch.paging.shadow.total_pages, - d->arch.paging.shadow.free_pages, - d->arch.paging.shadow.p2m_pages); + pages, d->arch.paging.total_pages, + d->arch.paging.free_pages, d->arch.paging.p2m_pages); ASSERT_UNREACHABLE(); @@ -1122,7 +1119,7 @@ mfn_t shadow_alloc(struct domain *d, ASSERT(shadow_type != SH_type_none); perfc_incr(shadow_alloc); - if ( d->arch.paging.shadow.free_pages < pages ) + if ( d->arch.paging.free_pages < pages ) { /* If we get here, we failed to allocate. This should never * happen. It means that we didn't call shadow_prealloc() @@ -1132,7 +1129,7 @@ mfn_t shadow_alloc(struct domain *d, printk(XENLOG_ERR "Can't allocate %u shadow pages!\n", pages); BUG(); } - d->arch.paging.shadow.free_pages -= pages; + d->arch.paging.free_pages -= pages; /* Backpointers that are MFNs need to be packed into PDXs (PFNs don't) */ switch (shadow_type) @@ -1153,7 +1150,7 @@ mfn_t shadow_alloc(struct domain *d, /* Init page info fields and clear the pages */ for ( i = 0; i < pages ; i++ ) { - sp = page_list_remove_head(&d->arch.paging.shadow.freelist); + sp = page_list_remove_head(&d->arch.paging.freelist); /* Before we overwrite the old contents of this page, * we need to be sure that no TLB holds a pointer to it. */ cpumask_copy(&mask, d->dirty_cpumask); @@ -1249,15 +1246,15 @@ void shadow_free(struct domain *d, mfn_t free_domheap_page(sp); } else - page_list_add_tail(sp, &d->arch.paging.shadow.freelist); + page_list_add_tail(sp, &d->arch.paging.freelist); sp = next; } if ( unlikely(dying) ) - d->arch.paging.shadow.total_pages -= pages; + d->arch.paging.total_pages -= pages; else - d->arch.paging.shadow.free_pages += pages; + d->arch.paging.free_pages += pages; } /* Divert a page from the pool to be used by the p2m mapping. @@ -1276,7 +1273,7 @@ shadow_alloc_p2m_page(struct domain *d) * paging lock) and the log-dirty code (which always does). */ paging_lock_recursive(d); - if ( d->arch.paging.shadow.total_pages + if ( d->arch.paging.total_pages < shadow_min_acceptable_pages(d) + 1 ) { if ( !d->arch.paging.p2m_alloc_failed ) @@ -1284,8 +1281,8 @@ shadow_alloc_p2m_page(struct domain *d) d->arch.paging.p2m_alloc_failed = 1; dprintk(XENLOG_ERR, "d%d failed to allocate from shadow pool (tot=%u p2m=%u min=%u)\n", - d->domain_id, d->arch.paging.shadow.total_pages, - d->arch.paging.shadow.p2m_pages, + d->domain_id, d->arch.paging.total_pages, + d->arch.paging.p2m_pages, shadow_min_acceptable_pages(d)); } goto out; @@ -1295,8 +1292,8 @@ shadow_alloc_p2m_page(struct domain *d) goto out; pg = mfn_to_page(shadow_alloc(d, SH_type_p2m_table, 0)); - d->arch.paging.shadow.p2m_pages++; - d->arch.paging.shadow.total_pages--; + d->arch.paging.p2m_pages++; + d->arch.paging.total_pages--; ASSERT(!page_get_owner(pg) && !(pg->count_info & PGC_count_mask)); out: @@ -1327,8 +1324,8 @@ shadow_free_p2m_page(struct domain *d, s * paging lock) and the log-dirty code (which always does). */ paging_lock_recursive(d); - d->arch.paging.shadow.p2m_pages--; - d->arch.paging.shadow.total_pages++; + d->arch.paging.p2m_pages--; + d->arch.paging.total_pages++; shadow_free(d, page_to_mfn(pg)); paging_unlock(d); @@ -1345,7 +1342,7 @@ static unsigned int sh_min_allocation(co max(max(domain_tot_pages(d) / 256, is_hvm_domain(d) ? CONFIG_PAGING_LEVELS + 2 : 0U) + is_hvm_domain(d), - d->arch.paging.shadow.p2m_pages); + d->arch.paging.p2m_pages); } int shadow_set_allocation(struct domain *d, unsigned int pages, bool *preempted) @@ -1361,15 +1358,15 @@ int shadow_set_allocation(struct domain if ( pages < lower_bound ) pages = lower_bound; - pages -= d->arch.paging.shadow.p2m_pages; + pages -= d->arch.paging.p2m_pages; } SHADOW_PRINTK("current %i target %i\n", - d->arch.paging.shadow.total_pages, pages); + d->arch.paging.total_pages, pages); for ( ; ; ) { - if ( d->arch.paging.shadow.total_pages < pages ) + if ( d->arch.paging.total_pages < pages ) { /* Need to allocate more memory from domheap */ sp = (struct page_info *) @@ -1379,29 +1376,29 @@ int shadow_set_allocation(struct domain SHADOW_PRINTK("failed to allocate shadow pages.\n"); return -ENOMEM; } - d->arch.paging.shadow.free_pages++; - d->arch.paging.shadow.total_pages++; + d->arch.paging.free_pages++; + d->arch.paging.total_pages++; sp->u.sh.type = 0; sp->u.sh.pinned = 0; sp->u.sh.count = 0; sp->tlbflush_timestamp = 0; /* Not in any TLB */ - page_list_add_tail(sp, &d->arch.paging.shadow.freelist); + page_list_add_tail(sp, &d->arch.paging.freelist); } - else if ( d->arch.paging.shadow.total_pages > pages ) + else if ( d->arch.paging.total_pages > pages ) { /* Need to return memory to domheap */ if ( !_shadow_prealloc(d, 1) ) return -ENOMEM; - sp = page_list_remove_head(&d->arch.paging.shadow.freelist); + sp = page_list_remove_head(&d->arch.paging.freelist); ASSERT(sp); /* * The pages were allocated anonymously, but the owner field * gets overwritten normally, so need to clear it here. */ page_set_owner(sp, NULL); - d->arch.paging.shadow.free_pages--; - d->arch.paging.shadow.total_pages--; + d->arch.paging.free_pages--; + d->arch.paging.total_pages--; free_domheap_page(sp); } else @@ -1421,23 +1418,12 @@ int shadow_set_allocation(struct domain /* Return the size of the shadow pool, rounded up to the nearest MB */ static unsigned int shadow_get_allocation(struct domain *d) { - unsigned int pg = d->arch.paging.shadow.total_pages - + d->arch.paging.shadow.p2m_pages; + unsigned int pg = d->arch.paging.total_pages + + d->arch.paging.p2m_pages; return ((pg >> (20 - PAGE_SHIFT)) + ((pg & ((1 << (20 - PAGE_SHIFT)) - 1)) ? 1 : 0)); } -int shadow_get_allocation_bytes(struct domain *d, uint64_t *size) -{ - unsigned long pages = d->arch.paging.shadow.total_pages; - - pages += d->arch.paging.shadow.p2m_pages; - - *size = pages << PAGE_SHIFT; - - return 0; -} - /**************************************************************************/ /* Hash table for storing the guest->shadow mappings. * The table itself is an array of pointers to shadows; the shadows are then @@ -2708,7 +2694,7 @@ int shadow_enable(struct domain *d, u32 } /* Init the shadow memory allocation if the user hasn't done so */ - old_pages = d->arch.paging.shadow.total_pages; + old_pages = d->arch.paging.total_pages; if ( old_pages < sh_min_allocation(d) ) { paging_lock(d); @@ -2888,7 +2874,7 @@ void shadow_teardown(struct domain *d, b } #endif /* (SHADOW_OPTIMIZATIONS & (SHOPT_VIRTUAL_TLB|SHOPT_OUT_OF_SYNC)) */ - if ( d->arch.paging.shadow.total_pages != 0 ) + if ( d->arch.paging.total_pages != 0 ) { /* Destroy all the shadows and release memory to domheap */ shadow_set_allocation(d, 0, preempted); @@ -2900,7 +2886,7 @@ void shadow_teardown(struct domain *d, b if (d->arch.paging.shadow.hash_table) shadow_hash_teardown(d); - ASSERT(d->arch.paging.shadow.total_pages == 0); + ASSERT(d->arch.paging.total_pages == 0); } /* Free the non-paged-vcpus pagetable; must happen after we've @@ -2959,15 +2945,13 @@ void shadow_final_teardown(struct domain { SHADOW_PRINTK("dom %u final teardown starts." " Shadow pages total = %u, free = %u, p2m=%u\n", - d->domain_id, - d->arch.paging.shadow.total_pages, - d->arch.paging.shadow.free_pages, - d->arch.paging.shadow.p2m_pages); + d->domain_id, d->arch.paging.total_pages, + d->arch.paging.free_pages, d->arch.paging.p2m_pages); /* Double-check that the domain didn't have any shadow memory. * It is possible for a domain that never got domain_kill()ed * to get here with its shadow allocation intact. */ - if ( d->arch.paging.shadow.total_pages != 0 ) + if ( d->arch.paging.total_pages != 0 ) shadow_teardown(d, NULL); /* It is now safe to pull down the p2m map. */ @@ -2977,13 +2961,11 @@ void shadow_final_teardown(struct domain shadow_set_allocation(d, 0, NULL); SHADOW_PRINTK("dom %u final teardown done." " Shadow pages total = %u, free = %u, p2m=%u\n", - d->domain_id, - d->arch.paging.shadow.total_pages, - d->arch.paging.shadow.free_pages, - d->arch.paging.shadow.p2m_pages); - ASSERT(!d->arch.paging.shadow.total_pages); - ASSERT(!d->arch.paging.shadow.free_pages); - ASSERT(!d->arch.paging.shadow.p2m_pages); + d->domain_id, d->arch.paging.total_pages, + d->arch.paging.free_pages, d->arch.paging.p2m_pages); + ASSERT(d->arch.paging.p2m_pages == 0); + ASSERT(d->arch.paging.free_pages == 0); + ASSERT(d->arch.paging.total_pages == 0); paging_unlock(d); } @@ -3000,7 +2982,7 @@ static int shadow_one_bit_enable(struct mode |= PG_SH_enable; - if ( d->arch.paging.shadow.total_pages < sh_min_allocation(d) ) + if ( d->arch.paging.total_pages < sh_min_allocation(d) ) { /* Init the shadow memory allocation if the user hasn't done so */ if ( shadow_set_allocation(d, 1, NULL) != 0 ) @@ -3049,10 +3031,8 @@ static int shadow_one_bit_disable(struct /* Get this domain off shadows */ SHADOW_PRINTK("un-shadowing of domain %u starts." " Shadow pages total = %u, free = %u, p2m=%u\n", - d->domain_id, - d->arch.paging.shadow.total_pages, - d->arch.paging.shadow.free_pages, - d->arch.paging.shadow.p2m_pages); + d->domain_id, d->arch.paging.total_pages, + d->arch.paging.free_pages, d->arch.paging.p2m_pages); for_each_vcpu(d, v) { if ( v->arch.paging.mode ) @@ -3082,10 +3062,8 @@ static int shadow_one_bit_disable(struct shadow_hash_teardown(d); SHADOW_PRINTK("un-shadowing of domain %u done." " Shadow pages total = %u, free = %u, p2m=%u\n", - d->domain_id, - d->arch.paging.shadow.total_pages, - d->arch.paging.shadow.free_pages, - d->arch.paging.shadow.p2m_pages); + d->domain_id, d->arch.paging.total_pages, + d->arch.paging.free_pages, d->arch.paging.p2m_pages); } return 0; --- a/xen/arch/x86/mm/shadow/hvm.c +++ b/xen/arch/x86/mm/shadow/hvm.c @@ -809,7 +809,7 @@ static void cf_check sh_unshadow_for_p2m * If there are any shadows, update them. But if shadow_teardown() * has already been called then it's not safe to try. */ - if ( unlikely(!d->arch.paging.shadow.total_pages) ) + if ( unlikely(!d->arch.paging.total_pages) ) return; /* Only previously present / valid entries need processing. */ From patchwork Wed Dec 21 13:25:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13078749 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 CE5F7C10F1B for ; Wed, 21 Dec 2022 13:25:37 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.467883.726934 (Exim 4.92) (envelope-from ) id 1p7z67-0003pP-Sg; Wed, 21 Dec 2022 13:25:27 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 467883.726934; Wed, 21 Dec 2022 13:25:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7z67-0003pI-Ph; Wed, 21 Dec 2022 13:25:27 +0000 Received: by outflank-mailman (input) for mailman id 467883; Wed, 21 Dec 2022 13:25:26 +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 1p7z66-0003Di-2u for xen-devel@lists.xenproject.org; Wed, 21 Dec 2022 13:25:26 +0000 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2089.outbound.protection.outlook.com [40.107.249.89]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ecf178b1-8132-11ed-91b6-6bf2151ebd3b; Wed, 21 Dec 2022 14:25:24 +0100 (CET) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AS8PR04MB8610.eurprd04.prod.outlook.com (2603:10a6:20b:425::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Wed, 21 Dec 2022 13:25:21 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::4da2:ea8b:e71e:b8d8]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::4da2:ea8b:e71e:b8d8%4]) with mapi id 15.20.5924.016; Wed, 21 Dec 2022 13:25:21 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ecf178b1-8132-11ed-91b6-6bf2151ebd3b ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QKS3DpjHRFu7eTVeb1my0sbj8LQjQlJ9u0VLMI0ZWhqQtriYFB6uQjKMDQPbZbvSdNEvN1rHw5M+b7Z1RDNEUS6y/Ku9I2aU/cv0VbnJDD6n16Y7QZgoV0E5pMbgiGgJE26D5gSCkqFBmc5AwHFdev0jwZuA4xSDhi5OGs48nxGV7E7oM7a4FzFSe8Aaihg3Y2pjp5cOtANET0mEnxQrVXUY98JQpvjStKHL1vNE+Mfp0E1U6qXpF3oIWpIilZDwsz7ETLtlR8TiWrBYmYBljosX+x5qgPIrrK7RKfJQRSlvW7RxIu9iK07FWzoBicFmdarIO+9ddW+9zJttXZMwVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jRn3ptmgQ2T1waA/6n6LdzW2l6WqDKNqZIo99H92QZU=; b=Vl/6bAiSq1G0APxADm88/y65y0chLV3lEQCeBpPivgt44AWhIpgnkUEjX1U8YLZSZiWH73LYaLY74bq5TyrZR+0CgrCDsXL1CA6WtMcaK63Mfr98fQaEVY3RaVNRqtATwN/Hx30QEFlDkCJ0ejqnCYlugvhzGdTE7vw526vw5Gx0/Q0EVjopOS/kUGZl9XKDNAs/uibTJAg4sm3/+23cp2SpaDG7ZDQKUoShS7BTsYFZpgkdQZGnhVjsKzag2cahMYlapnGFTEoX4Ym9AFAMee7zjp1MA86u7gff0ZErL89cKdxg49xmhXLHritrOy8j6eMz5uw9pbjZ8/MYuyvQVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jRn3ptmgQ2T1waA/6n6LdzW2l6WqDKNqZIo99H92QZU=; b=HXsirKOkW0PC57tQ7AHFFEZD84QzctJije7da3nhF0vMo0Wmt6/6BpCtD+dzlqPoytwYeS7L8KNBzG9LBrNT/ddI0guphKWmdsqjaAo1WOuVHqvkKuKT6tcDnOn42cOFJ00p5A7nwOMLe/HsdczKc+JSCF7UD8bV9e9TQNqtFW2oS6bqSlhBK+4sS4xcolCzFmhbyAplGeihgFIGMs7xY8sn1s62kvWUFHg7S/aO1R4bDLOYCmARgJUdBhjwG8ql1J1YI5rQwYI4ovpSKnNIUv8laHYMGp0Q6go2Gzq3TsM+w93Y3BMEpkR9/xrdWG4b2jPsrsv5kXNFThi6xyHyeA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <8d519e00-83c6-aee9-e7ba-523aa4265e1e@suse.com> Date: Wed, 21 Dec 2022 14:25:19 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: [PATCH 2/8] x86/paging: fold most HAP and shadow final teardown Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Tim Deegan References: In-Reply-To: X-ClientProxiedBy: FR2P281CA0041.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:92::12) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AS8PR04MB8610:EE_ X-MS-Office365-Filtering-Correlation-Id: 1cd98313-74f6-44aa-0ea2-08dae356cf9f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yUc+bDBZJI2axKq2+y8wY5mDQh4mPnR6FW1wUPRcBGj+Jh3P6yMz1WeKr3uyTJ0y2d4+CqIjNmt3XyH32FR4zyEfKbm52Zdf9dshak2Uw/8/vbtLSt1qFummkt7BpSU71blFDQR6TI8d4qXvm7kIF0UJo5/PnwJ6+751+olpCipVPZzbo4IW476+dKf4b91FNxLMJcZdmhatRPcvYkYsSbQ/5b2NanwfbY1aSPM8iZi8isOxARV8FpvdY4Ek771EfCIErjfGYfLPHDfgOH2GCMWi4T0bl//jaoydrFv8iDKOsJFenrCPnEaHMchq+KYTBvzM/1zZie7Vve7NrXIVXgBM2OVIltnzhKHB2jSpRljfIOa4bzQo7oMuiVEn8PdzpR5SAjgiPiv3bnEY5GsVqUFWJjQ/Xr9j9doO2r8hFws+B2sunSFT8nVSDFoAcBzX3cw6Tdi2aG8V26iShM7qOqQGSuZfnDJr/aY0+O6wEvuCu/NsUfvxomDMaf1mYf3LdAgp1+YO8G4z/OiIjEOVkHwp5OGR8Z/HnDjItdxTHc26yTg6k0v5HuosuMuDe/27/XyGMi1YLGUh9/9ItC0JAywZG2fQ3L81Jovw079M0Ac/oiWzIqDEsksa9RvQsdEWFJ2PEZ5xuPM4OuT4qGnF8SbVT0cqqBn9qvcNG4WSOAuBIZ0M2yuEuNOQkTbvzHCU6kMbKbSkV3wX5DAApkg1w9U3Hx+mF30QQDpiPO1SjIo= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(346002)(136003)(396003)(376002)(39860400002)(366004)(451199015)(31686004)(8936002)(8676002)(66476007)(86362001)(4326008)(66556008)(5660300002)(66946007)(316002)(2906002)(41300700001)(6916009)(54906003)(2616005)(83380400001)(31696002)(6512007)(186003)(6506007)(26005)(38100700002)(6486002)(478600001)(36756003)(43740500002)(45980500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6LtQCNMc1NuAbdUU4kPZcMx12iS+AxlDsQpa4c?= =?utf-8?q?Z1fAOyFAkJ+e9kuwd5ImACvRVOS09YZqC82d/UOt9WVst2dNd4YSIVmHi7K7FvBtb?= =?utf-8?q?HlB/pXR4j5cbNmXRbJlCWv3pdRVYTKFEAQbvVmhc+589gkJZYVNfws+pL3heuJ2IO?= =?utf-8?q?mHnTeKTJR5ieaNbPAc157L+0PPLT38pIEDrLYy4Mz6T8QmeWh0olBXeIeCQammrD5?= =?utf-8?q?Iv6l+zaiuT+cXtQiNs0wy3uYYrbNogdYzmBw0OQhHPQI7+3vRmTKGQGzBTjnVhJnI?= =?utf-8?q?SROxZJi93BjBCsvUQNXS8dSK0a7AN2zk64nN6rC2jA11HfyJbrQBHF/4A9/mLYel9?= =?utf-8?q?g0jkknsifypU+vjFZS9UntffZdy9WFqWuu+I7VLLLDviwbcV7xP9omyWqYgIpdndt?= =?utf-8?q?/etO90cqNLyHtJ+9IW9dHGwCCKdcw3GgcEJd/a6isfU+Gt5m1oMzX2zvumy9h9m2j?= =?utf-8?q?Iv5a2Kyfmedwrc6Wi4rEFUlK2oCxANuWGBGwR4W5beX/ubPaFhZgo1RYeA7EV1dQf?= =?utf-8?q?9Jgb9OIZRKM6l7hTN+PPcDG1LgCx29h7wT801uhYhBUQWpXLHXGx+slOkmdN37p6T?= =?utf-8?q?//2HkAv8UDpV99gf2WJMn3InEciT+uwweJPM/ho/XTMNeJxN+4ZX70pMV5jBIdoM4?= =?utf-8?q?5ckar5xaFrAAx/XE8VYrggBKRAnSKt14uPBjhMLTolPagGHm5Vq3zZAna+lZWUNSY?= =?utf-8?q?piMTU4OLatmU?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1cd98313-74f6-44aa-0ea2-08dae356cf9f X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2022 13:25:21.7440 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Wf+fYUmmBlmLwlp0Jrg/bEaqydI5Hz3LyjuBo/GD+GrKj25x3GWDY/X8FRY/H+zAFYWp8bcgv8z6IYNXYUwBPg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8610 HAP does a few things beyond what's common, which are left there at least for now. Common operations, however, are moved to paging_final_teardown(), allowing shadow_final_teardown() to go away. While moving (and hence generalizing) the respective SHADOW_PRINTK() drop the logging of total_pages from the 2nd instance - the value is necessarily zero after {hap,shadow}_set_allocation(). Signed-off-by: Jan Beulich --- The remaining parts of hap_final_teardown() could be moved as well, at the price of a CONFIG_HVM conditional. I wasn't sure whether that was deemed reasonable. --- a/xen/arch/x86/include/asm/shadow.h +++ b/xen/arch/x86/include/asm/shadow.h @@ -78,9 +78,6 @@ int shadow_domctl(struct domain *d, void shadow_vcpu_teardown(struct vcpu *v); void shadow_teardown(struct domain *d, bool *preempted); -/* Call once all of the references to the domain have gone away */ -void shadow_final_teardown(struct domain *d); - void sh_remove_shadows(struct domain *d, mfn_t gmfn, int fast, int all); /* Adjust shadows ready for a guest page to change its type. */ --- a/xen/arch/x86/mm/hap/hap.c +++ b/xen/arch/x86/mm/hap/hap.c @@ -268,8 +268,8 @@ static void hap_free(struct domain *d, m /* * For dying domains, actually free the memory here. This way less work is - * left to hap_final_teardown(), which cannot easily have preemption checks - * added. + * left to paging_final_teardown(), which cannot easily have preemption + * checks added. */ if ( unlikely(d->is_dying) ) { @@ -552,18 +552,6 @@ void hap_final_teardown(struct domain *d for (i = 0; i < MAX_NESTEDP2M; i++) { p2m_teardown(d->arch.nested_p2m[i], true, NULL); } - - if ( d->arch.paging.total_pages != 0 ) - hap_teardown(d, NULL); - - p2m_teardown(p2m_get_hostp2m(d), true, NULL); - /* Free any memory that the p2m teardown released */ - paging_lock(d); - hap_set_allocation(d, 0, NULL); - ASSERT(d->arch.paging.p2m_pages == 0); - ASSERT(d->arch.paging.free_pages == 0); - ASSERT(d->arch.paging.total_pages == 0); - paging_unlock(d); } void hap_vcpu_teardown(struct vcpu *v) --- a/xen/arch/x86/mm/paging.c +++ b/xen/arch/x86/mm/paging.c @@ -842,10 +842,46 @@ int paging_teardown(struct domain *d) /* Call once all of the references to the domain have gone away */ void paging_final_teardown(struct domain *d) { - if ( hap_enabled(d) ) + bool hap = hap_enabled(d); + + PAGING_PRINTK("%pd final teardown starts. Pages total = %u, free = %u, p2m = %u\n", + d, d->arch.paging.total_pages, + d->arch.paging.free_pages, d->arch.paging.p2m_pages); + + if ( hap ) hap_final_teardown(d); + + /* + * Double-check that the domain didn't have any paging memory. + * It is possible for a domain that never got domain_kill()ed + * to get here with its paging allocation intact. + */ + if ( d->arch.paging.total_pages ) + { + if ( hap ) + hap_teardown(d, NULL); + else + shadow_teardown(d, NULL); + } + + /* It is now safe to pull down the p2m map. */ + p2m_teardown(p2m_get_hostp2m(d), true, NULL); + + /* Free any paging memory that the p2m teardown released. */ + paging_lock(d); + + if ( hap ) + hap_set_allocation(d, 0, NULL); else - shadow_final_teardown(d); + shadow_set_allocation(d, 0, NULL); + + PAGING_PRINTK("%pd final teardown done. Pages free = %u, p2m = %u\n", + d, d->arch.paging.free_pages, d->arch.paging.p2m_pages); + ASSERT(!d->arch.paging.p2m_pages); + ASSERT(!d->arch.paging.free_pages); + ASSERT(!d->arch.paging.total_pages); + + paging_unlock(d); p2m_final_teardown(d); } --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -1232,7 +1232,7 @@ void shadow_free(struct domain *d, mfn_t /* * For dying domains, actually free the memory here. This way less - * work is left to shadow_final_teardown(), which cannot easily have + * work is left to paging_final_teardown(), which cannot easily have * preemption checks added. */ if ( unlikely(dying) ) @@ -2940,35 +2940,6 @@ out: } } -void shadow_final_teardown(struct domain *d) -/* Called by arch_domain_destroy(), when it's safe to pull down the p2m map. */ -{ - SHADOW_PRINTK("dom %u final teardown starts." - " Shadow pages total = %u, free = %u, p2m=%u\n", - d->domain_id, d->arch.paging.total_pages, - d->arch.paging.free_pages, d->arch.paging.p2m_pages); - - /* Double-check that the domain didn't have any shadow memory. - * It is possible for a domain that never got domain_kill()ed - * to get here with its shadow allocation intact. */ - if ( d->arch.paging.total_pages != 0 ) - shadow_teardown(d, NULL); - - /* It is now safe to pull down the p2m map. */ - p2m_teardown(p2m_get_hostp2m(d), true, NULL); - /* Free any shadow memory that the p2m teardown released */ - paging_lock(d); - shadow_set_allocation(d, 0, NULL); - SHADOW_PRINTK("dom %u final teardown done." - " Shadow pages total = %u, free = %u, p2m=%u\n", - d->domain_id, d->arch.paging.total_pages, - d->arch.paging.free_pages, d->arch.paging.p2m_pages); - ASSERT(d->arch.paging.p2m_pages == 0); - ASSERT(d->arch.paging.free_pages == 0); - ASSERT(d->arch.paging.total_pages == 0); - paging_unlock(d); -} - static int shadow_one_bit_enable(struct domain *d, u32 mode) /* Turn on a single shadow mode feature */ { From patchwork Wed Dec 21 13:25:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13078765 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 956A5C4332F for ; Wed, 21 Dec 2022 13:26:09 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.467890.726945 (Exim 4.92) (envelope-from ) id 1p7z6f-0004M5-5y; Wed, 21 Dec 2022 13:26:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 467890.726945; Wed, 21 Dec 2022 13:26:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7z6f-0004Ly-2S; Wed, 21 Dec 2022 13:26:01 +0000 Received: by outflank-mailman (input) for mailman id 467890; Wed, 21 Dec 2022 13:25: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 1p7z6d-0003Di-16 for xen-devel@lists.xenproject.org; Wed, 21 Dec 2022 13:25:59 +0000 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2079.outbound.protection.outlook.com [40.107.247.79]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 008fbdc5-8133-11ed-91b6-6bf2151ebd3b; Wed, 21 Dec 2022 14:25:57 +0100 (CET) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AS8PR04MB8214.eurprd04.prod.outlook.com (2603:10a6:20b:3b0::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Wed, 21 Dec 2022 13:25:56 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::4da2:ea8b:e71e:b8d8]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::4da2:ea8b:e71e:b8d8%4]) with mapi id 15.20.5924.016; Wed, 21 Dec 2022 13:25:56 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 008fbdc5-8133-11ed-91b6-6bf2151ebd3b ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JwL6Df3YszTBwlGv1OlA0hSp4q0z+MRE9/YqhmKZs6TXuFk/OdguBj1OL+ZgyTbx/RScA695xZpzgTqAebhBnQK/jFVnbCZWu1CuyQBjozP4q0tv3oTrAl94Td41OkcS9VTRFAmntoawAigysQUIoLM0FnH4SqwuU+JIY1g/A6MC+B6/5umF9YYmqAXgYJilIaH9+L8w3KqDb9V0zxVxfbUTxnkwrXiqOyJ4F7LcYG93KWGy+XLBL+nMYZ+MEMGKOjDfjYrnd0ddZ+xHRufXapkR5woTUgR3CiSqBJEgcqMWAJF3g2riXcaIE/vo9r2S57sPRXMaTiag2ofKAHKqOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rldcuhOARHmNVJ4bzrBkzU00bPLVpOspDoSIIfszq5Y=; b=cm4xxDUprR0GNH954Gz7SeIsiE+gKtQIkA67oz9UC2dpcgisbWcJGp051B1b3Px1cTfv3q8SQmYgqYtjExgVIr0cTJfoY+Krspz5McJsXN9+72BR2k+VPxZYhA2cmydDfVijjvjm2tDXcF+f6TFi0Dm5u1M+ZTzztXV/QL5uucUq8zneylFYRGPkdOoMIpwUJv6Mu7sc7zB2gDxUUIWmb2cmrcPbmQa22ENxQgJK8TEGtK0WrhlhRJDf5h21g+FVKS9WiPZe5NFmDPALfpZCsNolC4VQ5+qODOTPy6DiNArdg+XYFyBgdO24PUJdRFfFZox0kK0PEQDaD9riblq+Zw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rldcuhOARHmNVJ4bzrBkzU00bPLVpOspDoSIIfszq5Y=; b=CAXnM6HXdxR+HsV0AFUmPlv56Vs446+uKNFUuvMJYGYMHTyJ/i6m7zvyFQqU+sDmG9+9f5J3HRZ07m8+A525M845q8bEN9ApEUeVvzAeZqi3G7x74ny+Ozs0TNbGKh2woaKXeLaREBcKJozCy/huq32/LdCjDdcCa2wNTkXxc+nDrGkd8Wq6jIa+qnTfM8/pp9pOJH1jS83e4ypGqgIY04RqdVn1P+yxMM6zgez3Ef0+gKfxVt1ynIbYfCG6Jbw65RiBz01FYRFJp9B8TO6w/Q3014/kC2szxSin3ykaREgsHzLe5Qvpd1Pb9xWhQcyd3AhsLSpDwCVwE0yptY9nGw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Wed, 21 Dec 2022 14:25:55 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: [PATCH 3/8] x86/paging: move update_paging_modes() hook Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Tim Deegan References: In-Reply-To: X-ClientProxiedBy: FR0P281CA0064.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:49::8) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AS8PR04MB8214:EE_ X-MS-Office365-Filtering-Correlation-Id: 4ba18161-67f4-4766-ff8f-08dae356e44d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jvm8ZuL2nffqZFD8YXA+47EEtExRGfXTs9JlbW1qDfrgUDmfqo+ml0U8nMxCyBupy2FJQwHQ9jmsdZtt+gkwHNY0J6wLm+QWTTOrlfUKPjSPXqHWfVcJ9izlaUzk4LJSBU01iWiRJPABusssv6TG+uGXWwv2d6MZRqeed9gVuz1E62GzflhkUbakZMV4hx6Xk/tO+eKEBps0LWwYW11AQ4O7kMn4vX1qloEGspKFLjIYGi71VcSfnhOlQWTcoc8Od0ta83Mf5MxJRHjT/Cf2Ru1Hv0KbdCaVpQj/BRaeAW/dhJdB+WYSYqrot3j8Nb29NmdZMKBh7ci7E5vh5eMMKPYuf58v7m5WBqbCgwUKX0d1FrMVVDXwmdHka5tc5oWOAwbD6JHCUY+mjAjC4FbRHOUyOTokOYO2TI65jSX3J/2IVXG0O8Sjtm5Bb8AfPl7VgQHb+elI6W6L09s6bbhHu18oI7s5i5FkOYjS9MUHH3SbAGWPfIBJaON/wOjtTGfZlAIbdcFXCnMDPH8ZJmkukBiWVef+8Jco4XLRX8wYcKh4SRu8UihDBqnszA6mNBMzdaeAwi9TRjab1LIyl8CClLZWzv9J5VZXThke6029e/nuWTDAhJHSsM1n472VzeotnuicRsPewAu0rbu3bNZ2xDObEh1/8u0Oa7AE7KUiVqVJcGmqSzj7eyJVK4PBOON5kW/X58/K7KW1tpQ4524zXq0gTJDudu70kTx/JHws+Ok= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(346002)(39860400002)(366004)(136003)(376002)(451199015)(186003)(38100700002)(8936002)(36756003)(83380400001)(6486002)(6506007)(2906002)(15650500001)(41300700001)(54906003)(478600001)(6512007)(26005)(6916009)(66476007)(4326008)(5660300002)(86362001)(31686004)(8676002)(31696002)(66946007)(2616005)(66556008)(316002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-Chunk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oPRYk1T?= =?utf-8?q?JOqhTbjt/2/lgpTWSWmwaX42YtrUxjimM4zFDrpFPH6enNxKVOWMaD1XIHGW7PTmv?= =?utf-8?q?AzIBXmH/YRZZV666NZ334ZCDNN5uQYEC8X0ssmP1ACUi6F3JS87Nsd7/kxApTY4eN?= =?utf-8?q?qe+F9Qk1zLCBzFboYlVOB9eZMuTSLfueGMFFqLyKU3SW4QbfThuohCAeeXhrqWec9?= =?utf-8?q?SUo7wqwhRfQMvWgcqEw2sVaL/f671bdH0DCQ7MLxaktwnYzGR+TGqJuO9FcnU8CW2?= =?utf-8?q?PqPLqM4JQ9FseVM0FNEAXZ8JYsZNQvZgK2jYKd42gcqu7cMkwzs4KNsdLS8/J48G5?= =?utf-8?q?Fork2SvyuYCg0GhAd9R8GfIOnMIJZdbiwqAgBRx555sosr/JEH08ErBxH4lLo1G9j?= =?utf-8?q?wE0LmMtrsLZSdMGZL5aRmzpIm/PvndvtezdzVVSorkGVkIyW+b3QoQYZYQad3QPxn?= =?utf-8?q?Jpz9zrjU+ACrfH6w+1Pioc2FPjL94qKtPS53AmZ8VWdj0z5NRSS40F/XkAyAzpHCA?= =?utf-8?q?ABpXW3xGFwRozKK9nG28JfUg94pZEWu++XyYZrkg4lVynvzxDi6nBbOKDbClmYHh/?= =?utf-8?q?NtIv3ZXnd4i5LBOnzp7swYDp4qYarEH8d0QjwLspC47/IBXqyNTuMbrsuY4DrwHHl?= =?utf-8?q?tQ0Wpal6Omc4cV8Q15sIjdlz3gYc4Nr+JkeXDOx+nH515WGHrSBH2T3eYGjrs9SQH?= =?utf-8?q?8IAcOU05xN+6?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ba18161-67f4-4766-ff8f-08dae356e44d X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2022 13:25:56.4605 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3sBkT6E3xT3gwuhXurq8ZZGOo2VqsoruiISx6YYQB7nRXtLXBgNtkoR6myceQ/M7i5iznwKTTFu3wgC9+pAHJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8214 The hook isn't mode dependent, hence it's misplaced in struct paging_mode. (Or alternatively I see no reason why the alloc_page() and free_page() hooks don't also live there.) Move it to struct paging_domain. While there rename the hook and HAP's as well as shadow's hook functions to use singular; I never understood why plural was used. (Renaming in particular the wrapper would be touching quite a lot of other code.) Signed-off-by: Jan Beulich --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -235,6 +235,8 @@ struct paging_domain { * (used by p2m and log-dirty code for their tries) */ struct page_info * (*alloc_page)(struct domain *d); void (*free_page)(struct domain *d, struct page_info *pg); + + void (*update_paging_mode)(struct vcpu *v); }; struct paging_vcpu { --- a/xen/arch/x86/include/asm/paging.h +++ b/xen/arch/x86/include/asm/paging.h @@ -140,7 +140,6 @@ struct paging_mode { #endif void (*update_cr3 )(struct vcpu *v, int do_locking, bool noflush); - void (*update_paging_modes )(struct vcpu *v); bool (*flush_tlb )(const unsigned long *vcpu_bitmap); unsigned int guest_levels; @@ -316,7 +315,7 @@ static inline void paging_update_cr3(str * has changed, and when bringing up a VCPU for the first time. */ static inline void paging_update_paging_modes(struct vcpu *v) { - paging_get_hostmode(v)->update_paging_modes(v); + v->domain->arch.paging.update_paging_mode(v); } #ifdef CONFIG_PV --- a/xen/arch/x86/mm/hap/hap.c +++ b/xen/arch/x86/mm/hap/hap.c @@ -443,6 +443,9 @@ static void hap_destroy_monitor_table(st /************************************************/ /* HAP DOMAIN LEVEL FUNCTIONS */ /************************************************/ + +static void cf_check hap_update_paging_mode(struct vcpu *v); + void hap_domain_init(struct domain *d) { static const struct log_dirty_ops hap_ops = { @@ -453,6 +456,8 @@ void hap_domain_init(struct domain *d) /* Use HAP logdirty mechanism. */ paging_log_dirty_init(d, &hap_ops); + + d->arch.paging.update_paging_mode = hap_update_paging_mode; } /* return 0 for success, -errno for failure */ @@ -772,7 +777,7 @@ hap_paging_get_mode(struct vcpu *v) &hap_paging_protected_mode); } -static void cf_check hap_update_paging_modes(struct vcpu *v) +static void cf_check hap_update_paging_mode(struct vcpu *v) { struct domain *d = v->domain; unsigned long cr3_gfn = v->arch.hvm.guest_cr[3] >> PAGE_SHIFT; @@ -842,7 +847,6 @@ static const struct paging_mode hap_pagi .gva_to_gfn = hap_gva_to_gfn_real_mode, .p2m_ga_to_gfn = hap_p2m_ga_to_gfn_real_mode, .update_cr3 = hap_update_cr3, - .update_paging_modes = hap_update_paging_modes, .flush_tlb = flush_tlb, .guest_levels = 1 }; @@ -853,7 +857,6 @@ static const struct paging_mode hap_pagi .gva_to_gfn = hap_gva_to_gfn_2_levels, .p2m_ga_to_gfn = hap_p2m_ga_to_gfn_2_levels, .update_cr3 = hap_update_cr3, - .update_paging_modes = hap_update_paging_modes, .flush_tlb = flush_tlb, .guest_levels = 2 }; @@ -864,7 +867,6 @@ static const struct paging_mode hap_pagi .gva_to_gfn = hap_gva_to_gfn_3_levels, .p2m_ga_to_gfn = hap_p2m_ga_to_gfn_3_levels, .update_cr3 = hap_update_cr3, - .update_paging_modes = hap_update_paging_modes, .flush_tlb = flush_tlb, .guest_levels = 3 }; @@ -875,7 +877,6 @@ static const struct paging_mode hap_pagi .gva_to_gfn = hap_gva_to_gfn_4_levels, .p2m_ga_to_gfn = hap_p2m_ga_to_gfn_4_levels, .update_cr3 = hap_update_cr3, - .update_paging_modes = hap_update_paging_modes, .flush_tlb = flush_tlb, .guest_levels = 4 }; --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -45,6 +45,8 @@ static int cf_check sh_enable_log_dirty( static int cf_check sh_disable_log_dirty(struct domain *); static void cf_check sh_clean_dirty_bitmap(struct domain *); +static void cf_check shadow_update_paging_mode(struct vcpu *); + /* Set up the shadow-specific parts of a domain struct at start of day. * Called for every domain from arch_domain_create() */ int shadow_domain_init(struct domain *d) @@ -60,6 +62,8 @@ int shadow_domain_init(struct domain *d) /* Use shadow pagetables for log-dirty support */ paging_log_dirty_init(d, &sh_ops); + d->arch.paging.update_paging_mode = shadow_update_paging_mode; + #if (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC) d->arch.paging.shadow.oos_active = 0; #endif @@ -2558,7 +2562,12 @@ static void sh_update_paging_modes(struc v->arch.paging.mode->update_cr3(v, 0, false); } -void cf_check shadow_update_paging_modes(struct vcpu *v) +/* + * Update all the things that are derived from the guest's CR0/CR3/CR4. + * Called to initialize paging structures if the paging mode has changed, + * and when bringing up a VCPU for the first time. + */ +static void cf_check shadow_update_paging_mode(struct vcpu *v) { paging_lock(v->domain); sh_update_paging_modes(v); --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -4198,7 +4198,6 @@ const struct paging_mode sh_paging_mode .gva_to_gfn = sh_gva_to_gfn, #endif .update_cr3 = sh_update_cr3, - .update_paging_modes = shadow_update_paging_modes, .flush_tlb = shadow_flush_tlb, .guest_levels = GUEST_PAGING_LEVELS, .shadow.detach_old_tables = sh_detach_old_tables, --- a/xen/arch/x86/mm/shadow/none.c +++ b/xen/arch/x86/mm/shadow/none.c @@ -18,6 +18,11 @@ static void cf_check _clean_dirty_bitmap ASSERT(is_pv_domain(d)); } +static void cf_check _update_paging_mode(struct vcpu *v) +{ + ASSERT_UNREACHABLE(); +} + int shadow_domain_init(struct domain *d) { static const struct log_dirty_ops sh_none_ops = { @@ -27,6 +32,9 @@ int shadow_domain_init(struct domain *d) }; paging_log_dirty_init(d, &sh_none_ops); + + d->arch.paging.update_paging_mode = _update_paging_mode; + return is_hvm_domain(d) ? -EOPNOTSUPP : 0; } @@ -57,11 +65,6 @@ static void cf_check _update_cr3(struct ASSERT_UNREACHABLE(); } -static void cf_check _update_paging_modes(struct vcpu *v) -{ - ASSERT_UNREACHABLE(); -} - static const struct paging_mode sh_paging_none = { .page_fault = _page_fault, .invlpg = _invlpg, @@ -69,7 +72,6 @@ static const struct paging_mode sh_pagin .gva_to_gfn = _gva_to_gfn, #endif .update_cr3 = _update_cr3, - .update_paging_modes = _update_paging_modes, }; void shadow_vcpu_init(struct vcpu *v) --- a/xen/arch/x86/mm/shadow/private.h +++ b/xen/arch/x86/mm/shadow/private.h @@ -426,11 +426,6 @@ void cf_check sh_write_guest_entry( intpte_t cf_check sh_cmpxchg_guest_entry( struct vcpu *v, intpte_t *p, intpte_t old, intpte_t new, mfn_t gmfn); -/* Update all the things that are derived from the guest's CR0/CR3/CR4. - * Called to initialize paging structures if the paging mode - * has changed, and when bringing up a VCPU for the first time. */ -void cf_check shadow_update_paging_modes(struct vcpu *v); - /* Unhook the non-Xen mappings in this top-level shadow mfn. * With user_only == 1, unhooks only the user-mode mappings. */ void shadow_unhook_mappings(struct domain *d, mfn_t smfn, int user_only); From patchwork Wed Dec 21 13:26:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13078766 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 16556C4332F for ; Wed, 21 Dec 2022 13:26:53 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.467897.726956 (Exim 4.92) (envelope-from ) id 1p7z7K-0004yn-Jl; Wed, 21 Dec 2022 13:26:42 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 467897.726956; Wed, 21 Dec 2022 13:26:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7z7K-0004ye-H5; Wed, 21 Dec 2022 13:26:42 +0000 Received: by outflank-mailman (input) for mailman id 467897; Wed, 21 Dec 2022 13:26:41 +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 1p7z7I-0004I8-Pw for xen-devel@lists.xenproject.org; Wed, 21 Dec 2022 13:26:41 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2054.outbound.protection.outlook.com [40.107.20.54]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 19bfbfdf-8133-11ed-8fd4-01056ac49cbb; Wed, 21 Dec 2022 14:26:39 +0100 (CET) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by DU2PR04MB8582.eurprd04.prod.outlook.com (2603:10a6:10:2d9::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Wed, 21 Dec 2022 13:26:35 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::4da2:ea8b:e71e:b8d8]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::4da2:ea8b:e71e:b8d8%4]) with mapi id 15.20.5924.016; Wed, 21 Dec 2022 13:26:35 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 19bfbfdf-8133-11ed-8fd4-01056ac49cbb ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BqUoZ67qtEQOON11Ly4g4gWSBcXDwioQWHBlLtsSaZAQ3SGW3U+PzfMdTyVpbsRYfKyDdLCsEwOj8dEcuHV6gatjPxw851XyjhUVLovOiRXNT4uLpCK0YZNhPbj14+3J+PdMgTkrmEsO0XyQzoGzjQBZCtISNYmMKB8ewAQM7kUxxQVUknY9G/TgrcpHc3dp4l0//l52UHJ9SRvduw/k+LWdl7pSU9OpbK/sIGzAEj6wEboPIqIxDDp7IkQ0B1eF1LqzMdTCVbZZmSosdmOqepoSGOadH8tEGBDyj/Ykm4OTP/7fb1VUiEcUrRHsNNdXd9hJY3/zzernfzmgMlqK0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=r07Xy42pMGGEVQDplutw+NfWm8QrmcB72FHciyULsR0=; b=gPltjaS1/SHfHAcoXV7SgxGLRGislKlp31HVKYoJtADDMJznspPNa5akUuoF6TK3D/y2DvTMJwL/wHVsYQmTblKi6eDvJrCSZ0Rj4dEjLPeabaOYCXPa6xuXV9S8RWdmjWQW4NGjNJFIh4tmdLkoyrII+X2jnuDRwito3NO4WCYR5MfW96I0KqZz8mgGsX6F+HQ+K2BeJNnovAEGK5s+Deq/sov/xfcO5UnFS13u2urbLIPkaUJ/wcrsoghumC0Fs4Xrtu5CJW6g7JKehKsOEyHcwtUvOogmr7NHCiEKOJXHYvguc0pwot2zK0Oo1o55T52GMXTYYlxKaEO41mRN9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r07Xy42pMGGEVQDplutw+NfWm8QrmcB72FHciyULsR0=; b=mgQAh+eHNV09xflz6SG+P1eaGCBTtujN7xSKVYKTVuqTgfU6Z0wsi/4DqGgYLmq8aUn/OmXOS9tGoUhZoPoA2QFNHM8Z4Jk0/JJqC/DTkvb0McuNBgGPofeVJ6ESyUY+C3xyV7RpZPqihjy0TA1MvM80FtJHC0boxiD9+rpNLnesYl+jbT4x/Q3FDl7CWSQcNJCe9BREv37tKxz93I7ZQhIhb/hr4YNQWakPAOxvZmoEQrdLceHGjS0YLdHjtNhgesAOis3GIUAwpOKE+TR013M2hSGojAs/aUpcqp/Kqk2VgqXYlI1O8G3NlvggAK2qrbR2orb2Dn/IgjER+0hWtw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <584a986e-08ea-d064-9447-ed23c6e39721@suse.com> Date: Wed, 21 Dec 2022 14:26:34 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: [PATCH 4/8] x86/paging: move and conditionalize flush_tlb() hook Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Tim Deegan References: In-Reply-To: X-ClientProxiedBy: FR3P281CA0204.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a5::9) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|DU2PR04MB8582:EE_ X-MS-Office365-Filtering-Correlation-Id: f49f167a-0c38-4e81-9cd2-08dae356fbbe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LN79KCfHRqYQKkt34XcYtPV2dokir+tnsskLmurLicJyN8H4Hh0xQyOx1gN16D5rAjIXEL94P29+4MBaoiTYt/kGXtdHRaY+7nk9MfMbL5e+G8Wlle/2sLdWlz43ZVzPM60emVC310t2XcxPL9BqVMbMFdHp+9BwR8SzNO0OQONtBuhUMSL6AOqpy74rwkadxuG6ToylihJMWqjXODystPnxE+Lcr3PI1io8UeNNEE9vBuXH84CwwVYRMxhE6i0veNt5gz+4blRyUL1XR8cX8Orb0BC+xmtla/RO+mQvjY6aWJUGz8iInxxKWZVzqf/oJMQh1RtrYA5VUekQPVmr0CkzXop3LRBdui3p8fspRnAd6NQ7+HEzuVtW8lOUoSH0NPrue2ll/TWjuiV10sC9wgpr3WScPCbG+JMTCWRk2SK+b9DGGLtYIO00eWNsD+chHRGcvl687nMuxFwqcaC0QuCllpHtpvtm7Ptc/ueaiNGu6jVXF1tbgP1o6+Qwkplvu1Qv2hSUHDafWkt86vxqmBECiZah7Qt+C0gi0Zw+MsoIS76ybVzwDTjJQP+Hx+P+KguFf6SXjPmaX1koBzNF+d3F1HQlZrQhuEQEM0FX7l+UluQ0eIoLGEIiOaZGbe2v3cvl72ySys037PJy05J4MEkLm1ZB8+rt0drxdbLrjHGv+0+qcDADfyFN/vYagPLqqu6veDWz3G5r11pL87KeCW6x4J8lcGltW+33bNtt6dk= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(39860400002)(376002)(136003)(396003)(346002)(451199015)(83380400001)(86362001)(31696002)(2616005)(38100700002)(36756003)(478600001)(26005)(186003)(6506007)(6486002)(6512007)(66946007)(66476007)(5660300002)(8676002)(4326008)(66899015)(316002)(6916009)(31686004)(8936002)(66556008)(41300700001)(2906002)(54906003)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData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7gnwKwil060HLBtweKjuF9WX/kS037op47iXSwnmQCa0LePytkx8FlvYqJly7o8?= =?utf-8?q?oPDW9R0WZo2YZiA+UOa8iSqKI8xPiqvcxCmfvG43eVi1qo0vZq2fZUucfe+KfWbeL?= =?utf-8?q?aPAq3FPXVjt+G3ikr0U4n4r+IBL1g79IkHxv8fFelBvxRg3QSjZGkqH1hIXCepYiT?= =?utf-8?q?W+RjZKFMWR8NRa0di6UzcZQf8uKvbphyy1rc2gj9AHfpJ9ifZUA4yye3vj4hRius+?= =?utf-8?q?W1nl0mvinrmkFfOMSJDF4icEqt0+tOIeryBHXB0vv4F1m9JYjTJh3FbkgSFbXDrSC?= =?utf-8?q?3sODPA6k8RvkTXk02pZIyuDxBBLDF35hKfpvDXZAzxshgx5bDl0aTEze4JCoBR5rW?= =?utf-8?q?m0ni3ULyqqFv398iqi0EMdnhxp6zxk6f1wU70HcmfdO+1K8rBjFpaGHHdIIfLuVZP?= =?utf-8?q?jfM1xgL0aG1zuGSG0q+HyhzRe+I1Du6jPxuprCmVHpZDfv0ToGsQalG+pKGFNHuq8?= =?utf-8?q?pQHg9G28C4fYYWI/6hQWtLbSVNYUrVWWtD3wKOyw0TqNgPGatkR5n8ANXSPyVFfCo?= =?utf-8?q?XFtEZz1cgzQku3wixcxM8G5HWnPDd+IHvyavgM2IodZiJShKkiR6UvQ4Sk5yCEgtq?= =?utf-8?q?4kFmJWzEq/zJL7PqYeXVRF+33hGedA31BOzlQ6Lr/ZkFu1YY89ML3j4MuTxNetE1A?= =?utf-8?q?vTJXPCVwMCx8?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: f49f167a-0c38-4e81-9cd2-08dae356fbbe X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2022 13:26:35.7393 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /ssBx8hmaHvfkmcAHSUOFJZ+9jZGGTDA5Z9tLxG866td7caX28oDoWlmv1WC7bAGKHSwzGioBSVGMeJRs4qnIg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8582 The hook isn't mode dependent, hence it's misplaced in struct paging_mode. (Or alternatively I see no reason why the alloc_page() and free_page() hooks don't also live there.) Move it to struct paging_domain. The hook also is used for HVM guests only, so make respective pieces conditional upon CONFIG_HVM. While there also add __must_check to the hook declaration, as it's imperative that callers deal with getting back "false". While moving the shadow implementation, introduce a "curr" local variable. Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper , with two --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -237,6 +237,11 @@ struct paging_domain { void (*free_page)(struct domain *d, struct page_info *pg); void (*update_paging_mode)(struct vcpu *v); + +#ifdef CONFIG_HVM + /* Flush selected vCPUs TLBs. NULL for all. */ + bool __must_check (*flush_tlb)(const unsigned long *vcpu_bitmap); +#endif }; struct paging_vcpu { --- a/xen/arch/x86/include/asm/paging.h +++ b/xen/arch/x86/include/asm/paging.h @@ -140,7 +140,6 @@ struct paging_mode { #endif void (*update_cr3 )(struct vcpu *v, int do_locking, bool noflush); - bool (*flush_tlb )(const unsigned long *vcpu_bitmap); unsigned int guest_levels; @@ -300,6 +299,12 @@ static inline unsigned long paging_ga_to page_order); } +/* Flush selected vCPUs TLBs. NULL for all. */ +static inline bool paging_flush_tlb(const unsigned long *vcpu_bitmap) +{ + return current->domain->arch.paging.flush_tlb(vcpu_bitmap); +} + #endif /* CONFIG_HVM */ /* Update all the things that are derived from the guest's CR3. @@ -408,12 +413,6 @@ static always_inline unsigned int paging return bits; } -/* Flush selected vCPUs TLBs. NULL for all. */ -static inline bool paging_flush_tlb(const unsigned long *vcpu_bitmap) -{ - return paging_get_hostmode(current)->flush_tlb(vcpu_bitmap); -} - #endif /* XEN_PAGING_H */ /* --- a/xen/arch/x86/mm/hap/hap.c +++ b/xen/arch/x86/mm/hap/hap.c @@ -445,6 +445,7 @@ static void hap_destroy_monitor_table(st /************************************************/ static void cf_check hap_update_paging_mode(struct vcpu *v); +static bool cf_check flush_tlb(const unsigned long *vcpu_bitmap); void hap_domain_init(struct domain *d) { @@ -458,6 +459,7 @@ void hap_domain_init(struct domain *d) paging_log_dirty_init(d, &hap_ops); d->arch.paging.update_paging_mode = hap_update_paging_mode; + d->arch.paging.flush_tlb = flush_tlb; } /* return 0 for success, -errno for failure */ @@ -847,7 +849,6 @@ static const struct paging_mode hap_pagi .gva_to_gfn = hap_gva_to_gfn_real_mode, .p2m_ga_to_gfn = hap_p2m_ga_to_gfn_real_mode, .update_cr3 = hap_update_cr3, - .flush_tlb = flush_tlb, .guest_levels = 1 }; @@ -857,7 +858,6 @@ static const struct paging_mode hap_pagi .gva_to_gfn = hap_gva_to_gfn_2_levels, .p2m_ga_to_gfn = hap_p2m_ga_to_gfn_2_levels, .update_cr3 = hap_update_cr3, - .flush_tlb = flush_tlb, .guest_levels = 2 }; @@ -867,7 +867,6 @@ static const struct paging_mode hap_pagi .gva_to_gfn = hap_gva_to_gfn_3_levels, .p2m_ga_to_gfn = hap_p2m_ga_to_gfn_3_levels, .update_cr3 = hap_update_cr3, - .flush_tlb = flush_tlb, .guest_levels = 3 }; @@ -877,7 +876,6 @@ static const struct paging_mode hap_pagi .gva_to_gfn = hap_gva_to_gfn_4_levels, .p2m_ga_to_gfn = hap_p2m_ga_to_gfn_4_levels, .update_cr3 = hap_update_cr3, - .flush_tlb = flush_tlb, .guest_levels = 4 }; --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -68,6 +68,7 @@ int shadow_domain_init(struct domain *d) d->arch.paging.shadow.oos_active = 0; #endif #ifdef CONFIG_HVM + d->arch.paging.flush_tlb = shadow_flush_tlb; d->arch.paging.shadow.pagetable_dying_op = 0; #endif @@ -3134,66 +3135,6 @@ static void cf_check sh_clean_dirty_bitm paging_unlock(d); } - -static bool flush_vcpu(const struct vcpu *v, const unsigned long *vcpu_bitmap) -{ - return !vcpu_bitmap || test_bit(v->vcpu_id, vcpu_bitmap); -} - -/* Flush TLB of selected vCPUs. NULL for all. */ -bool cf_check shadow_flush_tlb(const unsigned long *vcpu_bitmap) -{ - static DEFINE_PER_CPU(cpumask_t, flush_cpumask); - cpumask_t *mask = &this_cpu(flush_cpumask); - struct domain *d = current->domain; - struct vcpu *v; - - /* Avoid deadlock if more than one vcpu tries this at the same time. */ - if ( !spin_trylock(&d->hypercall_deadlock_mutex) ) - return false; - - /* Pause all other vcpus. */ - for_each_vcpu ( d, v ) - if ( v != current && flush_vcpu(v, vcpu_bitmap) ) - vcpu_pause_nosync(v); - - /* Now that all VCPUs are signalled to deschedule, we wait... */ - for_each_vcpu ( d, v ) - if ( v != current && flush_vcpu(v, vcpu_bitmap) ) - while ( !vcpu_runnable(v) && v->is_running ) - cpu_relax(); - - /* All other vcpus are paused, safe to unlock now. */ - spin_unlock(&d->hypercall_deadlock_mutex); - - cpumask_clear(mask); - - /* Flush paging-mode soft state (e.g., va->gfn cache; PAE PDPE cache). */ - for_each_vcpu ( d, v ) - { - unsigned int cpu; - - if ( !flush_vcpu(v, vcpu_bitmap) ) - continue; - - paging_update_cr3(v, false); - - cpu = read_atomic(&v->dirty_cpu); - if ( is_vcpu_dirty_cpu(cpu) ) - __cpumask_set_cpu(cpu, mask); - } - - /* Flush TLBs on all CPUs with dirty vcpu state. */ - guest_flush_tlb_mask(d, mask); - - /* Done. */ - for_each_vcpu ( d, v ) - if ( v != current && flush_vcpu(v, vcpu_bitmap) ) - vcpu_unpause(v); - - return true; -} - /**************************************************************************/ /* Shadow-control XEN_DOMCTL dispatcher */ --- a/xen/arch/x86/mm/shadow/hvm.c +++ b/xen/arch/x86/mm/shadow/hvm.c @@ -688,6 +688,66 @@ static void sh_emulate_unmap_dest(struct atomic_inc(&v->domain->arch.paging.shadow.gtable_dirty_version); } +static bool flush_vcpu(const struct vcpu *v, const unsigned long *vcpu_bitmap) +{ + return !vcpu_bitmap || test_bit(v->vcpu_id, vcpu_bitmap); +} + +/* Flush TLB of selected vCPUs. NULL for all. */ +bool cf_check shadow_flush_tlb(const unsigned long *vcpu_bitmap) +{ + static DEFINE_PER_CPU(cpumask_t, flush_cpumask); + cpumask_t *mask = &this_cpu(flush_cpumask); + const struct vcpu *curr = current; + struct domain *d = curr->domain; + struct vcpu *v; + + /* Avoid deadlock if more than one vcpu tries this at the same time. */ + if ( !spin_trylock(&d->hypercall_deadlock_mutex) ) + return false; + + /* Pause all other vcpus. */ + for_each_vcpu ( d, v ) + if ( v != curr && flush_vcpu(v, vcpu_bitmap) ) + vcpu_pause_nosync(v); + + /* Now that all VCPUs are signalled to deschedule, we wait... */ + for_each_vcpu ( d, v ) + if ( v != curr && flush_vcpu(v, vcpu_bitmap) ) + while ( !vcpu_runnable(v) && v->is_running ) + cpu_relax(); + + /* All other vcpus are paused, safe to unlock now. */ + spin_unlock(&d->hypercall_deadlock_mutex); + + cpumask_clear(mask); + + /* Flush paging-mode soft state (e.g., va->gfn cache; PAE PDPE cache). */ + for_each_vcpu ( d, v ) + { + unsigned int cpu; + + if ( !flush_vcpu(v, vcpu_bitmap) ) + continue; + + paging_update_cr3(v, false); + + cpu = read_atomic(&v->dirty_cpu); + if ( is_vcpu_dirty_cpu(cpu) ) + __cpumask_set_cpu(cpu, mask); + } + + /* Flush TLBs on all CPUs with dirty vcpu state. */ + guest_flush_tlb_mask(d, mask); + + /* Done. */ + for_each_vcpu ( d, v ) + if ( v != curr && flush_vcpu(v, vcpu_bitmap) ) + vcpu_unpause(v); + + return true; +} + mfn_t sh_make_monitor_table(const struct vcpu *v, unsigned int shadow_levels) { struct domain *d = v->domain; --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -4198,7 +4198,6 @@ const struct paging_mode sh_paging_mode .gva_to_gfn = sh_gva_to_gfn, #endif .update_cr3 = sh_update_cr3, - .flush_tlb = shadow_flush_tlb, .guest_levels = GUEST_PAGING_LEVELS, .shadow.detach_old_tables = sh_detach_old_tables, #ifdef CONFIG_PV From patchwork Wed Dec 21 13:27:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13078778 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 35082C4167B for ; Wed, 21 Dec 2022 13:35:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.467911.726978 (Exim 4.92) (envelope-from ) id 1p7zFK-0007BH-R2; Wed, 21 Dec 2022 13:34:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 467911.726978; Wed, 21 Dec 2022 13:34:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7zFK-0007BA-M2; Wed, 21 Dec 2022 13:34:58 +0000 Received: by outflank-mailman (input) for mailman id 467911; Wed, 21 Dec 2022 13:34:57 +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 1p7z7j-0003Di-Oe for xen-devel@lists.xenproject.org; Wed, 21 Dec 2022 13:27:07 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2075.outbound.protection.outlook.com [40.107.13.75]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 29cc5943-8133-11ed-91b6-6bf2151ebd3b; Wed, 21 Dec 2022 14:27:06 +0100 (CET) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by DU2PR04MB8582.eurprd04.prod.outlook.com (2603:10a6:10:2d9::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Wed, 21 Dec 2022 13:27:05 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::4da2:ea8b:e71e:b8d8]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::4da2:ea8b:e71e:b8d8%4]) with mapi id 15.20.5924.016; Wed, 21 Dec 2022 13:27:05 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 29cc5943-8133-11ed-91b6-6bf2151ebd3b ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JVBYdeP0b0vu5GDPEmIxp52blEfH7yDoGx/+aaj+prhwyYdRO8Yjqnys1vmnGC/KZAB/rCABgEegYcByHDNE3/cdcxa/CqOba3Jn2xOfG5btznojXHlpz/UECpJcZzbuv1Y5GGlUAZ8Y+zcFspjL9wYioh6JitsMvjfOkoa618Ou7UnEbm4ciXAk2oLE3HJh3qAdELgLFLnOvWJjJSUz6xLq2ra3Jl1dqDFqaS2zLe6YJso5G+mBiSzumAXgG2IErXmg9KT+1b1JcQa0LfHvAIKwEarlWRSIsyoaEY4KoUgSbMNHR4DXQSD33dkT28wHbxshy1LsSiNbQ2ffbap7YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jPAPBzI9r0Pqf/DLCl5qsysEb208XfAwkfak1FQmFWM=; b=QmRsU/yCwgLfZ/bfqg6j/gaG/B7VZzRjk9a+2oAl+5jOaTSIf7Qc0lJU7dbVROUQJ3J2Nh90cRuD5D7Rx4kanXDETUsVDlPwPfv01K/b3nTYboxd1iyOgSsH2vHg9sn9yLh48/bSiNaDTVOgVmVVyJgMVFZTMmYxCEkQ3GD5s3dYguADDn7rpoeLdimngg1Igo3+VWKZ8a2gEsmzjevZXisupiNophqFBonD2InGeecON2olpXiA12ZdDKDHlvqWVONEZIgOaaXrviDR5/VpOm+SnTC+s9zUYS/H0n9ePZ4kYiSdlmCxKSwOrhBuGVqO60XQg9h2qAtXL7RYWC3GDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jPAPBzI9r0Pqf/DLCl5qsysEb208XfAwkfak1FQmFWM=; b=Qh1yIfZLHgeJRCEnASb5c8y4OWP9Z6OHsqqXNQCwQakml0y7KMqCVsKYb3LibO0oiybB2FKuSIXwt1ZsSMGEIcm2iqIdMRXCrmv9gcaxKKOj6lJzuK0SNLrGC7nbr5QcPAxgRGOzyMzDbxdgEd2C0BiCHUZyG1CUWJAXK7Ajxwv7FT1FuAN7+lzohnw1cUBAJhOx5m808DTwGW9nSdsjBkJ8I/rVxAN6nQ1mOL03iY5XeUcjLjRVpHjh3LzkE+oksb70PZItJ8TydzJWCq5FYmZqJh7S2a0CnXKpEHy91m2zoCl090x5CdGyky0+hJWgWkSbAgpaxzIZ8KqOU5nUAw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Wed, 21 Dec 2022 14:27:04 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: [PATCH 5/8] x86/PV: drop dead paging_update_paging_modes() call during Dom0 construction Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Tim Deegan References: In-Reply-To: X-ClientProxiedBy: FR2P281CA0056.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:93::7) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|DU2PR04MB8582:EE_ X-MS-Office365-Filtering-Correlation-Id: 6c1f6eb9-3ea9-42b0-f76b-08dae3570d80 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4Be0MpNX/2ClCniKXEKqwM/8jk/HfDPqhWcQjXWi2SyevVQLJ8uNr+LRcCDopcM6d28E2ReG8NlsGMTYZ2AOF8CqQcoLE0cwbDOXcxPnhumOUq03CA88D1RNreuKt2apVW0wz0mgXYbWzJWTAN+q+uLT1UEWQUA8F0RbIbEO+1rA8EcDFgGkhndKToPK4EdS+83uzKRbDjiz260aYqg8M6LZktG3XaMl0MIgCR8tA254FV68LJDaQNC7p5Slmk/RZX6QTeSwj4cSEV6qANXAaQkcsne+bb4Fs6fpcYNduS32qXfkOCrTEpbouVGRtvUE2r85p5fyrYNmBaUm48aOxGTG7izmOfbIcnkZzS3NVre8LsTRyR1ammKCnRKcNUZ7PkiGSyKCdSnRO6ycnligj2Vq8ftYb93hwdja7AReRsFC87d4Z7OFpoi70c8eM25D/OUehhY8EMERk0SPC9pOBQ3buwJgd69qWC6KVkaN/ECqXpki4/KFzO+gsV/LUa2IZn6jETPriXfx2e/5XllbOQlzhe5CsI/2tVAYJVl1b7X1nhZZ2We19qce+DHIt8aV3PFok/O0KKih0Lw+ZeOZip77MyJnTu/Gj+VUnKGyS3BL2JMGI5ZSLwQ7Hd6tNu43H1BHEa2WTDkG7Bqvmkvw68U4lmDYR2SPKJDCXG1ye5Vbuu7Sir6kDatSnqrEaHsyHyZpzVNbAno8szCSMCr9R+0KbqANW2id5DVcLMaUwwE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(39860400002)(376002)(136003)(396003)(346002)(451199015)(83380400001)(86362001)(31696002)(2616005)(38100700002)(36756003)(478600001)(26005)(186003)(6506007)(6486002)(6512007)(66946007)(66476007)(5660300002)(8676002)(4326008)(316002)(6916009)(31686004)(8936002)(66556008)(41300700001)(2906002)(54906003)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?fIvEyi6t7Iu55g6e27toRS5G0PDz?= =?utf-8?q?AV/DIH4L8VZ2ccLGT4k9GtA+LNEhjgvT2cTXxdVKqolHlQOFkZhTsGwp3XWsbyNZH?= =?utf-8?q?LkUNrXss05Lfiphs7ZCT4cphPrloEFOxvMfZi1eyKn1xvNhUFbbtNT4ZXH6MEz2fa?= =?utf-8?q?tD3ItfSUDYd9kumaUejiyTAtj5Gj6ZbJSVOnZ8S4PSFztUa6xNgnN69yD3q5/Kj7g?= =?utf-8?q?yURYgFqI1huYMYbKZpiLAQg3v3dnbrmT5dbwUyeJgabXSNB7LwKsrblBua1twwHcK?= =?utf-8?q?/m6ERGTYXexNdpuyurN5upYz7PbpW75hdybTXT4aiMnYBDIbFQHb9EvPtx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vX0FERtD?= =?utf-8?q?cG5sr3gwER0JBqdo2CCPM3WWRFAU9BI/FfbUqNlECwUxEstG7x4nTvPl62JPNmbxh?= =?utf-8?q?ODEzuDICwEuN/8+QewmHhvxTKTrkqNeXOo+Wm1iI9Z+D8dR71IAZuPqOz80MMRLO1?= =?utf-8?q?YFD0T/Wq9/GFjdVdQX88qh9wxag9yI4Nx/bhkKASXHJxoIu2C4eys4tLK60lPAnXK?= =?utf-8?q?vnFlKpTRT+sLyRTbjjeHQ2//btC0k7TAnC5zTf1upVY5L274DkWQuL6ud0aeKu4Jh?= =?utf-8?q?s4QtLhjZ3I5miQwY5oSt5p3yFZjXN9iB0J3AbjrO0wxLiRoNBQqEVTgGYz/T0ML1E?= =?utf-8?q?pxsAzk3pwA4N?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6c1f6eb9-3ea9-42b0-f76b-08dae3570d80 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2022 13:27:05.5343 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: I21aga143y/Q2Z2gdSj96NYdu8SH1khvmveIpvmdy4XVhk9IK6XfyEBYUXWvPWFosNZq3pEvmT90dh5P38DC4Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8582 The function won't ever be invoked, as paging_mode_enabled() always returns false here due to the immediately preceding clearing of d->arch.paging.mode. While compilers recognize this and eliminate the call, make this explicit in the source (which likely 9a28170f2da2 ["pvh dom0: construct_dom0 changes"] should have done right away, albeit even before that the call looks to have been pointless - shadow mode enabling has occurred later virtually forever). While there also update an adjacent partly stale comment. Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -804,11 +803,8 @@ int __init dom0_construct_pv(struct doma d->arch.paging.mode = 0; - /* Set up CR3 value for write_ptbase */ - if ( paging_mode_enabled(d) ) - paging_update_paging_modes(v); - else - update_cr3(v); + /* Set up CR3 value for switch_cr3_cr4(). */ + update_cr3(v); /* We run on dom0's page tables for the final part of the build process. */ switch_cr3_cr4(cr3_pa(v->arch.cr3), read_cr4()); From patchwork Wed Dec 21 13:27:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13078767 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 8DD0DC4332F for ; Wed, 21 Dec 2022 13:27:42 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.467903.726967 (Exim 4.92) (envelope-from ) id 1p7z86-0005Z5-UX; Wed, 21 Dec 2022 13:27:30 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 467903.726967; Wed, 21 Dec 2022 13:27:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7z86-0005Yy-QL; Wed, 21 Dec 2022 13:27:30 +0000 Received: by outflank-mailman (input) for mailman id 467903; Wed, 21 Dec 2022 13:27:30 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7z85-0004I8-Oc for xen-devel@lists.xenproject.org; Wed, 21 Dec 2022 13:27:29 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2089.outbound.protection.outlook.com [40.107.13.89]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 371b1f6f-8133-11ed-8fd4-01056ac49cbb; Wed, 21 Dec 2022 14:27:29 +0100 (CET) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by DU2PR04MB8582.eurprd04.prod.outlook.com (2603:10a6:10:2d9::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Wed, 21 Dec 2022 13:27:27 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::4da2:ea8b:e71e:b8d8]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::4da2:ea8b:e71e:b8d8%4]) with mapi id 15.20.5924.016; Wed, 21 Dec 2022 13:27:27 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 371b1f6f-8133-11ed-8fd4-01056ac49cbb ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oFI+7A7bB0bMZXnCezAEFai+PMf+hrNYXFT0H7ajeaeOifwGT4AA6SCHZOURfCbv1R7Zts0iZOkRGj0aflaovT/IxK5eMKyADNv0YXFusrnRUNIoNbS8vSklL4DORAypVrkoep1BXzPmVXseaRabze4odXRYn/l6XgGPyx25Mg51xbUkXmXnfD0kwwvVx77Z5sUB1ocoiTUZ6Ynwm2Y9i3/Xwuv4camQeFMbL/kHUx53nZ8kOcehXPtIFiiLuM09fnrABviZxm0nNYDg16SPCJ9IGmKIIYFA9GRWZTy2h/RPtTq20uGR9aC/sOEtSKWlfrIOteFOQZficjZHPa9eXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1niUsk5aDtIhCowAMZf6eTqYxpgtxdoRIXxLB3FTKzg=; b=SkrBSxbozIkHxw1vAoemOx7uep0396Lk8DUUrzTuBDZpKjrGUthVOuxVkyA/he4Lz/n73Yd9gv08uI3EwEI+gfzqurn+aFLV55RiwTgYhHtd2SUowYVdyyZTgRDU5Q3YpIdauzg05MXA7P0qr7g21J8bwNATuTIdJRB00ZAyy/lyUYdkCCDf+0ubXFzIzmrxCrgnXHSBGaDoYESjxAYzgILSr6XNz4aqgUc/EXb4f0kbMJiC40ad6S/veiX3K1RmKWzRMPPXwg6t16tAsTgLWiYwfrmiIico2b7z7fcw9vJp9VzvIGG10PGhdvBEVcV1UR0jRESyM4YZrPppcDzSzQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1niUsk5aDtIhCowAMZf6eTqYxpgtxdoRIXxLB3FTKzg=; b=Z/EDS2AHz+18HMErqIHcvRR7vY/hepriH43FamuB8Q2w26Gx/j5ipuJPKza5x6+JUpRcyjryVLKZYbdLTV//Otdsmc0ICKqTeBIVtFRnKpLzVMnwwcrpPfmilVh6qkzXxs+Igv0wKwI4w0ompsHY1XZH+ZYdfTqaFqGJoUt0EiGxiWyy3S+5o4pt57PPUdsYOzZ1j4RBdVTvspnHJ/kfXxSlPS8cJ/lK8cpd0rEPVxk0quqRqt9ZW425lI4t49KmjQnLaZ8E42MjJZFGSaApscSVjxnmgwRreqBiTaXmxlT6/1+6XBTLs7ko9lTT+5wLHE+iy/2P1Flsj+o0CrYvYg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Wed, 21 Dec 2022 14:27:26 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: [PATCH 6/8] x86/shadow: adjust and move sh_type_to_size[] Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Tim Deegan References: In-Reply-To: X-ClientProxiedBy: FR2P281CA0137.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9e::12) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|DU2PR04MB8582:EE_ X-MS-Office365-Filtering-Correlation-Id: 8deae829-604d-404a-3840-08dae3571aa7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mxwVCf2q/XZq1IhjlxzsWPgiR0pMcZy81rcjhanZsLc+qnMDcCo6W4jKvrHbJ4gYGUhb334xOJpOdU1eTkUZrxLquR1RvS9y+m49LJ6r6aSert7G0Op3CsEcBTkPnS5gYHWXUPiQV5KfgiFsZrukr9s4fuYrh9lUEiE65e5al3TKI8rJBcL7kUyyZMihtega6Us3L0c8iHKVr0Zd4lB46U/DSb9co4TB8onhVXbvoZlPF7RXWvcYoJEV9o0klnD0KjqVu57fn8ixzDr6fU9Fv0fCIgTS3F+/dvi5VHYUzjuN849NUtXegiSZ1VtBa8p9Pz31dslxYYZHJesGQwn4hGyR+FFcWUAnc7QShcyLeqcXhUuQlhyTsr/wbmJnbIbu3cSyiKQztQ+krZ1LtDOUx1nk/28a5ynT4mnbfolGplS+/mxG5vwhXHnsQ4JRAvJqYBymxLoNxhEmNH1PL+NNO1Yd0wXevofN1bAkhdxl1SJA6KOFDj9XEv7NjIGS5XEjE8y+Yn4pe4FNI9NYhpQ1jdareW71oA5KI8W91BFq5qLgL4KHk9cxdbTQkRKslwKAV85YlFOpFVrxgsuayQewSj8uD51clNGuF60/mmntqK2RmiJljstLui8cCzDvkETcYrbYSQf5StEy14/u5bGt2TitDrxhlV65i6XzUjs4XhSWR4MVM6ufz4HSfuSljHeiXFrKxGDTRrtV3a/S7qu9LkY7xfq654efJN2H2FD7Wk4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(39860400002)(376002)(136003)(396003)(346002)(451199015)(83380400001)(86362001)(31696002)(2616005)(38100700002)(36756003)(478600001)(26005)(186003)(6506007)(6486002)(6512007)(66946007)(66476007)(5660300002)(8676002)(4326008)(316002)(6916009)(31686004)(8936002)(66556008)(41300700001)(2906002)(54906003)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Y1a9vBQ5+Tclbj5ZyYR9KKKfLU5Q?= =?utf-8?q?NrndxRyibNcFAGISH3VPXVzx7iDbGgYUtg7ksmO7e6iugoLjsu8C2N5EQe1zyHXCM?= =?utf-8?q?l5X9J33s0MHlND/5TwFxAr9ll8NaIQrnIdIpER8hycNYLqIaVM5a6itRZu+y+fI+/?= =?utf-8?q?REr4u5jo3mL92kpfIXrZx+V0qX4W6VfPo8mmjZDzijomyRTxt0WIYN9SHGZQa1RdF?= =?utf-8?q?vShnfcKxnxI05YlqVcspiwXlUj692Ubnjso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viXiflfOstRZqSmeMZ5FI83wObe?= =?utf-8?q?FAsVPEb+SMAiy7Phbx7Abv8A9FpAR6OJzgZzeQIOFigT1HWtjOHcYkPx2mFo83Wgg?= =?utf-8?q?0/9Id00p71XhqGj2SvRB5CEbvWwNsSY46LJh7aB+7vRNz+M/AnbXmKLT2IPT7y1ab?= =?utf-8?q?GS5isrQVMXRNohN3VqHu9BXixA3RG4m2gZhLSZe7dbHAi3v6HgRqDB4RNTqvbdcSy?= =?utf-8?q?PdOdzY63lBMbVgwnc3dVyXUBtQCyMmo0pTEHb1pxXiHwXmjvaWdmZ0KgffpTbP+Yf?= =?utf-8?q?+0H7Lrv4NFCSCeyhJd8EIw6UIcNoXZJ8vM3EmwbRe5SCJImQNYv+dJo9DGTtaJMTU?= =?utf-8?q?8Osv4+Te6T2iDsyM7fYk045JZC9NPdX/r29FpCmfr/HIUTAXQQ7uKUiKVYhEidOIw?= =?utf-8?q?EPIWpgzeSq6J?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8deae829-604d-404a-3840-08dae3571aa7 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2022 13:27:27.5954 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xSSeBqK2mb9DSw1Qdwl7/icqBgZYMmnEEcvXgwjjaN3mXZQf7y4iwWF52Cwu/6k31Sbmn1NGn/hCLDu8xuw+aA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8582 Drop the SH_type_none entry - there are no allocation attempts with this type, and there also shouldn't be any. Adjust the shadow_size() alternative path to match that change. Also generalize two related assertions. While there move the entire table and the respective part of the comment there to hvm.c, resulting in one less #ifdef. In the course of the movement switch to using designated initializers. Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper , although ... --- In principle the SH_type_l2h_64_shadow entry could be dropped here as well (for being a PV32-only thing), but I wasn't sure whether that would be deemed okay right here. --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -838,44 +838,11 @@ sh_validate_guest_entry(struct vcpu *v, * not contiguous in memory; functions for handling offsets into them are * defined in shadow/multi.c (shadow_l1_index() etc.) * - * This table shows the allocation behaviour of the different modes: - * - * Xen paging 64b 64b 64b - * Guest paging 32b pae 64b - * PV or HVM HVM HVM * - * Shadow paging pae pae 64b - * - * sl1 size 8k 4k 4k - * sl2 size 16k 4k 4k - * sl3 size - - 4k - * sl4 size - - 4k - * * In HVM guests, the p2m table is built out of shadow pages, and we provide * a function for the p2m management to steal pages, in max-order chunks, from * the free pool. */ -#ifdef CONFIG_HVM -const u8 sh_type_to_size[] = { - 1, /* SH_type_none */ - 2, /* SH_type_l1_32_shadow */ - 2, /* SH_type_fl1_32_shadow */ - 4, /* SH_type_l2_32_shadow */ - 1, /* SH_type_l1_pae_shadow */ - 1, /* SH_type_fl1_pae_shadow */ - 1, /* SH_type_l2_pae_shadow */ - 1, /* SH_type_l1_64_shadow */ - 1, /* SH_type_fl1_64_shadow */ - 1, /* SH_type_l2_64_shadow */ - 1, /* SH_type_l2h_64_shadow */ - 1, /* SH_type_l3_64_shadow */ - 1, /* SH_type_l4_64_shadow */ - 1, /* SH_type_p2m_table */ - 1, /* SH_type_monitor_table */ - 1 /* SH_type_oos_snapshot */ -}; -#endif - /* * Figure out the least acceptable quantity of shadow memory. * The minimum memory requirement for always being able to free up a @@ -1121,7 +1088,7 @@ mfn_t shadow_alloc(struct domain *d, unsigned int i; ASSERT(paging_locked_by_me(d)); - ASSERT(shadow_type != SH_type_none); + ASSERT(pages); perfc_incr(shadow_alloc); if ( d->arch.paging.free_pages < pages ) @@ -1201,9 +1168,9 @@ void shadow_free(struct domain *d, mfn_t perfc_incr(shadow_free); shadow_type = sp->u.sh.type; - ASSERT(shadow_type != SH_type_none); ASSERT(sp->u.sh.head || (shadow_type > SH_type_max_shadow)); pages = shadow_size(shadow_type); + ASSERT(pages); pin_list = &d->arch.paging.shadow.pinned_shadows; for ( i = 0; i < pages; i++ ) --- a/xen/arch/x86/mm/shadow/hvm.c +++ b/xen/arch/x86/mm/shadow/hvm.c @@ -33,6 +33,37 @@ #include "private.h" +/* + * This table shows the allocation behaviour of the different modes: + * + * Xen paging 64b 64b 64b + * Guest paging 32b pae 64b + * PV or HVM HVM HVM * + * Shadow paging pae pae 64b + * + * sl1 size 8k 4k 4k + * sl2 size 16k 4k 4k + * sl3 size - - 4k + * sl4 size - - 4k + */ +const uint8_t sh_type_to_size[] = { + [SH_type_l1_32_shadow] = 2, + [SH_type_fl1_32_shadow] = 2, + [SH_type_l2_32_shadow] = 4, + [SH_type_l1_pae_shadow] = 1, + [SH_type_fl1_pae_shadow] = 1, + [SH_type_l2_pae_shadow] = 1, + [SH_type_l1_64_shadow] = 1, + [SH_type_fl1_64_shadow] = 1, + [SH_type_l2_64_shadow] = 1, + [SH_type_l2h_64_shadow] = 1, + [SH_type_l3_64_shadow] = 1, + [SH_type_l4_64_shadow] = 1, + [SH_type_p2m_table] = 1, + [SH_type_monitor_table] = 1, + [SH_type_oos_snapshot] = 1, +}; + /**************************************************************************/ /* x86 emulator support for the shadow code */ --- a/xen/arch/x86/mm/shadow/private.h +++ b/xen/arch/x86/mm/shadow/private.h @@ -363,7 +363,7 @@ shadow_size(unsigned int shadow_type) return sh_type_to_size[shadow_type]; #else ASSERT(shadow_type < SH_type_unused); - return 1; + return shadow_type != SH_type_none; #endif } From patchwork Wed Dec 21 13:27:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13078776 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 371EFC4332F for ; Wed, 21 Dec 2022 13:35:12 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.467916.727000 (Exim 4.92) (envelope-from ) id 1p7zFM-0007eM-BD; Wed, 21 Dec 2022 13:35:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 467916.727000; Wed, 21 Dec 2022 13:35: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 1p7zFM-0007cz-89; Wed, 21 Dec 2022 13:35:00 +0000 Received: by outflank-mailman (input) for mailman id 467916; Wed, 21 Dec 2022 13:34: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 1p7z8P-0003Di-2s for xen-devel@lists.xenproject.org; Wed, 21 Dec 2022 13:27:49 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2079.outbound.protection.outlook.com [40.107.20.79]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 41eb22e2-8133-11ed-91b6-6bf2151ebd3b; Wed, 21 Dec 2022 14:27:46 +0100 (CET) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by DU2PR04MB8582.eurprd04.prod.outlook.com (2603:10a6:10:2d9::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Wed, 21 Dec 2022 13:27:46 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::4da2:ea8b:e71e:b8d8]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::4da2:ea8b:e71e:b8d8%4]) with mapi id 15.20.5924.016; Wed, 21 Dec 2022 13:27:46 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 41eb22e2-8133-11ed-91b6-6bf2151ebd3b ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SjJmeMp1lzrElVK3f/hVnEarT0JTe5nQ08DWZq9pq4INx0+rKIzPvsWZjU5dbvHfbHd6uDREvUqRkyaVxPHtCyqURUiziX2bJkDCpbKeO0blVlO5JqJ4r4b8zKwSdEDVcluayKo5sVKM3xkf/seCtotM6qBHZuzvSQH8+ZfP7jtuBkN7r7Bz+nNAykdXL6nbtsOXy8D/nOCBPi/KV7Y3UxFoQGVILObvbuUNmVXUZ+p/wdx3ijG3TF92E7NB3j5ZXE97qoPANJrTkvuHTj2rgoX9FbEekf10VdBw8/wAh/81LPUXqgW4y5qpmp5EBgAdQO183EvDXJnAlgh0LM2+Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KksW3pwduy9TjDQH+MFwFhDkAzwXMmeF0LkQ/h+RxKI=; b=k96KxKfNglSIJqDeAvnet79qcSSsG/EX/+NPkwWGMSSQ/JLmV9JETYjk8Zsxv4xhD44HcNkf1I1ajG+gw9ma+FADNCDjfsrdo/B2uynJ+oP83OAnTeSmWk043uBqnkpeDkNBCxKN9Gkyv+HGbqRmWV5gYBtSKA2Dk34aS44w7JVL1zQvzP4BA01OFy6Zdtu1Y6URR6F+jMj4l/+H4qJ9nscERO61SY/anCMoao2ww5690Sn77Iyz8aGDh8AMgXJg+3X+SFXC9vWeTp5h+MNthCDQiJ4y4DRYjWfGw3Z0UNdoQ1iqbQ3MT/fOSB4UO4f8lTq2YrS5cbGypwTSKdjDMQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KksW3pwduy9TjDQH+MFwFhDkAzwXMmeF0LkQ/h+RxKI=; b=0Dx23uasr8RfffKfTyWghgAyGOo2jayIL2l7NcW6STq2OLBsTSybF99frJP99t3PKvB0RkKx6AwZPYSL/UAQ2YlmCvCbbiZb3XFL5vwhrCLJcFcMj5QGjb+iPUzRcD5N07l0s3HE5zurRtrI5ykZrrgZzW9AWDTGooGVkFsD9qOM080Jl2nhMrhEWseltWWqfwx6sX6hUDVQyBkvdS2qJcfGC7gAkhESNui94WOLHnsxIVNhbDmzqHuOKKIXm98m39vAHK9l0JRNd4mq1WpeTIclRTvcSvl1nbS4rcda5kMh1jVOVTk/kBWkS4z8NyIZqjWKjUIxbkFVuQ+nOAF3Gw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Wed, 21 Dec 2022 14:27:44 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: [PATCH 7/8] x86/shadow: don't open-code copy_domain_page() Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Tim Deegan References: In-Reply-To: X-ClientProxiedBy: FR2P281CA0106.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9c::18) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|DU2PR04MB8582:EE_ X-MS-Office365-Filtering-Correlation-Id: 77352dcf-f3f6-4ae8-fe1b-08dae35725a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jK/BWdiswM6UZ5WiHbFEXiXH1BoBj8i16ZFm0oL0Kt4I1Gd4Wbf5YnThTxoZP5yuYYl2JVHcpRnLJVFmkI0nL4qjJJ0wwqMmhZ18btHRu8A9MvYy9JeMe/VaZei89xH1w8wKeJhP3i2OWNTxwX1ksbUvmWUiDrmZ64UspiPe0/mlBMn1VFKt2H1vUEbTbMImCtJbj0nNnzF/RY1NBX+8X6ebOjDgv8WqQJV+ZkewTYwbJWxat5SHOAEGGKQhnAgzFnHwTI1yASdPRgGhoF/e/dyytpNyiUpz9O+7R4OrJL/AAjYC9BTn7nsgPsFVu/PkJnSETutIpva9EDrk2AS25v+XrQvMcygPtjGoZ6W6yVaafvjvFpJo8ly+yzHM8XvPAHm/Jd4/9pvduiMIJUk3YY6696VyWLy8Or/y47qwQSRUJtykgbDFzbTzedjPojFupZGk+9Pq7ilUlZfHOryZghbw4HjzzN4xUwFDl1z3N2bE0vKQ6+xc0WrXTJqaPt7NyDZS2YhuxmlKt6NM1vND9dFzKgTqMdkIweZW4cj17AnWsRmQTMegjXzcHa+5nOgc3RNna/A/COAXxlgX3o1e2yOsPcjoPCpdGUfvnJDKBgjp1/Rvabmd9uhGmBYDU0haL/aa5P4ZRSM/rTVFS2lgbYGM/6p3p6RH8R9EfX2rqAXuomDiAjb+mKonseDB2TWBQoxwSNEjXzqSf6/I5oYOvfBmm8R82TliyXhhzAoJp4k= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(39860400002)(376002)(136003)(396003)(346002)(451199015)(86362001)(31696002)(2616005)(38100700002)(36756003)(478600001)(26005)(186003)(6506007)(6486002)(6512007)(66946007)(66476007)(5660300002)(8676002)(4326008)(316002)(6916009)(31686004)(8936002)(66556008)(41300700001)(2906002)(54906003)(4744005)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?kMdLkX6nhFcOr2Q+enMnTIa25WHn?= =?utf-8?q?X4tfYS4aKtsmV5KIGBuNUhB2PUoWxGXvnn0hpWAzZccskViHB+qoZKSliORFKSiUN?= =?utf-8?q?PrZRua05P/SFeYhoTiMpnUYZXciZVKabK5HiMcj3hx97qToSdQlMNJczrkM4zdYUk?= =?utf-8?q?K+Jsro2LUJH0jTzW4qGOoU+B2Q+1/8MfgAlK/FWDoYiihqJwN6ZMX5O+7KkGDJvkz?= =?utf-8?q?HrpMttmrml0TsAIc5LBgBzqe18X2WHqDV1bZJ3hneUMCM1xl37M3lcDmLz7fVDs0W?= =?utf-8?q?Pn6oONEhaxBe1YsKW8zYAkLUtgcOoxXh7yaPFXvBwCOGZob2otgzjkEKoIGTW5EKn?= =?utf-8?q?yDZtGdkYgMlcKttCFFJIw4m7PJTotea/Rc2I+47wh3vwkc+kTdiQezs+4bpI9WZan?= =?utf-8?q?kSmgNMaJkAkiX7a46VOZG3ACk14H5fh7iJNPCvklFMColdOWEwJnRw94b1XPjYG4b?= =?utf-8?q?urHJi9kanPv2Qw8N5CZOeR5/y21NzKow5S6bmx8rqtXbH+mrEivF2n8mMhWfp/SQq?= =?utf-8?q?GEPJiO4G2oYaDoUoVJx3RKXwY/mn4gGk/CTaXoH9LSpq/3mhwxLZRB7EiUaJ+lEfj?= =?utf-8?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zrESWZE1Xjxhki9g/j4Ht6Yv3jKYNFMXW0ieuZ3U4To?= =?utf-8?q?Okjk8f3BWTyY?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 77352dcf-f3f6-4ae8-fe1b-08dae35725a1 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2022 13:27:46.1254 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wQ3+oFk1U2LX0EMKwU+FqB2zx65c/DxH6NnsCcrJdmx6b5X/dbcjTEHNLm+9esY4toL3YXZ7gcqhOlWpYtKlDg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8582 Let's use the library-like function that we have. Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -455,7 +455,6 @@ static void _sh_resync(struct vcpu *v, m static void oos_hash_add(struct vcpu *v, mfn_t gmfn) { int i, idx, oidx, swap = 0; - void *gptr, *gsnpptr; mfn_t *oos = v->arch.paging.shadow.oos; mfn_t *oos_snapshot = v->arch.paging.shadow.oos_snapshot; struct oos_fixup *oos_fixup = v->arch.paging.shadow.oos_fixup; @@ -488,11 +487,7 @@ static void oos_hash_add(struct vcpu *v, if ( swap ) SWAP(oos_snapshot[idx], oos_snapshot[oidx]); - gptr = map_domain_page(oos[oidx]); - gsnpptr = map_domain_page(oos_snapshot[oidx]); - memcpy(gsnpptr, gptr, PAGE_SIZE); - unmap_domain_page(gptr); - unmap_domain_page(gsnpptr); + copy_domain_page(oos_snapshot[oidx], oos[oidx]); } /* Remove an MFN from the list of out-of-sync guest pagetables */ From patchwork Wed Dec 21 13:28:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13078777 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 622E2C10F1B for ; Wed, 21 Dec 2022 13:35:12 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.467912.726983 (Exim 4.92) (envelope-from ) id 1p7zFL-0007Dq-5Z; Wed, 21 Dec 2022 13:34:59 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 467912.726983; Wed, 21 Dec 2022 13:34: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 1p7zFK-0007Dd-VF; Wed, 21 Dec 2022 13:34:58 +0000 Received: by outflank-mailman (input) for mailman id 467912; Wed, 21 Dec 2022 13:34: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 1p7z8h-0003Di-6S for xen-devel@lists.xenproject.org; Wed, 21 Dec 2022 13:28:07 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2053.outbound.protection.outlook.com [40.107.13.53]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4d2938a5-8133-11ed-91b6-6bf2151ebd3b; Wed, 21 Dec 2022 14:28:05 +0100 (CET) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by DU2PR04MB8582.eurprd04.prod.outlook.com (2603:10a6:10:2d9::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Wed, 21 Dec 2022 13:28:05 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::4da2:ea8b:e71e:b8d8]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::4da2:ea8b:e71e:b8d8%4]) with mapi id 15.20.5924.016; Wed, 21 Dec 2022 13:28:05 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4d2938a5-8133-11ed-91b6-6bf2151ebd3b ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XuHha0+8JPGsDy/jCXR0tZgx98mbuyRysym/7Wz4HNcJNTL6ZCrpkBSJaZ22M3/7Wv4q17SdRO6Z6FLKoB5AeONABxgel3aau8r6VmDXNS9Ce/ZhlhZ6UeaqV2+GdEGCEopGHpo4d72m1dIBtCaqi3AdI5xpGewfMd7APYjCDs5W3hjsnNKndgyXwSUsRInpP5zPtjBqWJiMHlHzhGnL0Ehrcgub5QppLh5yonQbVOO04rvPzshVVWEov5X/A6PV2sDCujwr6uQvI8CFw+py4fSu1mTLMX3BAUDyrHfxmRaqNXNT/+vvPbrRwU9OGGuzDMZmrTJfmo9nP/1Ws60Puw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lk1AWG9IAHms14v2W1Bq9TzpL/y0E/qqZRroIHMP9pc=; b=lt3cAp84PpenpteprfJCxIPzatbm/JszTU7IY4eQ4LxxKlPXFOIQccSahjfhDiPLJwYVF1Zo0M+UN+fLvJAXE5QbRDJkX/AD/ppOXvbpF9/i6IilSSMCbHddHTHIwxXyZWAvwHZ4zskF8Ix52N4Tq15GO62eIbxIO1B/ise85Eb0DxY8XvjhVfgWH4sFIqfS1ZVSNRf0BcVTf+ruOqdc+uQsJV4qdlaBc2FjY87z9ETgeE1co9+MpranPiwFvdj+P+FZPT7vHJyH71Y4fTMO/xSUHBHEx/6zPAsAKzGDDYUg00VsedNX7m8ez/9tssBE+ubYaLLiHAcmV/g0aDS8aA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lk1AWG9IAHms14v2W1Bq9TzpL/y0E/qqZRroIHMP9pc=; b=Qj2dwaYBSvUxiC8HrGHRGiI+Dv2Mzw0gjRUKpwJEchlgQloi3qsAj44qiRSty+etTEcBcKPRz3RuxKZ+OgDePiOFMxZ6VPxyMWbLNn0O0ymLim2Nxxwo2V2cFiJpxgTp4dQJQSpliwFijSQAsXH4rzQNwoDafgOHI8b5k2uPedopPX/26J+y+mLP+BALqf8EvuG3e6XWbZiICi5Zyc+mTOkWbRttB/ctwiiiF+vmFz8tD86KeduCADcPvEvRYmhiabFdkjsdI2oRrn+Xq7DjH7wDFJ2MxyMpCV3nte6QI845shdo9p75eot7mVj8R9BAtVsg/q+SwgqdTt/0zVdr7g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <3410c8cb-57d1-dcb8-ab58-dcd3ca6748c5@suse.com> Date: Wed, 21 Dec 2022 14:28:03 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: [PATCH 8/8] x86/shadow: drop zero initialization from shadow_domain_init() Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Tim Deegan References: In-Reply-To: X-ClientProxiedBy: FR2P281CA0147.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:98::12) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|DU2PR04MB8582:EE_ X-MS-Office365-Filtering-Correlation-Id: 4459deff-4f47-4ff7-d0ba-08dae357310c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wqJf6Z0uJL/GVn/2d80KBSjafM/NMyQn0ZB/za5e0LW8kERizP8VexE1p/AzuhHJe6snxChz7wdwWrnKuU3KMxfwRVMuebJyJIvIUmX1wweBoWz2KSkk2ZOgpPtA6akUOILHoh5feOl8a80SR5Zvm+803U+gDKOYjHOIltiabeP2nzLw7E0QBkJ73/4nr7ljF+px3+a8JvIHY8BV5kR8cbeOYKIicLwnGauG4hQH/fgKWMCk4vYl5wBPOfcw3Wv6QyVXtcGG+N45XtV/87YCTldJblvHzF9/kjHvH2W4kTkf5FlyiIFCFLtQdeo5E+q6u/iVtaySgFoLFJLMyP9Es+lNUtNzx9uNz+CSIm2A4t4sGYGshO5ppgob297co+lG2X0VtRNdoiFnJeOAX9o2ohdQms259Wt6VvCY8WlXRo8e12y0SKnPphf40oaTmG0AdtiXUUaGg8NPVPtQXZ+PGRDPdHaDh9ugkHm8LBfsnMT5MWF8HqefpM9A9nHkZZn8zeR+dFkHEf4QQBiqXeeBqVa0PrASBOJ5JeqSru9n5nqFjtodyngvIRThZqaBYpTXq7MS5B24Egxi8aH2wQ6BlROXEonkQ4Mm0avZ0+mhybvPODG2oh+Zw88IEUXFFaUOuUk6DsBHMyMqiTbccdS87jhb9B/+hAHZqNeM6sWMNpvZfVm0lQbxBpACjOZs7PjXyY3UcQT3JzlcpJtV8dpq9846wn5bSDTlRRisVaYfhHk= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(39860400002)(376002)(136003)(396003)(346002)(451199015)(83380400001)(86362001)(31696002)(2616005)(38100700002)(36756003)(478600001)(26005)(186003)(6506007)(6486002)(6512007)(66946007)(66476007)(5660300002)(8676002)(4326008)(316002)(6916009)(31686004)(8936002)(66556008)(41300700001)(2906002)(54906003)(4744005)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?6xoTtIjjM/MN9LNJYDSGLfH0DlJQ?= =?utf-8?q?lNIIdLQgbzVEI5GgiX1SdE9FN1GK35IeknQCAtb3eT3GicmpVFFbBxNOMYZ6NvOsj?= =?utf-8?q?Z31QcuwzMG85y/jIqMvYA2F5PDQCDAlPAMFayb03DRVr3aBf1k6DoB1PgK1lBhwiU?= =?utf-8?q?YCZMLH6nmgSO8V1+AxVzC/NdGXACHGMaBSQjB8olGh6RsBgmLv0/0B0yI9PO+AwXd?= =?utf-8?q?qU7y0nzPTxn94lYm+fNTWMOfs+ceT2mz1xRG+0auMFpKC5OSt5dd99niUaUQ7WY7Y?= =?utf-8?q?Jvw180E03BXbItI1jeLF4iLHXpWd/nWdcOSIAoG/G37OxxhjSP4tfwkSLUWKE96P+?= =?utf-8?q?ylLDaAmeAF+0HEkdvCdZhxr9Y54ebY28hpKd3FasXj8dbV09sd1XKQrABnIVeeZFa?= =?utf-8?q?E+QL8z3u0K5HRM1KjuN3QYLx/xDjQvs8EQ5xDijt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f+Vbx4QZ0qroU?= =?utf-8?q?sMwi3cUAdcUJxA/BC9u8mU2ueOYfzJupOk95aG2GMnZVIo6MZCGBu9eptgEPja4NO?= =?utf-8?q?0JChCpmH9g0XKO65n/IGvnPCeEMYpwEoNoIGnJCQF86Rh6b0KIjrwii//5ZeYGdIG?= =?utf-8?q?9ZyF47ZZkrUS2HVPCxPTPh8kxb2vEy8dx17a6JHhz/3/Qyt/m7lfQjeDsHQPtsJKf?= =?utf-8?q?iuMqWV0cjLQ2?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4459deff-4f47-4ff7-d0ba-08dae357310c X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2022 13:28:05.2179 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: C7F7vMgztf6iwuf/INMvs6qwwP4ooHCy++4qV6O4od1Ac7fFOGSjmuZ8qqxOIPoKLkQuEodti8Fi+WS3nOE8jQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8582 There's no need for this as struct domain starts out zero-filled. Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -64,12 +64,8 @@ int shadow_domain_init(struct domain *d) d->arch.paging.update_paging_mode = shadow_update_paging_mode; -#if (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC) - d->arch.paging.shadow.oos_active = 0; -#endif #ifdef CONFIG_HVM d->arch.paging.flush_tlb = shadow_flush_tlb; - d->arch.paging.shadow.pagetable_dying_op = 0; #endif return 0;