Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1531626pxk; Fri, 18 Sep 2020 15:27:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUHeMJ4bOIeIFAk1BK4M3EgxrfVDiM39sEZRXI/ob27+szaOu2lmIoK/jM17LYKhSuTdsO X-Received: by 2002:aa7:d04d:: with SMTP id n13mr42357531edo.354.1600468033664; Fri, 18 Sep 2020 15:27:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600468033; cv=none; d=google.com; s=arc-20160816; b=lD31Fp2V22Ip3Z5oS0d1EQ93C42Juo7FOt/EJbxaZ+bJzRcTXLWm0yGuVctKz4A7Yj 7ZZNHymYBm89UGe2T/vrbqLo6eQPSUDPIFQ75sKqZQ4KxPYILTtKgVbJfYfsC8J3Iq52 A1jQZE2s21DK4Ufo6HB/U38MmBFaYucSbNbG87mcQkB2rnIyYhcD0HEA8QbWJVq5W+Tx Tex7ajWl0OKhNZM3cqUjxK9zAAaC7WPqVlzCqh37Y/G7dmooc4Hr2MuKTNwDTLL99g5V 0t74VoQAEE4f3+FpH2sgmohb2xQ/q3ktt1Et0oumbBbHzK8LfCxPUMUB6yuNaZWkGElP RlxQ== 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-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=uvGKz1sFE+o1CSfrrplQKJoF19xX7m4i5mRKt1rmGJ8=; b=Dmj7bh5WRlG9Bxdbq9q0Osmb8J7A60YbQqUyllHVjSO53rLx/J6AMBArC2zgeeD6Q7 mSuLRmlLYA7IiSEgGiCWUr9QEvqBW5UGdbTWF11LniD/SdC4ZvM5qIe0vnJkAbzLwXlj MDJkl/oNMruXYZCkLsSS0Zov8tW3KdYK9GQHWn1JdXi9UdQn81Mq+RyoQQRlr5XaDEPR ahm+qMKIGl9tPbcyf64p3omrz9Pn/meVZJI9+Xk/Lpm/0m4Y1xdZimyEGosFedrrFXVU jtw6m7pCKq7iquQtWXiQiskbwgwc9qvN/b2aeBju2A9q8UlBjnJwe2iycOQqM2TtyP+J ysZA== 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 c24si3189579eja.263.2020.09.18.15.26.50; Fri, 18 Sep 2020 15:27:13 -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 S1726185AbgIRWZe (ORCPT + 99 others); Fri, 18 Sep 2020 18:25:34 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:41310 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726134AbgIRWZe (ORCPT ); Fri, 18 Sep 2020 18:25:34 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id C90C91C0B78; Sat, 19 Sep 2020 00:25:31 +0200 (CEST) Date: Sat, 19 Sep 2020 00:25:31 +0200 From: Pavel Machek To: Roman Kiryanov Cc: 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: <20200918222531.GD7443@duo.ucw.cz> References: <20200915172658.1432732-1-rkir@google.com> <20200915174643.GT14436@zn.tnic> <20200915182730.GW14436@zn.tnic> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="RhUH2Ysw6aD5utA4" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --RhUH2Ysw6aD5utA4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue 2020-09-15 11:36:13, Roman Kiryanov wrote: > On Tue, Sep 15, 2020 at 11:27 AM Borislav Petkov wrote: > > > 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. >=20 > This is fair. Unfortunately I am not an x86 asm expert. I expect the prop= er > 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. Best regards, Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --RhUH2Ysw6aD5utA4 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRPfPO7r0eAhk010v0w5/Bqldv68gUCX2Uz2wAKCRAw5/Bqldv6 8kNgAKCjTg2A11mig0JlRnhrDpMSV8Je1gCgu1Podyh1Zl2y7FFnMx3zbtS9RV0= =9X7o -----END PGP SIGNATURE----- --RhUH2Ysw6aD5utA4--