From patchwork Thu Mar 30 11:24:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13193978 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 5C9BEC6FD1D for ; Thu, 30 Mar 2023 11:25:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.516622.801033 (Exim 4.92) (envelope-from ) id 1phqOk-00067K-AZ; Thu, 30 Mar 2023 11:24:54 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 516622.801033; Thu, 30 Mar 2023 11:24: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 1phqOk-00067D-6u; Thu, 30 Mar 2023 11:24:54 +0000 Received: by outflank-mailman (input) for mailman id 516622; Thu, 30 Mar 2023 11:24:52 +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 1phqOi-000675-7f for xen-devel@lists.xenproject.org; Thu, 30 Mar 2023 11:24:52 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on20626.outbound.protection.outlook.com [2a01:111:f400:7d00::626]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7c5f2507-ceed-11ed-85db-49a42c6b2330; Thu, 30 Mar 2023 13:24:51 +0200 (CEST) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AS8PR04MB8214.eurprd04.prod.outlook.com (2603:10a6:20b:3b0::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.22; Thu, 30 Mar 2023 11:24:49 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b%6]) with mapi id 15.20.6222.033; Thu, 30 Mar 2023 11:24: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: 7c5f2507-ceed-11ed-85db-49a42c6b2330 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ed5Yb64HBDEojDTjedNMJvcrMEl1ZGkCW/6Uow5ImvTX61u8o5rxNDFZCeI0a2onvnOxBcpLzbgOxVeJL/sLadCfz8TUDOF32EP8ZohsNmCvuj0cXyU2Tgo+Eg3NzDD4y6u6bjk7TGIvj8LOismoCWHW0DJRnBXHAyCB1VlQRaOdEQIiys1PkU5JFDzvbHRcW7j/QqK5sU7J3mke0KD1ngVFiBrbVqdilmp3PGv5L0yw0kcgrm1QkLvLQVOFJuyPBb0Z14zxlFYZo4qSHRjPTmn60Nb1ATBxGMU+fXbb9Xsgb54Qd167SjvQ0FtfHcGaX/yXGwp2cm/cUq8480Xqwg== 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=IXU8ERDT0GGzzL6ivSLQ/bjRaCzv5zsN1CtsZo5Kh5Y=; b=bq9zzMcmjNHaQTaJKzNvCF8ksQZQdjVV6PZSae6/eRQRGw9676U/V4dkFvyn5Lm7zPCI4kP7F03AyA4xiSyG1RlbpbmztOsVOs+tCu1llvRJ8Wdzt1xuAOlbxf7J7hKKZMXOzhqf2ath1WopiatS6bneapzIOK33JrPS1DWsx8uciPYY7IVOXihkFmDUi/sTvHKeqYwG+XxmiR2/DcQquJyTLRIIcI2UGfrxlUgOkUubU+6ofE1FXu3NMgtqJbwfVdSmZhPkOhBqQNQ+YBPbbPuu4LAdeC1RcFyOIvZF3J7Fju9T5BI33pFckw/cuzaAIB4roqJHFzuBP857fuP+Ng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IXU8ERDT0GGzzL6ivSLQ/bjRaCzv5zsN1CtsZo5Kh5Y=; b=1jjis2BQLYgqLLnolxKuGOBtt+jbERMlKBjhSw1VZMcyRoYGNv22x6FA8ZpWWC/qeZdgDu3M3D77XgEl378MaVgRSO69571EXpY0RehC/GSPC999VIuC2ONjz1FYDfofoV+eaYVN/j06Sqs9KM+ZaVkfC/qY4pCTMKLS/QKRdFRAa8dAue5jypfsIDtC33vPTJa7YXvFZ9SNgT/DJP/48XyXkdESAiCIbc9WmUHKEzwXDJK7y5UM9HLSAJprvs5qsoPl7Zvkx/Rr9toAjGkC7oXLhpI+m8PClB0Sqx+NMLLbYIq/PRYlWxwU1fe0sjFQmbsN4rQaCQp8TDVFvkPYUg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Thu, 30 Mar 2023 13:24:48 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: [PATCH v2 01/13] x86/shadow: rename SHADOW_FOREACH_LE() to FOREACH_PRESENT_LE() Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Tim Deegan References: In-Reply-To: X-ClientProxiedBy: FR0P281CA0218.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ac::14) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AS8PR04MB8214:EE_ X-MS-Office365-Filtering-Correlation-Id: 13a6fa75-b8ba-43bd-ac0a-08db31115fc7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2twCQSf5zbI+6lLJnnyt3wyYFXaGsXSLlpmrY/2PAVL78yzz+XPGIbjIvdZkLxleZmZI/iRASxqZyCuAj+ZB+mA/1u0mttCRh26XtkDWOFkhZcYSj9D0gfGAdRD+1kFXASmmTjQYQxKZjoNWzdd8ywKvxtsfnzWMQUsfiv67SMsGYV/f+QN6WkdkI2oAkvRrGq4aWt6iijG4DgZZipOSbkJeCurOjg0onPnIwmW+JE/YKN8l4kN7zv+ZDsVBolBvHBgMFIdCc9xSjUgjSnJT2NyznnK3BNkRtiWJXa2u+VFwlUct1U6jYqOiOZFUI7kzXvFeX4MWz6zaI0TPY4Yqa68kHyZBsGmrB7LtK7ryfREcGApUPzjJVjLfSqcmPmpsFBWCAWKu9vVNi51cpK1Jfg4WDKBO2lSP8zWUEbHEw11eOhJxxVAR2efTUMHLQXek2SPRjum6y0FheDUeSpiD/djV4eAQ1TaGMvkhuMBDcRil3yUkflR58e/Uc5ehOHQ7pl4/B1QxE6v742IEGIr0ts8P1+3RWOwqWqcEf5AnYJEi3S8kJkpiEv8nQC7jBOOJldavLnhkBYywlwu0TvTW79S/0k72MGxpJh1dgYZrr0hx1Mx6SpikSp2Uh9LUpV4l/wmpY5jd1kW1/E0mudb1RSKogzXLB752DDU/NP9eDS8z7TvQ4oQ56hJwlPfQm94SEw1Uqq+3vCYcqKd+hD8GkwQkSeTKmge4dxGFasa6cGs= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(39860400002)(366004)(136003)(376002)(451199021)(2616005)(186003)(83380400001)(6486002)(478600001)(26005)(316002)(6512007)(54906003)(2906002)(6506007)(36756003)(5660300002)(6916009)(38100700002)(8936002)(66476007)(66946007)(66556008)(41300700001)(31696002)(8676002)(86362001)(4326008)(31686004)(43740500002)(45980500001)(414714003)(473944003)(357404004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?vqVFBJI1nnIExLOtx7HAgV60q2dc?= =?utf-8?q?cjHE/Gl2GNAfk5ZSRBbgKLOBkM2mmj08HM+IT9UJkUFrKrZnlejBJoOWn8wvjsMNa?= =?utf-8?q?+lnNTQQN/GAKA4rp+GbnoEvulPTcaYjBZRv2tdj9gxejOo5p1mo87MyMNjOtnvLWz?= =?utf-8?q?NdqK0fcdKqoE5PyB+r6+SLHtPVxY3i2BljQaphvmwpiCNZ6Azvyb+EkksK0QX3uBM?= =?utf-8?q?XWlHultD1bitv5Ykwp62FBs9du7Hw4IQyjAYmSje7E/XSNyiYfNigeXl/RoT1rctJ?= =?utf-8?q?8H1YiOJqDfXUjL6/O1XQDmSIHrUCfC2UXSlDgvgnw9qoa5DsjRZuRqiHicACnf90+?= =?utf-8?q?O5kyd0CoLAW+YJfTbmPEA/dyOxgve6Sm+aNF85w24vfUmEChxub1aqm77qz48JNvR?= =?utf-8?q?841C2htQD22cA1RNo57CgvEyy5dLW1ILor0CCEeD3u/nlDOAfNNfNe42VMGuBzCnK?= =?utf-8?q?e04jHpkpAhoZ7z/c5OmUpV0KNSppUwdwgByW9gQUrBDV9H+SntwJxJFeXuhl3i68V?= =?utf-8?q?e3hg1fa+RhGRCh47Ss9XOv1MMFBoPqTpy35suNpUt8896G0mbkNizG80oZxZNx0x3?= =?utf-8?q?hD9646vVuy1YJs9dH8gHNIeEx35/z/BfIgTSfwuMSbSNWOEkMKHodr+Aq+F9xL8ZB?= =?utf-8?q?5G61cSL418U4Vdadi2XvXWAYL8PtsU2EGSkZE3EQfm5aR5/v1OueHs03Ec80/zKpQ?= =?utf-8?q?uQqO3AEgVXVc2rjf3z0w6ZQAY5vydnzc5s+tGdLmj2UYUTD1SlDUPjKP970XePnYq?= =?utf-8?q?MiteVUsn4VJmVUeb3/TW0RJUzGXKPBcp6kP4IFHEp9p6pPXbj+HikKa1mqNVVtje6?= =?utf-8?q?aUmznil1fwvuoYyCzogvwco4s4yJB4RtCXAt4w35piy35hwKzv6EOZoLZfaVtF9nL?= =?utf-8?q?o6BnDvLFOSd27IhR1rB622JgDoeysTAQIVRyFF47GWS0Wfpr8NCKQN16iRCRItpT4?= =?utf-8?q?NTzRDe3Wecu4SE0D/EBdhoftqStJcmKlSq8vXJKGMfVA4n8DEU1VEWfRhLXD0n2ga?= =?utf-8?q?H73U9TuXfKdJgYdMdXsV+vPGXyKw/vy+RP5eorp6zMff4MEWFpxPQB7sZQfIGf1gV?= =?utf-8?q?KXARpq6a0um1wu8GmHvT125BL5+QYDz8gIf/vcRFEVwEsNnMOLkdRdqjAJhWYys7y?= =?utf-8?q?uxCaTx/lUA1T2jGUeCl66YdV/OLyn61qYyPX7hXlSCYw64M4/hW0CuaxDxLnDQmKy?= =?utf-8?q?B9zz9tKWAOyoVKn90iX5Jg+D2Fnppbff/YwYbIJLutlmC8q0rvUYlXr0elEVIw2s4?= =?utf-8?q?TFyzyYFf4Phv70YN7wl2pYDErwh/aYkzjfh7IQY6cQC4VYvsHr3597GaIISte33Sr?= =?utf-8?q?MZUBnTjRp9VVaiXPyXFxMtFEE/yyaM+zWqNMmIbnYe7S/PiQ81u/X7XH2JUBOiyzx?= =?utf-8?q?lyMzkyNqmUf/9W0Ez/CLCycRb0lo8INSoPt/slihmQbrbSj5n2XiksSR9YboO/K8u?= =?utf-8?q?WZ2OErvjcIFFLNPAbfnIwp71UUlOWWnY8Odrxhs2rCKJBvrnlrqlqke+bixDk/Q9d?= =?utf-8?q?5LcGPO1Yl1Ne?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 13a6fa75-b8ba-43bd-ac0a-08db31115fc7 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 11:24:49.5421 (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: jCWgJxjCr/LFGnU4CcNYxCLHeW+RYt1F9H4XWMRgxPmx05qdNdtDmrUdGt8J/rnAPnnhu9AtWAqwqQruwydI6g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8214 These being local macros, the SHADOW prefix doesn't gain us much. What is more important to be aware of at use sites is that the supplied code is invoked for present entries only. While making the adjustment also properly use NULL for the 3rd argument at respective invocation sites. Requested-by: Andrew Cooper Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper --- v2: New. --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -777,7 +777,7 @@ static inline void increment_ptr_to_gues } /* All kinds of l1: touch all entries */ -#define _SHADOW_FOREACH_L1E(_sl1mfn, _sl1e, _gl1p, _done, _code) \ +#define _FOREACH_PRESENT_L1E(_sl1mfn, _sl1e, _gl1p, _done, _code) \ do { \ int _i; \ shadow_l1e_t *_sp = map_domain_page((_sl1mfn)); \ @@ -796,25 +796,25 @@ do { /* 32-bit l1, on PAE or 64-bit shadows: need to walk both pages of shadow */ #if GUEST_PAGING_LEVELS == 2 && SHADOW_PAGING_LEVELS > 2 -#define SHADOW_FOREACH_L1E(_sl1mfn, _sl1e, _gl1p, _done, _code) \ +#define FOREACH_PRESENT_L1E(_sl1mfn, _sl1e, _gl1p, _done, _code) \ do { \ int __done = 0; \ - _SHADOW_FOREACH_L1E(_sl1mfn, _sl1e, _gl1p, \ + _FOREACH_PRESENT_L1E(_sl1mfn, _sl1e, _gl1p, \ ({ (__done = _done); }), _code); \ _sl1mfn = sh_next_page(_sl1mfn); \ if ( !__done ) \ - _SHADOW_FOREACH_L1E(_sl1mfn, _sl1e, _gl1p, _done, _code); \ + _FOREACH_PRESENT_L1E(_sl1mfn, _sl1e, _gl1p, _done, _code); \ } while (0) #else /* Everything else; l1 shadows are only one page */ -#define SHADOW_FOREACH_L1E(_sl1mfn, _sl1e, _gl1p, _done, _code) \ - _SHADOW_FOREACH_L1E(_sl1mfn, _sl1e, _gl1p, _done, _code) +#define FOREACH_PRESENT_L1E(_sl1mfn, _sl1e, _gl1p, _done, _code) \ + _FOREACH_PRESENT_L1E(_sl1mfn, _sl1e, _gl1p, _done, _code) #endif #if GUEST_PAGING_LEVELS == 2 /* 32-bit l2 on PAE/64: four pages, touch every second entry */ -#define SHADOW_FOREACH_L2E(_sl2mfn, _sl2e, _gl2p, _done, _dom, _code) \ +#define FOREACH_PRESENT_L2E(_sl2mfn, _sl2e, _gl2p, _done, _dom, _code) \ do { \ int _i, _j; \ ASSERT(shadow_mode_external(_dom)); \ @@ -839,7 +839,7 @@ do { #elif GUEST_PAGING_LEVELS == 3 /* PAE: touch all entries */ -#define SHADOW_FOREACH_L2E(_sl2mfn, _sl2e, _gl2p, _done, _dom, _code) \ +#define FOREACH_PRESENT_L2E(_sl2mfn, _sl2e, _gl2p, _done, _dom, _code) \ do { \ int _i; \ shadow_l2e_t *_sp = map_domain_page((_sl2mfn)); \ @@ -859,7 +859,7 @@ do { #else /* 64-bit l2: touch all entries except for PAE compat guests. */ -#define SHADOW_FOREACH_L2E(_sl2mfn, _sl2e, _gl2p, _done, _dom, _code) \ +#define FOREACH_PRESENT_L2E(_sl2mfn, _sl2e, _gl2p, _done, _dom, _code) \ do { \ unsigned int _i, _end = SHADOW_L2_PAGETABLE_ENTRIES; \ shadow_l2e_t *_sp = map_domain_page((_sl2mfn)); \ @@ -886,7 +886,7 @@ do { #if GUEST_PAGING_LEVELS == 4 /* 64-bit l3: touch all entries */ -#define SHADOW_FOREACH_L3E(_sl3mfn, _sl3e, _gl3p, _done, _code) \ +#define FOREACH_PRESENT_L3E(_sl3mfn, _sl3e, _gl3p, _done, _code) \ do { \ int _i; \ shadow_l3e_t *_sp = map_domain_page((_sl3mfn)); \ @@ -903,7 +903,7 @@ do { } while (0) /* 64-bit l4: avoid Xen mappings */ -#define SHADOW_FOREACH_L4E(_sl4mfn, _sl4e, _gl4p, _done, _dom, _code) \ +#define FOREACH_PRESENT_L4E(_sl4mfn, _sl4e, _gl4p, _done, _dom, _code) \ do { \ shadow_l4e_t *_sp = map_domain_page((_sl4mfn)); \ int _xen = !shadow_mode_external(_dom); \ @@ -1288,7 +1288,7 @@ void sh_destroy_l4_shadow(struct domain shadow_demote(d, gmfn, t); /* Decrement refcounts of all the old entries */ sl4mfn = smfn; - SHADOW_FOREACH_L4E(sl4mfn, sl4e, 0, 0, d, { + FOREACH_PRESENT_L4E(sl4mfn, sl4e, NULL, 0, d, { if ( shadow_l4e_get_flags(*sl4e) & _PAGE_PRESENT ) { sh_put_ref(d, shadow_l4e_get_mfn(*sl4e), @@ -1319,7 +1319,7 @@ void sh_destroy_l3_shadow(struct domain /* Decrement refcounts of all the old entries */ sl3mfn = smfn; - SHADOW_FOREACH_L3E(sl3mfn, sl3e, 0, 0, { + FOREACH_PRESENT_L3E(sl3mfn, sl3e, NULL, 0, { if ( shadow_l3e_get_flags(*sl3e) & _PAGE_PRESENT ) sh_put_ref(d, shadow_l3e_get_mfn(*sl3e), (((paddr_t)mfn_x(sl3mfn)) << PAGE_SHIFT) @@ -1351,7 +1351,7 @@ void sh_destroy_l2_shadow(struct domain /* Decrement refcounts of all the old entries */ sl2mfn = smfn; - SHADOW_FOREACH_L2E(sl2mfn, sl2e, 0, 0, d, { + FOREACH_PRESENT_L2E(sl2mfn, sl2e, NULL, 0, d, { if ( shadow_l2e_get_flags(*sl2e) & _PAGE_PRESENT ) sh_put_ref(d, shadow_l2e_get_mfn(*sl2e), (((paddr_t)mfn_x(sl2mfn)) << PAGE_SHIFT) @@ -1389,7 +1389,7 @@ void sh_destroy_l1_shadow(struct domain { /* Decrement refcounts of all the old entries */ mfn_t sl1mfn = smfn; - SHADOW_FOREACH_L1E(sl1mfn, sl1e, 0, 0, { + FOREACH_PRESENT_L1E(sl1mfn, sl1e, NULL, 0, { unsigned int sl1f = shadow_l1e_get_flags(*sl1e); if ( (sl1f & _PAGE_PRESENT) && !sh_l1e_is_magic(*sl1e) ) @@ -1421,7 +1421,7 @@ void sh_destroy_l1_shadow(struct domain void sh_unhook_l2_mappings(struct domain *d, mfn_t sl2mfn, bool user_only) { shadow_l2e_t *sl2e; - SHADOW_FOREACH_L2E(sl2mfn, sl2e, 0, 0, d, { + FOREACH_PRESENT_L2E(sl2mfn, sl2e, NULL, 0, d, { if ( !user_only || (sl2e->l2 & _PAGE_USER) ) shadow_set_l2e(d, sl2e, shadow_l2e_empty(), sl2mfn); }); @@ -1432,7 +1432,7 @@ void sh_unhook_l2_mappings(struct domain void sh_unhook_l4_mappings(struct domain *d, mfn_t sl4mfn, bool user_only) { shadow_l4e_t *sl4e; - SHADOW_FOREACH_L4E(sl4mfn, sl4e, 0, 0, d, { + FOREACH_PRESENT_L4E(sl4mfn, sl4e, NULL, 0, d, { if ( !user_only || (sl4e->l4 & _PAGE_USER) ) shadow_set_l4e(d, sl4e, shadow_l4e_empty(), sl4mfn); }); @@ -1666,7 +1666,7 @@ void sh_resync_l1(struct vcpu *v, mfn_t gp = map_domain_page(gl1mfn); gl1p = gp; - SHADOW_FOREACH_L1E(sl1mfn, sl1p, &gl1p, 0, { + FOREACH_PRESENT_L1E(sl1mfn, sl1p, &gl1p, 0, { guest_l1e_t gl1e = *gl1p; if ( snp[guest_index(gl1p)].l1 != gl1e.l1 ) @@ -3564,7 +3564,7 @@ int cf_check sh_rm_write_access_from_l1( mfn_t base_sl1mfn = sl1mfn; /* Because sl1mfn changes in the foreach */ #endif - SHADOW_FOREACH_L1E(sl1mfn, sl1e, 0, done, + FOREACH_PRESENT_L1E(sl1mfn, sl1e, NULL, done, { flags = shadow_l1e_get_flags(*sl1e); if ( (flags & _PAGE_PRESENT) @@ -3597,7 +3597,7 @@ int cf_check sh_rm_mappings_from_l1( int done = 0; int flags; - SHADOW_FOREACH_L1E(sl1mfn, sl1e, 0, done, + FOREACH_PRESENT_L1E(sl1mfn, sl1e, NULL, done, { flags = shadow_l1e_get_flags(*sl1e); if ( (flags & _PAGE_PRESENT) @@ -3648,7 +3648,7 @@ int cf_check sh_remove_l1_shadow(struct int done = 0; int flags; - SHADOW_FOREACH_L2E(sl2mfn, sl2e, 0, done, d, + FOREACH_PRESENT_L2E(sl2mfn, sl2e, NULL, done, d, { flags = shadow_l2e_get_flags(*sl2e); if ( (flags & _PAGE_PRESENT) @@ -3671,7 +3671,7 @@ int cf_check sh_remove_l2_shadow(struct int done = 0; int flags; - SHADOW_FOREACH_L3E(sl3mfn, sl3e, 0, done, + FOREACH_PRESENT_L3E(sl3mfn, sl3e, NULL, done, { flags = shadow_l3e_get_flags(*sl3e); if ( (flags & _PAGE_PRESENT) @@ -3693,7 +3693,7 @@ int cf_check sh_remove_l3_shadow(struct int done = 0; int flags; - SHADOW_FOREACH_L4E(sl4mfn, sl4e, 0, done, d, + FOREACH_PRESENT_L4E(sl4mfn, sl4e, NULL, done, d, { flags = shadow_l4e_get_flags(*sl4e); if ( (flags & _PAGE_PRESENT) @@ -3924,7 +3924,7 @@ int cf_check sh_audit_l1_table(struct do #endif gl1e = gp = map_domain_page(gl1mfn); - SHADOW_FOREACH_L1E(sl1mfn, sl1e, &gl1e, done, { + FOREACH_PRESENT_L1E(sl1mfn, sl1e, &gl1e, done, { if ( sh_l1e_is_magic(*sl1e) ) { @@ -3978,7 +3978,7 @@ int cf_check sh_audit_fl1_table(struct d /* fl1 has no useful backpointer: all we can check are flags */ e = guest_l1e_from_gfn(_gfn(0), 0); gl1e = &e; /* Needed for macro */ - SHADOW_FOREACH_L1E(sl1mfn, sl1e, 0, done, { + FOREACH_PRESENT_L1E(sl1mfn, sl1e, NULL, done, { f = shadow_l1e_get_flags(*sl1e); f &= ~(_PAGE_AVAIL0|_PAGE_AVAIL1|_PAGE_AVAIL2); if ( !(f == 0 @@ -4015,7 +4015,7 @@ int cf_check sh_audit_l2_table(struct do #endif gl2e = gp = map_domain_page(gl2mfn); - SHADOW_FOREACH_L2E(sl2mfn, sl2e, &gl2e, done, d, { + FOREACH_PRESENT_L2E(sl2mfn, sl2e, &gl2e, done, d, { s = sh_audit_flags(d, 2, guest_l2e_get_flags(*gl2e), shadow_l2e_get_flags(*sl2e)); @@ -4066,7 +4066,7 @@ int cf_check sh_audit_l3_table(struct do #endif gl3e = gp = map_domain_page(gl3mfn); - SHADOW_FOREACH_L3E(sl3mfn, sl3e, &gl3e, done, { + FOREACH_PRESENT_L3E(sl3mfn, sl3e, &gl3e, done, { s = sh_audit_flags(d, 3, guest_l3e_get_flags(*gl3e), shadow_l3e_get_flags(*sl3e)); @@ -4115,7 +4115,7 @@ int cf_check sh_audit_l4_table(struct do #endif gl4e = gp = map_domain_page(gl4mfn); - SHADOW_FOREACH_L4E(sl4mfn, sl4e, &gl4e, done, d, + FOREACH_PRESENT_L4E(sl4mfn, sl4e, &gl4e, done, d, { s = sh_audit_flags(d, 4, guest_l4e_get_flags(*gl4e), shadow_l4e_get_flags(*sl4e)); From patchwork Thu Mar 30 11:26:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13193979 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 40175C6FD1D for ; Thu, 30 Mar 2023 11:26:25 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.516625.801043 (Exim 4.92) (envelope-from ) id 1phqPw-0006gu-KE; Thu, 30 Mar 2023 11:26:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 516625.801043; Thu, 30 Mar 2023 11:26:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1phqPw-0006gn-HE; Thu, 30 Mar 2023 11:26:08 +0000 Received: by outflank-mailman (input) for mailman id 516625; Thu, 30 Mar 2023 11:26:07 +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 1phqPv-0006gd-8Q for xen-devel@lists.xenproject.org; Thu, 30 Mar 2023 11:26:07 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on20626.outbound.protection.outlook.com [2a01:111:f400:fe1a::626]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a8e2fd4a-ceed-11ed-85db-49a42c6b2330; Thu, 30 Mar 2023 13:26:05 +0200 (CEST) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AS8PR04MB8468.eurprd04.prod.outlook.com (2603:10a6:20b:34b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.21; Thu, 30 Mar 2023 11:26:03 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b%6]) with mapi id 15.20.6222.033; Thu, 30 Mar 2023 11:26:03 +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: a8e2fd4a-ceed-11ed-85db-49a42c6b2330 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DaJO9OHr6FA//Q9hwgzmYIpkbpmei5cDC09U3SFkty1bDplYEPFxI17Vu3XiRCejhmVnwPsPbwUjvTJ2XX1hNSlPI0o2PJUm6A6fuoGqbhtEStfEAGS/yDoKZ5+JY8r3NPVewjV/IgQW+Z8AfpZGvwNPsxMUUz0Ed3NGnyHVGIRGh1P2Oh4N36I5Py4pQBSVaDO5vvV21LgMxP6V13NiiOWIJ0jCAyKhtzLwbLjkcYG0CRd1y4XUPZ3lFYHBShnL4Nd05Y3axEdtQbfeoJIAeVQUt+V794EMLrayudthVG4LqXe811Ta1Wi4n3Yq5MaZ1R+KIk2DY5ZNPgQbZ3dXKw== 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=hACkpCooSftjlIisKDKVvGugJLC80byuS3ebKyYgdUY=; b=iI2cFAyrS6xSRYX+RoDIAOnvmxIAghIRkcKHdg1WxqaUYWVDFZTLY9TX4IxP9l6A81y+CZo4U3uK2zCREUcfsdFf9lDAH8u7IWVT5lvXOWtplF7RHEfTPo+HoMdfRVDsi0kdkX+pSIabipMsqry5KRkJu8zHJP6iJqk2rMH3z4OpThWQg8CcwNtjs0rAmdsLknDnFq0Rc2yHNYK6j+sAaw3Zmu5zWZrZn5DuxZ5Bre4Kq9VhTA++taJsWrHH+RBNHx9eYXxIJflY9JnUZj6sRanzS9G67ZLrIEPL+zJUS4Ux3vjOhOIqT38Uig5OqddZ4PZHGh4zS1DDwJoEymm04A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hACkpCooSftjlIisKDKVvGugJLC80byuS3ebKyYgdUY=; b=ffIssB7fastpYQGXzHQhQEaq0TEv03XSu/se4dTmKbVSiRfxnqVdcIxg82rXZBJGt5tgWWxDBuEA1C/RJSnLx98jdyHYgONZX2CmHXLgo0ozA8AWgYIesBOM/Db4LjvLRkwB2gi7pKXPcgst56mwCPNG92+/lKo1CGl7Uy7APlTgBk+6TB11T1OEqwTCUBIe4g8ijrq/kkvX1PUC8ne5HxrcxNPTG80C//A8xjFbEoztokFeLyJvOF05TELVqERDd0Xp3r1SXtw2Di2qCyelB7A6F2rZqZHyYQZqgVl2fWX3PrVQUgRTjyXLXYVtbnSGF1tpSKaJpkJA0GR0nnJayA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <44271af1-a6ef-325b-9e56-0c35b2716c58@suse.com> Date: Thu, 30 Mar 2023 13:26:02 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: [PATCH v2 02/13] x86/shadow: drop redundant present bit checks from FOREACH_PRESENT_LE() "bodies" Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Tim Deegan References: In-Reply-To: X-ClientProxiedBy: FR3P281CA0171.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a0::7) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AS8PR04MB8468:EE_ X-MS-Office365-Filtering-Correlation-Id: 8b85f931-04f1-41fd-6136-08db31118bee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MJ9VEG6HGPTLtZ69reXyMBGc4Bxbg90hPPUpVHRUEx1+ZN0q4e4ONy56dnGInFxFA7wEY7kuzs0q/GYUDNdurgLI4NNAZcHNv943SAa4qWl0POX+bzRqYefjVAj0HpQQBFd2HdyE59xOv0obM9/PPPlDqV9yGZhke8KjU4g/PJIVIxHQR8LRpXL+gK3842u3alMlQN1bRTe6SBi4MAbVDdnzhX0/pmMRefHDPppUEqtwc3jd/tcAd8TFB6Py8ZoYf/GCOwr2EORFjsHGg8QQ/gfzOK1VCDKWl0URsCNBO8NCAFhn2iQhHOUrWx69l5YmGLCxfFkMZIxucq+G61jUkp6ioWnBdiIFa4+vytbpwBwmFNFWM4C5eEE141KgSkQaj1PxvFtVpDXUswV04x+L8UUD7992dnOmc6wE6ybcrKHDgY0x2MTkvFd5kiBwUQzqOBUJm3ereXonRoxOZgGuEYNJ2kDX/mjIZV/GxOTVabOEQs1lK5yhEKqUvdYf235hUS7/RvrwZ6FKKAlRYOj0ESaLubkB5g8HFF1dXrWV/MIlsBJ39NyIbxLuZjXbobPss5nsToUtP9MAPLy4zMkm/O+1ClUHks2cbZv+btdmMLsvY2lTzFa2MmVqngfltscAHy18qQ7bbSjYBRYPQIEiULfYj2pz8H6iXb5JtwzuVvhl+pg6T7pjCSZQltDuF+c5Z9cWWnx5WJwl2nlLRTTcEj/JU3FDY0jGbY8RGWXoQwg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(136003)(376002)(39860400002)(366004)(396003)(451199021)(2616005)(83380400001)(6486002)(478600001)(316002)(186003)(26005)(6506007)(6512007)(54906003)(2906002)(36756003)(5660300002)(86362001)(4326008)(6916009)(8936002)(38100700002)(41300700001)(31696002)(8676002)(66556008)(66476007)(66946007)(31686004)(45980500001)(43740500002)(414714003)(473944003)(357404004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?GzvMck1pwjxWKiNcOgpwWn5tNJTD?= =?utf-8?q?Ib0ZSstDYxqpNnJ4tqElciSx+meTo6Z6o6rdJut3eBY62sr43hKGQACmApc+WL3Dg?= =?utf-8?q?hVCu8L+n0s5K8UlPX73GH/muJmujYSFZrhTSHnRwR7qPg1oqTYMyiBefIHB5NH7Tl?= =?utf-8?q?1Ha6S1FfWVHxURrREWfvQ2n+vIwhErp9F5tmvOjijT7T3+VDeUh0Ird8Ud2jSmYaw?= =?utf-8?q?4D8NyzUwAypFHGL9x95lmP0ANBbyf1+20020EsfswnTVgzhhuxJVbBH66Yyv09Sfq?= =?utf-8?q?ZHcBtelZLz83tl27hOt3P2RmXu0NwXwzhposFfR1MFhSgkt/a2aIo1010/mggV9gc?= =?utf-8?q?MWJ1IVgbSGQcXCaKLkni+gL8F0M73LL+XbOkhU7B7jyt8gWJ9gTvZlDg1/LjroIfK?= =?utf-8?q?PCU1iW6pmjD311KnR+N+TMt4573N1xTAMmH8z4ChN/RcngfbzrkHKKZbjp/Xha9h7?= =?utf-8?q?kztWo6HH3xB9fRFmYd1MMwIpJIH34RbzXNL1TDpMc8xPlMxXJkGnDwC+vtOV2yK6+?= =?utf-8?q?42aDptgVvHEMYvz/Nvj30q6OC1XwZs1dWTN1O09KRFFC4SoSCB8RP0j6cN9n3ssuT?= =?utf-8?q?0iShULZW85LaSrH9OYkrCZXnk2nhGtrED9OstBm6Hz4N7ueiEk/NV6jIBWdX5HGvO?= =?utf-8?q?deSR4h3zIqOeotsWgxkHd4lkv1aprBy3eZLRy2+iYfjULpL0z0vUM8/TQVmh87CJe?= =?utf-8?q?aLIlkQGVKdSJASd2wgZpfHFZvTBFmD1iwsEHL4+yAu7+J+vwBEjToXyKezon/KQbF?= =?utf-8?q?XxA2iRbM0tDTyLqGAHxkWpsGIFGdMMnNY9nDA3VRiBA3d49dUgXQZ5fFh+icmhSlK?= =?utf-8?q?o+b+YZWLhtmX3VkloM3jUlvjcDYIzeinEWDC0pQHKTL3qpSy1F9CzMcMlw512vFOt?= =?utf-8?q?yQo3olP5BPA4E6uJwhJ8W+CO6kQKTSKT5rESQEovMSlLDVBB9MQ5/UTrq0LBxZm/v?= =?utf-8?q?F6mRkY3dLyR6+M4wNmHOgq+2E/JNYDggKMqgXr8/9wP778lhBOvPZgOfViF5jvoAv?= =?utf-8?q?pgpiFo0g9ENCfjgH5hM0e7coGyXE5BiPiwP+bbR4ICH3KkdA48QnB/IIz6/UY8img?= =?utf-8?q?T6EBHj42kl94R8mjS8WE0jgSre+IsautCxz/yc+3S1Q8idnmegB37q597oF11MVpB?= =?utf-8?q?AFPnEHoGI1PJgA0fMo7Bq7u30hSUyCMHAFpRd6/d25wAB4rZHgUmRaHhzE45BeNtH?= =?utf-8?q?deqgcW69gZie59Rj9OON9fXvl0Q7gYtnikrLS38E3Z7dv/zu9XW4dvHttn8EXxsDF?= =?utf-8?q?yacd1135Wifu9+bPPBkrqz3uEvlusmsWmpxlVrrTDd9DGK4TZDpke0Evu3NAObnMb?= =?utf-8?q?EFaAwh6/QK+xNWla1dgtcn4nMZcMrOu9XdkZd89w4zGLSjqAYdPwyY841ZUGvXV6r?= =?utf-8?q?nKrQHZyyf47TW+sJRDoTT/tLNxIrCiw9mJdvjwgmFrha1BomTpUufbe9F7VrPP6YS?= =?utf-8?q?pUt0UgdORZTkJFhqVD0up0nSpNSV5dX/Dp+ZKitBzoEVOc1eADgT0Yc/DVi03kGny?= =?utf-8?q?P+ONbjygOjYG?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b85f931-04f1-41fd-6136-08db31118bee X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 11:26:03.6108 (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: csN4KbAjQJRFIa6oF57piRbfjOQdCUbvH02Pmp+AeztFyLdfVkFa1/m37nlR1YvG17Z39nXGdpeF1l2tQbHOqg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8468 FOREACH_PRESENT_LE(), as their names (now) say, already invoke the "body" only when the present bit is set; no need to re-do the check. While there also - stop open-coding mfn_to_maddr() in code being touched (re-indented) anyway, - stop open-coding mfn_eq() in code being touched or in adjacent code, - drop local variables when they're no longer used at least twice. Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper --- v2: Re-base over new earlier patch. More mfn_eq(). --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -1289,12 +1289,8 @@ void sh_destroy_l4_shadow(struct domain /* Decrement refcounts of all the old entries */ sl4mfn = smfn; FOREACH_PRESENT_L4E(sl4mfn, sl4e, NULL, 0, d, { - if ( shadow_l4e_get_flags(*sl4e) & _PAGE_PRESENT ) - { - sh_put_ref(d, shadow_l4e_get_mfn(*sl4e), - (((paddr_t)mfn_x(sl4mfn)) << PAGE_SHIFT) - | ((unsigned long)sl4e & ~PAGE_MASK)); - } + sh_put_ref(d, shadow_l4e_get_mfn(*sl4e), + mfn_to_maddr(sl4mfn) | ((unsigned long)sl4e & ~PAGE_MASK)); }); /* Put the memory back in the pool */ @@ -1320,10 +1316,8 @@ void sh_destroy_l3_shadow(struct domain /* Decrement refcounts of all the old entries */ sl3mfn = smfn; FOREACH_PRESENT_L3E(sl3mfn, sl3e, NULL, 0, { - if ( shadow_l3e_get_flags(*sl3e) & _PAGE_PRESENT ) - sh_put_ref(d, shadow_l3e_get_mfn(*sl3e), - (((paddr_t)mfn_x(sl3mfn)) << PAGE_SHIFT) - | ((unsigned long)sl3e & ~PAGE_MASK)); + sh_put_ref(d, shadow_l3e_get_mfn(*sl3e), + mfn_to_maddr(sl3mfn) | ((unsigned long)sl3e & ~PAGE_MASK)); }); /* Put the memory back in the pool */ @@ -1352,10 +1346,8 @@ void sh_destroy_l2_shadow(struct domain /* Decrement refcounts of all the old entries */ sl2mfn = smfn; FOREACH_PRESENT_L2E(sl2mfn, sl2e, NULL, 0, d, { - if ( shadow_l2e_get_flags(*sl2e) & _PAGE_PRESENT ) - sh_put_ref(d, shadow_l2e_get_mfn(*sl2e), - (((paddr_t)mfn_x(sl2mfn)) << PAGE_SHIFT) - | ((unsigned long)sl2e & ~PAGE_MASK)); + sh_put_ref(d, shadow_l2e_get_mfn(*sl2e), + mfn_to_maddr(sl2mfn) | ((unsigned long)sl2e & ~PAGE_MASK)); }); /* Put the memory back in the pool */ @@ -1390,11 +1382,10 @@ void sh_destroy_l1_shadow(struct domain /* Decrement refcounts of all the old entries */ mfn_t sl1mfn = smfn; FOREACH_PRESENT_L1E(sl1mfn, sl1e, NULL, 0, { - unsigned int sl1f = shadow_l1e_get_flags(*sl1e); - - if ( (sl1f & _PAGE_PRESENT) && !sh_l1e_is_magic(*sl1e) ) + if ( !sh_l1e_is_magic(*sl1e) ) { - shadow_vram_put_mfn(shadow_l1e_get_mfn(*sl1e), sl1f, + shadow_vram_put_mfn(shadow_l1e_get_mfn(*sl1e), + shadow_l1e_get_flags(*sl1e), sl1mfn, sl1e, d); shadow_put_page_from_l1e(*sl1e, d); } @@ -3558,7 +3549,6 @@ int cf_check sh_rm_write_access_from_l1( { shadow_l1e_t *sl1e; int done = 0; - int flags; #if SHADOW_OPTIMIZATIONS & SHOPT_WRITABLE_HEURISTIC struct vcpu *curr = current; mfn_t base_sl1mfn = sl1mfn; /* Because sl1mfn changes in the foreach */ @@ -3566,10 +3556,8 @@ int cf_check sh_rm_write_access_from_l1( FOREACH_PRESENT_L1E(sl1mfn, sl1e, NULL, done, { - flags = shadow_l1e_get_flags(*sl1e); - if ( (flags & _PAGE_PRESENT) - && (flags & _PAGE_RW) - && (mfn_x(shadow_l1e_get_mfn(*sl1e)) == mfn_x(readonly_mfn)) ) + if ( (shadow_l1e_get_flags(*sl1e) & _PAGE_RW) && + mfn_eq(shadow_l1e_get_mfn(*sl1e), readonly_mfn) ) { shadow_l1e_t ro_sl1e = shadow_l1e_remove_flags(*sl1e, _PAGE_RW); @@ -3595,13 +3583,10 @@ int cf_check sh_rm_mappings_from_l1( { shadow_l1e_t *sl1e; int done = 0; - int flags; FOREACH_PRESENT_L1E(sl1mfn, sl1e, NULL, done, { - flags = shadow_l1e_get_flags(*sl1e); - if ( (flags & _PAGE_PRESENT) - && (mfn_x(shadow_l1e_get_mfn(*sl1e)) == mfn_x(target_mfn)) ) + if ( mfn_eq(shadow_l1e_get_mfn(*sl1e), target_mfn) ) { shadow_set_l1e(d, sl1e, shadow_l1e_empty(), p2m_invalid, sl1mfn); if ( sh_check_page_has_no_refs(mfn_to_page(target_mfn)) ) @@ -3646,13 +3631,10 @@ int cf_check sh_remove_l1_shadow(struct { shadow_l2e_t *sl2e; int done = 0; - int flags; FOREACH_PRESENT_L2E(sl2mfn, sl2e, NULL, done, d, { - flags = shadow_l2e_get_flags(*sl2e); - if ( (flags & _PAGE_PRESENT) - && (mfn_x(shadow_l2e_get_mfn(*sl2e)) == mfn_x(sl1mfn)) ) + if ( mfn_eq(shadow_l2e_get_mfn(*sl2e), sl1mfn) ) { shadow_set_l2e(d, sl2e, shadow_l2e_empty(), sl2mfn); if ( mfn_to_page(sl1mfn)->u.sh.type == 0 ) @@ -3669,13 +3651,10 @@ int cf_check sh_remove_l2_shadow(struct { shadow_l3e_t *sl3e; int done = 0; - int flags; FOREACH_PRESENT_L3E(sl3mfn, sl3e, NULL, done, { - flags = shadow_l3e_get_flags(*sl3e); - if ( (flags & _PAGE_PRESENT) - && (mfn_x(shadow_l3e_get_mfn(*sl3e)) == mfn_x(sl2mfn)) ) + if ( mfn_eq(shadow_l3e_get_mfn(*sl3e), sl2mfn) ) { shadow_set_l3e(d, sl3e, shadow_l3e_empty(), sl3mfn); if ( mfn_to_page(sl2mfn)->u.sh.type == 0 ) @@ -3691,13 +3670,10 @@ int cf_check sh_remove_l3_shadow(struct { shadow_l4e_t *sl4e; int done = 0; - int flags; FOREACH_PRESENT_L4E(sl4mfn, sl4e, NULL, done, d, { - flags = shadow_l4e_get_flags(*sl4e); - if ( (flags & _PAGE_PRESENT) - && (mfn_x(shadow_l4e_get_mfn(*sl4e)) == mfn_x(sl3mfn)) ) + if ( mfn_eq(shadow_l4e_get_mfn(*sl4e), sl3mfn) ) { shadow_set_l4e(d, sl4e, shadow_l4e_empty(), sl4mfn); if ( mfn_to_page(sl3mfn)->u.sh.type == 0 ) From patchwork Thu Mar 30 11:26:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13193980 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 70D96C6FD1D for ; Thu, 30 Mar 2023 11:26:48 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.516629.801053 (Exim 4.92) (envelope-from ) id 1phqQS-0007AF-0F; Thu, 30 Mar 2023 11:26:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 516629.801053; Thu, 30 Mar 2023 11:26: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 1phqQR-0007A8-Tk; Thu, 30 Mar 2023 11:26:39 +0000 Received: by outflank-mailman (input) for mailman id 516629; Thu, 30 Mar 2023 11:26:39 +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 1phqQR-0006gd-1j for xen-devel@lists.xenproject.org; Thu, 30 Mar 2023 11:26:39 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on20615.outbound.protection.outlook.com [2a01:111:f400:fe1a::615]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id bc64e8e2-ceed-11ed-85db-49a42c6b2330; Thu, 30 Mar 2023 13:26:38 +0200 (CEST) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AS8PR04MB8468.eurprd04.prod.outlook.com (2603:10a6:20b:34b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.21; Thu, 30 Mar 2023 11:26:37 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b%6]) with mapi id 15.20.6222.033; Thu, 30 Mar 2023 11:26: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: bc64e8e2-ceed-11ed-85db-49a42c6b2330 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kawQ88ejvpYSr+SK5zXClVyuo1dvd+jkmp5bnmO2qncx0zmsqa20lcDsPg0BKQQvLdcoyRpEsDdjZBoX9LYqWIMTrykiN0CHgegnba4Z95YMkDsjB9sV4WFOEryekhZ7mKMnPYiD+2iLOpIjtr7M9EWHnO673rvjvmqLnmcKYyR3Nb4DxjzIMm6Z+tvw+byyT9JD6vNafnE1qXunr9Pss64ETSEEF2tzGfgtpJYFeyDDcCksNpfPczjBpjY87YijHBaQ5zAQJgCjVmaoACS9AdD9v3s9MTdlINu2vBPpDm78yrh/UTFU/xZAxOlbi5pi+fNZm5QuTYUzchiDgAn0fA== 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=o37qmZQGz0dUPVarEE5M4F8gAAfRaPl7Obs64dcS6gQ=; b=Dlqt8EZ92XFYkUkX6dsOgfeIPc0lRWiBpHdysauln6eQoLm+6lLMrVxjL6eiC1YyW68PtYB2wrEnA6l9GxxT5JJMDQOhrkXTOXN/lYXQq2NiRMPXS5yQ7yzKA3OrgDQWbgmnDYANSJ6D5YnE9QmCRZ3lUfve7BXM4F8lGxH1vfT6K3S8j4ignFth842VT5mkPjWcYp5EoBMMF9rSNAP8l3I6j18Q/W0pSOcgTM5V9vsmYaN79KwmrIHn4ynM5GcnvgARzXSADk764pziCbNB2jxCNzgqB2YDVlDCxQuba7Q4iOrRlmIBsPuDc9ZQOH8DMb9kZmb8ftRx2kaT70TukQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=o37qmZQGz0dUPVarEE5M4F8gAAfRaPl7Obs64dcS6gQ=; b=jqgZCThEfB4GsA6wvAxQFST6HoPuurWldv1Uuszho1cmWP7KBHvJ2csVBIbqo4HEmz0yO9Sab14BYCUB4tk8IvBhv214+umdEyBiLtAl2vKLuBUs2B2dfqzRTdgE37pNtCyXlfkqF8dq0/CHRnhL8nSt+33YEIaViw6t7UNOQrGFKEVFnJJSuj7OGwwtKgCy0vTap7/oEdlkMPy2VG+OMJ3/hpWny8R/gD2G+e6Z44ktbG1fb5l8RtH8WbI4wxLt3VPjhsD9KxYW8H6YZE8EIHTpejopAmmmJXEhIiH1V6VhVWiPDI6cy5rsNMYsWPzChjhpQc33S4D2/GAz1Xx15g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Thu, 30 Mar 2023 13:26:35 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: [PATCH v2 03/13] x86/shadow: reduce explicit log-dirty recording for HVM Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Tim Deegan References: In-Reply-To: X-ClientProxiedBy: FR3P281CA0175.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a0::12) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AS8PR04MB8468:EE_ X-MS-Office365-Filtering-Correlation-Id: 248b542d-67f2-422e-c1d6-08db31119fc6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: is+k0jfzLnA1SefsrgzOh8bkUUhqQFeYigt5qJ7tXEg7F6uSeHvXonN46vPqIsp4ZHdnScYJtCe1xOimsBQm4TnTDKfRyLljsnaOcNHm8aPe2RxEtrJxD4qjyji4M06D91SIdA/mRiqiyTTacpqoACYgs256He2Fr51nGupcFyVEeCCGWt8jWldC30QkhkmIz+qRnoFszYIrQRUwvrGJq7QZw7AQziTGgYrFsT7KEXsSrk/b8R6zyP9lJ7hBj7guTqTnXNPecICAKR+Vt3jyqeIOUdEvzcnTr3AiWDC+co/KarldMlUBoAG427vgRRfHBZofeNd/cOiu5g6cABpuDl6KVN6I3AHUw+T3r6RJf8bVnuuiW1mHrKZTqJDcocp7CRelPwlz3cG3lKWWZJug4yZCFQZeZs8bkepHhKKrJlp1/yPmjUoI6mEXsJs/5HAVxxMbw9y3jf4Op7M5gTwLhATDv1hf7ok3dNdNgvyF5Xj8to36rk5fFwh5w+9qaSOtcyGmJdpjJTBV5jvTMNMJZZb1I/WG6OGRcEop50E9kh12J2F72wZdlq5VOEwgeAG/1nWiVZYnTpxESy/SU3pM7Ik/+iNvXGHcd7dVsCZvunByD+yaXmcCcgwrC2yhO+wn5VgzAgSwnJeIx06vtLhuBVZ2VrpjEg3zCHMf/XkDMfk= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(136003)(376002)(39860400002)(366004)(396003)(451199021)(2616005)(83380400001)(6486002)(478600001)(316002)(186003)(26005)(6506007)(6512007)(54906003)(2906002)(36756003)(5660300002)(86362001)(4326008)(6916009)(8936002)(38100700002)(41300700001)(31696002)(8676002)(66556008)(66476007)(66946007)(31686004)(14143004)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?lMeWfFmXVxviBCiu7n4Ogyv/sXst?= =?utf-8?q?oU61Cq4Qh/cgWMkZfY9JrXcBLQu1EWoedcbuZt2ep2vcN1jz2O6StyzPr+sAsZk2i?= =?utf-8?q?Yg8umtSnLOL++3AZhtxZjCMQEdQa9myIA8J4xV/HvbE2fZsx6ugTIDn0CR8tJyjpW?= =?utf-8?q?PGNc/lKm+Oy5/EnptdfR6+IiCIEmYc55Nax6ra9ALoi7PHgH3YW5VhUqvdDj7G9fh?= =?utf-8?q?WkXB5oY8QLb4OZIKGLcz12apQeDGF2Qeilzgl0nXs0XhPMS32o1cHFKimtX8iNt+K?= =?utf-8?q?2NU6NB/qfj+mW52+eIcHusChWRPSpVAxr4NXBCF76X/EOpSDJYaijDD73kb4Pu23o?= =?utf-8?q?oqJyydX6GOL6XqGCVcMr43blg/vlPX9JhO47FLyq6C5Axj6xGky1uH6TlwfQkqBDI?= =?utf-8?q?CR4oA+Nap0v3IiGfqeFcgDbhDX6rvwzkbqUjBTTPYdZXzcUhcIhe3cWckQwt9sF7v?= =?utf-8?q?UucA06tvSQmI54zfLWtSQTkUlL8l2CTfTlalIFqR7qOKbQokPho+3w7YzgqGDy6VR?= =?utf-8?q?OCt8LwE41kFVZD49vjGi+hq51Am/anU5MqhhmhBaFckCRXpzbTMWRnmLhdu2Sfwth?= =?utf-8?q?CPojSxNeFjpx/4T/VldSpiJETHpIM43tKrgP8YJ99endSveeRmBUDuK+ffvFZsDXE?= =?utf-8?q?IjMw3/Q2GcCmuyTGv3iSvSAE3AJDu1u6oT/r7Lon59EZZqSgtcDX37ItA9BpfVy+f?= =?utf-8?q?6GPgPVyTZky2GvryuOURBIYeybgOCfSgRFOQQO1GLQxCurYItK9vi40ibSVdGn3Fx?= =?utf-8?q?y0s/p1JWH+mkBwe2m9hCdw6pMSVCMV+EQvXIJ1fu1eDVurHTDU2CvPJ0YIzN05wtO?= =?utf-8?q?lGpiVBgKCSnsqS5Aj4m3QM1ou4kw7PL9d2qmX3IIXViIzPuTsZETcRhPHp/QBuK39?= =?utf-8?q?EISGEchREJ3lUcNi9IXfjhJE9j4QKYRjlvy7WXHMYeWxgZzyMCuSH1w2HQrbv4hOP?= =?utf-8?q?ycDuT/kgYSgkuJG8QGPQ3TUxA7D//ES29qq6EKi5nihre9lGb+RAS8rlwF9uaJH+V?= =?utf-8?q?PoZODNRu6Ca6t44KML/5PbbemJZxdS8JS+HLUy5fXSEP7LODvhW7UQK/AfDdboerD?= =?utf-8?q?5KHIclDwm9SpzllAuCsSqnFiNmKvUoBe5ihI2iQxCcd9AF11C59IKgJQtaXA7Q0dF?= =?utf-8?q?Vqfx40NL3snG1YrbcwZUvN30zvXkj2lGU2d5p77v6GLE4+FgyWS8XCexz3Q4n8pLo?= =?utf-8?q?EeeqgXkNEoFslnH5f1AVoewVlOS74eYCbPe6xPUSnZEoeeHYlkV7lvEOIC2mFEa9E?= =?utf-8?q?j6aVwRInyKhAjxO+FNMN8Ap82P/RlKBj7YwrT63CWDhr96okCAvybo43Bk17s3C3/?= =?utf-8?q?ocqEvo8H6iizFMmnXiieS6psSbvKyTGiq/3ovkYfXNQy2apWP3+/6kI1IzcuC+dtP?= =?utf-8?q?4yJcFpb95X9B1ok8rMsIU0HQzrpoc45YHpb0CEMt6HOOk2+AyfbI/9k6lTDoRIrd3?= =?utf-8?q?GWFB5C8zTYEjx4cVX0TqmvEAo0w03LIspjwIjcz5vXJg9BIV/S2sUu6SA68VK5YjF?= =?utf-8?q?szww/ZqlVswd?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 248b542d-67f2-422e-c1d6-08db31119fc6 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 11:26:36.9286 (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: EEcg+3fq/oYA1PnQCOjBiEXykK6PXKWbSSI/XQ1Igkl7n28ctN3CPhzdNBIIraaDE9+nR5aKjpKIrorKgIE+fQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8468 validate_guest_pt_write(), by calling sh_validate_guest_entry(), already guarantees the needed update of log-dirty information. Move the operation into the sole code path needing it (when SHOPT_SKIP_VERIFY is enabled), making clear that only one such call is needed. Signed-off-by: Jan Beulich --- a/xen/arch/x86/mm/shadow/hvm.c +++ b/xen/arch/x86/mm/shadow/hvm.c @@ -656,6 +656,7 @@ static void sh_emulate_unmap_dest(struct { /* Writes with this alignment constraint can't possibly cross pages. */ ASSERT(!mfn_valid(sh_ctxt->mfn[1])); + paging_mark_dirty(v->domain, sh_ctxt->mfn[0]); } else #endif /* SHADOW_OPTIMIZATIONS & SHOPT_SKIP_VERIFY */ @@ -673,12 +674,10 @@ static void sh_emulate_unmap_dest(struct validate_guest_pt_write(v, sh_ctxt->mfn[1], addr + b1, b2); } - paging_mark_dirty(v->domain, sh_ctxt->mfn[0]); put_page(mfn_to_page(sh_ctxt->mfn[0])); if ( unlikely(mfn_valid(sh_ctxt->mfn[1])) ) { - paging_mark_dirty(v->domain, sh_ctxt->mfn[1]); put_page(mfn_to_page(sh_ctxt->mfn[1])); vunmap((void *)((unsigned long)addr & PAGE_MASK)); } From patchwork Thu Mar 30 11:27:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13193981 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 AE568C761A6 for ; Thu, 30 Mar 2023 11:27:33 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.516632.801062 (Exim 4.92) (envelope-from ) id 1phqR7-0007nW-98; Thu, 30 Mar 2023 11:27:21 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 516632.801062; Thu, 30 Mar 2023 11:27:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1phqR7-0007nP-6S; Thu, 30 Mar 2023 11:27:21 +0000 Received: by outflank-mailman (input) for mailman id 516632; Thu, 30 Mar 2023 11:27:20 +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 1phqR6-0007nJ-94 for xen-devel@lists.xenproject.org; Thu, 30 Mar 2023 11:27:20 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2061b.outbound.protection.outlook.com [2a01:111:f400:7e1b::61b]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d4e95526-ceed-11ed-85db-49a42c6b2330; Thu, 30 Mar 2023 13:27:19 +0200 (CEST) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AS8PR04MB8468.eurprd04.prod.outlook.com (2603:10a6:20b:34b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.21; Thu, 30 Mar 2023 11:27:18 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b%6]) with mapi id 15.20.6222.033; Thu, 30 Mar 2023 11:27:18 +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: d4e95526-ceed-11ed-85db-49a42c6b2330 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dC8UDeNwCb1fDsND3XweZkNMR2xrS+GeOZ2+bng0t6GCuHSv02U4YqmSQJzE+I0V7XlK+lyJ10cE05tEUr2Q35yqLlAKpHbKkvLDWxmVVQsusq+pOKL4GeIiEMnDgOjUqJzBODfaA9lDwN4GwDouf6Y/kQ64snED12TORLVmuvO7i9vc4oJQNj1SjyT1Q2ADytN51qtbBLTRVqYttcHpbyjDcLBxHNQA1Az0DFH7VZgtEtLzVVVnpgDNuNn3PacB9EPF1LSz+IKV3apciaVjH5lzurI6vQanqD5jUEtFeJ5KSOEPhWvLvyz+Yqosz3j2nl+unJ1L2FKmg01nFFUSiA== 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=ue41tyDmmg6PevYB5Qc1ThieQRcpS48A5cxO6+NoPwo=; b=WLSm8A9L1tdmWGODm6ZDoIfx+IpwmJn2iz2DcQhkGpE6IKHgKegb0cIuiGnG5FE2FRjnyQYFV/lqKawWzGqEkVltiPdd86pGaBxsegWf5O4L+AbsJ3i9Qpwd12Ho1i+S2orY9W7T2KtP6UHi1iyK/w5j82Nv7q2+j+kQrwIhNG2kbkOtiATj/PZlkgaWwth6Doq8/1fKfS5kSkoOd4BrkX1GJYTAjPATeOsy+mDzvX1H1FhVi0/0LzFyiLxoDRGkpP2XNr5kV2jPL8OTxoQJ1gRx4uZXwMey2O/MCOKaV2uuw7NNPYh8DA1Z29pmXw60xIDWfewyNXhx/M1lL1FmQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ue41tyDmmg6PevYB5Qc1ThieQRcpS48A5cxO6+NoPwo=; b=iAOOAGY1E4Gdlrr7FHuxXKKj5a2/un/Eq/RLSi7Pql5/FIgRH3dtqtf4+t/wcYAX1owY0UiAKyJVNU0oBaaFxJwhoqIrdLP20qWnnW8wQckorHFg87ynfCSK42Y/Da/DB7EHUch0OcO16UWLrGvv3ntDYljvhhVlifxAxYRRJhyDl1vJd72zj3BD4/+3X8QYZ8l96COD32+UWyIEG/gerBHrKvcn3AGmdCDjTann6K5I6L90gDZ3pkMg0Cf96v02Vaee+RiivIso+xz5POCG5WPiGCIOuHzlt+A2VWpIEI+wmjP3APQAm/svcDb/XX8/1XDQnz43jYlC6I4lF+khUA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <8ab32f85-d0d5-956d-9375-829e578c65d5@suse.com> Date: Thu, 30 Mar 2023 13:27:17 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: [PATCH v2 04/13] x86/shadow: call sh_update_cr3() directly from sh_page_fault() Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Tim Deegan References: In-Reply-To: X-ClientProxiedBy: FR3P281CA0151.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::12) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AS8PR04MB8468:EE_ X-MS-Office365-Filtering-Correlation-Id: bce404f4-7a21-4de6-99c6-08db3111b87b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 544vpSndasg0eolfvRm13QOmNe2vn5/NjCm+eq/NKmkhtpG7N2pXm0PnJNgJ1+UCrdUT8JeyQclreuQ9uy0mvZpVzsda0QairrXrCBUoAHTqd8qdjRuo8OvhZb+oFucuZeulMpAbhTMALDTZyQPUOLd59w9fgFyxjcbI7QxLBkzLcmzZRN6wnbXN91V/84/+I2LfYXy9f2rW9Byca/1FbNU8m9zvMRGGEFvqeJOBNpT4/jb6HDL+FJS3bVHejw2ZBpExC/dZXSZ5q+KbPpU3+CCxCG3K3AqpiVXwa8Mx9qGWDh94Cz8twjyp7Cyb/lo7X/uujBDAlwfJBAzqZ8J1vv7dT61IE7UTmhbHzj6pYfOXLJZ7i/kYjSt/XB9h7n6xDj+oe5JkQiJOa2dg36kUnL5zzBRpkyIyxy5IHHwPgxbkhEeoEH/xE5Ef2nZtySo4bIY842FQKHTP9aBAoKQdp8tHCmMXfoTldJfo76+M2adDvrLkBxtG78BbBHt7hbwiI8KKAgk3BSyFmY25StMj4dvSvtAF46/3p2kO0w2dOGQDdgDVrKQpf2P3ackw4ixMtgI5sFHrQgAX6L6F1lO6Fn+jDACVVuC+a5PsEp1v0JX3mMc8BJpEPXCrtO2DrPdwxgXTzImnjq11Hrg7+bKKog== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(136003)(376002)(39860400002)(366004)(396003)(451199021)(2616005)(83380400001)(6486002)(478600001)(316002)(186003)(26005)(6506007)(6512007)(54906003)(2906002)(36756003)(5660300002)(86362001)(4326008)(6916009)(8936002)(38100700002)(41300700001)(31696002)(8676002)(66556008)(66476007)(66946007)(31686004)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?qmf/hWiJ+XuxwlmI+jGNoqrWxxpr?= =?utf-8?q?lGJfvLThDwZ2QtL0qBFT1HrVCeY2/QGKGGXhKH5VqauwB29uSDf8gqFzq8lk7fpbw?= =?utf-8?q?3bRP8cJwEYY7gxW6uV7sWint7dBCwKAjeb2VFgMT0pJhUnjnndyaYe9kpK5xDGVM4?= =?utf-8?q?N2b1myz0HS0d2xlB/ZIXj7DL9RybYcUqW6jxvFAvF76TP1isakwS0UIDDniSN5Uze?= =?utf-8?q?DPd98ozcFWe6qHuG6kUX8npjuT8T0FJqgxr0c/2md5Bj5zqc/ZyDDIpOnFiSvrdHu?= =?utf-8?q?7uUQ9TxxrDmEN8jeMjjba24+jWEEDg9mSWr9gTk8lDn6rjPpgEXy4D6NTjcPihrT7?= =?utf-8?q?ZqaG6sUIOpfutV4h10brGGiA3B2orMBmY6TRoBSle0aJ6bq1jmYm2F0CeXrHM0GIR?= =?utf-8?q?kpTbAGp/Rd4ff7C0EaOgjTPe0I+24sOB19sa97NOT9+nWG7/qDvViBEKIzOya53Ez?= =?utf-8?q?0nbYk1q/RuRMl/tD1jsf0gu8ZT1vHE2CJNLE/z97HNK74L0gK8XHejWNu2IcnEFLm?= =?utf-8?q?Q9uUCBL7oDsHR/4fkhcW8Hrra74b92tRG25+vJJgQV9PdUZ497EDqJt06yZy95am+?= =?utf-8?q?/UJOYKMSZmcL1BrrwX5YJ/9atIGn8gb1oJzkLc81cRaEqA5zhWM85kegZRua3om7x?= =?utf-8?q?HJTSQT4vj8HOoXOA+W8a9pALTeA1JBeYNfx58LcLkTSZnw71Qm6jklYx5fDtLYZvh?= =?utf-8?q?5ecTSYYOpge7s7wnNnG+w7hOBv1/IpPF5tocMT9LB3danIJSDKYnWBBsnmbaR0oJj?= =?utf-8?q?bnDhidVkQDF6Lzz4gpH3wE6Y+XnCy+X6YTTO78gFsipGAttntsGSOMaUkxHMRKlGh?= =?utf-8?q?gQqnKsp4BxLezpGSaacNRgD8G2q0aTTZ4cikrf0BFLmplLVqEOMTFzDGq6kZDrExz?= =?utf-8?q?GAaRsw3ytEe1RZ/dyhgZt52vacSJCMQ1e2TJlI4ALlKI9UoKmKdY19wHbPZdJGmIn?= =?utf-8?q?J8Zr9MrNECGSxSYrh8LsAVoeUxz+XX87bENOVlbgq23aBnrhQDQjlVSyysklUO9Tf?= =?utf-8?q?pKxQ4Bou2+1Z5Vkzrhqm2DZT692uci8UQjv4qHch9jyyR2HePACXYfbMzYySUbvb6?= =?utf-8?q?+13HuufTrZfO6h7vgOhX81PiMr3iqp+6yMmXjpekFXYM7/++NE70CO2HOE8JTtAdO?= =?utf-8?q?M2PAg4+iC1F1WEIWwdH7NyOVOE9WpTyw5k1J4yjWuAuhdb/vMvWb67GBi7QdlBvFQ?= =?utf-8?q?mWiVjI48pG/Em1+iwVY0fizSyaA+AQgGKaMhIK2r516qzOBHAA8HqIlSiRcR2excW?= =?utf-8?q?GFvg/W5ZhEoYDGbBe+2TiY6ZCdYlZP65byROi6MdoKuA8S/A1dNt9+1Yd7T2B3Wie?= =?utf-8?q?nbPwNz1JGKVPk5BMcFyPRU9GzxQurvUsOpBNPStXijGICjH83hM7NE5DcxCX2MgJ4?= =?utf-8?q?vFRt1d+Ee5UwbMxwY/D23kNNj3Iw3uQKFrN6W+7jUtzQcUJ93FBSh5HLtRPgqiU/f?= =?utf-8?q?ZoU49b6Wau60G6QgttvmlWnLzHXr78p6LAfaEYNjRjmzU5gdvbTkT+NcsELAHc3mU?= =?utf-8?q?l/W7ETjvJAwu?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: bce404f4-7a21-4de6-99c6-08db3111b87b X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 11:27:18.3537 (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: ZlAprwsSTY/ZAzx4JNVaReyfPSFwMp7tkIbUsnZ1JiKIvtpP6NHLfACLY2R5M9uQ5Ekdt17VW/7/z26lVpvSjQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8468 There's no need for an indirect call here, as the mode is invariant throughout the entire paging-locked region. All it takes to avoid it is to have a forward declaration of sh_update_cr3() in place. Signed-off-by: Jan Beulich --- I find this and the respective Win7 related comment suspicious: If we really need to "fix up" L3 entries "on demand", wouldn't we better retry the shadow_get_and_create_l1e() rather than exit? The spurious page fault that the guest observes can, after all, not be known to be non- fatal inside the guest. That's purely an OS policy. Furthermore the sh_update_cr3() will also invalidate L3 entries which were loaded successfully before, but invalidated by the guest afterwards. I strongly suspect that the described hardware behavior is _only_ to load previously not-present entries from the PDPT, but not purge ones already marked present. IOW I think sh_update_cr3() would need calling in an "incremental" mode here. (The alternative of doing this in shadow_get_and_create_l3e() instead would likely be more cumbersome.) Beyond the "on demand" L3 entry creation I also can't see what guest actions could lead to the ASSERT() being inapplicable in the PAE case. The 3-level code in shadow_get_and_create_l2e() doesn't consult guest PDPTEs, and all other logic is similar to that for other modes. (See 89329d832aed ["x86 shadow: Update cr3 in PAE mode when guest walk succeed but shadow walk fails"].) --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -91,6 +91,8 @@ const char *const fetch_type_names[] = { # define for_each_shadow_table(v, i) for ( (i) = 0; (i) < 1; ++(i) ) #endif +static void cf_check sh_update_cr3(struct vcpu *v, int do_locking, bool noflush); + /* Helper to perform a local TLB flush. */ static void sh_flush_local(const struct domain *d) { @@ -2487,7 +2489,7 @@ static int cf_check sh_page_fault( * In any case, in the PAE case, the ASSERT is not true; it can * happen because of actions the guest is taking. */ #if GUEST_PAGING_LEVELS == 3 - v->arch.paging.mode->update_cr3(v, 0, false); + sh_update_cr3(v, 0, false); #else ASSERT(d->is_shutting_down); #endif From patchwork Thu Mar 30 11:28:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13193982 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 B4005C761A6 for ; Thu, 30 Mar 2023 11:28:19 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.516635.801073 (Exim 4.92) (envelope-from ) id 1phqRu-0008Lm-Jc; Thu, 30 Mar 2023 11:28:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 516635.801073; Thu, 30 Mar 2023 11:28:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1phqRu-0008Lf-Gk; Thu, 30 Mar 2023 11:28:10 +0000 Received: by outflank-mailman (input) for mailman id 516635; Thu, 30 Mar 2023 11:28:09 +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 1phqRt-0008Hi-7b for xen-devel@lists.xenproject.org; Thu, 30 Mar 2023 11:28:09 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2060f.outbound.protection.outlook.com [2a01:111:f400:fe1a::60f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f17ae3ad-ceed-11ed-b464-930f4c7d94ae; Thu, 30 Mar 2023 13:28:07 +0200 (CEST) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by PAXPR04MB8782.eurprd04.prod.outlook.com (2603:10a6:102:20d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.35; Thu, 30 Mar 2023 11:28:06 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b%6]) with mapi id 15.20.6222.033; Thu, 30 Mar 2023 11:28:05 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f17ae3ad-ceed-11ed-b464-930f4c7d94ae ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dHhl5j7FNcvkHOfe24V4SM18kCPTzXi+RRxUi7vk0sifUa3lgs6Mp69rZY35nLyx4KsMo0nGDgSmaiombpLoTpHjZZnlfVsHZ1u9sJjg9ZTbc3WPqwmF7GJstR8Nggi7kLa8K8tqEFUG4+v5DsBIJVU1A8QXQRux9wMkH8K3X2cYFkFKDhGyZaoo0tDHDze38gYKY8lZ2ulPvJ1fEzg/S0Zx9vL+K6el6lB0n9wA5ZiA5jhAp32n+HZokynrQyczDfscjXs2wR/UdCpfPKFzb68UorZ5X3jZ6BSglv+4SlNyQc82o9AJuRCATsh2DoBjJHhS9DhXjMAvPVutB2H0Jg== 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=bLFXY1A1PoRDeG2OxMqFXZeghqkcVHyCuf7lr3QrX/U=; b=LGIbasSAViVCSKX+dCOV9iyH+d19WKFAnbd2vtR0Eem1zG+jt69M4tfe3W8NM5RJ2e3OVTERrg3gYtvPJAHhAlnMleA81Xl3z7uVVZJ59WptKej4lb8ry5DyxqmsnDyiw+rLeB2Tv0PMrIrxzpDcHuW27bhaN/iNSIafMgJwUlsWRxb+qFDCCXPN9B/yhSoKw3LcIhA5281PjEiN3I/iHTp1Dry3MJmuryhMMb/f846P4UOnaoqQbWoKImcT28PBcrs4SUWHKHEifmy3oxiLQAAr5dtaMod8tIMM+nMuJutsi/h10JVOJHIcUntIbGEJ3RPRZ5Te9XJhus3m/j3Y2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bLFXY1A1PoRDeG2OxMqFXZeghqkcVHyCuf7lr3QrX/U=; b=otxxi+15956H2KFZJhaldcSAmVBLCw1pUJDwmbnpRcKcrDxfg6BV4GZ5tAo6H+xP8I1pcBQkaCyTEvLYbkFpJ+G4FkLap9orf0YjxyzT+crw93jd+8AMPecX/Zfv//k9M1dN4vGbm/5VnN8MTl2SL4KXgaa06vLofZdifgOsDyY95bVqnSneN24vycATzeVh2n8BkAUIDYooxjDMxKhylkjUvJZb3JkuOyBjvlOQPAFKXTazKhpILJqr8TynFeFAOq/Re6Azy2RSDKaFiVxWX8Lg1qVzumIQ6tOnaOIIQtdr3sZCujHtDwNERpGwMS9V1WCi2NIVTtX3+ZiF8Q/7HQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <6363f9aa-4030-d889-a85d-f5834e607d85@suse.com> Date: Thu, 30 Mar 2023 13:28:04 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: [PATCH v2 05/13] x86/shadow: don't generate bogus "domain dying" trace entry from sh_page_fault() Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Tim Deegan References: In-Reply-To: X-ClientProxiedBy: FR3P281CA0192.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a4::16) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|PAXPR04MB8782:EE_ X-MS-Office365-Filtering-Correlation-Id: 1ed8ee46-0696-4e5a-9a0c-08db3111d4d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kkYaEWtsx7PFfKM1PwHx6ux3lX/5+JYW5iaNU4gaMLqiCj/dLuDY34hw5EYx69kAq3wA5Orm7qsh3/zRJ02Rln81zb026YzqQ/+1al5TPH2uPh71zRBxEq6l/958odINyftdk1VFgMDT6vDxuXRyNHALOCwMDdYzqNX03C5r0ZopW+9b8rwLQ7zFEc7HLEVCSzyxhmH/TKCJB9Eow4ZwPzOPACHrSQddv9M6pcHvjGER0d1dl/edMxb3Urq7P/1X++xwfQ9fduwW7VnlAe610HqOSqNWdTYym7y71XNqjiTKyJA4jZSRkmtzqbatE1FNrmhNQH13njoDkBI+6GDgD39Sf+2w9DaJx4rUZF2vMRagUlmKEapADmzlqx/Xwu/2ELxWP+3P8u4jbujn1p4f/gR9QZTwCwrkxetRt4/ZN9znJN5b0H20F9A80+AkQHHJ5fNYZuiTta5Xu9phyZGWKwGGoDrru/87EtyRxiHaaQhAZK6EZX+aaIzWHqyR5HBCdW6rq0QFXa1rwrKwHzQj6hvlI/zlxhHqv4khPibcFTkkt8icPmxGL8h1mF8ETLuJN1ZlDjAdEGQFoVQ82JyvkDFBnQ9Nt4B2mH4ZCggfBapaAGPd9F25hovP2jh5P5rGmY7DJZzucUn0nvk7vcCb6JenJY+9skcXhSx8B6kjxf3ciBOeSzeZw+SSWIVRFj7AXxRmfZI1z3us6sQQ8mRzSw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(366004)(136003)(39860400002)(396003)(376002)(451199021)(316002)(66556008)(8676002)(66476007)(54906003)(6916009)(5660300002)(38100700002)(41300700001)(4744005)(66946007)(8936002)(186003)(4326008)(2616005)(6506007)(6486002)(6512007)(478600001)(83380400001)(26005)(86362001)(2906002)(31696002)(36756003)(31686004)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?F1C6AmujT8GQB2+70O+p0OeooKFD?= =?utf-8?q?v8jJI+shE0WJoPwFxXdPGYKTghvkQKudNZGqgdnRV14bcnWeYb43zZNi9Kfqe+yOm?= =?utf-8?q?xkbrjIZpPsLtUVTNqJiP1yCymevDIEZUuN6q8B5RLVSXr4M7hUupyjgcHxV9rqftR?= =?utf-8?q?i8/ySTm41PHMk6puWpDuEjkLvy0V0Ic2mY0x/KKR5272AaE0iyNw5UtpRzmyiiVcS?= =?utf-8?q?eUH5rFTJzd8Ds8WfhIMS53GAN0VkD7R1VBA/xFA+491ytkIB2gvXPDx3Pv7Ui4Q43?= =?utf-8?q?xM8hf0Am0t7eHHz8ZmLOinPWobOTbjuq7srjSkCffH2RrNgnn1Jfz7pL36oC6jF6c?= =?utf-8?q?gpPw3L5GKUCXTB84LFFCcvx0gjlEHDU0Atk/BY1Fn5GCaJJSsBr47c9LjM+vAwy+v?= =?utf-8?q?ajaW5WuwE1eghdAXg+UAdWeB2Mb//UIZsg/A8r1SpawFZq4G4+X202MdnkLCYI6Mj?= =?utf-8?q?x18l7c7Fw40boC2Q+D4R6OKiEzQSsGjZ0s/Ar8LFO+zygXDRKgYGbZzuC9mkLsANu?= =?utf-8?q?9ugUaiFwhI9kSdaoGvNyK/yW2IZCb/u6W0AvNdzRfc9b/iizAPDGHLbl7opMVYtRC?= =?utf-8?q?9eGNktvNg1IBBevD9MRgbDlXYnOizPVNu0JeHak2hwfAACWDl3Aet4sSTiHJqPm8s?= =?utf-8?q?IfTt14c/XY2uXv8fnAwAU3ifQ3qOhY7dLHbx11i3F4M47c2qTX4RxDZwemnWcM1J3?= =?utf-8?q?zewI3ysn912aOfRZ59mXoXDihBLpeJbJ0moJngCc7g+L6H6A5OyDK9Hugvd0+ud4A?= =?utf-8?q?ysdjrjPI+4WaqxzFDdPy7OJ4u4KYWawlsvj9+U0OB4J++eMxi6hqzoEO4/FNbvSwu?= =?utf-8?q?okULYTyAMe/bkv3lG4vY3wxBaX1DSd1J6LZdqw34PP9BMEuOg77ulzeDM6Tezy1Tq?= =?utf-8?q?2HmvtEk9msqKcOBZNDiwDVd1NHwMXzo6LcpLi3kVps2kTgM4Cs/R8a4+5sPRxYWDx?= =?utf-8?q?qlIm3YHMdosAoGdvxTOE8D1Bw2sdcuuDhKrA5E6QBtJirN4TxUK2MxnkEynR8BHSH?= =?utf-8?q?xefxRkMbhVwO5o6BQmezN16SZWqyUFhcjFEau9b+Bmxdb/v8NjqBYWKGtB/3U8njP?= =?utf-8?q?2BSj//GY+v/QPuvhu68JOdp4VQ3NfJrhX/3hZRjrK4xIXZqcygYvgll8aNeqkyVkk?= =?utf-8?q?x/ysHo2er8vU7HZqbRw0+Us/Ts4pkdNp0WeySU8FM93G9xdydSjqf1WZLxmzASJn+?= =?utf-8?q?gOjkPgvbqOGVVXJPVZrUvCUvL+xoNQ2wGjJqxlylLxwSY+pNzuak5wN6hn6Rdi6nO?= =?utf-8?q?wiUTs+lb8o0GFVso2bKzqiJYVarKxdNz/lPC+3AQkokVulKevrGkxvG4xF4WA3c2Z?= =?utf-8?q?thc+GT9GYI7t87JIjA8sQnW41/XLvzwtYa4J7ILPZ2DPjXX2K/eTXwRGjYsr6zCYV?= =?utf-8?q?CxmvL59RuLoKnKX+Grp2xQZ2AHPxLdm+yHg1o4ieQkR0ZdeLKYmwgAYxeC5RcobrO?= =?utf-8?q?3aM1trPeXNjPo+ZfaDu6XhxyxA4uDB6hVRwpE6hdYcyiYsEa+wMtv5MGSMVN514Dl?= =?utf-8?q?FBMKuGFjASGu?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ed8ee46-0696-4e5a-9a0c-08db3111d4d4 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 11:28:05.9154 (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: MAPpOQJNCsFA6To+zP515CbVcui0/lVJEhFS/0UQ4q9TUH5kg0u7LDYmbbIovPka0tTJQ9MTfClbu9aTYe8OKw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8782 When in 3-level guest mode we help a guest to stay alive, we also shouldn't emit a trace entry to the contrary. Move the invocation up into the respective #ifdef, noting that while this moves it into the locked region, emitting trace records with the paging lock held is okay (as done elsewhere as well), just needlessly increasing lock holding time a little. Signed-off-by: Jan Beulich --- v2: New. --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -2492,10 +2492,10 @@ static int cf_check sh_page_fault( sh_update_cr3(v, 0, false); #else ASSERT(d->is_shutting_down); + trace_shadow_gen(TRC_SHADOW_DOMF_DYING, va); #endif paging_unlock(d); put_gfn(d, gfn_x(gfn)); - trace_shadow_gen(TRC_SHADOW_DOMF_DYING, va); return 0; } From patchwork Thu Mar 30 11:28:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13193986 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 99D19C6FD1D for ; Thu, 30 Mar 2023 11:29:10 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.516639.801083 (Exim 4.92) (envelope-from ) id 1phqSg-0000XK-2j; Thu, 30 Mar 2023 11:28:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 516639.801083; Thu, 30 Mar 2023 11:28:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1phqSf-0000XD-W9; Thu, 30 Mar 2023 11:28:57 +0000 Received: by outflank-mailman (input) for mailman id 516639; Thu, 30 Mar 2023 11:28:56 +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 1phqSe-0000Wf-DM for xen-devel@lists.xenproject.org; Thu, 30 Mar 2023 11:28:56 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0603.outbound.protection.outlook.com [2a01:111:f400:fe02::603]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 0cf75118-ceee-11ed-b464-930f4c7d94ae; Thu, 30 Mar 2023 13:28:54 +0200 (CEST) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by VE1PR04MB7262.eurprd04.prod.outlook.com (2603:10a6:800:1ab::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.22; Thu, 30 Mar 2023 11:28:51 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b%6]) with mapi id 15.20.6222.033; Thu, 30 Mar 2023 11:28:51 +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: 0cf75118-ceee-11ed-b464-930f4c7d94ae ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IHym341cL9QELRcjy2x7O6q96mwuEBCwMNXjhd92QikchXkzhSMf/rc3PE0uKKPerDQdQdCkjqvfUwQF4PCwaS81BRW9iDgN1AvGcfChEG/XQ/A7ZS7P+j/zibFLzN57IajoC4QOwm05qjiaNTBlNMNtGPPIJ/xlA5ryidq7vMeu+Lzdgd9xR2Vb/5x5gAMKTMPuNCjArPXpbldi+y1zJrGQhXZAGgDk5BQZ3qpPKuhxozsrvZQ7dq1obz7r9KfGln7MjlZj+eBiUwbGLbujMDsiAtkP2HtcEdNwzxjMURH1AzCA8+7kA48jRIm7C5EL/pCpDsAQkDYrzR/0nmj9vg== 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=OMWrhjKLwqoqO04g0GrrD1jO59AIbRDrnsG95manGKw=; b=AYsb16hdbV6yw2IeB3weg6oAZSJaQBD3FVdYD38wOLSRg5sleltKalO99Ojd6GtznGojxbmhXi7DbuL+E62m0+NjihGgh/V8CzyOY1W28xwXIwgJBW9+lbkyZkhWdQtkiGkZvIv8GdgM+HCD2apHSHzeHnSMsmZCjn9VEpTMgrWxOjRXkx3vhCaXi963MeBlhGaD1GvL4iG1N3bcpyUS8rPeAHraePJWHXa47WUZvuMD3PCRiU7W8Ugb6H7tdHy8JmNhq1bBT8J56fVD+DUN4+DkFDQN3XBhRgFnJsezmGEkeDf1B5+JbUD6qSwNkF0Q0SivtapwDE0YeJrnBA4E5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OMWrhjKLwqoqO04g0GrrD1jO59AIbRDrnsG95manGKw=; b=qxmeKtZ3WVO/tRgv4DZWBRUVg3siGHJMdzMrPhiLOYginJdqkpjBwYfvKU2kqvCnXeBcfZtZ9mcPKDbJx31iC1CpjQ+rwV9uSKthP+TNoEk105H1wXTh6lfzoR8zsRe4eto40CKEMNhm7JB19kfXxAQGbvygbzo+U5P5YNCWd9o7wyVCs/ak2yW5i2Hc/1YSv4PO57twbf2F7vGFKOLPx7Q2CQ/M4kovz2x/Vffta3NyHGDR3DUJAMpoEpEqu18O9PLXXbSV+CQ9YPHYUfe4T6Me+kuu5SV14d4NUCxys2FAUBIHM8c4rUeQ2War1eMarBzF6sVZvLXV/g1FiAvMlw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <74eb4a4c-8f5c-fd1d-f3a2-479abe736480@suse.com> Date: Thu, 30 Mar 2023 13:28:50 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: [PATCH v2 06/13] x86/shadow: use lighter weight mode checks Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Tim Deegan References: In-Reply-To: X-ClientProxiedBy: FR3P281CA0071.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4b::7) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|VE1PR04MB7262:EE_ X-MS-Office365-Filtering-Correlation-Id: ad630740-782b-4e70-e904-08db3111eff2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8memgGHnnl3923G4y2R5P0BTvyELGs7DNEdsvhKy4/yfszg5A5bqzZZNkznqif5mhuvcMNAq6rBUeZud9QVj7DN67b61qu9/UMO9lZWXGtQjKKvsFnfAe8DMFURf/jYhrwbGX0u+8qDPSu7y8onqDWiWtMSWJ47mxS41ET7dFmwzjIRKpBN5casbravTVC/EnzbmSHX5KUPos9HL06AP2awRb0C4TmQLwNPajiIb7R3rDklcKD6mf8fS5Q8zYkp90Gex55pOjhD+AZ4waBYVm2u3BlophI9QsN1/deCYmxorMg1dMw6eSvz1BUcJZUCcCAOYQTmNkF1YPlk2KQZQmSfrSPZmO8ds69sdzMUyJGIZq9De6gOvox6irR56LkNS/CtOoqupIamvyFao3yfbq9FtA4ZaBIamLc0scfyPum4cULWpLwguO0xJpCnUf5bEPavUfPIdLMhVjCRztc1TqvnYNEcTacbc2/CnIAtWlonIKmcFjMq30ZnATs4VBQdiU1dF2DW0nl/PF+Ydw8HPq6tVRNH4XsEzqFBmhuOa/70bxaG1P5gwlNGGNs+we5R6qptn6w4FILHYNI7sZwcrPqcY5PxsnAsCti72bT+IbnWia1izGw7bf3JF+OCJYg0yZUbiBDsbSERDBf38KwUyCFS7Sk430PEKKkFYX2O9qxBXzhSbiPNarDFEHbGepf5fZgzwKcsMSe2SoHFTiW6HwiYenbKrr7oxljvs/0TsvFmxYm+WBqnnmMH3CpCCRbOA X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(366004)(396003)(136003)(376002)(39850400004)(451199021)(2616005)(83380400001)(6486002)(26005)(478600001)(316002)(186003)(54906003)(6506007)(2906002)(6512007)(36756003)(5660300002)(8936002)(38100700002)(4326008)(6916009)(66556008)(8676002)(66946007)(31696002)(66476007)(41300700001)(86362001)(31686004)(66899021)(16393002)(45980500001)(43740500002)(414714003)(473944003)(357404004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?O1pbuaKZLvzlxT3/seacpZKq6b4H?= =?utf-8?q?gjgfOENbZLvBwK/5nyTZmq7M6xIT3JNsR/Xx2ClaXdMoGZRjDmTajJmkb7Lj8ZsoH?= =?utf-8?q?9Fi9wH/HEImDpbCXcR9wM/jE9v2XfKr3RKEiJUXYd0ztkmO/SGJu6Kag3hYhfMJcx?= =?utf-8?q?L+FgLF5+KrWWl/6sniY5G2wBZKybAotlumWa61gecms2u2oVvCOQpfMa+oTUTrEWu?= =?utf-8?q?rNxP2BtcPOBTJZnl357uvrOI1KOwkJoCDQ0S1g955N0d/Q6sLRatEEAZGxTpzm0ah?= =?utf-8?q?Zb23NQSFyTb/DNWIsPsy3uwmrtn392nZx0Rx0YgNOJ0hCqciKOhpQoRfnTx+FhjMG?= =?utf-8?q?ZVN39MYqhi6g0yNb+gqXSt645UGayGLNDXOyWknbyLVd+l6DYNern4AxmzkAp4XdB?= =?utf-8?q?vyddK8jJ7YUru06wrSOPbbskLI6yX2ew0qqnIOhPO+eebg5n1oJ1oxmy54Wp3oyWM?= =?utf-8?q?Py//7kgLWcX/UntrOiUsz/ySPxESiQBdY+BfVk1uKBMDOlCueHv13lquNZmTj/dV0?= =?utf-8?q?ribX0NE3GCFcuRyn5rLpPM1UdUTdu6OTVYDugoPc7wZqBdtn3/4er/9k9X/Dd/jlO?= =?utf-8?q?a543q7oqPAxOR37S0soCIkQ9xdNoLFe0jNMbjjgfD2o98ln6lHPgx9oVwmx32qPe0?= =?utf-8?q?0c2CO13WDoddwva9TTFfsc/6QuTDPZ/Tm7lWYPb0MUTVv9xMIhuTo9Uh18YxdLM3I?= =?utf-8?q?fALj+H0fCnGTu+g7fEi3jw+3tJEN+ITXYXGfvJPPpACwnXlNPv6gjJEZzogLakPuQ?= =?utf-8?q?A3Qm0Objb+XxiEMOMngrjg+37xq8q5Zcn6ulzKeNH53oXte/G3wWsW7E78JmGWbo9?= =?utf-8?q?3zjiotHjKeBH2Sb7SabGMMJCIpWExiXfJtTZ1edtDhxygsXaR5MiQrcgfc4SCzBGm?= =?utf-8?q?wWWHVVd0vsTqgn0MzzwrEtK1av06SOUj8gtcfYxTZiAjHoVe0I581XyB8R6R9vcRf?= =?utf-8?q?qree9ayhBj3VbPmabOWFMAeb27z9lRM24CBcevNiyoUuzHr+0CdwmVmaAtkdn8kt3?= =?utf-8?q?UVTndho5Dllgc2SR9584S7iTmbCHGDO/rAFmg7Y4A9rvjI5dWgiPraphiGsJTgu1M?= =?utf-8?q?8BhWfWA1gNe7js7DN0+W0YZiYbijHykYG5EqNchFjvYDDSLPpixIZvz7sbxl0Gjga?= =?utf-8?q?jrqYz9eIhwcdfkPDDnYSDH/HhwlfmcOc1ll0eF1Xxlk8sUo+d4SK9y5k3TZANBLnd?= =?utf-8?q?8RiwgStn36NeUPoRk0c+SoVF2lLIQHb6MOsGtG2EJo5o3z+OkvN5ahLhqBMzbxNUA?= =?utf-8?q?wV+L6wZRv2VKTbq8IXllKe0vINh/XfuwuMivMO/KJ91hqEGOZ4ciTAXdUKC9qPufU?= =?utf-8?q?zCkE2pHaU2Sg003sPRVeHtw0s2smqf+4bxttfoRrlYCpJcpIgiGhwEphjMPFKpzdX?= =?utf-8?q?hoJpPL7RBY0Iako7oiAwOAyd73V0swjoAvtMe8J/WTxnz0JSxDG3KbkA7aUlpGqTp?= =?utf-8?q?w/cyN79eRtsMSE3DafzGLI/sJ75yObP8+8d1E0WtwvgVyjG6rt9/Xj5JBqCcr6fb1?= =?utf-8?q?HWB3gAaIjL9f?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad630740-782b-4e70-e904-08db3111eff2 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 11:28:51.4167 (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: LWpWk8yDV2la+oYkT79E07SY+0eEmvB0wIHZVmKdxSroYbZOm58Q+lBGZpRVYP09bsrp5KrzFtjAAykW+lxFHw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7262 shadow_mode_...(), with the exception of shadow_mode_enabled(), are shorthands for shadow_mode_enabled() && paging_mode_...(). While potentially useful outside of shadow-internal functions, when we already know that we're dealing with a domain in shadow mode, the "paging" checks are sufficient and cheaper. While the "shadow" ones commonly translate to a MOV/AND/CMP/Jcc sequence, the "paging" ones typically resolve to just TEST+Jcc. Signed-off-by: Jan Beulich --- v2: Re-base over new earlier patch. --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -1856,7 +1856,7 @@ int sh_remove_write_access(struct domain * In guest refcounting, we trust Xen to already be restricting * all the writes to the guest page tables, so we do not need to * do more. */ - if ( !shadow_mode_refcounts(d) ) + if ( !paging_mode_refcounts(d) ) return 0; /* Early exit if it's already a pagetable, or otherwise not writeable */ @@ -2088,7 +2088,7 @@ int sh_remove_all_mappings(struct domain * guest pages with an extra reference taken by * prepare_ring_for_helper(). */ - if ( !(shadow_mode_external(d) + if ( !(paging_mode_external(d) && (page->count_info & PGC_count_mask) <= 3 && ((page->u.inuse.type_info & PGT_count_mask) == (is_special_page(page) || @@ -2385,8 +2385,8 @@ static void sh_update_paging_modes(struc { const struct paging_mode *old_mode = v->arch.paging.mode; - ASSERT(shadow_mode_translate(d)); - ASSERT(shadow_mode_external(d)); + ASSERT(paging_mode_translate(d)); + ASSERT(paging_mode_external(d)); #if (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC) /* Need to resync all our pages now, because if a page goes out @@ -2773,7 +2773,7 @@ void shadow_vcpu_teardown(struct vcpu *v sh_detach_old_tables(v); #ifdef CONFIG_HVM - if ( shadow_mode_external(d) ) + if ( paging_mode_external(d) ) { mfn_t mfn = pagetable_get_mfn(v->arch.hvm.monitor_table); --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -526,7 +526,7 @@ _sh_propagate(struct vcpu *v, || (level == 1 && page_get_owner(mfn_to_page(target_mfn)) == dom_io); if ( mmio_mfn - && !(level == 1 && (!shadow_mode_refcounts(d) + && !(level == 1 && (!paging_mode_refcounts(d) || p2mt == p2m_mmio_direct)) ) { ASSERT((ft == ft_prefetch)); @@ -543,7 +543,7 @@ _sh_propagate(struct vcpu *v, _PAGE_RW | _PAGE_PRESENT); if ( guest_nx_enabled(v) ) pass_thru_flags |= _PAGE_NX_BIT; - if ( level == 1 && !shadow_mode_refcounts(d) && mmio_mfn ) + if ( level == 1 && !paging_mode_refcounts(d) && mmio_mfn ) pass_thru_flags |= PAGE_CACHE_ATTRS; sflags = gflags & pass_thru_flags; @@ -663,7 +663,7 @@ _sh_propagate(struct vcpu *v, * (We handle log-dirty entirely inside the shadow code, without using the * p2m_ram_logdirty p2m type: only HAP uses that.) */ - if ( level == 1 && unlikely(shadow_mode_log_dirty(d)) && !mmio_mfn ) + if ( level == 1 && unlikely(paging_mode_log_dirty(d)) && !mmio_mfn ) { if ( ft & FETCH_TYPE_WRITE ) paging_mark_dirty(d, target_mfn); @@ -819,7 +819,7 @@ do { #define FOREACH_PRESENT_L2E(_sl2mfn, _sl2e, _gl2p, _done, _dom, _code) \ do { \ int _i, _j; \ - ASSERT(shadow_mode_external(_dom)); \ + ASSERT(paging_mode_external(_dom)); \ ASSERT(mfn_to_page(_sl2mfn)->u.sh.type == SH_type_l2_32_shadow); \ for ( _j = 0; _j < 4; _j++ ) \ { \ @@ -845,7 +845,7 @@ do { do { \ int _i; \ shadow_l2e_t *_sp = map_domain_page((_sl2mfn)); \ - ASSERT(shadow_mode_external(_dom)); \ + ASSERT(paging_mode_external(_dom)); \ ASSERT(mfn_to_page(_sl2mfn)->u.sh.type == SH_type_l2_pae_shadow); \ for ( _i = 0; _i < SHADOW_L2_PAGETABLE_ENTRIES; _i++ ) \ { \ @@ -866,7 +866,7 @@ do { unsigned int _i, _end = SHADOW_L2_PAGETABLE_ENTRIES; \ shadow_l2e_t *_sp = map_domain_page((_sl2mfn)); \ ASSERT_VALID_L2(mfn_to_page(_sl2mfn)->u.sh.type); \ - if ( is_pv_32bit_domain(_dom) /* implies !shadow_mode_external */ && \ + if ( is_pv_32bit_domain(_dom) /* implies !paging_mode_external */ && \ mfn_to_page(_sl2mfn)->u.sh.type != SH_type_l2_64_shadow ) \ _end = COMPAT_L2_PAGETABLE_FIRST_XEN_SLOT(_dom); \ for ( _i = 0; _i < _end; ++_i ) \ @@ -908,7 +908,7 @@ do { #define FOREACH_PRESENT_L4E(_sl4mfn, _sl4e, _gl4p, _done, _dom, _code) \ do { \ shadow_l4e_t *_sp = map_domain_page((_sl4mfn)); \ - int _xen = !shadow_mode_external(_dom); \ + int _xen = !paging_mode_external(_dom); \ int _i; \ ASSERT(mfn_to_page(_sl4mfn)->u.sh.type == SH_type_l4_64_shadow);\ for ( _i = 0; _i < SHADOW_L4_PAGETABLE_ENTRIES; _i++ ) \ @@ -977,7 +977,7 @@ sh_make_shadow(struct vcpu *v, mfn_t gmf #endif // Create the Xen mappings... - if ( !shadow_mode_external(d) ) + if ( !paging_mode_external(d) ) { switch (shadow_type) { @@ -1379,7 +1379,7 @@ void sh_destroy_l1_shadow(struct domain shadow_demote(d, gmfn, t); } - if ( shadow_mode_refcounts(d) ) + if ( paging_mode_refcounts(d) ) { /* Decrement refcounts of all the old entries */ mfn_t sl1mfn = smfn; @@ -1476,7 +1476,7 @@ static int cf_check validate_gl4e( l4e_propagate_from_guest(v, new_gl4e, sl3mfn, &new_sl4e, ft_prefetch); // check for updates to xen reserved slots - if ( !shadow_mode_external(d) ) + if ( !paging_mode_external(d) ) { int shadow_index = (((unsigned long)sl4p & ~PAGE_MASK) / sizeof(shadow_l4e_t)); @@ -2399,7 +2399,7 @@ static int cf_check sh_page_fault( gfn = guest_walk_to_gfn(&gw); gmfn = get_gfn(d, gfn, &p2mt); - if ( shadow_mode_refcounts(d) && + if ( paging_mode_refcounts(d) && ((!p2m_is_valid(p2mt) && !p2m_is_grant(p2mt)) || (!p2m_is_mmio(p2mt) && !mfn_valid(gmfn))) ) { @@ -2623,7 +2623,7 @@ static int cf_check sh_page_fault( return EXCRET_fault_fixed; emulate: - if ( !shadow_mode_refcounts(d) ) + if ( !paging_mode_refcounts(d) ) goto not_a_shadow_fault; #ifdef CONFIG_HVM @@ -3067,7 +3067,7 @@ sh_update_linear_entries(struct vcpu *v) */ /* Don't try to update the monitor table if it doesn't exist */ - if ( !shadow_mode_external(d) || + if ( !paging_mode_external(d) || pagetable_get_pfn(v->arch.hvm.monitor_table) == 0 ) return; @@ -3216,7 +3216,7 @@ static void cf_check sh_update_cr3(struc /* Double-check that the HVM code has sent us a sane guest_table */ if ( is_hvm_domain(d) ) { - ASSERT(shadow_mode_external(d)); + ASSERT(paging_mode_external(d)); if ( hvm_paging_enabled(v) ) ASSERT(pagetable_get_pfn(v->arch.guest_table)); else @@ -3241,7 +3241,7 @@ static void cf_check sh_update_cr3(struc * table. We cache the current state of that table and shadow that, * until the next CR3 write makes us refresh our cache. */ - ASSERT(shadow_mode_external(d)); + ASSERT(paging_mode_external(d)); /* * Find where in the page the l3 table is, but ignore the low 2 bits of @@ -3272,7 +3272,7 @@ static void cf_check sh_update_cr3(struc ASSERT(d->is_dying || d->is_shutting_down); return; } - if ( !shadow_mode_external(d) && !is_pv_32bit_domain(d) ) + if ( !paging_mode_external(d) && !is_pv_32bit_domain(d) ) { mfn_t smfn = pagetable_get_mfn(v->arch.paging.shadow.shadow_table[0]); @@ -3366,7 +3366,7 @@ static void cf_check sh_update_cr3(struc /// /// v->arch.cr3 /// - if ( shadow_mode_external(d) ) + if ( paging_mode_external(d) ) { make_cr3(v, pagetable_get_mfn(v->arch.hvm.monitor_table)); } @@ -3383,7 +3383,7 @@ static void cf_check sh_update_cr3(struc /// /// v->arch.hvm.hw_cr[3] /// - if ( shadow_mode_external(d) ) + if ( paging_mode_external(d) ) { ASSERT(is_hvm_domain(d)); #if SHADOW_PAGING_LEVELS == 3 --- a/xen/arch/x86/mm/shadow/private.h +++ b/xen/arch/x86/mm/shadow/private.h @@ -420,7 +420,7 @@ static inline int sh_remove_write_access unsigned int level, unsigned long fault_addr) { - ASSERT(!shadow_mode_refcounts(d)); + ASSERT(!paging_mode_refcounts(d)); return 0; } #endif @@ -533,8 +533,8 @@ sh_mfn_is_a_page_table(mfn_t gmfn) return 0; owner = page_get_owner(page); - if ( owner && shadow_mode_refcounts(owner) - && (page->count_info & PGC_shadowed_pt) ) + if ( owner && paging_mode_refcounts(owner) && + (page->count_info & PGC_shadowed_pt) ) return 1; type_info = page->u.inuse.type_info & PGT_type_mask; --- a/xen/arch/x86/mm/shadow/set.c +++ b/xen/arch/x86/mm/shadow/set.c @@ -93,7 +93,7 @@ shadow_get_page_from_l1e(shadow_l1e_t sl struct domain *owner = NULL; ASSERT(!sh_l1e_is_magic(sl1e)); - ASSERT(shadow_mode_refcounts(d)); + ASSERT(paging_mode_refcounts(d)); if ( mfn_valid(mfn) ) { @@ -354,7 +354,7 @@ int shadow_set_l1e(struct domain *d, sha !sh_l1e_is_magic(new_sl1e) ) { /* About to install a new reference */ - if ( shadow_mode_refcounts(d) ) + if ( paging_mode_refcounts(d) ) { #define PAGE_FLIPPABLE (_PAGE_RW | _PAGE_PWT | _PAGE_PCD | _PAGE_PAT) int rc; @@ -387,7 +387,7 @@ int shadow_set_l1e(struct domain *d, sha old_sl1f = shadow_l1e_get_flags(old_sl1e); if ( (old_sl1f & _PAGE_PRESENT) && !sh_l1e_is_magic(old_sl1e) && - shadow_mode_refcounts(d) ) + paging_mode_refcounts(d) ) { /* * We lost a reference to an old mfn. --- a/xen/arch/x86/mm/shadow/types.h +++ b/xen/arch/x86/mm/shadow/types.h @@ -274,7 +274,7 @@ int shadow_set_l4e(struct domain *d, sha static void inline shadow_put_page_from_l1e(shadow_l1e_t sl1e, struct domain *d) { - if ( !shadow_mode_refcounts(d) ) + if ( !paging_mode_refcounts(d) ) return; put_page_from_l1e(sl1e, d); From patchwork Thu Mar 30 11:29:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13193987 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 8303DC761A6 for ; Thu, 30 Mar 2023 11:30:03 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.516642.801093 (Exim 4.92) (envelope-from ) id 1phqTX-000183-Ch; Thu, 30 Mar 2023 11:29:51 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 516642.801093; Thu, 30 Mar 2023 11:29:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1phqTX-00017s-9g; Thu, 30 Mar 2023 11:29:51 +0000 Received: by outflank-mailman (input) for mailman id 516642; Thu, 30 Mar 2023 11:29:50 +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 1phqTW-00017i-5X for xen-devel@lists.xenproject.org; Thu, 30 Mar 2023 11:29:50 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0614.outbound.protection.outlook.com [2a01:111:f400:fe02::614]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2ca88dfd-ceee-11ed-b464-930f4c7d94ae; Thu, 30 Mar 2023 13:29:46 +0200 (CEST) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by VE1PR04MB7262.eurprd04.prod.outlook.com (2603:10a6:800:1ab::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.22; Thu, 30 Mar 2023 11:29:44 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b%6]) with mapi id 15.20.6222.033; Thu, 30 Mar 2023 11:29: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: 2ca88dfd-ceee-11ed-b464-930f4c7d94ae ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ANvtN6LtwhTDqcjrIm/qSioZOiVayLXVQAgq2BJWraLt/rdoQXVC8TMn6W4TjKg3wxcInIwoc2nufJ+hAkmoZjPfAF56Z9/xmz0PW9IM8xPt4m/k63CleawESvLJzwUqoivU+6U0pELFIsT6IAJuFzeRsIKVwzjBAfEfANgmfRmALP5Znk1YnOLruebiJktVVAHFt9fJgvWWuBYYl2uWvALFF4FGhL9/3b7lW2pVGccQG482mIIh5lE3z5FnYz85TfglT63bIekNvE4z9/YHugm6HtGdxESkQMnxBD76swlc1kYUePF1C3j42wRIMV2bk6pGUDQdNrCOPaprkheVUg== 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=1Yc63R99xXpCV2rFaghPhoG7GaIwoeqheiEnc9dAADg=; b=go0DRwATzveZ5FzDYQV5cPVed0ra3WSNtvUPYwWiMzlic3n0oeS/24y+IDwIF8BCB1i4DbQdAeDf0KBliLBtjuNW2XNwIhs9URv19qjYttFS9K7USjQz9rBAA+I4cYZsgY13dPk6xmodP+fry79ztxjydAOioP48AzFioDjGTGd+l2f0iL0+YHxdQqM77j6z3W8L4EB36819/QYyVdCYZ+DDK4Jndby9Hmjh8S336CeaJIuhwHhInUCXIUEOPxko/kYLMVApG9L7W9dy6pusJixu//1OaP3JSyl5zxZ/9x0erFjkcASufv+cdpclF1HkELUg+/SfedZVd6eJl3ysVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1Yc63R99xXpCV2rFaghPhoG7GaIwoeqheiEnc9dAADg=; b=w73M7jtqUkOuIR1VNn/q7VX4ZVER49pJb3Gy7cEgDVOgXMR8F62A5/GWkSMRHU5ti/pokOipT1xWFiNqjTjMlcjpGqZdBviMVL3B7YE+91xh5QtM8sqSaaFxI79SA/EPCij8WZLNJqjnBPb4KF+t8m4M/2ziJ8l+QDMa7WQPWuGk+i4usg0GayXc+xxAsXaZYDNywCF5mypjatM27CnI+Kxw+pF36lWorI4HP9EjRHSzvBoKVw00i/Vhkb8f/CgdFgjL+AgNgkrMjtCcU12z21vcOKYfXQDsAzr9nmis15V1hgShCsivet7BxBIHRJfpk8qSFN2YeHlwCbS26wLbFg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Thu, 30 Mar 2023 13:29:43 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: [PATCH v2 07/13] x86/shadow: move OOS functions to their own file Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Tim Deegan References: In-Reply-To: X-ClientProxiedBy: FR0P281CA0261.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:b5::15) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|VE1PR04MB7262:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b29130a-6045-490a-0333-08db31120f9f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y4H5ejcPOHTSmfmzacEXkXyc9yLmltlg4iWflarDccXuQ/Hw+7ffGKmHTHeZsM8Nobhr63f3ZitcxYVju/21gLLgVt74EzQZrPW3TrscwgCSRYjQK4+3t9kQoRO/xHIK+HDdzcavaaFQeCnxL7+ERVVDJDYBpQcZNjuphjw9wbZ6jvl/xNjbJUfMJYBcpnOqIs6nart3biSCvZ97vKqsBrlt6hPr+4YVt3ZEgT6oR+LRm39NU2fzLYyx1L97qLHO7o31ktKquMTT9IHI09EWQvN5GVjVhJM2h/WyXaWtzaUrFd7bMma+4qO/qIN3IulitGEMPUiTPXGrAK6T3NmXP2DcFHr3aA5hvVlaZNJHnJqevZGbepZ62XKHELnMPAdDWjI5ZeLdhCNMFR7Mlb8mdc55VNC30MoWQ0906Xk2+onxHHOSjGDegtsHBBS/2MqXYskLZw/1Z7+yJK66jk4kbG3NoaJrmlwlEkCXJOkqK+VDqFA0VyIMlnAL2zeHX+Tbx7QuSJtmlhKtFQUFLbG5ZymjLXo6tiFBFy9JrZEY7Jj7W5VH64vG9jZ0ARYCrAHSJPAMVHfQL+WG40hELTFVHvQtiSDkslzCRYYgfgIaLLy+HkoNu9o3JxmNs2PLSimLyW4s7tI4eT/5Qnao7lYXBT4LkjKLCpBY/1j0hlVGOkrfSrxreBPcUHrphdAFh3x+mMWYiSe98pm9c1od/x43ng== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(366004)(396003)(136003)(376002)(39850400004)(451199021)(2616005)(83380400001)(6486002)(26005)(478600001)(316002)(186003)(54906003)(6506007)(2906002)(6512007)(36756003)(5660300002)(30864003)(8936002)(38100700002)(4326008)(6916009)(66556008)(8676002)(66946007)(31696002)(66476007)(41300700001)(86362001)(31686004)(66899021)(45980500001)(43740500002)(579004)(414714003)(473944003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?fG+vcXcv4iM43SRFRCR82DxR8FTP?= =?utf-8?q?0iks3feKmsCBZqvc5rB/v3dSMMLljRFi9ptPoQ/lCiHIDalQoUwOkVhDFbRQFiW8B?= =?utf-8?q?sdmFP8d827E5ayBd89q8geNT7rW+cJJpiX+HeLIKAUaxq2j0Uiv3tfNIHCvYanZMV?= =?utf-8?q?oIIJIAURxngHvhkkxYPfNu7I3RuzcT5uiF9XlGpifLSiGwjKA9uczRYjMCWLmtiIW?= =?utf-8?q?E/jdmw3OD8QpMJtRZzE1yfXPPI3YIYu+yvevUlSBjmSP4EHqyJekIKSs+Ri5kNSOz?= =?utf-8?q?zJCmq09bnkGGpBEHcmG8vsTIIDtL2I2uCRr++BcZ5H7Ts+g0/AqCOYxOcJv1Ran83?= =?utf-8?q?vrDm5W929mHvGOHvoOqLII0WrHv3/3fckJxi5lP/z9qeLFruq8XOXrnHF5LYfv+5N?= =?utf-8?q?KwaZaZms880nJo8NoG7OwFpbGPe9yvzNRap6EuolUqHoSVl1bvY5pl7rT4sPQZywx?= =?utf-8?q?bI8TrH6zGQZHENyXYIeDNkakJeX59Kiw5MW10na+aUpyHWx4Ca+HmrVousnyBK/4Q?= =?utf-8?q?7v9tpeJbR+0ZlYvTEU9yKON3qDP1/xCVMHHhTeBPZOrJthAzWUEwkU9mf1K1gOClu?= =?utf-8?q?BJJMQNhW+gTIk6UMl3sPe6++ymQbR+QwTy72RJy4tPwbekYdvxE31clxFK4Q7rp7q?= =?utf-8?q?J/5E9nOLtO/OVbI9pFDZpMuAXTFrFPIwcxJpaE/5iCqmn6Vk7ytL81ZH/tnX4LZOc?= =?utf-8?q?VhPb7q1WAmEMrlx94TqhgJjPXA5wEUW/PSo0gYYDJTnJCHgMZ/l0WfkcP+88w7wN4?= =?utf-8?q?QnPR82juf7ta0HPnLcOLKpHBeMWAjNg7yjXdjIwGI+C6HpkUDdiHHvetrTHACIaqa?= =?utf-8?q?4tEv9gwWOvgkoQy2LlxwO3Pqb+5bRWrXvDCT897Db3+U2B9/NEsBcz/nZOWtBU/K5?= =?utf-8?q?D15Vp4N28QAn1metD7c9yK9jZ2d5i+WxbJXT9TpzSRZcW/tw9ttxjPJ16gZ+9x5NQ?= =?utf-8?q?enR1xxAmPWljolWT04N0uVrEZ0EglfuDESebwZ2F+Yy1POpP0sKpXI4ksi+p7Sm92?= =?utf-8?q?KOaQNJxhgpw/FVo7MyF7BPgOiaSwUlK27w7E0GAxEUjTXIvNUI7PdyucdJOGd+Szm?= =?utf-8?q?l+4m+mFbTh7IJQv5I8jZn5ljce8rncjznoE/VxXBARXACXMG2Fo/Z8XeQ8UH3yptQ?= =?utf-8?q?XjPgJjf0+9LI+efDjk62XnCi4+be8oYVky7J5m67v8HsXorV3nqnj09l3OjPCmsiJ?= =?utf-8?q?sQ/FFK+GwrfCr8fWn+huOgW/uYkCtRje72ylNNTgfa7jCdy5BTiC0vbIjAoRydsYC?= =?utf-8?q?kw+VZituwwz1b2WmYNUgzV48esP36YH8nwvvbMc1SU7uhxyrXqVYNKOoL/GNZSpfw?= =?utf-8?q?OUfuNoFa4A5Yb3xbXUIwWvEFnDDMZQ6pKxN7MeVJblPo4QLoxbsvX+lMBu3+mvuAg?= =?utf-8?q?nHL6e4xYRjD4Nzy5kil2CzqhNl/WLNUZHvSg6sJl/RbA9/V3QrlOge80GH1XX4h3U?= =?utf-8?q?RVytAt8BLivgpQazEWNA4AfOJOZ+OdH6FEpFVWbqxhOzi7T9ZaRDlUISdoPkntu4M?= =?utf-8?q?55kcxpaqpt5r?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b29130a-6045-490a-0333-08db31120f9f X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 11:29:44.5688 (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: b6RAXunOvFEJ1ADpmT1zQtyEcfMmM/nrVVj6gZTD/UTr6yqpziGosHu1aWzKjV2SshWTk9XujG/jZ8z2WhJs/Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7262 The code has been identified as HVM-only, and its main functions are pretty well isolated. Move them to their own file. While moving, besides making two functions non-static, do a few style adjustments, mainly comment formatting, but leave the code otherwise untouched. Signed-off-by: Jan Beulich Acked-by: Andrew Cooper --- v2: Adjust SPDX to GPL-2.0-only. A few more style adjustments. --- a/xen/arch/x86/mm/shadow/Makefile +++ b/xen/arch/x86/mm/shadow/Makefile @@ -1,6 +1,6 @@ ifeq ($(CONFIG_SHADOW_PAGING),y) obj-y += common.o set.o -obj-$(CONFIG_HVM) += hvm.o guest_2.o guest_3.o guest_4.o +obj-$(CONFIG_HVM) += hvm.o guest_2.o guest_3.o guest_4.o oos.o obj-$(CONFIG_PV) += pv.o guest_4.o else obj-y += none.o --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -152,576 +152,6 @@ static int __init cf_check shadow_audit_ __initcall(shadow_audit_key_init); #endif /* SHADOW_AUDIT */ -#if (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC) -/**************************************************************************/ -/* Out-of-sync shadows. */ - -/* From time to time, we let a shadowed pagetable page go out of sync - * with its shadow: the guest is allowed to write directly to the page, - * and those writes are not synchronously reflected in the shadow. - * This lets us avoid many emulations if the guest is writing a lot to a - * pagetable, but it relaxes a pretty important invariant in the shadow - * pagetable design. Therefore, some rules: - * - * 1. Only L1 pagetables may go out of sync: any page that is shadowed - * at at higher level must be synchronously updated. This makes - * using linear shadow pagetables much less dangerous. - * That means that: (a) unsyncing code needs to check for higher-level - * shadows, and (b) promotion code needs to resync. - * - * 2. All shadow operations on a guest page require the page to be brought - * back into sync before proceeding. This must be done under the - * paging lock so that the page is guaranteed to remain synced until - * the operation completes. - * - * Exceptions to this rule: the pagefault and invlpg handlers may - * update only one entry on an out-of-sync page without resyncing it. - * - * 3. Operations on shadows that do not start from a guest page need to - * be aware that they may be handling an out-of-sync shadow. - * - * 4. Operations that do not normally take the paging lock (fast-path - * #PF handler, INVLPG) must fall back to a locking, syncing version - * if they see an out-of-sync table. - * - * 5. Operations corresponding to guest TLB flushes (MOV CR3, INVLPG) - * must explicitly resync all relevant pages or update their - * shadows. - * - * Currently out-of-sync pages are listed in a simple open-addressed - * hash table with a second chance (must resist temptation to radically - * over-engineer hash tables...) The virtual address of the access - * which caused us to unsync the page is also kept in the hash table, as - * a hint for finding the writable mappings later. - * - * We keep a hash per vcpu, because we want as much as possible to do - * the re-sync on the save vcpu we did the unsync on, so the VA hint - * will be valid. - */ - -static void sh_oos_audit(struct domain *d) -{ - unsigned int idx, expected_idx, expected_idx_alt; - struct page_info *pg; - struct vcpu *v; - - for_each_vcpu(d, v) - { - for ( idx = 0; idx < SHADOW_OOS_PAGES; idx++ ) - { - mfn_t *oos = v->arch.paging.shadow.oos; - if ( mfn_eq(oos[idx], INVALID_MFN) ) - continue; - - expected_idx = mfn_x(oos[idx]) % SHADOW_OOS_PAGES; - expected_idx_alt = ((expected_idx + 1) % SHADOW_OOS_PAGES); - if ( idx != expected_idx && idx != expected_idx_alt ) - { - printk("%s: idx %x contains gmfn %lx, expected at %x or %x.\n", - __func__, idx, mfn_x(oos[idx]), - expected_idx, expected_idx_alt); - BUG(); - } - pg = mfn_to_page(oos[idx]); - if ( !(pg->count_info & PGC_shadowed_pt) ) - { - printk("%s: idx %x gmfn %lx not a pt (count %lx)\n", - __func__, idx, mfn_x(oos[idx]), pg->count_info); - BUG(); - } - if ( !(pg->shadow_flags & SHF_out_of_sync) ) - { - printk("%s: idx %x gmfn %lx not marked oos (flags %x)\n", - __func__, idx, mfn_x(oos[idx]), pg->shadow_flags); - BUG(); - } - if ( (pg->shadow_flags & SHF_page_type_mask & ~SHF_L1_ANY) ) - { - printk("%s: idx %x gmfn %lx shadowed as non-l1 (flags %x)\n", - __func__, idx, mfn_x(oos[idx]), pg->shadow_flags); - BUG(); - } - } - } -} - -#if SHADOW_AUDIT & SHADOW_AUDIT_ENTRIES -void oos_audit_hash_is_present(struct domain *d, mfn_t gmfn) -{ - int idx; - struct vcpu *v; - mfn_t *oos; - - ASSERT(mfn_is_out_of_sync(gmfn)); - - for_each_vcpu(d, v) - { - oos = v->arch.paging.shadow.oos; - idx = mfn_x(gmfn) % SHADOW_OOS_PAGES; - if ( !mfn_eq(oos[idx], gmfn) ) - idx = (idx + 1) % SHADOW_OOS_PAGES; - - if ( mfn_eq(oos[idx], gmfn) ) - return; - } - - printk(XENLOG_ERR "gmfn %"PRI_mfn" marked OOS but not in hash table\n", - mfn_x(gmfn)); - BUG(); -} -#endif - -/* Update the shadow, but keep the page out of sync. */ -static inline void _sh_resync_l1(struct vcpu *v, mfn_t gmfn, mfn_t snpmfn) -{ - struct page_info *pg = mfn_to_page(gmfn); - - ASSERT(mfn_valid(gmfn)); - ASSERT(page_is_out_of_sync(pg)); - - /* Call out to the appropriate per-mode resyncing function */ - if ( pg->shadow_flags & SHF_L1_32 ) - SHADOW_INTERNAL_NAME(sh_resync_l1, 2)(v, gmfn, snpmfn); - else if ( pg->shadow_flags & SHF_L1_PAE ) - SHADOW_INTERNAL_NAME(sh_resync_l1, 3)(v, gmfn, snpmfn); - else if ( pg->shadow_flags & SHF_L1_64 ) - SHADOW_INTERNAL_NAME(sh_resync_l1, 4)(v, gmfn, snpmfn); -} - -static int sh_remove_write_access_from_sl1p(struct domain *d, mfn_t gmfn, - mfn_t smfn, unsigned long off) -{ - ASSERT(mfn_valid(smfn)); - ASSERT(mfn_valid(gmfn)); - - switch ( mfn_to_page(smfn)->u.sh.type ) - { - case SH_type_l1_32_shadow: - case SH_type_fl1_32_shadow: - return SHADOW_INTERNAL_NAME(sh_rm_write_access_from_sl1p, 2) - (d, gmfn, smfn, off); - - case SH_type_l1_pae_shadow: - case SH_type_fl1_pae_shadow: - return SHADOW_INTERNAL_NAME(sh_rm_write_access_from_sl1p, 3) - (d, gmfn, smfn, off); - - case SH_type_l1_64_shadow: - case SH_type_fl1_64_shadow: - return SHADOW_INTERNAL_NAME(sh_rm_write_access_from_sl1p, 4) - (d, gmfn, smfn, off); - - default: - return 0; - } -} - -/* - * Fixup arrays: We limit the maximum number of writable mappings to - * SHADOW_OOS_FIXUPS and store enough information to remove them - * quickly on resync. - */ - -static inline int oos_fixup_flush_gmfn(struct vcpu *v, mfn_t gmfn, - struct oos_fixup *fixup) -{ - struct domain *d = v->domain; - int i; - for ( i = 0; i < SHADOW_OOS_FIXUPS; i++ ) - { - if ( !mfn_eq(fixup->smfn[i], INVALID_MFN) ) - { - sh_remove_write_access_from_sl1p(d, gmfn, - fixup->smfn[i], - fixup->off[i]); - fixup->smfn[i] = INVALID_MFN; - } - } - - /* Always flush the TLBs. See comment on oos_fixup_add(). */ - return 1; -} - -void oos_fixup_add(struct domain *d, mfn_t gmfn, - mfn_t smfn, unsigned long off) -{ - int idx, next; - mfn_t *oos; - struct oos_fixup *oos_fixup; - struct vcpu *v; - - perfc_incr(shadow_oos_fixup_add); - - for_each_vcpu(d, v) - { - oos = v->arch.paging.shadow.oos; - oos_fixup = v->arch.paging.shadow.oos_fixup; - idx = mfn_x(gmfn) % SHADOW_OOS_PAGES; - if ( !mfn_eq(oos[idx], gmfn) ) - idx = (idx + 1) % SHADOW_OOS_PAGES; - if ( mfn_eq(oos[idx], gmfn) ) - { - int i; - for ( i = 0; i < SHADOW_OOS_FIXUPS; i++ ) - { - if ( mfn_eq(oos_fixup[idx].smfn[i], smfn) - && (oos_fixup[idx].off[i] == off) ) - return; - } - - next = oos_fixup[idx].next; - - if ( !mfn_eq(oos_fixup[idx].smfn[next], INVALID_MFN) ) - { - TRACE_SHADOW_PATH_FLAG(TRCE_SFLAG_OOS_FIXUP_EVICT); - - /* Reuse this slot and remove current writable mapping. */ - sh_remove_write_access_from_sl1p(d, gmfn, - oos_fixup[idx].smfn[next], - oos_fixup[idx].off[next]); - perfc_incr(shadow_oos_fixup_evict); - /* We should flush the TLBs now, because we removed a - writable mapping, but since the shadow is already - OOS we have no problem if another vcpu write to - this page table. We just have to be very careful to - *always* flush the tlbs on resync. */ - } - - oos_fixup[idx].smfn[next] = smfn; - oos_fixup[idx].off[next] = off; - oos_fixup[idx].next = (next + 1) % SHADOW_OOS_FIXUPS; - - TRACE_SHADOW_PATH_FLAG(TRCE_SFLAG_OOS_FIXUP_ADD); - return; - } - } - - printk(XENLOG_ERR "gmfn %"PRI_mfn" was OOS but not in hash table\n", - mfn_x(gmfn)); - BUG(); -} - -static int oos_remove_write_access(struct vcpu *v, mfn_t gmfn, - struct oos_fixup *fixup) -{ - struct domain *d = v->domain; - int ftlb = 0; - - ftlb |= oos_fixup_flush_gmfn(v, gmfn, fixup); - - switch ( sh_remove_write_access(d, gmfn, 0, 0) ) - { - default: - case 0: - break; - - case 1: - ftlb |= 1; - break; - - case -1: - /* An unfindable writeable typecount has appeared, probably via a - * grant table entry: can't shoot the mapping, so try to unshadow - * the page. If that doesn't work either, the guest is granting - * his pagetables and must be killed after all. - * This will flush the tlb, so we can return with no worries. */ - shadow_remove_all_shadows(d, gmfn); - return 1; - } - - if ( ftlb ) - guest_flush_tlb_mask(d, d->dirty_cpumask); - - return 0; -} - - -static inline void trace_resync(int event, mfn_t gmfn) -{ - if ( tb_init_done ) - { - /* Convert gmfn to gfn */ - gfn_t gfn = mfn_to_gfn(current->domain, gmfn); - - __trace_var(event, 0/*!tsc*/, sizeof(gfn), &gfn); - } -} - -/* Pull all the entries on an out-of-sync page back into sync. */ -static void _sh_resync(struct vcpu *v, mfn_t gmfn, - struct oos_fixup *fixup, mfn_t snp) -{ - struct page_info *pg = mfn_to_page(gmfn); - - ASSERT(paging_locked_by_me(v->domain)); - ASSERT(mfn_is_out_of_sync(gmfn)); - /* Guest page must be shadowed *only* as L1 when out of sync. */ - ASSERT(!(mfn_to_page(gmfn)->shadow_flags & SHF_page_type_mask - & ~SHF_L1_ANY)); - ASSERT(!sh_page_has_multiple_shadows(mfn_to_page(gmfn))); - - SHADOW_PRINTK("%pv gmfn=%"PRI_mfn"\n", v, mfn_x(gmfn)); - - /* Need to pull write access so the page *stays* in sync. */ - if ( oos_remove_write_access(v, gmfn, fixup) ) - { - /* Page has been unshadowed. */ - return; - } - - /* No more writable mappings of this page, please */ - pg->shadow_flags &= ~SHF_oos_may_write; - - /* Update the shadows with current guest entries. */ - _sh_resync_l1(v, gmfn, snp); - - /* Now we know all the entries are synced, and will stay that way */ - pg->shadow_flags &= ~SHF_out_of_sync; - perfc_incr(shadow_resync); - trace_resync(TRC_SHADOW_RESYNC_FULL, gmfn); -} - - -/* Add an MFN to the list of out-of-sync guest pagetables */ -static void oos_hash_add(struct vcpu *v, mfn_t gmfn) -{ - int i, idx, oidx, swap = 0; - mfn_t *oos = v->arch.paging.shadow.oos; - mfn_t *oos_snapshot = v->arch.paging.shadow.oos_snapshot; - struct oos_fixup *oos_fixup = v->arch.paging.shadow.oos_fixup; - struct oos_fixup fixup = { .next = 0 }; - - for (i = 0; i < SHADOW_OOS_FIXUPS; i++ ) - fixup.smfn[i] = INVALID_MFN; - - idx = mfn_x(gmfn) % SHADOW_OOS_PAGES; - oidx = idx; - - if ( !mfn_eq(oos[idx], INVALID_MFN) - && (mfn_x(oos[idx]) % SHADOW_OOS_PAGES) == idx ) - { - /* Punt the current occupant into the next slot */ - SWAP(oos[idx], gmfn); - SWAP(oos_fixup[idx], fixup); - swap = 1; - idx = (idx + 1) % SHADOW_OOS_PAGES; - } - if ( !mfn_eq(oos[idx], INVALID_MFN) ) - { - /* Crush the current occupant. */ - _sh_resync(v, oos[idx], &oos_fixup[idx], oos_snapshot[idx]); - perfc_incr(shadow_unsync_evict); - } - oos[idx] = gmfn; - oos_fixup[idx] = fixup; - - if ( swap ) - SWAP(oos_snapshot[idx], oos_snapshot[oidx]); - - copy_domain_page(oos_snapshot[oidx], oos[oidx]); -} - -/* Remove an MFN from the list of out-of-sync guest pagetables */ -static void oos_hash_remove(struct domain *d, mfn_t gmfn) -{ - int idx; - mfn_t *oos; - struct vcpu *v; - - SHADOW_PRINTK("d%d gmfn %lx\n", d->domain_id, mfn_x(gmfn)); - - for_each_vcpu(d, v) - { - oos = v->arch.paging.shadow.oos; - idx = mfn_x(gmfn) % SHADOW_OOS_PAGES; - if ( !mfn_eq(oos[idx], gmfn) ) - idx = (idx + 1) % SHADOW_OOS_PAGES; - if ( mfn_eq(oos[idx], gmfn) ) - { - oos[idx] = INVALID_MFN; - return; - } - } - - printk(XENLOG_ERR "gmfn %"PRI_mfn" was OOS but not in hash table\n", - mfn_x(gmfn)); - BUG(); -} - -mfn_t oos_snapshot_lookup(struct domain *d, mfn_t gmfn) -{ - int idx; - mfn_t *oos; - mfn_t *oos_snapshot; - struct vcpu *v; - - for_each_vcpu(d, v) - { - oos = v->arch.paging.shadow.oos; - oos_snapshot = v->arch.paging.shadow.oos_snapshot; - idx = mfn_x(gmfn) % SHADOW_OOS_PAGES; - if ( !mfn_eq(oos[idx], gmfn) ) - idx = (idx + 1) % SHADOW_OOS_PAGES; - if ( mfn_eq(oos[idx], gmfn) ) - { - return oos_snapshot[idx]; - } - } - - printk(XENLOG_ERR "gmfn %"PRI_mfn" was OOS but not in hash table\n", - mfn_x(gmfn)); - BUG(); -} - -/* Pull a single guest page back into sync */ -void sh_resync(struct domain *d, mfn_t gmfn) -{ - int idx; - mfn_t *oos; - mfn_t *oos_snapshot; - struct oos_fixup *oos_fixup; - struct vcpu *v; - - for_each_vcpu(d, v) - { - oos = v->arch.paging.shadow.oos; - oos_fixup = v->arch.paging.shadow.oos_fixup; - oos_snapshot = v->arch.paging.shadow.oos_snapshot; - idx = mfn_x(gmfn) % SHADOW_OOS_PAGES; - if ( !mfn_eq(oos[idx], gmfn) ) - idx = (idx + 1) % SHADOW_OOS_PAGES; - - if ( mfn_eq(oos[idx], gmfn) ) - { - _sh_resync(v, gmfn, &oos_fixup[idx], oos_snapshot[idx]); - oos[idx] = INVALID_MFN; - return; - } - } - - printk(XENLOG_ERR "gmfn %"PRI_mfn" was OOS but not in hash table\n", - mfn_x(gmfn)); - BUG(); -} - -/* Figure out whether it's definitely safe not to sync this l1 table, - * by making a call out to the mode in which that shadow was made. */ -static int sh_skip_sync(struct vcpu *v, mfn_t gl1mfn) -{ - struct page_info *pg = mfn_to_page(gl1mfn); - if ( pg->shadow_flags & SHF_L1_32 ) - return SHADOW_INTERNAL_NAME(sh_safe_not_to_sync, 2)(v, gl1mfn); - else if ( pg->shadow_flags & SHF_L1_PAE ) - return SHADOW_INTERNAL_NAME(sh_safe_not_to_sync, 3)(v, gl1mfn); - else if ( pg->shadow_flags & SHF_L1_64 ) - return SHADOW_INTERNAL_NAME(sh_safe_not_to_sync, 4)(v, gl1mfn); - printk(XENLOG_ERR "gmfn %"PRI_mfn" was OOS but not shadowed as an l1\n", - mfn_x(gl1mfn)); - BUG(); -} - - -/* Pull all out-of-sync pages back into sync. Pages brought out of sync - * on other vcpus are allowed to remain out of sync, but their contents - * will be made safe (TLB flush semantics); pages unsynced by this vcpu - * are brought back into sync and write-protected. If skip != 0, we try - * to avoid resyncing at all if we think we can get away with it. */ -void sh_resync_all(struct vcpu *v, int skip, int this, int others) -{ - int idx; - struct vcpu *other; - mfn_t *oos = v->arch.paging.shadow.oos; - mfn_t *oos_snapshot = v->arch.paging.shadow.oos_snapshot; - struct oos_fixup *oos_fixup = v->arch.paging.shadow.oos_fixup; - - SHADOW_PRINTK("%pv\n", v); - - ASSERT(paging_locked_by_me(v->domain)); - - if ( !this ) - goto resync_others; - - /* First: resync all of this vcpu's oos pages */ - for ( idx = 0; idx < SHADOW_OOS_PAGES; idx++ ) - if ( !mfn_eq(oos[idx], INVALID_MFN) ) - { - /* Write-protect and sync contents */ - _sh_resync(v, oos[idx], &oos_fixup[idx], oos_snapshot[idx]); - oos[idx] = INVALID_MFN; - } - - resync_others: - if ( !others ) - return; - - /* Second: make all *other* vcpus' oos pages safe. */ - for_each_vcpu(v->domain, other) - { - if ( v == other ) - continue; - - oos = other->arch.paging.shadow.oos; - oos_fixup = other->arch.paging.shadow.oos_fixup; - oos_snapshot = other->arch.paging.shadow.oos_snapshot; - - for ( idx = 0; idx < SHADOW_OOS_PAGES; idx++ ) - { - if ( mfn_eq(oos[idx], INVALID_MFN) ) - continue; - - if ( skip ) - { - /* Update the shadows and leave the page OOS. */ - if ( sh_skip_sync(v, oos[idx]) ) - continue; - trace_resync(TRC_SHADOW_RESYNC_ONLY, oos[idx]); - _sh_resync_l1(other, oos[idx], oos_snapshot[idx]); - } - else - { - /* Write-protect and sync contents */ - _sh_resync(other, oos[idx], &oos_fixup[idx], oos_snapshot[idx]); - oos[idx] = INVALID_MFN; - } - } - } -} - -/* Allow a shadowed page to go out of sync. Unsyncs are traced in - * multi.c:sh_page_fault() */ -int sh_unsync(struct vcpu *v, mfn_t gmfn) -{ - struct page_info *pg; - - ASSERT(paging_locked_by_me(v->domain)); - - SHADOW_PRINTK("%pv gmfn=%"PRI_mfn"\n", v, mfn_x(gmfn)); - - pg = mfn_to_page(gmfn); - - /* Guest page must be shadowed *only* as L1 and *only* once when out - * of sync. Also, get out now if it's already out of sync. - * Also, can't safely unsync if some vcpus have paging disabled.*/ - if ( pg->shadow_flags & - ((SHF_page_type_mask & ~SHF_L1_ANY) | SHF_out_of_sync) - || sh_page_has_multiple_shadows(pg) - || !is_hvm_vcpu(v) - || !v->domain->arch.paging.shadow.oos_active ) - return 0; - - BUILD_BUG_ON(!(typeof(pg->shadow_flags))SHF_out_of_sync); - BUILD_BUG_ON(!(typeof(pg->shadow_flags))SHF_oos_may_write); - - pg->shadow_flags |= SHF_out_of_sync|SHF_oos_may_write; - oos_hash_add(v, gmfn); - perfc_incr(shadow_unsync); - TRACE_SHADOW_PATH_FLAG(TRCE_SFLAG_UNSYNC); - return 1; -} - -#endif /* (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC) */ - - /**************************************************************************/ /* Code for "promoting" a guest page to the point where the shadow code is * willing to let it be treated as a guest page table. This generally --- /dev/null +++ b/xen/arch/x86/mm/shadow/oos.c @@ -0,0 +1,606 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/****************************************************************************** + * arch/x86/mm/shadow/oos.c + * + * Shadow code dealing with out-of-sync shadows. + * Parts of this code are Copyright (c) 2006 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. + */ + +#include "private.h" + +#if (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC) + +#include + +#include + +/* + * From time to time, we let a shadowed pagetable page go out of sync + * with its shadow: the guest is allowed to write directly to the page, + * and those writes are not synchronously reflected in the shadow. + * This lets us avoid many emulations if the guest is writing a lot to a + * pagetable, but it relaxes a pretty important invariant in the shadow + * pagetable design. Therefore, some rules: + * + * 1. Only L1 pagetables may go out of sync: any page that is shadowed + * at at higher level must be synchronously updated. This makes + * using linear shadow pagetables much less dangerous. + * That means that: (a) unsyncing code needs to check for higher-level + * shadows, and (b) promotion code needs to resync. + * + * 2. All shadow operations on a guest page require the page to be brought + * back into sync before proceeding. This must be done under the + * paging lock so that the page is guaranteed to remain synced until + * the operation completes. + * + * Exceptions to this rule: the pagefault and invlpg handlers may + * update only one entry on an out-of-sync page without resyncing it. + * + * 3. Operations on shadows that do not start from a guest page need to + * be aware that they may be handling an out-of-sync shadow. + * + * 4. Operations that do not normally take the paging lock (fast-path + * #PF handler, INVLPG) must fall back to a locking, syncing version + * if they see an out-of-sync table. + * + * 5. Operations corresponding to guest TLB flushes (MOV CR3, INVLPG) + * must explicitly resync all relevant pages or update their + * shadows. + * + * Currently out-of-sync pages are listed in a simple open-addressed + * hash table with a second chance (must resist temptation to radically + * over-engineer hash tables...) The virtual address of the access + * which caused us to unsync the page is also kept in the hash table, as + * a hint for finding the writable mappings later. + * + * We keep a hash per vcpu, because we want as much as possible to do + * the re-sync on the save vcpu we did the unsync on, so the VA hint + * will be valid. + */ + +#if SHADOW_AUDIT & SHADOW_AUDIT_ENTRIES_FULL +void sh_oos_audit(struct domain *d) +{ + unsigned int idx, expected_idx, expected_idx_alt; + struct page_info *pg; + struct vcpu *v; + + for_each_vcpu(d, v) + { + for ( idx = 0; idx < SHADOW_OOS_PAGES; idx++ ) + { + mfn_t *oos = v->arch.paging.shadow.oos; + + if ( mfn_eq(oos[idx], INVALID_MFN) ) + continue; + + expected_idx = mfn_x(oos[idx]) % SHADOW_OOS_PAGES; + expected_idx_alt = ((expected_idx + 1) % SHADOW_OOS_PAGES); + if ( idx != expected_idx && idx != expected_idx_alt ) + { + printk("%s: idx %x contains gmfn %lx, expected at %x or %x.\n", + __func__, idx, mfn_x(oos[idx]), + expected_idx, expected_idx_alt); + BUG(); + } + pg = mfn_to_page(oos[idx]); + if ( !(pg->count_info & PGC_shadowed_pt) ) + { + printk("%s: idx %x gmfn %lx not a pt (count %lx)\n", + __func__, idx, mfn_x(oos[idx]), pg->count_info); + BUG(); + } + if ( !(pg->shadow_flags & SHF_out_of_sync) ) + { + printk("%s: idx %x gmfn %lx not marked oos (flags %x)\n", + __func__, idx, mfn_x(oos[idx]), pg->shadow_flags); + BUG(); + } + if ( (pg->shadow_flags & SHF_page_type_mask & ~SHF_L1_ANY) ) + { + printk("%s: idx %x gmfn %lx shadowed as non-l1 (flags %x)\n", + __func__, idx, mfn_x(oos[idx]), pg->shadow_flags); + BUG(); + } + } + } +} +#endif + +#if SHADOW_AUDIT & SHADOW_AUDIT_ENTRIES +void oos_audit_hash_is_present(struct domain *d, mfn_t gmfn) +{ + int idx; + struct vcpu *v; + mfn_t *oos; + + ASSERT(mfn_is_out_of_sync(gmfn)); + + for_each_vcpu(d, v) + { + oos = v->arch.paging.shadow.oos; + idx = mfn_x(gmfn) % SHADOW_OOS_PAGES; + if ( !mfn_eq(oos[idx], gmfn) ) + idx = (idx + 1) % SHADOW_OOS_PAGES; + + if ( mfn_eq(oos[idx], gmfn) ) + return; + } + + printk(XENLOG_ERR "gmfn %"PRI_mfn" marked OOS but not in hash table\n", + mfn_x(gmfn)); + BUG(); +} +#endif + +/* Update the shadow, but keep the page out of sync. */ +static inline void _sh_resync_l1(struct vcpu *v, mfn_t gmfn, mfn_t snpmfn) +{ + struct page_info *pg = mfn_to_page(gmfn); + + ASSERT(mfn_valid(gmfn)); + ASSERT(page_is_out_of_sync(pg)); + + /* Call out to the appropriate per-mode resyncing function */ + if ( pg->shadow_flags & SHF_L1_32 ) + SHADOW_INTERNAL_NAME(sh_resync_l1, 2)(v, gmfn, snpmfn); + else if ( pg->shadow_flags & SHF_L1_PAE ) + SHADOW_INTERNAL_NAME(sh_resync_l1, 3)(v, gmfn, snpmfn); + else if ( pg->shadow_flags & SHF_L1_64 ) + SHADOW_INTERNAL_NAME(sh_resync_l1, 4)(v, gmfn, snpmfn); +} + +static int sh_remove_write_access_from_sl1p(struct domain *d, mfn_t gmfn, + mfn_t smfn, unsigned long off) +{ + ASSERT(mfn_valid(smfn)); + ASSERT(mfn_valid(gmfn)); + + switch ( mfn_to_page(smfn)->u.sh.type ) + { + case SH_type_l1_32_shadow: + case SH_type_fl1_32_shadow: + return SHADOW_INTERNAL_NAME(sh_rm_write_access_from_sl1p, 2) + (d, gmfn, smfn, off); + + case SH_type_l1_pae_shadow: + case SH_type_fl1_pae_shadow: + return SHADOW_INTERNAL_NAME(sh_rm_write_access_from_sl1p, 3) + (d, gmfn, smfn, off); + + case SH_type_l1_64_shadow: + case SH_type_fl1_64_shadow: + return SHADOW_INTERNAL_NAME(sh_rm_write_access_from_sl1p, 4) + (d, gmfn, smfn, off); + + default: + return 0; + } +} + +/* + * Fixup arrays: We limit the maximum number of writable mappings to + * SHADOW_OOS_FIXUPS and store enough information to remove them + * quickly on resync. + */ + +static inline int oos_fixup_flush_gmfn(struct vcpu *v, mfn_t gmfn, + struct oos_fixup *fixup) +{ + struct domain *d = v->domain; + int i; + for ( i = 0; i < SHADOW_OOS_FIXUPS; i++ ) + { + if ( !mfn_eq(fixup->smfn[i], INVALID_MFN) ) + { + sh_remove_write_access_from_sl1p(d, gmfn, + fixup->smfn[i], + fixup->off[i]); + fixup->smfn[i] = INVALID_MFN; + } + } + + /* Always flush the TLBs. See comment on oos_fixup_add(). */ + return 1; +} + +void oos_fixup_add(struct domain *d, mfn_t gmfn, + mfn_t smfn, unsigned long off) +{ + int idx, next; + mfn_t *oos; + struct oos_fixup *oos_fixup; + struct vcpu *v; + + perfc_incr(shadow_oos_fixup_add); + + for_each_vcpu(d, v) + { + oos = v->arch.paging.shadow.oos; + oos_fixup = v->arch.paging.shadow.oos_fixup; + idx = mfn_x(gmfn) % SHADOW_OOS_PAGES; + if ( !mfn_eq(oos[idx], gmfn) ) + idx = (idx + 1) % SHADOW_OOS_PAGES; + if ( mfn_eq(oos[idx], gmfn) ) + { + int i; + for ( i = 0; i < SHADOW_OOS_FIXUPS; i++ ) + { + if ( mfn_eq(oos_fixup[idx].smfn[i], smfn) && + (oos_fixup[idx].off[i] == off) ) + return; + } + + next = oos_fixup[idx].next; + + if ( !mfn_eq(oos_fixup[idx].smfn[next], INVALID_MFN) ) + { + TRACE_SHADOW_PATH_FLAG(TRCE_SFLAG_OOS_FIXUP_EVICT); + + /* Reuse this slot and remove current writable mapping. */ + sh_remove_write_access_from_sl1p(d, gmfn, + oos_fixup[idx].smfn[next], + oos_fixup[idx].off[next]); + perfc_incr(shadow_oos_fixup_evict); + /* + * We should flush the TLBs now, because we removed a + * writable mapping, but since the shadow is already + * OOS we have no problem if another vcpu write to + * this page table. We just have to be very careful to + * *always* flush the tlbs on resync. + */ + } + + oos_fixup[idx].smfn[next] = smfn; + oos_fixup[idx].off[next] = off; + oos_fixup[idx].next = (next + 1) % SHADOW_OOS_FIXUPS; + + TRACE_SHADOW_PATH_FLAG(TRCE_SFLAG_OOS_FIXUP_ADD); + return; + } + } + + printk(XENLOG_ERR "gmfn %"PRI_mfn" was OOS but not in hash table\n", + mfn_x(gmfn)); + BUG(); +} + +static int oos_remove_write_access(struct vcpu *v, mfn_t gmfn, + struct oos_fixup *fixup) +{ + struct domain *d = v->domain; + int ftlb = 0; + + ftlb |= oos_fixup_flush_gmfn(v, gmfn, fixup); + + switch ( sh_remove_write_access(d, gmfn, 0, 0) ) + { + default: + case 0: + break; + + case 1: + ftlb |= 1; + break; + + case -1: + /* + * An unfindable writeable typecount has appeared, probably via a + * grant table entry: can't shoot the mapping, so try to unshadow + * the page. If that doesn't work either, the guest is granting + * his pagetables and must be killed after all. + * This will flush the tlb, so we can return with no worries. + */ + shadow_remove_all_shadows(d, gmfn); + return 1; + } + + if ( ftlb ) + guest_flush_tlb_mask(d, d->dirty_cpumask); + + return 0; +} + +static inline void trace_resync(int event, mfn_t gmfn) +{ + if ( tb_init_done ) + { + /* Convert gmfn to gfn */ + gfn_t gfn = mfn_to_gfn(current->domain, gmfn); + + __trace_var(event, 0/*!tsc*/, sizeof(gfn), &gfn); + } +} + +/* Pull all the entries on an out-of-sync page back into sync. */ +static void _sh_resync(struct vcpu *v, mfn_t gmfn, + struct oos_fixup *fixup, mfn_t snp) +{ + struct page_info *pg = mfn_to_page(gmfn); + + ASSERT(paging_locked_by_me(v->domain)); + ASSERT(mfn_is_out_of_sync(gmfn)); + /* Guest page must be shadowed *only* as L1 when out of sync. */ + ASSERT(!(mfn_to_page(gmfn)->shadow_flags & SHF_page_type_mask + & ~SHF_L1_ANY)); + ASSERT(!sh_page_has_multiple_shadows(mfn_to_page(gmfn))); + + SHADOW_PRINTK("%pv gmfn=%"PRI_mfn"\n", v, mfn_x(gmfn)); + + /* Need to pull write access so the page *stays* in sync. */ + if ( oos_remove_write_access(v, gmfn, fixup) ) + { + /* Page has been unshadowed. */ + return; + } + + /* No more writable mappings of this page, please */ + pg->shadow_flags &= ~SHF_oos_may_write; + + /* Update the shadows with current guest entries. */ + _sh_resync_l1(v, gmfn, snp); + + /* Now we know all the entries are synced, and will stay that way */ + pg->shadow_flags &= ~SHF_out_of_sync; + perfc_incr(shadow_resync); + trace_resync(TRC_SHADOW_RESYNC_FULL, gmfn); +} + +/* Add an MFN to the list of out-of-sync guest pagetables */ +static void oos_hash_add(struct vcpu *v, mfn_t gmfn) +{ + int i, idx, oidx, swap = 0; + mfn_t *oos = v->arch.paging.shadow.oos; + mfn_t *oos_snapshot = v->arch.paging.shadow.oos_snapshot; + struct oos_fixup *oos_fixup = v->arch.paging.shadow.oos_fixup; + struct oos_fixup fixup = { .next = 0 }; + + for ( i = 0; i < SHADOW_OOS_FIXUPS; i++ ) + fixup.smfn[i] = INVALID_MFN; + + idx = mfn_x(gmfn) % SHADOW_OOS_PAGES; + oidx = idx; + + if ( !mfn_eq(oos[idx], INVALID_MFN) && + (mfn_x(oos[idx]) % SHADOW_OOS_PAGES) == idx ) + { + /* Punt the current occupant into the next slot */ + SWAP(oos[idx], gmfn); + SWAP(oos_fixup[idx], fixup); + swap = 1; + idx = (idx + 1) % SHADOW_OOS_PAGES; + } + if ( !mfn_eq(oos[idx], INVALID_MFN) ) + { + /* Crush the current occupant. */ + _sh_resync(v, oos[idx], &oos_fixup[idx], oos_snapshot[idx]); + perfc_incr(shadow_unsync_evict); + } + oos[idx] = gmfn; + oos_fixup[idx] = fixup; + + if ( swap ) + SWAP(oos_snapshot[idx], oos_snapshot[oidx]); + + copy_domain_page(oos_snapshot[oidx], oos[oidx]); +} + +/* Remove an MFN from the list of out-of-sync guest pagetables */ +void oos_hash_remove(struct domain *d, mfn_t gmfn) +{ + int idx; + mfn_t *oos; + struct vcpu *v; + + SHADOW_PRINTK("d%d gmfn %lx\n", d->domain_id, mfn_x(gmfn)); + + for_each_vcpu(d, v) + { + oos = v->arch.paging.shadow.oos; + idx = mfn_x(gmfn) % SHADOW_OOS_PAGES; + if ( !mfn_eq(oos[idx], gmfn) ) + idx = (idx + 1) % SHADOW_OOS_PAGES; + if ( mfn_eq(oos[idx], gmfn) ) + { + oos[idx] = INVALID_MFN; + return; + } + } + + printk(XENLOG_ERR "gmfn %"PRI_mfn" was OOS but not in hash table\n", + mfn_x(gmfn)); + BUG(); +} + +mfn_t oos_snapshot_lookup(struct domain *d, mfn_t gmfn) +{ + int idx; + mfn_t *oos; + mfn_t *oos_snapshot; + struct vcpu *v; + + for_each_vcpu(d, v) + { + oos = v->arch.paging.shadow.oos; + oos_snapshot = v->arch.paging.shadow.oos_snapshot; + idx = mfn_x(gmfn) % SHADOW_OOS_PAGES; + if ( !mfn_eq(oos[idx], gmfn) ) + idx = (idx + 1) % SHADOW_OOS_PAGES; + if ( mfn_eq(oos[idx], gmfn) ) + { + return oos_snapshot[idx]; + } + } + + printk(XENLOG_ERR "gmfn %"PRI_mfn" was OOS but not in hash table\n", + mfn_x(gmfn)); + BUG(); +} + +/* Pull a single guest page back into sync */ +void sh_resync(struct domain *d, mfn_t gmfn) +{ + int idx; + mfn_t *oos; + mfn_t *oos_snapshot; + struct oos_fixup *oos_fixup; + struct vcpu *v; + + for_each_vcpu(d, v) + { + oos = v->arch.paging.shadow.oos; + oos_fixup = v->arch.paging.shadow.oos_fixup; + oos_snapshot = v->arch.paging.shadow.oos_snapshot; + idx = mfn_x(gmfn) % SHADOW_OOS_PAGES; + if ( !mfn_eq(oos[idx], gmfn) ) + idx = (idx + 1) % SHADOW_OOS_PAGES; + + if ( mfn_eq(oos[idx], gmfn) ) + { + _sh_resync(v, gmfn, &oos_fixup[idx], oos_snapshot[idx]); + oos[idx] = INVALID_MFN; + return; + } + } + + printk(XENLOG_ERR "gmfn %"PRI_mfn" was OOS but not in hash table\n", + mfn_x(gmfn)); + BUG(); +} + +/* + * Figure out whether it's definitely safe not to sync this l1 table, + * by making a call out to the mode in which that shadow was made. + */ +static int sh_skip_sync(struct vcpu *v, mfn_t gl1mfn) +{ + struct page_info *pg = mfn_to_page(gl1mfn); + + if ( pg->shadow_flags & SHF_L1_32 ) + return SHADOW_INTERNAL_NAME(sh_safe_not_to_sync, 2)(v, gl1mfn); + else if ( pg->shadow_flags & SHF_L1_PAE ) + return SHADOW_INTERNAL_NAME(sh_safe_not_to_sync, 3)(v, gl1mfn); + else if ( pg->shadow_flags & SHF_L1_64 ) + return SHADOW_INTERNAL_NAME(sh_safe_not_to_sync, 4)(v, gl1mfn); + + printk(XENLOG_ERR "gmfn %"PRI_mfn" was OOS but not shadowed as an l1\n", + mfn_x(gl1mfn)); + BUG(); +} + +/* + * Pull all out-of-sync pages back into sync. Pages brought out of sync + * on other vcpus are allowed to remain out of sync, but their contents + * will be made safe (TLB flush semantics); pages unsynced by this vcpu + * are brought back into sync and write-protected. If skip != 0, we try + * to avoid resyncing at all if we think we can get away with it. + */ +void sh_resync_all(struct vcpu *v, int skip, int this, int others) +{ + int idx; + struct vcpu *other; + mfn_t *oos = v->arch.paging.shadow.oos; + mfn_t *oos_snapshot = v->arch.paging.shadow.oos_snapshot; + struct oos_fixup *oos_fixup = v->arch.paging.shadow.oos_fixup; + + SHADOW_PRINTK("%pv\n", v); + + ASSERT(paging_locked_by_me(v->domain)); + + if ( !this ) + goto resync_others; + + /* First: resync all of this vcpu's oos pages */ + for ( idx = 0; idx < SHADOW_OOS_PAGES; idx++ ) + if ( !mfn_eq(oos[idx], INVALID_MFN) ) + { + /* Write-protect and sync contents */ + _sh_resync(v, oos[idx], &oos_fixup[idx], oos_snapshot[idx]); + oos[idx] = INVALID_MFN; + } + + resync_others: + if ( !others ) + return; + + /* Second: make all *other* vcpus' oos pages safe. */ + for_each_vcpu(v->domain, other) + { + if ( v == other ) + continue; + + oos = other->arch.paging.shadow.oos; + oos_fixup = other->arch.paging.shadow.oos_fixup; + oos_snapshot = other->arch.paging.shadow.oos_snapshot; + + for ( idx = 0; idx < SHADOW_OOS_PAGES; idx++ ) + { + if ( mfn_eq(oos[idx], INVALID_MFN) ) + continue; + + if ( skip ) + { + /* Update the shadows and leave the page OOS. */ + if ( sh_skip_sync(v, oos[idx]) ) + continue; + trace_resync(TRC_SHADOW_RESYNC_ONLY, oos[idx]); + _sh_resync_l1(other, oos[idx], oos_snapshot[idx]); + } + else + { + /* Write-protect and sync contents */ + _sh_resync(other, oos[idx], &oos_fixup[idx], oos_snapshot[idx]); + oos[idx] = INVALID_MFN; + } + } + } +} + +/* + * Allow a shadowed page to go out of sync. Unsyncs are traced in + * multi.c:sh_page_fault() + */ +int sh_unsync(struct vcpu *v, mfn_t gmfn) +{ + struct page_info *pg; + + ASSERT(paging_locked_by_me(v->domain)); + + SHADOW_PRINTK("%pv gmfn=%"PRI_mfn"\n", v, mfn_x(gmfn)); + + pg = mfn_to_page(gmfn); + + /* + * Guest page must be shadowed *only* as L1 and *only* once when out + * of sync. Also, get out now if it's already out of sync. + * Also, can't safely unsync if some vcpus have paging disabled. + */ + if ( (pg->shadow_flags & + ((SHF_page_type_mask & ~SHF_L1_ANY) | SHF_out_of_sync)) || + sh_page_has_multiple_shadows(pg) || + !is_hvm_vcpu(v) || + !v->domain->arch.paging.shadow.oos_active ) + return 0; + + BUILD_BUG_ON(!(typeof(pg->shadow_flags))SHF_out_of_sync); + BUILD_BUG_ON(!(typeof(pg->shadow_flags))SHF_oos_may_write); + + pg->shadow_flags |= SHF_out_of_sync|SHF_oos_may_write; + oos_hash_add(v, gmfn); + perfc_incr(shadow_unsync); + TRACE_SHADOW_PATH_FLAG(TRCE_SFLAG_UNSYNC); + return 1; +} + +#endif /* (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC) */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ --- a/xen/arch/x86/mm/shadow/private.h +++ b/xen/arch/x86/mm/shadow/private.h @@ -452,6 +452,7 @@ int sh_unsync(struct vcpu *v, mfn_t gmfn /* Pull an out-of-sync page back into sync. */ void sh_resync(struct domain *d, mfn_t gmfn); +void oos_hash_remove(struct domain *d, mfn_t gmfn); void oos_fixup_add(struct domain *d, mfn_t gmfn, mfn_t smfn, unsigned long off); /* Pull all out-of-sync shadows back into sync. If skip != 0, we try @@ -477,6 +478,7 @@ shadow_sync_other_vcpus(struct vcpu *v) sh_resync_all(v, 1 /* skip */, 0 /* this */, 1 /* others */); } +void sh_oos_audit(struct domain *d); void oos_audit_hash_is_present(struct domain *d, mfn_t gmfn); mfn_t oos_snapshot_lookup(struct domain *d, mfn_t gmfn); From patchwork Thu Mar 30 11:30:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13193988 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 AB68CC761A6 for ; Thu, 30 Mar 2023 11:30:26 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.516644.801103 (Exim 4.92) (envelope-from ) id 1phqTt-0002RV-Qa; Thu, 30 Mar 2023 11:30:13 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 516644.801103; Thu, 30 Mar 2023 11:30:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1phqTt-0002RN-Mz; Thu, 30 Mar 2023 11:30:13 +0000 Received: by outflank-mailman (input) for mailman id 516644; Thu, 30 Mar 2023 11:30:12 +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 1phqTr-00017i-Ro for xen-devel@lists.xenproject.org; Thu, 30 Mar 2023 11:30:11 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0615.outbound.protection.outlook.com [2a01:111:f400:fe02::615]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3a683b9f-ceee-11ed-b464-930f4c7d94ae; Thu, 30 Mar 2023 13:30:10 +0200 (CEST) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by VE1PR04MB7262.eurprd04.prod.outlook.com (2603:10a6:800:1ab::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.22; Thu, 30 Mar 2023 11:30:08 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b%6]) with mapi id 15.20.6222.033; Thu, 30 Mar 2023 11:30:08 +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: 3a683b9f-ceee-11ed-b464-930f4c7d94ae ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kZg0rSseGpV+uzGMN3CDD6fzLffFmJQacHnt3j6X5kZmjcacOTKDYIwtz0iSsGmecLRnjW2U2UV/WNPwomnRE2VD7xZXfp0y18ao0tigI+DUgVKlQLfVWa6ZhJO/k/R8tSF51Fw3xWAh8cEHBW/DRXptN4VDG53HXp4DY7R1s6l3ISXXoH+2BA3BVvp+SZAPsCyFKW7H2ZMwRLG4PoGrf6s5hX1/jZ8wVqTU+RSM68snYriEvZzPxYoKGpiYSRhmbymHu2jrofJILIFs/+VqH0/CfeCKYM8jZaSbnmDFLKS/Fh5lclbP+eaRy2Hx2GlYDQu2Zc9fIKDuYPG28NJZ0w== 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=/nCRqVSKvE7qJC49XJOcofUh4xS4zVFI7oAhMmha4Gk=; b=gBKO7HrQfPQ1p4JYHO5L+RwKoialoaGihzmoYjE0OijJM51XrhQXMgh8qVdNJAqCpf4U9eOerzqWhUsgFzx1uO5UBkCvKRSEQemb9j3qZpAeu0OyvQq3gYcutlAEWkRFM2bfebDYacXYh9+ii2OZ3jU+btqLkYxkxmBGCkexEV1bHb1VLoTk4EmxL1hxrVwtr+TqBzG1Tu0o8wE1D2Pj0Qxu9HYRZQCnli5JKa4Tb5fKLAggkgbqZkU7CzL7bXE8nxUmtISsFmegbtuvx1lVZqyVlAi1uG2p+8skDAVtMojw8D24YUmpXR4ZApnIeIcGr6Uw8ylyOA7G+rBxMZVAgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/nCRqVSKvE7qJC49XJOcofUh4xS4zVFI7oAhMmha4Gk=; b=AsZrtxFlawKcFYr6M3F7gfKCIqdlDG4+CcaCwREo2YZ4zmUpLom7ZY74V2ZnEo1JFGt4DKEfhHzbjeDZIkIaMrWEtaRcYGxUlniq3vGoYfcvQIZn9WaLlALSUZBj5Ev7IJteP6i1LxYir3xgzuJRkU7XayzZiD73XtLBjHO6h7O6OdGARmTZ1wdWq+LQUMi0XnUFUNPwkQpzHG4CIJT61wAncKT3OsQEPx39qeSliqAqiUl458e1Dk1QsBYFjpdcCziOEBFJG8P8ZJHchJqlrD80FtMu8MUp3TJTuszG7XdCE08nm4NMFElOyVxKZhvJceRIsrNiGIojdNVTXvN5ug== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <66c0efb0-43d4-9e8d-4429-1f2732d2fe38@suse.com> Date: Thu, 30 Mar 2023 13:30:07 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: [PATCH v2 08/13] x86/shadow: sh_rm_write_access_from_sl1p() 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 , Tim Deegan References: In-Reply-To: X-ClientProxiedBy: FR2P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:99::6) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|VE1PR04MB7262:EE_ X-MS-Office365-Filtering-Correlation-Id: 5ae4d77c-384e-43e2-a875-08db31121df1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uIStktsr9a8Mz2F4tWJ9KB+kdMaBOITVxPp8pMlZPamUt5M6J5G0YlDJwkzP9f8hF1rlSHQ+HS0lyWn/brRyCJ/v/xR++tlknSyPoVvHBPbwljx+dXup4YczSnRBxNl4tuWBLn/ifAm1MFaC4cAdkYYQkE7Oj7jsm7virMYgFSKUsdMctXfOiTR5A3WS/H2J2RItzsTxkweeAhL//iXgIJsfEc+icb7VOqew4yfU+SCIpN99Qpkem3h/KHYH2MIVV8faS2jA5cko6OH6duYuvKm2Dm1o316jIKs42+bAMj+AzwQYs/NifUgLqyG8fv58aa2Njo4nQ+wctBJCNhmpi9ffxdRRii3xbxiBSx5BfjAxf4ZVu6qPGU8f0XitfaBwISfJM35isJW6ASkWY8aQ7JZ/ce5YPpocH2x1Jgl1zxZg4OgOJpQFzqmUjHMWqhpFb5WeE1qlFWJ/6Iaz1fc+rHoY1kVN6atoJsXhkm88jWeyv6VCFweLzg98xd1MBTNimdEuKXJDxI1lV4jq+zIkOl+akbEdENOj4xBMrAttlLnZKkBp/sjp5HwDSJt0tQQDgfUK5fBw7/G6lebJ2HSc6w/M114GlU925z0q/I/dH8drUqiIeliIhvekLFgfvjrx/J9wjrgP0e/hyMszEhVl4Crk39Tylt4CVUaEI0izpcdG/n4Du47QgQdBI0kdHRaW X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(366004)(396003)(136003)(376002)(39850400004)(451199021)(2616005)(83380400001)(6486002)(26005)(478600001)(316002)(186003)(54906003)(6506007)(2906002)(6512007)(36756003)(5660300002)(8936002)(38100700002)(4326008)(6916009)(66556008)(8676002)(66946007)(31696002)(66476007)(41300700001)(86362001)(31686004)(45980500001)(43740500002)(357404004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?N/i3pNw/DiKCVEH02LvyFI9321y4?= =?utf-8?q?e4EjDVg2CwN6xGXanjShGLq1AWXyEDNWoL4w1vHaT47PU7z0c5oKxHrcwr2bVpFN4?= =?utf-8?q?B7mt3hwXXVNEPXEDnPUobDvv0ZkmrBRsJwE8bqrmz0zjxp4HvsyZzTfcRlOX7FbIO?= =?utf-8?q?aua53FTGMc4GCjqi4p+TNygG/RFPsB8sK/+8evA3x8x/V5rbB2ECTVBqGbDlQcrKv?= =?utf-8?q?g8Hsri7JLAf42wezqN8C6coIX4jWKpc21kPuuVkTGRjLM4geYbimL1rUK6ascX4CQ?= =?utf-8?q?IkddDZLxSMjDPx6cdlqbf2jQ1gfosjS0QwYvYh1MNyTXxDJ2JJg1yEw/GbfLXltsX?= =?utf-8?q?/X6+OTjA0d/tpVGfjS4Tmrk/uJ1ia+m1jWRV/wyBwn8KHemwMI/q2EAoRnbpxdrfG?= =?utf-8?q?DKO+BAyYu88P+yKXSeYjo9PLxCCMXMhLJAb0sCj843bdoeF6dRcqLE1cvWiIuuivO?= =?utf-8?q?3sHbu6+RVEurlQR5Jy7spM4DDZIf4ZtdAfZ//8XQ16VNX4l7VzxZxZ6NjSmVVSiJi?= =?utf-8?q?BelV0VP4a7fN4esQa5Q/A++QqyEAuQyBSziX+pJEjoyRLbkgVJ4d4IFt4Jl66+XoB?= =?utf-8?q?QW8hQ0Eazx3GAUENVwPId1TiiewsIU3268LC5TjDQiQe25ej/NmNzSwxRNBtFp+rY?= =?utf-8?q?lPEbMPXyiMEXbdpoGd9aTqeiz/wgBF50el4UwiTfVLQZWnbXyfxOs7O7okd0Ux/US?= =?utf-8?q?7+OueCrHXzTTjUtAK88FWILjc1qxAsAkPa1rnesPGRChd5sRo61Sw7nBbsp3M9xB7?= =?utf-8?q?cJNKQyAC9yXiwRtJobCij9uoK12qpQ2Eaknwna8dSLF6h8dZNIJnRQO/pAuBLKm19?= =?utf-8?q?tBJ0+iqYHn9PIPA1ajjNTuhI4hnKmliejVIaKawEum8BzWZE+Pct31ZQxc+wWPksa?= =?utf-8?q?/37pJI1jMUdcV5EOTlns+G43OGYHrIyeqRFBXnpfBO9HXZ+ToyKI1uU6aiPqlLmQ6?= =?utf-8?q?D+Xxfj5TfbMXJ/imccw3H8UaxA7Zv44NhqXSLTnYcheWjkKYv0WcnRSVtbVLecDrY?= =?utf-8?q?PLyap1OQVigJ6cwK57sjsGx0WuHoTiPluvrHAtJGLdNv9bYN05LDln/X9/3Dph+8Y?= =?utf-8?q?KVnPPVG/mwVL+YxtZUdc0p7+SbfFZIxetMz2mbbAsqmUR4BWiBaHZNyJ9mnLgpWix?= =?utf-8?q?YDK8KwN4cJDfTlnuJZAhr5c/Md/IzrHjANvpcZX+N/WpFIXD3G7d1eAbUY8sbB5GF?= =?utf-8?q?mA7bmQ7a+VK7DiYO3n0y83OgMxIbGRqlcgy9ygtaA1wKCPhL1EtxJQ6JM+bAThqDq?= =?utf-8?q?li7/bJDhzA8WN9y0EqcsvEU+CRtkQJ7B4YXuq8746ELqtpXzMuDYYQEZwdliIcePH?= =?utf-8?q?JVZlWCIj2QaniuAa9uJTggI0aNjbFKJb+YDPBJTZa71CFXFmv856SZWMJjJSeAyQr?= =?utf-8?q?s3iurdno5luxRKw0GRvTZOlnnuW9eYvGLuGk1FIn0Ir1tVKh5tqXRTY6NPpbdcBxM?= =?utf-8?q?ysU6rfcA5oqrf2X4g9FN5p+nrKZN1/T8kBXURtr0KpHm31Hb5Wem3ViN2mJCfT1ZF?= =?utf-8?q?z6xnSbSWGYUX?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5ae4d77c-384e-43e2-a875-08db31121df1 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 11:30:08.6150 (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: R/Wgysh6oGrNNa+Ugu85SAHMhmby4TqCDZlSd5NgHAJJoTt1TKIUU84V+EK72KKBimwQKvtvsT8zqfAtLM/fkA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7262 The function is used from (HVM-only) OOS code only - replace the respective #ifdef inside the function to make this more obvious. (Note that SHOPT_OUT_OF_SYNC won't be set when !HVM, so the #ifdef surrounding the function is already sufficient.) Requested-by: Andrew Cooper Signed-off-by: Jan Beulich --- v2: New. --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -3429,9 +3429,7 @@ static void cf_check sh_update_cr3(struc int sh_rm_write_access_from_sl1p(struct domain *d, mfn_t gmfn, mfn_t smfn, unsigned long off) { -#ifdef CONFIG_HVM struct vcpu *curr = current; -#endif int r; shadow_l1e_t *sl1p, sl1e; struct page_info *sp; @@ -3439,12 +3437,10 @@ int sh_rm_write_access_from_sl1p(struct ASSERT(mfn_valid(gmfn)); ASSERT(mfn_valid(smfn)); -#ifdef CONFIG_HVM /* Remember if we've been told that this process is being torn down */ if ( curr->domain == d && is_hvm_domain(d) ) curr->arch.paging.shadow.pagetable_dying = mfn_to_page(gmfn)->pagetable_dying; -#endif sp = mfn_to_page(smfn); From patchwork Thu Mar 30 11:30:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13193989 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 F2A02C761A6 for ; Thu, 30 Mar 2023 11:30:48 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.516648.801113 (Exim 4.92) (envelope-from ) id 1phqUH-00031x-5Z; Thu, 30 Mar 2023 11:30:37 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 516648.801113; Thu, 30 Mar 2023 11:30:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1phqUH-00031q-0A; Thu, 30 Mar 2023 11:30:37 +0000 Received: by outflank-mailman (input) for mailman id 516648; Thu, 30 Mar 2023 11:30:35 +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 1phqUF-00017i-KE for xen-devel@lists.xenproject.org; Thu, 30 Mar 2023 11:30:35 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on062d.outbound.protection.outlook.com [2a01:111:f400:fe02::62d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 488a6625-ceee-11ed-b464-930f4c7d94ae; Thu, 30 Mar 2023 13:30:33 +0200 (CEST) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by VE1PR04MB7262.eurprd04.prod.outlook.com (2603:10a6:800:1ab::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.22; Thu, 30 Mar 2023 11:30:32 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b%6]) with mapi id 15.20.6222.033; Thu, 30 Mar 2023 11:30: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: 488a6625-ceee-11ed-b464-930f4c7d94ae ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WdTjPLQ4EeBnw9fzPy29IBboxuebftSZyWXu3FIOCX34cqzRxjYT/htLlj8cJlZo+Vvj+C+rg8GmqKsuXt0bL1b8FJsMwX52fJEJjJ6YOmS1Zyf5V745TIOpuTWsWQTSyAyPK2MWAew62vzaaJVqCFIhF/d4tUbfSn4S6wtSp2+qQGD+hKd0YY46vFM8Zrl+dFROGTXcqrjXAneQECaRPTSo4J5IuUtRWmknS5u87MrWsujiOFkWMEh48qa2036GTatTBea9Yu5rC99dQXhqSgiOjuYwmvzsYNEozu0GLsfFYNVuXyjRZRFrz9BYeozImCGGC/9DPsJgDNCjQRZZOw== 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=Pj7jaA7EDF02LqGniZpgC5UCF349tOE3CFBTSklxv5k=; b=mmf1gXxV6ed+FBzw1c8/cWpNrXgzlwCvJrktK71sc1sC+4Y59hKLoclfiq+5ddQ2rJrmmN9RDWqEOMT8DyIf07f1vwqKpZViv1mf/3tsZlSxp0OB7L1Vr4glkLvVdDiocQvSCefm9PMEUo8J1dUbH7eWjIaJLfRW2nwQq1UF40VgDifCo3zWcGz4ddGPRfJbbfixqtSDXfUAa2qY3xFVIkes7z9G6Kwh0UM4bhf+curl9rgGZ9v5OB0VoBrAjOB4EWYAvD8NZVipbHkTMm5anrj07DDCGOQ8fk1o7tbhny/XILbm3vgnC8zMr7I7hpXxLvIlvuf0TyiaqhJUoNAo6A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Pj7jaA7EDF02LqGniZpgC5UCF349tOE3CFBTSklxv5k=; b=TDrfGO65qWlDdV/Zs9jH6WmcH/wg1zP4l+r8yKqD0XUmJwCmBu9O2LZMdv9JC2J2VZ5dp8NpjXThd5/sXmquIU3mEu+tx5Juu3uaEpKcK3RvjUEEwmUNWFq1+Qq0JQD8ON29uMDZNKilCiEgwFGdeUynNsOAX3fRQvJu0fsdd7VS2ivFsmEROI9iJcWfSpWGwH/yFCsnNvrBt26eTxmcUcXhLzcRjy122MdS3na+x1rQcdQLw2rTfsARvB2sdgwEZ/kmNpGRAk55SWzo+2GJ2FmSQPh7Udwqyo6vt4c12+rg8dvGaexfdI/bgrHBDotFPHuQmGyK34XtQ5fkZGJbLA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Thu, 30 Mar 2023 13:30:31 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: [PATCH v2 09/13] x86/shadow: drop is_hvm_...() where easily possible Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Tim Deegan References: In-Reply-To: X-ClientProxiedBy: FR2P281CA0127.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9e::15) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|VE1PR04MB7262:EE_ X-MS-Office365-Filtering-Correlation-Id: 09095ce4-d362-463f-c45c-08db31122c3a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bpkTtRmLCbBN3i7c+MvbHdH/Q1WrPlIgHIqzmKA/5Mivdq7sW+8+LNDW9Yz0Kbv7sIvH3lLs6AIQZA8t7JORD9hqKY/xZMRXXeB/1lxhlCfVKit4DBTXm7L8aJY5KVm+XJVxsW0CwrUP2BiPW2ETeube+sO10utqON9uZMceXdLJ3iR6x0hp3E/m0I/pAYGvTDlcyDdLnqdPD6Y6o8G2+B+XqbqhoKn6G3F39Fhm+zjLHPwjMJD8cA88ucHoV7y6B585XyXdVHb8weqX9QahC/GrIG3Hiy9kLgEtHnZ+1ZXxA/dtKrnnzICahRCL8+vOnjpPimVDzgJrx5gZdQFNWTa/OMtV757rW8IcoM3A7t3UERYcsT3jZQJ0QyNrV6QjzNG7Ia5Eqh20nECehVH10BNwc6QOo3LV7Ufe+nkbB3sx3pd8NxKSlCz9bidV8DfNECt1cnxLaaBpTOR79mE7n0Bjr030XnP+4p1305BISTlNRYYDht3y65kinkLYr7fLFfz4pBRh7YJt3W1+YZ/w8R8BBFJH6QcUNASZHA2vKqfBrwm4Kv/BZnHdXy3b/9kiw39wFgxsD28zXIpoV7pBA92jAO0hBCwydcP8nF9sseGase9mHEiWfaLM2ec1I3DI3SC63LQwDFaE+mkl4XRg2A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(366004)(396003)(136003)(376002)(39850400004)(451199021)(2616005)(83380400001)(6486002)(26005)(478600001)(316002)(186003)(54906003)(6506007)(2906002)(6512007)(36756003)(5660300002)(8936002)(38100700002)(4326008)(6916009)(66556008)(8676002)(66946007)(31696002)(66476007)(41300700001)(86362001)(31686004)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?p53AvhMTrhiT7dQalXPfrxV2KzNl?= =?utf-8?q?cuEe+ynDcj4PxDnjxV5rQsAjftjHFE7Zjv+iWt5VyOUltnSNEw/D9ADF4+qmTjcLL?= =?utf-8?q?LHmFLGe+99WkM53yGRWLNakKNSccQQOgKVC+c09XkA6PQyjbB/DLYlh/hm8nLhYRQ?= =?utf-8?q?y+oVtFdEFW02A7juFKfpHvxXAU/93LgHTa9doOCeVGw5PqELE1t9aGAbtfBTfHdVV?= =?utf-8?q?Jd4YP1m4nz7H4OmWS0x5bJQMVmsDjhSXQKVa/naT4O74Gub7toyoUCMHz8GmKO5Uz?= =?utf-8?q?Mmh7EzF8z06A6R2X5CUe5eOF9uelmZJzSTQM4no9oSrhU2jVPoN6GuO4aA59Dz1sN?= =?utf-8?q?TQPWCbOkms2q4Vztj0t5otIyjQL3z4rn/c5EhQnxSBaQNzUoMgY8M2bxfoxDfO0hG?= =?utf-8?q?EBJauVCUhPKCbH133Ly5Jlz5/DUZ8MI+wMgTmLwkG5PRAvtkM+7hjHsKDiaAZefaZ?= =?utf-8?q?keVvaG6Enp2zMrNCLsUCTSV0n6Ya6dMvmMvK8MotX06PKLbnc7WIQJ48Szb003W43?= =?utf-8?q?W/ok1c64Rhrjn/puoUVNh0+wwAfHKSz/Bx7ofJWPYjoudTkmSKrykrWgHEd5J9aix?= =?utf-8?q?I//wmm2vhXp3ewLQkvvehnxEIEYv12GyOUmaLexzXwP1WBvAkxRL/NePDvgQ1dHVX?= =?utf-8?q?K7qOjcyJVIdU2zaxei8Tl5DTzrHjsxOLPzeAMwBJLf8qjBFSfl/WBLz9CTL7l6Cg3?= =?utf-8?q?ZEjv+Ro6+7VyjAiahRnrslyk367bXiRTbeRq35zsv8jx4acNG/z7l7wRI2T4N9+Si?= =?utf-8?q?gq3ijwpJcdXkfLt5fDZDRYVcZL8P9VBCuXK6sn9xATgEOlki22jI9mTUeuHSWZ5Pz?= =?utf-8?q?efJOn2plv/HSqYBDsBOPtzQCNHfIecILqa/2WjVqBGLEj6m3ojns2MSH1vQrKCh+W?= =?utf-8?q?/8sY7apDquwITVgAJX8wYN7aCFLepsU5jS4rMCRP1b2QpCHoSeB2wrxmrLd3obu8R?= =?utf-8?q?5Fi2DCxZFzxAhZvJ43vLfxVQMgqc9s9X/GXUJw9RQlPu20kYPiiCETEH8bBBQs3xX?= =?utf-8?q?H9eZPyveh+ZQG4XDYpPNqXPCNIgBidrxh4Tvcrb9fLNqHNbH6S1embYCLX67t7Xqn?= =?utf-8?q?7nOMLFLgRyOKgJN02rrNDkFl3R/035/N/MpnJTUcaAi//hwgRDLSgzlB0j7hIc6Yy?= =?utf-8?q?3Bd346XxkoO33ZM1IcaVVzKRaouMrqfQw4gIZJJhS1QROPO4UPnixgwJfqYoG0AgZ?= =?utf-8?q?Z9jSv3pfhUnUFp4SQVmm9LkqTdYTZeiCb6VE1YmIB7a2KRSbchkHALckbr6RcaV4E?= =?utf-8?q?cGv0ChLrXLT0lfy1epJvclu/R5qL0h7K1TPYNqsksp6LuPApqxoS8a2755ye+A6/m?= =?utf-8?q?NMScKGLzfpAIWmetTjEmWuRQL4jLN6N37aPh+1f8AjiMQqTutc99TdVZKckyGCr++?= =?utf-8?q?YJ3CK0OoyYUv2jovQvFIrmwp6ZcZw8ia0WJmqfs+huUJD6OfSef/d7LtzliWxwtjm?= =?utf-8?q?BihmNPlS95GuT68kypG3emRIUYGHSEb39KESky9IkraTBBGSvdAviAwpcgHQ00TB6?= =?utf-8?q?1l3HemKNOY2O?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 09095ce4-d362-463f-c45c-08db31122c3a X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 11:30:32.5858 (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: sIrE36J2LL8rfZyIY17Wvqh4ZKJ029XLYbSoea3QBWLLUqGKodQEZ6fyMbvh/1H2SgHUk70gbadfgqHD8u185g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7262 Emulation related functions are involved in HVM handling only, and in some cases they even invoke such checks after having already done things which are valid for HVM domains only. OOS active also implies HVM. In sh_remove_all_mappings() one of the two checks is redundant with an earlier paging_mode_external() one (the other, however, needs to stay). Signed-off-by: Jan Beulich --- v2: Re-base over changes/additions earlier in the series. --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -1522,7 +1522,7 @@ int sh_remove_all_mappings(struct domain && (page->count_info & PGC_count_mask) <= 3 && ((page->u.inuse.type_info & PGT_count_mask) == (is_special_page(page) || - (is_hvm_domain(d) && is_ioreq_server_page(d, page))))) ) + is_ioreq_server_page(d, page)))) ) printk(XENLOG_G_ERR "can't find all mappings of mfn %"PRI_mfn " (gfn %"PRI_gfn"): c=%lx t=%lx s=%d i=%d\n", mfn_x(gmfn), gfn_x(gfn), --- a/xen/arch/x86/mm/shadow/hvm.c +++ b/xen/arch/x86/mm/shadow/hvm.c @@ -204,10 +204,6 @@ hvm_emulate_write(enum x86_segment seg, if ( rc || !bytes ) return rc; - /* Unaligned writes are only acceptable on HVM */ - if ( (addr & (bytes - 1)) && !is_hvm_vcpu(v) ) - return X86EMUL_UNHANDLEABLE; - ptr = sh_emulate_map_dest(v, addr, bytes, sh_ctxt); if ( IS_ERR(ptr) ) return ~PTR_ERR(ptr); @@ -258,10 +254,6 @@ hvm_emulate_cmpxchg(enum x86_segment seg if ( rc ) return rc; - /* Unaligned writes are only acceptable on HVM */ - if ( (addr & (bytes - 1)) && !is_hvm_vcpu(v) ) - return X86EMUL_UNHANDLEABLE; - ptr = sh_emulate_map_dest(v, addr, bytes, sh_ctxt); if ( IS_ERR(ptr) ) return ~PTR_ERR(ptr); @@ -457,8 +449,7 @@ static void *sh_emulate_map_dest(struct #ifndef NDEBUG /* We don't emulate user-mode writes to page tables. */ - if ( is_hvm_domain(d) ? hvm_get_cpl(v) == 3 - : !guest_kernel_mode(v, guest_cpu_user_regs()) ) + if ( hvm_get_cpl(v) == 3 ) { gdprintk(XENLOG_DEBUG, "User-mode write to pagetable reached " "emulate_map_dest(). This should never happen!\n"); @@ -487,15 +478,6 @@ static void *sh_emulate_map_dest(struct sh_ctxt->mfn[1] = INVALID_MFN; map = map_domain_page(sh_ctxt->mfn[0]) + (vaddr & ~PAGE_MASK); } - else if ( !is_hvm_domain(d) ) - { - /* - * Cross-page emulated writes are only supported for HVM guests; - * PV guests ought to know better. - */ - put_page(mfn_to_page(sh_ctxt->mfn[0])); - return MAPPING_UNHANDLEABLE; - } else { /* This write crosses a page boundary. Translate the second page. */ --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -3438,7 +3438,7 @@ int sh_rm_write_access_from_sl1p(struct ASSERT(mfn_valid(smfn)); /* Remember if we've been told that this process is being torn down */ - if ( curr->domain == d && is_hvm_domain(d) ) + if ( curr->domain == d ) curr->arch.paging.shadow.pagetable_dying = mfn_to_page(gmfn)->pagetable_dying; --- a/xen/arch/x86/mm/shadow/oos.c +++ b/xen/arch/x86/mm/shadow/oos.c @@ -580,7 +580,6 @@ int sh_unsync(struct vcpu *v, mfn_t gmfn if ( (pg->shadow_flags & ((SHF_page_type_mask & ~SHF_L1_ANY) | SHF_out_of_sync)) || sh_page_has_multiple_shadows(pg) || - !is_hvm_vcpu(v) || !v->domain->arch.paging.shadow.oos_active ) return 0; From patchwork Thu Mar 30 11:30:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13193990 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 96BA9C761A6 for ; Thu, 30 Mar 2023 11:31:16 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.516651.801123 (Exim 4.92) (envelope-from ) id 1phqUj-0003aH-DR; Thu, 30 Mar 2023 11:31:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 516651.801123; Thu, 30 Mar 2023 11:31:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1phqUj-0003aA-9B; Thu, 30 Mar 2023 11:31:05 +0000 Received: by outflank-mailman (input) for mailman id 516651; Thu, 30 Mar 2023 11:31:04 +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 1phqUh-00017i-Tq for xen-devel@lists.xenproject.org; Thu, 30 Mar 2023 11:31:04 +0000 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2060c.outbound.protection.outlook.com [2a01:111:f400:7eaf::60c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 598ba096-ceee-11ed-b464-930f4c7d94ae; Thu, 30 Mar 2023 13:31:02 +0200 (CEST) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by PAXPR04MB8782.eurprd04.prod.outlook.com (2603:10a6:102:20d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.35; Thu, 30 Mar 2023 11:31:01 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b%6]) with mapi id 15.20.6222.033; Thu, 30 Mar 2023 11:31:00 +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: 598ba096-ceee-11ed-b464-930f4c7d94ae ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YlLFKeR6RaPhYnHgeHi9MiqyGQdzUGh0q2Qywecje3WrA+tU1w5U77WBEGEw2Xeiobf0zpU8bbWtvQxi+nH93oJU3mnvOgf9AOUmoEPhNxrfg+LZyYbdEHOosznCSAGpa6RmToZlrq/vghEztF0x900XZsdRRaCEhAuBhZnylKyayIFdWNaJyMiQREubUgtIUPpBmoSerJczcy4QFcEF7MvpGNVgvYA98S9wyPe3q9kl7KqvoSVRgPYaX93cknWJhl8OuBPcOvLZtPt49ceNAP7JpST+GbIZfHyUrYIsff45510Z+HEsn+wFCU4kLPkuvH30cweOpzoxWPRzIv61kA== 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=8un3XXWErGo1I3D86zB/Aw1v47GFYml06HHbcbR4F10=; b=aXToDlwU6bLjvXIa8bB/Qq/aakYoQ7qmDijW1UbZ8ENPOvfQLMsp9UDgUGO/VxPHK7jaw6Y2FefJ2j6M+gPfre+/a3WNYlBG27Unm/w6tWoIIyBG6W+Ts0xV4exwUALor/7c5Kt0iNdR/vjahQDDn5GxukQ+QR/jfSbkqWLFUbP3D7sn2EEUZ8rfurJFm4LsxO9DeS/Clih9tGdsVM0rQugHiS0Uf9siKJUsyAqwPJlHxThGW+zc5lTmWeov/m33mBjYCpJ2HC6vg7clw6f4gA/rxIzoUzqg67tO7aarrYcxkEsvidAgOiPaN0hTyCfatBjT/HmJSM8if9nmZctFAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8un3XXWErGo1I3D86zB/Aw1v47GFYml06HHbcbR4F10=; b=bwYI92QkfbsiXyVCmwFAdQPFhB0zDLAWld4Qhv7lB4JtLT0LWkxgf8xrsPn/7Mi86ZWVQnKiey0NTKgOmfr8tgnd/hbDXjIhpJJShqsscPmn9FI4baAvxq2zphTVE+mvo/gjxUSFZDgFqunWBC1PapssytRH+NYgX9x39BL91dDOuATv9Gwz0rA/5f5Df9Qw0CvNnS3QLt6fEg2bJLT1LssPUpDTFqAa2sWMTiZ2tGtoMhJDasqOB4/kAylQIF52Dvp82VFw0zRGgZbrwG4EaOn1XZgvX9X0CPpX+Qn6petWykr3RXtGYaf4wyHYssu6kpUNBqXmJdXz1HtxOpkxRA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Thu, 30 Mar 2023 13:30:59 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: [PATCH v2 10/13] x86/shadow: make monitor table create/destroy more consistent Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Tim Deegan References: In-Reply-To: X-ClientProxiedBy: FR3P281CA0192.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a4::16) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|PAXPR04MB8782:EE_ X-MS-Office365-Filtering-Correlation-Id: 8132e925-4bdf-4ba7-058a-08db31123d1d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pmFGJKVfiuH0X/TqlRbWLCnJ/kQSgAWMcAYCJ67NT31FdZII4NauL61ohuKLjlfmI1R5ZMXfMqx2p9rQ5dxmaIMDkfrbhD1w2E8Ai71LNMMbm44bjwtFy98Hz7LSqOsGIjx4Tz3YEJV3/idN6eubibPqQ8kFIC7tsLNSBWEN8mUWczM9xHbnLnfdMsK8lDqPXhli1uiqj4+mChlxca7Lv7LaUtQo8exxHLHJv7y8gFerDQgW6e7Yng564s/InEK/MyflWLovOtHrwbuMA+BJ2omvE3qCeB9v6vWU/hePkLk9Eu8rbRzO0L9sbenzVbP53+fpUC7JygRAnf6EnB/1LCUbp8rLiyZnqblD9EYGQKvj1YQsXM0v7ZN3RsWSj/w/Xwh42aQrfkZWDNNTa2aTlAVesim6u8gx5P8BQCGnrjr8+9w+N+jD4DQMbVqqyPRM/cdIUtZfWwhksY6+b0fEE/r7wKuWq9pi2/wAjxYJxQoDSkv9XxB8uWFhj+CkD+0WdeqzdnkyPXuCVFReYvzvssLfbre9OVN+1waqieHFBPxypKQ0cQRp+M9WhyddLuefjB6u5nD2l68wtHMMS0UkVSiSP2frrbXc607vW1wEISu+hRd0MkUHbsvQxBkTIejSbQiGVgWC4DDuHNsrk3ae4oiC+p6SJteP/obP0LcVcnXUEdR778E41Bf2F3L3BwNU X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(366004)(136003)(39860400002)(396003)(376002)(451199021)(316002)(66556008)(8676002)(66476007)(54906003)(6916009)(5660300002)(38100700002)(41300700001)(66946007)(8936002)(186003)(4326008)(2616005)(6506007)(6486002)(6512007)(478600001)(83380400001)(26005)(86362001)(2906002)(31696002)(36756003)(31686004)(66899021)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?4WfyvxtabKAgxW6t/JtI7CoCSlBv?= =?utf-8?q?eo66k1o5W5BKNG8rmpiBT5oZNsQx6HwcKYxfQU4f6/yVbRljk8Qnnm/pAIer+LAzG?= =?utf-8?q?XZJIq8rTtYigshZNZllU4ClNXCgg3jVHomNKKf/ox3AlZgJnKwa7EA3WiUAgI48zY?= =?utf-8?q?S/cUeyu46RYFbhSJ3WVqJ+jfI+bOIZpYUJ+ieXimwwp4rUe0YHfoKl47FqiYtJYkA?= =?utf-8?q?BvF2/Y7ynFLArbtFjU7E8wH5zBvmt5wb4B7BWMGEs4SylTw5nOjHuBFaW3xWIzR/G?= =?utf-8?q?ExctvDivKfXF6v2MAxzAbSkeebgM40NcG1Is6KZQEm6K7GroThhPyauoF1XM3ek6b?= =?utf-8?q?F8vonEoJEZvlf6UgwHRXizekGHSHvI3zLbCvNx4nIzRIBChar8NzwskdiW6U2WGYy?= =?utf-8?q?KaYZ+q/QgiYMxzaXHAPgGkFzlMBwIxUhdDsuGzSFfSDTaMyHRNF/uQ4/SzhfIU8NL?= =?utf-8?q?3mXlyCYrgsqnsgbl+4wlUyja5WQwWSy9jp/FOp2tuS4VlhdKz5yboDH0Dhdv27A9M?= =?utf-8?q?x4Uj2IGhQS49H8MFoeqSRnuT0PmMF+Fo4Tv6nKvgMA/1yF9noTp19a8L5T+bHnSx8?= =?utf-8?q?cjiRvtevn4dLi8hRUxxIvJ5nx6a4AQAggcInxFkyQomVP1Qriu3N/wUubH8gN+jbd?= =?utf-8?q?4GF7BwWsBaYOkQfKdrV1TFrhao5kamxQCOy/NnzPx6k0aKZ+DyLsdJr8urCmPUpA6?= =?utf-8?q?01FAEQbNxTs4Q0gMvkm/+fxIyxAqEj9Q7fvsBInnA8pIjk4/Mn7WTQHkhsvbNwS3y?= =?utf-8?q?rlncT1C0MwDs0bi8tfeMevYVhSK+1j6JR6ffhnuVHBOQwzslDJ0HMXaJIwMBGjo6U?= =?utf-8?q?K1INucLFNkH4EO2cJUY30zaEIpRrILfj+Y2783m1KYLE7VcTcRtPCiSNfm/whZOEi?= =?utf-8?q?yFNggqS6aajDJVHReRmKA4CRhaDREHE271837E3ToHQsuw8G1jSZ3LfBVi3edvODV?= =?utf-8?q?bxz7he0uH9kRAfsqmoAuE1X4WBlvITmBS4JpVoDS/TjXFiec/B6v0HAXHp2r5hTas?= =?utf-8?q?rqLPs7KlNNI22548mx8UPqboi0it8r/9xZhzlhgVpmyQCAjkwsfd2086ECrHMl8c3?= =?utf-8?q?vY9uXblRg+IeWCV6d12uJ6iGPsHE38L+tAPnmUuW5VSO/v9RVyfiQivmuyuF72Fhc?= =?utf-8?q?Koh2/z63fgpd06so41JlwwTB7IUCqFUEqpVCQueALZoDyxLyuNxTY5sm7E6izFYnY?= =?utf-8?q?BLy/rzuCCCD5g9EDABnZRYHjTKiJPpeFkV7Tp4vv+V65YFN3ICVJxnY3RNgppaYpe?= =?utf-8?q?vOmtGCfmxZzpQTS6PubJaAx4+D1dfRf/FMyUnQo5DgTWDcC9TmaONNZj7nyitdi/b?= =?utf-8?q?Vk402wfNt+yJYq2ylO/FzVDtd3FymNF0YqZZhvawqENcA9KWV+2ej7zDwhwnWIWNf?= =?utf-8?q?yGjG4/SCi9dzxF7arUy2wbkpJaGisQNWnEUtm7YgwLZMv/cVSVhxbq/fDAMRDysxq?= =?utf-8?q?Vvcmsjt52nFkvelwPt/XzMwekdb6Gj2I5iSB6IJEJFLKNTevwanUQJr2TZmiCwkzI?= =?utf-8?q?h6fJ72eqn2r4?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8132e925-4bdf-4ba7-058a-08db31123d1d X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 11:31:00.9072 (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: bvNQRdLzgnYkDnoKIuDBaiIzODn/iX4uP33cF6BCbFAEC7ab0Bk50EAODqWAkyFJ/Pkm5ihvBJUaFIilgxutbw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8782 While benign at present, it is still a little fragile to operate on a wrong "old_mode" value in sh_update_paging_modes(). This can happen when no monitor table was present initially - we'd create one for the new mode without updating old_mode. Correct this in two ways, each of which would be sufficient on its own: Once by adding "else" to the second of the involved if()s in the function, and then by setting the correct initial mode for HVM domains in shadow_vcpu_init(). Further use the same predicate (paging_mode_external()) consistently when dealing with shadow mode init/update/cleanup, rather than a mix of is_hvm_vcpu() (init), is_hvm_domain() (update), and paging_mode_external() (cleanup). Finally drop a redundant is_hvm_domain() from inside the bigger if() (which is being converted to paging_mode_external()) in sh_update_paging_modes(). Signed-off-by: Jan Beulich --- v2: Style adjustment. --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -129,9 +129,9 @@ void shadow_vcpu_init(struct vcpu *v) } #endif - v->arch.paging.mode = is_hvm_vcpu(v) ? - &SHADOW_INTERNAL_NAME(sh_paging_mode, 3) : - &SHADOW_INTERNAL_NAME(sh_paging_mode, 4); + v->arch.paging.mode = paging_mode_external(v->domain) + ? &SHADOW_INTERNAL_NAME(sh_paging_mode, 2) + : &SHADOW_INTERNAL_NAME(sh_paging_mode, 4); } #if SHADOW_AUDIT @@ -1811,7 +1811,7 @@ static void sh_update_paging_modes(struc sh_detach_old_tables(v); #ifdef CONFIG_HVM - if ( is_hvm_domain(d) ) + if ( paging_mode_external(d) ) { const struct paging_mode *old_mode = v->arch.paging.mode; @@ -1864,13 +1864,12 @@ static void sh_update_paging_modes(struc make_cr3(v, mmfn); hvm_update_host_cr3(v); } - - if ( v->arch.paging.mode != old_mode ) + else if ( v->arch.paging.mode != old_mode ) { SHADOW_PRINTK("new paging mode: %pv pe=%d gl=%u " "sl=%u (was g=%u s=%u)\n", v, - is_hvm_domain(d) ? hvm_paging_enabled(v) : 1, + hvm_paging_enabled(v), v->arch.paging.mode->guest_levels, v->arch.paging.mode->shadow.shadow_levels, old_mode ? old_mode->guest_levels : 0, From patchwork Thu Mar 30 11:31:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13193991 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 53725C6FD1D for ; Thu, 30 Mar 2023 11:31:40 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.516654.801133 (Exim 4.92) (envelope-from ) id 1phqV3-00043L-Qn; Thu, 30 Mar 2023 11:31:25 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 516654.801133; Thu, 30 Mar 2023 11:31:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1phqV3-00043E-O0; Thu, 30 Mar 2023 11:31:25 +0000 Received: by outflank-mailman (input) for mailman id 516654; Thu, 30 Mar 2023 11:31:24 +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 1phqV2-0002FN-5T for xen-devel@lists.xenproject.org; Thu, 30 Mar 2023 11:31:24 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on20628.outbound.protection.outlook.com [2a01:111:f400:7e1b::628]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 66595093-ceee-11ed-85db-49a42c6b2330; Thu, 30 Mar 2023 13:31:23 +0200 (CEST) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AS8PR04MB8980.eurprd04.prod.outlook.com (2603:10a6:20b:42f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.21; Thu, 30 Mar 2023 11:31:21 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b%6]) with mapi id 15.20.6222.033; Thu, 30 Mar 2023 11:31: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: 66595093-ceee-11ed-85db-49a42c6b2330 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZEAezTPRfpOrOzkIsF8PtVUubNazP3Ic4XJR6GZQMJWEraX0SyOlJi6Ox3kwI1+EORJoiva3YLktEXGPCqlmDZaSRDhvf/+4S8RehFG4CJ9zPnR0XgEP/IPjrLy0pJtNqX5UCtCtkLen0sL502qNxkPQmwdnM+uoHYpYksTSwB2hVv0bxCxEbAGX/7nBLq+gmV5sVCvPGztUS5pFks5We6LY/GnrC9Vokj2BFeQByPguO2rOaRKPgFVhdKwmExbbpyQIxNSbt63WMi3jh/AfZjVlvXzh7Z6N27SY6G1awiRGUdGPq8Hn5P7Q7r6xCt85Qsai4DozL0CGOFl3HnE8cg== 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=Pm/MJtSEloG9bhupNLw1FgcnGKAOHIGYAu+yof1N0B0=; b=iTHvTioKrh+sf5KlqVV7ZCT85hBZzRAAY+jAmogZviG3mp9mgDzBKEpn2zX61Nx8Z0ADKrsqpS1SPhEFKKnh/m2BLLM2VvxlpFErlL69zKuwfyplduJJVPVVmw4Fmq6ZqFBOkAtO0JrqiFedaGrAPdf5LRxyypbwaHj3xmZyO6CP2ZuXfFxtVkXDIoTAj8Qf82kgxS17ZUlKSG0FCV+giPvcC224enuiWzRgiQ44+0giHgv/fka7uvMnsvnQMuqYxJWehcLVZrJYEpGt1MEz6GvzJzHBPpdTlQ7i9GzuKcWAa/D1Oso737mSJdgGN80DDJYwpXep0N2jihCIk1spbA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Pm/MJtSEloG9bhupNLw1FgcnGKAOHIGYAu+yof1N0B0=; b=W7EQWDTe/U0GnY63KDgHt6KDHW1JwyZ5Okv+EQJBCU+yCwkvmlaEti7zxujV52Nu0p6c82XWXmKYlWqPfHt+KLdGukMBVuqksFSqx4yitA1lrdxKq2b8I42vqAdA0CP45/MIYTVGcmPudZVgjUjl6m9VXUtHSkU/wOzLRb3uUKtYOE7+xoPTxQcNh9AX+OLC6hVrFHXNC9RHQLm+2VGMdyCT7PSkRv0VrSzfV91oxwd/eRvl8W8rjenZZcjG3wsb8TzXcdbvNr16x25d7Nm6/7RYpeiJVjILZOlJr0SR9lj1zWOgTgL7ZWpHyOzADld7ANui7hzRrrS/0vxNP6JydA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <6b41e44e-282a-6397-a8e1-1d0782ace5c0@suse.com> Date: Thu, 30 Mar 2023 13:31:19 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: [PATCH v2 11/13] x86/shadow: vCPU-s never have "no mode" Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Tim Deegan References: In-Reply-To: X-ClientProxiedBy: FR3P281CA0193.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a4::6) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AS8PR04MB8980:EE_ X-MS-Office365-Filtering-Correlation-Id: ebf57109-21f5-4f9b-a68e-08db3112493a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 46xan642PeeERT/rLiD0TuQ+k4rZPWDnEdRN9isUjUp7tTEeZ3oZdKcRYRJtaNznc9Qk7Ghydj9Y7LsO2CwJvHviy7mxhA0Wgr8ug4sqEiIYiXNYzrLivBHD9jpAGwcZxKSrfiU0DNPpK84AVN0InqYOCnss8k2Ro4jZ5OIZR9vKujA9ObiOSkLqzr6F09b9tGWlBJfjRMQvrkUFLF4gtZRMtwIG+Wo9in1twWh13xtlESd05w/vqvj9m41WDZ0rfDV3WIEwa+9/IruwWxNHydMtkf5darIh5ye9p8n74XKWaU0ch7m+Njuwydsr4AJWmm2QF0RsIxcc3ItIAvKmCnsUNXEJRc3jEkhxMGG0VEIf6iQ9fr5B3DSMBRbwDn2p/SOtUSq5Xtm1kABXC4U4bTMTcRe0gqb9KGWVXuveWX5q4CnyZqVCANONwv5rk+M5Bgc+4XGH8j6LfHCnuyGapR/Nezs3LRGE7XRKBiUhYMVfFPoC3VNQPX+ozsj2Y+AJYfD92vxHys+LsbVpsG8c+TC8FuJ+gpZFmqrqJJ6giTYt1RyjGe91LCN/ks9F2rsCR7XDpaOz3ssDrGEKop2VhB2sybXUUcK/UhVw1/ilY6YoD45CCZwlzoj0X/r8x+ZMLESWRO+cgqMxHZUjWu3ueg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(136003)(396003)(346002)(366004)(376002)(39860400002)(451199021)(5660300002)(31686004)(8936002)(2906002)(8676002)(4326008)(66946007)(6512007)(66556008)(66899021)(66476007)(54906003)(316002)(6916009)(36756003)(6486002)(2616005)(478600001)(26005)(6506007)(186003)(41300700001)(86362001)(83380400001)(31696002)(38100700002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?ahLmC4R5ku0DLfCwAIbQ1MMeSPws?= =?utf-8?q?lHOS33YyEpy5dDJ15kekOTdMyKDRLjvhXJLVEyMtcYZRoN4WZX6luLOrkJxe9ECco?= =?utf-8?q?g48J6PQEJyfR5fEU+Yxj2xwVh5mTGdvD6lgyyZBfepwLgDY54BqHtB+URxsqmqPsM?= =?utf-8?q?iZbz7HmP0earyPSKU4ukO4L6Foo4+ANyc5Q64H6z82OdiO6S0eI3p1lzrc9WqN9GF?= =?utf-8?q?GiBlzLZQekzTNTPu5MYXf50moZ5rTeMDX3/BqCFgcrKKeK9uu4w3x3EACvfDjmSMP?= =?utf-8?q?ChrTXDrR/RsTmLLg1OXRYnQfsbANzhgKnrg0mds2CLZQYmMqxkSWt7MN4A0MQXsbY?= =?utf-8?q?rP5GDczh7Kej91tqvLLHI/dn6W8FM7E0FrR1vt5ulnCgLtyAq6RUM8n3DepthEC14?= =?utf-8?q?2TKDeO2TpT3Dp8GFujB3wYKgPlW3f3IieL1Q6gJd889FaJNuIAMdcCu2m/bvMd7N6?= =?utf-8?q?DGNDVeF9bwlzX/HKVQYmpOxYI/xquR9SHrNvQa9WQYGOIB/svp4x8/DVh2nTSefEi?= =?utf-8?q?WSiZ9QXvffrizr2qmV+fDfq21fOZrVhK7vricrtwgh9WMExfMXui4q1AqvKacj8uo?= =?utf-8?q?Lh/5fitxEmGKSgunxmtcps+q3FI0Jsil1psoD5fUdoOfxNZgcaP+Pk2Lf6HOYmAuR?= =?utf-8?q?XPOAomeeummk1Se6f99p9rrCjn+1P6HuqnX/eoK0Aty7syVnw4YmJIj6Ab3d7e+jR?= =?utf-8?q?0Ir/gsyGmABgf9L5Sg3GPVQWfOGAbkoy25qRsQqP2FlTuuC1QuuykqI8bMgoRMQbz?= =?utf-8?q?mo2MOz4X+Bjz5CeYo77hO6fu32KBWqwRA7/a7CogY6mEgy8SwEd+3HmjWjWVtxFeZ?= =?utf-8?q?/AlEBMEtln3jiRwuDIAGTVuYiq/UKTRee/p0iK+gR958bV7Ujm3GpQbQK3gEZ6Y2u?= =?utf-8?q?oui9dRJ6cEYvEnd3MEaS8k7NPneRY7s6T1F+ETsziEiXrH+eLWF9wlE98iTKHMbgl?= =?utf-8?q?ySSkF62tFheYpLSCZZQpIBfAYvUPLZOKlciogfDWd9vc4OaoxpZtik12lTO3d0R8G?= =?utf-8?q?m9KZEIKjn43vXe90E8+o5VOxktNRKEsK0R4qUfRjSBrz99vux1UfaKy5gZbvlpnrL?= =?utf-8?q?EpeIBNlqbxGv2ATDUGEHgtXmSEMqUhl0XopdKsMusvd8nH3qlqhZBWI+9phpRgNLg?= =?utf-8?q?NNjwbdds6sC3a6slSbrT+9PoYhJjLwE4qRkas42Gs+/FOqgQaIPK1p3M8uxgzkX0d?= =?utf-8?q?bDANVOaJfeH8ctMViuhP1HVstI+YsQSF6RSlZdeDsqI5fL1f4yiXGbA/M/BI0IB9o?= =?utf-8?q?tSG0eZ3oEZEghr3laOB6RzYMnv/JZ3hBTl8m7mo19J/g9tnuBcnn46oToegt1K4v8?= =?utf-8?q?vuurkGsT89NBgwGxgIezD61JfNuYbY7ldITZv9NbZFSAfd50/eGUKDl17+eZpp0sd?= =?utf-8?q?MSENQuFuZhJrOE2fVgJn6wiqjH19qiERj+VvRbKPccTpbw82NLNQDm9XpRoEYcMDi?= =?utf-8?q?hw4y59j4q2rrOgDA5/ZK19dB+2PYGYRkl64EeW7cBbRFQmOacn1eCFxLQTDm37juA?= =?utf-8?q?Tzq2j8TDXBvb?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: ebf57109-21f5-4f9b-a68e-08db3112493a X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 11:31:21.3289 (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: U8lRrfegjJ2xUIzWLGmvnl42u+V36Zp82eLEZq9TPxwvf1z1K0dnV4TtSri+CCr9l5CtT7f05pdHntetIN/pew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8980 With an initial mode installed by shadow_vcpu_init(), there's no need for sh_update_paging_modes() to deal with the "mode is still unset" case. Leave an assertion, though. Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -1864,6 +1864,8 @@ static void sh_update_paging_modes(struc make_cr3(v, mmfn); hvm_update_host_cr3(v); } + else if ( !old_mode ) + ASSERT_UNREACHABLE(); else if ( v->arch.paging.mode != old_mode ) { SHADOW_PRINTK("new paging mode: %pv pe=%d gl=%u " @@ -1872,11 +1874,10 @@ static void sh_update_paging_modes(struc hvm_paging_enabled(v), v->arch.paging.mode->guest_levels, v->arch.paging.mode->shadow.shadow_levels, - old_mode ? old_mode->guest_levels : 0, - old_mode ? old_mode->shadow.shadow_levels : 0); - if ( old_mode && - (v->arch.paging.mode->shadow.shadow_levels != - old_mode->shadow.shadow_levels) ) + old_mode->guest_levels, + old_mode->shadow.shadow_levels); + if ( v->arch.paging.mode->shadow.shadow_levels != + old_mode->shadow.shadow_levels ) { /* Need to make a new monitor table for the new mode */ mfn_t new_mfn, old_mfn; From patchwork Thu Mar 30 11:31:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13193992 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 18A3AC761A6 for ; Thu, 30 Mar 2023 11:31:56 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.516658.801143 (Exim 4.92) (envelope-from ) id 1phqVQ-0004eC-4C; Thu, 30 Mar 2023 11:31:48 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 516658.801143; Thu, 30 Mar 2023 11:31: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 1phqVQ-0004e5-1A; Thu, 30 Mar 2023 11:31:48 +0000 Received: by outflank-mailman (input) for mailman id 516658; Thu, 30 Mar 2023 11:31:46 +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 1phqVO-0002FN-O5 for xen-devel@lists.xenproject.org; Thu, 30 Mar 2023 11:31:46 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on20600.outbound.protection.outlook.com [2a01:111:f400:7e1b::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 73e58b8f-ceee-11ed-85db-49a42c6b2330; Thu, 30 Mar 2023 13:31:46 +0200 (CEST) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AS8PR04MB8980.eurprd04.prod.outlook.com (2603:10a6:20b:42f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.21; Thu, 30 Mar 2023 11:31:42 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b%6]) with mapi id 15.20.6222.033; Thu, 30 Mar 2023 11:31:42 +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: 73e58b8f-ceee-11ed-85db-49a42c6b2330 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I2o04hZTFoDpTSL4zM6urm9xv17de54SzbPTwFFd6FinuLMsdRTQ+u8xiW8ghFJBQy8Y+CVhJF/rlwPvpiu9Fs9julzu9hHwMDIeLhFCEeay+QSHRgTpylrmMPofJrJ9xkYzrEJI1751IVNEHGq8zNPdpfx25A/pKMHOq+0JzBXe8/YYJ+PA6IMjmIoIaFej79dMsocsTarFzRJOpL8GS4uDO11RbSf5jMWYoFjJ1a5a4xnuuXEMQ08RpnuODUVG+oW6IcPVsrmmlmNZdUloI0MTJFE7keNuvwFmUn2dFG+DburkjaLeV00nUNViMchTmMg1Sbj9AchxbmL1T3RtEw== 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=RpugR2creDQpmbTfh0GSUcRY9SEocvRjzcrAYXp5z+A=; b=MJ4dAyMSyDS7NOsmr0GfPUNHjyPG5Hw54A4ODtrLSBbllyfkiqQKs4340kAXNkbWhaV88dt/CfMX4ePqaPbugt0jwjF6qbE7ZN3PSm1OWCS7TehtBuHg7pXADLI+VF2MDSdbkFMpKBCDoCkPESvT6t610fUvgm3uRxVAeilOs9T+uxCjCY/chqAXxdWDF8UDuQFNB17W67XqHk7/xSAavhGqw0BvYUM4lQX5PgzeT3r9ZYf1fhIN42spWZJ1rlUraMgcTWvMsedAaXAnFqn6e6neCAzFgXai6jpz98FwXYgO9zyIl6yJHPkQzbaOZrLymwRQijbIYBbn8cumtAlcFw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RpugR2creDQpmbTfh0GSUcRY9SEocvRjzcrAYXp5z+A=; b=PBtMUD2Y/3r/ezkaYWXao3GhiZzn3fxdKH+oy4a2xazwjdyl69S7eGRrsuVabM/TFZtm4GRg9YWW84DzuDnSKtyOyejQMpHJEThy3bzp8rt8Qxk5Umg8RJGwVlZhQLkyhe1LUEXi9qfQB+yonFIXKK872L+RCCHBh+5rI47tqe9FQlCr3tZeoZL4oHKXTo3N8ALIrm3fwFqmNh5SC4bB9yDgmCFZCaSBjManCExjoYwbt6TCwdInLJ6oGaD9N1AN8K9auO9iQMFE+VQtRd9qUixbTWiKpgr/Qkl8szIUq5GgnsOqdi0PEVWCCMOV9G7uWaUN0ycRUGoKWmjPZ0iz2Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <354658dc-35f5-1322-a1a7-da44d0d2b0f8@suse.com> Date: Thu, 30 Mar 2023 13:31:41 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: [PATCH v2 12/13] x86/shadow: "monitor table" is a HVM-only concept Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Tim Deegan References: In-Reply-To: X-ClientProxiedBy: FR2P281CA0119.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9d::15) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AS8PR04MB8980:EE_ X-MS-Office365-Filtering-Correlation-Id: ea24e251-c833-4649-2837-08db3112561e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MJe2KzOXMMhONTIYdGoBnV7EJQ3rJwZAEdm4+mgebBCbNkbB18cIQ6AAtYFgwHrPFU+wun5PGNo9rm/SN8/RUkiZZxyXMNA/k8LWveVcDtvpMYh1YzFHAiZoGa71yyEDDpqkUruiMVPUcohem8rICJzr8Ix6hBYcMQ0mgCaVKUrSqD2BszO0kvvSdyq1ihhlXt4os5l5CSKn0w2mGOygn49+5vYPhsZC0491OuArIfxAynyAF4HowEzh9RbT5mrUmJXiuNx/0tFFdVc4b0DjLqekeYTZrNrkpsPd2CAHj2OfX5fBCu5eZ8wR5T35353FX/GiuWeW+TnjwqiGyYljYRbai7xupcjwDQ4ETxTWo0Gt/36orycgRDlwEhq7QFIxg1dxDVbeuCj1UyynUFtP29WgVbqpXwLoDrEPTEMmo2DA1dohjIjBg6H9axb3untG/P/CuPlCGDOKUiR0j6+KEAhL3lVzFq/NMS4HcxBPnQI6TxFIJbQO/BtxNVLK2nKF91sFqyxGHJZcXekdU1fMSmvkbV+e6BAX6O/YBWQ+MaUQ4aW2cDW1wzC04V5utfgyLICHRSZmiWSJwzOiZuOTNSISPq70H1qdHHFI9mJhoAAgina/SgesCGmLexS+00DcU5x8oiWd5SJYh+Eq3Z/SYA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(136003)(396003)(346002)(366004)(376002)(39860400002)(451199021)(5660300002)(31686004)(8936002)(2906002)(8676002)(4326008)(66946007)(6512007)(66556008)(66476007)(54906003)(316002)(6916009)(36756003)(6486002)(2616005)(478600001)(26005)(6506007)(186003)(41300700001)(86362001)(31696002)(38100700002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?XoCVeRMHYud7NCV0W8LjQhRufzZo?= =?utf-8?q?Eje05ys808GODQdkjqYfaohkUDVmtsvqnRNzPHsFBiCPfyWYivDrepD5k9ia+4auW?= =?utf-8?q?V4WzWNyu1R+CZKAmnkIufSWIcr5NQefU9xOU1qV8VZtG2FXddqe3BAfHbUCURru9C?= =?utf-8?q?R9w5J5EAWhK01vvb99kMuisKdqfSJmMmbquxrbtgY3pEhcTYOODPxJuKdIb4uBGOQ?= =?utf-8?q?P3H1r6HcnxdXbyBgco7QMrjjzuBIMTrzrVCGQlXcJGumGcF2ga1hu6XwhYfbqDhvE?= =?utf-8?q?3I24lE9zBjlMQ/tS5G2zj6NKdETgLzwpQEKuloq9HsXZhenlWdzWhZS+6A8LeJi3f?= =?utf-8?q?KfE8Fn5530b1HgENhKhJ912HckoIJfQjLsAjwDd4i87iK2UunLbR7bxRmz0vRuZlU?= =?utf-8?q?KBm86Fikmo/UN+xbcS/7mldNEOq0Wk4SO7Z7XyhACu7xaT1qkYPWiPE8+jjrb558K?= =?utf-8?q?KIwxmecXyriiWnCTNGlQnLAbjsPPfFcSUcqas8379HzltqfGxLrTDfFQISp5iC2V7?= =?utf-8?q?Hy5Uaqtsx1FP5oQKmphJV+TBor6PI1Pww3cmWddgJOM2Y5cNA+PLHXleT71X5tQA2?= =?utf-8?q?YKffuBTkJOqa1orHCFe61siB0XCkQ25garlotz1HhKIUmLxSe3g99Xd68lveo1U0Z?= =?utf-8?q?3L6ngfvRM+FVfpZjqQ2pf0kmgbA3OHJVPGrUvdEpxMk+KyNo0h/+Tlk0/GlxNRcPb?= =?utf-8?q?QaC5XQ2kBonxUwPSbJFC+s1P2tvAPrreczlxUwpPIuSTIjin1aIdg+v4+UkkXPDMH?= =?utf-8?q?Bn/zk08gm5SIKLvFdD88Qtpwho5CKHxAuDXkG4P/YFtbmV/f7Gwqp4Ap0tNWCdMat?= =?utf-8?q?kSpjF0nf7c1tna9AXL2Z9zAWlIWj2+x038UVhocmafmX6gEr273AK0AV2Weyux93N?= =?utf-8?q?hfNuXiusuZTCxQ8fqOm50DiFBsAZAJdAyJeboDvnwDnm/h4fYymfr/a/KjwEV683Q?= =?utf-8?q?5y2cR+UpgsLB26iGnz7lVrNNFOg833VcZtpTqn26OQ/3HaCgvLm5em41or93w6cfH?= =?utf-8?q?kU+1eFCHk0TKZu/ws0B0FBeGrMv8LG86PiI7U7jc7v1KQ1RvT7cTvovM3gxWo2K+I?= =?utf-8?q?LTMWStmiA+pd9AGOilBBNgDVOLRB2XPMTZXARq4YZ5yvQsOiEt/GRcc7OJE172uY0?= =?utf-8?q?3H48k0BZ2O+iPxR2Ga7GtVLcfQ4FGrysd4l2MMRlEPJ+7wm0uqjY6s2+qGzZfZSov?= =?utf-8?q?4BX1osK1gmIU71c1H0RiRbk2DhI4uARFyPd9npielcpfhlSCUtRfbK0aznCSp6KjQ?= =?utf-8?q?EgPM5TjB2qxmKhZbD12ZjjOR4nYgcsJ1dRdJOChSLMepPmHV/3pf1Fz68jrqNlcLy?= =?utf-8?q?7u0RXepxoSVb3wUGF4niuPOHywnpHcFcORBbVR+ZY8DJ/gW9MWUnZy2XXPEAbxfu0?= =?utf-8?q?/BJD+XXZEOAbyt/RnOX/cTeHZJiqOLWOdBLZ6D+mbp0BXl2CJAzjV3WkzBmil6q0T?= =?utf-8?q?0Ib90RYABA5NvhYzGIYjCG3aSZfmtqDSq+R/SU6I6hXiHbNnTyCcac1lx/7k3doff?= =?utf-8?q?NZhuRoCMOPmm?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: ea24e251-c833-4649-2837-08db3112561e X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 11:31:42.8178 (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: 2grHUIOVSnqm2zAGrySE86Gky9ltNwd7kbkQiocudmBPEq+GE9v3Ss0YYmqVOkxft9pW/JkB/rQ4OjeAVaL9Mw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8980 It looks like in the combination of aff8bf94ce65 ('x86/shadow: only 4-level guest code needs building when !HVM') and 0b841314dace ('x86/shadow: sh_{make,destroy}_monitor_table() are "even more" HVM- only') I didn't go quite far enough: SH_type_monitor_table is also effectively unused when !HVM. The assertion early in sh_destroy_shadow() can have the type dropped altogether: it shouldn't make it here in the first place. Pages of this type are freed directly from sh_destroy_monitor_table() only. Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -1190,7 +1190,6 @@ void sh_destroy_shadow(struct domain *d, ASSERT(t == SH_type_fl1_32_shadow || t == SH_type_fl1_pae_shadow || t == SH_type_fl1_64_shadow || - t == SH_type_monitor_table || (is_pv_32bit_domain(d) && t == SH_type_l4_64_shadow) || (page_get_owner(mfn_to_page(backpointer(sp))) == d)); --- a/xen/arch/x86/mm/shadow/private.h +++ b/xen/arch/x86/mm/shadow/private.h @@ -205,8 +205,7 @@ extern void shadow_audit_tables(struct v #define SH_type_l4_64_shadow 6U /* shadowing a 64-bit L4 page */ #define SH_type_max_shadow 6U #define SH_type_p2m_table 7U /* in use as the p2m table */ -#define SH_type_monitor_table 8U /* in use as a monitor table */ -#define SH_type_unused 9U +#define SH_type_unused 8U #endif #ifndef CONFIG_PV32 /* Unused (but uglier to #ifdef above): */ From patchwork Thu Mar 30 11:32:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13193993 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 BAACAC6FD1D for ; Thu, 30 Mar 2023 11:32:47 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.516662.801153 (Exim 4.92) (envelope-from ) id 1phqWB-0005KT-Dh; Thu, 30 Mar 2023 11:32:35 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 516662.801153; Thu, 30 Mar 2023 11:32:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1phqWB-0005KK-Ac; Thu, 30 Mar 2023 11:32:35 +0000 Received: by outflank-mailman (input) for mailman id 516662; Thu, 30 Mar 2023 11:32:34 +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 1phqWA-0002FN-1n for xen-devel@lists.xenproject.org; Thu, 30 Mar 2023 11:32:34 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on20610.outbound.protection.outlook.com [2a01:111:f400:7e1b::610]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8fdf046c-ceee-11ed-85db-49a42c6b2330; Thu, 30 Mar 2023 13:32:33 +0200 (CEST) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AS8PR04MB8980.eurprd04.prod.outlook.com (2603:10a6:20b:42f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.21; Thu, 30 Mar 2023 11:32:32 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b%6]) with mapi id 15.20.6222.033; Thu, 30 Mar 2023 11:32: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: 8fdf046c-ceee-11ed-85db-49a42c6b2330 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gh/ofto/1gHJ02qlDvJj6RD30SdIKBaldip+atea+Z4sxd41vbYa3PR8L79arSc1uphxUiW6C/t7bEmAlRoKQvvtUbG6YgazjSj0dntfl6w5z0gxCjbaqTpi6DGJBHhN4cPSBRAsthZqC40Io8s0J2L0KJ40LSO2dKHKcOUM1NQQbpasjK6CdxMt4WhiIDdPMU+EQODqySVTVlZJ8WvlBv7zsAzHym2mSdcd8GUb4YBsnOgutSCDG83ip5QhW7B6coN9uBIMVRv1Ew7R+QEek9Zh7HHohmnJ0pblLSh+qfvY6WxJTRU22ks2qP/6V9AOMMig07o+mv7Gde2dwCu6XQ== 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=X1l2fkRqRJiGKZyq0x1zbIscrbjHpZaIQjMcBMuPrbQ=; b=SDgh5ofhCzXCC3CvMd+3OGGiwuLTQtQrzDEfE81XBWe7BNvQ22uKi97miKVHm+/VShFr4KkakwHDS8ClmCJoFlLYLG38A3HrkMI67XkKDML7tQoJ+rvsGog4SlGHmHRpKALHBgRl7ViseXGjnrFj53O7pC1T3ufoFBfBmZvlzy7mmZMXVCYDVJLfPBqHEHZeyLPlsWRSmZi8JknDefRQFXbonZYQu7P0rvV49TAjT4KffGmWILWvQoGXPHoq95kd08pwkh+RyhmA2T4uAbQ+3A5xKpziYCuuxzIxWOTnbG1kK0b02HO63v9QWtgW8awkQk3IDSbc/++wN5echwWAPA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=X1l2fkRqRJiGKZyq0x1zbIscrbjHpZaIQjMcBMuPrbQ=; b=3XjdHwsOJQGis5sxBnLb53b5XroEG1UtxOHMa4aBXdf+kl5En/0ffCGWbZGgb2Ws8VqU4841LJ6ia2+1RwutyjrY3lWQOV8h17G7//nYLscEF9/fJ1RZ2OlHMz5Kwn6Xkks75PJufk25dPRUIE/hZaky33FObxvkJ9gNE1NOSQIttmiy1tfuz9ZhQ/ywSZWyrHY53KlfyjiZBrEm8F4xVuWtnY5+9nranWbR4zXhs0OWfc97jJ/zRxoDC82fNTJMzDBT/RzNamsi0d5+WHNd2Qoer7t45ANvoibU7ggyE3Nrnvl2sUS7uh+mRmTU+Hh8t6kmu1UFuKlJGqSZN6ZA9g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <9d53c403-da7e-8a56-516e-b5f8151d2707@suse.com> Date: Thu, 30 Mar 2023 13:32:30 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: [PATCH v2 13/13] x86/shadow: adjust monitor table prealloc amount Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Tim Deegan References: In-Reply-To: X-ClientProxiedBy: FR2P281CA0110.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9c::20) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AS8PR04MB8980:EE_ X-MS-Office365-Filtering-Correlation-Id: cdf2c7b0-1bbb-4eb3-b60a-08db3112736c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PXKUekEv+9+Ds7SnzPL4yL+yIQdKbslb0Vr73af1hYc1CCViBpnQCTysYeyKubmaY7+u76r+W4t3u7uCg5QnKAV/tU1RK0+kLS8Ecoq7TbP+eC6GO52x1bxtTNXR22/cPXf8LCXHPj4Q5haD6NoW35j5H3XTm1Jq+zF81zArvWSPEhq/4lssNd/3y7K4xQxUbEwohy01cp+GwgdYtXg0a8FyqVqlEL3OL0CHhJY7zZMEc8vbR7yaKj25P0/u8PIE135uJS6G3bOtcssAjwgcVfrRf5oQGSegsY+XFpPPcwzQjISFMllpmT9frD0ylR7x94JmPbneE2hbzA663g/Ydi3lLOy8DMAYc73jOSoHIW9uVBYOWTxK3g7bXjs1U7JiyMFF+HKh4E8w59/r/jK/l0n9aoPW1janS4ddw8UKA1BrvpZecfNzsdZ5S9fT4g609+qITY+nskE13RejjbBuopYik1K2LidqRqh0tcv7JDkfF0mLrTcOVg+EnqvfJuhFeoLdk86lLxniWlRVpSdaS94dBCCJI/BcqHtt6rioCFxFddCwDuQMsYLnSz5mPz8Q6zjrPApLFjkNlIcwDg+iG4auT4HsxHI1p3pq4j+KNk7dQFxn0rStgXq+2gPTwhxezo3Q73e964JNXg5egzkwFQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(136003)(396003)(346002)(366004)(376002)(39860400002)(451199021)(5660300002)(31686004)(8936002)(2906002)(8676002)(4326008)(66946007)(6512007)(66556008)(66476007)(54906003)(316002)(6916009)(36756003)(6486002)(2616005)(478600001)(26005)(6506007)(186003)(41300700001)(86362001)(31696002)(38100700002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?TTyfrRYL8TrGkTr4tH4yBUAgDCGL?= =?utf-8?q?BmrAv7maQgLH5CONqq8nRIRU5+yOnntlK0Hs/Ct0F2S3jK7wNp/4PB1lcHfIqziV+?= =?utf-8?q?FzLREVBkLFjAgj6yXKDesVWYTw4lBzYYoWq/775AkR+gS15rx41rQgZGIWKhAXKHA?= =?utf-8?q?w+EO12w/y+t2ltxhFudtSmiZiwqfPAzJAtqLLdBVQckHSRfBsY1+bINMbLE1GqGOG?= =?utf-8?q?IP7ORlxHnbr1lavrvoIOJYZdSj6650GZBc7M20pgf99X7QHvjVUSZf5PGqzlU/gEB?= =?utf-8?q?saLcv9lmntD4mUbaaHHNDlW3FvI1+5pqRMqIE0p8D87fT2vZlz0SCaSWwjEVY6BSC?= =?utf-8?q?3frNabIg7UEYJ2JrzZmC8sTsOLGjgR3dLk4CqFtD/V2Gz5Rjjb98eQD9LZ0G4uXG9?= =?utf-8?q?TG/tiTZLzi1VuURlrMLYubK1yUL9mVVeHg3JUojOrJZPw1dQ59wOH1s3EC2YNDza+?= =?utf-8?q?3mlQodLjWHaZIomgEj6QRSh2gTqJBieurCJ4qbNz7ZpS4de98M6a+U7WBgmIJ3/0J?= =?utf-8?q?BHEZoiRaublZQpYLt4wIu1GoOlun3RxGg7GvlS4sb3Vl/NySI7Xom1uusUCVazZPo?= =?utf-8?q?6ctVdLHhpAue5pDQb6k3aUBVVFlYTgpkC1xY6s06cR41mUN+c9TePmHjClrfOx00b?= =?utf-8?q?xRy1Hfl5XIsBpEmL3HbGPCdr3n3Uc1fWjmA4dVBZ8c3y3rH0unZHIvvhnh1dmF/j+?= =?utf-8?q?MoyqeJocFx20eCnrMgj8w0rafjj/klIqSUAX40TZzL1Csf3PqyBRdTmxrjky8K92V?= =?utf-8?q?YuRjQNt48obKpJ85yyIDmyAEcHAwt/wk603p4EZAzSzDdETu2Yq7tCdY7VtsDfukX?= =?utf-8?q?cIWVwJuuLyJ49Of8J8iQbIApbHHxHOzvNZphYqfGvD/QhmclWWulwREr4LPAakagy?= =?utf-8?q?AEIfmxcaBK9xryt7v3TLWK67viSbJ7PnQtD1Bk5lkv48Z/fcAYB+TiLvBzqmGj/P8?= =?utf-8?q?AlDSgaKIBmx1Ab8RhBHsrhzm6M+0mMBDvaIpnd8ZxZRnQ42kjaYw2Pcw22YgeNfrX?= =?utf-8?q?F552keWWXMfe0Y30yJtq54y39U1IQNSQfSY4vBclvvlFo/GLQc5H1nzF7zWS4P7es?= =?utf-8?q?iunZYneLPoe5JzaKhAmzUEaDOL4fA7E7e5GFJoPpKgddV6xdm/mHbEgnRmK4B50da?= =?utf-8?q?ey+3+cSr30cL3yVn3K9H/X9zptxdtAXotFoTs+3MBtYRP/JqwmqWC8jSJ5npe1fef?= =?utf-8?q?pUIW+l/NOtZ4NFLbx9Td9IIPRfi1RYY3gkVOH4Unpi0/GXDoA/CerhYs7eWsDJCK0?= =?utf-8?q?jYdam2DrKpq1u5wXQeI4fV6bEX66JSzk+YmxrPEhhczV7sntbMOwf1sCfqoH/wMbA?= =?utf-8?q?D/WJWHTKi3rXhVpGrvrTPJ9AJY+5n0XeuXngiht0Mw8aGy4gQ+Bn3cnVGDmZmrRgy?= =?utf-8?q?63jJHL3Sdu76CcA7J6JvAXmuiwPjq0ckeTXH0oFYc/FqcmTTBBqq3e41/9Ha5BSK/?= =?utf-8?q?zUNQd+Zj3+NwpCxvP2oG/a76qUGP2CdkWKkWps60UO1IE2KSBdSRNgrsQ9PL2M5kZ?= =?utf-8?q?FVcTKeZcHehy?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: cdf2c7b0-1bbb-4eb3-b60a-08db3112736c X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 11:32:31.9872 (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: Nra8okp7oP/4xp1ofcR+glPqXrCweXrXZ4az4PviL4/+BEtvgNikhqFrvDON2gBoJssbW9tDICxGiuJsQFkLeQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8980 While 670d6b908ff2 ('x86 shadow: Move the shadow linear mapping for n-on-3-on-4 shadows so') bumped the amount by one too little for the 32-on-64 case (which luckily was dead code, and hence a bump wasn't necessary in the first place), 0b841314dace ('x86/shadow: sh_{make,destroy}_monitor_table() are "even more" HVM-only'), dropping the dead code, then didn't adjust the amount back. Yet even the original amount was too high in certain cases. Switch to pre-allocating just as much as is going to be needed. Signed-off-by: Jan Beulich --- a/xen/arch/x86/mm/shadow/hvm.c +++ b/xen/arch/x86/mm/shadow/hvm.c @@ -738,7 +738,7 @@ mfn_t sh_make_monitor_table(const struct ASSERT(!pagetable_get_pfn(v->arch.hvm.monitor_table)); /* Guarantee we can get the memory we need */ - if ( !shadow_prealloc(d, SH_type_monitor_table, CONFIG_PAGING_LEVELS) ) + if ( !shadow_prealloc(d, SH_type_monitor_table, shadow_levels < 4 ? 3 : 1) ) return INVALID_MFN; m4mfn = shadow_alloc(d, SH_type_monitor_table, 0);