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=-11.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL 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 9F024C4727C for ; Mon, 21 Sep 2020 23:29:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6066E23A65 for ; Mon, 21 Sep 2020 23:29:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ErhlL2wM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728857AbgIUX3L (ORCPT ); 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-Google-Smtp-Source: ABdhPJz4YutrmrjOwYZG2RGNgLOZ0aUYNOGbqakuENM0brWNTF2tMcddEnlheCzTQcWh6UftGJr12yvyrGh7Jya1nQk= 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.