From patchwork Wed Feb 23 15:57:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12757135 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 91301C433FE for ; Wed, 23 Feb 2022 15:58:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.277457.473960 (Exim 4.92) (envelope-from ) id 1nMu1g-00008G-TS; Wed, 23 Feb 2022 15:58:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 277457.473960; Wed, 23 Feb 2022 15:58: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 1nMu1g-000089-QM; Wed, 23 Feb 2022 15:58:00 +0000 Received: by outflank-mailman (input) for mailman id 277457; Wed, 23 Feb 2022 15:58:00 +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 1nMu1g-000083-0k for xen-devel@lists.xenproject.org; Wed, 23 Feb 2022 15:58:00 +0000 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.109.102]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 5f3ad3c3-94c1-11ec-8539-5f4723681683; Wed, 23 Feb 2022 16:57:59 +0100 (CET) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03lp2055.outbound.protection.outlook.com [104.47.9.55]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-19-SQzgJmp3NryWrBBt5thgAw-1; Wed, 23 Feb 2022 16:57:57 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by DB3PR0402MB3770.eurprd04.prod.outlook.com (2603:10a6:8:12::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.28; Wed, 23 Feb 2022 15:57:56 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65%6]) with mapi id 15.20.5017.022; Wed, 23 Feb 2022 15:57: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: 5f3ad3c3-94c1-11ec-8539-5f4723681683 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1645631878; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+aFyYLBG+wsL1hFDXE2XB3gg/hIZf4QnUWxpT0OEYsQ=; b=lHBmmS6P6PH3J3TOR17keKx2dAwglPwF4UEa0cCTOHpXOHDAdzggDSE8zvSc1H9Pg2XapF EQBZIv2n3a6XyxF4qLikjuvILXtM1s+FQesgkOK/341HjJh/kOJLzT9zjBWaiONs/06FxR NUVIoDmyMx/fU9ZjaYxL8rh3HNnD4mA= X-MC-Unique: SQzgJmp3NryWrBBt5thgAw-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jPm1eBKfko+0msEY4Srou/jjGn3g1iQ2VfaGtWZDCwZ8OoGd03wpWzyoRwdCAjk3xi1ij8+OMJonAfsg58NrpqMiPheKXIn6XQFmg6vUhuDpPp/yzrIOuXhJdalQqAZvbNbt302Z5S7qYyMelCvuF5JHNNyBHnvctQQ/XGkIeWVgfitxWwZlTeKFrmJBj7ngWIKpLsg6QiRn8i5HzIvNRkqzBJiNUOEnuJGXKArR1jgWiI7wZeNSr6QIfFg0ftEBs5RddEvGF5T4ExH7QotGcgdxys6PXLLJMS9w72zs6n6wPblbdJYtS/NJs43xhamHaYydDaaB2WxB5MA+FgGGxQ== 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=+aFyYLBG+wsL1hFDXE2XB3gg/hIZf4QnUWxpT0OEYsQ=; b=mS97rn069Ede95/TcGHwN8fy7CC446CWe4n7tl+YDPUS9oHiPpqbqLdtsmMGRhvN02RGNJI9s8ZZyyujHuzmTpUfcBTSwk9HWOpeRZ+NmW5oIkXYCu54K/B7Y7vsM+UXFzapCe5+PKP+CRhpmy7iQ01fdJ/BMhlTIvMkLmKfrq/40VoKQUDhdVk+KnjKc9OKfZ4m7vwzsIGvvJ/9AmP+/CAO5S5+J6/5525U6sMi9abYnQ+ERd8e8f9qY/8QUr4nJxTtbQotzqxdu78Jl8a8cvU5NdpYdBybEWyAREJAQqU1T38J0mbMvPdB2C2LSrQR/OtoZf+XPJXEJqdPjoWfFA== 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 Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <2353ed37-e62a-4e34-7442-0638bb92dc2c@suse.com> Date: Wed, 23 Feb 2022 16:57:53 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH v2 01/14] x86/P2M: rename p2m_remove_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 References: In-Reply-To: X-ClientProxiedBy: AS9PR04CA0103.eurprd04.prod.outlook.com (2603:10a6:20b:50e::14) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5f9a0e0e-c011-4b7e-c8c2-08d9f6e541c5 X-MS-TrafficTypeDiagnostic: DB3PR0402MB3770:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7G/HNfygm3MNpj2kD5dxbOsbERLa9Y/VF2MB8MqzFwu6msYEnUReAXXg6dAUy24BrVwcc9uE/IhATLpWJcSYc/ixgIouTZmV5/9F09sN3Ps8PMxjniBD49jGi4ZpCg0jecc0MvbR3MzhreH3BZNTkL37kQ8fvhVYWtxC/fE+VAkQp4h2b5KJau0bDt8vqGAP//D6ALTQlAVojjP63oUub581AD1UUPnsOyPqfEfJEjpxG/1An0JyoG/MAwxYJCgiIWExnR9Hj/l6zxBsYQoQiR8eZSvmhtfjudVsbljeVwve3BSLZoshBsE47tL/yx1NCrCdNPH0E1HUUjLStwtSFadI14TVEtg82jK/oI+3opcuskeevCcCV+FMg++sIn2xI0fv9K7auQugxKWonZacPEc4o3AsJ8i4AFRVTAykhNJS7Zwq3C4kh/AoVMSeRsC4h1Iehh7gujIE4mrMZmpxiqq/HRbW1+1gzXY1gXYb1rdJJHHliNAD7vuXqkXJFskKBFOlQJxBiDeERJmEkUEr2F125JMM5DKumS2rtzHRIy19jR3XaVfPv8NjyWtnxzefzwO09KcWNB3gWv2/S55yGjdeBxQX40i3cjaOAfx6YfnpaBEaJrw2F38WA4s1R6aY4OS3oFiEJDPYyDVcG73APKKru8NEYwIXkWS4Tq2hteqfJdIh1LGvXx3SkT27uPfFEexzXzWKn55BJqjD9uVjp5tut80SNuv5H/K66xP99rbX12zttcTO3dzCOQwykogq X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(66476007)(66556008)(66946007)(4326008)(8676002)(8936002)(36756003)(6506007)(31686004)(6512007)(316002)(6486002)(5660300002)(6916009)(54906003)(31696002)(6666004)(508600001)(86362001)(2906002)(2616005)(83380400001)(26005)(38100700002)(186003)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?fWpeLEhbSx4IBGifV2/2dZCYlG4F?= =?utf-8?q?QKiOLVu0IIHEmcgcg5dss8HPfbUBGyVQwBRjCnMkxEyVVx9VbfJTn//AgCzi4C4pX?= =?utf-8?q?ZhwzVfDmnLDzbfMgqITEQbi557EJRtT+Y6fkuxq4O3NG6Nc+Aa/VZbnk0PAuVJTB4?= =?utf-8?q?0aldx/BACg3xfFUSD8PLLr+RnLiGdQPKyxwkGSVja0YCDOvj04IPdmDwufZSMx/w8?= =?utf-8?q?ZZp3OofEsnrhdrz6b5kvU/BKjX/aJkKK0Cs58bXBwgEE5ly3HXTztXN5dwu+61yUI?= =?utf-8?q?21qXAjJrJhdUuZOUPV6sKwhgye/hC86hfNc2M3NTEjBIUWcps/fkfgfmy7xyv7vVd?= =?utf-8?q?PerwBelsUIzti8YyERphyDW0k4XVJHq+FMDh5+27KioRQTOXMer9vdSVs8LkLQKU2?= =?utf-8?q?9EwcFhroVbxHm23gsRxX2mqvqbmQ5tqqvvpYQxXwRTOlF3GMNj7i3+QCsUTM5gh5T?= =?utf-8?q?VbL+NyLkokBam2TxhTLZoSMcCYEJp7sMrmc2GDE/viCRNKJx37at7BQh2GikP2hmH?= =?utf-8?q?DqCNoiLqkFCRskcNuBhnkKpXhkDav3aqF3KNnfQrZfDOej2p6yyO6uLBIZoZqfy7a?= =?utf-8?q?1A5WRAJX0fmjpTSqYkISthBkXMTFeaDJLZqQcE+3o677KIpZr3Y2WNWG8RhUHJtlm?= =?utf-8?q?yG4gO6RopCUAGfwX4/V0oUsuH//ERuMJ7D2FOjScuqqszueR3UjptY6L1sBWOGU0s?= =?utf-8?q?Bk1/PncKmVfkAmDRBIjd7jQthYFoEy7L1gy5rjeS40YJVFXB1UeYEjfI9f69Yrfin?= =?utf-8?q?QkWSK0qW4oUy7jEJmgP5LhXVsTUhxJvCywlKTXSBsQ6KEIqPQ638keISBN18ybaPB?= =?utf-8?q?4LFhYxgiQ9wjXd+pPGnoIGERGtSfEqTtwPUhLFSyJuUv0LHh1Ce6G+HsF6EmPesiT?= =?utf-8?q?414mJxp+KHVesoP4gWusm29vjCci5wce4eE8Q0Ue4Lt44eDFL+by/KJeF8eZrxmHW?= =?utf-8?q?hnTWpt41dPmvO+Xt7Ark8SejSbGNLNhDjog39xJBrISzVc6omy8wk6K8UziLk/lbA?= =?utf-8?q?+8plMHJHMZxkoO++eQ7VjAoLl8SGA+Qfv0NFYZ6z76YvT341IHWemPkZa+JdZqQgf?= =?utf-8?q?gL70HAzmPd+GhkgjW9davoqFGTYldY9SwxByBLMsPLI20A6gR8iXy8fflxgvWar4O?= =?utf-8?q?J+TJziHsARNK6/UykdLTwAXWY51aIQkoshVlBE8lg26h9G0QUIPZeg7FEwLJ90AmH?= =?utf-8?q?lLIgVOVPrOZ8KmiyzgCdjaeyrzUQOsXbZCiHLolnqL7TSV8/fmegdr3O00x0and26?= =?utf-8?q?bnNQGjFj0Mt34FKNMevU3eRzp5cV7prKj8QPsf9GuDZLEcuGVjdV8Re0kpG7nBP7a?= =?utf-8?q?uwg8HDPocgdbas1P3YVh8+4NHhdD0YpPC1sboZ8bLvWewlnP65cM8jUufmbL9NvJY?= =?utf-8?q?y68PQ4fPOwqpP57nSy99ZJtjcr3IzB+hpE9UADZ81pTzcHcKjRuJjsC53k72wk60B?= =?utf-8?q?psYSqlYAk2xqHvoYEV/ZUOh6aHqA3DWniGwSd/xg3c+qaF+tTHHwE/DOOJ9hslCTU?= =?utf-8?q?nm3/A2K7vdjHA+r/UfjRXkVGJTuT1prCY8N08vJMOnRYKlKpN/ug//o=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f9a0e0e-c011-4b7e-c8c2-08d9f6e541c5 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2022 15:57:56.2310 (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: 66J6X4yg94OJC5Sx0LWHMCdwjgOUe/FMe+ZfB2cL5yAt7c3LPuni4lZvViKy2ZOvRSl/rU3lBjMzwl4jUQg24w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0402MB3770 This is in preparation to re-using the original name. Signed-off-by: Jan Beulich Reviewed-by: George Dunlap --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -788,8 +788,8 @@ void p2m_final_teardown(struct domain *d #ifdef CONFIG_HVM static int __must_check -p2m_remove_page(struct p2m_domain *p2m, gfn_t gfn, mfn_t mfn, - unsigned int page_order) +p2m_remove_entry(struct p2m_domain *p2m, gfn_t gfn, mfn_t mfn, + unsigned int page_order) { unsigned long i; p2m_type_t t; @@ -861,7 +861,7 @@ guest_physmap_remove_page(struct domain return 0; gfn_lock(p2m, gfn, page_order); - rc = p2m_remove_page(p2m, gfn, mfn, page_order); + rc = p2m_remove_entry(p2m, gfn, mfn, page_order); gfn_unlock(p2m, gfn, page_order); return rc; @@ -1034,7 +1034,7 @@ guest_physmap_add_entry(struct domain *d P2M_DEBUG("old gfn=%#lx -> mfn %#lx\n", gfn_x(ogfn) , mfn_x(omfn)); if ( mfn_eq(omfn, mfn_add(mfn, i)) && - (rc = p2m_remove_page(p2m, ogfn, omfn, 0)) ) + (rc = p2m_remove_entry(p2m, ogfn, omfn, 0)) ) goto out; } } @@ -2444,7 +2444,7 @@ int p2m_change_altp2m_gfn(struct domain { mfn = ap2m->get_entry(ap2m, old_gfn, &t, &a, 0, NULL, NULL); rc = mfn_valid(mfn) - ? p2m_remove_page(ap2m, old_gfn, mfn, PAGE_ORDER_4K) + ? p2m_remove_entry(ap2m, old_gfn, mfn, PAGE_ORDER_4K) : 0; goto out; } From patchwork Wed Feb 23 15:58: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: 12757136 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 DA3B5C433EF for ; Wed, 23 Feb 2022 15:58:39 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.277462.473971 (Exim 4.92) (envelope-from ) id 1nMu28-0000fr-9b; Wed, 23 Feb 2022 15:58:28 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 277462.473971; Wed, 23 Feb 2022 15:58:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nMu28-0000fk-5v; Wed, 23 Feb 2022 15:58:28 +0000 Received: by outflank-mailman (input) for mailman id 277462; Wed, 23 Feb 2022 15:58:27 +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 1nMu26-000083-UU for xen-devel@lists.xenproject.org; Wed, 23 Feb 2022 15:58:27 +0000 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.109.102]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 6f4c82fc-94c1-11ec-8539-5f4723681683; Wed, 23 Feb 2022 16:58:26 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2108.outbound.protection.outlook.com [104.47.17.108]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-3-Zm6pYrUGPle-SJIaBPcs8A-1; Wed, 23 Feb 2022 16:58:24 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR0401MB2479.eurprd04.prod.outlook.com (2603:10a6:800:53::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.22; Wed, 23 Feb 2022 15:58:22 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65%6]) with mapi id 15.20.5017.022; Wed, 23 Feb 2022 15:58: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: 6f4c82fc-94c1-11ec-8539-5f4723681683 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1645631905; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UcksslQkFnjukx7/qYD/769exeJYXe3uEWi/y4UhXP8=; b=I2WVD+bKt7OphxsKNTrcGgt55gQGf6RyzwBg1ZQYLgTmWG73jqj9/aZFl0PyrfKfK/D3gZ s1vMlskfNEV+F7q2x4SJCeO0AVaakiD77DgCXHdCjlaNnZvSUDoMjr4vpXQ38ZScDkZ+wO P3O0P6DMr6LMWpSPxsN/8GUeeCl/wiA= X-MC-Unique: Zm6pYrUGPle-SJIaBPcs8A-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OTkmp3eUsu+niUJ8vaY04/O94scbFhQpwOAkTC0uN1TE62IECYiLvpxkwJyXdYogd99jnmBbzCuZBrc0Pzh0XI6o0/iYgFRp1Bt28swjIysef2Ex9C+/crNZ6MRiTEtSveXDe0qnH8QSLiQeszoH3jQ5GuC/JbUtR+tjmRGTBjTWrkxqBsADzC/5iy0EGGK+Ued//VvVERJeDi6oprcuavTWrPa133HU6MZ0GCjdGC6eWNr7k/Ep0qFz9Exm7RPlQVxwCx/HZCT2XjH0RhsY1pTqxUXY14fdk43P+vHz0fVSSvHKoSCJPcOHghGc5QNgcoK0l83ro6ci+tVVydOmAA== 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=UcksslQkFnjukx7/qYD/769exeJYXe3uEWi/y4UhXP8=; b=JIUGLUacf0gy7AXabk3vQv2+mrJ1S3UyApcqdAZaiSfzRYopSPsinic9iVzrNT49hpSDNNOoWNg5WFPchRY7Oa1Mqlt+EKdxfHak1kTWmp+jaOcCDdp3axrAzG9UTLS6ySumb9KybjyFpww44Hnzjdsqa8ktM1wAkSgAI39BJimaYUob1V8PsrvZTmtACcVtJSg+gB6PODoD7YnY9jEM46IEN4Z+fs4C4T6VCv7A3LsWmvQRfldiNOT8GNwGll7V6NDDdRgIfDWhy0eZZoLAYC0op+Pgluovg4De45sRWLCm1JVIEuOMFXt0t1loWo0UEFfgA0MWOvt2tjIM+HpmKA== 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 Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Wed, 23 Feb 2022 16:58:19 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH v2 02/14] x86/P2M: introduce p2m_{add,remove}_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 References: In-Reply-To: X-ClientProxiedBy: AS9PR04CA0087.eurprd04.prod.outlook.com (2603:10a6:20b:50e::9) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b2401632-ba8f-4e18-c1d4-08d9f6e550f3 X-MS-TrafficTypeDiagnostic: VI1PR0401MB2479:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yjw9wy2M5E9JsbLrU4e+tchVyP22l5Ka1irAt6Qzpo3cFATgJqMy2gaJpQDXvEQ01Kb42wqkpElDtuzHX9fOx28YUd+eJ2w6/JUJh3vQhC4HTkR0MBUncCucAiulK3GY6Fa2u9yunSB75aQyKNAcub2bwEw2V7s7KcGzfQ/N2Tk+2LHWzYZG60UtEAnnHmzp05jmjcwzcVZ9QvT5cPbIUDkeu+/aQ/9vLPEPAPZSTYsm2r4FNAwFBR1CJM6dmwYgazL1Isg79D/bUmiUUdtO+T3rn4oWX+x3aUbtgI1l/N+jMFvWAwymKLx4C8WNNT8w3tdc8qO6mSt2M43zX3OkoukUnCbAIUmYgupNOpayIb4mIMLo/CVDh9hsSrxEBx1w99vJu7+Sj6iERnc+l20mQjk2GRBhH3MtQnBMzgaaxqAZXLbzxjPmxNN2gXpmKYz00cTVa6dsgAn10h6WdTwot7UCZ4Kd++0ulcTR7qRG15B0YbXJMUGDu0H5atCYAihW8eEkDCBbNRShwYyDyALGTN0L5J7O37qY+Vve4pUiN4CLd2rUEDfUI+b6WySY7DLwRmwZDWCComYehgIC+z+BnYKBXx/qd9GwJrmpdsQYiTJ/3NSgfXbj5GNzEqiY4tKTcnKXSL/Fk1uTY8p1ZuXJBhP0yCy5bQwYQ2DbsbWnOaHVkeCOoB1Q89xtwto5rxwVS7tYgaByo1GF1xgDx23TRkwMejxutTET3X7Z0hdoyiD5I/s2hnYjGgKi6hnsfMuA X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(66476007)(66556008)(8676002)(4326008)(26005)(66946007)(186003)(6512007)(2616005)(2906002)(6486002)(508600001)(6506007)(31686004)(316002)(8936002)(6916009)(31696002)(86362001)(38100700002)(5660300002)(83380400001)(54906003)(36756003)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?NkiHsoMozD6ne+/uWQq6pxM/n7h9?= =?utf-8?q?kDMdaJQBCtbA5pNY8/aoJE+CnNpwMMMPGPOD+z+J6MXMseo9Ti5JDNrF3etzZzwNY?= =?utf-8?q?qzoqMNUkt3H4wXmrNbCg5/Z0BAOS6gbJIdGpv5s/yPz5kuhYCv3gqPsgNIFa4GsAr?= =?utf-8?q?LlH9P/6VIwQD1BG1PfMAPikuXSHsi8BdNBc/YAaH0RqFoYfy/2NENxO5/3KecLxUS?= =?utf-8?q?rlDJDzR2VmxKiYCxivmgwJru5NmEQ81rZL/x/Twy+5PyTJjCmm6/hRhkcR/qg7t/L?= =?utf-8?q?PDp8EHSnSHSc5VWV/EhVvUKBxt2x+ylum5claev2xQMvGsmPZCtZDGP9gBWu0gpyI?= =?utf-8?q?dF+nYGHrcB5vBXb60CcRwwum/QXWD95fTQqAtYrc/Qxo+isjhscM+PPH+iVdfOE8z?= =?utf-8?q?4021IE4EKpylt15xp0Fv4ltH0BWYZ6xdIWd/wfe6NSRK6LhVA3gQExVGosSetb757?= =?utf-8?q?vK2M/ZOKq5YPBzpqAZF96E9tx3RB08rufaoQ8AEZGIlK22Jhp/gJtRRwNSgkQBJB7?= =?utf-8?q?KjOJ76gbAtasVcEAztgxCXGldWp51a580BxT2IgG6InNAieX+uzjk/YlCXJqdLozn?= =?utf-8?q?b3TeC79Sc4v25yRBK0LTzMzykV8D/d43B9xZTBBocfbZaPage0i46w458AdRyp8jI?= =?utf-8?q?dKUQsG2+cRkpdKcYLCSXEKNizzj8EtAHMu5yAPIPKVZF3HZTrTy+CDaQ1O93FHM8k?= =?utf-8?q?Vp2omiRSWz8XZBxyOibUF98t+IjtuXO6UbXYMWP78vFoHAmd2YHE4rqcympfX943O?= =?utf-8?q?5qyh9d4cGYd6ikuSPyRx09e85kI8lh3zndKAzKGlkUi79kO8l+ZZr6C1R/vpTQyMG?= =?utf-8?q?YUfRh366r94eTgasI+QHiuXhyWU/O1XPogJ6ExXu8iBA3iidNBPr3zZRHLhz6ls44?= =?utf-8?q?vy7ZZlRauF+WnlixC+yrIDORGscyQcLSUL1rjTPiF9NQPCrtSdeBH+PNdAvw/jWJ2?= =?utf-8?q?2YwfjGHl1is36fB39jvsDhRyWTTkO8Mw7jnRoXytz8gVeenyJkmucOWaM1Q0f2fLa?= =?utf-8?q?ptOlGrpL//9q/Wjo7Cp1yfOsiCN9lGf1EoXoKukqYLIsoHBaZmvizgiAMygPnc9s9?= =?utf-8?q?3qC5ZfJRubbqTnzPsHCCN0KR2/fPCrD/Tz2yHEtCoza4AOFftV5OvIyhsUNPMZY8G?= =?utf-8?q?l9vCrXF+l+VwVia2f7fm8269qzJHuCXK1GmtLP91GKXFX4rn8tiQmJQHBWXfNrP2Y?= =?utf-8?q?l0x4NqFrIHO6ITa0r8MNROxtOeTrdF29FN/Ae/PiOFWt9+bKz1xfqn2Uta68c4uHm?= =?utf-8?q?++OtsWJ1mGoz0y7uu1u/g2bkBSJlLNt+mtPgRx6YDgoSwwl0cYuNMtrpeEd5rL0mq?= =?utf-8?q?jZkpt1vh96zacfiqpHHLe+qjFkueESql6+TXVJJvl8eetHwmhFDMoIxP9xfP0ykJJ?= =?utf-8?q?dKtfqoTGp6hYSJnl2AyyTBgoH82q7jqtEdl5sLip6ABR8qZVcjF+Pl6av0Xey2HCL?= =?utf-8?q?iyc7tU9iLwsBWbiLx4dYSQ75IjYS4WwP5v34A943Aun4l+z962scHAPh/LpVCFsgS?= =?utf-8?q?Lo2mlpx/FQTjxfUMkGlBebxUgSV6NGSNhh6Xv8EJIVBcZViPnZLLKRo=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: b2401632-ba8f-4e18-c1d4-08d9f6e550f3 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2022 15:58:21.8231 (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: s+NkDB1vovupwkMp3XZTRieGTc5miDaMCztCt6vo0rypIgUOPBUNwGMEss4IyPV9dYprXudVp03a89lqTB5ttA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2479 Rename guest_physmap_add_entry() to p2m_add_page(); make guest_physmap_remove_page() a trivial wrapper around p2m_remove_page(). This way callers can use suitable pairs of functions (previously violated by hvm/grant_table.c). In HVM-specific code further avoid going through the guest_physmap_*() layer, and instead use the two new/renamed functions directly. Ultimately the goal is to have guest_physmap_...() functions cover all types of guests, but p2m_...() dealing only with translated ones. Signed-off-by: Jan Beulich Reviewed-by: Paul Durrant Reviewed-by: George Dunlap --- v2: Re-base. Adjust description. --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -173,8 +173,7 @@ static int __init pvh_populate_memory_ra continue; } - rc = guest_physmap_add_page(d, _gfn(start), page_to_mfn(page), - order); + rc = p2m_add_page(d, _gfn(start), page_to_mfn(page), order, p2m_ram_rw); if ( rc != 0 ) { printk("Failed to populate memory: [%#lx,%#lx): %d\n", --- a/xen/arch/x86/hvm/grant_table.c +++ b/xen/arch/x86/hvm/grant_table.c @@ -39,9 +39,8 @@ int create_grant_p2m_mapping(uint64_t ad p2mt = p2m_grant_map_ro; else p2mt = p2m_grant_map_rw; - rc = guest_physmap_add_entry(current->domain, - _gfn(addr >> PAGE_SHIFT), - frame, PAGE_ORDER_4K, p2mt); + rc = p2m_add_page(current->domain, _gfn(addr >> PAGE_SHIFT), + frame, PAGE_ORDER_4K, p2mt); if ( rc ) return GNTST_general_error; else @@ -68,7 +67,7 @@ int replace_grant_p2m_mapping(uint64_t a type, mfn_x(old_mfn), mfn_x(frame)); return GNTST_general_error; } - if ( guest_physmap_remove_page(d, _gfn(gfn), frame, PAGE_ORDER_4K) ) + if ( p2m_remove_page(d, _gfn(gfn), frame, PAGE_ORDER_4K) ) { put_gfn(d, gfn); return GNTST_general_error; --- a/xen/arch/x86/hvm/ioreq.c +++ b/xen/arch/x86/hvm/ioreq.c @@ -188,8 +188,7 @@ static void hvm_remove_ioreq_gfn(struct if ( gfn_eq(iorp->gfn, INVALID_GFN) ) return; - if ( guest_physmap_remove_page(d, iorp->gfn, - page_to_mfn(iorp->page), 0) ) + if ( p2m_remove_page(d, iorp->gfn, page_to_mfn(iorp->page), 0) ) domain_crash(d); clear_page(iorp->va); } @@ -205,8 +204,7 @@ static int hvm_add_ioreq_gfn(struct iore clear_page(iorp->va); - rc = guest_physmap_add_page(d, iorp->gfn, - page_to_mfn(iorp->page), 0); + rc = p2m_add_page(d, iorp->gfn, page_to_mfn(iorp->page), 0, p2m_ram_rw); if ( rc == 0 ) paging_mark_pfn_dirty(d, _pfn(gfn_x(iorp->gfn))); --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -850,15 +850,17 @@ p2m_remove_entry(struct p2m_domain *p2m, } int -guest_physmap_remove_page(struct domain *d, gfn_t gfn, - mfn_t mfn, unsigned int page_order) +p2m_remove_page(struct domain *d, gfn_t gfn, mfn_t mfn, + unsigned int page_order) { struct p2m_domain *p2m = p2m_get_hostp2m(d); int rc; - /* IOMMU for PV guests is handled in get_page_type() and put_page(). */ if ( !paging_mode_translate(d) ) - return 0; + { + ASSERT_UNREACHABLE(); + return -EPERM; + } gfn_lock(p2m, gfn, page_order); rc = p2m_remove_entry(p2m, gfn, mfn, page_order); @@ -867,6 +869,17 @@ guest_physmap_remove_page(struct domain return rc; } +int +guest_physmap_remove_page(struct domain *d, gfn_t gfn, + mfn_t mfn, unsigned int page_order) +{ + /* IOMMU for PV guests is handled in get_page_type() and put_page(). */ + if ( !paging_mode_translate(d) ) + return 0; + + return p2m_remove_page(d, gfn, mfn, page_order); +} + #endif /* CONFIG_HVM */ int @@ -905,14 +918,14 @@ guest_physmap_add_page(struct domain *d, return 0; } - return guest_physmap_add_entry(d, gfn, mfn, page_order, p2m_ram_rw); + return p2m_add_page(d, gfn, mfn, page_order, p2m_ram_rw); } #ifdef CONFIG_HVM int -guest_physmap_add_entry(struct domain *d, gfn_t gfn, mfn_t mfn, - unsigned int page_order, p2m_type_t t) +p2m_add_page(struct domain *d, gfn_t gfn, mfn_t mfn, + unsigned int page_order, p2m_type_t t) { struct p2m_domain *p2m = p2m_get_hostp2m(d); unsigned long i; @@ -2724,7 +2737,7 @@ static int p2m_add_foreign(struct domain { if ( is_special_page(mfn_to_page(prev_mfn)) ) /* Special pages are simply unhooked from this phys slot */ - rc = guest_physmap_remove_page(tdom, _gfn(gpfn), prev_mfn, 0); + rc = p2m_remove_page(tdom, _gfn(gpfn), prev_mfn, 0); else /* Normal domain memory is freed, to avoid leaking memory. */ rc = guest_remove_page(tdom, gpfn); @@ -2732,7 +2745,7 @@ static int p2m_add_foreign(struct domain goto put_both; } /* - * Create the new mapping. Can't use guest_physmap_add_page() because it + * Create the new mapping. Can't use p2m_add_page() because it * will update the m2p table which will result in mfn -> gpfn of dom0 * and not fgfn of domU. */ @@ -2846,7 +2859,7 @@ int xenmem_add_to_physmap_one( { if ( is_special_page(mfn_to_page(prev_mfn)) ) /* Special pages are simply unhooked from this phys slot. */ - rc = guest_physmap_remove_page(d, gpfn, prev_mfn, PAGE_ORDER_4K); + rc = p2m_remove_page(d, gpfn, prev_mfn, PAGE_ORDER_4K); else if ( !mfn_eq(mfn, prev_mfn) ) /* Normal domain memory is freed, to avoid leaking memory. */ rc = guest_remove_page(d, gfn_x(gpfn)); @@ -2854,11 +2867,11 @@ int xenmem_add_to_physmap_one( /* Unmap from old location, if any. */ if ( !rc && old_gpfn != INVALID_M2P_ENTRY && !gfn_eq(_gfn(old_gpfn), gpfn) ) - rc = guest_physmap_remove_page(d, _gfn(old_gpfn), mfn, PAGE_ORDER_4K); + rc = p2m_remove_page(d, _gfn(old_gpfn), mfn, PAGE_ORDER_4K); /* Map at new location. */ if ( !rc ) - rc = guest_physmap_add_page(d, gpfn, mfn, PAGE_ORDER_4K); + rc = p2m_add_page(d, gpfn, mfn, PAGE_ORDER_4K, p2m_ram_rw); put_all: put_gfn(d, gfn_x(gpfn)); --- a/xen/arch/x86/include/asm/p2m.h +++ b/xen/arch/x86/include/asm/p2m.h @@ -577,10 +577,11 @@ int p2m_alloc_table(struct p2m_domain *p void p2m_teardown(struct p2m_domain *p2m); void p2m_final_teardown(struct domain *d); -/* Add a page to a domain's p2m table */ -int guest_physmap_add_entry(struct domain *d, gfn_t gfn, - mfn_t mfn, unsigned int page_order, - p2m_type_t t); +/* Add/remove a page to/from a domain's p2m table. */ +int p2m_add_page(struct domain *d, gfn_t gfn, mfn_t mfn, + unsigned int page_order, p2m_type_t t); +int p2m_remove_page(struct domain *d, gfn_t gfn, mfn_t mfn, + unsigned int page_order); /* Untyped version for RAM only, for compatibility and PV. */ int __must_check guest_physmap_add_page(struct domain *d, gfn_t gfn, mfn_t mfn, From patchwork Wed Feb 23 15:58: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: 12757137 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 6481CC433EF for ; Wed, 23 Feb 2022 15:59:06 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.277470.473982 (Exim 4.92) (envelope-from ) id 1nMu2Y-0001Fw-I1; Wed, 23 Feb 2022 15:58:54 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 277470.473982; Wed, 23 Feb 2022 15:58:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nMu2Y-0001Fp-EE; Wed, 23 Feb 2022 15:58:54 +0000 Received: by outflank-mailman (input) for mailman id 277470; Wed, 23 Feb 2022 15:58:52 +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 1nMu2W-000083-JD for xen-devel@lists.xenproject.org; Wed, 23 Feb 2022 15:58:52 +0000 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.109.102]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7e8ea6a3-94c1-11ec-8539-5f4723681683; Wed, 23 Feb 2022 16:58:51 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2111.outbound.protection.outlook.com [104.47.17.111]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-29-zU7gkAc4PgqNKoLYXq-eyA-1; Wed, 23 Feb 2022 16:58:50 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR0401MB2479.eurprd04.prod.outlook.com (2603:10a6:800:53::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.22; Wed, 23 Feb 2022 15:58:45 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65%6]) with mapi id 15.20.5017.022; Wed, 23 Feb 2022 15:58:45 +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: 7e8ea6a3-94c1-11ec-8539-5f4723681683 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1645631931; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Absf33xo61iOtxqb/+8Eu6L66vlBNlW2G4hE8J6Sq7o=; b=PqAPjUGtAceYdQRviw961lJiU11Jf6C59vrit+3rMXZCvtHHLDh+N5VYTeQ/epH2RBrAGX JbOn1+u/US+iLSXP/7k+9ANySfeu5S+YVu5u8QPumfkXqCGof0WkmP3l/Z/OKGqoNls7ax Gky+QAtvV47fFQHOVrA7U35x6SbxsGk= X-MC-Unique: zU7gkAc4PgqNKoLYXq-eyA-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WGvqI8lY7T3PBBTL5P2rrn9cyf77+7GvTxPiIbgNQMErHX/MCsgB0+dFKhzvdwzRy+03eQs7zGlyTgwKHKAMAak8bAUVimKA/EZGEDz+8IZTC9vqkbmdjFgPslcR6e27Ms+j0uzo8J+HuYV+9qqb9QtGJ+PlwtIdXl1tObNpTKz3BvuzN+CbrVsYWcPG0um6efkIIJjcNVfw9SK42ilWE6OcbetAeAdAMHO+ex63PAjzFQ98+Cj+l80pgQbCHjSjaVcRunk5zAGAwqJq7cUCW+x0+livy+jowYYoBhm0VFBosu68sZErUCuw+hrXFSmWHDodJ+qhEK5A8+9P65ETPw== 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=Absf33xo61iOtxqb/+8Eu6L66vlBNlW2G4hE8J6Sq7o=; b=I8D7EbBgxBaBfszSBub3/rkec2CUJV9chcxyvXDV9FynTk0ZHj2zFsLipI0kBG3PHVQI67GmObZ74aAMvaneMbMDTqsa3q1PmQN61cwltyCT3dukz98deSmZnnSc28H51QbUMxglHgaKDiqJtUlZ8Tx6hBUZ92wmBdEoJ3AlzS1veQ8ibGzUC4+E9PtW9Vj0Zlmy8JD5/E0a+s6LUWDloYbgKoJ2k7WVVD/CyNp+RXZnwOKBTnQGF8XjkfAiUpZtA17ZEfK0d9j7mNksIbgaGqwWNrVjnU0owYQrVq36xjQAdbL0Z2ikGPfoq4laNhS/QuOxdWEUNa0F/a0OHT2w4g== 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 Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Wed, 23 Feb 2022 16:58:44 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH v2 03/14] x86/mm: move guest_physmap_{add,remove}_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 References: In-Reply-To: X-ClientProxiedBy: AS9PR06CA0355.eurprd06.prod.outlook.com (2603:10a6:20b:466::22) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e5795b0e-57da-4f2b-a191-08d9f6e55f41 X-MS-TrafficTypeDiagnostic: VI1PR0401MB2479:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WABS4NcpsqIOvX/u/RMoLxxGAwmzGlIny8Vn/d0YWRwPz9fcFZKcvOquP7EeXByTDwIuK7rqGVb/UXmDyZkw5cws7p59BikH8Jdrl3hNASQAZstsGRj1bz8r0ypkhmlmwqdDWrZoaHo2s7C58K7O5WCJUyIcBNeksZCiwOw2cEF8D6WFpfEkAQyxCBocLuXhqSWgf9YViTduPpB5x3uqXvt5chlgeBkWdxSXfO6ymqoT+TCAzxJv3ZOn0Xa7RaSvF4QTntz8WfAzmdVMG7oXxjeQKylAkROX53kF7hq7q7BEHW/8iAX7MGpKVyvUUatmuUfGCXtcQAiSp7+fyOXRMWf3v1y5xGHWFr7qx/zVAcHaP9Q4yUJpropajWY7es5doa6X89IRZRji1ILVKTeFrbW4nXWHSkpaQ73X5n06lt85ZtjKaG79+Td9+1yTVd3Fz+8aeI4I2JEsRekhs9BFC86IVz1AwOuCKtdqi4FGt4zWRwzgxKDX8xDfQFOaSbihkgBJe5C2ATF/Bg+Xu5JGqcgNZl2bgyqaMEoleJmuBmPgfqB8m3n2VsLQdNEYPz/4EZUXTNBE9JVvwWEkqGgXSMuvXGuTrCyBJA9dImSrsQHSz7Qkm00LIQdnL63VO1Z2arhpq7h3Q8F8/bz/0tIVXngQhTm8K58+wZUMJIAM/BaQFd50+uzzq7l2BvR1TEUBpe+vlcbxa2b4iX3F+2+JlsUCgsY6p55wzk9C2ww9/bCmCTnTo9nQg8CJEnPnrN1+XllIDU6j2tq3zOF1wMxScsFKmonlpIHUSZ+OFbmsTVPAGcPaeSEnf5tdUfiM762oieo/HnvNr0rgc7x2sXeXwA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(66476007)(66556008)(8676002)(4326008)(26005)(66946007)(186003)(6512007)(2616005)(2906002)(6486002)(508600001)(6506007)(31686004)(316002)(8936002)(6916009)(31696002)(86362001)(38100700002)(5660300002)(83380400001)(54906003)(36756003)(2004002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?UbbbIwSURfMC/D0yoWndBPI+CCnf?= =?utf-8?q?IsaE4EGXe3Ggr1D4MZa7SxkfAsY8Y5lPMrz9AjnhV3v0NI5K00bmFn1oZU/GQI/I4?= =?utf-8?q?0BEjzrI2KDXeGg4GRgM6YekfiR9TFTyWLBAuocSMlkir+loEQlegpd2nUAQeu5g7r?= =?utf-8?q?JzOOmmg8YxDYu9eybAgMqAbnGhDkO/wIImxqiCRIhB3LFrqVA+b12En9SL0pPDwZB?= =?utf-8?q?Mv8CbLlWjX2yGfJpufhr9D5KfSG9trxbTbfe/1MIOzcC2rzEe5VaL1Bs9DmHXLfuy?= =?utf-8?q?Y2DUFHExKiM2qKaqt59m3rI17IYY83pEn26VZ5kpDtIeWzQRmKqizCHDDVK5t5LS4?= =?utf-8?q?gjFcRhnmGqjV9eKaPuIe/r3kqLoAmJ4OArJ7eVNJ7yJHiz5CkIxLOm99xwQrxzP57?= =?utf-8?q?aiE+OnlPXGLqv47kV8zQf+IoYwS6H9CiyG7T/BaX+Stpxl5O1ibMv6v2IkRtflKnZ?= =?utf-8?q?Xpy3EWoa9zc1nFC7zZPekwsMTY1f+EqBNE7/74qOd1vVK0jlhuIR59GnjDipYqmJQ?= =?utf-8?q?3YxaMs3/TRpC8xjCMsIYr+/W1Qua0pqT8R7eIqM/UvyugrZsHNhGiXcGJbK1zRs+n?= =?utf-8?q?/6rJUGR09D3iT+dnP+Tvnp9oOt/rP7U6urRGtvqPHtaVn57Ewe3wrvfxyDwHmfwo8?= =?utf-8?q?WLvfWTdDuNVmnB7CrFHFaolzuBNzfM8Lr6x7TDBmYLcAYD/Zo2S5K29N+Fdrzl8f0?= =?utf-8?q?iN0uF0fXtXTzdQlEBqPHXIo4Rp2CsqLBKDrzxHU7My0e0NwTTqlzJdd+OTFl+xigt?= =?utf-8?q?K2KS2rfHKR/g3IvU6Ps3ypoqgBIrgepkGuP0R7PxtDby8gO3yiSyZSCRImecAuOA+?= =?utf-8?q?D1IwUEkEmEFt6w8qQ4NbFie+lAYwvcghQskqA2fN1HnKZtwV5i6fxXS9YcGPNFpu5?= =?utf-8?q?8Hyan1KFpWP0BRwOuiaxX5XCKrBJ93Grt/rU9/sEvNGBrmXSkBv0FiMfcXup0Kk8Y?= =?utf-8?q?HlY1s3vyDTE8EKydtKhIvKsBQCl4N3diqxI2rVDmMtIJQ8mv4mcR3NMPkPc6qtvDu?= =?utf-8?q?dC3SGubQpGK7fQOVhptPMTh5hJ4ohMkKsOCgV5U70A6X2zgL1BwccTsjeMgWtkFbZ?= =?utf-8?q?+/eIrnzGUsBONlnPkcyVV2bkRPbUZd8/5phaRE21nSd0WuViB0a+ez8+kpWy7PNvY?= =?utf-8?q?Sy4HTHE0FdrHLvgU6ZxOyGtLBsdlsmDPcWMqIWioSI3YQiKVAGo8l6wMHiwZLij7K?= =?utf-8?q?GdVXhbzLwbaiK6x3y4Cm4+r6mg2td/G8A6oGpjegaNA9FyljJ4P55lbeI0fn30nT+?= =?utf-8?q?CIOF8pIqhE9qeZNRrFU7sj3phqWqesJ7jOTk0ZbdgAPWci4626XL7NwS5XZG6fk5c?= =?utf-8?q?967KYfmiCtGxMXMYuJmIz79K2+/DSfTwFC2jyQhH5WnMa77qGmq+dYdXEVbWcODOG?= =?utf-8?q?GlbyMkzVFcENz9Mb3Ku7ffxxT/Uv3xmwctJHRsdZmN7l8shKUMVvcvxHn1BUtNrds?= =?utf-8?q?Ji7jzSLMNH8aLoIZYlVxNVrWcgDIKg3G3qsCLrkPelz1b1pIUumyUObPcXHugZw9Z?= =?utf-8?q?NQUCM48Zq7wbJumLRAFEKhseqlsyROszds6oL/oMsFh+53nuota1DVg=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: e5795b0e-57da-4f2b-a191-08d9f6e55f41 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2022 15:58:45.7278 (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: CvyFsYc8ownQ1/EGeS4qc3C+pgthdYbarHFA0wTgKjdSk3AqKqDNzyheg+KHEyVbjy1Z4C9THSAyFZVHFwz8EA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2479 ... to a new file, separating the functions from their HVM-specific backing ones, themselves only dealing with the non-translated case. To avoid having a new CONFIG_HVM conditional in there, do away with the inline placeholder. Signed-off-by: Jan Beulich Reviewed-by: George Dunlap --- v2: Re-base. --- a/xen/arch/x86/mm/Makefile +++ b/xen/arch/x86/mm/Makefile @@ -10,3 +10,4 @@ obj-$(CONFIG_MEM_SHARING) += mem_sharing obj-y += p2m.o obj-$(CONFIG_HVM) += p2m-ept.o p2m-pod.o p2m-pt.o obj-y += paging.o +obj-y += physmap.o --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -870,60 +870,6 @@ p2m_remove_page(struct domain *d, gfn_t } int -guest_physmap_remove_page(struct domain *d, gfn_t gfn, - mfn_t mfn, unsigned int page_order) -{ - /* IOMMU for PV guests is handled in get_page_type() and put_page(). */ - if ( !paging_mode_translate(d) ) - return 0; - - return p2m_remove_page(d, gfn, mfn, page_order); -} - -#endif /* CONFIG_HVM */ - -int -guest_physmap_add_page(struct domain *d, gfn_t gfn, mfn_t mfn, - unsigned int page_order) -{ - /* IOMMU for PV guests is handled in get_page_type() and put_page(). */ - if ( !paging_mode_translate(d) ) - { - struct page_info *page = mfn_to_page(mfn); - unsigned long i; - - /* - * Our interface for PV guests wrt IOMMU entries hasn't been very - * clear; but historically, pages have started out with IOMMU mappings, - * and only lose them when changed to a different page type. - * - * Retain this property by grabbing a writable type ref and then - * dropping it immediately. The result will be pages that have a - * writable type (and an IOMMU entry), but a count of 0 (such that - * any guest-requested type changes succeed and remove the IOMMU - * entry). - */ - for ( i = 0; i < (1UL << page_order); ++i, ++page ) - { - if ( !need_iommu_pt_sync(d) ) - /* nothing */; - else if ( get_page_and_type(page, d, PGT_writable_page) ) - put_page_and_type(page); - else - return -EINVAL; - - set_gpfn_from_mfn(mfn_x(mfn) + i, gfn_x(gfn) + i); - } - - return 0; - } - - return p2m_add_page(d, gfn, mfn, page_order, p2m_ram_rw); -} - -#ifdef CONFIG_HVM - -int p2m_add_page(struct domain *d, gfn_t gfn, mfn_t mfn, unsigned int page_order, p2m_type_t t) { --- /dev/null +++ b/xen/arch/x86/mm/physmap.c @@ -0,0 +1,85 @@ +/****************************************************************************** + * arch/x86/mm/physmap.c + * + * Parts of this code are Copyright (c) 2009 by Citrix Systems, Inc. (Patrick Colp) + * Parts of this code are Copyright (c) 2007 by Advanced Micro Devices. + * Parts of this code are Copyright (c) 2006-2007 by XenSource Inc. + * Parts of this code are Copyright (c) 2006 by Michael A Fetterman + * Parts based on earlier work by Michael A Fetterman, Ian Pratt et al. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; If not, see . + */ + +#include + +#include "mm-locks.h" + +int +guest_physmap_add_page(struct domain *d, gfn_t gfn, mfn_t mfn, + unsigned int page_order) +{ + /* IOMMU for PV guests is handled in get_page_type() and put_page(). */ + if ( !paging_mode_translate(d) ) + { + struct page_info *page = mfn_to_page(mfn); + unsigned long i; + + /* + * Our interface for PV guests wrt IOMMU entries hasn't been very + * clear; but historically, pages have started out with IOMMU mappings, + * and only lose them when changed to a different page type. + * + * Retain this property by grabbing a writable type ref and then + * dropping it immediately. The result will be pages that have a + * writable type (and an IOMMU entry), but a count of 0 (such that + * any guest-requested type changes succeed and remove the IOMMU + * entry). + */ + for ( i = 0; i < (1UL << page_order); ++i, ++page ) + { + if ( !need_iommu_pt_sync(d) ) + /* nothing */; + else if ( get_page_and_type(page, d, PGT_writable_page) ) + put_page_and_type(page); + else + return -EINVAL; + + set_gpfn_from_mfn(mfn_x(mfn) + i, gfn_x(gfn) + i); + } + + return 0; + } + + return p2m_add_page(d, gfn, mfn, page_order, p2m_ram_rw); +} + +int +guest_physmap_remove_page(struct domain *d, gfn_t gfn, + mfn_t mfn, unsigned int page_order) +{ + /* IOMMU for PV guests is handled in get_page_type() and put_page(). */ + if ( !paging_mode_translate(d) ) + return 0; + + return p2m_remove_page(d, gfn, mfn, page_order); +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ --- a/xen/include/xen/p2m-common.h +++ b/xen/include/xen/p2m-common.h @@ -8,18 +8,9 @@ int set_foreign_p2m_entry(struct domain unsigned long gfn, mfn_t mfn); /* Remove a page from a domain's p2m table */ -#ifdef CONFIG_HVM int __must_check guest_physmap_remove_page(struct domain *d, gfn_t gfn, mfn_t mfn, unsigned int page_order); -#else -static inline int -guest_physmap_remove_page(struct domain *d, gfn_t gfn, mfn_t mfn, - unsigned int page_order) -{ - return 0; -} -#endif /* Map MMIO regions in the p2m: start_gfn and nr describe the range in * * the guest physical address space to map, starting from the machine From patchwork Wed Feb 23 15:59:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12757150 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 8BA30C433EF for ; Wed, 23 Feb 2022 16:00:02 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.277480.473993 (Exim 4.92) (envelope-from ) id 1nMu3S-0001z0-08; Wed, 23 Feb 2022 15:59:50 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 277480.473993; Wed, 23 Feb 2022 15:59:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nMu3R-0001yt-SO; Wed, 23 Feb 2022 15:59:49 +0000 Received: by outflank-mailman (input) for mailman id 277480; Wed, 23 Feb 2022 15:59:48 +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 1nMu3Q-000083-HH for xen-devel@lists.xenproject.org; Wed, 23 Feb 2022 15:59:48 +0000 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.111.102]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 9ff2ad84-94c1-11ec-8539-5f4723681683; Wed, 23 Feb 2022 16:59:47 +0100 (CET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2104.outbound.protection.outlook.com [104.47.18.104]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-10-abkoG7xhPoqmV5MEq1IFFQ-1; Wed, 23 Feb 2022 16:59:46 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VE1PR04MB7277.eurprd04.prod.outlook.com (2603:10a6:800:1b3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.22; Wed, 23 Feb 2022 15:59:44 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65%6]) with mapi id 15.20.5017.022; Wed, 23 Feb 2022 15:59:44 +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: 9ff2ad84-94c1-11ec-8539-5f4723681683 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1645631987; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rxOvYBPuwcs53bD4+mtzB6XcLqkGKt/WncfF3FQQLbQ=; b=d4ajpPmOPofNs+OPBpiFx0MBBSAzq0z86m1kPc3v1VEf4ywCiXYzkynxSxvaBR0+xVxoPs BWGtW7zGL0U2RRsD+UUkkgdNmPAtk1JXnQK2xyIeVpxrec4c7YszryRqq5EFWYywX81Ot2 9e7+VfWcOBqf6LctQrW+vkZBPV/yQIE= X-MC-Unique: abkoG7xhPoqmV5MEq1IFFQ-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RqtXOWrC85AhXLlQO37mlPRuNqBbvTpvf8XGeHMXnCB4+B3kKRODde6m9ZbYD0juFpJ5F4LTcRNYrh5tbZynUj51QJh5KmWXSebMvOe5stzvJnbbsuEcuaRlG+BwEVbq+cjKeS9UJnflDfB4Gj7owWOxycDbk06ZyzRYzbikmhyMmdIQ/PIXesyKScnXb9n2AM1LlbNzB8B+w5PAL6so/pBAZ3yZGh5Qcd7QgJX8sguO9jeAiPMq0KCX6sDQW++jyFJi/956V9MlCePPsukpSrEAX8nNTsiIQTN9mp9+iDsSU0VBu/oAalZuahJZYKJOZdD5YHwm+X9y+bP+F8OREw== 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=rxOvYBPuwcs53bD4+mtzB6XcLqkGKt/WncfF3FQQLbQ=; b=k12nXV9WZS0/4y9XCBm0gu2xmJo5TTdnf0pcmp3izAFpPXzUTg3hZJl01UOJyrgUvObpCETUhl4Ph40wBKEFzizbqZBcqs5wvooTzPWZwn6xWkgwHigbYK3TMCPCzKDlfZlqR6VQmsfpnIR6kLDjQbEohju3uN9CeXaiFfI52QxeWha3ce84MYfvBgZh9t90YTDUj7+lBN5J3ybGPYytGFEAoKu3yuhYv56LExrIJDsJxRy3U01u6Q3sTDOjS157KK/aMRyP+sgyMHga93dh0DTRMBYT2gxWYCCjfIvmTWxlK0X+RW9bfHfoOWPEtNW6I64zKnPmW/K0LBE2ipIdtA== 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 Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <69623630-cda7-9b2b-4f2f-09a83d5dc22a@suse.com> Date: Wed, 23 Feb 2022 16:59:42 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH v2 04/14] x86/mm: split set_identity_p2m_entry() into PV and HVM parts 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 , Paul Durrant References: In-Reply-To: X-ClientProxiedBy: AM5PR0701CA0010.eurprd07.prod.outlook.com (2603:10a6:203:51::20) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 74362b95-35ae-40e6-5e4f-08d9f6e5822b X-MS-TrafficTypeDiagnostic: VE1PR04MB7277:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: O6GhJO9JSlCfTRRpTRHJv96TDo1klnDLYdOiA0zJXOupuPHTJ8P8mihdKjlpFlkRg613p7vjQOgMoujI211QBbg50Dp0HJZ82O2rSdQguftlsfGYr0wzLacOB1xZWIeqneYAOKVSaPUsR7wSTjOLD5L0GT7b53eQ/wYULsAjVffgr1ZYk6vZZDBtpekQoDJKUz4jRRb+dW52MPvxz6f9nVb7V1vL0riq/m7YZvO11l4b2larSMo+9ifXQ3DmY8ae2rAoDPZhxNfZQUqaT8TBcT/yATH9HJmnbovfiKHbth4DHtJVGvORGYs8t8Cv3vn52jnq32Q2E2eouuqhPzbamcvdBlwp4Q0965GJvWQQLGNFIP9xTimnk8nHe52s8h68Bbx5AWGOUuf1A4PqnPlgCg2BjiHN8k9SPHBrLK0bhDahixW1blCHmg4wW8GriPI25RYpzxiIsqrdPdo84vpdwcaLhenE4VCe0s+N8rCbLpYJXDRMBZbkaZvvGAJ8AXDUEMtH33EEKuRw8MjrdDenBXfpfSj+NOPqq2JENIlTmSc3FV4tipc/MHLcr1GhXYYcARx1YysLveYUumEV5HB3tuUzntSWSyrfhgGkpirnEKcNP2rzYXOfpx6QRC7zWt5QO0ryVJ8AbVEd3ovpfWlnWzl6XYc6T3TmIEJPSswBRLCZowlAotB/mkwxrI2YPII/8KLF1wl1I7hePQGyI9fUIK4ewlJxi4/pP0Xp9JieUNdGDbKzH7sugokGMU6ePcFsrcLy06KbpLDNA1enedNCMceth5AzxWZCKTahS+mH7ytS6acBHZmC5KHt/4OcPV8iygo+dwDgxYkfXLSU0JzA9fOTqj4q8ImxbeOgkRsj9Vw= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(66476007)(186003)(2616005)(8676002)(4326008)(26005)(66556008)(66946007)(6512007)(2906002)(6486002)(508600001)(6506007)(31686004)(8936002)(6916009)(31696002)(86362001)(5660300002)(83380400001)(36756003)(316002)(38100700002)(54906003)(70780200001)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?VyRyXrU7xzq9kEJlYjkLLqwo18Xx?= =?utf-8?q?ZNbxLhfsfBWr0my5tgUgTqPl8WQGQNgw7tkd0k6wC8zWPU1MhTr3CFCV5QD5pY8nu?= =?utf-8?q?WDSWjbI/IgB1kuxv2E8jBeINfUs4IN93OcBHU8z7eZY6DGDuoYhg1yKeATZ9cT9mp?= =?utf-8?q?AWGyqzr101AC6J7+daYF9qarcTEF77Ea9URMyegZ0bi4oxziF+0efN24+FAfopOEO?= =?utf-8?q?NVr+RpapgdfjTBJmoLYe4NSccQp8w5H6FGBgEo9E8TUOrIxDZ4KxvUd0e6jmExwL3?= =?utf-8?q?mr9ts/nc/o7f0OmXDd19YQZRhb4TwQmGfkhGetV35MUB89rsR4AS0APpPsz9VdFUa?= =?utf-8?q?65s8A4ViFimDVbwRdN+cf2oYg3TO0Zj3+hvlvxmjR0APSfc0qk69PupiOBTEEjieR?= =?utf-8?q?AtQszy1C2qRNBzcNo2WAHtRDvrWfT4cmmdSFEY0SM2tnBNmqbGs2kYahI1uKu80ir?= =?utf-8?q?D3ctxM19/c960/lfNzu1s8wMLbBZBsezFmKlkyJ2jDQukv5hnKDVf6bz/KzmcvVBD?= =?utf-8?q?HVXZGSCyzN9F3CKWP9DG46HcE6DONpS2MZk0V/hZe7HjOLl8grKL3wqIuld2iadew?= =?utf-8?q?WPRNJ+NCBEqHJRdEkGol0Vqr0ulMI/ALUbCFYPNVSIl5uWZwaO8IYnJS+lapL4sXm?= =?utf-8?q?/Ut4X1MBoRk+Jud23+qDhfONXdoYNjwbO2DmZPnlYVWQFu4HryP880jv4y03Ujv23?= =?utf-8?q?9L8U/xhbBI3OC41a+56Qy/snrPgc/I6Stx5W643RAcBAiBlRh8U0HCk2aknJHZu/y?= =?utf-8?q?l7X4L9lp6WwDuhrCuonuYP3fNjuiTfxWfTpthjlSCdJifa5S/clTw2pMZpqeYpJq2?= =?utf-8?q?p+t2bdmSfilWwrZlCGVgXs2XMvQfCP5Bs1XzPkqTGX/wgnVX2VfuvCAFr+kPDm2M2?= =?utf-8?q?9TpALIQHORR7/ThCDj8ku3zkQgfOkDsR/83oEgT2MU1xbIjcy8XI95fg+nYtE7aCf?= =?utf-8?q?oiYDBJFYCWOtF+yUvMdL/sjIWRCIHGHy7r+dKtPIDFWAx4RQ5Ph4TYwQkHaSqJWi0?= =?utf-8?q?zzfVaZQ1l/LVp9AhMAwA4sHUcbIR6+6lqwu0GWNV/4rnJ4kvWQoDW9mfSQACOPQvL?= =?utf-8?q?L3gQOjvuxlSx9O2Q+2M0wr8udxcRD09t/XGbOsBw8AG0iD8tjDwtEZpE35ZK3V+1I?= =?utf-8?q?Iqoohr8axbwdA1Jw+qoFriTPhMY+1kvhA+1EiFztXTp19UzhpcKpIVZZLVenu08bX?= =?utf-8?q?9LNhE6F0aYYoSu0UNxw4ScukVU7N9X7oDLBlUaaENo/XKFDqRrx805vdBPOcRjwG8?= =?utf-8?q?vXK93LNIbbQIcoQ5BvgVdyIrDVPOAh+/J7nLeDAvPRX+nCo4+aHL/9J1JlUizkkPz?= =?utf-8?q?ovowhhOW7336G8pphtqJhG4lkRk7JLgnP7XmrQdcQ1bXiLTTzV7K+rjKimUnTKLEY?= =?utf-8?q?FxgH1gCSpPEhaIZDoOsDAQ6nmsp2tHNLsVWfTQGbFslxCcs/LghpKJlM+UPDtw2f4?= =?utf-8?q?kysRWFJf8vUGiOO0oLHJjCKyVwA5OGBzUezrEQlM6LKJ/DmsD++/qwN2Qzo66B9ma?= =?utf-8?q?HSU8FSe2cSfKOtkqTrL7PINGEftMw47XF5TEc9PEWV5NpXoOpxWQKkQ=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 74362b95-35ae-40e6-5e4f-08d9f6e5822b X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2022 15:59:44.3022 (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: Mb30VvWdbv7CEnZjD0OY3IzCl/JfeLaFI26VUJc7Mrg/7YCmGHTIHD9zAsI3ekiM5ul35AWIK1F5vEvKDBj3oA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7277 ..., moving the former into the new physmap.c. Also call the new functions directly from arch_iommu_hwdom_init() and vpci_make_msix_hole(), as the PV/HVM split is explicit there. Signed-off-by: Jan Beulich Reviewed-by: George Dunlap Reviewed-by: George Dunlap Reviewed-by: Roger Pau Monné --- v2: Change arch_iommu_hwdom_init() and vpci_make_msix_hole(). --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -1473,12 +1473,9 @@ static int clear_mmio_p2m_entry(struct d return rc; } -#endif /* CONFIG_HVM */ - -int set_identity_p2m_entry(struct domain *d, unsigned long gfn_l, +int p2m_add_identity_entry(struct domain *d, unsigned long gfn_l, p2m_access_t p2ma, unsigned int flag) { -#ifdef CONFIG_HVM p2m_type_t p2mt; p2m_access_t a; gfn_t gfn = _gfn(gfn_l); @@ -1488,13 +1485,8 @@ int set_identity_p2m_entry(struct domain if ( !paging_mode_translate(d) ) { -#endif - if ( !is_iommu_enabled(d) ) - return 0; - return iommu_legacy_map(d, _dfn(gfn_l), _mfn(gfn_l), - 1ul << PAGE_ORDER_4K, - p2m_access_to_iommu_flags(p2ma)); -#ifdef CONFIG_HVM + ASSERT_UNREACHABLE(); + return -EPERM; } gfn_lock(p2m, gfn, 0); @@ -1520,12 +1512,10 @@ int set_identity_p2m_entry(struct domain gfn_unlock(p2m, gfn, 0); return ret; -#endif } -int clear_identity_p2m_entry(struct domain *d, unsigned long gfn_l) +int p2m_remove_identity_entry(struct domain *d, unsigned long gfn_l) { -#ifdef CONFIG_HVM p2m_type_t p2mt; p2m_access_t a; gfn_t gfn = _gfn(gfn_l); @@ -1535,11 +1525,8 @@ int clear_identity_p2m_entry(struct doma if ( !paging_mode_translate(d) ) { -#endif - if ( !is_iommu_enabled(d) ) - return 0; - return iommu_legacy_unmap(d, _dfn(gfn_l), 1ul << PAGE_ORDER_4K); -#ifdef CONFIG_HVM + ASSERT_UNREACHABLE(); + return -EPERM; } gfn_lock(p2m, gfn, 0); @@ -1561,7 +1548,6 @@ int clear_identity_p2m_entry(struct doma } return ret; -#endif } #ifdef CONFIG_MEM_SHARING @@ -1606,8 +1592,6 @@ int set_shared_p2m_entry(struct domain * #endif /* CONFIG_MEM_SHARING */ -#ifdef CONFIG_HVM - static struct p2m_domain * p2m_getlru_nestedp2m(struct domain *d, struct p2m_domain *p2m) { --- a/xen/arch/x86/mm/physmap.c +++ b/xen/arch/x86/mm/physmap.c @@ -21,6 +21,7 @@ * along with this program; If not, see . */ +#include #include #include "mm-locks.h" @@ -75,6 +76,33 @@ guest_physmap_remove_page(struct domain return p2m_remove_page(d, gfn, mfn, page_order); } +int set_identity_p2m_entry(struct domain *d, unsigned long gfn, + p2m_access_t p2ma, unsigned int flag) +{ + if ( !paging_mode_translate(d) ) + { + if ( !is_iommu_enabled(d) ) + return 0; + return iommu_legacy_map(d, _dfn(gfn), _mfn(gfn), + 1ul << PAGE_ORDER_4K, + p2m_access_to_iommu_flags(p2ma)); + } + + return p2m_add_identity_entry(d, gfn, p2ma, flag); +} + +int clear_identity_p2m_entry(struct domain *d, unsigned long gfn) +{ + if ( !paging_mode_translate(d) ) + { + if ( !is_iommu_enabled(d) ) + return 0; + return iommu_legacy_unmap(d, _dfn(gfn), 1ul << PAGE_ORDER_4K); + } + + return p2m_remove_identity_entry(d, gfn); +} + /* * Local variables: * mode: C --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -373,7 +373,7 @@ void __hwdom_init arch_iommu_hwdom_init( if ( !hwdom_iommu_map(d, pfn, max_pfn) ) rc = 0; else if ( paging_mode_translate(d) ) - rc = set_identity_p2m_entry(d, pfn, p2m_access_rw, 0); + rc = p2m_add_identity_entry(d, pfn, p2m_access_rw, 0); else rc = iommu_map(d, _dfn(pfn), _mfn(pfn), 1ul << PAGE_ORDER_4K, IOMMUF_readable | IOMMUF_writable, &flush_flags); --- a/xen/drivers/vpci/msix.c +++ b/xen/drivers/vpci/msix.c @@ -409,7 +409,7 @@ int vpci_make_msix_hole(const struct pci case p2m_mmio_direct: if ( mfn_x(mfn) == start ) { - clear_identity_p2m_entry(d, start); + p2m_remove_identity_entry(d, start); break; } /* fallthrough. */ --- a/xen/arch/x86/include/asm/p2m.h +++ b/xen/arch/x86/include/asm/p2m.h @@ -637,6 +637,10 @@ int set_mmio_p2m_entry(struct domain *d, int set_identity_p2m_entry(struct domain *d, unsigned long gfn, p2m_access_t p2ma, unsigned int flag); int clear_identity_p2m_entry(struct domain *d, unsigned long gfn); +/* HVM-only callers can use these directly: */ +int p2m_add_identity_entry(struct domain *d, unsigned long gfn, + p2m_access_t p2ma, unsigned int flag); +int p2m_remove_identity_entry(struct domain *d, unsigned long gfn); /* * Populate-on-demand From patchwork Wed Feb 23 16:00:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12757151 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 EE2A3C433EF for ; Wed, 23 Feb 2022 16:00:55 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.277487.474004 (Exim 4.92) (envelope-from ) id 1nMu4F-0003tF-A4; Wed, 23 Feb 2022 16:00:39 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 277487.474004; Wed, 23 Feb 2022 16:00:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nMu4F-0003t8-5g; Wed, 23 Feb 2022 16:00:39 +0000 Received: by outflank-mailman (input) for mailman id 277487; Wed, 23 Feb 2022 16:00:38 +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 1nMu4D-000083-Pp for xen-devel@lists.xenproject.org; Wed, 23 Feb 2022 16:00:38 +0000 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.109.102]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id bd5c63a5-94c1-11ec-8539-5f4723681683; Wed, 23 Feb 2022 17:00:37 +0100 (CET) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04lp2057.outbound.protection.outlook.com [104.47.13.57]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-19-6uulGi0aMkiUDrCb_-IcGg-2; Wed, 23 Feb 2022 17:00:35 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by DBAPR04MB7477.eurprd04.prod.outlook.com (2603:10a6:10:1a9::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.22; Wed, 23 Feb 2022 16:00:32 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65%6]) with mapi id 15.20.5017.022; Wed, 23 Feb 2022 16:00:32 +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: bd5c63a5-94c1-11ec-8539-5f4723681683 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1645632036; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XB8iGCGqs8PHapYbAltMnTIf3L+ULvxt+u5ysAKSY4A=; b=npRSJUupycm1feeGAKEssoYMuQU5h2FHTxOnmnh1Rp8QUoFQ+dDCMIfGXsFglQx8MzbXb5 Q/8o86C4yhPq3/uvDrHIAaMex7GE8K1Zdcs8dVePNSSor3mhurLFHg0/feS+zLfxfqTZlV 20DQvRFnOnojASm/skBsW8bzlBAsfD0= X-MC-Unique: 6uulGi0aMkiUDrCb_-IcGg-2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ta0Q2CS5xPVH6PK5Dns7ddodwo/13k6SHOE816p2YYpHgdl5Rj5NtJjggzxB0omBryvVcr7PKBWJ6YfZqKcd+tOiTgQsNXPkjS+vVIskUra+Zbra5W7qMx1DITgoW4lAd5nvFnGNkTyBS++nnvcGkIoBNqJImMq1Ag6OSmdjsVWqJk7GKrUuNMjDqO98Rl3qdR8VFnqKgYZeX3oYEy4AV+R9DgG/CQdBahpx43detnIIPrKl7zyDe84Nii1yg4epcmIKuBtyd+Ti55U2QkCtwJTtwB2lxz9EzmthtW2PWKNlCS7yL34c81YXf7kAQAmlUDvbaWh1jO0nd6GvRPzSgg== 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=XB8iGCGqs8PHapYbAltMnTIf3L+ULvxt+u5ysAKSY4A=; b=lodkDBsp/t6haZR0x+LCuzXj9MkpqvAQjcqjLwRHzEcHr0MzpmwAwVguIAP0SL3BcaJbXqcF07FlHm5q6tvEnZDHj5ebhpqUg1Mfk/69BmB5D6Uth/7JCFOnNnsRXHo4SDS7QBN43nOFGiX8iP5H1AX1wGdP9c2Sxd6BgITGTidGMwhuAfB/jyH6nNXKKTNUubhejWFAgbmqev3ET6c1i4V0k6aok7LQFC+S7m1DeMSloiJkSBt67vE+5VrqMuo8+NG/Wc8Kh2DCZ+RbfesQTu3GMcmca1Zfy3QDh/ph+jeHZKnsF8Ps+/H/M9h2jz6ZWnfBqmE3JhKVS09n8gWzMg== 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 Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <0c3d463d-80fa-cd19-22b6-6335fd69bd11@suse.com> Date: Wed, 23 Feb 2022 17:00:30 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH v2 05/14] x86/P2M: p2m_{alloc,free}_ptp() and p2m_alloc_table() are HVM-only 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 References: In-Reply-To: X-ClientProxiedBy: AS9PR06CA0362.eurprd06.prod.outlook.com (2603:10a6:20b:460::9) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4457a6a9-e610-4491-2e56-08d9f6e59ef9 X-MS-TrafficTypeDiagnostic: DBAPR04MB7477:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2zgOHG295iw2Sedcr4OJG3j/GbeAnEW96HDS0TNykkgjAULuWW6G+1OiNjqJggvC1CgqXF289e5ocKL0hfHKltyyUT78s9w7a298eUICryk7g8y7A+lkxxoWZQazDEHc+UCIGIdzXWLSc6mW/khESwJg/OmqSs9fMuFySAwwooCnytB7nvdOjpSv+2qWhqCnupbvgXgcUmcXwp/CL15/g1Tz40Wf45C2xi9nUJ4ibLMScW/YNoX7grY0/kTglKL5aDXCiilGW2XZybzK/tUWmTHHSA7XW1ztaEAGZfe1QMe4yrFjJ82hWgONrZKrhN15409kamaGy1S0Ljf9i/xdP+DxlwllbGiCWDF5St1TXSSVSEEDoYnJfxLhE7rpvqQhgGr4aCIuoT1+ZZPKPzymbOkaUmgdvE+YcYPX6siS2QqJ9Ln8mZDN0DfTixDRnCdovCSCms01Jg/OXO7tytxnj1dcbLaYQjlWERfGE3oFgszIzGq8CaTihzI8M57UYnOZrWWHGjRGl0btMGOzWsmCQonyNi3cWQGJ/amieqJsRi4sNvjCF11dECRVG9Mfn/m4vcklIXr83APZJQYEjZTXMUPSyI0KnaVdn/PkukWvXrwdCY9xxfnWHefmv0u1Xv/GYQxg5vaipYIEWRb+hlkJUzkjlNgE5KxqN25Xlbkg/KF+vl1SAdec4tU6gdTIgv42QAyqGxhn0UxVbhqorrA+dQfUFEiYGVLc7BmGAOSfqzL4VBYf2lLSXHNfrqTnVtRi X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(31686004)(2906002)(5660300002)(4326008)(36756003)(8676002)(38100700002)(8936002)(186003)(83380400001)(6486002)(26005)(2616005)(66556008)(66946007)(66476007)(6506007)(6916009)(316002)(31696002)(86362001)(54906003)(508600001)(6512007)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?yue4lqYKeWt1W1aQQFXPLbXkIeb2?= =?utf-8?q?JFgZoztvY80xpDbTFAFIIW10Er98iY/KEDCB0lmajXXv/o2kaKRu3lcOP+X+kBuo1?= =?utf-8?q?Qw3VtTWpPndEeGqGq5eeVsW10p8hfJ7XLh42L/0IQ1GltTD7zflrBnlg0cEP041Xd?= =?utf-8?q?Lxz/EyD0/4Y95mS1yqsvvMmsmxM5w/tv9ECciV8QXl7Hla4c4mcpX02XpDtLwKWR7?= =?utf-8?q?tN16HCERsuaEEsRuWsqIuM4hlyV+q2lzJjknOvE+eQyWlsZPo5cqzwsOCsuycPu/L?= =?utf-8?q?sYPyklNnbFzxatLx3bsgLSUh8eQhDeinY2Xe7StQ9Gumsi3kh/TsRec0JIZ/I9JnT?= =?utf-8?q?r+0yJqymvEB6viAl67DsQs7lMoQJnU/23UgII54LRNVHMEbZbT6vbhd/0oo71aaWB?= =?utf-8?q?JDCMzYPt9K01nuhrjvucLCikyysqduaVfCB3Mm5IG6uAbk3ky0oaqKstNTORQhLV5?= =?utf-8?q?sjM6tpkTWr3+qmRH5X9ObkCjlTtejVBhRn8R6igy1iPBdRmkJQ2GSbby5hvu3i5LI?= =?utf-8?q?vYxHmRDR50o5lQoOviPhkuZnBtKR2nErXK8v2k5khoAng4wj0/Vh5I8kUkXe5DSRR?= =?utf-8?q?8QQHpJiL4QnWdWusdNfqq3xWmLLB2mSSi5XA+fdtoSZfsfPgquGVHEJGj07E6oSY1?= =?utf-8?q?PG/JiWmT7EWZoIqSDhApoU9Lgpwm0aT2UlSrisyRfw/rCVFJUZ6O5XN31NawVx/pV?= =?utf-8?q?Bg7FVILnQL5lbEr34yZ50YS8Wsj7oO8zS3dcxpJ117zOdRLm0yW41XDlD6gHOXq42?= =?utf-8?q?z6ET+bSdFaS9s89Y97n6TNASAHvo+ew2/BV4wqKaOHXSY9ZV2v9JJVTpHvMb1tBmp?= =?utf-8?q?VOICxW/uhmyJekJnynuDIBdhxa6NYLmiNiNTgA64Jj1RUsqRDTqSCUm/LAwe0qFzY?= =?utf-8?q?EJ0gX1ZUFHF5e+hcgJtjqXLL6kq2rAX7McY9ZD9Rfh3wlFCyCrDj0HzkwI0oJaGzz?= =?utf-8?q?AsfNl2fieDCWLT3d+uYi4ECns1yQPoD1UP/3+fVYaY3a5xjoLi2mRd9hDZY4C5OmJ?= =?utf-8?q?k5YeYSVxMdTQ5IuviuC44nx14tdpcekvoK1UsX9v29LANSN7/THaB/8nOJFgtTNse?= =?utf-8?q?bV0X5pMwjLmm6QBlgKRGU5wGQfezJJIaoG6obNhqaSgq6pzUUtubHgWq3wa3VmWqW?= =?utf-8?q?ki0n2Hx/BvMAP2MJsfzKFH7PYuUjki96dcxRD9RANEphZZW8rVeQXqmFxj+HzWuou?= =?utf-8?q?dv8XTpPWmdhxWWqzMMiXDyPxFiJZT9MPjLoOuCJMresMrp6ArXlN94uVfT48bbdNv?= =?utf-8?q?bA98W5heCT+0Wsfs0iJsDun26mZmTRiYFcK4J6HLegzLWQrI+XhmJH80VkTPyQb+2?= =?utf-8?q?TGDdXLuGABaLy6QgUKdUOGpuGw6RCr7irDls3rVFmYY26MLn7ROTzESWFGsBHqIVA?= =?utf-8?q?Xs/6Al2bYfSnlqk7YiMm8bvuDvSWvpQ7SqPM/brTfCgHIQeAfCHfZjCp4XRjyDXhS?= =?utf-8?q?HVbJ3uMHmyzy0PZqHLa7EC3XBQ6/82rVmK08lAslqh+C2VNpc0w/r/JFB6Hf5r+RW?= =?utf-8?q?ZpREscqYUyAcuI16jSMWLY48lSY+7GdDxrJjOCRWxJ7S1ILnDw3NCuE=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4457a6a9-e610-4491-2e56-08d9f6e59ef9 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2022 16:00:32.6741 (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: eKRP3niiXXK+JF9FbjeqmfxEA4ZiN7TmuEDxBj1Z+Zg2SA0bofQvwy0krljCPVlGb8FOkBFv6IEH75SUinCRyw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7477 This also includes the two p2m related fields. Signed-off-by: Jan Beulich Reviewed-by: Kevin Tian Reviewed-by: George Dunlap --- v2: Re-base. --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -93,7 +93,9 @@ static int p2m_initialise(struct domain int ret = 0; mm_rwlock_init(&p2m->lock); +#ifdef CONFIG_HVM INIT_PAGE_LIST_HEAD(&p2m->pages); +#endif p2m->domain = d; p2m->default_access = p2m_access_rwx; @@ -627,6 +629,7 @@ struct page_info *p2m_get_page_from_gfn( } #ifdef CONFIG_HVM + /* Returns: 0 for success, -errno for failure */ int p2m_set_entry(struct p2m_domain *p2m, gfn_t gfn, mfn_t mfn, unsigned int page_order, p2m_type_t p2mt, p2m_access_t p2ma) @@ -666,7 +669,6 @@ int p2m_set_entry(struct p2m_domain *p2m return rc; } -#endif mfn_t p2m_alloc_ptp(struct p2m_domain *p2m, unsigned int level) { @@ -745,6 +747,8 @@ int p2m_alloc_table(struct p2m_domain *p return 0; } +#endif /* CONFIG_HVM */ + /* * hvm fixme: when adding support for pvh non-hardware domains, this path must * cleanup any foreign p2m types (release refcnts on them). @@ -753,7 +757,9 @@ void p2m_teardown(struct p2m_domain *p2m /* Return all the p2m pages to Xen. * We know we don't have any extra mappings to these pages */ { +#ifdef CONFIG_HVM struct page_info *pg; +#endif struct domain *d; if (p2m == NULL) @@ -762,11 +768,16 @@ void p2m_teardown(struct p2m_domain *p2m d = p2m->domain; p2m_lock(p2m); + ASSERT(atomic_read(&d->shr_pages) == 0); + +#ifdef CONFIG_HVM p2m->phys_table = pagetable_null(); while ( (pg = page_list_remove_head(&p2m->pages)) ) d->arch.paging.free_page(d, pg); +#endif + p2m_unlock(p2m); } --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -2700,8 +2700,10 @@ int shadow_enable(struct domain *d, u32 out_locked: paging_unlock(d); out_unlocked: +#ifdef CONFIG_HVM if ( rv != 0 && !pagetable_is_null(p2m_get_pagetable(p2m)) ) p2m_teardown(p2m); +#endif if ( rv != 0 && pg != NULL ) { pg->count_info &= ~PGC_count_mask; --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -370,6 +370,7 @@ static uint64_t domain_pgd_maddr(struct ASSERT(spin_is_locked(&hd->arch.mapping_lock)); +#ifdef CONFIG_HVM if ( iommu_use_hap_pt(d) ) { pagetable_t pgt = p2m_get_pagetable(p2m_get_hostp2m(d)); @@ -377,6 +378,7 @@ static uint64_t domain_pgd_maddr(struct pgd_maddr = pagetable_get_paddr(pgt); } else +#endif { if ( !hd->arch.vtd.pgd_maddr ) { --- a/xen/arch/x86/include/asm/p2m.h +++ b/xen/arch/x86/include/asm/p2m.h @@ -208,9 +208,6 @@ struct p2m_domain { /* Lock that protects updates to the p2m */ mm_rwlock_t lock; - /* Shadow translated domain: p2m mapping */ - pagetable_t phys_table; - /* * Same as a domain's dirty_cpumask but limited to * this p2m and those physical cpus whose vcpu's are in @@ -229,9 +226,6 @@ struct p2m_domain { */ p2m_access_t default_access; - /* Pages used to construct the p2m */ - struct page_list_head pages; - /* Host p2m: Log-dirty ranges registered for the domain. */ struct rangeset *logdirty_ranges; @@ -239,6 +233,12 @@ struct p2m_domain { bool global_logdirty; #ifdef CONFIG_HVM + /* Translated domain: p2m mapping */ + pagetable_t phys_table; + + /* Pages used to construct the p2m */ + struct page_list_head pages; + /* Alternate p2m: count of vcpu's currently using this p2m. */ atomic_t active_vcpus; From patchwork Wed Feb 23 16:01:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12757152 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 15A28C433EF for ; Wed, 23 Feb 2022 16:01:59 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.277493.474015 (Exim 4.92) (envelope-from ) id 1nMu4u-0004RD-Ic; Wed, 23 Feb 2022 16:01:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 277493.474015; Wed, 23 Feb 2022 16:01:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nMu4u-0004R6-Ed; Wed, 23 Feb 2022 16:01:20 +0000 Received: by outflank-mailman (input) for mailman id 277493; Wed, 23 Feb 2022 16:01:18 +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 1nMu4s-0004Fn-MP for xen-devel@lists.xenproject.org; Wed, 23 Feb 2022 16:01:18 +0000 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.111.102]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d5b427a3-94c1-11ec-8eb8-a37418f5ba1a; Wed, 23 Feb 2022 17:01:17 +0100 (CET) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03lp2056.outbound.protection.outlook.com [104.47.9.56]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-24-x1nm9-4WNM6dlw1HnPAvaA-2; Wed, 23 Feb 2022 17:01:16 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by DU2PR04MB9179.eurprd04.prod.outlook.com (2603:10a6:10:2f6::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.21; Wed, 23 Feb 2022 16:01:14 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65%6]) with mapi id 15.20.5017.022; Wed, 23 Feb 2022 16:01:14 +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: d5b427a3-94c1-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1645632077; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2rZGfRwylNtAPsQ5UVyxgV9uPoIoLBQeDGzPZv56WOI=; b=MeY32wDFRHRbuA39k8rYQBh8XSVRkiUulFX+SVYoFi4FAK0WRxww85qqpmTbjZW8D7nq9D heuR+vsrkBckGP14M+myhklE9BlkL0HFHUs5BfKITseBGDoKnjHi44mawyyRgl9k+0p9eN 2WJghh/B8/rzhOjqJQ3cwr8kCdKSBMQ= X-MC-Unique: x1nm9-4WNM6dlw1HnPAvaA-2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RcVBFhziv4YjjpxvCkhrDnq3RhXBZAk1bgPBcsRv8+8iZphoNkeSKfkB+owjdb8Pz3CAIVNUQIFlRRx1IiVTVK/aPgz4qMhFMjD/ZqcjmGe02CU0YYe4wwtNoBtQMA6So3Pf/vatwWageX/4q3I52a1nrGhvVhu/yJjwIVkMKSf2gHd10ftvKHZwsJ08yoFzWaSsl09ySwNbb2whk0Vz5g2GkTYBGw8aCeXvhFhqChgBa5CGaz8UUYAhMvpIv7327MP9QHpwactc6a/PtN7zz84yJALZoy8NqRcfUjZyUQ4f/OVDRGbObUY70GheAS3256/t/P060LqWEpVUASQrpg== 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=2rZGfRwylNtAPsQ5UVyxgV9uPoIoLBQeDGzPZv56WOI=; b=lqWnLKiXzqTim2tsz0fMe/9N4JM1Atmz/3RZXaJF7EIv6Ov8q6bcWuaxX9f4uL/GixgdNHpa5sYmWPUPgcvJa5ITlcOvt3B09AXvbscJjN8ky91xR072Q8QdgvsXRGLPX03WRNIdVeKuM7hadoeC337xbKcf6FhvpkISzVJ7Bckorxc+zEeaqfS6YTT4qpJU6KnpXqJU4RH05KFilHXGo6mRpSIHFmhp8ZnOhfItHckCfVqmdys7G3B/mSXxgjyebiSNh3NtvZxnBbwU90Gq/0yWiI3AhoOh4I6ISYvlvm7yNtilCgtsco87EUCok2DjIk4dyfQCAvlPQukWQI8y6g== 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 Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <556f793f-e4c2-8f05-44e9-edf8b300777d@suse.com> Date: Wed, 23 Feb 2022 17:01:12 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH v2 06/14] x86/P2M: PoD, altp2m, and nested-p2m are HVM-only 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 References: In-Reply-To: X-ClientProxiedBy: AS9PR06CA0251.eurprd06.prod.outlook.com (2603:10a6:20b:45f::28) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2f68c61e-8e29-42fe-57d2-08d9f6e5b7db X-MS-TrafficTypeDiagnostic: DU2PR04MB9179:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2MMwojvcXXA7wozS4kgd12WMgQ0MUCZA2JXvAvEkD6Aei2DzIl3CxhRiIFiPWycirlBaV8LRzR9Ei1WwNQCJweKQ4L38pwaKvD4LP3GIOPHsqHQPhD29X4qH4OSjncSAGPNmT66lMeULN5dOZWoHByzsaM23B6fRoYUrzQXy6GW3Jt2PVRMIB1/8iVimKgd6F5qMRx4piGE8mdJOK5SQbNAK+BWV1Kbo1vRGquilirjvSMU9yRK4jnCxkchf9jYY2UaXAaPog1v73H659Gdjgy72KQNDq+T/ZhE93kGDXEOdw7ezlE1eRrJmHIMrkiP8eAG4JtT4e42frHhlMQ9RIqanvue2gcAvReSnXnLe9xJ5hzW152DBH1t/W6Y+zNG/GfcU1meB7BTDFDci8cQBFaP4achkSfsziUhRF7Ck9iUjSp72JbKKr5ncaHl4Ehg+jOOzGi5hnqbi8M5uUg3OBm46gDi0v9+J7eUOI2cio2lDAuqkeRY+Ot0lFCQbJiWAzDuDsgdgPLU20Kpo0AYLXK05j4xA8JAnuPinwuROZmGqvsuk8AZY6s09UDlGJY/XrynSlipxLb6cRZIH01+1euop1SzbSo5ycC2lMCM0DWDZLVi4viELtCScX1+kihLbAKbaQxbEVl4AuMapmGWT0w3lS2iMXghztmDP+hnf5t4ELXbKLHUcTbF7ybdtBTRdhLuv7kZDdTgOuDBkpRhnDmJcbVxa/EkbWqDGlzEowruE8OPILmhey+0RvKMlYAyfoN+URtucBW76MXBi7jH5T8ceBKSUu1smFpoRErjA1/1eEe93PSJAN8MEKPD9KQ2r4De2cCV8mkXEWICKR6R5CQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(86362001)(66476007)(66556008)(31696002)(6512007)(8676002)(66946007)(54906003)(4326008)(38100700002)(6916009)(316002)(186003)(508600001)(83380400001)(31686004)(6486002)(6506007)(8936002)(26005)(2906002)(2616005)(5660300002)(36756003)(2004002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?fE5Mf2zo4Zksy7CKmejacIsF+EPA?= =?utf-8?q?nmzzN0GCEGbwAOgoKFIyyDsL7Vz+I5w7TlZXNI6Sx/Jnf1+vLnZUvKgqVI3/ux1cK?= =?utf-8?q?JsQ85ZrDNOUeI4g8u2lish5XCGz7OCcdNeADBKmjjPScL7+mrbEC/pCKRU8r2cem7?= =?utf-8?q?3H7mxcGcpIJwtPhct+MmIUT9HbcIYrI+QOQBHM4jpLUM4lsSuJcrLMJTo8srGsUjZ?= =?utf-8?q?/Uh8Rl2tdueOrIUUrjUm7zlKz1XNbTQ2APeVBLB7FmA0ynGPlIQGqIBm/yEM5g9WV?= =?utf-8?q?JyskTW8l27nUV/PA8PDjfCVZZJb508jNqNZ5ILIUhX6j+Gci90teMV93nmxRlCbd/?= =?utf-8?q?1v1F2OWUUgjGUfgxt78T600S3uT0ZgrLlfIHHxOUZL7yYFz7IyzL6ni9U54uhO7yR?= =?utf-8?q?VAXYi5SestiIEoQb0o3U/sjIuEVyabht9iqyfYR0BCtmYiVhZtOf0uNtYrsXjxl/W?= =?utf-8?q?It5WPwkYeJUSesbJK6oUA50QEP/3baDf2+6pRXiJ4aLN/DYs4EIgAYec6guQ21ckv?= =?utf-8?q?hYsvLRQy+FW0hN7Zbsk7mSyWW5y3vkbbVP3va1Lp8pQmJKMRkdPQOIpX0YwHUuDHZ?= =?utf-8?q?UG4kzy6JtzfuUAi8RRU3em64rg/1gvv36bMxpXpXDZpb9uXNuofDf/iWxJMGBCLPN?= =?utf-8?q?WRxOK5OuWVzsp1IYAwAdE4EUOfFu0+7Tio1XESl1EorcQruUDaW99yp24C5SW3ZK1?= =?utf-8?q?UHD3pUyTOOJff2At50juwIxoCW28njXpQLjVNtWQB+LZ3uzbuqDVEDtOgRJJaHorj?= =?utf-8?q?iNYIn7XijbFpLb5Aj4PRcnP8qPB420lq80kjc8E179OlUp06/sYF4Oc8am1yc1aLv?= =?utf-8?q?Xj8hi4DEAjK+ocQpu76rfqBFypjhRq3P5tqpPppSDp/T5DW6ARVoZ+n1WNUif9Asl?= =?utf-8?q?cNdRVWMeZMvUKoPTAH+0Ba+DCTFRoQp8a15fCW4AAfnamY/HvswxaNXDmSGikobmo?= =?utf-8?q?5/flSi9prs2wmIqD3yUJlyx84DAg7NAe0J1gOi1ttpfVARzdO7Z4JK6fTURO1ehtm?= =?utf-8?q?q+ImFj1sgKmNqwd6TruP5aBNNYepDw1uLqveZ8SVatwk84ZMbS3g2LVvD5wb0UOkI?= =?utf-8?q?wHQeaOnW/pp1F9Xv8NKLm6GW7gQTsnN9m39d/SPn5U9NZk/UcQ9VzJKxHgQjX4XCm?= =?utf-8?q?791NMLKG2n83SQsXnmW2MvP8lYDiKo6KibLnGVJKQgm5s1g2Ox9wwYOwoagjvfUkj?= =?utf-8?q?syHWvH45CpzqdNsKNZHjSNDpLXFWNIfJpXXkZcT9KW4xwqjlRI5pbS/A4n53iRY6/?= =?utf-8?q?bugxI5gfIrtFJ5d9SiObcl+MqstD+2omXi7CHPa1deWL4LCXWEXiZbYYw27JfAK3E?= =?utf-8?q?aCVhJdEo5xfGftbNc0Hg2n7e2B8/ADbKqoHDMeNKafsPJ0yTGElAjSBQE/h/jwspU?= =?utf-8?q?dQPG0mnGBethQnP2m3e7XsRvt2TwtHGieQSQDG03pQJnPGSC2/B+6Lhy5FvdqOU54?= =?utf-8?q?ZY+rmM4x/h2F0eFZfDMNFc9RT8XJBubhZ9FPpB6VSJ1ilATM+wOuXnmhUhamBg+/5?= =?utf-8?q?ADjeOZRb6XiNguBl2tZJCRiAkRQU63uRIBMWfknG9mk+PNTPuVcTHnE=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2f68c61e-8e29-42fe-57d2-08d9f6e5b7db X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2022 16:01:14.3903 (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: 54kOxSZlZIbZ0cgNTSDnJ+jR+wqok+ZFOfpE94HyAqyZZp04s/75ezskm1rm/jzpBNEH1ZQlhg7J+H1D+rGxHw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB9179 There's no need to initialize respective data for PV domains. Note that p2m_teardown_{alt,nested}p2m() will handle the lack-of-initialization case fine. As a result, despite PV domains having a host P2M associated with them and hence using XENMEM_get_pod_target on such may not be a real problem, calling p2m_pod_set_mem_target() for a PV domain is surely wrong, even if benign at present. Add a guard there as well. In p2m_pod_demand_populate() the situation is a little different: This function is reachable only for HVM domains anyway, but following from other PoD functions only ever acting on the host P2M (and hence PoD entries only ever existing in host P2Ms), assert and bail from there for non-host-P2Ms. Signed-off-by: Jan Beulich Reviewed-by: George Dunlap --- v2: Also guard XENMEM_{get,set}_pod_target handling. Re-base over wider p2m_add_identity_entry() exposure in earlier patch. Add missing inclusion of "p2m.h". Mention the p2m_pod_demand_populate() adjustment separately in the description. --- Perhaps p2m_pod_init() could be invoked from p2m_init_hostp2m(), leaving all other p2m's PoD state uninitialized. Of course at that point the question would be whether the PoD pieces of struct p2m_domain wouldn't better move into a separate structure, present only for host P2Ms. Together with the p2m_pod_demand_populate() adjustment this might then better be a separate change ... --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -43,6 +43,7 @@ #include #include "mm-locks.h" +#include "p2m.h" /* Override macro from asm/page.h to make work with mfn_t */ #undef virt_to_mfn @@ -101,6 +102,9 @@ static int p2m_initialise(struct domain p2m->default_access = p2m_access_rwx; p2m->p2m_class = p2m_host; + if ( !is_hvm_domain(d) ) + return 0; + p2m_pod_init(p2m); p2m_nestedp2m_init(p2m); @@ -258,7 +262,7 @@ int p2m_init(struct domain *d) int rc; rc = p2m_init_hostp2m(d); - if ( rc ) + if ( rc || !is_hvm_domain(d) ) return rc; #ifdef CONFIG_HVM --- /dev/null +++ b/xen/arch/x86/mm/p2m.h @@ -0,0 +1,27 @@ +/****************************************************************************** + * arch/x86/mm/p2m.h + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; If not, see . + */ + +void p2m_pod_init(struct p2m_domain *p2m); + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -30,6 +30,7 @@ #include #include "mm-locks.h" +#include "p2m.h" #define superpage_aligned(_x) (((_x)&(SUPERPAGE_PAGES-1))==0) @@ -1162,6 +1163,12 @@ p2m_pod_demand_populate(struct p2m_domai mfn_t mfn; unsigned long i; + if ( !p2m_is_hostp2m(p2m) ) + { + ASSERT_UNREACHABLE(); + return false; + } + ASSERT(gfn_locked_by_me(p2m, gfn)); pod_lock(p2m); --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4810,7 +4810,9 @@ long arch_memory_op(unsigned long cmd, X if ( d == NULL ) return -ESRCH; - if ( cmd == XENMEM_set_pod_target ) + if ( !is_hvm_domain(d) ) + rc = -EINVAL; + else if ( cmd == XENMEM_set_pod_target ) { rc = xsm_set_pod_target(XSM_PRIV, d); if ( rc ) --- a/xen/arch/x86/include/asm/p2m.h +++ b/xen/arch/x86/include/asm/p2m.h @@ -679,8 +679,6 @@ static inline long p2m_pod_entry_count(c return p2m->pod.entry_count; } -void p2m_pod_init(struct p2m_domain *p2m); - #else static inline bool @@ -709,8 +707,6 @@ static inline long p2m_pod_entry_count(c return 0; } -static inline void p2m_pod_init(struct p2m_domain *p2m) {} - #endif From patchwork Wed Feb 23 16:01: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: 12757153 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 CB4D1C433EF for ; Wed, 23 Feb 2022 16:02:10 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.277501.474026 (Exim 4.92) (envelope-from ) id 1nMu5S-0004xe-VY; Wed, 23 Feb 2022 16:01:54 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 277501.474026; Wed, 23 Feb 2022 16:01:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nMu5S-0004xW-RR; Wed, 23 Feb 2022 16:01:54 +0000 Received: by outflank-mailman (input) for mailman id 277501; Wed, 23 Feb 2022 16:01:53 +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 1nMu5Q-0004wX-W5 for xen-devel@lists.xenproject.org; Wed, 23 Feb 2022 16:01:53 +0000 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.109.102]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e9bb3574-94c1-11ec-8eb8-a37418f5ba1a; Wed, 23 Feb 2022 17:01:51 +0100 (CET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2106.outbound.protection.outlook.com [104.47.18.106]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-33-LkOjBEtmMImzsigRdtK4dg-1; Wed, 23 Feb 2022 17:01:49 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by DB6PR0401MB2358.eurprd04.prod.outlook.com (2603:10a6:4:51::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.27; Wed, 23 Feb 2022 16:01:47 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65%6]) with mapi id 15.20.5017.022; Wed, 23 Feb 2022 16:01:47 +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: e9bb3574-94c1-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1645632111; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kfo3pz5C0VU61envUYqryzUUTaf8SbibABEgwXmQS1A=; b=To/TDaUDsDXdOYRqaNhhJB/eFoFahlSA/4CgfpvonTKgePSbNyDwwMQw7SKiURpIwc/78d iMVSFvoNuBsFo5iW1AE7rJV3sCDtEowOelgd+BIfwH7PeHnnpT6wZSLYPN+m1dL2zO00bI 7T2wnUWu3k3L+7iLjt2c/W4yIIFsoN0= X-MC-Unique: LkOjBEtmMImzsigRdtK4dg-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fb7R63YCslDyguUIQvOAwRdmtRrETXPnQb83PxVSl9SuaTZwpQZ2W7vunu1iGbdmkn1lhNmVeox/CZkOaFh00yDh1iKgqAzrHi9NydrMrBXnj18vMrQb5/HcWOJ51oNdftKn7/I/G63U9bl344DzD6aoaXzk5mSg/N6dl3g6V97p4UxeExklGV6NOw7JPqGHP20KwNCKQSK7HlhPoCITQve9dpulPywGx7XfAz/spMpS+W+TiLOlUeRN/uh/8r28iKEP1BCMX6fhlZuz0deyNZtbDpAtX4YdajO55XOu8S9mGUoUs3ohHoWLqCcmnqPe41YS8EWoLn/1ClrCg066+Q== 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=kfo3pz5C0VU61envUYqryzUUTaf8SbibABEgwXmQS1A=; b=KBhjcWzUcuyz6mD9aUXDak2WPiyjuBnlmxKPWg07p+C5QKlZSaEJqfJh4BMJ0DuXH9AAjASpZ3Fc8B+YaPs2CpSxbj2kKqRHP8JRp47HWybXI4FxNHLQhqrvrZd0EvVC1LZzbs9GpYJObSnxfwmGDfI7gaVjFdQKFhLAuXv6UXbgFrY6KfWpxgJcc+i5yOqeutBsQVwOBhuEcGx4/UVAA3N6WVl+a21EkY5eNM7+yH1TZzES1mNqrRVzuRJQpoAAiNtB+EQWoJPw1sqocHGccMFGpaswe17YGOvY4huUCm/Dl+26+mliuxxaTDk8N+1uRKHpHz+pzCvWJId01rvooA== 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 Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <88109672-c829-e083-5084-b12fc68ae39b@suse.com> Date: Wed, 23 Feb 2022 17:01:44 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH v2 07/14] x86/P2M: split out init/teardown functions 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 , Kevin Tian , Jun Nakajima References: In-Reply-To: X-ClientProxiedBy: AM6P194CA0069.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:84::46) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 589884bb-04b3-4ada-67af-08d9f6e5cb35 X-MS-TrafficTypeDiagnostic: DB6PR0401MB2358:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RKuZlGQSLig8OeXUsVYkt44fLNwk/yCmIrfvvR01DUzhySt8pnlJe3SzCf1IxuMI2QMu3LWBB0cf6QYschvrg9h7WauquL8R40Y/pCcSwu7O1WoqXwfmroqGDWsF5YfQEycgi40kw9KchxYnhWU2Kr9y5NW0sGUkQ7FUA+EJQwBljcl85wk7+9103jXRKS6uPVG0iip6jegHuQNXhR37S49GjSOxkOy+O61Wj0b4+FVvwN+BZkX8Jy5yEb030G0DcQXlHQnO3H7fpHEIL+YBbuDv6SyOJuEuf5RUUS/M/Ag1ew+Mv1aLQuikPqdlTlhrbUQRx0DoAo/E4YROgUJnq3oh9IZRT1MAG2jSEq/1nDeajWFLkoO10m6skAh1qPK3Xmdh8m9iqyVt6PeEsHOS4tMsFXfmOREFuj3SCv7DJuWxqYHkDFUTCmCONVX5l2YdtymX49vB40DhRglid+2MKMuJ4oeRSzOST0kTE6ZX4p7J2XeEifq/Spkk6ggNYUoWM3BQlhH2Ur2+KAk5ZQMzMHFfhfwNgWk3/ETjnLuF+ZweFVUqxag+i+xYqygpbAUH6v6AT9IQHdZGnN1wf7g2yw8DX/1J1xiO8foQ9mSXZWDkcP6lWTwoB+aynWMyqMVuj2qnawPWSwiKVtnekIJ19o0xGhRopeU5g+cvE7LCSigRzB3OWlKQ888x/qsjAzgBYulWK7CVOkMOq/b9AAVAnzaqDzX2LE9oZ+wdnjIy5ZYKG3LksC7JafxdOMSBuXuP6PJEdNM0b6aRiBkD6iJCgorE6/3vlzytHOiaaUdZUGlTn5E+tgSS0t1dv32C0kcYPvhH4Zq3vzosGor2JtjbTw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(2616005)(6506007)(66946007)(8676002)(5660300002)(6512007)(83380400001)(4326008)(66556008)(186003)(6486002)(66476007)(316002)(26005)(508600001)(31686004)(36756003)(30864003)(54906003)(2906002)(6916009)(31696002)(86362001)(38100700002)(6666004)(8936002)(2004002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?ZIeAgptUJ2l1B7xkG0IpJQVliLME?= =?utf-8?q?qIS0sxiVx9bFOQzbA5WHqEX9g/EpNbM2dMtz+XlC2gZb9z41Qg2Qj63POQhMc5Lfm?= =?utf-8?q?aZLDjTSbcj/gYYe9nU0VBQ2f9Xy+WggiIEhKJUZ/NkD4SkJ1xc8gBjFQ9NkZw8BtR?= =?utf-8?q?d6ZF4BPiwWaIqR9swtz5Zlz4C0WEeyvV9fYHS0kUOfaFTjLKFr8Lw7lhy4UAUJg7P?= =?utf-8?q?Nd2DFfPq6XTxPvg0RrPVyuWm7UqokHMqDVQU+6N0Js9nBt65ZjqU2IvUvhMCpkbZG?= =?utf-8?q?tRl9uIw+pmDHUzDYfTJw87+TfHHY3eik/OrkEbXcFNaNeabSKVEj+fonQ7ZMzks1B?= =?utf-8?q?fd0e2KDeL7KWG7EsDitc+WyKXF1aDPp7J2nSAHL6lu5a+cL6a1i9HmchFaXP8faHH?= =?utf-8?q?MmQ/3vb24uU29LiuqEluICp26Ei5srFQ+AnwvEwU/irdJP9If5m86fXAyzQVrkjnp?= =?utf-8?q?3lU6Pg5UZNdc/veBd6++dJzEd1hezWa2B9KIuveLCFgOAoDFYplsP+TrOh/cel/Yg?= =?utf-8?q?c+sypZhvmxaq7ukqKg+P+TrDSi5tRyRqU6j7J07w/qKV23X+w4bZL73F4wBu7S6HE?= =?utf-8?q?Vm60uurcMSmC1+OcxG8tMoabwyK6OsO217CpBjUz9tha7V73jqaFiz70J8+EQZcxI?= =?utf-8?q?3lyNE0PGLsCgqVs8xBy7fltImNCbtAU0yLxYinj1MLAkag40wtBzNfNwbH681dGu+?= =?utf-8?q?tE72CiM76gkMGO2/zOmiEn6yUU+mDuFYHMnLwinzZctfEv6rKdShorCdqyDwjnCbM?= =?utf-8?q?uvo6cvferz8t1SJVWR77dWxnFM1Io1kSEKSWwHg0ZmU8hwmOoRC0XjlSfYrxqyzJd?= =?utf-8?q?EQyCxDTz8RwsFYM5M4MmBrUFpSoRLKfiwyowSx5N1drVVOj33Y3v1JeqIoYloBc4J?= =?utf-8?q?SCtTCn6d9wz0iX3VupnXFSmr+ziM15Gys5hw7anC3RgrvJzfN9lZD2Zl5X6FQiZ6g?= =?utf-8?q?cvmzQDFZs4oz9UkXjyl5fMV9JYzW9uIvzCB0+aS17PD77+kTBwRaBZd9dZaqAuumT?= =?utf-8?q?SI2LkZcQSlw3jfZqD7AnOTAgJW3gPwT5+s7+0+tkLgCFhrhM/ahY9dDhytkqeOyLk?= =?utf-8?q?K/EuUmasUo1oZ7goePHwFa4cMMJaitO92BY3IXViO1hwF7mWPbEvzKG8aDrDien4k?= =?utf-8?q?dRPLYeI21DW92uK+XL184q5rngVDGxfTB8VUEZ2Neroo3+Y9l1hAmDrSTFV33yu/h?= =?utf-8?q?C00w4svQ525WALb6QyqM4vSC4i4J5cwfiWSa8Hs0Is/DSV2mtXRsJUyU1Q7tBdIM5?= =?utf-8?q?GPhjtX1KuUpQhIT3ZGVpQf5dEyDWNJ313bjnYcWa99dcQSMBr54EJtTXoip1P8rRL?= =?utf-8?q?xfQFk9sqHbbuybDmQLLFt3gvqYdXLmeBNpExi8hT2TJ1VR+EExMKnjXDP7w2jInGU?= =?utf-8?q?LHn+KB19J9B9XF1MLWl0kzB2yDdh9uFHpe7F5LBxe0rtoYuXnztaLUdRyQEYmIq/d?= =?utf-8?q?NQzvw/YW2rfQKjTAeLZpggCsueNyupazh+V/uP8nQOmm4mKW419ghqoh5c8WGZngU?= =?utf-8?q?WytIGPM2WcRT06YqH3tEaoaB6FyniNCW9Iz2FEUy2eKLFwoRt9kO4Pc=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 589884bb-04b3-4ada-67af-08d9f6e5cb35 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2022 16:01:46.8104 (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: xx/eBZ9fyL2DRKznAJZ6Sjjub6W9q0KbPrftzL757t/93pDbtIo+sFd8BmxdSajgj3MlpauhiDx6O/AeodxI2g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0401MB2358 Mostly just code movement, and certainly no functional change intended. In p2m_final_teardown() the calls to p2m_teardown_{alt,nested}p2m() need to be guarded by an is_hvm_domain() check now, though. This matches p2m_init(). And p2m_is_logdirty_range() also gets moved inside the (so far) adjacent #ifdef. Signed-off-by: Jan Beulich Reviewed-by: George Dunlap --- v2: Re-base over wider p2m_add_identity_entry() exposure in earlier patch. --- a/xen/arch/x86/mm/Makefile +++ b/xen/arch/x86/mm/Makefile @@ -7,7 +7,9 @@ obj-$(CONFIG_SHADOW_PAGING) += guest_wal obj-$(CONFIG_MEM_ACCESS) += mem_access.o obj-$(CONFIG_MEM_PAGING) += mem_paging.o obj-$(CONFIG_MEM_SHARING) += mem_sharing.o +obj-$(CONFIG_HVM) += nested.o obj-y += p2m.o +obj-y += p2m-basic.o obj-$(CONFIG_HVM) += p2m-ept.o p2m-pod.o p2m-pt.o obj-y += paging.o obj-y += physmap.o --- a/xen/arch/x86/mm/altp2m.c +++ b/xen/arch/x86/mm/altp2m.c @@ -19,6 +19,8 @@ #include #include #include +#include "mm-locks.h" +#include "p2m.h" void altp2m_vcpu_initialise(struct vcpu *v) @@ -123,6 +125,44 @@ void altp2m_vcpu_disable_ve(struct vcpu } } +int p2m_init_altp2m(struct domain *d) +{ + unsigned int i; + struct p2m_domain *p2m; + struct p2m_domain *hostp2m = p2m_get_hostp2m(d); + + mm_lock_init(&d->arch.altp2m_list_lock); + for ( i = 0; i < MAX_ALTP2M; i++ ) + { + d->arch.altp2m_p2m[i] = p2m = p2m_init_one(d); + if ( p2m == NULL ) + { + p2m_teardown_altp2m(d); + return -ENOMEM; + } + p2m->p2m_class = p2m_alternate; + p2m->access_required = hostp2m->access_required; + _atomic_set(&p2m->active_vcpus, 0); + } + + return 0; +} + +void p2m_teardown_altp2m(struct domain *d) +{ + unsigned int i; + struct p2m_domain *p2m; + + for ( i = 0; i < MAX_ALTP2M; i++ ) + { + if ( !d->arch.altp2m_p2m[i] ) + continue; + p2m = d->arch.altp2m_p2m[i]; + d->arch.altp2m_p2m[i] = NULL; + p2m_free_one(p2m); + } +} + /* * Local variables: * mode: C --- a/xen/arch/x86/mm/mm-locks.h +++ b/xen/arch/x86/mm/mm-locks.h @@ -25,8 +25,6 @@ #ifndef _MM_LOCKS_H #define _MM_LOCKS_H -#include - /* Per-CPU variable for enforcing the lock ordering */ DECLARE_PER_CPU(int, mm_lock_level); --- /dev/null +++ b/xen/arch/x86/mm/nested.c @@ -0,0 +1,74 @@ +/****************************************************************************** + * arch/x86/mm/nested.c + * + * Parts of this code are Copyright (c) 2009 by Citrix Systems, Inc. (Patrick Colp) + * Parts of this code are Copyright (c) 2007 by Advanced Micro Devices. + * Parts of this code are Copyright (c) 2006-2007 by XenSource Inc. + * Parts of this code are Copyright (c) 2006 by Michael A Fetterman + * Parts based on earlier work by Michael A Fetterman, Ian Pratt et al. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; If not, see . + */ + +#include +#include +#include "mm-locks.h" +#include "p2m.h" + +void p2m_nestedp2m_init(struct p2m_domain *p2m) +{ + INIT_LIST_HEAD(&p2m->np2m_list); + + p2m->np2m_base = P2M_BASE_EADDR; + p2m->np2m_generation = 0; +} + +int p2m_init_nestedp2m(struct domain *d) +{ + unsigned int i; + struct p2m_domain *p2m; + + mm_lock_init(&d->arch.nested_p2m_lock); + for ( i = 0; i < MAX_NESTEDP2M; i++ ) + { + d->arch.nested_p2m[i] = p2m = p2m_init_one(d); + if ( p2m == NULL ) + { + p2m_teardown_nestedp2m(d); + return -ENOMEM; + } + p2m->p2m_class = p2m_nested; + p2m->write_p2m_entry_pre = NULL; + p2m->write_p2m_entry_post = nestedp2m_write_p2m_entry_post; + list_add(&p2m->np2m_list, &p2m_get_hostp2m(d)->np2m_list); + } + + return 0; +} + +void p2m_teardown_nestedp2m(struct domain *d) +{ + unsigned int i; + struct p2m_domain *p2m; + + for ( i = 0; i < MAX_NESTEDP2M; i++ ) + { + if ( !d->arch.nested_p2m[i] ) + continue; + p2m = d->arch.nested_p2m[i]; + list_del(&p2m->np2m_list); + p2m_free_one(p2m); + d->arch.nested_p2m[i] = NULL; + } +} --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -35,7 +35,6 @@ #include #include #include -#include /* ept_p2m_init() */ #include #include #include @@ -56,17 +55,9 @@ boolean_param("hap_2mb", opt_hap_2mb); DEFINE_PERCPU_RWLOCK_GLOBAL(p2m_percpu_rwlock); -static void p2m_nestedp2m_init(struct p2m_domain *p2m) -{ #ifdef CONFIG_HVM - INIT_LIST_HEAD(&p2m->np2m_list); - p2m->np2m_base = P2M_BASE_EADDR; - p2m->np2m_generation = 0; -#endif -} - -static int p2m_init_logdirty(struct p2m_domain *p2m) +int p2m_init_logdirty(struct p2m_domain *p2m) { if ( p2m->logdirty_ranges ) return 0; @@ -79,7 +70,7 @@ static int p2m_init_logdirty(struct p2m_ return 0; } -static void p2m_free_logdirty(struct p2m_domain *p2m) +void p2m_free_logdirty(struct p2m_domain *p2m) { if ( !p2m->logdirty_ranges ) return; @@ -88,205 +79,6 @@ static void p2m_free_logdirty(struct p2m p2m->logdirty_ranges = NULL; } -/* Init the datastructures for later use by the p2m code */ -static int p2m_initialise(struct domain *d, struct p2m_domain *p2m) -{ - int ret = 0; - - mm_rwlock_init(&p2m->lock); -#ifdef CONFIG_HVM - INIT_PAGE_LIST_HEAD(&p2m->pages); -#endif - - p2m->domain = d; - p2m->default_access = p2m_access_rwx; - p2m->p2m_class = p2m_host; - - if ( !is_hvm_domain(d) ) - return 0; - - p2m_pod_init(p2m); - p2m_nestedp2m_init(p2m); - - if ( hap_enabled(d) && cpu_has_vmx ) - ret = ept_p2m_init(p2m); - else - p2m_pt_init(p2m); - - spin_lock_init(&p2m->ioreq.lock); - - return ret; -} - -static struct p2m_domain *p2m_init_one(struct domain *d) -{ - struct p2m_domain *p2m = xzalloc(struct p2m_domain); - - if ( !p2m ) - return NULL; - - if ( !zalloc_cpumask_var(&p2m->dirty_cpumask) ) - goto free_p2m; - - if ( p2m_initialise(d, p2m) ) - goto free_cpumask; - return p2m; - -free_cpumask: - free_cpumask_var(p2m->dirty_cpumask); -free_p2m: - xfree(p2m); - return NULL; -} - -static void p2m_free_one(struct p2m_domain *p2m) -{ - p2m_free_logdirty(p2m); - if ( hap_enabled(p2m->domain) && cpu_has_vmx ) - ept_p2m_uninit(p2m); - free_cpumask_var(p2m->dirty_cpumask); - xfree(p2m); -} - -static int p2m_init_hostp2m(struct domain *d) -{ - struct p2m_domain *p2m = p2m_init_one(d); - int rc; - - if ( !p2m ) - return -ENOMEM; - - rc = p2m_init_logdirty(p2m); - - if ( !rc ) - d->arch.p2m = p2m; - else - p2m_free_one(p2m); - - return rc; -} - -static void p2m_teardown_hostp2m(struct domain *d) -{ - /* Iterate over all p2m tables per domain */ - struct p2m_domain *p2m = p2m_get_hostp2m(d); - - if ( p2m ) - { - p2m_free_one(p2m); - d->arch.p2m = NULL; - } -} - -#ifdef CONFIG_HVM -static void p2m_teardown_nestedp2m(struct domain *d) -{ - unsigned int i; - struct p2m_domain *p2m; - - for ( i = 0; i < MAX_NESTEDP2M; i++ ) - { - if ( !d->arch.nested_p2m[i] ) - continue; - p2m = d->arch.nested_p2m[i]; - list_del(&p2m->np2m_list); - p2m_free_one(p2m); - d->arch.nested_p2m[i] = NULL; - } -} - -static int p2m_init_nestedp2m(struct domain *d) -{ - unsigned int i; - struct p2m_domain *p2m; - - mm_lock_init(&d->arch.nested_p2m_lock); - for ( i = 0; i < MAX_NESTEDP2M; i++ ) - { - d->arch.nested_p2m[i] = p2m = p2m_init_one(d); - if ( p2m == NULL ) - { - p2m_teardown_nestedp2m(d); - return -ENOMEM; - } - p2m->p2m_class = p2m_nested; - p2m->write_p2m_entry_pre = NULL; - p2m->write_p2m_entry_post = nestedp2m_write_p2m_entry_post; - list_add(&p2m->np2m_list, &p2m_get_hostp2m(d)->np2m_list); - } - - return 0; -} - -static void p2m_teardown_altp2m(struct domain *d) -{ - unsigned int i; - struct p2m_domain *p2m; - - for ( i = 0; i < MAX_ALTP2M; i++ ) - { - if ( !d->arch.altp2m_p2m[i] ) - continue; - p2m = d->arch.altp2m_p2m[i]; - d->arch.altp2m_p2m[i] = NULL; - p2m_free_one(p2m); - } -} - -static int p2m_init_altp2m(struct domain *d) -{ - unsigned int i; - struct p2m_domain *p2m; - struct p2m_domain *hostp2m = p2m_get_hostp2m(d); - - mm_lock_init(&d->arch.altp2m_list_lock); - for ( i = 0; i < MAX_ALTP2M; i++ ) - { - d->arch.altp2m_p2m[i] = p2m = p2m_init_one(d); - if ( p2m == NULL ) - { - p2m_teardown_altp2m(d); - return -ENOMEM; - } - p2m->p2m_class = p2m_alternate; - p2m->access_required = hostp2m->access_required; - _atomic_set(&p2m->active_vcpus, 0); - } - - return 0; -} -#endif - -int p2m_init(struct domain *d) -{ - int rc; - - rc = p2m_init_hostp2m(d); - if ( rc || !is_hvm_domain(d) ) - return rc; - -#ifdef CONFIG_HVM - /* Must initialise nestedp2m unconditionally - * since nestedhvm_enabled(d) returns false here. - * (p2m_init runs too early for HVM_PARAM_* options) */ - rc = p2m_init_nestedp2m(d); - if ( rc ) - { - p2m_teardown_hostp2m(d); - return rc; - } - - rc = p2m_init_altp2m(d); - if ( rc ) - { - p2m_teardown_hostp2m(d); - p2m_teardown_nestedp2m(d); - } -#endif - - return rc; -} - int p2m_is_logdirty_range(struct p2m_domain *p2m, unsigned long start, unsigned long end) { @@ -298,8 +90,6 @@ int p2m_is_logdirty_range(struct p2m_dom return 0; } -#ifdef CONFIG_HVM - static void change_entry_type_global(struct p2m_domain *p2m, p2m_type_t ot, p2m_type_t nt) { @@ -751,57 +541,6 @@ int p2m_alloc_table(struct p2m_domain *p return 0; } -#endif /* CONFIG_HVM */ - -/* - * hvm fixme: when adding support for pvh non-hardware domains, this path must - * cleanup any foreign p2m types (release refcnts on them). - */ -void p2m_teardown(struct p2m_domain *p2m) -/* Return all the p2m pages to Xen. - * We know we don't have any extra mappings to these pages */ -{ -#ifdef CONFIG_HVM - struct page_info *pg; -#endif - struct domain *d; - - if (p2m == NULL) - return; - - d = p2m->domain; - - p2m_lock(p2m); - - ASSERT(atomic_read(&d->shr_pages) == 0); - -#ifdef CONFIG_HVM - p2m->phys_table = pagetable_null(); - - while ( (pg = page_list_remove_head(&p2m->pages)) ) - d->arch.paging.free_page(d, pg); -#endif - - p2m_unlock(p2m); -} - -void p2m_final_teardown(struct domain *d) -{ -#ifdef CONFIG_HVM - /* - * We must teardown both of them unconditionally because - * we initialise them unconditionally. - */ - p2m_teardown_altp2m(d); - p2m_teardown_nestedp2m(d); -#endif - - /* Iterate over all p2m tables per domain */ - p2m_teardown_hostp2m(d); -} - -#ifdef CONFIG_HVM - static int __must_check p2m_remove_entry(struct p2m_domain *p2m, gfn_t gfn, mfn_t mfn, unsigned int page_order) --- a/xen/arch/x86/mm/p2m.h +++ b/xen/arch/x86/mm/p2m.h @@ -15,8 +15,30 @@ * along with this program; If not, see . */ +struct p2m_domain *p2m_init_one(struct domain *d); +void p2m_free_one(struct p2m_domain *p2m); + void p2m_pod_init(struct p2m_domain *p2m); +#ifdef CONFIG_HVM +int p2m_init_logdirty(struct p2m_domain *p2m); +void p2m_free_logdirty(struct p2m_domain *p2m); +#else +static inline int p2m_init_logdirty(struct p2m_domain *p2m) { return 0; } +static inline void p2m_free_logdirty(struct p2m_domain *p2m) {} +#endif + +int p2m_init_altp2m(struct domain *d); +void p2m_teardown_altp2m(struct domain *d); + +void p2m_nestedp2m_init(struct p2m_domain *p2m); +int p2m_init_nestedp2m(struct domain *d); +void p2m_teardown_nestedp2m(struct domain *d); + +int ept_p2m_init(struct p2m_domain *p2m); +void ept_p2m_uninit(struct p2m_domain *p2m); +void p2m_init_altp2m_ept(struct domain *d, unsigned int i); + /* * Local variables: * mode: C --- /dev/null +++ b/xen/arch/x86/mm/p2m-basic.c @@ -0,0 +1,207 @@ +/****************************************************************************** + * arch/x86/mm/p2m-basic.c + * + * Basic P2M management largely applicable to all domain types. + * + * Parts of this code are Copyright (c) 2009 by Citrix Systems, Inc. (Patrick Colp) + * Parts of this code are Copyright (c) 2007 by Advanced Micro Devices. + * Parts of this code are Copyright (c) 2006-2007 by XenSource Inc. + * Parts of this code are Copyright (c) 2006 by Michael A Fetterman + * Parts based on earlier work by Michael A Fetterman, Ian Pratt et al. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; If not, see . + */ + +#include +#include +#include "mm-locks.h" +#include "p2m.h" + +/* Init the datastructures for later use by the p2m code */ +static int p2m_initialise(struct domain *d, struct p2m_domain *p2m) +{ + int ret = 0; + + mm_rwlock_init(&p2m->lock); +#ifdef CONFIG_HVM + INIT_PAGE_LIST_HEAD(&p2m->pages); +#endif + + p2m->domain = d; + p2m->default_access = p2m_access_rwx; + p2m->p2m_class = p2m_host; + + if ( !is_hvm_domain(d) ) + return 0; + + p2m_pod_init(p2m); + p2m_nestedp2m_init(p2m); + + if ( hap_enabled(d) && cpu_has_vmx ) + ret = ept_p2m_init(p2m); + else + p2m_pt_init(p2m); + + spin_lock_init(&p2m->ioreq.lock); + + return ret; +} + +struct p2m_domain *p2m_init_one(struct domain *d) +{ + struct p2m_domain *p2m = xzalloc(struct p2m_domain); + + if ( !p2m ) + return NULL; + + if ( !zalloc_cpumask_var(&p2m->dirty_cpumask) ) + goto free_p2m; + + if ( p2m_initialise(d, p2m) ) + goto free_cpumask; + return p2m; + + free_cpumask: + free_cpumask_var(p2m->dirty_cpumask); + free_p2m: + xfree(p2m); + return NULL; +} + +void p2m_free_one(struct p2m_domain *p2m) +{ + p2m_free_logdirty(p2m); + if ( hap_enabled(p2m->domain) && cpu_has_vmx ) + ept_p2m_uninit(p2m); + free_cpumask_var(p2m->dirty_cpumask); + xfree(p2m); +} + +static int p2m_init_hostp2m(struct domain *d) +{ + struct p2m_domain *p2m = p2m_init_one(d); + int rc; + + if ( !p2m ) + return -ENOMEM; + + rc = p2m_init_logdirty(p2m); + + if ( !rc ) + d->arch.p2m = p2m; + else + p2m_free_one(p2m); + + return rc; +} + +static void p2m_teardown_hostp2m(struct domain *d) +{ + /* Iterate over all p2m tables per domain */ + struct p2m_domain *p2m = p2m_get_hostp2m(d); + + if ( p2m ) + { + p2m_free_one(p2m); + d->arch.p2m = NULL; + } +} + +int p2m_init(struct domain *d) +{ + int rc; + + rc = p2m_init_hostp2m(d); + if ( rc || !is_hvm_domain(d) ) + return rc; + + /* + * Must initialise nestedp2m unconditionally + * since nestedhvm_enabled(d) returns false here. + * (p2m_init runs too early for HVM_PARAM_* options) + */ + rc = p2m_init_nestedp2m(d); + if ( rc ) + { + p2m_teardown_hostp2m(d); + return rc; + } + + rc = p2m_init_altp2m(d); + if ( rc ) + { + p2m_teardown_hostp2m(d); + p2m_teardown_nestedp2m(d); + } + + return rc; +} + +/* + * Return all the p2m pages to Xen. + * We know we don't have any extra mappings to these pages. + * + * hvm fixme: when adding support for pvh non-hardware domains, this path must + * cleanup any foreign p2m types (release refcnts on them). + */ +void p2m_teardown(struct p2m_domain *p2m) +{ +#ifdef CONFIG_HVM + struct page_info *pg; +#endif + struct domain *d; + + if ( !p2m ) + return; + + d = p2m->domain; + + p2m_lock(p2m); + + ASSERT(atomic_read(&d->shr_pages) == 0); + +#ifdef CONFIG_HVM + p2m->phys_table = pagetable_null(); + + while ( (pg = page_list_remove_head(&p2m->pages)) ) + d->arch.paging.free_page(d, pg); +#endif + + p2m_unlock(p2m); +} + +void p2m_final_teardown(struct domain *d) +{ + if ( is_hvm_domain(d) ) + { + /* + * We must tear down both of them unconditionally because + * we initialise them unconditionally. + */ + p2m_teardown_altp2m(d); + p2m_teardown_nestedp2m(d); + } + + /* Iterate over all p2m tables per domain */ + p2m_teardown_hostp2m(d); +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -35,6 +35,7 @@ #include #include "mm-locks.h" +#include "p2m.h" #define atomic_read_ept_entry(__pepte) \ ( (ept_entry_t) { .epte = read_atomic(&(__pepte)->epte) } ) --- a/xen/arch/x86/include/asm/hvm/vmx/vmx.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmx.h @@ -594,15 +594,11 @@ unsigned int vmx_get_cpl(void); void vmx_inject_extint(int trap, uint8_t source); void vmx_inject_nmi(void); -int ept_p2m_init(struct p2m_domain *p2m); -void ept_p2m_uninit(struct p2m_domain *p2m); - void ept_walk_table(struct domain *d, unsigned long gfn); bool_t ept_handle_misconfig(uint64_t gpa); int epte_get_entry_emt(struct domain *d, gfn_t gfn, mfn_t mfn, unsigned int order, bool *ipat, p2m_type_t type); void setup_ept_dump(void); -void p2m_init_altp2m_ept(struct domain *d, unsigned int i); /* Locate an alternate p2m by its EPTP */ unsigned int p2m_find_altp2m_by_eptp(struct domain *d, uint64_t eptp); From patchwork Wed Feb 23 16:02:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12757154 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 DAEADC433F5 for ; Wed, 23 Feb 2022 16:02:59 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.277510.474037 (Exim 4.92) (envelope-from ) id 1nMu6K-0005hh-8b; Wed, 23 Feb 2022 16:02:48 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 277510.474037; Wed, 23 Feb 2022 16:02:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nMu6K-0005ha-5a; Wed, 23 Feb 2022 16:02:48 +0000 Received: by outflank-mailman (input) for mailman id 277510; Wed, 23 Feb 2022 16:02:47 +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 1nMu6J-0004uA-8j for xen-devel@lists.xenproject.org; Wed, 23 Feb 2022 16:02:47 +0000 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.111.102]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 0a9503e7-94c2-11ec-8539-5f4723681683; Wed, 23 Feb 2022 17:02:46 +0100 (CET) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03lp2054.outbound.protection.outlook.com [104.47.9.54]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-8-UhdHrXFQPNGFmR2seDZxmA-1; Wed, 23 Feb 2022 17:02:45 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by DBBPR04MB6156.eurprd04.prod.outlook.com (2603:10a6:10:cd::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.27; Wed, 23 Feb 2022 16:02:43 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65%6]) with mapi id 15.20.5017.022; Wed, 23 Feb 2022 16:02:43 +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: 0a9503e7-94c2-11ec-8539-5f4723681683 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1645632166; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W6vAYToK8QO3swRu/19GKo63qRHFt41aiy10HV87R7U=; b=FKtt+k/mt/W+HNiCn7IqiNH/mvosaAO0HkT6eWGF+gI3PTZZDpnP85jOD/gac/qvNi+lZW T+ZVPiWq2VSNfOdnd1mMfyN33bLItT3TWGabeve+rQVemnuRlcbO3LYIyG7srQiZbHks7H A2r7L8XINSNXVCkq+DYZsVv+lt5OkYM= X-MC-Unique: UhdHrXFQPNGFmR2seDZxmA-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lE4M7Y/E/EP4dRAhwGVx8/HAqVZLMIdBfzh7Mjn73NQPOCKJX6BDq7NC3euvsWkcOwmW5KoYv7CkEKMnMc43qqz+QrnqxWV6nfOr4dNxLz4b+DZZWTq46++M7ywXhV5GyYL7eniXhlRv5pTgg2c7CHvO7koqLguMMqtg1EOfoLhSyJlayKp6xwQ96vsoQfEIvXnpu4BvZfA0867nyfYKRhaqB5LOWB0vOohh4K7cN7RUjyHfk+919pe5d9ajPyTsBAXlgSBRIou0QjiE3u3BwgPUJOEJHKAC/rclBFX7A94BneWZiNcCHOeChpKw7JENVNqaLm0oVuOzpl/0J3scEw== 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=W6vAYToK8QO3swRu/19GKo63qRHFt41aiy10HV87R7U=; b=anDDHc1VaUb5kZu1bNmewLVkzc8jAVze05qw7bfD3BZADPX4sSWrEMOR3ftTqbl99nvIyIHdvVWgDAO8hIgCLvTmje0WWJrdAdQJoMe7iMPrvhL+qPrB4gdjk/lu6cWQcYDiCN6sBdOMhBwyy18GHG3ElXk1AMXRjlO9k/G/F3Dgzn34vuBlSwjrVjwb6ltr1V+qy5XUaMWyqO0/2lqGIz5Fxpewb2yYP/Cnj2rtOtfIU8EiMbCv8rcHlgnlrm8wJfOvds6ZGywnAZMbLmdzSUXyR4KZ4C13Sw9Cry4M/aYsknq/o0+GaZ6uZAOufhYsRZceW0to5DWVqMDC3es6Xg== 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 Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <04b5ed35-ba53-a0d5-3583-a474f7d08c06@suse.com> Date: Wed, 23 Feb 2022 17:02:40 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH v2 08/14] x86/P2M: p2m_get_page_from_gfn() is HVM-only 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 References: In-Reply-To: X-ClientProxiedBy: AS8PR04CA0108.eurprd04.prod.outlook.com (2603:10a6:20b:31e::23) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 102f8c07-b6a1-4031-99a6-08d9f6e5ecb9 X-MS-TrafficTypeDiagnostic: DBBPR04MB6156:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AklIItO4QQvKgTTeBw0ZzGpv/xr35tCmmrbmra+xRNjeyaL1RX925QaO8wWp93JWLYGD/GI95oFMtWSeOcNWE2CwpO3UCpdVUJhydtpbSc9CSVUNlR+OWIx7jnS4o7EqQetL56z48n58Eo7F6/koREEmPou2EQoWU2q3us9iWtN4bvD1YpdW2TcMRxfldYPVYxKprlbWYfaPRbYZinJT7YKzzDEK/Q9X8jNkqrKpP1q1SX93GMj661F0MKMGujbzgcA2hCdGQuSGu3MBP4N+8LS23OtR2kPZRjKZ0YAbJa99a4jZKZZdIYG3kJRRCr/pGdeCbL8fHxyTIakqppH0GA9iJXYguUNynKFQYiuj07rLOb05kMNS8imllH3vg9V8AJOF6UVY+SIbzz8P5btiUcQmXrckoUgVfpT46BilGnSuMZy4IEMVcdEE3nZzaPwLJW8tfU3eo1ajnZsLLElvFwBsVz0EHJ1YM5qYtC89opGcXxQmJMwM4IteaPgPNbl8S0/rllQInRtYzzRIS0YlHihmHVwtFM5o57NLyTvi/YnKq84nF1VhPbtZj2KXiaNKoq9citnVrRiocF0Hom/PSNCZ8JlJ+xMdybkjiRFatC4IjsWjSvQ36JEGdF6AsNvGrnPK0GTZR4hZLbn8AHUymA/+LqOd/nu+Vi353Eesj2sHmebMS5U3I0h+VdtAoLmfy3E3xkuFtBq3AV9qendC6hQ3RE/BKCm5JQXtcKr2FfZ19P9S8Ec7XYTYf+UIT9yu X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(36756003)(6506007)(2616005)(6486002)(508600001)(31686004)(6512007)(2906002)(38100700002)(66556008)(66476007)(4326008)(5660300002)(54906003)(6916009)(8936002)(26005)(8676002)(316002)(31696002)(86362001)(186003)(83380400001)(66946007)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?GdK3DShCqi2VGoAWwlX9zS0YPxxm?= =?utf-8?q?E//Z02PHG3VZJ8p0c76fbQBS3MaeFxh6ZXaZVlKPNsZzluyH87N5i4U2sFQBylQUn?= =?utf-8?q?eXKBm+i6M/KeKuxC3fzpCxU2XA2eY/Y9DgSX32vezN8orlMh3snC6jmdUJPoltgOX?= =?utf-8?q?04Ri7ClfIFc5tldTKtAM78xxeXbwEjS8gClGXwLNWYtsGHjrsZYl1BX7U460ybAIr?= =?utf-8?q?O1MbIGBATAhP6DOP9uvbZAvtA7noAX4Bwkk5G0hZYV2bqJ8ummDEgECk6M0gEL1Ut?= =?utf-8?q?KIyn9uZXrsQeS2YESFqwxE0NBYHNp0vk43HD7tLg1f55uXvyTzVu5bKZapBzbCYCW?= =?utf-8?q?tTeqGCES6ipRG2R+t/QDKSPJhd21ztpdx/SLWKXDixaL/a/NJfJPIa4ZHtvWT8ksk?= =?utf-8?q?6dWfdAn8e3y4NEBFx6+27uMmnr84z/05Ws8zjeqtrnSV2SpFk2OPdDmTH3xhwT2S3?= =?utf-8?q?itb6Y1ECbYy2oerwCwM6Swc+8ZOgAvF5iDzwrefuq7EWC3tPq004JO2ULpCBDGzSU?= =?utf-8?q?l1JARkbOMlGTWvG+M6uzqUG2AhxaY+sWoQyozM+znyZfU0Dv9QAXdkGJ9DJh25Q3Z?= =?utf-8?q?MuNCXw0RHhDs8mk9/S7pQLabhUFgoI0c+q5LtR6Gw1px7uorhnqnmev3nEyGZam2k?= =?utf-8?q?ilhaHCZKAukKuw3U/dJLMAPZNxcE0hM7e9ANo6eNSDajS7PfvEz6pM3Lnh07aPrW7?= =?utf-8?q?o+d7q6cYmFD68gBYA8rLw2Umm/L2BonlMTUnIjPfrPoMGsIeA69klpyJ6a7xSt6lj?= =?utf-8?q?wBhvqhImezDsEcz2a01rM8k84BksKTEKRJnLDUHgb1dHr69UwdrpUsqgBISjvLX1X?= =?utf-8?q?s4vgJNymx5IlJSDh3A/1PhnerYv9hDi93C5N1tkqY8TJoPSAGnIaZok/4CMPlP5bR?= =?utf-8?q?1QRZcTysQdpR6zDt7y7l3oWrDL9xN8gGz77Je6WhidLsmkL2JUryUicwfJpBj32HG?= =?utf-8?q?ypC7Tdi4p1WIDy5fwywIXvQYG5lED+G5vYdHE3TsLUVD0GkGAX4W2Ek7Z3HjBJ3tx?= =?utf-8?q?9LNSTnmG1Ml7WkJ1rfBuUVZmzE1cnvXiBbAAljJxRh2HEyRelIFhZf8Kl9b6diw22?= =?utf-8?q?5A8hRKREZ+nTW4dHSASLdvVdN5Sof9ypJ+nOxFZZ3x+MGOmU7+ZVVAHy+7Wmca4wD?= =?utf-8?q?XINaG872Ss51z/htPXjs0ApI7o5oNgpt/PqREcc8qP+c6upfsy4+M+O+aUciuZJ4U?= =?utf-8?q?gnWkmm+fIJM2GuhmrVK5vMsRxm8tnoSaKyLj7QvHf1KenerdUuFWl4CvI++wOm65D?= =?utf-8?q?7HXBvJ0UZXoE8/Vt8vfVNiCuixRlyDbM5q5nazNHeIU9WdrhrPnpy6TZPMv2wRmKK?= =?utf-8?q?Rvl0FhvdQw64gJ7EApW/LzF4L8roGXuGzM1U9ZITWfS/BQpFmAIwU8v1R/ZQSQUXJ?= =?utf-8?q?NdjVa6azVGhUAuLkBITQg0mMkrOMOmPZhrV/gvW66h0fBVFkaOAdTL2RxJCkEZaO8?= =?utf-8?q?JZ0XdQMGTCoG3nN+TxIrcJa6EP5yBLQupIHOOZ+oDsH6pULB3dZyJOMlwdq/KaeO1?= =?utf-8?q?g3Sh/BqRyef0KQCKo8jtpn4EjbsX7e3MYGh29J4sQ144/W9EYCbJNXY=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 102f8c07-b6a1-4031-99a6-08d9f6e5ecb9 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2022 16:02:43.0415 (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: d7r7BMLJVeBVTuOyTEHvE65g7wqLrA2T3jp2n7795gWI9ZpKJYqUgcqJtnXvhHieD6KoWE77fspG5YZnxy9DZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB6156 This function is the wrong layer to go through for PV guests. It happens to work, but produces results which aren't fully consistent with get_page_from_gfn(). The latter function, however, cannot be used in map_domain_gfn() as it may not be the host P2M we mean to act on. Signed-off-by: Jan Beulich Reviewed-by: George Dunlap --- a/xen/arch/x86/mm/guest_walk.c +++ b/xen/arch/x86/mm/guest_walk.c @@ -551,7 +551,9 @@ void *map_domain_gfn(struct p2m_domain * } /* Translate the gfn, unsharing if shared. */ - page = p2m_get_page_from_gfn(p2m, gfn, &p2mt, NULL, q); + page = paging_mode_translate(p2m->domain) + ? p2m_get_page_from_gfn(p2m, gfn, &p2mt, NULL, q) + : get_page_from_gfn(p2m->domain, gfn_x(gfn), &p2mt, q); if ( p2m_is_paging(p2mt) ) { ASSERT(p2m_is_hostp2m(p2m)); --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -357,6 +357,8 @@ void __put_gfn(struct p2m_domain *p2m, u gfn_unlock(p2m, gfn, 0); } +#ifdef CONFIG_HVM + /* Atomically look up a GFN and take a reference count on the backing page. */ struct page_info *p2m_get_page_from_gfn( struct p2m_domain *p2m, gfn_t gfn, @@ -422,8 +424,6 @@ struct page_info *p2m_get_page_from_gfn( return page; } -#ifdef CONFIG_HVM - /* Returns: 0 for success, -errno for failure */ int p2m_set_entry(struct p2m_domain *p2m, gfn_t gfn, mfn_t mfn, unsigned int page_order, p2m_type_t p2mt, p2m_access_t p2ma) From patchwork Wed Feb 23 16:03:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12757155 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 D19F0C433EF for ; Wed, 23 Feb 2022 16:03:42 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.277518.474047 (Exim 4.92) (envelope-from ) id 1nMu6z-0006Kv-Mw; Wed, 23 Feb 2022 16:03:29 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 277518.474047; Wed, 23 Feb 2022 16:03:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nMu6z-0006Kn-JQ; Wed, 23 Feb 2022 16:03:29 +0000 Received: by outflank-mailman (input) for mailman id 277518; Wed, 23 Feb 2022 16:03:28 +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 1nMu6y-00064O-AZ for xen-devel@lists.xenproject.org; Wed, 23 Feb 2022 16:03:28 +0000 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.111.102]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 22e118cd-94c2-11ec-8eb8-a37418f5ba1a; Wed, 23 Feb 2022 17:03:27 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2175.outbound.protection.outlook.com [104.47.17.175]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-40-MZVb_loDP-adKvBNPFmRnA-1; Wed, 23 Feb 2022 17:03:26 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB6335.eurprd04.prod.outlook.com (2603:10a6:803:f9::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.27; Wed, 23 Feb 2022 16:03:24 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65%6]) with mapi id 15.20.5017.022; Wed, 23 Feb 2022 16:03:23 +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: 22e118cd-94c2-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1645632207; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ldFCmhVgf2hohYtDOIo5qnNRmC9eRJje8GLGX9RkTuY=; b=Y8yGCLBwNj02hEid5RUUJ2DraOdirHDFEt3emNUBautuNIDO3RsA4QiQUPKKgBQGyrD8Tv g8bZPosCPJVO0ADjdbjVxR1MqkBsDsqJHNyw3hMVInfxHpqYAEXYxHAcKN+Lxm73ZY9Zec Tb86FWYjIcVPFwvLLL+wwssypxV7iu8= X-MC-Unique: MZVb_loDP-adKvBNPFmRnA-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dPkIcQVyhHbPH9XYk++KieGKiHzaI2VGt7PWwB0Xo2sOQp0Vg2MW0O48bJAHGRDq0W8UnTOOkFSk+4xOek0aFYHymD47Qq0WpGD1MCjoHXfmzvP+v/g51Mv+X/DWh3O2gPCrgR7uhc9l88onX8Qon7D4/BSDdHAXce78qCyTjuCgbLqiSYbGwcFF5e8TkEtA96qXqIin1dtq40+jjp/Xv8q91xMJa/4cw4XGkjYuMGEJyL04c7spmZBSbnDEgvGDk8fxADP3n6FjdNYu16hc3JSkQb6k39L0Ojc2YK1Ccv/vxrwb9o7BexjdNVuqNaioiuT5Lwscokkz4RUWRm7+oQ== 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=ldFCmhVgf2hohYtDOIo5qnNRmC9eRJje8GLGX9RkTuY=; b=CDotKA3uMoCbkamW6h1Yzkv8IV94uw3fORH99R18nQA1tSr8a1c7aljXSZGrgp0HGsJVcVdp6QCczQuVVQvjy4LkS/MeakY2sbQJtT2XF/9A9TPV/hytrtKEhHCFbmBox/e6EKiVDIcGuHIjKj3xCcRvdH5jPPqhSlLvn25YRQuuDzXq1jp4Gcj0B5j5D/tOyqmFg7Vc9x/7tASqPteHDu8tpOoKzPdJIZKRGXER//UYn1/InhERQtLDfiHuyfShr7CNcEWXuptNK6HI17xkZvONgllu4azhhcCVRsTsFsbdosZE/nKwqefkcGtTB8dx4hMdhC2bhhawXEZ4wu5tew== 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 Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <12673497-72ca-3b24-f35f-0d93c645e11b@suse.com> Date: Wed, 23 Feb 2022 17:03:22 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH v2 09/14] x86/P2M: derive HVM-only variant from __get_gfn_type_access() 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 , Tamas K Lengyel References: In-Reply-To: X-ClientProxiedBy: AM6P192CA0107.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:8d::48) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 27f82c7a-3633-4bfd-e1e7-08d9f6e60513 X-MS-TrafficTypeDiagnostic: VI1PR04MB6335:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1xXFtTr9vmZ42FxJeDi5QwVUnyn3nWp2oGd7DqdzoRAOJoZ/cj9c1gvEPHZFsQqE5K0It6OB42FjY7n/ABaxtvNnF1OudbR5aMhODuvt2rlOMNw3J1AM9bQprViy2ItxEh1GzSnMy+HmjmDcqFteJ3NvQsAbCRSiysiekxSBMqac2fU0q8Rmj1FiLXDYEaF7WEfY118S7YyhPwh4XE9esW4bbYfM3H4xxyn8cbW16Oe8mpg/w6cqmiYvPguQS+rYpjkNyby0LYF78mYbfB95gJMMYC8WsRmMdYFk0y+LFnvhK0GkHHhUu8L5vWku6DhtnejFYzaf0WZWO/gef6X+O/CMwf40oa8bZqR11xYMTkrxlGpLUi/ZSreu7mF58S/U7k7tW07k6Fq7EyYonVkBFMU/8jtKEPZuhTT1fKUQMwOHzOyl6oF43mosteTBLY/YiMQpZIoAj/A8IzZRLn2iqsjMoh4nIR2i+ghjNd+8DOJ7jI9j5XAgiSVloTYiteX3dxS42FXujGU5V0rBPGblozjGCyLiyThpypuY1kvDrXa+F03J92L6JcYbiQ2Cr4bSLYF6qmqZ1pGB+HCkfSgm3qAPo9MMns+FRnPxTZ9W6aNBOcxGBYmhiJD2nigmE4FYNdnVNuDtVPBCU1kWRlKsmEnWw1ctfyGkk5zBEF9peDdvxRBrF98atSdaAVVWWUAUPp8QJt4Mnz+0uobY7rEu0RGWUy9Yg750tFa/SIXHh8EHpyfDGgskp6rwHhsMMKOw X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(31686004)(66476007)(54906003)(6916009)(66556008)(66946007)(83380400001)(4326008)(36756003)(8676002)(508600001)(6486002)(6506007)(86362001)(186003)(31696002)(26005)(5660300002)(2906002)(8936002)(316002)(2616005)(6512007)(38100700002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?lmULjVDoEH/ZYkTowL+9vf2CaFJf?= =?utf-8?q?BKzUEAqPiIxR6unX9ESmyKbMxRqM2HN3FKJysOeS+uz/CykQ++hnTXQiVj193tKhL?= =?utf-8?q?TDtZK/pY0BwFXW30Ux4eh6BLEdM492X9SQzGyYRx3mK1stCz4pP72zpbJQDjVPdT1?= =?utf-8?q?XJ6dXuszsCKsX0Q2Iqt6dTV8SwVDwRQ985JmAWcJiswNH0BhulsVruXrXSuHNuIyh?= =?utf-8?q?Q0cFjr81Pt5XXMswFhht48bqGE3s+P/BoVCxstNv6R1e2AxXmdPIjv9Po5l6w08eo?= =?utf-8?q?OL5QS5Y9cfmZdqk4uLU3GQDTDpyFa7iD7yH8kP647emL1ywA+zdt6EBu0U2O5Uanu?= =?utf-8?q?JV07S9C4bjv+yNS+EZJIf+qc1A55vNsfR5sRJl9XS8VvqtnNtrodAQxXdWHFeW+L1?= =?utf-8?q?lTN927ozW/FTyX9hbezE73v7tgVq6OmYumy2i2wrkGgJUNDrkED4Vh/oSUr2CLp4K?= =?utf-8?q?h3JBDRXBAiKZC62XI4MUWNkY8e0NlDZ8T5un0FjJp6WTUReeB8Mfl8jxsVUaywzdD?= =?utf-8?q?LtL/nBQmqTXO1/LojUdP48zN86mMPwc/PSpAGGtjSZ6EWp+3p9jvL1AnjZ7rOJbGW?= =?utf-8?q?bp0ajCw/AW0+MiXSoyTIeJ3ROkelIt7ietBqB/lOTyYqRiV/IadG2B4Fk73sPTLst?= =?utf-8?q?uoKyKgN/1GwRiuW+6246mAN76ym4sz//VqV9eSnzawQB1BecF7Pjg3kMAP587eZM+?= =?utf-8?q?oDF/9VJFs1IuPX4x23aenrgZ++dRhxXXvX0MgdltMtHvpMYvd1sQKsN75NCVWwawM?= =?utf-8?q?01u4dcOPdz2vk8TTnkrjy4DKN2lG/AH3fVlXTeWaefGaJaCBzoxs7cBFINd0JO+PE?= =?utf-8?q?w+unUUYO5usS7mloCBnJ/Zpy4Xa3sUl5G6l+bYIp7Ev1fXXzwBLB+qoBEIseU4Al8?= =?utf-8?q?qZGqFdMRWABahAX3ABgCltEx0fge+ZU12e+RYX8gZyscbQU2Gr9WAMaz+iH9cvTM+?= =?utf-8?q?mtIOs95ni3fp6hzHruuBho819XRdZb3NTpNyboWOahvSZFwbmlogZQ5xWfwiy5ca9?= =?utf-8?q?PST6x5cpNdCfPdN448+OTMQ8WizhlMLrUTkm11wd3uTbbX1B13ubzXqdMOARJCM91?= =?utf-8?q?d1X069BTvl333Dre4vm89uNuK3LXVLbOszpYqnfHDVwllYNDIHuRSKky+e54EXcRq?= =?utf-8?q?Kr6UbIXrMljUAu9LkCHt9aNLYsAQBj9SkofO/xF+LJ7ghSrE732vT3A16mLjESDfh?= =?utf-8?q?4SeEgOnSdlqwVpkQWKOv+lccJFniRwK8g5E4t3C4u8yHhlebV//ndShgaFwOfKNae?= =?utf-8?q?CKewCyR8xIgjPJJ85JSeE42iesPlnQc8J0ifXDgDDkJCaZYyVvTJZ7xai9usKu3Ws?= =?utf-8?q?2UXr1g4yPbhcEUIaEE/jGSJn5Oyjj8D539ubpOOJk6pfdjDln//+ZrshJeiqr/MZo?= =?utf-8?q?hR8CRS/NWKxzTYPzBcq1DuBkkD7NpzgpIFC5uWcoNAy+U324fUEXEsXBCyox5naHF?= =?utf-8?q?ICgtG2YrBlX1B4uXgOL4glgH08hJYQ6f5CMEsRqWjIwHXoBAa0043dTwcu2onxVP3?= =?utf-8?q?VCoziwpuB9YSxrcksu6g2Ev7lMxgJKosIScFz/HNM80EJn0KwyNhO5o=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 27f82c7a-3633-4bfd-e1e7-08d9f6e60513 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2022 16:03:23.8985 (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: bv0YSkwOPcVrPb5WpNy1OlcqjHLeK6v8WJwM/IfCXUCm7tL9tL4Tf/F9FD5SjEfkxHDuJ2DIvnX1bhCCaebNLA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6335 Introduce an inline wrapper dealing with the non-translated-domain case, while stripping that logic from the main function, which gets renamed to p2m_get_gfn_type_access(). HVM-only callers can then directly use the main function. Along with renaming the main function also make its and the new inline helper's GFN parameters type-safe. Signed-off-by: Jan Beulich Reviewed-by: George Dunlap --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1716,7 +1716,7 @@ static void svm_do_nested_pgfault(struct } _d; p2m = p2m_get_p2m(v); - mfn = __get_gfn_type_access(p2m, gfn, &p2mt, &p2ma, 0, NULL, 0); + mfn = p2m_get_gfn_type_access(p2m, _gfn(gfn), &p2mt, &p2ma, 0, NULL, 0); _d.gpa = gpa; _d.qualification = 0; @@ -1741,7 +1741,7 @@ static void svm_do_nested_pgfault(struct if ( p2m == NULL ) { p2m = p2m_get_p2m(v); - mfn = __get_gfn_type_access(p2m, gfn, &p2mt, &p2ma, 0, NULL, 0); + mfn = p2m_get_gfn_type_access(p2m, _gfn(gfn), &p2mt, &p2ma, 0, NULL, 0); } gdprintk(XENLOG_ERR, "SVM violation gpa %#"PRIpaddr", mfn %#lx, type %i\n", --- a/xen/arch/x86/include/asm/p2m.h +++ b/xen/arch/x86/include/asm/p2m.h @@ -459,10 +459,27 @@ void p2m_unlock_and_tlb_flush(struct p2m * After calling any of the variants below, caller needs to use * put_gfn. ****/ -mfn_t __nonnull(3, 4) __get_gfn_type_access( - struct p2m_domain *p2m, unsigned long gfn, p2m_type_t *t, +mfn_t __nonnull(3, 4) p2m_get_gfn_type_access( + struct p2m_domain *p2m, gfn_t gfn, p2m_type_t *t, p2m_access_t *a, p2m_query_t q, unsigned int *page_order, bool_t locked); +static inline mfn_t __nonnull(3, 4) _get_gfn_type_access( + struct p2m_domain *p2m, gfn_t gfn, p2m_type_t *t, + p2m_access_t *a, p2m_query_t q, unsigned int *page_order, bool_t locked) +{ + if ( !p2m || !paging_mode_translate(p2m->domain) ) + { + /* + * Not necessarily true, but for non-translated guests we claim + * it's the most generic kind of memory. + */ + *t = p2m_ram_rw; + return _mfn(gfn_x(gfn)); + } + + return p2m_get_gfn_type_access(p2m, gfn, t, a, q, page_order, locked); +} + /* Read a particular P2M table, mapping pages as we go. Most callers * should _not_ call this directly; use the other get_gfn* functions * below unless you know you want to walk a p2m that isn't a domain's @@ -474,7 +491,7 @@ static inline mfn_t __nonnull(3, 4) get_ struct p2m_domain *p2m, unsigned long gfn, p2m_type_t *t, p2m_access_t *a, p2m_query_t q, unsigned int *page_order) { - return __get_gfn_type_access(p2m, gfn, t, a, q, page_order, true); + return _get_gfn_type_access(p2m, _gfn(gfn), t, a, q, page_order, true); } /* General conversion function from gfn to mfn */ @@ -515,7 +532,8 @@ static inline mfn_t get_gfn_query_unlock p2m_type_t *t) { p2m_access_t a; - return __get_gfn_type_access(p2m_get_hostp2m(d), gfn, t, &a, 0, NULL, 0); + return _get_gfn_type_access(p2m_get_hostp2m(d), _gfn(gfn), t, &a, 0, + NULL, 0); } /* Atomically look up a GFN and take a reference count on the backing page. --- a/xen/arch/x86/mm/mem_access.c +++ b/xen/arch/x86/mm/mem_access.c @@ -299,8 +299,9 @@ static int set_mem_access(struct domain { p2m_access_t _a; p2m_type_t t; - mfn_t mfn = __get_gfn_type_access(p2m, gfn_x(gfn), &t, &_a, - P2M_ALLOC, NULL, false); + mfn_t mfn = p2m_get_gfn_type_access(p2m, gfn, &t, &_a, + P2M_ALLOC, NULL, false); + rc = p2m->set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, t, a, -1); } --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -478,12 +478,12 @@ do { #undef assign_pointers /* Now do the gets. */ - *first_mfn = __get_gfn_type_access(p2m_get_hostp2m(rval->first_domain), - gfn_x(rval->first_gfn), first_t, - first_a, q, NULL, lock); - *second_mfn = __get_gfn_type_access(p2m_get_hostp2m(rval->second_domain), - gfn_x(rval->second_gfn), second_t, - second_a, q, NULL, lock); + *first_mfn = p2m_get_gfn_type_access(p2m_get_hostp2m(rval->first_domain), + rval->first_gfn, first_t, + first_a, q, NULL, lock); + *second_mfn = p2m_get_gfn_type_access(p2m_get_hostp2m(rval->second_domain), + rval->second_gfn, second_t, + second_a, q, NULL, lock); } static void put_two_gfns(const struct two_gfns *arg) @@ -936,8 +936,8 @@ static int nominate_page(struct domain * if ( !ap2m ) continue; - amfn = __get_gfn_type_access(ap2m, gfn_x(gfn), &ap2mt, &ap2ma, - 0, NULL, false); + amfn = p2m_get_gfn_type_access(ap2m, gfn, &ap2mt, &ap2ma, + 0, NULL, false); if ( mfn_valid(amfn) && (!mfn_eq(amfn, mfn) || ap2ma != p2ma) ) { altp2m_list_unlock(d); --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -286,25 +286,13 @@ void p2m_unlock_and_tlb_flush(struct p2m mm_write_unlock(&p2m->lock); } -mfn_t __get_gfn_type_access(struct p2m_domain *p2m, unsigned long gfn_l, - p2m_type_t *t, p2m_access_t *a, p2m_query_t q, - unsigned int *page_order, bool_t locked) -{ #ifdef CONFIG_HVM - mfn_t mfn; - gfn_t gfn = _gfn(gfn_l); - if ( !p2m || !paging_mode_translate(p2m->domain) ) - { -#endif - /* - * Not necessarily true, but for non-translated guests we claim - * it's the most generic kind of memory. - */ - *t = p2m_ram_rw; - return _mfn(gfn_l); -#ifdef CONFIG_HVM - } +mfn_t p2m_get_gfn_type_access(struct p2m_domain *p2m, gfn_t gfn, + p2m_type_t *t, p2m_access_t *a, p2m_query_t q, + unsigned int *page_order, bool_t locked) +{ + mfn_t mfn; /* Unshare makes no sense without populate. */ if ( q & P2M_UNSHARE ) @@ -329,8 +317,8 @@ mfn_t __get_gfn_type_access(struct p2m_d * Try to unshare. If we fail, communicate ENOMEM without * sleeping. */ - if ( mem_sharing_unshare_page(p2m->domain, gfn_l) < 0 ) - mem_sharing_notify_enomem(p2m->domain, gfn_l, false); + if ( mem_sharing_unshare_page(p2m->domain, gfn_x(gfn)) < 0 ) + mem_sharing_notify_enomem(p2m->domain, gfn_x(gfn), false); mfn = p2m->get_entry(p2m, gfn, t, a, q, page_order, NULL); } @@ -343,9 +331,10 @@ mfn_t __get_gfn_type_access(struct p2m_d } return mfn; -#endif } +#endif /* CONFIG_HVM */ + void __put_gfn(struct p2m_domain *p2m, unsigned long gfn) { if ( !p2m || !paging_mode_translate(p2m->domain) ) @@ -377,7 +366,7 @@ struct page_info *p2m_get_page_from_gfn( { /* Fast path: look up and get out */ p2m_read_lock(p2m); - mfn = __get_gfn_type_access(p2m, gfn_x(gfn), t, a, 0, NULL, 0); + mfn = p2m_get_gfn_type_access(p2m, gfn, t, a, 0, NULL, 0); if ( p2m_is_any_ram(*t) && mfn_valid(mfn) && !((q & P2M_UNSHARE) && p2m_is_shared(*t)) ) { @@ -1775,8 +1764,8 @@ int altp2m_get_effective_entry(struct p2 unsigned int page_order; int rc; - *mfn = __get_gfn_type_access(hp2m, gfn_x(gfn), t, a, - P2M_ALLOC | P2M_UNSHARE, &page_order, 0); + *mfn = p2m_get_gfn_type_access(hp2m, gfn, t, a, P2M_ALLOC | P2M_UNSHARE, + &page_order, 0); rc = -ESRCH; if ( !mfn_valid(*mfn) || *t != p2m_ram_rw ) From patchwork Wed Feb 23 16:03:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12757164 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 B6776C433EF for ; Wed, 23 Feb 2022 16:04:08 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.277524.474059 (Exim 4.92) (envelope-from ) id 1nMu7Q-0006qC-06; Wed, 23 Feb 2022 16:03:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 277524.474059; Wed, 23 Feb 2022 16:03:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nMu7P-0006q3-Sm; Wed, 23 Feb 2022 16:03:55 +0000 Received: by outflank-mailman (input) for mailman id 277524; Wed, 23 Feb 2022 16:03:54 +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 1nMu7O-0006oT-F4 for xen-devel@lists.xenproject.org; Wed, 23 Feb 2022 16:03:54 +0000 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.109.102]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3277c14a-94c2-11ec-8539-5f4723681683; Wed, 23 Feb 2022 17:03:53 +0100 (CET) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-ve1eur02lp2050.outbound.protection.outlook.com [104.47.6.50]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-25-EznRuw0VMlmRQgSV7fuLvg-1; Wed, 23 Feb 2022 17:03:52 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by AM0PR04MB5921.eurprd04.prod.outlook.com (2603:10a6:208:123::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.21; Wed, 23 Feb 2022 16:03:50 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65%6]) with mapi id 15.20.5017.022; Wed, 23 Feb 2022 16:03:50 +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: 3277c14a-94c2-11ec-8539-5f4723681683 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1645632233; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gz3zvRiEWYkf7LDrZ0GXIkTScZJf9PYhQI0iXwQf+w8=; b=KgJjdGIXL4Y/4HqVXyis53AGeWBnx8I6lJ+uzdMqZ6YUjib0UBvHK5m159Ln9SHmABCOEy 8l8/LVBSOCJJxvarZ1TUeZ8HZX01JqtB07SCpWj44cg2/KvHqh6JFcrUIRGr7JPu+NWfby Tb/aaWAUURlgALumGmFUBz8QwF8sdUQ= X-MC-Unique: EznRuw0VMlmRQgSV7fuLvg-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NHG+aAk22uie8LA+AXU1k0xkPThoEL6+363srUsCo3+pRU/s06yUo+AvUOWaKE0Rus7xAAF3qt5d7/X0LcKpVr/csfwTwpTVwNezxJoUf1UxH6ImX+TVUSQNXLc+vQe5dwVnXRT3x6LUShz00WKfuPYsxRg2esMnWbL/RcTSdtwvheTGtgJXP2Iy9NivDRUJcH9+LQWHs2jHlL8UHb7Q0V++BuwpgfS2cLfAycfr3Vt58gpkl7Yidq78B7UqtIsHQBVFq7Zm2wr+vmVk1xXUU5rAy6DuP/EsaE6nCsRQcz5W3xK5veGQrqBMBz/rrI1YGmIHb9FxUFGh6to48mVs7g== 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=gz3zvRiEWYkf7LDrZ0GXIkTScZJf9PYhQI0iXwQf+w8=; b=Gqv+/s9ev9P7wC2KGShPWjxCmG8ITGhN9zrV8Hcsq5TmDD3esuKlJfK7VM+EfJQAxhSwLtKVJNUyy4leoUoP17BiGISFsldEDnaHPOoYG+w2rb4nsFucURLZAy3MLxQFCNADKs/ZI5d2hS7tsPX2bw68fbpov3bfHpIQDBKSlCVUVTtlagHMwTgwAWc58vWYKKevBZU5b5pWC8dJeKYwuDvt9NIYNcBFQkNuuUSe1VqMb1OiVM9ZJBesdIjEofpS0ygVdzjkTbHlDhbeifplPhnpOlD+Sx/M3rBjTdL0qIOvhnhoIG1HFK+Ya+jLFO3XoIVRyFkqKTzRftxRSeoIxw== 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 Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <7834a4ea-3b39-5557-28ce-138084f21c31@suse.com> Date: Wed, 23 Feb 2022 17:03:49 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH v2 10/14] x86/p2m: re-arrange {,__}put_gfn() 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 References: In-Reply-To: X-ClientProxiedBy: AS9PR05CA0030.eurprd05.prod.outlook.com (2603:10a6:20b:488::24) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1576fe68-b70f-4874-d2d6-08d9f6e6151a X-MS-TrafficTypeDiagnostic: AM0PR04MB5921:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l2N0jbVMnd3qfjhrZ8PdCAVEgki6jQy4PX8x7Zdp7pDmYCznJEcWZpIU/wsHbc/agfaHg2uoue6havCBpkctuvwG4Snfz5CPEXzKFos9vLbpm4EGCV2AfuxzEQZIOJutCrfIPAJ72ql43G1Xd9FX8cIKQdyl9Fh5UmJJRbJDzBykp65PbGZLhHlZxNP+O/jk4s/I/VnW0KqVexVCHFIa942VL/Wa2MRGbu049zDxXzAS0KU7FC4pY783r/Xp6E/rxzrSJPM73lXw3P3aKxJU8QsN/0McCRhBRnyR/pTifBb7n9g98BGJeB+s+juw154BErVZgsGx6XdKohKH8vo8vwVVVTFMc77WuA8ciJjhZ3wBjk/q0usmjcYThhhW6/K6tZRiz4YtoDoE2TvdXYx66VQIG6Yj27PP6W3hBZneCs8bR/prgPOetwA2vcLoV3tj878a+Go/AelF7DigQFq4BED8HBaBLa7VPDV9pipeOGix467SoS8dKY3+KCG+eLSaava3yIEsUDneqwFBJjVbU7czxOaJduHpfnx2e4eNuic68LQfXK/37EphcTGYJDIoHOxTlhiLkNzHNe94ERfXw57sUUj7wc+yqFtDhAOV2uiCilo1J8FODQqUDV82zrHPU9jN97gDGzyo0Llb7HSXqxYCxl0pXbn7MjZdKaVrzK0xf7XUOJyaV+jjJUeNgxzofa0WzGqm/hjCbijmuXkuXuH8lerVCOqVIhpEFEoaoIrY+8NZ99uZLbA3SiaEzD4c X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(316002)(31686004)(2906002)(8936002)(5660300002)(66476007)(6486002)(66946007)(36756003)(8676002)(66556008)(83380400001)(4326008)(6916009)(54906003)(186003)(6506007)(26005)(2616005)(86362001)(38100700002)(31696002)(6512007)(508600001)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?oaYITsbMHdY2QTGkEO5EPgDKiCsE?= =?utf-8?q?316xWepLLvsLoUPU/drEyKV5ViXRZt2HzsZM5lxJwwdPWTLZEqqha8RUoFsSPXMok?= =?utf-8?q?aYuLwGJxfCOTqdv+a+VUqyHHHneyBmoiVrx09viZ5UpqvrOmbLBRnQ+E6p11IXtYt?= =?utf-8?q?w68ZsGG8xMg3TFgrUkOXZcjcdaJWi9wFNLQE19x2jRLBFi3GZzNPEX2zKXATXRJU0?= =?utf-8?q?pYtjUk6no3Oqoc8MKSlrKfujiNRrsheRHtF548Y3dN/JeQM2Cosv1Y4ZW9Z4bV2hd?= =?utf-8?q?akRO494msTfuAwZHXv+ITTxewufDqiu6Sgdd9cgSbfQfo99Bspqd7sgwtROSyRNzx?= =?utf-8?q?It3lanaOQqTb89z2srtH2n7sHxLYG9RtF9G9AuUa8STpPxzR3olcgBHXIxWP5jnGv?= =?utf-8?q?/LU8qcsWU2ISd9mPChOnS87eyIxpt2rvYsL5HWtPiZHeRWPud+XKMLi8r7Apv8MCx?= =?utf-8?q?VYiRsJvBDBfukSl4j/WQSb0yjz+4r2dB+ereajP64UtXJ/57a0Y+kIztE3XHFQFxR?= =?utf-8?q?Zia7YtlT9erGUTH+YkRGxrkgKQmxJhQ0cvXX1+srs2X4Jii7oKLuN6x7QZGZpXs2U?= =?utf-8?q?VccGqxS6ni/tEgTvJL4ySrH+qt9RMVk70VgYvTbj5heCEKmAJuptYcqBfxP2XJ6tw?= =?utf-8?q?Ik4nx3ofI+UbkUUfA6a97ujovyVdh8vYOrdvVD3//RKRtuTzkFvSrLFzmB+htSQKy?= =?utf-8?q?zzVs5GCm1iDPN0NwvI4RzhJKoQJl9lWhMgLOwJggQqOJ6iAr2oYsGKLdIJoCs/+Fj?= =?utf-8?q?aZnd2zxTrxVsf6wBZTdUi75T7YBcT1EsF5rgYDwwtOXOoxNPtK29nCOWpPiq9fGRm?= =?utf-8?q?ruGRYOAGZOVkIL9a23HSPO/k2Hs8c+YXUZ9Trd34cZZ9USN5h0Hs1HjSPHN1YVjOl?= =?utf-8?q?u3SqEgEurs38ADhltM52H1Dfm57JvMe5I9Jq4v3x+GErRvUx/VbBrB254hqFof8Fq?= =?utf-8?q?gWqf4TW3LQ5BdAM81ELF2n7jOh0fMxtrSDw0/cOXvP1OAJSKwhtFomuLWYTlNwdzd?= =?utf-8?q?MNC3mC5GZ4fjTzMQgiOmEnWA8N8odocsxuHOiyh+VUjmD/GQVboiQoN2QLLKA3vXi?= =?utf-8?q?hH8n8B67leeqryP7J1S4a5xG3iAsM57kgFVOIRkxB0qY14KY5sATz9UV066TPxPbh?= =?utf-8?q?Egbg05pkdS6a0nISlG9V+d1WsRIFs82ncFdd10YJsqbgcqdUGI823yOdVBRISlUzk?= =?utf-8?q?GUzYIaGeLHP1KsKI8mb2HrbfYSXHZnuzYIQe1PoFRZJus3muAjryXZ0w0nsJ+GH7l?= =?utf-8?q?RsxhKufLwxsyM1rbmTjf02WJQ/uVKOcKitmsgcFNcUNnKA36LohFfo4wKv3GTERQd?= =?utf-8?q?DTYnBc+GM8Q0CePwW3ezCPk2tRykBEgVamIZ/42627EeQ0HqgxkNi+/udl8uiH4lp?= =?utf-8?q?GiJatyoMwW0oxf3Rt/lN0a0EEXZnBx3VElLf/A7wv4mgGSLE3KfFnA0BGd7Oq1sSV?= =?utf-8?q?6L2H56VEzZkugsE1W+befpvXPZTWZd1pPrz/bujqSaZYvOlOZSXsc6PdaVipjAYJo?= =?utf-8?q?FSRZVmwUzuZn56baCCOySLa0AErDia4IWw6ywJmwGo6oNzQ/i7YJ5p4=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1576fe68-b70f-4874-d2d6-08d9f6e6151a X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2022 16:03:50.7719 (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: FkRqybpzQRugmbY06uaPz1s3s73T8g6aRoIM/nxeu/1TFN3wHufwfjDcOAKBw3Z1bUcVT6kapoq/NQ3mOcY9kw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5921 All explicit callers of __put_gfn() are in HVM-only code and hold a valid P2M pointer in their hands. Move the paging_mode_translate() check out of there into put_gfn(), renaming __put_gfn() and making its GFN parameter type-safe. Signed-off-by: Jan Beulich Reviewed-by: George Dunlap --- v2: Re-base over XSA-388 follow-up. --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1955,9 +1955,9 @@ int hvm_hap_nested_page_fault(paddr_t gp * altp2m_list lock. */ if ( p2m != hostp2m ) - __put_gfn(p2m, gfn); + p2m_put_gfn(p2m, _gfn(gfn)); p2m_change_type_one(currd, gfn, p2m_ram_logdirty, p2m_ram_rw); - __put_gfn(hostp2m, gfn); + p2m_put_gfn(hostp2m, _gfn(gfn)); goto out; } @@ -1979,8 +1979,8 @@ int hvm_hap_nested_page_fault(paddr_t gp out_put_gfn: if ( p2m != hostp2m ) - __put_gfn(p2m, gfn); - __put_gfn(hostp2m, gfn); + p2m_put_gfn(p2m, _gfn(gfn)); + p2m_put_gfn(hostp2m, _gfn(gfn)); out: /* * All of these are delayed until we exit, since we might --- a/xen/arch/x86/include/asm/p2m.h +++ b/xen/arch/x86/include/asm/p2m.h @@ -509,9 +509,16 @@ static inline mfn_t __nonnull(3) get_gfn P2M_ALLOC | P2M_UNSHARE) /* Will release the p2m_lock for this gfn entry. */ -void __put_gfn(struct p2m_domain *p2m, unsigned long gfn); +void p2m_put_gfn(struct p2m_domain *p2m, gfn_t gfn); -#define put_gfn(d, gfn) __put_gfn(p2m_get_hostp2m((d)), (gfn)) +static inline void put_gfn(struct domain *d, unsigned long gfn) +{ + if ( !paging_mode_translate(d) ) + /* Nothing to do in this case */ + return; + + p2m_put_gfn(p2m_get_hostp2m(d), _gfn(gfn)); +} /* The intent of the "unlocked" accessor is to have the caller not worry about * put_gfn. They apply to very specific situations: debug printk's, dumps --- a/xen/arch/x86/mm/hap/nested_hap.c +++ b/xen/arch/x86/mm/hap/nested_hap.c @@ -149,7 +149,7 @@ static int nestedhap_walk_L0_p2m( direct_mmio_out: *L0_gpa = (mfn_x(mfn) << PAGE_SHIFT) + (L1_gpa & ~PAGE_MASK); out: - __put_gfn(p2m, L1_gpa >> PAGE_SHIFT); + p2m_put_gfn(p2m, gaddr_to_gfn(L1_gpa)); return rc; } --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -333,21 +333,13 @@ mfn_t p2m_get_gfn_type_access(struct p2m return mfn; } -#endif /* CONFIG_HVM */ - -void __put_gfn(struct p2m_domain *p2m, unsigned long gfn) +void p2m_put_gfn(struct p2m_domain *p2m, gfn_t gfn) { - if ( !p2m || !paging_mode_translate(p2m->domain) ) - /* Nothing to do in this case */ - return; - - ASSERT(gfn_locked_by_me(p2m, gfn)); + ASSERT(gfn_locked_by_me(p2m, gfn_x(gfn))); - gfn_unlock(p2m, gfn, 0); + gfn_unlock(p2m, gfn_x(gfn), 0); } -#ifdef CONFIG_HVM - /* Atomically look up a GFN and take a reference count on the backing page. */ struct page_info *p2m_get_page_from_gfn( struct p2m_domain *p2m, gfn_t gfn, @@ -2201,7 +2193,7 @@ int p2m_altp2m_propagate_change(struct d else { /* At least 2 altp2m's impacted, so reset everything */ - __put_gfn(p2m, gfn_x(gfn)); + p2m_put_gfn(p2m, gfn); for ( i = 0; i < MAX_ALTP2M; i++ ) { @@ -2225,7 +2217,7 @@ int p2m_altp2m_propagate_change(struct d ret = rc; } - __put_gfn(p2m, gfn_x(gfn)); + p2m_put_gfn(p2m, gfn); } altp2m_list_unlock(d); @@ -2310,7 +2302,7 @@ void audit_p2m(struct domain *d, * blow away the m2p entry. */ set_gpfn_from_mfn(mfn, INVALID_M2P_ENTRY); } - __put_gfn(p2m, gfn); + p2m_put_gfn(p2m, _gfn(gfn)); P2M_PRINTK("OK: mfn=%#lx, gfn=%#lx, p2mfn=%#lx\n", mfn, gfn, mfn_x(p2mfn)); From patchwork Wed Feb 23 16:04:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12757165 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 6F41FC433F5 for ; Wed, 23 Feb 2022 16:04:49 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.277531.474069 (Exim 4.92) (envelope-from ) id 1nMu86-0007Wx-C0; Wed, 23 Feb 2022 16:04:38 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 277531.474069; Wed, 23 Feb 2022 16:04:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nMu86-0007Wq-8t; Wed, 23 Feb 2022 16:04:38 +0000 Received: by outflank-mailman (input) for mailman id 277531; Wed, 23 Feb 2022 16:04:37 +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 1nMu85-00064O-10 for xen-devel@lists.xenproject.org; Wed, 23 Feb 2022 16:04:37 +0000 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.111.102]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4bee537c-94c2-11ec-8eb8-a37418f5ba1a; Wed, 23 Feb 2022 17:04:36 +0100 (CET) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04lp2052.outbound.protection.outlook.com [104.47.13.52]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-16-ST5p_GrHNC20dxGWWejDcQ-1; Wed, 23 Feb 2022 17:04:34 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by DB3PR0402MB3803.eurprd04.prod.outlook.com (2603:10a6:8:e::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19; Wed, 23 Feb 2022 16:04:32 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65%6]) with mapi id 15.20.5017.022; Wed, 23 Feb 2022 16:04:32 +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: 4bee537c-94c2-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1645632275; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c0HTObp3YJHfE/uo6Cw54yUOSGjrcQcQ2DoP9QPbuT4=; b=MzfkmX9mSAA8fG2Kk7xA9vQkN+R+/1dd/a6dbeVWIocd11KNYQlfJv50+n6x2nGPB2iQaS BlWulrb7USHOhbe/6nuI6wFwJRTk/Cb2TEpZZJQ3IxW5Lbmw5EYJcab+UBnA//vc8vYMSz InFCN4BZ5+HaJSNI63ObtChHDphTA1s= X-MC-Unique: ST5p_GrHNC20dxGWWejDcQ-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DnoGcvjpGOCw2/KNiC75fZjWsUL6EVBZdVidcg6OXrpMjR44lVZovtzTBYIKe8ghYoVnMmA3c7b1APMJlZNiFfv6LhSYwfjdVhcP61Kp++sTrHh4DG0EVQOrXX/8A3MSGl14wEknZeDrKXrEPahNOCHBLdUTRqBDYkQG+CAs5ejclkpwMn1J6Wc0DwiXBtieTxjLj1Q1cR0I2mcEx6+PD+7OiKcSexznqA0mVw0JQBZN0NQU+c3/uanwatWsqjw8OmBg1FZq3aRymjdH8naLBbgB8t1xif/BQ2OXXOCqvvWb5tAoxFTXDaQqNslXcu6s+kCRr/cPuCnFinGKmRplPw== 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=c0HTObp3YJHfE/uo6Cw54yUOSGjrcQcQ2DoP9QPbuT4=; b=WrDHh2h4pIv+lDQzuL9521foq7aOShXKvDvQQ7k0Lke7Fb5dLEQEoUJvjc0ymn6z7riHpgeQrvabgZ0YbeocnDEuJLG5rday55b6oyAR+TvUQV9rlsMr2o8myEIPzRX2znj8jdh69mOnuozb0fdNTWxKiJvMdfWu48HRus+3AgsycY7SttjmBs5yQIqkVyeDRgDYYoN1BQGbxcZZzl3YtgiF3hwBbyOiz0uJXinUFi9TVHa1IvrDtH3gdkhunC5sSuAkEQpwJdpbwD1C/mJE4eiOBsn1AATIEvmHFuogM77Fmq4EwRgAeH3Iv7cwWGc61HT0HP+jcDmRtJoIYrRY4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Wed, 23 Feb 2022 17:04:30 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH v2 11/14] shr_pages field is MEM_SHARING-only Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Andrew Cooper , George Dunlap , Julien Grall , Stefano Stabellini , Wei Liu References: In-Reply-To: X-ClientProxiedBy: AM7PR02CA0012.eurprd02.prod.outlook.com (2603:10a6:20b:100::22) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4e192341-4fe7-4004-4c74-08d9f6e62dec X-MS-TrafficTypeDiagnostic: DB3PR0402MB3803:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s6lpIxStBEmhwTnParHSK0fvUq/209veCbXgl6W7GoQzqCfpW7AHe/VqjoW++6twYKwiGnlO/8OThFbI1sCMj19BF+PVAMp0Cz4bpIrtxsp017m8cD4FlxJQa32yg3UWwbCy4O9/z4MsRDQjpyH06YJbHHSEN+35wRJAjur2GaoyALQTC+8OYmuUFHCkKPSGCoXtQANsMBNkrAmJYVJu43I5Aio/a1pJCUdLIn2qiwWl8EXt5rZgAbyjnoZSjivGxGSnn4FPDO5VdjNCoClG2wTLXWdAsYQMSkIQ2G1HKJtQDpwyh7X6UMGjErT/T1c7CMfJylF4K4Uycrclaux+lN2FAMhE1DQYsSODVWkN2zX0dVSFtihn7RyfD5Juj/YPvyDnQOjlZVjGseZ2fi59oiaEAwXr3Adrx2+oTZBLtQ5Uwq8Ols1mR5p0/u6/CBIMnXTS9U6LluenR6E0By9LyEz9YMvz1dbUaA4P29BRwt2Xh+PhfC97j33asvjiaKl+mtWnIOJx6iIthvfu6YXdkcoXNWS9+GCN5XoiwU1KUWXhGSuMIj3qPKXhGyz3hiv8r/eKhYwW/rcAeGarCHNjlKpUy4uKm/60yhlYkWqpeMWD4cItKaRWA/fqtTE26QVzLy1nrMIktf4xC3VyMFBB4cuzTTih8is6B7EdnuXOgXRLBxtW1GKnPEEvzXxRTOAW/90N1y8pRRC3kQwH9+/TzbFFD8nD/pMOQ7lTcB1eHF87hF1ObqhRUtmr8JdCzzMd X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(6512007)(66476007)(8676002)(6916009)(6506007)(31686004)(86362001)(8936002)(31696002)(6486002)(316002)(66556008)(508600001)(66946007)(26005)(5660300002)(36756003)(83380400001)(4326008)(38100700002)(186003)(2906002)(54906003)(2616005)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?VDz+C7ZTFbfQvEjUpvL6rECRC3W2?= =?utf-8?q?4jzY0qDXdN4on6/gRjYFsUGvGw2TGX+s0ziAntfPnMROyLJ7MfZZfs95ghqw5MVOx?= =?utf-8?q?KcV0MzAKx26a01jCKX9g1xZhIyJdsyvrS8UmoRy0WZxPWfYH/OlOcAUQtLvOGgb5b?= =?utf-8?q?aFPzdCH2xjePgpsvedwzeQhqAiKzlscnEauGh/CxLkhuqEOcaPximsz0ByfhU9u+/?= =?utf-8?q?1nsQxBkEjI9c/WaBi7h6S9PCWyGy0sptQIHkBa8NI26FlXNFhKNu+bs6DrFbqh79m?= =?utf-8?q?lLcwORW7chd+D9lUgEMDUyM5w+IYF8xKst+0E6kHnmZ2yG/LqC4RM+MqhruHp+7Ka?= =?utf-8?q?FQnTjSbCA3eebvahquGM6y3xs5ZA9QHCexX1MAI+KRz5a/vWmNheC6deA6AB14VZ0?= =?utf-8?q?BieyoId+ggJ4nm2gD1JE4t1R7TnEOeM4ieeYqJfPF/XtUAvonY4qJ//s0qNV7lgQF?= =?utf-8?q?Qa7AiHRJe/VYwA71w/Ub1wnf8ccNkfotmbzeH+emMTyw90qadWnvD489ijhMniUbE?= =?utf-8?q?ffx1cIg2RtiHNr2vtVwesNlNKllJh6WmGXZtOMmQ9lWKK7PKp1gfeCAH6NrQcNUHc?= =?utf-8?q?GCMSgMLwwV91+tYMrqMIB4ZFqryIX8oUE1EBp4WU1e2OEwxQnSpl4BvUs+/dQZa82?= =?utf-8?q?E/shGD58p3YfHpflF1UWa6G/g0gZuBtCc8jrDgzhGOa0C6IvK9pDXLjEJVIOPLtYz?= =?utf-8?q?MCBcQe2DXDbFYaKON7hD+KBjM+J5dUQr9tTKJkMSM8Hb9AJrV1AHP0s72NndxVIq9?= =?utf-8?q?viNrLUwUn7QtXgEGTDzhqk/JufE4XYxuW3HDX4iAjEuWeEOBFZMOjek+39n2+qA2m?= =?utf-8?q?+WNsBX+sWQaMtnI8K0jdcpiihpU8bWgs/1nkGcrBBVT8R7T/OrqMhZ2/P9wZqn81c?= =?utf-8?q?DJ7J7qhjQlc+xbskAn4WcC/0m7QEbF1BabGwNGVjlca+OFaVDThYPhRpsvLPxyGs8?= =?utf-8?q?wo7Ao+AqC1l44/ZwvNUAJuyLMA8WzVbHg9LRVf6G1FdRBNmYkfg28SCFE0fDh5NuT?= =?utf-8?q?pYQn50JJC8cOCy1b/lxPsNgcvPCbRwrKNDQClqobWKwzBQ5w4xFB/AW01YYvhC3RJ?= =?utf-8?q?sTXlbH+/3GsRT6lCmviA/sMagrs7KhJZDE/3d3VxeTsOvUHMvx/8XQjk4uznxceEE?= =?utf-8?q?rnuvYvhGFlqJ3wLe/F5I4U6S6urcklNgpPnd68RLUabMqj9tcS7HmTxNWemnzwrIJ?= =?utf-8?q?7ZEOn53kDVubmOLI8SM6XU2Euo8QJAFUCSJEWKeZ7MSg73brXXe3Likzfn78HpxGz?= =?utf-8?q?zvE+EIoIVqSsxJsW7jvTnNZqN+MH+kRovf5x1VtoGKjNipGtDFLv9kNFYsLfr/U4B?= =?utf-8?q?DeKKjzeAb+ZPFcaaTjkamPjT7qY53tOJs9RlQRZ675OxMN3WhMDMdJFKfNMTjsWJY?= =?utf-8?q?aRfytif+yOfashMT7hSrhvU05UZlUx2UKdaQbVI/jwm7RlbjjHX2ZiGJOElNyg5su?= =?utf-8?q?e3C/agGu4thX+yXcuy4O05SyPM8NB+xVsiu7cpIPYpmNB0kbpua8i42xqfICnGATf?= =?utf-8?q?S+bUmZlruR1zVS5c19hMgjHQ9fAGyH8pMQOpuodnSObfiXDRXIcGwyg=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e192341-4fe7-4004-4c74-08d9f6e62dec X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2022 16:04:32.4413 (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: SFyDBtjzEiPkhQH2+gxfHn/6ZS3qcSPMmWf/RP3QWkaND0RL/lodLlhzTxqsOG/uMfOC2bNjJ5JHhfrzYszpqg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0402MB3803 Conditionalize it and its uses accordingly. The main goal though is to demonstrate that x86's p2m_teardown() is now empty when !HVM, which in particular means the last remaining use of p2m_lock() in this cases goes away. Signed-off-by: Jan Beulich Reviewed-by: Tamas K Lengyel Reviewed-by: George Dunlap --- I was on the edge of introducing a helper for atomic_read(&d->shr_pages) but decided against because of dump_domains() not being able to use it sensibly (I really want to omit the output field altogether there when !MEM_SHARING). --- a/xen/arch/x86/mm/p2m-basic.c +++ b/xen/arch/x86/mm/p2m-basic.c @@ -159,7 +159,6 @@ void p2m_teardown(struct p2m_domain *p2m { #ifdef CONFIG_HVM struct page_info *pg; -#endif struct domain *d; if ( !p2m ) @@ -169,16 +168,17 @@ void p2m_teardown(struct p2m_domain *p2m p2m_lock(p2m); +#ifdef CONFIG_MEM_SHARING ASSERT(atomic_read(&d->shr_pages) == 0); +#endif -#ifdef CONFIG_HVM p2m->phys_table = pagetable_null(); while ( (pg = page_list_remove_head(&p2m->pages)) ) d->arch.paging.free_page(d, pg); -#endif p2m_unlock(p2m); +#endif } void p2m_final_teardown(struct domain *d) --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -109,7 +109,9 @@ void getdomaininfo(struct domain *d, str info->tot_pages = domain_tot_pages(d); info->max_pages = d->max_pages; info->outstanding_pages = d->outstanding_pages; +#ifdef CONFIG_MEM_SHARING info->shr_pages = atomic_read(&d->shr_pages); +#endif info->paged_pages = atomic_read(&d->paged_pages); info->shared_info_frame = gfn_x(mfn_to_gfn(d, _mfn(virt_to_mfn(d->shared_info)))); --- a/xen/common/keyhandler.c +++ b/xen/common/keyhandler.c @@ -274,9 +274,16 @@ static void dump_domains(unsigned char k printk(" refcnt=%d dying=%d pause_count=%d\n", atomic_read(&d->refcnt), d->is_dying, atomic_read(&d->pause_count)); - printk(" nr_pages=%d xenheap_pages=%d shared_pages=%u paged_pages=%u " - "dirty_cpus={%*pbl} max_pages=%u\n", - domain_tot_pages(d), d->xenheap_pages, atomic_read(&d->shr_pages), + printk(" nr_pages=%u xenheap_pages=%u" +#ifdef CONFIG_MEM_SHARING + " shared_pages=%u" +#endif + " paged_pages=%u" + " dirty_cpus={%*pbl} max_pages=%u\n", + domain_tot_pages(d), d->xenheap_pages, +#ifdef CONFIG_MEM_SHARING + atomic_read(&d->shr_pages), +#endif atomic_read(&d->paged_pages), CPUMASK_PR(d->dirty_cpumask), d->max_pages); printk(" handle=%02x%02x%02x%02x-%02x%02x-%02x%02x-" --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -385,7 +385,11 @@ struct domain unsigned int outstanding_pages; /* pages claimed but not possessed */ unsigned int max_pages; /* maximum value for domain_tot_pages() */ unsigned int extra_pages; /* pages not included in domain_tot_pages() */ + +#ifdef CONFIG_MEM_SHARING atomic_t shr_pages; /* shared pages */ +#endif + atomic_t paged_pages; /* paged-out pages */ /* Scheduling. */ From patchwork Wed Feb 23 16:05:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12757166 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 DA85AC433F5 for ; Wed, 23 Feb 2022 16:06:03 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.277542.474081 (Exim 4.92) (envelope-from ) id 1nMu9E-0008E6-MZ; Wed, 23 Feb 2022 16:05:48 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 277542.474081; Wed, 23 Feb 2022 16:05:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nMu9E-0008Dz-JY; Wed, 23 Feb 2022 16:05:48 +0000 Received: by outflank-mailman (input) for mailman id 277542; Wed, 23 Feb 2022 16:05:47 +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 1nMu9D-0008Dl-Qp for xen-devel@lists.xenproject.org; Wed, 23 Feb 2022 16:05:47 +0000 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.111.102]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 76017dca-94c2-11ec-8eb8-a37418f5ba1a; Wed, 23 Feb 2022 17:05:46 +0100 (CET) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04lp2053.outbound.protection.outlook.com [104.47.13.53]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-34-aLZRpbzcPm-R-iu9EkuZDQ-1; Wed, 23 Feb 2022 17:05:45 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by DB3PR0402MB3803.eurprd04.prod.outlook.com (2603:10a6:8:e::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19; Wed, 23 Feb 2022 16:05:43 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65%6]) with mapi id 15.20.5017.022; Wed, 23 Feb 2022 16:05:43 +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: 76017dca-94c2-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1645632346; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9KYg7EGIpsPMfdCGhpfXXPnI+8C1a2jFdZUo/dNcjvI=; b=UdaPDpzPKhozyJIW2OBIUqw+4pt5NQLgJjXMjRDy1LORQyEU5IUOOToN+gW5fDi1Xfutxr 5jyAmfboeqYsVuZWuxaqIrBW5vhWjqQ/nZrHQ8j8BgK6oWCKEQVyD88Y+2Ff2dkzo1+eHf Wi8LWsbQSHN6evMm8LSUHs0M3cMC7lk= X-MC-Unique: aLZRpbzcPm-R-iu9EkuZDQ-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cNz5jjzW1OhytF9f2xN0YITudhK29hMyD0g4CBatFM3ux5Wi8JLbRl1fqODTN4w6wz+9th/9vjg2Ty0uP7+kWMont1ZOqABatZjJabcaNLE0z6ByDcSk/4G88zgIYepj3FGwnE4uEo8cxhld1jOM2PziC3QXq0LsiUOnIn3CuFSWRd0yrtxI1BRTJsNW6Oz6G/eDcKY48O+PGGDk2Rchp5dZDwxbgAdzWvwOkLSHC1nyY1Vl094rKaFEQWnR6f/8YazyyRVuGiP4TNxKzuEcuUu/rAOC/xQfukeobK6bM0WaehFRqbzYeIhGj9flLxXDp+OGhBu1WKl81B7/cok4hQ== 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=9KYg7EGIpsPMfdCGhpfXXPnI+8C1a2jFdZUo/dNcjvI=; b=Wj5z+y3xarQOXN9BLfIcEie3N6ZzT56TE2Ora/Et7o7aCalvGVRVkGNtPZe2FUPLDLvKLrfh/bspFzhTSET6bOwUIWtXfa94WuAwgwNORyjlQ0mDsyIDx0eIlr+dfl4kdhtufDvAxB+LURyLknRS1IeCK1R0n1JRA8IQf9P6v57o6XHkbDKAmMATiOzpyOIa4lFSu+Df62GVcHtstClAtHPprAtKp9XJu2b70cBG4+pV5x5olmjRooKiRkToa5kfR5xXvsSrbromP6EsiXWGEG5ZtYIl5GWAqaM8XGuvvZGe7sRfq6B/KW2JgYs5GEJAVii/Q/OlBqMKXhHO4OycNg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Wed, 23 Feb 2022 17:05:41 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH v2 12/14] paged_pages field is MEM_PAGING-only Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Andrew Cooper , George Dunlap , Julien Grall , Stefano Stabellini , Wei Liu References: In-Reply-To: X-ClientProxiedBy: AS9PR06CA0251.eurprd06.prod.outlook.com (2603:10a6:20b:45f::28) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 92ff817d-7971-4327-2449-08d9f6e65861 X-MS-TrafficTypeDiagnostic: DB3PR0402MB3803:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pVWyEOGGrTZ2tSpsOHz0mMAuDpkyRIXV2wOEaBPLi3EVORr69LZiGcP0WPOHzXSRYj+c6lT8hxgrmTlpd/hyFqU0SUsUnvaGdS3ND+35FdOwiCIdKRsJh7pjUM8SdGKvU7hWuPJdtB4/SyL0Y4pQ0aQSqDjHI478oToo0JAsH370/l0rfNRrZDeOcDBAWEkxbu1hkuI4ORONffl59YXzb3yQ6SP95C9dkzJzSqXcagMqm4kA3cXehcROB4QEpeFtz8lBVQk20ef8zlZOPbsWOggUJC4pZqkN31ocJWVvty/jaXIVdXEbWGg1HjnlsSSb6tXOZgCYt+afnULyezpRvvW9iw5tloTctRPCcPesonRMfrSlL+OHIDdKYBsNMJMGWp1HaJW9Pcn3KYqw2Oj2MyZ/FB0d37jjBjhhforBtLC9WM4deY1bCp6YTBbIMflAQ8y9/M7ACSXFyjot8JczX7VaYPIrfxHfJ84euXw54LbEVTpo8HbH8M3+WctwCG59lX5o8ZH5YoA4Q4iY77uniiqmOd6CCLKnFJJzACYUkTcITuNr+P2Fs/QRtTy/JV4zDvE6dYk5lpsHiIsU70ccQSIo3ecvZEvsdOrTv9kBt6ocEUv7BkrV2e7UVEDKuszLyRCe1fuKtbx5fEu+os7ivReFsHHHEsdsjoimlkoE6z8i0aBUwFbZR52XXkFSZ6E5Srxy4D8pSo11uakwTc1lhKRX1x+rJUIpIjx0cRJw3qdfDTpfUFQAIHSVlr9mlFSG X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(6512007)(66476007)(8676002)(6916009)(6506007)(31686004)(86362001)(8936002)(31696002)(6486002)(316002)(66556008)(508600001)(66946007)(26005)(5660300002)(36756003)(4326008)(38100700002)(186003)(2906002)(54906003)(2616005)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?nMOfdXyfpyFZegzdGgb9/BkoUIuI?= =?utf-8?q?3OSpCwvhBgPJ0DVM4tapbW+uf+ol/Oy97yVvsb/2gg/d8wKoOO97embtgDUet4M+m?= =?utf-8?q?KUXwuYAtEKw4pv/2hptBu1RxtXOFwEJP3KgH5Nq0eyQHOD9NBUVqQMLbabo1ULPer?= =?utf-8?q?B+FJ5XtKNNsc9Rvi5xWeYhXMOzbPJcLvbjZBKy2NX/zZIzdikT9JRBtvnSdO36WgH?= =?utf-8?q?GyGDw02c4Ycj0nyfc/R5n9f1ovZ7NMdDr/xPqtnQ6o7m0DXvqD6omLSd1v7LPaWDK?= =?utf-8?q?OpVldyuF9Za7uT1szHmyuZrwKHbrDDHlJeDKbmh/yR32LsUeQOMQQW3XPn6KLC1Hn?= =?utf-8?q?1yhiRI/ticZxL79WnfAa7vu+n9Y2HdOzVrbiMBbK+SyekmMcsZFYxRa4chsbPfwY7?= =?utf-8?q?NzxeNN0h0YxMIwNJ0NFvDYyRqyr+RaumZwJciLrMUH1cVV+fkDBWPqVB1uhqcjpPm?= =?utf-8?q?MXPJutq2UyRuN5m3gOSU3cTA1FhbjZLf9a1FtTSYeqdMb5uIGyz66jny/e7ehY0M0?= =?utf-8?q?e64QK5IJ17s1NG/pX4sZAq5oduHz3evfq4l0yqkMCJb4/4PwUZK7mt57Asg0/Q3l9?= =?utf-8?q?7tgD+lz4ULYyya06oPqVyNqv8f1a6ltuQnKfuFWoH18cWSuToYwVb+aGFeqApu/tx?= =?utf-8?q?AWjaO7bg8/RqHUqkQ8ZNbNUAK9dLObsOPcPWGc1trvaNT6vYNHLftoGcgKDoL8u6v?= =?utf-8?q?SSAjFiwoG4dxSIXqRskMqx/X/BRZLy/mt1R7mqbDH/Wdeg/3VxhhE8j6h/kH0qa8k?= =?utf-8?q?mGrMe+aApjYkjQlLxv/jKFzMCWVzlnBRBGvhDgn8DnrmH6CcyujSHlnf8E1G65Yka?= =?utf-8?q?n9GIDF2zJpR9/e+kI/cWtn3P98hzb0z+wzlI7p0wc5QZ1LoYHE/p78TlafqJCMqQQ?= =?utf-8?q?Y7C81virCTRbFULSX2CZTo077Jea5Pjwfw8p+QNEgEvSea90ky9hqebH77VHtFnsX?= =?utf-8?q?SdJ0+5gT7ETS54bwlLyPJ/hmdQfEJMPSwHzlJv1NUu69dBQkGyf2YKMMAgRF1Fc8K?= =?utf-8?q?w7ZpKnD3nZUEOI9f4WkHnGLNDxMC4gqmxCMLQpNRJCUhATSype+Xry4L9UBCvicyj?= =?utf-8?q?MP+mUZBaT+T0dhXD8WI8m8fp/H5CcmnUyt0I8Lr68fZK3kPVDxglNHGuLswr22xkQ?= =?utf-8?q?LllsU9nq/mxtDnObODF9fCfNsnV9tHQwSI0rHvfqboJXz5Fzuscs3vOjD2JZfEaq3?= =?utf-8?q?WA7yiXx2xzHXyQBigEg/JO7ZWMj5jhkjVcjbC7vQYjcvfBnaJCdNi7yMs1xsFLRtq?= =?utf-8?q?rIyPhRDB70RmiNjg6PViZVZmH/LZ/ITwQfxo9/BfbsiFGyI/hvYIgMpZJhT/NVHeI?= =?utf-8?q?XrUJDDTFf5tpBN9Sj4lTcBm1PdmVWxlybHaE9Da10AO1f9ffx3ByiF/yyUbG4UK1O?= =?utf-8?q?5NhuryQhsqKaP6QPQ0GMpL5xD/ivU+VGQh+zvrz4ueAdhC8C/kuLFbVcEt/pzQwTY?= =?utf-8?q?F/v9y5IljlbmMKQzoScOiWfE3zRQ/0IIyL2lBFIjhwwuOLfsrG1KvlRd1qRMP7sQ2?= =?utf-8?q?39UsQ0jg3WbBnOUmb4MHvT9IPCPmkmkesGstDxuNTTjox+DEaawb3dU=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 92ff817d-7971-4327-2449-08d9f6e65861 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2022 16:05:43.6558 (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: GfBDFdq3wXdxM63wyfIfXILJ18GdRjL7NxradvD5OYMHcoV6xlevPHrCQGSQm4+W50oT37yU9eu5qtcP3Ir3JA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0402MB3803 Conditionalize it and its uses accordingly. Signed-off-by: Jan Beulich Reviewed-by: Tamas K Lengyel Reviewed-by: George Dunlap --- v2: Re-base (drop clearing of field in getdomaininfo()). --- I was on the edge of introducing a helper for atomic_read(&d->paged_pages) but decided against because of dump_domains() not being able to use it sensibly (I really want to omit the output field altogether there when !MEM_PAGING). --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -1213,6 +1213,7 @@ int add_to_physmap(struct domain *sd, un } else { +#ifdef CONFIG_MEM_PAGING /* * There is a chance we're plugging a hole where a paged out * page was. @@ -1238,6 +1239,7 @@ int add_to_physmap(struct domain *sd, un put_page(cpage); } } +#endif } atomic_inc(&nr_saved_mfns); --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -691,11 +691,13 @@ p2m_add_page(struct domain *d, gfn_t gfn /* Count how man PoD entries we'll be replacing if successful */ pod_count++; } +#ifdef CONFIG_MEM_PAGING else if ( p2m_is_paging(ot) && (ot != p2m_ram_paging_out) ) { /* We're plugging a hole in the physmap where a paged out page was */ atomic_dec(&d->paged_pages); } +#endif } /* Then, look for m->p mappings for this range and deal with them */ --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -112,7 +112,9 @@ void getdomaininfo(struct domain *d, str #ifdef CONFIG_MEM_SHARING info->shr_pages = atomic_read(&d->shr_pages); #endif +#ifdef CONFIG_MEM_PAGING info->paged_pages = atomic_read(&d->paged_pages); +#endif info->shared_info_frame = gfn_x(mfn_to_gfn(d, _mfn(virt_to_mfn(d->shared_info)))); BUG_ON(SHARED_M2P(info->shared_info_frame)); --- a/xen/common/keyhandler.c +++ b/xen/common/keyhandler.c @@ -278,14 +278,18 @@ static void dump_domains(unsigned char k #ifdef CONFIG_MEM_SHARING " shared_pages=%u" #endif +#ifdef CONFIG_MEM_PAGING " paged_pages=%u" +#endif " dirty_cpus={%*pbl} max_pages=%u\n", domain_tot_pages(d), d->xenheap_pages, #ifdef CONFIG_MEM_SHARING atomic_read(&d->shr_pages), #endif - atomic_read(&d->paged_pages), CPUMASK_PR(d->dirty_cpumask), - d->max_pages); +#ifdef CONFIG_MEM_PAGING + atomic_read(&d->paged_pages), +#endif + CPUMASK_PR(d->dirty_cpumask), d->max_pages); printk(" handle=%02x%02x%02x%02x-%02x%02x-%02x%02x-" "%02x%02x-%02x%02x%02x%02x%02x%02x vm_assist=%08lx\n", d->handle[ 0], d->handle[ 1], d->handle[ 2], d->handle[ 3], --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -390,7 +390,9 @@ struct domain atomic_t shr_pages; /* shared pages */ #endif +#ifdef CONFIG_MEM_PAGING atomic_t paged_pages; /* paged-out pages */ +#endif /* Scheduling. */ void *sched_priv; /* scheduler-specific data */ From patchwork Wed Feb 23 16:06:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12757167 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 322BCC433F5 for ; Wed, 23 Feb 2022 16:06:30 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.277548.474092 (Exim 4.92) (envelope-from ) id 1nMu9i-0000IZ-WC; Wed, 23 Feb 2022 16:06:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 277548.474092; Wed, 23 Feb 2022 16:06:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nMu9i-0000IS-Sk; Wed, 23 Feb 2022 16:06:18 +0000 Received: by outflank-mailman (input) for mailman id 277548; Wed, 23 Feb 2022 16:06:18 +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 1nMu9i-0008Dl-2g for xen-devel@lists.xenproject.org; Wed, 23 Feb 2022 16:06:18 +0000 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.109.102]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 883359fc-94c2-11ec-8eb8-a37418f5ba1a; Wed, 23 Feb 2022 17:06:17 +0100 (CET) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04lp2056.outbound.protection.outlook.com [104.47.13.56]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-15-isKHM8ZCMuaq6KkTn66bwg-1; Wed, 23 Feb 2022 17:06:15 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by DB3PR0402MB3803.eurprd04.prod.outlook.com (2603:10a6:8:e::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19; Wed, 23 Feb 2022 16:06:14 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65%6]) with mapi id 15.20.5017.022; Wed, 23 Feb 2022 16:06:14 +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: 883359fc-94c2-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1645632377; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r/iLJGRiDWz9znYj5kxZFXueDDoLEYeNTD/fTL9rUek=; b=MjbbkCOAdbaRuyKRPfDEAhvFYWcOseXFKUFoT5CdyaiXoFAOKhEsm6IRuuL907oveLsDoS NvdZ7LRg2ORKjFMXT/SZOZi+lv5jOuVNdDk3wgml9X3VS+ORQD+redyt464Im/LPMul+33 yVKUwhXOgfZlYdR+h0LIZm+PG4rdN5Y= X-MC-Unique: isKHM8ZCMuaq6KkTn66bwg-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MOSpUC6ycuWhrZeTCAM7GqfkxSruI5Z7cFNBmtA6couBH9+M+3ldPF4I+QD2gbMdGJP0bQEROnnWrD1a0RCyx6zqjqr+ub6dhSfSt/Xg9gAUfTBzsX0lXnBww5spe1xqy1cjBK2O5ZFhMC/JoxXnqZtefErTRUpaCK43yM2ogTRvE0Uq8j9xP5ECDeczyP0AiK0F4Yo7HXI1V4Eqm52RK5BZAXnyWg9BAR936EMWHURzBtln4rNE5NdA+yM72+i8juokuYsdrYcOPO/qXbt653hQ52gWehZJXcJ6WRbed7OiTvVWTFsXoHfNkSrZENS6HkiIMQTFS4KJL0lURtLEHg== 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=r/iLJGRiDWz9znYj5kxZFXueDDoLEYeNTD/fTL9rUek=; b=E82CXA6ZD+NvavlLzI+1qr1hsNCBVe7yucN3osD9m4l6ZaUhHMu6NNb9fZ1v4m9bfldc58juFdinlOsboZSonbimRXz3wc1yflP2Kuu30z6BIJ+oXYbytA8NRev89j4oHP2QyATJPnRqMUGA/XSECCaj5WbFOjpqbl7t+UEwVbpkdZhf8BLm+P+MgN1ZO9tLMp0FO6JbxqeCqN+Jz7HoFpBz9qNyzi+AC5kXtgAtqX9pDqMR0P/YdQrmYjyNh69dN18OeETtXP4OACZ2cFQtB1jaU2cZURPgmLBQ+OLgfLv8M/2wgS93igyCYC7r1YZ+4Oa2FJ/MqYZHttAiwZAG1A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <3908bf69-f560-6a71-1a66-74ba1f9f3696@suse.com> Date: Wed, 23 Feb 2022 17:06:12 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH v2 13/14] x86/P2M: p2m.c is HVM-only 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 References: In-Reply-To: X-ClientProxiedBy: AS9PR06CA0260.eurprd06.prod.outlook.com (2603:10a6:20b:45f::25) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9614b131-30b4-41d0-2bb0-08d9f6e66a91 X-MS-TrafficTypeDiagnostic: DB3PR0402MB3803:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZPw6vMM43BJb4v8ZSNENfUizhR1HWNR/L/6O8FaxJpu9QZ0BlZNr2KOv/t1iZ4+o72tbQxf7WJigmifrAAw3NPqpPkkrgTMPK2aDNqBqFxNmIqP05vO1i4Pdix85GbW+DET5HAP5N/dcCp8q1GpvnePRlAIucULdBnaJgKyolKUBUKajsW3DmvCXHln+dUoZi/fP1shT+0G+RHcgJJs1rFGa1KOpOzPz3HjCFcxbbJ2baC3itagg2y0f12RyRTqFKOZ4cSYdGyrY9qx7ZkqoFL2fHvYq3gJlYZyk74Nq5I0rmDMNr7ts9sTAtz87wFGqKSIdxRgULoh5y+fup+7A0wrjTQcvkSOXJOahTeSYDVuslLNrqUGQE8ejwwcnVm+jq9hY00Fd71fBI6tedOI2nJhxb7T7CFfj3OIO8p+NLA8m/9F2HimHNMVS+2BsSqSN3baox4xxp6tJSdMoTwcGBDlGWK9DBRXQcPBn2L9bKFXPiUqHV3DIVyLwi/om7vqrU4GAiFXXUz8ZMeQ43QODO83TV2Zvim5oLnq1/pdI1IS2DyUS57I206rdXkQS3a539y16xqSiItMJSczNUomtbHVw3FOhU1hw7M7JVSaQIn/3flZPiHDV8RXoBOZFw3tdrTGR/Ann/Fgsk4Y/bKnJW8+dzBjdYC6fNOBhbHzKj3jRmrYO50BQ+Gj/YlNSgdQxDB8s3NCd7cX853ZrbUD2VtQNS8vZIcS0ocGg5ffF2sk= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(6512007)(66476007)(8676002)(6916009)(6506007)(31686004)(86362001)(8936002)(31696002)(6486002)(316002)(66556008)(508600001)(66946007)(26005)(5660300002)(36756003)(83380400001)(4326008)(38100700002)(186003)(2906002)(54906003)(2616005)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?KuJXs7FC2O1D6uXyALwxEy5kdj/a?= =?utf-8?q?dhE+Iyuw924HZtyCHIcufTXdh8/r5ZRxkJ+O1yQFJQ10oc/vgFFWB61vV4Y4jq5FO?= =?utf-8?q?pgQ5oatvzrFa0LdoUblvQK008OfUq4pyLHtIMCgAgx9D8veKVwCkpvLNJYTewtv+z?= =?utf-8?q?u2m2rlUpM2/xYjthFuV9DhgvYloZ5JM3H2xImuKgv+fMqnLTGHLvFefXvaMn0cjXR?= =?utf-8?q?Mv6Due+WOIMnOpIFm25IvJdtGsMd8TEi78pf36fMxA9VH7tBUkWvpNTVJTuHLEGDu?= =?utf-8?q?dpjs5MQ7/X43aMnxGyZITe70jE5yJEdmwAcdhQmNViQVgtoWuyMI2O/SzyeRsqS+5?= =?utf-8?q?1oMInBfWzs3lgE7JV25zHzhrXOHeu0+iHwhnYGiuryk56YlOs+PwMFJnPnSpuCTSu?= =?utf-8?q?fdFmjlLpkj7ChIy/bnZYmUZ8c/VJqeXavw5qj653fQ7fUDOGTxEag9ONHZUdhDy+z?= =?utf-8?q?widPjLqe3a04ycyslXoRZ6A0d4wi2pGyLuj2baxu2rmbvanrVF/d7s0UvBJx8xizB?= =?utf-8?q?s4AhSRJmZX4sFwDj6ZK38RmZ19yL15pP5L1SZGxGhTaKr6Iq3EaYOKxAV++YFRu+l?= =?utf-8?q?+FV6Gx9rFgk6dX+eUPUtetsvttauglFcipLdhbjb1xbXaGWjTmk2+Fer0QmajnF78?= =?utf-8?q?WlcyUxyLoJ3FIQditU4KKzFeeQCpogEVhTrq+1s1g4HY28MJf00ADb38rCX8DfFTg?= =?utf-8?q?vXdhhsuyQAaTPTPWfHQCxsVlEQT7XMWABBrQlJ13k3Tt8H1kNCs7ANYLsh41TO2AA?= =?utf-8?q?0oXsmGZ5WEetgEz1TRWq85IauZ5gEx6W2YUbeFc7jgDxK+zLpBfK/GPTe8bM0uHDy?= =?utf-8?q?ODq965xRewK4N5IpO5aQM8jU1X0uMlRM+q5zlVukApUH6EZ6gKOlXP/UWwNLp+GU/?= =?utf-8?q?dew43LSr7o7cv3WPPKWLBTP7phX8hZ62403k3aE6CRBFlnybTTQjarEkoEqoEj4Pk?= =?utf-8?q?m/R/Xh0G8Wx5ym+KPy2FlGmKibZdvYqtopGVqwMyPUNU5kHJWHTwA11YYni095n3P?= =?utf-8?q?JEF0fAEc+cd5mUrJT5jBpgfAIl0wV9EnkmX8H5AH+zbjvRZ/qis/SD7N2q4sq4sbc?= =?utf-8?q?b5hiaO4D5JFhHFshJz5LudJTj/pV+2b5LOuqR4d0AaDFKrgVPfPM6vt2zS0X5RimW?= =?utf-8?q?8x801vC9shKwOfTjdmztMxJwGnnCiIBAx/7MMeryTD0b6L5if/S2/gZO1Tfy814lg?= =?utf-8?q?dLzCmdrw0cGywtpftxckdSq7mCw1/t2yFMqhk09KaJHvYaEEvQKXxnIqCLWXao65J?= =?utf-8?q?3GaiC/1/qq+HNhPVag76q0ApulwAR0lNhw+dMSZT+yUSv6vM6ZF4NLhC4Ad6SBVSt?= =?utf-8?q?mw5TMq+BdfoV8gg48x7DIiuQnK2Yt1MJ++LceohTjVbP8eAE0MQIJVVmbZnpcL84V?= =?utf-8?q?fHo+JAd+vc/Atu/A9f/qem4bXQ/TVvID8ZiJ4GxFre7eeqbuokq79iOe2WKJF2/eY?= =?utf-8?q?8f+jil8khabfZYOfZTJqhW11/5ZZlOltLk4wVLFwvFLLbqF4JdPLuh+uzFqDC/JHh?= =?utf-8?q?2CR1YQFQWgQVGEo7ADpSx3tLLq680QOuaVDjN2vk4IGpXWzNDbiPkxk=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9614b131-30b4-41d0-2bb0-08d9f6e66a91 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2022 16:06:14.1851 (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: m9GciQwZqb1/k288cPFOl36/iS+JvWvdw2kpN4NmqtfmxuLYGCZ7blQ+FOGNmxjtnumY+/WIAbeS4MhA/39tEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0402MB3803 This only requires moving p2m_percpu_rwlock elsewhere (ultimately I think all P2M locking should go away as well when !HVM, but this looks to require further code juggling). The two other unguarded functions are already unneeded (by virtue of DCE) when !HVM. Signed-off-by: Jan Beulich Reviewed-by: George Dunlap --- a/xen/arch/x86/mm/Makefile +++ b/xen/arch/x86/mm/Makefile @@ -8,7 +8,7 @@ obj-$(CONFIG_MEM_ACCESS) += mem_access.o obj-$(CONFIG_MEM_PAGING) += mem_paging.o obj-$(CONFIG_MEM_SHARING) += mem_sharing.o obj-$(CONFIG_HVM) += nested.o -obj-y += p2m.o +obj-$(CONFIG_HVM) += p2m.o obj-y += p2m-basic.o obj-$(CONFIG_HVM) += p2m-ept.o p2m-pod.o p2m-pt.o obj-y += paging.o --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -53,10 +53,6 @@ bool_t __initdata opt_hap_1gb = 1, __ini boolean_param("hap_1gb", opt_hap_1gb); boolean_param("hap_2mb", opt_hap_2mb); -DEFINE_PERCPU_RWLOCK_GLOBAL(p2m_percpu_rwlock); - -#ifdef CONFIG_HVM - int p2m_init_logdirty(struct p2m_domain *p2m) { if ( p2m->logdirty_ranges ) @@ -258,8 +254,6 @@ void p2m_flush_hardware_cached_dirty(str } } -#endif /* CONFIG_HVM */ - /* * Force a synchronous P2M TLB flush if a deferred flush is pending. * @@ -286,8 +280,6 @@ void p2m_unlock_and_tlb_flush(struct p2m mm_write_unlock(&p2m->lock); } -#ifdef CONFIG_HVM - mfn_t p2m_get_gfn_type_access(struct p2m_domain *p2m, gfn_t gfn, p2m_type_t *t, p2m_access_t *a, p2m_query_t q, unsigned int *page_order, bool_t locked) @@ -2718,8 +2710,6 @@ int p2m_set_altp2m_view_visibility(struc return rc; } -#endif /* CONFIG_HVM */ - /* * Local variables: * mode: C --- a/xen/arch/x86/mm/p2m-basic.c +++ b/xen/arch/x86/mm/p2m-basic.c @@ -28,6 +28,8 @@ #include "mm-locks.h" #include "p2m.h" +DEFINE_PERCPU_RWLOCK_GLOBAL(p2m_percpu_rwlock); + /* Init the datastructures for later use by the p2m code */ static int p2m_initialise(struct domain *d, struct p2m_domain *p2m) { From patchwork Wed Feb 23 16:06:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12757168 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 A9240C433F5 for ; Wed, 23 Feb 2022 16:07:07 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.277555.474103 (Exim 4.92) (envelope-from ) id 1nMuAK-0000xl-Dk; Wed, 23 Feb 2022 16:06:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 277555.474103; Wed, 23 Feb 2022 16:06:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nMuAK-0000xe-AN; Wed, 23 Feb 2022 16:06:56 +0000 Received: by outflank-mailman (input) for mailman id 277555; Wed, 23 Feb 2022 16:06:54 +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 1nMuAI-0000w1-6i for xen-devel@lists.xenproject.org; Wed, 23 Feb 2022 16:06:54 +0000 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.111.102]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9d746bdb-94c2-11ec-8eb8-a37418f5ba1a; Wed, 23 Feb 2022 17:06:53 +0100 (CET) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04lp2050.outbound.protection.outlook.com [104.47.13.50]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-38-OgQyaPfSOMqLrBABE6INEg-1; Wed, 23 Feb 2022 17:06:51 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by DB3PR0402MB3803.eurprd04.prod.outlook.com (2603:10a6:8:e::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19; Wed, 23 Feb 2022 16:06:49 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65%6]) with mapi id 15.20.5017.022; Wed, 23 Feb 2022 16:06:49 +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: 9d746bdb-94c2-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1645632412; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qlmDT6QYqTFfeFQW5rElaxTqCBQLlgaE3LTl1YDteaU=; b=VAe75CrWyOGfLMQlt3P7rrpJuNuTw8ohUOj4SAm9vepWS8iHAdpicoz6A0K9sHiwpGpNaj OUuQ2EPtSlhSGjoQ3MfZJ5ubrmctvP4q9+atYN3VT3rIiYvifpbnhWycKxtaxz0oBdsFaX pj/24GLs+kEZEQdvmCp1GUpi+s6/SxM= X-MC-Unique: OgQyaPfSOMqLrBABE6INEg-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T0rWpJ3adE5GqoNa9SgQTtaJ+eUpHtkVXTZzjce326XuoKPTI5Slm7mCYmITPQ+L73bjI+TycUnxW16yaR5uWd6GESJvRsAJzYrS2423QqziQLT0VWHz9RbSN9NX7b/YT21+GxE82mgS3mc5pNNxN/wj8+ziL42VmnQ6cb9CnNCBqDZ2usgSmddwWp8iZxj1beVvBRJFWMmtCDiDYmF/SLx26xZL8425Zp3ASgpUc1uyRGRZn3rPI3r71ioGMJ9Deb4PYJIvNT3AoufEhwIQfHuHTYapXV2sPkAgXz/1QSM8twqF8GcfUQb76PsZLSommwRINmd2QBTlomFLyPhfuQ== 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=qlmDT6QYqTFfeFQW5rElaxTqCBQLlgaE3LTl1YDteaU=; b=cF8jCESKRZkmQ+OcyrH9TQuev1Ri87bop1VEnASVIoyteix53WsOCJSDnxr2gBefU9ZsriwxWjML27gJpiyDqniWWm+mtDubzxkKD2pf3kQE/yO/D1KNUdNuHwCB9S0kOSuNPDI3Afqb6NIfK3EMKZiMFnL5RF25pRK84R9zmPLylYBdLA+P3AicHyyzj/+Yr7nYQx7ZuCYu2Rm6u5sw5cd9ooyDrl/DQNCDgcrbGoWhFMBfeJpQp1TAGOqL7Xys8HTeRF8Ya9OFloJeVX3gA8qEvX1D40bljk4Oc5uvLrsaJ6PtvJRijHxYe7ZnQHN8GwxBEvreYMYzMlzk5IQA0w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <9b964afe-635f-3320-ceee-2845ed079332@suse.com> Date: Wed, 23 Feb 2022 17:06:48 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH v2 14/14] x86/P2M: the majority for struct p2m_domain's fields are HVM-only 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 , Paul Durrant References: In-Reply-To: X-ClientProxiedBy: AM5PR0601CA0025.eurprd06.prod.outlook.com (2603:10a6:203:68::11) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 409846ce-b77a-49d3-02ac-08d9f6e67fc8 X-MS-TrafficTypeDiagnostic: DB3PR0402MB3803:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8fwQCb6RFUx6V1ZzmK51tmdr339Y2T5qd7aqZ8Re5PnWpFpyJQ5wuzXut35hgVA54tb35v3rnXa8m0MX9LCTWcjAVfwF/Y9EoMZ3F3eGpAlBaN9QZiUNc4mDG/Gr2LSvRhgpgTffFizazcn2k45XE5t7pP2cQRlVkNFlIhSuxdHPCFhdlsCyRQTamXRcH6oPDa/8142WUvisi1BH11fWrj4R3gBeGN6kpFXm/z36wdUBbsU4+8aVWMsU4Gs58/ceqZktq9tNVUJJMy4rbzsNL/SxNRsyDVHFkzApnf3WDJTZOvsqQd2Csm9YauhmLtAhpxAhwIY79rIhUvAZbwzDloY7SbU9hWMSotErfbVakivQBqGldRO+G+JSaJ/aI5b4dUex+T6qJ7jdBhGzRsnZXEs22JYyEnwVu7ZmrSfyXXUtsNbllIMZXgYSH2mITwgF5AfyDC8g0ozG6yqrp0ANiGOrWduPpo05EiHAADtRTxad0Q/rwKcZwA4FPiJhrjmpubwWeBfcZFADlT7v3UWXxgx2BJH4C8AIEanDp7qLpJ9FcDIAzmuQ60tP3VOM4SX0tuBD47xGjcz+upwU4drGExniczfogqcC81E9bB1Ul8FqgahlL84b3fxMqcKY5SJA9T/6rTe3waGwYwkMW3gNTLhUiWJ3QtAXS/G8+9tdxZHEEceGKuwE8lTH+d/Sf0GrqTTbxd6A3EZE5Jr3E4U484xFEDlj2hFo0CCe1NcrndI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(6512007)(66476007)(8676002)(6916009)(6506007)(31686004)(86362001)(8936002)(31696002)(6486002)(316002)(66556008)(508600001)(66946007)(26005)(5660300002)(36756003)(83380400001)(4326008)(38100700002)(186003)(2906002)(54906003)(2616005)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?9y/nxDC+YaQmYCt5fZ+BwKJowglL?= =?utf-8?q?rNPTYtWGCHWY7nBBAWWq9CfElkvE0A6za0tnCdm+c0Wz73CEWh7R1BK3LRra999Gj?= =?utf-8?q?vUq/7XWDMRBBv+ueOofDemIDGnTpEqmY36kbktt0LpCVOfT4zU2kYMp4zu6HOPrYJ?= =?utf-8?q?QiY8rVH+uEU11RnJZKNc3Vr4GBwfUs0kNMBE8HBTkGg674CRhn9k8Y16KpIFeDGlr?= =?utf-8?q?EAPc3sZwErQYkoH7nqaPqmnzKqiuTb+C0c1Lcs/jHdSvFoTTzfT50+ub6lOrVxkKl?= =?utf-8?q?OiBpEoL24IlKq/eN7mfRMS39DxqiLUE2llAq0hHS93/UFZIOQ1PwxyI++I+HVh0pe?= =?utf-8?q?BrAS8osIYiXAtITFYHe76TER27vjQuF+DUtC9b6fg3w2Iejn8wa79fOP8RuEJ8S5W?= =?utf-8?q?MXfEk7c7fliBq+VUa7K9mF3hgVs5TzaLasiLiwN2wD1vz97GqztFGpk5s/7+Yw8TD?= =?utf-8?q?mY+Mn3DcJK3we4QAB7VcQqcyzH1pqdyFUccuLkRHYmIZXfJ2M0a2JERUqGUfyi6qq?= =?utf-8?q?wVDEp3f3LdYuv4wFFEttU7HBYMTiGsgyuILy2Lr25c1pLNpwbjVC6HkQPhClWu4hY?= =?utf-8?q?DvTAfb8XfeXjKNo7Q2AR1RjL6Ku5Q9HdwPL1DZ40SI4mmqJgmvc/DoOl2sdUyPUiy?= =?utf-8?q?Ftj10x8fOdns0Oeywj1nAMD7s0Fk/FQPn8To9V8FpSfY6Go/IwOxpNsvV+OCwmOya?= =?utf-8?q?+QuUKUa3PAhQF1L0/SB9tq7jARRq/seppwbl9gZm0OFOZec5YMuXUxGj8kxh2uQRS?= =?utf-8?q?V4Qc/saNpDNGVxnAC97xDeMeJnFoa/Waauvzd7AHzcwsIkfi6Lo9KUO4qiR35xMnU?= =?utf-8?q?ZTXG4J1zIQDKbUePWzln2SVweRT4mf+5xlJyumYC+h3XthHCkt8WsI8akX4xZt4KT?= =?utf-8?q?zMTTeMw5VNTuZlKW17fWIFGw+9lM7dNeuzqrjNjt7VbxEeCkn9COWLtKH+IWhqTK5?= =?utf-8?q?c9Y997YgG5Kobvw7LoAezSqKsV9vO72lav5+8zSRRfw8V4XE4dkSYEdo1QSBd3rTG?= =?utf-8?q?aCMbm2ADWgIGPsBUIG2/2M+G3WOlaebVtiBZ/6JYWmRDXTLfjzV+hZru4XIjU3pIw?= =?utf-8?q?yUAMlG4a8dH2brPAx4jY5f0nKwVyFtl8Xl+5C4luvN3oSTJeO+R6Z1a2OC4pK3xO6?= =?utf-8?q?tUf7fNaAqhqeS+6yeL5z6ERUZJu6a8tb5NNn8CppvlB5HkgphHNXzky9AgvA5oSmC?= =?utf-8?q?JSo85ZDfWgYp455KdG2IgkGytMtEo+4zKOPNyKrJjQ+2ev2v7k+NDlOeParbq1VfG?= =?utf-8?q?qIG774hWJB6gcUKQnVYSbnHfhj8zNoLsFFUfTXxHG+O47ze6a9fUITUaEPZPQaifO?= =?utf-8?q?UW1fkqRVnUf5Bc98fEP6Ic+Q7eban+KCe6w/vteF6W/ynucGO4Drk65ZUQ9mTa93O?= =?utf-8?q?yzrqBPUXXlH+VJgeOxsM/mjKKreCAWModM/KRucwZWZWtG5G1+xJ7UBzGvhAPzV3H?= =?utf-8?q?EbI2/y/pKRR943rwn3dBbSPbX0YkdJTLvLYn0f7e4wDWfjpeTxiyOcok6yLak+7u8?= =?utf-8?q?chWpDD/EBVBVsK7W6rnjJsny23iHBdnUunWBFNoJ8Z5q2BL3llg/DOg=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 409846ce-b77a-49d3-02ac-08d9f6e67fc8 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2022 16:06:49.7611 (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: Blpzr+W413RLbPKOOTb1kU9EJAOdM2VfEMhOqNc7KBAnDlIoAWB4Tqhx1+MPov0sCgh4qSxusKrByejwX+YJGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0402MB3803 ..., as are the majority of the locks involved. Conditionalize things accordingly. Also adjust the ioreq field's indentation at this occasion. Signed-off-by: Jan Beulich Reviewed-by: Paul Durrant Reviewed-by: George Dunlap --- v2: Adjust a comment. --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -481,8 +481,11 @@ unsigned int page_get_ram_type(mfn_t mfn unsigned long domain_get_maximum_gpfn(struct domain *d) { +#ifdef CONFIG_HVM if ( is_hvm_domain(d) ) return p2m_get_hostp2m(d)->max_mapped_pfn; +#endif + /* NB. PV guests specify nr_pfns rather than max_pfn so we adjust here. */ return (arch_get_max_pfn(d) ?: 1) - 1; } --- a/xen/arch/x86/mm/mm-locks.h +++ b/xen/arch/x86/mm/mm-locks.h @@ -237,6 +237,8 @@ static inline void mm_enforce_order_unlo * * ************************************************************************/ +#ifdef CONFIG_HVM + /* Nested P2M lock (per-domain) * * A per-domain lock that protects the mapping from nested-CR3 to @@ -354,6 +356,8 @@ declare_mm_lock(pod) #define pod_unlock(p) mm_unlock(&(p)->pod.lock) #define pod_locked_by_me(p) mm_locked_by_me(&(p)->pod.lock) +#endif /* CONFIG_HVM */ + /* Page alloc lock (per-domain) * * This is an external lock, not represented by an mm_lock_t. However, --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -48,6 +48,8 @@ #undef virt_to_mfn #define virt_to_mfn(v) _mfn(__virt_to_mfn(v)) +DEFINE_PERCPU_RWLOCK_GLOBAL(p2m_percpu_rwlock); + /* Turn on/off host superpage page table support for hap, default on. */ bool_t __initdata opt_hap_1gb = 1, __initdata opt_hap_2mb = 1; boolean_param("hap_1gb", opt_hap_1gb); --- a/xen/arch/x86/mm/p2m-basic.c +++ b/xen/arch/x86/mm/p2m-basic.c @@ -28,16 +28,15 @@ #include "mm-locks.h" #include "p2m.h" -DEFINE_PERCPU_RWLOCK_GLOBAL(p2m_percpu_rwlock); - /* Init the datastructures for later use by the p2m code */ static int p2m_initialise(struct domain *d, struct p2m_domain *p2m) { int ret = 0; - mm_rwlock_init(&p2m->lock); #ifdef CONFIG_HVM + mm_rwlock_init(&p2m->lock); INIT_PAGE_LIST_HEAD(&p2m->pages); + spin_lock_init(&p2m->ioreq.lock); #endif p2m->domain = d; @@ -55,8 +54,6 @@ static int p2m_initialise(struct domain else p2m_pt_init(p2m); - spin_lock_init(&p2m->ioreq.lock); - return ret; } --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -459,7 +459,7 @@ bool arch_iommu_use_permitted(const stru return d == dom_io || (likely(!mem_sharing_enabled(d)) && likely(!mem_paging_enabled(d)) && - likely(!p2m_get_hostp2m(d)->global_logdirty)); + likely(!p2m_is_global_logdirty(d))); } /* --- a/xen/arch/x86/include/asm/p2m.h +++ b/xen/arch/x86/include/asm/p2m.h @@ -205,8 +205,10 @@ typedef enum { /* Per-p2m-table state */ struct p2m_domain { +#ifdef CONFIG_HVM /* Lock that protects updates to the p2m */ mm_rwlock_t lock; +#endif /* * Same as a domain's dirty_cpumask but limited to @@ -226,13 +228,14 @@ struct p2m_domain { */ p2m_access_t default_access; +#ifdef CONFIG_HVM + /* Host p2m: Log-dirty ranges registered for the domain. */ struct rangeset *logdirty_ranges; /* Host p2m: Global log-dirty mode enabled for the domain. */ bool global_logdirty; -#ifdef CONFIG_HVM /* Translated domain: p2m mapping */ pagetable_t phys_table; @@ -275,7 +278,6 @@ struct p2m_domain { unsigned int level); void (*write_p2m_entry_post)(struct p2m_domain *p2m, unsigned int oflags); -#endif #if P2M_AUDIT long (*audit_p2m)(struct p2m_domain *p2m); #endif @@ -310,7 +312,6 @@ struct p2m_domain { unsigned long min_remapped_gfn; unsigned long max_remapped_gfn; -#ifdef CONFIG_HVM /* Populate-on-demand variables * All variables are protected with the pod lock. We cannot rely on * the p2m lock if it's turned into a fine-grained lock. @@ -367,27 +368,27 @@ struct p2m_domain { * threaded on in LRU order. */ struct list_head np2m_list; -#endif union { struct ept_data ept; /* NPT-equivalent structure could be added here. */ }; - struct { - spinlock_t lock; - /* - * ioreq server who's responsible for the emulation of - * gfns with specific p2m type(for now, p2m_ioreq_server). - */ - struct ioreq_server *server; - /* - * flags specifies whether read, write or both operations - * are to be emulated by an ioreq server. - */ - unsigned int flags; - unsigned long entry_count; - } ioreq; + struct { + spinlock_t lock; + /* + * ioreq server who's responsible for the emulation of + * gfns with specific p2m type(for now, p2m_ioreq_server). + */ + struct ioreq_server *server; + /* + * flags specifies whether read, write or both operations + * are to be emulated by an ioreq server. + */ + unsigned int flags; + unsigned long entry_count; + } ioreq; +#endif /* CONFIG_HVM */ }; /* get host p2m table */ @@ -651,6 +652,15 @@ int p2m_finish_type_change(struct domain gfn_t first_gfn, unsigned long max_nr); +static inline bool p2m_is_global_logdirty(const struct domain *d) +{ +#ifdef CONFIG_HVM + return p2m_get_hostp2m(d)->global_logdirty; +#else + return false; +#endif +} + int p2m_is_logdirty_range(struct p2m_domain *, unsigned long start, unsigned long end); @@ -792,6 +802,8 @@ extern void audit_p2m(struct domain *d, #define P2M_DEBUG(f, a...) do { (void)(f); } while(0) #endif +#ifdef CONFIG_HVM + /* * Functions specific to the p2m-pt implementation */ @@ -852,7 +864,7 @@ void nestedp2m_write_p2m_entry_post(stru /* * Alternate p2m: shadow p2m tables used for alternate memory views */ -#ifdef CONFIG_HVM + /* get current alternate p2m table */ static inline struct p2m_domain *p2m_get_altp2m(struct vcpu *v) { @@ -905,10 +917,10 @@ int p2m_altp2m_propagate_change(struct d /* Set a specific p2m view visibility */ int p2m_set_altp2m_view_visibility(struct domain *d, unsigned int idx, uint8_t visible); -#else +#else /* !CONFIG_HVM */ struct p2m_domain *p2m_get_altp2m(struct vcpu *v); static inline void p2m_altp2m_check(struct vcpu *v, uint16_t idx) {} -#endif +#endif /* CONFIG_HVM */ /* p2m access to IOMMU flags */ static inline unsigned int p2m_access_to_iommu_flags(p2m_access_t p2ma) @@ -972,6 +984,8 @@ static inline unsigned int p2m_get_iommu return flags; } +#ifdef CONFIG_HVM + int p2m_set_ioreq_server(struct domain *d, unsigned int flags, struct ioreq_server *s); struct ioreq_server *p2m_get_ioreq_server(struct domain *d, @@ -1036,6 +1050,8 @@ static inline int p2m_entry_modify(struc return 0; } +#endif /* CONFIG_HVM */ + #endif /* _XEN_ASM_X86_P2M_H */ /*