From patchwork Wed Jun 9 13:14:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12310091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3944BC48BCF for ; Wed, 9 Jun 2021 13:15:14 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E00F5613BC for ; Wed, 9 Jun 2021 13:15:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E00F5613BC Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.139370.257735 (Exim 4.92) (envelope-from ) id 1lqy2y-0001pz-6E; Wed, 09 Jun 2021 13:15:04 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 139370.257735; Wed, 09 Jun 2021 13:15:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lqy2y-0001ps-2o; Wed, 09 Jun 2021 13:15:04 +0000 Received: by outflank-mailman (input) for mailman id 139370; Wed, 09 Jun 2021 13:15:02 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lqy2w-0001pm-5l for xen-devel@lists.xenproject.org; Wed, 09 Jun 2021 13:15:02 +0000 Received: from de-smtp-delivery-102.mimecast.com (unknown [194.104.109.102]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id b99d3d57-45c5-46df-ae00-645cd10f6bcc; Wed, 09 Jun 2021 13:15:01 +0000 (UTC) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01lp2055.outbound.protection.outlook.com [104.47.0.55]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-35-NK8jlv9RPZaJjPs-9_P21w-1; Wed, 09 Jun 2021 15:14:59 +0200 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB4944.eurprd04.prod.outlook.com (2603:10a6:803:60::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.29; Wed, 9 Jun 2021 13:14:57 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::f06c:6f5d:34d2:1c36]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::f06c:6f5d:34d2:1c36%5]) with mapi id 15.20.4219.022; Wed, 9 Jun 2021 13:14:56 +0000 Received: from [10.156.60.236] (37.24.206.209) by PR0P264CA0116.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:19::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Wed, 9 Jun 2021 13:14:56 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b99d3d57-45c5-46df-ae00-645cd10f6bcc DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1623244500; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ujG2q1YnMDOR6+z6mxxei0XuEaxDYgCI4hRLLdDBk1E=; b=AxXMCzB7BRWA0VXhit7GLMBzhRcKGWi3dt8hdVYrI7DuCsU6mead3EhLNXBOqMe0XfG4fB yOKmb9DC26qwKdu2BqHULk2c5hQKr286/Er9FrELJc3eL6yZcxU5aKpy0YRZGcHbnwgKPt qkYQyUgj5SsoyUrvP/OJJMClm7u6d+c= X-MC-Unique: NK8jlv9RPZaJjPs-9_P21w-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iXnweP5JzaN7p7O6XJowXSVHMJC9jhUVCFitY2glRnvsI82ft2rYfZNvFKQLAoQl0YkbpberIEpMVhz33RBQMgPy/vCMYaqSo0CTKMG16zPPEhMSPr2LRLQXYlxdEjCzAEBV4cioz9rPvS8xUrwPJrV2ejTB4bv5rS7LPjB07wkcOxQUacoJIIB/Ky0RWe9MiSZieQk4eU04HLv3NmOwDxJXJlB3wdpX6c65A0EVlLspSVEvfcRXHjhXxsMPofYwxJZkkuK59GQo5dQ5JBrlcjp63jyTBDyLBDgSKeh+DpYAL0pa51H9byH1Jl6f31RUmv93TaTh2y/KxLJ7KgBVXQ== 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-SenderADCheck; bh=ujG2q1YnMDOR6+z6mxxei0XuEaxDYgCI4hRLLdDBk1E=; b=difdWQzC0iONMX96ob2VamGGhhzlMF3aNrF5IOuNJdgYeRbI2tEpWMdUuNm18enJ0PKgS5+XQcbDHpsWE1he0La7OlhXkD4U/yHSOUke5+bt2swPUETNLSUD1A+Qkwt+XybNoxwNCe2uiZBlGlZcqyz7vhByUFKvy7KTRJ+PDjUh+rohPg1qw2BeCPaYL59vtLszaUzNgCFHbInMMDytYxkX739ILB7kiD7cLhQVQXTCEP9NpwPUpSBsLfF7y2biOv9W9t6iktYVzmNPNVtgx4qDUYDezdE8Fuzl/4vAGexv8PcE0xMRUP9uEETQe/eMF8Ghm2VSK5ZVWipsbP5pjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: citrix.com; dkim=none (message not signed) header.d=none;citrix.com; dmarc=none action=none header.from=suse.com; To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= From: Jan Beulich Subject: [PATCH] x86: please Clang in arch_set_info_guest() Message-ID: Date: Wed, 9 Jun 2021 15:14:54 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 Content-Language: en-US X-Originating-IP: [37.24.206.209] X-ClientProxiedBy: PR0P264CA0116.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:19::32) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2f9ed265-cfdc-468b-30b8-08d92b4893d4 X-MS-TrafficTypeDiagnostic: VI1PR04MB4944: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GVziiPIpjx4+ldEy8/FJcgd1VYjTTuyGiYY6ISlUpRGgrgHYSvO2OX/9HngjY3rqySQRgf7VxvxKlN6w0zOp0McZIy4XA5l79b8UJnOl4jZfRBsC8OaA7BQ6NIXjgFEKGOicDnD2zeAyj7YzZa52BmmJ0Rjij2rq5eqk2MsRhN7x6A6SfR0HGd6AjVx0QiFPOIls/4qvS2myBjzsaQsOtTVPJW17/5plQOV0WHRKTMgMtuat9MnJ7ArlpCa+KxUQN080+VzHt70mNjM1f7+MzazbUHsEQkE1dXMH8UzskmjIeMUmRhT9lFuQWRt21zs7HRnWCl2aoi5Pt2FzNIMxKsnHojhpLqjQfwj/idfCBFi4yK6pBwtmLXtCxo//3FTxJCLEFIBr3xEehwM+ZeEUI82ivgbm4e7DlHJcwVQBlMIbfOBxCplfhTtGjDYAUUcIAdSaLozDyRACz7G0Yp82u/w126OpLG2xAgQb8Ggab5wC4kQ5Z8Y5J36u5wsHtzQORFvOAEbalbMf6AwwTNctkCotiWFFyKihucCVDxlrW7mAo470U4dT82+MrHOaf72ETIYJIL+0eKxWXV2mN7c2CQ9+mYgUz35Zn30uZ36atIhOGek4fXX8YHpLJGoRGXW1752ovRgDLaImrXvCwJG1ZI7IadniBh9QPEQCd8I1rLAGzQ139n0+VXyapQ2Cqp31 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(39860400002)(376002)(366004)(346002)(136003)(36756003)(6486002)(4326008)(2616005)(16526019)(86362001)(186003)(26005)(956004)(316002)(2906002)(6916009)(31686004)(38100700002)(54906003)(8676002)(5660300002)(8936002)(83380400001)(31696002)(66476007)(66556008)(66946007)(16576012)(478600001)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?5vgzV2rdBciJTg7WKiStT9bAXsZpDq?= =?utf-8?q?4P2PA4h1vdhx5HpOai27MpIYsHfsH7DZZJq2hMdxoDA9r7SDTS3pH446WxONolK3n?= =?utf-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?q?tJwjTkO3K1itn9hosykGRiQ2j6pmX3dFyI8NA8BCUK7PYNN/JT4YNrlJ5HJ3u6VWY?= =?utf-8?q?gKWn2bnJ3O5D9RGGFmVahzJL7Y+3jBhUBdVYQabFWpixziO3yvpc5g+5CUK6UzQ2M?= =?utf-8?q?OUbuozmAZzJ8geP2IrttdiUFE6HvB8ZMQi+a00t+jj2pT8IjfeNg/o86OjMeGNYBr?= =?utf-8?q?V0gtvf362pFxgM6JPv0ighpM9tt7sR+kQnefZ3j6qvpv2KNumQEzHIOfvtsqTAvwh?= =?utf-8?q?/IyF9BSbbK8A95/ogtWG/YWFTQ65CSjNKXlRSM0ckyFbG8sDsenYUxmuGaVAU3yc4?= =?utf-8?q?SkNNwUtS+a5XLM?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2f9ed265-cfdc-468b-30b8-08d92b4893d4 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2021 13:14:56.8371 (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: NtiwqQyQtY6TUFRBUhfQtfYeQHjCh7GA1++86AKDwoJk591Hy43ucz/E2T87Z+J7GK+6tGnPhHcQaGFZU1I4lQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4944 Clang 10 reports domain.c:1328:10: error: variable 'cr3_mfn' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] if ( !compat ) ^~~~~~~ domain.c:1334:34: note: uninitialized use occurs here cr3_page = get_page_from_mfn(cr3_mfn, d); ^~~~~~~ domain.c:1328:5: note: remove the 'if' if its condition is always true if ( !compat ) ^~~~~~~~~~~~~~ domain.c:1042:18: note: initialize the variable 'cr3_mfn' to silence this warning mfn_t cr3_mfn; ^ = 0 domain.c:1189:14: error: variable 'fail' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] if ( !compat ) ^~~~~~~ domain.c:1211:9: note: uninitialized use occurs here fail |= v->arch.pv.gdt_ents != c(gdt_ents); ^~~~ domain.c:1189:9: note: remove the 'if' if its condition is always true if ( !compat ) ^~~~~~~~~~~~~~ domain.c:1187:18: note: initialize the variable 'fail' to silence this warning bool fail; ^ = false despite this being a build with -O2 in effect, and despite "compat" being constant "false" when CONFIG_COMPAT (and hence CONFIG_PV32) is not defined, as it gets set at the top of the function from the result of is_pv_32bit_domain(). Re-arrange the two "offending" if()s such that when COMPAT=n the respective variables will be seen as unconditionally initialized. The original aim was to have the !compat cases first, though. Reported-by: Andrew Cooper Signed-off-by: Jan Beulich Acked-by: Andrew Cooper --- I wonder how many more there are to come. --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1186,7 +1186,17 @@ int arch_set_info_guest( unsigned long pfn = pagetable_get_pfn(v->arch.guest_table); bool fail; - if ( !compat ) +#ifdef CONFIG_COMPAT + if ( compat ) + { + l4_pgentry_t *l4tab = map_domain_page(_mfn(pfn)); + + pfn = l4e_get_pfn(*l4tab); + unmap_domain_page(l4tab); + fail = compat_pfn_to_cr3(pfn) != c.cmp->ctrlreg[3]; + } + else +#endif { fail = xen_pfn_to_cr3(pfn) != c.nat->ctrlreg[3]; if ( pagetable_is_null(v->arch.guest_table_user) ) @@ -1197,16 +1207,6 @@ int arch_set_info_guest( fail |= xen_pfn_to_cr3(pfn) != c.nat->ctrlreg[1]; } } -#ifdef CONFIG_COMPAT - else - { - l4_pgentry_t *l4tab = map_domain_page(_mfn(pfn)); - - pfn = l4e_get_pfn(*l4tab); - unmap_domain_page(l4tab); - fail = compat_pfn_to_cr3(pfn) != c.cmp->ctrlreg[3]; - } -#endif fail |= v->arch.pv.gdt_ents != c(gdt_ents); for ( i = 0; !fail && i < nr_gdt_frames; ++i ) @@ -1325,12 +1325,12 @@ int arch_set_info_guest( set_bit(_VPF_in_reset, &v->pause_flags); - if ( !compat ) - cr3_mfn = _mfn(xen_cr3_to_pfn(c.nat->ctrlreg[3])); #ifdef CONFIG_COMPAT - else + if ( compat ) cr3_mfn = _mfn(compat_cr3_to_pfn(c.cmp->ctrlreg[3])); + else #endif + cr3_mfn = _mfn(xen_cr3_to_pfn(c.nat->ctrlreg[3])); cr3_page = get_page_from_mfn(cr3_mfn, d); if ( !cr3_page )