From nobody Sat May 4 11:14:10 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=chromium.org ARC-Seal: i=1; a=rsa-sha256; t=1582179842; cv=none; d=zohomail.com; s=zohoarc; b=Hjwa58GZlRh4EzIrP5hUsjqx+JMubtt7OvmwWe0RwBP7JO9Sd30/rRO1pBgy6A1EKVJWWKOeR1LXgqwSFBY5Dik9srDtCg64stK09X9DJ4xL1vbvxJ18cGW9m5AN/d42Ds8ljN1xTLSXwLUkFtY1xNwLPTIEhnJ+/OijwiS5HgQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582179842; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=nNRhxlyY34T2MfR+bXRrr5Xi8YY/mvspraZgHdPHd0o=; b=KsNEio24jKRN70QfWPJkWGKpCUWMQYbyjjVOv1MQUEGkoATOZs7fiMSckHI7pIb80Nne+vnU/jtP7EtmWJqqf6PYoscfYeDjEN099jnRpC3YS1H7uYOGEgjxl0hjzbn4ljPazUSSazbbY3Y05F3PCJDSROFHzsg64Rmnr3xgTTY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1582179842994423.3804171146303; Wed, 19 Feb 2020 22:24:02 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j4fF4-0000Sx-OU; Thu, 20 Feb 2020 06:23:22 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j4fF3-0000Ss-Vl for xen-devel@lists.xenproject.org; Thu, 20 Feb 2020 06:23:22 +0000 Received: from mail-pj1-x1043.google.com (unknown [2607:f8b0:4864:20::1043]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7d961a5c-53a9-11ea-b0fd-bc764e2007e4; Thu, 20 Feb 2020 06:23:21 +0000 (UTC) Received: by mail-pj1-x1043.google.com with SMTP id e9so430363pjr.4 for ; Wed, 19 Feb 2020 22:23:21 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id 3sm1760480pfi.13.2020.02.19.22.23.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2020 22:23:19 -0800 (PST) X-Inumbo-ID: 7d961a5c-53a9-11ea-b0fd-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pK6zifq3Fj1hZPmmtdvS+UBS/FWrDP/7PRY/z1oHHl8=; b=KZPJA/xXWgvj7+EDceNGW99DsMGfVsrwZtMNYFEQmEcfbi6t1Ltywm8yF3gRS+KFsW YYa/KruX+agIH6tt/eZGI71UjpwjuT3jsuFYNKw+P7dbnGut/vUuytmTV4wCLvbb1OWN mFx5qdjyKzEPpPz0IfGRUIg5ongLMg7FFfcz0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pK6zifq3Fj1hZPmmtdvS+UBS/FWrDP/7PRY/z1oHHl8=; b=cEB9S8aIKqH0zoTjeE9VMtpHNCeHbhGAd/RZGnf5KgksZO92k1V+f9DcP2QvI1N0AF Hk1vSmOE6Vy3vIq+Y2S1JZl9QkRSHxAG4BPrqSwXNxMUwclbdQhZJxtv2g164iktZiPo 65BDH8gu68VBT2z9CUkbCm2Vdyff+20EP51STFf9F8ieL/a9OTTxfQkcJaANaSvpV89C mqRY6ehWJIQ7U9Oim9s1EuXMoIBRfQ5oHMSwNBAOQi9NkwV0iRgv5kh1TXjOnWY7nXMQ N1xfZCrR6SVdoFR6dDsZOwwVxJyxIBCYzzG22jCUPeUQYfnv5Fk0qWNxKEHvPT+HbMSx pgsA== X-Gm-Message-State: APjAAAW31zwB07iYOX0TzfeWiSnwOmDgcJyJmqlAtY35yfx1SF7CPHQP aPA60XqfYBnsbeMt72WwcBlEJw== X-Google-Smtp-Source: APXvYqx1kik6D0tY4SYKS7j1S0Bqg7hWpfmaq2nth5vTea0tU8wMl9ddGmg2GgyqqThc+95RG3/LrA== X-Received: by 2002:a17:90a:f316:: with SMTP id ca22mr1759190pjb.59.1582179800527; Wed, 19 Feb 2020 22:23:20 -0800 (PST) From: Kees Cook To: Boris Ostrovsky , Juergen Gross Date: Wed, 19 Feb 2020 22:23:18 -0800 Message-Id: <20200220062318.69299-1-keescook@chromium.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] x86/xen: Distribute switch variables for initialization X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: xen-devel@lists.xenproject.org, Stefano Stabellini , Alexander Potapenko , Kees Cook , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=3Dy) 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 =E2=80=98xen_write_msr_safe=E2=80= =99: arch/x86/xen/enlighten_pv.c:904:12: warning: statement will never be execut= ed [-Wswitch-unreachable] 904 | unsigned which; | ^~~~~ [1] https://bugs.llvm.org/show_bug.cgi?id=3D44916 Signed-off-by: Kees Cook Reviewed-by: Juergen Gross --- arch/x86/xen/enlighten_pv.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c index 1f756ffffe8b..789dc12b7962 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -896,14 +896,15 @@ static u64 xen_read_msr_safe(unsigned int msr, int *e= rr) static int xen_write_msr_safe(unsigned int msr, unsigned low, unsigned hig= h) { int ret; +#ifdef CONFIG_X86_64 + unsigned which; + u64 base; +#endif =20 ret =3D 0; =20 switch (msr) { #ifdef CONFIG_X86_64 - unsigned which; - u64 base; - case MSR_FS_BASE: which =3D SEGBASE_FS; goto set; case MSR_KERNEL_GS_BASE: which =3D SEGBASE_GS_USER; goto set; case MSR_GS_BASE: which =3D SEGBASE_GS_KERNEL; goto set; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel