Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2537691pxk; Sun, 4 Oct 2020 03:02:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1D1mwjqc7TKysPh2TQt0WrtlTnv3IAKX5DBXrr7wDw5V61hAtEF2uesHLnroDQrPPT0or X-Received: by 2002:a05:6402:7c8:: with SMTP id u8mr11902791edy.153.1601805727247; Sun, 04 Oct 2020 03:02:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601805727; cv=none; d=google.com; s=arc-20160816; b=X/feKOyDua2uUsxjc47ziwkRpqnndt71DmG6mkQUHQ/G+1hrUiDzEKaQvpa/nO0S3G 2FFx7c75WLDI25fYkVl/CmHw4cGu9DMuu52nav9IfFO+MUILgD3AsoCN7Nx4A5Inxjjc x48PHywj3KqGcRrBmNoe0JgMPy2smyH0xS8/37hQv3usjektZqmtehHyhsLZTDAGjdu6 qghoWd0dC/HaxPCgBqFs/aGalD8Ag50xYLUuB67LFXnqC4pzzQkAynChr7Jja4msINS2 Ut+v8TC4UiNfclU0HJ6mei/aUKgFJwykd+9BOUI2mg/4H0sIfWf3bi4pzl7CTacFHwHW F9jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Vxs/+SW/Qe6g5RZ7T57n6KEorFpJiDgCVKfkY9rxq7E=; b=lLJVkP30DwXtLrXlCklwxZEFhX55gMfJHhOc8tBdJf22miz9C7vl6rkI5mPJQ6Wj1G eLCKwL1WMOR2FBTdx8/gkfj8HH6FRXopWszhczFV2Vd4fjtiJYO7Iq250CkUS6BcC3de AG/TEs+wHd5tyLL/KTdlp40KexOULjI3Q2CUHtg5RdDVzaPs66zsQEEnMzcLf/x14cIR 4a45YbQb7V9DKwMLPPqtMHE1Fsnqobx5IMqqDhkrzV8iKZVDDayKpuv1xM1EcdI6zJ+E NGJ1fUCAqV6Hx7/bwCCiGXTWd/4p9x4ekw7m3Bri5XvFOKmPccHPLcYgxWV3P/LehUga /i0Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z12si5283657edm.560.2020.10.04.03.01.44; Sun, 04 Oct 2020 03:02:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725994AbgJDJ7t convert rfc822-to-8bit (ORCPT + 99 others); Sun, 4 Oct 2020 05:59:49 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:49918 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725825AbgJDJ7q (ORCPT ); Sun, 4 Oct 2020 05:59:46 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 5CFD41C0B76; Sun, 4 Oct 2020 11:59:44 +0200 (CEST) Date: Sun, 4 Oct 2020 11:59:43 +0200 From: Pavel Machek To: Roman Kiryanov Cc: Pavel Machek , Borislav Petkov , rjw@rjwysocki.net, Thomas Gleixner , mingo@redhat.com, x86@kernel.org, linux-pm@vger.kernel.org, Greg KH , Nick Desaulniers , Alistair Delva , Haitao Shan , lkml Subject: Re: [PATCH] arch: x86: power: cpu: init %gs before __restore_processor_state (clang) Message-ID: <20201004095942.GD1104@bug> References: <20200915172658.1432732-1-rkir@google.com> <20200915174643.GT14436@zn.tnic> <20200915182730.GW14436@zn.tnic> <20200918222531.GD7443@duo.ucw.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: 8BIT In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi! > > > > > I believe the kernel makes a questionable assumption on how clang > > > > > uses registers (gs will not be used if stack protection is disabled). > > > > > Both kernel and clang behaves unfortunate here. > > > > > > > > If the kernel is at fault here and this same thing happens with GCC, > > > > sure, but this is a clang-specific fix. > > > > > > This is fair. Unfortunately I am not an x86 asm expert. I expect the proper > > > fix should land into arch/x86/kernel/acpi/wakeup_64.S to init %gs > > > (maybe some more registers) before "jmp restore_processor_state". > > > > That would certainly be nicer / more acceptable solution than patch > > being proposed here. > > > > Code was written with assumption compiler random C code would not use > > %gs. If that's no longer true, fixing it in wakeup_64.S _with comments > > explaining what goes on_ might be solution. > > I looked and restore_processor_state is referenced in several places, > so changing > wakeup_64.S is not enough. Is moving the beginning of restore_processor_state > to an .S file ok? I see restore_processor_state initializes CR registers first, > do you know if there is a reason to do so (can I init segment > registers before CR ones)? Yes, moving to .S file should be okay. CR first... makes sense to me, they really select how segment registers will be interpretted, etc. If it will work the other way... not sure. I'd keep existing code if I were you. This is tricky to debug. Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html