From mboxrd@z Thu Jan 1 00:00:00 1970 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=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 7BED3C4363C for ; Sun, 4 Oct 2020 09:59:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 49C58206C1 for ; Sun, 4 Oct 2020 09:59:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725916AbgJDJ7t convert rfc822-to-8bit (ORCPT ); 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-pm@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