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=-7.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,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 526CDC433EF for ; Fri, 10 Sep 2021 01:06:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D0D1610C7 for ; Fri, 10 Sep 2021 01:06:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235413AbhIJBHS (ORCPT ); Thu, 9 Sep 2021 21:07:18 -0400 Received: from out30-42.freemail.mail.aliyun.com ([115.124.30.42]:60205 "EHLO out30-42.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239286AbhIJAiB (ORCPT ); Thu, 9 Sep 2021 20:38:01 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=laijs@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0UnqfhRh_1631234206; Received: from C02XQCBJJG5H.local(mailfrom:laijs@linux.alibaba.com fp:SMTPD_---0UnqfhRh_1631234206) by smtp.aliyun-inc.com(127.0.0.1); Fri, 10 Sep 2021 08:36:47 +0800 Subject: Re: [PATCH 17/24] x86/entry: Introduce struct ist_regs From: Lai Jiangshan To: Lai Jiangshan , linux-kernel@vger.kernel.org Cc: Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Joerg Roedel , Youquan Song , Tony Luck , Juergen Gross , "Peter Zijlstra (Intel)" References: <20210831175025.27570-1-jiangshanlai@gmail.com> <20210831175025.27570-18-jiangshanlai@gmail.com> Message-ID: <01b8f2d7-b987-47c5-0436-1535031fde05@linux.alibaba.com> Date: Fri, 10 Sep 2021 08:36:46 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/9/10 08:18, Lai Jiangshan wrote: > > > On 2021/9/1 01:50, Lai Jiangshan wrote: >> From: Lai Jiangshan >> >> struct ist_regs is the upmost stack frame for IST interrupt, it >> consists of struct pt_regs and other fields which will be added in >> later patch. >> >> Make vc_switch_off_ist() take ist_regs as its argument and it will switch >> the whole ist_regs if needed. >> >> Make the frame before calling paranoid_entry() and paranoid_exit() be >> struct ist_regs. >> >> This patch is prepared for converting paranoid_entry() and paranoid_exit() >> into C code which will need the additinal fields to store the results in >> paranoid_entry() and to use them in paranoid_exit(). > > This patch was over designed. > > In ASM code, we can easily save results in the callee-saved registers. > For example, rc3 is saved in %r14, gsbase info is saved in %rbx. > > And in C code, we can't save results in registers.  And I thought there was > no place to save the results because the CR3 and gsbase are not kernel's. > So I extended the pt_regs to ist_regs to save the results. > > But it was incorrect.  The results can be saved in percpu data at the end of > paranoid_entry() after the CR3/gsbase are settled down.  And the results > can be read at the beginning of paranoid_exit() before the CR3/gsbase are > switched to the interrupted context's. > > sigh. Sigh again. IST interrupts can be nested. We can't save the results in percpu data unless we make it stack-like which is not a good idea. The changelog failed to express it. > >> >> The C interrupt handlers don't use struct ist_regs due to they don't need >> the additional fields in the struct ist_regs, and they still use pt_regs. >> >