From patchwork Wed Dec 1 10:53:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12649713 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 5539AC433F5 for ; Wed, 1 Dec 2021 10:53:31 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.235849.409085 (Exim 4.92) (envelope-from ) id 1msNEe-0000zO-FP; Wed, 01 Dec 2021 10:53:12 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 235849.409085; Wed, 01 Dec 2021 10:53:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1msNEe-0000zH-B8; Wed, 01 Dec 2021 10:53:12 +0000 Received: by outflank-mailman (input) for mailman id 235849; Wed, 01 Dec 2021 10:53:11 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1msNEd-0000Oa-1d for xen-devel@lists.xenproject.org; Wed, 01 Dec 2021 10:53:11 +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 df86d3ef-5294-11ec-976b-d102b41d0961; Wed, 01 Dec 2021 11:53:10 +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-36-58fWeLOpOBeox4l2FTO6pg-1; Wed, 01 Dec 2021 11:53:09 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR0402MB3534.eurprd04.prod.outlook.com (2603:10a6:803:8::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23; Wed, 1 Dec 2021 10:53:07 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::5951:a489:1cf0:19fe]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::5951:a489:1cf0:19fe%5]) with mapi id 15.20.4734.024; Wed, 1 Dec 2021 10:53:07 +0000 Received: from [10.156.60.236] (37.24.206.209) by AS9PR06CA0105.eurprd06.prod.outlook.com (2603:10a6:20b:465::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23 via Frontend Transport; Wed, 1 Dec 2021 10:53:06 +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: df86d3ef-5294-11ec-976b-d102b41d0961 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1638355989; 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=2kRxZT307uKBK1UcuellO4ewXtOz3JX0bF445MqtSGI=; b=ivNMOY2nAc+tNy3+BV1yA8Eg0zoVicryiZ/K+t2mZFLUGJmqkcOmqUp0iuzzUThRAKsNJp oMNHZIt0ooAK3N0BUTRiDhGcVSeYRyNaizuIA8iqvUJ8xTfBFtH/06k+TWs/Uc+Os7f5aI qYWu57M7YXOyZi/17V9Zy0vtwN5gAUg= X-MC-Unique: 58fWeLOpOBeox4l2FTO6pg-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mK0slyE5Fpd+FEfeZnOu93036UbDylk0wsdKvXFXXEW4sS7kJ3/hClRNecSA2EZPAo96OCM3WqXeCmeguczysO/VsHgCIFm/W8DDTF/L2rvSgquZM0Bx2mtFEPzBjW6lCfv/3sGUWYsFluUPzSFWiEYLjxs3Ypc5eiLuLO9pHvFoKwaYzu9fklacqZIuSjvqcCSM5qXSR6LGGgyluhfQTp75OIuww1wkJIzTdvbUFZHan/r2Iu+RTkI40tOSmdHk33L6i5Hk7vqnWrxKXt00fnjuZw/Dy7w1Mz2m4pwSKQfbp8uVjLWgT3bx+AGbWWazyddEMFgHHMu92aDlmL2PgQ== 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=2kRxZT307uKBK1UcuellO4ewXtOz3JX0bF445MqtSGI=; b=ezvo8V75ITWCQpX+xt25eElDvGGwn893OCG4oayXeF0wwerQBXrdwah6gX1FlqWZK7U7Wl0anbmMVS/eUCtMjCSjTj3OsXiGcpb9tkaxvp1kDA82JWRwVuSUMAe90FAFahBu65hYemyR3HpZDHxs8cduxfLBB7xBHYoMziel19wjAfstORAauYwioHda2itKM9GW8pxEWvug1a1U220ADHIMQYYMKXs0p8CrmkjCNaup46zHeoMg9d+hS48VIs34g2862lxj3D6fCl58kEXvzaH6vt2bhicgnJZlkKKFKACPQvPW7fKMYIKzDZvavoMHjtkb1pL1QYlTDQs6opZHPw== 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: <2525b63f-f666-2430-2c22-b1b7b0d5d7f0@suse.com> Date: Wed, 1 Dec 2021 11:53:05 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: [PATCH 1/4] x86/PoD: simplify / improve p2m_pod_cache_add() 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: <21148e89-4750-3112-1096-36119be96c7e@suse.com> In-Reply-To: <21148e89-4750-3112-1096-36119be96c7e@suse.com> X-ClientProxiedBy: AS9PR06CA0105.eurprd06.prod.outlook.com (2603:10a6:20b:465::27) 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: 667d2f9d-01b6-4853-d4a4-08d9b4b8c1cb X-MS-TrafficTypeDiagnostic: VI1PR0402MB3534: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:569; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u6OsVc6HhwPpEvW1f1fXKfGR0G+R77edy/BK6n8lwslUMrqKKaZego89DhfGWjBpl7d7wr8ahT72OnkG87Pol1wvJMwQ9C9AKazeeeMFsLDYP7bT2nVus6PY8DLBCdnQTu3iBvXIWpd2g/KTeltTM83E2M8rXkAVfzWfCKbzHPTub1U+WXQusvb4C0Zmt+CWfsdYNDqsQgA8HXfIOqfuC67Qbb3waQ6nQGYH6Oc6nQXwnzUXYmfafI/5eF2cnaItmkp24opkgdh+3s86tx5dCl+4UtSMkhB3mSTbwbg24Vm4UpxJxG+ut8Mkxd2Y1I9DGbFOMGIEOcsGs51j1GNMNs9MICNFr2zDuTmicEcp6pEcY6WmNlW7pZbHIqHOh4BZSqGZBSATgOKptIhC7b+q7yJ43M7TyDKDEa2gZXEy/A8XSPECihg1PsYKQesxJwjyS06OQjYs9JuMhFldi3+mpNvgILdAe58V+YfxwTURTSc5crmp5QD3IOMg+Y204Tz5eZgkFio7zkH27gCNQt8JQTc/epESyGs+d4h8q3mSZ4NF/FZCbaS2FUWarVedGcpPcbP/2zE8FzEoaKdQmCRV/+NHDCpVI3Y4gqK/LLRA1rcEYh85Oa2mpuDBp8LtXR66GkHQtY39L+tNm/iIu3Og49xTmqAtjlN9H4rjUNwEbW71LizY8qznzG/3W/2LLCMuUPvK8piLpSgiz3PpwNclnbG7GsREoXL3cizONfi5AkFn3mhxxKp9YWXsT9EqrVnI 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:(366004)(4326008)(956004)(2616005)(36756003)(66476007)(26005)(6486002)(66556008)(54906003)(508600001)(66946007)(86362001)(8676002)(8936002)(316002)(5660300002)(2906002)(38100700002)(83380400001)(16576012)(6916009)(31686004)(31696002)(186003)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?+JzO2RIlxoxg+9f2nNi7SiSMtlJB?= =?utf-8?q?1c81i/p2eNJJk5W/Q+WGvNqR5HeJ29QZjFMWuyETz1N3szguL1wP9SkKDsBhyvtGd?= =?utf-8?q?wMPxJFLhah9CGCzrZkJwi77wV08yvjLgJY809bwdMt6DIIFji/0EMyzHbucG89hhx?= =?utf-8?q?tGBPD5GqGWd/eiK/diFCzmxcxC5N99AINv6e5Qj8Y1u7RmzbTgmbgOPsszulQC135?= =?utf-8?q?3leM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7f/2Hq5UC9RVoNHwUCC6dv2DrNVkqzCfXe2TZN18JD7w?= =?utf-8?q?zxHCitHVZ/baiCo6iPVan2ihACdZLkzNE2dflp2WrPwNPtFdBd5h+aidIxTyY3tUk?= =?utf-8?q?QnwGGzoKomCDiRj/uS/RRGrGINOGrTGB1H+BsmYN7Jebqo4jbfqXrXSKvrZq0MDhe?= =?utf-8?q?9HiS9lAO2mOSkvq/1xSusMxoqSbX4qR20vyiadCSimGE4hlsHQuSa/CllJQ3mbuX/?= =?utf-8?q?PeORFyCqlG86LgT9cZ42GhqMmY43kGIF7P+UxNsHyHSeSYbedZLTxv4yDk7THVHj5?= =?utf-8?q?4i2myvPHA8HPhZ/m4TV0p99WTUu7O8doNG35eZPOHI6kDxNyNGrCEzDoMZ8dFU071?= =?utf-8?q?eXpf9zjgl01oSHJnr3AbpUaxjEJwuJAuaT1gR1AJFK8sgB/T/UwtEXZ+xfI5JB1ru?= =?utf-8?q?enlYoFn5RT1ihmqMh4hiapkRdDwY08YApZIytdpm1S71O0jmEGXY2ZY=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 667d2f9d-01b6-4853-d4a4-08d9b4b8c1cb X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2021 10:53:06.8968 (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: rWVhRqI369Puhq9W04OtoL1rtS6WyGf2AvwMOX+LQTuH5077rcrLrbf43k3b4qOjxYwYphWTJ0Ik4uOFOZjhhg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3534 Avoid recurring MFN -> page or page -> MFN translations. Drop the pretty pointless local variable "p". Make sure the MFN logged in a debugging error message is actually the offending one. Adjust style. Signed-off-by: Jan Beulich --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -58,14 +58,10 @@ p2m_pod_cache_add(struct p2m_domain *p2m unsigned int order) { unsigned long i; - struct page_info *p; struct domain *d = p2m->domain; + mfn_t mfn = page_to_mfn(page); #ifndef NDEBUG - mfn_t mfn; - - mfn = page_to_mfn(page); - /* Check to make sure this is a contiguous region */ if ( mfn_x(mfn) & ((1UL << order) - 1) ) { @@ -74,17 +70,14 @@ p2m_pod_cache_add(struct p2m_domain *p2m return -1; } - for ( i = 0; i < 1UL << order ; i++) + for ( i = 0; i < (1UL << order); i++) { - struct domain * od; + const struct domain *od = page_get_owner(page + i); - p = mfn_to_page(mfn_add(mfn, i)); - od = page_get_owner(p); if ( od != d ) { - printk("%s: mfn %lx expected owner d%d, got owner d%d!\n", - __func__, mfn_x(mfn), d->domain_id, - od ? od->domain_id : -1); + printk("%s: mfn %lx owner: expected %pd, got %pd!\n", + __func__, mfn_x(mfn) + i, d, od); return -1; } } @@ -98,16 +91,12 @@ p2m_pod_cache_add(struct p2m_domain *p2m * promise to provide zero pages. So we scrub pages before using. */ for ( i = 0; i < (1UL << order); i++ ) - clear_domain_page(mfn_add(page_to_mfn(page), i)); + clear_domain_page(mfn_add(mfn, i)); /* First, take all pages off the domain list */ lock_page_alloc(p2m); - for ( i = 0; i < 1UL << order ; i++ ) - { - p = page + i; - page_list_del(p, &d->page_list); - } - + for ( i = 0; i < (1UL << order); i++ ) + page_list_del(page + i, &d->page_list); unlock_page_alloc(p2m); /* Then add to the appropriate populate-on-demand list. */ From patchwork Wed Dec 1 10:53:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12649727 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 0870DC433F5 for ; Wed, 1 Dec 2021 10:54:04 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.235852.409096 (Exim 4.92) (envelope-from ) id 1msNF8-0001X6-Nd; Wed, 01 Dec 2021 10:53:42 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 235852.409096; Wed, 01 Dec 2021 10:53:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1msNF8-0001Wz-Ka; Wed, 01 Dec 2021 10:53:42 +0000 Received: by outflank-mailman (input) for mailman id 235852; Wed, 01 Dec 2021 10:53:41 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1msNF6-0001JS-SG for xen-devel@lists.xenproject.org; Wed, 01 Dec 2021 10:53:40 +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 652bfe92-5293-11ec-b945-1df2895da90e; Wed, 01 Dec 2021 11:42:35 +0100 (CET) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04lp2055.outbound.protection.outlook.com [104.47.14.55]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-39-FgZvrVmPMySAsPVC5_PT4A-1; Wed, 01 Dec 2021 11:53:39 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB5741.eurprd04.prod.outlook.com (2603:10a6:803:df::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23; Wed, 1 Dec 2021 10:53:38 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::5951:a489:1cf0:19fe]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::5951:a489:1cf0:19fe%5]) with mapi id 15.20.4734.024; Wed, 1 Dec 2021 10:53:38 +0000 Received: from [10.156.60.236] (37.24.206.209) by AS9PR06CA0107.eurprd06.prod.outlook.com (2603:10a6:20b:465::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.22 via Frontend Transport; Wed, 1 Dec 2021 10:53:37 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 652bfe92-5293-11ec-b945-1df2895da90e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1638356019; 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=0OKNfDnsUjtw+PEZVjp549hJsBhAjbhkyxNkaubCrTw=; b=ksPPHNcVgyP7OTl5f7QeT4eqRoyop5MQcbEspB+6ZldaTGQb32NTBsIajmFObzosBbdcpP w5XoZPw00SnSdtsNm/RSvjkc4EWP5nxSC+POc3QIyq0hYobu71H+i8QPfk9Q2VYYSUg4ZS Y1r/rEqPKJmbvNaoYQrrxqlzGWxHMGo= X-MC-Unique: FgZvrVmPMySAsPVC5_PT4A-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SJBBbvD0w7X4v3pY/jwz8YMyceXAaw8Vq5k63hcV2BNRxC6V5BFPlLX/cg6NtTX0bFHphr/2Vs0lbTxaUdmYCeP9Hf5HE3s42Jt8V6HpKWz645lM9mDGDC8VBJIF+o4wFUpGZ0vrQfIhpyfz+J7bJ235IgWP7Su7i9mqDMg44e35PdoPZogX/uxHPmq76Aeblx0IX+ixIZb29vxU43RMNB5rIOPbkzBHMKLiqcBzc0N7r4oIpxobVR2l56tpNE6obEIbNouP6rRwmHVVCNgr19hQN8/XiHbCJt3IIupRgGHmNicvQj93aImxQ4mP2fO8V/Z5Um07GvcgkRDZerCHrg== 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=0OKNfDnsUjtw+PEZVjp549hJsBhAjbhkyxNkaubCrTw=; b=e/IEfBMBeEA03WImd7WmMt1dpA9nJkbjXdZRjLJR6RqqyO8iPSt3esURIz0W1Y0ErP6ApGd2vd6J9COc8ytYM0GNOjT2Sh3Odeh86fg1Ew+1ZdMgX98N3zO81JNRoNDSefPlEif8si6xL/EdN2sXw4kN3HiYusKQvDTTzKYW2GjggyT2zq/X+5cMQ9/v7o6sHJogzKWPreqY6Bj/oMRE6uvH+YvxA7lEYfOU/X380SJeey3FfqL8jmMNyxiHaDtq9f962sggCdQoXfdHWA4DGr7veeoYRBtwfOeccVC2/b59dkLOnsIynlduSVJ5uUPNDYqxVFd/EgTx5gzy8iFeRw== 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: <0ec2eb9c-a4b9-65c3-3751-3a7fb9b760c1@suse.com> Date: Wed, 1 Dec 2021 11:53:36 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: [PATCH 2/4] x86/PoD: HVM guests can't pin their pages 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: <21148e89-4750-3112-1096-36119be96c7e@suse.com> In-Reply-To: <21148e89-4750-3112-1096-36119be96c7e@suse.com> X-ClientProxiedBy: AS9PR06CA0107.eurprd06.prod.outlook.com (2603:10a6:20b:465::31) 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: bf323e91-2674-4621-5917-08d9b4b8d447 X-MS-TrafficTypeDiagnostic: VI1PR04MB5741: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2043; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JcK5rrlheRLPTKBLj4VCCKqMgct6tlF0uhZO+eO1P/Vio8ZpAMUgos1dHCBZOWCfm6ok9mZKkHMoygiEYUhzcLoOslpR79F/6rjwWPlDpKdtpFkloMf2qKlwDPJzSKlswvYdC9DhGrdiTupTlOiqsH74GvqEIt+7Yz0QHHJ/4jh+IXuApKEFun7o0BgVM07ryJAh3D1oqhmF5gTonEGy7d/GZzpzZEvaZ2EUK8KaAPpxagjIRxn4cFOvCZqWld3dsTaUwb9cdbTTuoOqSyMSAJPXA1UQFfXRKOKIXxwXDTwhV6iBeCEDElHXddOfQ8riljekEsG73NBS6kCv46WpcAUtx0j6pOmiol9ojIHwixRSBlilJ0I5Hgryf6mUH3axRyONRgj36YuuWcFjUnepsRoJ898yZgFrE65KjHllXqxCKAOCBREq4RU3vslfBsKc49Nr8x6UXE0pMrc/UWrJGzBx0lriHiEkaiJ2WAD+K9LIOiu3jisLAzYPFtgePHlFOeh6oAHW2c6AUZccPYNpfXVz1sdRYO9h4ZyQTjsLAcXGKncmoleq2lolHlTL1s26jwEMxm5BsQ52pZ3BDNeDIpuKZncNNYUZei51TN125pc2VeXm00aVVdVDRnX06mnRvmJUCTO777Sowd48cqfciEEd488sQpUK/OHCfTB5DXyA7DMY0qNWNLq24EGpBajoHwixOqyEpiUmrUegmAjHZ2jL0Jpm/f4uOcXFsM4uir8erDmWcL6M4QbPNwpkiqE+ 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:(366004)(186003)(508600001)(66476007)(54906003)(2906002)(6486002)(5660300002)(66556008)(66946007)(8936002)(38100700002)(36756003)(2616005)(31686004)(26005)(316002)(31696002)(4326008)(86362001)(956004)(6916009)(16576012)(8676002)(4744005)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?RMMjKP+sjVUriQcLWifyCFTIiae+?= =?utf-8?q?oOj0u5Wat0Matdo+9tCxH+RoumbcSHPLwWpHGrk44dPmTxdQryzRe6UTUMpGn4whr?= =?utf-8?q?h6TNy8QvqaZeAxVqbBB3s9Pcmj5fAm7IPg/bmrfJE90mL/CietfteixuLHySEg53Q?= =?utf-8?q?ooJNel022aH/pG4xAnqaKGK87rpfJU9XYvDTm9VlObuTlmwNEfVpeN/AWQQYWxo5Q?= =?utf-8?q?1KDWrU2Q84j3lTlkkpkh5+divpbMmE8j+3YWDbBNrfEBve/ilLK5EM/eUZv99+zC5?= =?utf-8?q?NARpIbuF2Xsy37H1B64WKirHWzbs/MmZ2ZA4KX+mZ7baaIKIRa6+0suM4yGKi2N91?= =?utf-8?q?VOzk0GOs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1nX2OQymF3aJMmkazji2wIYYxAa5EclPoJTsRic7GXVXts/?= =?utf-8?q?AkdFDfGlUOPEeseBP1u1oBiABP+5/+hHlHCbhzVjS2PFAWe/zbr6XMLlIQzSaq5PX?= =?utf-8?q?TuhYxoX+3F7Ef8lSEbPvcbN+QbprO4l3WiUx7jL2nQxzrJSmKp+xxpaN+GsCGAtHy?= =?utf-8?q?UjcPCuRCiB806jPNzRRlGWgHE4g129cIWkphq4U8Wwl8h8/ApRiGIrBWniatJTPli?= =?utf-8?q?086eAWqb2JqN3Vxrfkm6BpaqM8IgSx5779XadV1ZRHJku8RNpsxYZXZJ3bmL3IHdT?= =?utf-8?q?jOA1Q21+rYhbWczWDhEp6ojOXq/XACwqI4iKWdBf4ABELio7SMYgJTQ=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: bf323e91-2674-4621-5917-08d9b4b8d447 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2021 10:53:37.9252 (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: DxCtCIvilLraJpxPKoTcFeAQn21s/cCQebirkaoCfNgzTbPwhzCFjchJSgudAWhJqMm/ZTg9jNqtCnRCSe6Thw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5741 Pinning is a PV concept, used there only for page table pages. Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper --- I'm actually inclined to hide _PGT_pinned in !HVM builds; the downside of doing so is some new #ifdef-ary which would need adding. --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -260,9 +260,6 @@ p2m_pod_set_cache_target(struct p2m_doma goto out; } - if ( test_and_clear_bit(_PGT_pinned, &(page+i)->u.inuse.type_info) ) - put_page_and_type(page + i); - put_page_alloc_ref(page + i); put_page(page + i); From patchwork Wed Dec 1 10:54:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12649729 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 888D4C433F5 for ; Wed, 1 Dec 2021 10:54:55 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.235861.409106 (Exim 4.92) (envelope-from ) id 1msNGA-0002DR-5K; Wed, 01 Dec 2021 10:54:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 235861.409106; Wed, 01 Dec 2021 10:54:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1msNGA-0002DK-2T; Wed, 01 Dec 2021 10:54:46 +0000 Received: by outflank-mailman (input) for mailman id 235861; Wed, 01 Dec 2021 10:54:44 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1msNG8-00029y-0n for xen-devel@lists.xenproject.org; Wed, 01 Dec 2021 10:54:44 +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 16f9d8f0-5295-11ec-976b-d102b41d0961; Wed, 01 Dec 2021 11:54:43 +0100 (CET) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03lp2059.outbound.protection.outlook.com [104.47.9.59]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-35-9MX1PPkOPlSCw58qVc7xoA-1; Wed, 01 Dec 2021 11:54:42 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB5741.eurprd04.prod.outlook.com (2603:10a6:803:df::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23; Wed, 1 Dec 2021 10:54:41 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::5951:a489:1cf0:19fe]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::5951:a489:1cf0:19fe%5]) with mapi id 15.20.4734.024; Wed, 1 Dec 2021 10:54:41 +0000 Received: from [10.156.60.236] (37.24.206.209) by AS8PR05CA0022.eurprd05.prod.outlook.com (2603:10a6:20b:311::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23 via Frontend Transport; Wed, 1 Dec 2021 10:54:40 +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: 16f9d8f0-5295-11ec-976b-d102b41d0961 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1638356083; 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=pYFz+VhG8wlpeeBq7xjjYCfhq2Lp5V/iDsZjW/ovDgI=; b=imIlm5pRNg84YDoRkPkwItqf8B3QRaqv1lk4kXv4NY2vI0Ku4Vd6LgNxlabALe0RaYoQMV 05Qp2zHhfGtW3fcsc0La4p5vHhe20s7pVyl1YXW0Fm4goofEqYAnfOZ2jgpjTJSuqk95yb pE9m6bgg5hH/SleEnrzJBnSR8olIZQs= X-MC-Unique: 9MX1PPkOPlSCw58qVc7xoA-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WBBTSpNdiwDZqxh01E8ciNhLj9VUVZqkBGQFcvwb8LSIGNJKSaYOagsI0Cpv4T8H/wSrAZO6fmCEgLfKueeIt52KjhaWWeN9fbGIgDp8/WNpaPalGXEPFGh25XjNwfIEKBC4V4F/CYHlybr8x3nfeEMzRUm2sy8U496u394EkVVzkkzRoO9redw9EuEZA9sRHNn9qxUZYk5V2UOZqh9GgAS53kIkb1KOhK+cU7FdoDrBd+e5kOMquvTZkAP5Zo7lkfSQ5NWRFuXXTyDpcOT6+d9PawPNS7F/0iIeqdJxUsZYipOeneEcPeXcxM5e0nZNiifG+to/6IjB76wh47EjmA== 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=pYFz+VhG8wlpeeBq7xjjYCfhq2Lp5V/iDsZjW/ovDgI=; b=ixA8H4aV6ECgiwPYpLv+hTtNNeyECSC2c6wU8FplOlOvbnqnFMPe/6A3LprPoDCQwhv71417lbpfglF9+YKwJzBcl+ObUUwvwmdCBq7JRZsh7ivbGfXbG7ZzJTiuthAVy/Rx0dcM+mS7DGrJHRIr1er8KpJb0RIFVb4XZRFjsR2fNG7R8gTC93q+oItGHHFLn3xWKXkJxUYUOF1GaNgfXOMQBV+ymhR8DMCF5e4MjQajRDiV+T7NdfQ9VxPBVC5edqSbtKNzIak7pLr/osJInorLelTUf/AjJ33kuEk0GW6zICaqNA3JRcvMpQ3+ueCjSzFES2z5S0cyxcF0OOU0Yw== 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: <09aaf19a-b03e-7f41-208e-bfc6bb968049@suse.com> Date: Wed, 1 Dec 2021 11:54:39 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: [PATCH 3/4] x86/altp2m: p2m_altp2m_get_or_propagate() should honor present page order 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 , Alexandru Isaila , Petre Pircalabu References: <21148e89-4750-3112-1096-36119be96c7e@suse.com> In-Reply-To: <21148e89-4750-3112-1096-36119be96c7e@suse.com> X-ClientProxiedBy: AS8PR05CA0022.eurprd05.prod.outlook.com (2603:10a6:20b:311::27) 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: cafaafff-ce6b-4d2a-dadd-08d9b4b8fa05 X-MS-TrafficTypeDiagnostic: VI1PR04MB5741: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ko+I2e9g9myVvqGVVesu5g4R5QATjtcMaRgskJ1+mStj8gApCytF7yhQElxKshdg4CVNUJH2ofcJir/Jw/PT/lo/W2g7yEZYKnzuQGpvrM9ZiAEEpa6O9woAAfcgnfZ6a01FZ+sFpAxg7CBICoEG+6Q1yYvjUr5M3TxyoqSYRsGVCymsyuZzlEvmJ/JQnxG4pkOImGn2vnEK2ogLSfccFqVxaKAENI3hnrQg0w98ceRUk3+0SXv6mfHdtDB58cNnre5/MEPHGj7KRSQWOuYg/co8E34IZeOKzAJXlPVHVjs69Q9AY+JvX7vHbA/WB5dcrNbBg6Uss4+0VKm3Lv3QqFllGEjSeHd8AwrXBV22bM6kxqd3sBm1CpvJMnTBmc9CL2SmrpK1pTkmt1Z1iSAb/S5KZEp34UcTsis2s5TiWzN+KICQxfxKXEAq8HBAk5Yi5PoQi7dUu5E9imLRHui/EVUq4TKLxpchuqUTOrYjFw09DY95A+WVm/EYQ9c9VQcbm2HpqM+oQ7zoVuszyZDf4+5C/DRWHIfa4z1qz9VQ2meG9snEQkgkxiUohl9uLak3EVEQgYjwUUjjaOr2RW0T+c+Ck+RyAMslVU9tTUHp9m86F4p6nZrjvkRfQ+LLqFQpH7AtzxdHqPZGtHkPBgEV5TToXHvGK9pj2N80aQFz06HY27RiPwZKsSwaXmkYKBI8e9lv/qpkUn/10EU+J0TtKePEFX81mf2d4KOrlaQPYeF4gjfXF4ycoD+UIP3HA3yr 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:(366004)(186003)(508600001)(66476007)(54906003)(2906002)(6486002)(5660300002)(66556008)(66946007)(8936002)(38100700002)(36756003)(2616005)(31686004)(26005)(316002)(31696002)(4326008)(86362001)(83380400001)(956004)(6916009)(16576012)(8676002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?J42tH9OWQZqxDi1ixJT4G5w0310r?= =?utf-8?q?/jdYv4VGYZWp3FZ3jn2FLFezDtmug3ii0PhsTODvnKw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3Ok3WynJeYUERAA/GH+amesRtUM1?= =?utf-8?q?fS/4enGydG0f/6RUflVuNcK1sG4DzfQzub2HsX17iWSpXAU1C6zffGbA3b6QRUsaQ?= =?utf-8?q?LfsN29KyF5KOXxPZpiT4eReNQLD3Mioty9lrdnDwh7N1GcSGsZsDlxpG0A+n9yGVP?= =?utf-8?q?0XesTnuajqKRNGkfELqDF1iBNVW0Ql8ACwqNb+qd35AmgiS3qOhN7/2uZCc+/CsaI?= =?utf-8?q?dzCe+9SyHM3jVCMaJ3cH6bUoMkRfVDPZft00f5rf7qMr7PzLaHwrY8VTkJK6DHJlK?= =?utf-8?q?DG9xhIZly24j6RgWC+SQTe5YCg/HdojGKRXpOu4VtaLAPwicD5FwUtTQoewliarMV?= =?utf-8?q?fs03BiO8JB4n5IUPW+78n+yAf8O44jxhmHsfm15lSmARX4y9HqFKCv6Qe1fnndXvb?= =?utf-8?q?uh7tcvnxFPc/UoxhXQxZpTBoRCzGw6pH/97rrDiONa6i5uayXstinhytTBA49usvD?= =?utf-8?q?MItqQSmNaGeNT/tyzlS3Dx5Ur1CRf9qGXo6T72FenHzrIvLFLsvo2dYYIFe+rxJVf?= =?utf-8?q?WXTcvDEruuHUQ/GISTmgmHaJM5Eov9Q9EtXSUabEFBI+u55JGehp/ioqwGox+tMnh?= =?utf-8?q?nHXE9zhrSkS2euqO0GKBneV0JKy1ZmC+OmmXtNF5c1wOjwu22Kf3JNc=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: cafaafff-ce6b-4d2a-dadd-08d9b4b8fa05 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2021 10:54:41.2405 (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: LC2qngut7yEBEc52JlE65ip36VjwAk2iOaCZXA1779do7YI8JB+YKGqSAr2pLIVI2IqeWel7FQhQq4J5z8d/6Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5741 Prior to XSA-304 the only caller merely happened to not use any further the order value that it passes into the function. Already then this was a latent issue: The function really should, in the "get" case, hand back the order the underlying mapping actually uses (or actually the smaller of the two), such that (going forward) there wouldn't be any action on unrelated mappings (in particular ones which did already diverge from the host P2M). Similarly in the "propagate" case only the smaller of the two orders should actually get used for creating the new entry, again to avoid altering mappings which did already diverge from the host P2M. Signed-off-by: Jan Beulich --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1826,7 +1826,7 @@ int hvm_hap_nested_page_fault(paddr_t gp * altp2m. */ if ( p2m_altp2m_get_or_propagate(p2m, gfn, &mfn, &p2mt, - &p2ma, page_order) ) + &p2ma, &page_order) ) { /* Entry was copied from host -- retry fault */ rc = 1; --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -2198,10 +2198,11 @@ bool_t p2m_switch_vcpu_altp2m_by_id(stru */ bool p2m_altp2m_get_or_propagate(struct p2m_domain *ap2m, unsigned long gfn_l, mfn_t *mfn, p2m_type_t *p2mt, - p2m_access_t *p2ma, unsigned int page_order) + p2m_access_t *p2ma, unsigned int *page_order) { p2m_type_t ap2mt; p2m_access_t ap2ma; + unsigned int cur_order; unsigned long mask; gfn_t gfn; mfn_t amfn; @@ -2214,7 +2215,10 @@ bool p2m_altp2m_get_or_propagate(struct */ p2m_lock(ap2m); - amfn = get_gfn_type_access(ap2m, gfn_l, &ap2mt, &ap2ma, 0, NULL); + amfn = get_gfn_type_access(ap2m, gfn_l, &ap2mt, &ap2ma, 0, &cur_order); + + if ( cur_order > *page_order ) + cur_order = *page_order; if ( !mfn_eq(amfn, INVALID_MFN) ) { @@ -2222,6 +2226,7 @@ bool p2m_altp2m_get_or_propagate(struct *mfn = amfn; *p2mt = ap2mt; *p2ma = ap2ma; + *page_order = cur_order; return false; } @@ -2229,6 +2234,7 @@ bool p2m_altp2m_get_or_propagate(struct if ( mfn_eq(*mfn, INVALID_MFN) ) { p2m_unlock(ap2m); + *page_order = cur_order; return false; } @@ -2237,11 +2243,11 @@ bool p2m_altp2m_get_or_propagate(struct * to the start of the superpage. NB that we repupose `amfn` * here. */ - mask = ~((1UL << page_order) - 1); + mask = ~((1UL << cur_order) - 1); amfn = _mfn(mfn_x(*mfn) & mask); gfn = _gfn(gfn_l & mask); - rc = p2m_set_entry(ap2m, gfn, amfn, page_order, *p2mt, *p2ma); + rc = p2m_set_entry(ap2m, gfn, amfn, cur_order, *p2mt, *p2ma); p2m_unlock(ap2m); if ( rc ) --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -852,7 +852,7 @@ void p2m_flush_altp2m(struct domain *d); /* Alternate p2m paging */ bool p2m_altp2m_get_or_propagate(struct p2m_domain *ap2m, unsigned long gfn_l, mfn_t *mfn, p2m_type_t *p2mt, - p2m_access_t *p2ma, unsigned int page_order); + p2m_access_t *p2ma, unsigned int *page_order); /* Make a specific alternate p2m valid */ int p2m_init_altp2m_by_id(struct domain *d, unsigned int idx); From patchwork Wed Dec 1 10:55:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12649731 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 6367AC433EF for ; Wed, 1 Dec 2021 10:56:08 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.235865.409117 (Exim 4.92) (envelope-from ) id 1msNHF-0002p0-GM; Wed, 01 Dec 2021 10:55:53 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 235865.409117; Wed, 01 Dec 2021 10:55:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1msNHF-0002ot-DW; Wed, 01 Dec 2021 10:55:53 +0000 Received: by outflank-mailman (input) for mailman id 235865; Wed, 01 Dec 2021 10:55: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 1msNHE-0002ol-4e for xen-devel@lists.xenproject.org; Wed, 01 Dec 2021 10:55: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 b33b6bf5-5293-11ec-b945-1df2895da90e; Wed, 01 Dec 2021 11:44:46 +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-3-VSVIWibIOeSt9CkaisyGAw-1; Wed, 01 Dec 2021 11:55:49 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB4383.eurprd04.prod.outlook.com (2603:10a6:803:6b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.22; Wed, 1 Dec 2021 10:55:46 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::5951:a489:1cf0:19fe]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::5951:a489:1cf0:19fe%5]) with mapi id 15.20.4734.024; Wed, 1 Dec 2021 10:55:46 +0000 Received: from [10.156.60.236] (37.24.206.209) by AM6P193CA0051.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11 via Frontend Transport; Wed, 1 Dec 2021 10:55: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: b33b6bf5-5293-11ec-b945-1df2895da90e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1638356150; 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=EubbiLSoJ7gBkAT814XkFnEd7VOT3g+5pVKJpSG0l1c=; b=iX9J4B76o6sp2RAgzhXzerJIYLRl2W2kHIKHw1LtwBy6NbC/5waOiSHhGUp3N44cwepuao RFTea1W4303fUUkiY8KGWjTYEIg1cBrHcPX8T4Ahbv65yyecl9AWlkQVHME+0d6gIZlG6d x8J+aGGu87RN9iWC2SRhQX/9G1Ov5Xo= X-MC-Unique: VSVIWibIOeSt9CkaisyGAw-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LpGOdPH53N8SypL5PcJCQLZg7FFjVb8YdgJjtqsyL4ByymsPcCz51drN3Ep0QRnTVtrWFcimIwbl7+aFOov26OBkR+44eQcu+8FgU9rlATRU5VXFSjSG7QrzVD7mAvZ7FtK8VGGjgRMRou/kLtSW8ClgUvvg4DzQZIz/NirAz+Jfpj/bEv66VeABhhzVPdaDdslSmI6ebl6yB8hjtkhjpTHe9fCdydlYrIiDfhCDqsnV9bdpuutpAiyYxxLiytsGVWdABtk8o9DcU4CXd3naErSQmvHfSH3qrk/xmAelzUDphztKoJErqF9wfjQF1VRz2PKMuRVBfjaaX0DUWDEBsw== 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=EubbiLSoJ7gBkAT814XkFnEd7VOT3g+5pVKJpSG0l1c=; b=gXCcAbERJqCRQuOg+CNEEQ1BCheq0y5yLlQJlfrAVQvRNag9LcRItK0swqggorQc4a/8XI1G++BczOXBmThpk65tBw/lAEaphyDhSs26snccEq45aXAWwhsWo/HEVh9wW9l6/C4pSeFSW0kOg2qrZRvKIUBdRDaHYFaswPOQWe2Xxz4BKpCVghPzZQVaCRDn++PxUd2ElOdud0x1rwA2i6gcfQbmKuHhYwhMBCOn/+YrbNtnalpVGP0XQ4VeVXicOI7zzNy/z56/eAaf6hd/vtNwl6/1NMCeJh7EJ/gdv9GtwZL847MSTTkfyivuUrHcRdHbtG5FD9UX9Nqend/cAA== 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: <58a47cd2-1ba7-730e-efd4-7ade1f415924@suse.com> Date: Wed, 1 Dec 2021 11:55:44 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: [PATCH RFC 4/4] x86/altp2m: p2m_altp2m_propagate_change() should honor present page order 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 , Petre Pircalabu , Alexandru Isaila References: <21148e89-4750-3112-1096-36119be96c7e@suse.com> In-Reply-To: <21148e89-4750-3112-1096-36119be96c7e@suse.com> X-ClientProxiedBy: AM6P193CA0051.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::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: 00b870af-3c49-4fd3-4d6f-08d9b4b920e2 X-MS-TrafficTypeDiagnostic: VI1PR04MB4383: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CrGgslRV3CdEcWuRxSFRDUheEqFLzrSTULfmiOit9lW1BV5+uYlv6uDi5IAClaAR7CkdvCM3tXYPG5Kiy0IxVrvSKxjIo21E8CFNqsZm11M4jLftiGYQuVDKn+MneVm33noRUGrrEHgWFK85VcfsRM+dYrHRN9mcwqeH7UlvI+/BPcwugSvqkDP/JQ2sW8HSBMMDRAwz6Tk41QhEuTavyHyHUeOqI/zJqrS4/TAFdiyN6/C8FBTU5riHGF4qLTgLE/KDpfuRvk95TTO6QwCU4VIoQwerPFLW5IXcdkOAho51fw2NQvijJNJeq2HD1O4Kd9XnU/vhyvpT9t4JA4gExYGfb7+Q3bONkRGYBhHJc+HTDN6nx/01N2otDMTop3ANQ0hBX+apEo4hXv4Om5WowK4kDaUj0pK+PRdavuqSORP0UbQtzknchfMnGBlxll9QiotqTpqtyAmJgc9xl7Oo84KLpAz9hnajVrnOxmGCt4JSptPq7MF7p20QBiY4iaTEHHeAgD09r0IZMFcAzhX7mkY0LwRYl9lygafTeS2GH62dYVgY3gzYFNS1G2dA9fU0MnJpfo8SUCObTcbu4nhFwuhlIh8SCB9yCROOWsFLA7eZFX71JVgLZFo6iNTl9SnQvO49CII/6W6B+h0Z6CKvaKpjNCyAZq0A9vSwxGnWfkhc7WG36aDHZQKOLkW45wwlPRYT++kEiQsEby4J3EWkjfDbSfvfQS+FVTvf1xbstIqMrgjeTOmHJPfX3swC4MdUeQgMuGjwgigcmxAKN5lUlQ== 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:(366004)(31696002)(8676002)(83380400001)(2616005)(66946007)(31686004)(8936002)(186003)(86362001)(5660300002)(956004)(66476007)(6486002)(4326008)(54906003)(508600001)(6916009)(26005)(38100700002)(316002)(2906002)(16576012)(36756003)(66556008)(21314003)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?+553VHMnC1MBhFdCio5HEVHvQm8E?= =?utf-8?q?jwPCRM8/fcY9K3I8S6EqIAwnSM/LLlbvYDGZY2rP9Ji1QGJTHiHLxxlbbDIYNIJld?= =?utf-8?q?4xF5hLDaK+Gd6YN2KWMbB6+xNSosad9IoRJ39WLhrs+13vevqXWrFHQ+/Cc737hLI?= =?utf-8?q?A97qxLYJC8PAVBq5b4PucVkBDUAbwTMXLtfKcktKJpBXFPwa8RR8hCrrx5TpQUBS+?= =?utf-8?q?j6AQckCA++2LUL42z0WRRsZVRAwoLYTLKprZslOIHuRSW7D1hs5Mn6jBKlMn1fRh3?= =?utf-8?q?VFmiWDPlG7JoScGYGDQfOAKvULAwazwPNQaS0nUxhzkhe7tcUTUIFQ4FE3kY53KcU?= =?utf-8?q?tmy02s12ODTJtbYR8BQkPWtYhSntiS62Rzbl1S+XFJ2GzA6hiEI/OIxBUHOeSElff?= =?utf-8?q?gZMOcAzXWJsQ+bUqoyqiLOIQNiZMBMShZeKSmrcSG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y5FEocP6xqSHEbEf?= =?utf-8?q?2wlaqzlbCXcneotr6yXNlHJspnHrJ1HaCo7vIpjtzFgP7ezr8qdFTQODKK9OH1Fdk?= =?utf-8?q?KkAPBnN0hInQi7MRkEHMFsIqp7nrSGG1HHa2su9AsZgpR/bGp+x5+GvJ5n52i9oLP?= =?utf-8?q?bh30ekTI+szCJGjzUWjYkYPwicdwVZb6e1G5unkDwCaPWv9Al5g9JzXnSwI0stgUk?= =?utf-8?q?LSmL9tULJn7O12z4HcInKeeyNkJ3RsBLx8FlhCIT/ZSK9o8STyABZ58=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 00b870af-3c49-4fd3-4d6f-08d9b4b920e2 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2021 10:55:46.4376 (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: SyggMt3dIO6YL3yhqmaHi+DaZrO8aLIMf3GasfdYUVXVE/gvJnkjGWwsn6+rAc0MCHl8UUM1iQw06Ll+EwcTkA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4383 For higher order mappings the comparison against p2m->min_remapped_gfn needs to take the upper bound of the covered GFN range into account, not just the base GFN. Otherwise, i.e. when dropping a mapping and not overlapping the remapped range, XXX. Note that there's no need to call get_gfn_type_access() ahead of the check against the remapped range boundaries: None of its outputs are needed earlier. Local variables get moved into the more narrow scope to demonstrate this. Signed-off-by: Jan Beulich --- I may be entirely wrong and hence that part of the change may also be wrong, but I'm having trouble seeing why the original "!mfn_eq(m, INVALID_MFN)" wasn't "mfn_eq(m, INVALID_MFN)". Isn't the goal there to pre-fill entries that were previously invalid, instead of undoing prior intentional divergence from the host P2M? (I have intentionally not reflected this aspect in the description yet; I can't really write a description of this without understanding what's going on in case the original code was correct.) When cur_order is below the passed in page_order, the p2m_set_entry() is of course not covering the full range. This could be put in a loop, but locking looks to be a little problematic: If a set of lower order pages gets re-combined to a large one while already having progressed into the range, we'd need to carefully back off. Alternatively the full incoming GFN range could be held locked for the entire loop; this would likely mean relying on gfn_lock() actually resolving to p2m_lock(). But perhaps that's not a big problem, considering that core functions like p2m_get_gfn_type_access() or __put_gfn() assume so, too (because of not taking the order into account at all)? --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -2532,9 +2532,6 @@ int p2m_altp2m_propagate_change(struct d p2m_type_t p2mt, p2m_access_t p2ma) { struct p2m_domain *p2m; - p2m_access_t a; - p2m_type_t t; - mfn_t m; unsigned int i; unsigned int reset_count = 0; unsigned int last_reset_idx = ~0; @@ -2551,12 +2548,30 @@ int p2m_altp2m_propagate_change(struct d continue; p2m = d->arch.altp2m_p2m[i]; - m = get_gfn_type_access(p2m, gfn_x(gfn), &t, &a, 0, NULL); + if ( !mfn_eq(mfn, INVALID_MFN) ) + { + p2m_access_t a; + p2m_type_t t; + unsigned int cur_order; + + if ( mfn_eq(get_gfn_type_access(p2m, gfn_x(gfn), &t, &a, 0, + &cur_order), + INVALID_MFN) ) + { + int rc = p2m_set_entry(p2m, gfn, mfn, min(cur_order, page_order), + p2mt, p2ma); + + /* Best effort: Don't bail on error. */ + if ( !ret ) + ret = rc; + } + + __put_gfn(p2m, gfn_x(gfn)); + } /* Check for a dropped page that may impact this altp2m */ - if ( mfn_eq(mfn, INVALID_MFN) && - gfn_x(gfn) >= p2m->min_remapped_gfn && - gfn_x(gfn) <= p2m->max_remapped_gfn ) + else if ( gfn_x(gfn) + (1UL << page_order) > p2m->min_remapped_gfn && + gfn_x(gfn) <= p2m->max_remapped_gfn ) { if ( !reset_count++ ) { @@ -2566,8 +2581,6 @@ int p2m_altp2m_propagate_change(struct d else { /* At least 2 altp2m's impacted, so reset everything */ - __put_gfn(p2m, gfn_x(gfn)); - for ( i = 0; i < MAX_ALTP2M; i++ ) { if ( i == last_reset_idx || @@ -2581,16 +2594,6 @@ int p2m_altp2m_propagate_change(struct d break; } } - else if ( !mfn_eq(m, INVALID_MFN) ) - { - int rc = p2m_set_entry(p2m, gfn, mfn, page_order, p2mt, p2ma); - - /* Best effort: Don't bail on error. */ - if ( !ret ) - ret = rc; - } - - __put_gfn(p2m, gfn_x(gfn)); } altp2m_list_unlock(d);