From patchwork Wed Feb 23 15:14:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12757058 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 B77DFC433FE for ; Wed, 23 Feb 2022 15:15:14 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.277419.473905 (Exim 4.92) (envelope-from ) id 1nMtM6-0001zT-Go; Wed, 23 Feb 2022 15:15:02 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 277419.473905; Wed, 23 Feb 2022 15:15:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nMtM6-0001z4-Cp; Wed, 23 Feb 2022 15:15:02 +0000 Received: by outflank-mailman (input) for mailman id 277419; Wed, 23 Feb 2022 15:15:01 +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 1nMtM5-0001xo-Gc for xen-devel@lists.xenproject.org; Wed, 23 Feb 2022 15:15:01 +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 5e46f61d-94bb-11ec-8eb8-a37418f5ba1a; Wed, 23 Feb 2022 16:15:00 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2174.outbound.protection.outlook.com [104.47.17.174]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-27-QyKErOFPMvuwCLrVRxdJrw-1; Wed, 23 Feb 2022 16:14:59 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB4624.eurprd04.prod.outlook.com (2603:10a6:803:72::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.26; Wed, 23 Feb 2022 15:14:57 +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:14:57 +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: 5e46f61d-94bb-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1645629300; 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=st09De5AhrTxtdqW5QYgoa+DjF7F0kOPM0aXdyBYarM=; b=VhLilorMbEjZS+D/HH82XbAqqEHEm6pdaxtdFHnsK05Wx15gC8tFD8Gqyb8dL42l5/8CE+ KMGWScs7HlZa1XUyxCBKdM6w+4yjSsVk1RpYkfGyqJa/LYQ/33r/lusJlJggfsqJmDfOrN V1wH1a6Elt0tHQ4KbSpx5j3C4j05Cbw= X-MC-Unique: QyKErOFPMvuwCLrVRxdJrw-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JIfAxmIMAJeqOtVHyS5LYz9eBwzWXekExKRqJizoEc7CGUnEHjcFrbyBcmLf997yA1OiIQgayPxpAvMtx3fWFdLNge82iWHEL7+mWOa+JWU5tLGAEIxmKU9Y0EXqS5mmSBCjQIMymDhXBofTRUzZUb9dCnSfy6YCOEZFxenpnZpR/9WmtxjE4OhlgzAa9stVd/6qWCzIUqbtqDCbyGk9VreJqwLUB5+2QkpiLszL+j609ziZ1nYx9U2ywLMj6rEqAyGKcMMxdHh6QFb3DYyWbVMn8R0g67H11tN3GB1A80CmIm1xAQq/yV4oBKtlnQPy5x9jrONnBLq0GYzupT0sqQ== 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=st09De5AhrTxtdqW5QYgoa+DjF7F0kOPM0aXdyBYarM=; b=HSj84r02CbY+xmuKm5mTllNjAIX1oF5YfGBA8oP6/ZSFRSmbT0Qk8NkfIGdYIpgRoa2kiNmNx4e1lAgeBwlJIDrjdnqVEhvM1Y4FIeDd9imkO9ztWpOdYnUvvm2vHf8FDZizdo9BeB5UpgqP3UZy74NNCWSU+sLwlE5lob0WXdNb5kmeQZlGKS4txWZrcUxFUYS6DdckVPAPoeMeAX4+qe0f/93m1DKMVr0lGBpumayoDUsKywY4C73jPCU9KpjsN0MgRRrMo+k8lM85pl/RB/PD7QPxpV4qI5KtIjBgBglJhLOg338xWgnHf+XDQAITROv6KtsxqUWA/PvHChGESQ== 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: <5a8c1f9e-e91a-a7f5-8c8a-025ab6a39908@suse.com> Date: Wed, 23 Feb 2022 16:14:55 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH 1/2] x86/p2m: make p2m_get_page_from_gfn() handle grant and shared cases better 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: <32526b73-25f7-e6b0-208b-669a7648ee44@suse.com> In-Reply-To: <32526b73-25f7-e6b0-208b-669a7648ee44@suse.com> X-ClientProxiedBy: AS8PR05CA0015.eurprd05.prod.outlook.com (2603:10a6:20b:311::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: 2f341c8c-ac06-4f8e-6496-08d9f6df40cb X-MS-TrafficTypeDiagnostic: VI1PR04MB4624: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: LENeZugZTYcDC8iqmEYrWAdyiPRXg6/a4IwqZnesTjxQ1cJiEpFDvG7gTdsE+05hFmiYoyPB2qdye3gaNHzBaehykW5w9iR+JpbexDHwk7bASKXosjAOAeALzyY873Wwb8pOiWGQkQt8T/OAyF8hyeyFqLCclikb7Imqjp2iDy7GmYjIbjQrpKq5Gg8GHUpe3e2eUb0ixlRKGpB4a5XoDy5N1MbIjCyN5s5HMuwU9rx1rllW48XgYApbZ9s+JKSdoo0kEEyUlKlq71lQrCwXUekd4qh6SbgL3wQVHyo5ntJa812FPlM5fjt793q+kzAbTELwxRWdxhvRM/M9zQxMZaD81XwmCpV/YTAjwSlEMrfmKaAaSiirVVs9J6BIPOzeQUCdf8slVBtqhaF5OJRhrUA+gHjZiXtMc8atKSdjdLG9udeWoSa0U8FctzyaLHd8H6bAlla5Cvr/6Q3j5qsQvhAEV1NkAe5dpaQoi2jr7nSpj6eq7bWJuC3f3vKFOG3oBDCcYvEx0f5RXdzL6fjwnmuSQYPRcJdufJPAG57Kc5zooIPK/MiK3mjrQ7caaGck9Pw4kWuCmj+E9zhBE967N0rWY17HJDfxcEHINnb6Htu0Nmlrs41ZmabwlU8xqEmcwaWZZKTz0Q3d95Lhz+wzqxzuqEwqgG+ya7bqYk1kXEKul2kPr6pYPQwAyL2wpHmiqtH1TJhuj9u1GR12ro2E/VyQDD4ejiBdgNKpQdd4M2qaQZG7DOKvfXbwLWyYasyM 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)(186003)(2616005)(38100700002)(26005)(86362001)(31696002)(83380400001)(54906003)(5660300002)(8676002)(316002)(6916009)(66556008)(66476007)(66946007)(2906002)(4326008)(508600001)(31686004)(6486002)(36756003)(6506007)(6512007)(8936002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?RcZbglprf71g6I9bTUoCNWnwVIMN?= =?utf-8?q?Tlir/04tbDXdLBvETuEnZe6E9xfjAxr8E5/GPvMqQ3XcjiiZyE8KZ40tXqPC8ep7O?= =?utf-8?q?3uCBZKQBk3thbOuVqQk0ErPM4nHMhsXx8k814f42M+hbEGiwGUtYi/6hjMn506Tt3?= =?utf-8?q?fA3ZUkNd0cPWoF1tlLIOKZyyjYGLvB3mUwhDFldRy/Q3IJMuXnBm/wQ+5YbfcsD2I?= =?utf-8?q?IcFhI929l9+FGqvczpUuM46bcPAQcbb35by8MipuJIck14sif2dLQ2okJhpDgvYJ1?= =?utf-8?q?eiJlsouYXpCr9dbjZxrfkTMAin5U9En4WMOBKRguT4WP7fyez3/caonHJ2otJllhZ?= =?utf-8?q?I7su+dXRyB2uEUdZjS+T60xiPMSH/hHZN6iAxGKW62gIZYK6Fga3jlxtgUPjRra6L?= =?utf-8?q?+Myrh6noazy0JFTBFPWoGhj13i/f/L2EbShqPwAs38pw7LY0IRgLP+MKLNQFNcyEO?= =?utf-8?q?i3+uzM6OLj3FkjxgtKxnkRbHxkcAI98kQ/qiGqR+/55kuD10p4mrCfAiNIMtaohMN?= =?utf-8?q?O4GHOovP8BArje7sQrx5mh2OfgCwMkVu/P8iRSgOc9ZK3zGT2mfrmRtlIJPfk6h26?= =?utf-8?q?cmRd6QqY9RB6xQ5ocob8YZKZheYMfMoyMujJuSfZACHYzjbzmzOVIlZmpE8b+J5vZ?= =?utf-8?q?9yR/0ZU19oW4YeOCzeACTKSidWyQrKsohP4yk+VtCVMgaFr789t/qOrtWnKdfVt9n?= =?utf-8?q?XZeOsbBwLbeiRdhSfPYtgg8HObJSvjI5yROMPTobLDcHFSMEWgcFwQnwdGW3UJAoi?= =?utf-8?q?cEi3tw4uhkyPOgZmGUF1FgASYOOQ+wkK0Y49auoeYyDHjFFQ0f0UimqzyocXRJn1I?= =?utf-8?q?T1WPaH2vOTsG6uMVGvlTXTACekHZXAN6Gvhn/hkDcd9X/K4y/k+hrhwPoHV87OYgk?= =?utf-8?q?CL8DAQAskyKUtwEtJAJ9dZutwBB/x7qCTvEaPniAoTKHQEP+LZKvulsYanntiH9qQ?= =?utf-8?q?SkJC7JYZ+vcVNuITMCr9NSnPWW2VkPu2a6KCdMaRlr3HLotkw1460vD9dDfAN/Uwh?= =?utf-8?q?FI17n1YRUrDo4eID66VZclfGwUGumI4yR3/1FB8sHA6lD2MgcGUmmFGP2O6IyrQFI?= =?utf-8?q?cJ0/wJi+2NTqRvDTkUBxjsSfV1wlo5NNBAWt/v7NZnDp5RDd8v3egbYpodbpAC+u5?= =?utf-8?q?v8/w/bEg99K07NO8H+1ACU6Y93108F3OUGKsdQ9KbKTb5MAwdpClbty4//f3mgLaP?= =?utf-8?q?rupo7JzDpK5WPLwdpPRRZiSXRi3E9hRCIp04piMWj0wi0TgrpEXtTghjqMeeAur36?= =?utf-8?q?sfDWmer1Ub1RUfjV+V//gMwbYrBTDEuQ6Jsqy0ZfAxbimFB5zVJfpEwaybPsO20qP?= =?utf-8?q?7NmtgxEcoZ716Tlw+pQC04Ux8CnmAAcGrI0uFqIVDeCGSxd0UfS2oKgL8SnBkVBlr?= =?utf-8?q?VBcW6MktH4UshdbxwYff/GCQSCQ5XJ5mDhY1ovu6r5Qz/g+RgbQ4Ka8Sokq6z/umg?= =?utf-8?q?busho/xHx5YJt+jtBadIQGEEuvN1OFaXLpeFTk9EqGAYnI3LZ3x8P57YJ1cl4r85c?= =?utf-8?q?l7uCy7o9wm7Huyg8KeUY+bPcfZbCUBxuvobZ6as4bEMPjhEBtUzxXs4=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2f341c8c-ac06-4f8e-6496-08d9f6df40cb 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:14:57.6097 (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: 22Upqrmy8rnUs+MW3vAIqtXHIZbXBNwnk3dZnYBHTi3OnGbmvxuj8ezLzNAYq9pde8ygFlfegoWh0WoSd8YhwA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4624 Grant P2M entries, which are covered by p2m_is_any_ram(), wouldn't pass the get_page() unless the grant was a local one. These need to take the same path as foreign entries. Just the assertion there is not valid for local grants, and hence it triggering needs to be avoided. Shared entries, when unshare is requested, would bypass the retrieval of "page" and thus always take the error path rather than actually trying to unshare by taking the slow path. Signed-off-by: Jan Beulich --- Using | instead of || helps the compiler fold the two p2m_is_*(). --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -584,11 +584,11 @@ struct page_info *p2m_get_page_from_gfn( && !((q & P2M_UNSHARE) && p2m_is_shared(*t)) ) { page = mfn_to_page(mfn); - if ( unlikely(p2m_is_foreign(*t)) ) + if ( unlikely(p2m_is_foreign(*t) | p2m_is_grant(*t)) ) { struct domain *fdom = page_get_owner_and_reference(page); - ASSERT(fdom != p2m->domain); + ASSERT(!p2m_is_foreign(*t) || fdom != p2m->domain); if ( fdom == NULL ) page = NULL; } @@ -607,6 +607,7 @@ struct page_info *p2m_get_page_from_gfn( /* Error path: not a suitable GFN at all */ if ( !p2m_is_ram(*t) && !p2m_is_paging(*t) && !p2m_is_pod(*t) && + (!p2m_is_shared(*t) || !(q & P2M_UNSHARE)) && !mem_sharing_is_fork(p2m->domain) ) return NULL; } From patchwork Wed Feb 23 15:15:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12757059 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 DEB7AC433F5 for ; Wed, 23 Feb 2022 15:15:43 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.277425.473916 (Exim 4.92) (envelope-from ) id 1nMtMa-0002Y5-P6; Wed, 23 Feb 2022 15:15:32 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 277425.473916; Wed, 23 Feb 2022 15:15:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nMtMa-0002Xy-LU; Wed, 23 Feb 2022 15:15:32 +0000 Received: by outflank-mailman (input) for mailman id 277425; Wed, 23 Feb 2022 15:15:31 +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 1nMtMZ-0001xo-KR for xen-devel@lists.xenproject.org; Wed, 23 Feb 2022 15:15:31 +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 70639974-94bb-11ec-8eb8-a37418f5ba1a; Wed, 23 Feb 2022 16:15:30 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2169.outbound.protection.outlook.com [104.47.17.169]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-35-3dQJ3TB0NpCTqpojnSG21g-1; Wed, 23 Feb 2022 16:15:29 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB4624.eurprd04.prod.outlook.com (2603:10a6:803:72::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.26; Wed, 23 Feb 2022 15:15:28 +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:15:28 +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: 70639974-94bb-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1645629330; 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=juNOMnTTaHYlj1GzEVqLULFZt9qHfroO97X6sGnQeak=; b=JCjfno2Q+m+5NNs+lhBer8yZhmOZEY3ExCpzdNszbsS/bymiO+McQ6OqLDKzVp3OiV5XUP A3XT7ztvlU6zZgOUIP3ZFC+RXdfRFT6QBz9L2HK3t0yIA69Ru79YJD1IpbdFz4LfOtXMkh adHcSFyEEKh1JiE+XxSpscNHgesNPVU= X-MC-Unique: 3dQJ3TB0NpCTqpojnSG21g-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NIVaUBF7YAcQAIFyN3rLPE2mXM3gkyPE+WI3IlTzB+l04gNhbd5gU01PsYa6h8E3vX3KejMfjJYXVpRGJV+53AnSY7kb30O519xNGaOrZ74lNcVfwzd0LM2/eYi+tS4YFkjECk97U8zdbqP5KrgxFBzSeQf1IXdpWMPBnrmp0Jh2D7Jp9YBSAE8Jm8JiO4O/2WZm0393XMsNwWnFyQI+1SktvXYWPAUHOsHBqF3c+W78EvoKTjkp6+yboCK5xkKICquGcxI4/eUOufHvjjuWPOmcGno9DDONdSI6CeeUQT3YVHKjXDGZVZfWOiCOX0n2Cibm06u1/PBtkAe3Dfbv2g== 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=juNOMnTTaHYlj1GzEVqLULFZt9qHfroO97X6sGnQeak=; b=mxWQJaWfT87S89A/JU4FoATAQB2xWAqR2MWw0Hnf/n7XkdZq/pYMazFmxsvP6JVtb1Jyc2v2/Ye6O3mLqN9Mh2ADug4wnhb4Y5t9wdhOj074Xdj24mvd9bqZvMPDAk2cxn6RCF7twhFlvrzQHUSUpiahDaTAgU0tGQR/VMOUkE38Qd+ZABJf8dSd6d+avG5mdT7n1VHjWedp9CpnVYJNmBKSfi74BT5nVMEjOmUFVOP3KNrEfu6B/Az8SMk92IzpTfB6bBOPvTGiECPNaN9k9pjIw7qrg+xhhMIdefff7W+PlVkvblhM4RCcsxDRE4KMaDZAlP5T1JGoMhy5ag9Ydg== 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: <0273a69d-0c51-cbd6-e5e9-da861d14cb06@suse.com> Date: Wed, 23 Feb 2022 16:15:26 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH RFC 2/2] x86/p2m: aid the compiler in folding p2m_is_...() 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: <32526b73-25f7-e6b0-208b-669a7648ee44@suse.com> In-Reply-To: <32526b73-25f7-e6b0-208b-669a7648ee44@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: ad62a710-c668-476e-dd3e-08d9f6df532f X-MS-TrafficTypeDiagnostic: VI1PR04MB4624: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: kWY5kXiURfwJAi82lGTxa33Zn33gFFmGWCyOLAb3Ve5hBgElGSVsSfxs/4I6HDvTOtjU3IfSa0vGNeh3cMP46V+bfbxuQyv6Gz7ZhY1KlAmokD2uaJPCvUXGEwrGf4dA+GLjTfkadvKGsOBSrd+Z+I+Kb3eYgqGOE3VNF+7h8K/3X1EahX6jC7in+TIi7BOZN6o8IgRphsX3/9PrCZorICq/HsDaME9cxsQYeC5dlq4sj5ID/iaBKm81lgB8gF5IBEUwGTJFzsnMO/dfGxEZpto30cNppaohOc5AAZDNTTbFRpU+YE3WUprVxzd0SQDFfEyeH3u4vuOXpCvlfw5H5PZyc8v7iOUEIVdAs0HKx4kVziGD0Q4W5npW9yCJ9PwFd4Jj6xfRS4YfshHYZN3Fd24ILCJ0u+l7vjZvwO339OMT9+BxS/zx8b35q+dF6JS3jWbgE3a0Bopop7oPnhverTAfXMDUz+MlYiLXOzhKDrmGeRceNDucFOgS552IgtKwESRgEict4jWoKIGvu0M7rMhFpz0QhXNcw8VX38ITTohS0St3cE7wtpr7ahtr1PxG0MSjn5Cs3nK+63leENK27uBoQ2hj5CStM/o3OMCdcgOchRyaIUrC9EPn9W2t/NvX4KcNIoiMVQdHz0kjB1RvAMW+IkgDNUra0vvqgNMYWBMInbb2+mbwIoViZ7ZPJqc6DQEKO7f7XC6fe1WvI0LDSOXJCj8aVar3d1J/2//fogI= 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)(186003)(2616005)(38100700002)(26005)(86362001)(31696002)(83380400001)(54906003)(5660300002)(8676002)(316002)(6916009)(66556008)(66476007)(66946007)(2906002)(4326008)(508600001)(31686004)(6486002)(36756003)(6506007)(6512007)(8936002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?T4mar1yYSaWtnlfpxHACpSJt5mfx?= =?utf-8?q?NVycmSoDUfPojvUpo9thCFh9cvQwCxbZ5pjRwCypzdhB0CSUgdc1KN6Dnmm9J/MIw?= =?utf-8?q?Ot6CFPYOyGBZMLA/JcBhPOuz+iEgcgj2Us28jgvOLC3YhUKZpBVYnCSq7gH1G0cEX?= =?utf-8?q?0EqECIxkVjff8JpuUTc41TY8lurkhD5eRAbgfYxBuI0iW1De6l05+gJjyCvAON8jY?= =?utf-8?q?9XjmYu/d+gwrdyNunetzZ7sql2rjk7ltzgW7WaUJTkRydJV1E2WDL7cUWi9wXFdlA?= =?utf-8?q?4SJC7cjZ2erjuYsi9S+o4RHOv431vW0ob12XM+AKkGTrHuZScdvUMwBQ6cYJRQcK+?= =?utf-8?q?3geVshtBz0Igbn79HD5viy9zwh2mRVBdP1XmplSvGBcQWEPfUo5a4+fr/wxi+GbeG?= =?utf-8?q?RB68c3H5CyBeF8nBQA5rFsWm1uUe7JzLkNv7pD0cOWlG4KP/wQL1NV57mWADUWWOY?= =?utf-8?q?/iLeF54IWlim2RW8IoJVsUWywKk5/mus4Jn/CWlbXn6x4EnJQK/YJasm22uYsQ3RI?= =?utf-8?q?S6Ob1Xgt7RYhtM0GKJ4Ylarbsn//s34Uy6x0LNVoQfN6Nfnqs3Wm3cpIycqJvPBEC?= =?utf-8?q?G35207cxISENDweUx4BGfnkHd1Sni0chelukm45dozXkXOIj0zpkwUYGr6rMs1X4F?= =?utf-8?q?Tz7EablmEllTkG8geRIjJilEXZlXfi4HXPaVs7MiyN0J+PTIivwtC2tZHQaB+qIln?= =?utf-8?q?nraN2Fmao+6Fla5OrqX23N/m/xAP19SfpHK/VYYb+ICSWObP3cu95XWlWs2FdGft2?= =?utf-8?q?oCrvVDBP37iiETjOHGuWBOE0jB6nZSAjrtksgkcusdwdQDuH1A8O8QYgiWnpwMveg?= =?utf-8?q?WUQv23BTwdaiOL18rFrs6ujX/frkWBMp4HK8QdWpFYfMKhcwg9XCgW0gCAbggdNQ7?= =?utf-8?q?nZivNgsRrYBCwsMuiy/5eVq8zzFHCNTy7M6LoBnnIsRdxi4u2smjJpNxJZt2E1fC5?= =?utf-8?q?ItJXHmSrYju8QZZUpsBACQtqMjS562SNHGxJSYq2tBbrYlwsDSdhEqvtW1UWmkkcD?= =?utf-8?q?4U6lrKYu0XLHzpJeSDO9JMYBbGy7Kw9qTTxECKM2kIp5sVft2bzffvXWuKY8r2bdV?= =?utf-8?q?K9Cp5F0zejey3hRxL7AfXT+gqHhRplPbYYKBIWN1rD6AL1in1DUoG1PQ6WrUhJaW6?= =?utf-8?q?N1CWlam+fes2/qCCh2Kzi5Kz+umIwzM55rwZyWvwldkUc2dEkj3+dnfftKgEn5wGw?= =?utf-8?q?Khy79X/Yw5qedZgzc6RrEu4EIlPUlnvoHZxiM6uxyxBiwO6Ax8NjksW82NPRe3ivq?= =?utf-8?q?tWfSHvKNlCantL2+x8v78/1fcx2+lCNC27uoh+mCPw9Bv2R0PEnwjVyjbvaGdLPbj?= =?utf-8?q?K1g9zrGnd+cBu/PgDV5LYlxOslazeMDe+gpyJUUBQlkV6vM7QDl+nt0qlfOTYH62s?= =?utf-8?q?CRw6jqYB4ks4Nj5rpr0s8/j7WDgGdwQtvzODHowVJhaERnvTGhtK3yld8tRcOImYf?= =?utf-8?q?LbYWzVI3wxqJACKztQJznkQIjWsSPVImMvsrgeAY5WOci6LRzL+W7rcTkkO7MTrij?= =?utf-8?q?pDqMBIS3ujv3wzXKuoEzTEwH9kzt7gtmyArU86idvDzFyJAmjhvFw54=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad62a710-c668-476e-dd3e-08d9f6df532f 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:15:28.4515 (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: aIiUXxWVjq+7PVi8HpT6nMDjEC+LT5wTt74BTQOEFnkPQUVSA1g5lQThNJEPHoK25i31uOnEfIZJCAnjyYw8Ew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4624 By using | instead of || or (in the negated form) && chances increase for the compiler to recognize that both predicates can actually be folded into an expression requiring just a single branch (via OR-ing together the respective P2M_*_TYPES constants). Signed-off-by: Jan Beulich --- RFC: The 3-way checks look to be a general problem for gcc, but even in some 2-way cases it doesn't manage to fold the expressions. Hence it's worth considering to go farther with this transformation, as long as the idea isn't disliked in general. --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -606,7 +606,7 @@ struct page_info *p2m_get_page_from_gfn( return page; /* Error path: not a suitable GFN at all */ - if ( !p2m_is_ram(*t) && !p2m_is_paging(*t) && !p2m_is_pod(*t) && + if ( !(p2m_is_ram(*t) | p2m_is_paging(*t) | p2m_is_pod(*t)) && (!p2m_is_shared(*t) || !(q & P2M_UNSHARE)) && !mem_sharing_is_fork(p2m->domain) ) return NULL; @@ -840,7 +840,7 @@ p2m_remove_page(struct p2m_domain *p2m, for ( i = 0; i < (1UL << page_order); ++i ) { p2m->get_entry(p2m, gfn_add(gfn, i), &t, &a, 0, NULL, NULL); - if ( !p2m_is_hole(t) && !p2m_is_special(t) && !p2m_is_shared(t) ) + if ( !(p2m_is_hole(t) | p2m_is_special(t) | p2m_is_shared(t)) ) { set_gpfn_from_mfn(mfn_x(mfn) + i, gfn_x(gfn) + i); paging_mark_pfn_dirty(p2m->domain, _pfn(gfn_x(gfn) + i));