Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3547405pxk; Mon, 21 Sep 2020 17:26:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDMeuJtgBe/dFRZ7o+/jGv+1RB3TQl+3zJCP9/Y6pa9t1wEfQZbSW+5nYAm7vtgY5iiFfG X-Received: by 2002:a17:906:cc98:: with SMTP id oq24mr2158053ejb.106.1600734417615; Mon, 21 Sep 2020 17:26:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600734417; cv=none; d=google.com; s=arc-20160816; b=f5KXCE9coGBg1m3d7c9+pH6tOu/6UwGGX+2zfNHwGudsy/syR2WX1H3s1X75uEAkc8 O+ALvn8GUBxUK2xDcuw+wDCeNpajrhVXaW1debGI11eig0rBuFnnvBbyi1Kpz6sYHD8f 4bdZzvRM+F9prpWoOqSSBBel5xvKGeMKDD3aVdwL33Q7QW6OWwODsxSYCN/NSLlkVFfd JPQyqdoiEnUO0/bFkOaZN5vyONzST4NlyOpoyEKPE5ka7xEpcvQ8tUCXkX0dJygmOfv7 0alpK3EZyIS6FId01TF6rwc5WwVWSq2w86TE6akh6LpkFghPspOI2OKsM5fnPWWtOOf3 1/bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=lhpvAZ3QErKtUDQl7kJDzrjuCD9QQ90HcO/B4IQrDrI=; b=NHVV4uSsejYgHesPjja8ltM2jv+MKXqu1bN/As+OCqWwo3cHOOzH/4K7BJT57Q5/h1 LgiRVZcaLltwRochAvjNktuFtA5yxBrU9ti/UeKWT6f2M1SMCWRjygr7RvcdnEem54Gz pHanvGQMXNMkwdsjGJ6bKrdpRGhTB6sSQY++mqMTjSo0AGqFUC63Ou45oRh1ZDKZ+eMA qsf3aA4iXjPE7rUNiZ/5M9ye4M43pJCrTCNDbm3fq5tjmfQTqRSxwuEUUGprOq31JXbx E96MoAuSfftN7IawtW81Nc14wdyYYklDuOwa3OGHxEdUTSnWWQVWx/2iagt/px9xdgQm BxtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ErhlL2wM; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g23si9045109edv.304.2020.09.21.17.26.34; Mon, 21 Sep 2020 17:26:57 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=ErhlL2wM; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728803AbgIUX3L (ORCPT + 99 others); Mon, 21 Sep 2020 19:29:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728704AbgIUX3L (ORCPT ); Mon, 21 Sep 2020 19:29:11 -0400 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B172EC0613CF for ; Mon, 21 Sep 2020 16:29:10 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id b12so15949750lfp.9 for ; Mon, 21 Sep 2020 16:29:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lhpvAZ3QErKtUDQl7kJDzrjuCD9QQ90HcO/B4IQrDrI=; b=ErhlL2wMGJFM/QNL+KbYCiAAKOWrQijX/gN+f1xx8U0cagqtSYaVr8wYsg00BjLzxx 0YyOVt54yWPhwFYFRtg/y+Lks95cV6JY8ef4GlavUbMApcs27uC9Y+boxrw7GnYuQJW4 2/tQBuwZ0oEVjyUMGe8bqInifFd6VJaenyM5Sgy3gPJpJAibgLScsMthO2Zw0pu0M7du LLdAAxsFU+qvcTGzrChilGjTiH08PMt1RvPiv0jsy/p6XhqTamaqVKlB6cQ6N9C5XNV6 1oa6Hs9NiIPq8rAWnNciqvdmgCw5g1TUmazAjrMyWxv8SeqaZiBSHnKy33HLU5dxzv1u reYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lhpvAZ3QErKtUDQl7kJDzrjuCD9QQ90HcO/B4IQrDrI=; b=XYsb3gr5Ai4RJTthWIxAI666ZQe8MniJYj3vX7zl66wZnCgIZ3xj5a6IbsmiI71uha 5PbW2C+R0sp0Df+j8GZxjIEJ3/a8lAHmNKedVToZu+1x72DkcAQ97iS5L9R6T6c7hjE9 9Y57okvS9OSmC1WwRgUDVf6JzmxXz3dCsJSEPcyMtPv/QxgYFp1AONedXLXtjXSIjrvI cdbpWEcpm3se5WVmwvCfbUpV275TYE2SFNpLFDmb6m/kAIeZxeYiZvsKI3/b2cj0imHn CNi61kEmkssDwZH7aVUptLqLoiw4oszrBSDPslnPjDQIniXfinZuVrL/Q1pz58UaRYTP qgZg== X-Gm-Message-State: AOAM531JlhHoPFKYj+d58msUH0Acfq8VULeYrZqo21w0M9qLvZ7B50AF kzSK2e8fF2RR+f6LZIVMSbQu0zgu8mINNJt1S5LsEg== X-Received: by 2002:a19:dc13:: with SMTP id t19mr617798lfg.350.1600730948713; Mon, 21 Sep 2020 16:29:08 -0700 (PDT) MIME-Version: 1.0 References: <20200915172658.1432732-1-rkir@google.com> <20200915174643.GT14436@zn.tnic> <20200915182730.GW14436@zn.tnic> <20200918222531.GD7443@duo.ucw.cz> In-Reply-To: <20200918222531.GD7443@duo.ucw.cz> From: Roman Kiryanov Date: Mon, 21 Sep 2020 16:28:57 -0700 Message-ID: Subject: Re: [PATCH] arch: x86: power: cpu: init %gs before __restore_processor_state (clang) To: Pavel Machek 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 18, 2020 at 3:25 PM Pavel Machek wrote: > > 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. > > > > 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)? Regards, Roman.