Message ID | 0998689a-91b1-e381-ac63-a485ab2cb65d@suse.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show
Return-Path: <xen-devel-bounces@lists.xenproject.org> 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 4F4DFC3DA7A for <xen-devel@archiver.kernel.org>; Thu, 5 Jan 2023 16:06:53 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.472043.732140 (Exim 4.92) (envelope-from <xen-devel-bounces@lists.xenproject.org>) id 1pDSlN-0005uC-H7; Thu, 05 Jan 2023 16:06:41 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 472043.732140; Thu, 05 Jan 2023 16:06:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from <xen-devel-bounces@lists.xenproject.org>) id 1pDSlN-0005u2-EI; Thu, 05 Jan 2023 16:06:41 +0000 Received: by outflank-mailman (input) for mailman id 472043; Thu, 05 Jan 2023 16:06:40 +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 <SRS0=lIpW=5C=suse.com=JBeulich@srs-se1.protection.inumbo.net>) id 1pDSlM-0005kL-2C for xen-devel@lists.xenproject.org; Thu, 05 Jan 2023 16:06:40 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2087.outbound.protection.outlook.com [40.107.104.87]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id efab7802-8d12-11ed-91b6-6bf2151ebd3b; Thu, 05 Jan 2023 17:06:39 +0100 (CET) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AS1PR04MB9432.eurprd04.prod.outlook.com (2603:10a6:20b:4d8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 16:06:37 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2991:58a4:e308:4389]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2991:58a4:e308:4389%7]) with mapi id 15.20.5944.019; Thu, 5 Jan 2023 16:06:37 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion <xen-devel.lists.xenproject.org> List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-devel>, <mailto:xen-devel-request@lists.xenproject.org?subject=unsubscribe> List-Post: <mailto:xen-devel@lists.xenproject.org> List-Help: <mailto:xen-devel-request@lists.xenproject.org?subject=help> List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xenproject.org?subject=subscribe> Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" <xen-devel-bounces@lists.xenproject.org> X-Inumbo-ID: efab7802-8d12-11ed-91b6-6bf2151ebd3b ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l4YhXWejcZbws13WDR0aSs6oVQoxmssMvS6YypsZTBokNSZJ9iiDVsXHqYHgXkdAsoHjvCFIlfg7kr7p/fCVUxfHLrUSQkICw6Ia+Fc7LirDbF/np3/oebizf+9HFM8Aa6CLSUE2kytICE0Ung6Z3fnGylwiwiOlaPkZAs6dpMWGkeM9ODMRASQh+paGb5CFWgR0Kv/5kz5+GtxeTPabRc4SfKhoUJx3LHmXbZ7EPwE+QcwXyAueXy/Dxbhi4asxcjtP3L3SptiRsNmTCoWBHaRV2vHFuELT4Wwx27l4KucBIlNNOY7RTEIPiR8o8uvBGZ7AMXTqNPYfJS1VKqqzgw== 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=iBgM5VtWVqIkPoDCOPK8xEPFq96mp+OUcLEBtT+07eA=; b=ZlHpO0xn9nPfqrWGjoomxwjgSXtoEQvCZAtYBuqneles+J7jyoz3PlESkWmfdEhpcr78533t5xqRSPwQIL5VA3MOGUVoexYKzIw5wvhP8hwX+oSUv5U+0jCcXnpViZVaQeTaSIf3tonW5XLKp6SgjpoWnnMBFDplXIkUKybfRJEEG1XwpBME47OLP8NyYexaNHdbVojtKNljyp7RVnuELpO6I7wP2lW29QB05peTl/Qwve25GNtEZ/uDPw+2PIwJdQFmFOyDbe4g+eHfCyRJ6m2VulvlssUI+OMeEEwl2nlhbH/qxnjVRhuqgp5N5LmaGg5NsIS6FIANbjwC12M0Iw== 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=iBgM5VtWVqIkPoDCOPK8xEPFq96mp+OUcLEBtT+07eA=; b=l7VkZDgN1vWhY7eQ1WCKwhL2ReJP9SDbXcsvQtxT5n+FxK28rOKERP3bt16/JyPsrrEWCkQAvumNn6xhlvx+xLZ4+npqJ9LAZMjpp3CVJoCxkahqcASK1myTLVKI5durFKN+jaFOIBpVzia5qThqnKtg1LNVAY7dfRSfqy0k5KBc3IYtkkPFZXDYu4U6a4hFWZb9NRtdVDX9pPnyhzsjiXZKka6+mZFaPkXl2c9D7b00gpIflcJqRh9wgwhaVisykP2hc4xLOWL9qoraNHYeVjFSUMy/JKWLEU8KpU6lyhjAJmpkTSfYGRzhzAjdYKh+IUnhEIlPJGmvtNcRL19+/A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <0998689a-91b1-e381-ac63-a485ab2cb65d@suse.com> Date: Thu, 5 Jan 2023 17:06:36 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: [PATCH 09/11] x86/shadow: simplify conditionals in sh_{get,put}_ref() Content-Language: en-US From: Jan Beulich <jbeulich@suse.com> To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org> Cc: Andrew Cooper <andrew.cooper3@citrix.com>, Wei Liu <wl@xen.org>, =?utf-8?q?Roger_Pau_Monn=C3=A9?= <roger.pau@citrix.com>, Tim Deegan <tim@xen.org>, George Dunlap <george.dunlap@citrix.com> References: <074dc3bb-6057-4f61-d516-d0fe3551165c@suse.com> In-Reply-To: <074dc3bb-6057-4f61-d516-d0fe3551165c@suse.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FR2P281CA0010.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::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_|AS1PR04MB9432:EE_ X-MS-Office365-Filtering-Correlation-Id: 3af18b23-60d9-47d6-01bb-08daef36d320 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vJ6piFQCYG2spTAB6SysG6x25rneJH89bOIqSUkifTZp+K99hrxhrqqMMJKy2KNR/rxGmpiCT4keIHBmCT3Pqe5be1Hy8aTH9IqiNvknbiAA7SyAdozGkaTHQj/muOIf9PIP+gSoqTQH1TyMOOklJ0Gy+iODzINriRUgt50lN+MCSMGS3Q1YjCCd+bShJ/AY8fJ5ayVW5o5yKWaYftAwRcOiaTGOsjvLs1Abx14HJxZlh9rkxsEms1wyjjbOwDBIf7wDXy+hepIdiRfSGkvg07f+OMBmhLCJjYig45Tseq2No2d36zylFjOJcNpQvESBAOOYJ3XBJ0tZVj8fMq3n41TIBdTWP+DA++mUFl1Tf7mUe6adGxWZYvrBwX5mNzagu7HtyOParcy40mZOsUG2xZVMYfbN5mK4/aSL9m2cw1Kga/SK54insiK4jLMy9bItbiGQqGvQ87dw1VeXQJTD5+MZhjAzJFpnM8MKTxRNYUWvZOGTiKDpW2LnoizoHRbl/hrvIZvjYrNnsNUdJ2tYfRA/45xqoBR95x4ADAAhMDh8UVetEgElTz/FFXXZLlx+vVO/aaQsXmOEYhxoFhUjIGLWfE18gjRyOj0hEzjtw1QGjb2NeY6gAXg8NERqbEAKusPkWz7msIuWxd2YxVlZAntaBZlMkKEStNTzY4OAwPHp6teQ7Vm4hSRz7Uhh7F6GYJiwuMPYfmnrvOybkbP8ij3lIMycyPXz8NuEsIROTcs= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(376002)(136003)(346002)(366004)(39860400002)(396003)(451199015)(54906003)(6916009)(31686004)(26005)(186003)(66946007)(8676002)(6486002)(66476007)(2616005)(478600001)(6512007)(66556008)(41300700001)(8936002)(5660300002)(83380400001)(4326008)(2906002)(316002)(6506007)(38100700002)(31696002)(86362001)(36756003)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?+i0zNbxw37kF1uAwcepOeJ+SKjh0?= =?utf-8?q?HUkNSdfkhSMzEDv+U2ph6oEQT/6T9zjUtK37ORw0/HhJIcM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tdG6P?= =?utf-8?q?XtqvLGi5dA+1vt/dhDD+JvsKoUMQUKXny2WrOCa0WObwZGhN0LNGxwQjqGW6py/23?= =?utf-8?q?Rdq0fXNnTq4wtp9q4cEmcEsZqUhHpxLMyaTNxgwuRXnNNhZu1cIZHjVPnfX54FZpO?= =?utf-8?q?HTyeTIKkWnFU3hHPiNiZz588F8a3V3SfnZxYsFL0taDFStFKgQKPoaJaLjU9e1KNp?= =?utf-8?q?J7V6K1tAfplLp5uJW10pkJ+ZFTVBiZ34LuxRHgJ6w5LGIb0Ioa42/EqCEUdy9TW85?= =?utf-8?q?S5lolMTAK30rSc33bj+sdcF8mRtjmPQQnI0IYsDgettMhRsoybxWqyEV3W9gW5aeX?= =?utf-8?q?wfdTeZrjt7LupFOHdm4oU0y5LTOBUAkbmoDXvtBT/pRtTv/OPXedfp++GDaJkijOE?= =?utf-8?q?U1z4I4s8HB2Vknok4bLIzznBHEY7wse4dXaoIsWYfvLlmgfB1oe7lsYAA8g72gjVb?= =?utf-8?q?CRll843vl7OzYghjjgxkltaSxiyCnivlKlK47wuAh4yUK4qqZLDhb/cDRFojzQ62i?= =?utf-8?q?MvWNmUU1I6koE9+iFL4ByWeXAGpn0T5lvns/kXl87K/7131dPJJ+ijeNtPiyTDbDa?= =?utf-8?q?Q7TftyWUyokf?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3af18b23-60d9-47d6-01bb-08daef36d320 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 16:06:37.6802 (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: d54P2iPN7JaHNZZWMtCb08lWhqROSGJ6/zUqKXb7t54PlXli06etdxO9gupjKq5uyxcP6sjcp+wb4ne8smx/xg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9432 |
Series |
x86/shadow: misc tidying
|
expand
|
--- a/xen/arch/x86/mm/shadow/private.h +++ b/xen/arch/x86/mm/shadow/private.h @@ -586,9 +586,7 @@ static inline int sh_get_ref(struct doma sp->u.sh.count = nx; /* We remember the first shadow entry that points to each shadow. */ - if ( entry_pa != 0 - && sh_type_has_up_pointer(d, sp->u.sh.type) - && sp->up == 0 ) + if ( !sp->up && sh_type_has_up_pointer(d, sp->u.sh.type) ) sp->up = entry_pa; return 1; @@ -607,10 +605,11 @@ static inline void sh_put_ref(struct dom ASSERT(!(sp->count_info & PGC_count_mask)); /* If this is the entry in the up-pointer, remove it */ - if ( entry_pa != 0 - && sh_type_has_up_pointer(d, sp->u.sh.type) - && sp->up == entry_pa ) + if ( sp->up == entry_pa ) + { + ASSERT(!entry_pa || sh_type_has_up_pointer(d, sp->u.sh.type)); sp->up = 0; + } x = sp->u.sh.count; nx = x - 1;
In both cases the "entry_pa != 0" check is redundant; storing 0 when the field already is 0 is quite fine. Move the cheaper remaining part first in sh_get_ref(). In sh_put_ref() convert the has-up-pointer check into an assertion (requiring the zero check to be retained there). Signed-off-by: Jan Beulich <jbeulich@suse.com> --- RFC: Strictly speaking accessing ->up ahead of checking that the type actually has an "up" pointer is UB, as only the last written field of a union may be read. But we have violations of this rule in many other places, so I guess we can assume to be okay-ish here as well.