Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp330721ybv; Wed, 19 Feb 2020 22:38:44 -0800 (PST) X-Google-Smtp-Source: APXvYqy/8we8ZdbocVVxgqlwe3r3aaIuCIJ5fv4ER5xnphCtIV8TzqY/fQpvE9oaDUAmHUm9DYE0 X-Received: by 2002:a9d:6b95:: with SMTP id b21mr21304314otq.96.1582180724209; Wed, 19 Feb 2020 22:38:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582180724; cv=none; d=google.com; s=arc-20160816; b=SShgqSnEJzeKB/UQPAeSGSl4Sb5jWhx8aRP4nYcJytEBLuHgF3YfOY6hRc8b5ES8rU DFLTQWZbeZZICa/la3r0R4FoiWLTzJZcFno3isnUhl/zs3rHe5ek1F2P6MjQzl9rCaVL TQNENRtsEHdTJfmg3KcdaRDIoF3KsZQMo2J1dXl1yAX+bMT1EIpw3PD6tvdSbxvWiDGj NCtZb9L9LOfyZKWwnCDNZTcZZc5p/UI0+XxWxo9IYnGRUG/z1QrV6NudhxYqpPis6ga7 T7noSjd6slM3vh2d/gvF7J+KXc7a1T8u0Wv4/1+tfXgj7+QflaMPzgo2GeeA3FWn4sp4 pilA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=MGSaquf6NuYuy5DKMUHzwdmIaNrjLgaO+G3S4LzfnGU=; b=RydVwxyCgm8FOC4tTaobpQYXWMvZs9/K56mriwugo2vCwZbsPsqNJXAr2OyHXTwpmn 5abELlmZqiV+y64qtOhEE6Nr0xxtnOwlJutfUOc7j0hfVecTXZfwfI69vHPMyTL+SIGN uxg2WLGnQDRqHqGOnDQr5DHWH6Li1A9SB/YZ+HauZoFamyKQggNJwug2ULYQNjU+LgMc jNb5yhK0ud8EpOUwKd5dDbyEP0cb7SQ6XQWLNcHpJm95AQuIbaraIBA9Co6WJ1Fpgjl8 1ezOQBBQeY3uekOrg1WcSuTUmR27uimHeKYgS50vRkkUZggCc9Zh13tlGgfq+GoZy7Q9 J8EA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m26si1233717otr.159.2020.02.19.22.38.31; Wed, 19 Feb 2020 22:38:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726310AbgBTGhY (ORCPT + 99 others); Thu, 20 Feb 2020 01:37:24 -0500 Received: from mx2.suse.de ([195.135.220.15]:47100 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725962AbgBTGhY (ORCPT ); Thu, 20 Feb 2020 01:37:24 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id DB201AD33; Thu, 20 Feb 2020 06:37:22 +0000 (UTC) Subject: Re: [PATCH] x86/xen: Distribute switch variables for initialization To: Kees Cook , Boris Ostrovsky Cc: Alexander Potapenko , Stefano Stabellini , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org References: <20200220062318.69299-1-keescook@chromium.org> From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Message-ID: <16a166da-c6e7-aa36-53a0-1b56197c8fc0@suse.com> Date: Thu, 20 Feb 2020 07:37:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200220062318.69299-1-keescook@chromium.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20.02.20 07:23, Kees Cook wrote: > Variables declared in a switch statement before any case statements > cannot be automatically initialized with compiler instrumentation (as > they are not part of any execution flow). With GCC's proposed automatic > stack variable initialization feature, this triggers a warning (and they > don't get initialized). Clang's automatic stack variable initialization > (via CONFIG_INIT_STACK_ALL=y) doesn't throw a warning, but it also > doesn't initialize such variables[1]. Note that these warnings (or silent > skipping) happen before the dead-store elimination optimization phase, > so even when the automatic initializations are later elided in favor of > direct initializations, the warnings remain. > > To avoid these problems, move such variables into the "case" where > they're used or lift them up into the main function body. > > arch/x86/xen/enlighten_pv.c: In function ‘xen_write_msr_safe’: > arch/x86/xen/enlighten_pv.c:904:12: warning: statement will never be executed [-Wswitch-unreachable] > 904 | unsigned which; > | ^~~~~ > > [1] https://bugs.llvm.org/show_bug.cgi?id=44916 > > Signed-off-by: Kees Cook Reviewed-by: Juergen Gross Juergen