Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1018469pxb; Thu, 9 Sep 2021 18:08:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGKK0skhOMiqHe3V23zSRFtBQnzRPoztp5m2duxbhTL4kayOn7rxGaBL58h3RsBnoIShjc X-Received: by 2002:a17:907:d09:: with SMTP id gn9mr6504995ejc.447.1631236115948; Thu, 09 Sep 2021 18:08:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631236115; cv=none; d=google.com; s=arc-20160816; b=Bzpv6kqMy2EsA+nMGGrf8W7hEXUlwUZTuhqgcgFT0ipL5K45eEbeD2lgrnZjjHtyr7 XsykMOEJWjCbRGU1IZByhh5O+uSpcSzKs5juKWtOtkI46y+hP8aECuIvWhUIHIvfSqEr uQigaYGstWdw3wGeXx9ioeMt1dgBDhYv/qhKBdccxEOG1H7DBcCsuXoIr+H1QmWpv2fx GRTHbqA/djiJkzGHL6oRg3outi5ew3SiY3dQlYsq+ZijJX7TbXMKwjC0EDkh6Pl00Xrb vfGPJNZJu9DtbXKlUOoaKDOooDL1PShWa5u0T1+P5ksRmJjIUvyjsPC9UL7nP6YY6pFW vhaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:from:subject; bh=p3QaK/VgysOJTtoVrFT/u8ckxMDLtqAeH5/9TWZLtQc=; b=TEGaEy7iMcJzaxAIa2kD1dAwttVH3FtfK3meIFRaS2SvUBeWHRMu4psKdfuvB0PIww klW9KXgzq/c8kqMKA+HR4Pf2cvgJKYeNpRW74F2C6lUCISaJligbwEXETIMMNFoUOD0m BVddaEL7rqGq9ktoel7Qo3+o3OG4R7iDt+lcbI1vdjEyVdMIyLQwZzEBA+NQlk5kTlUN Sd2DcPk/qKWB9Zo7bhBaPf9WsKhubo7kYomk8yT4felXVZcqk0VyiklW8a+SMX8mPesV RZBgmua1k8PLOtVfITHF0hGuczzQVStUb53lOpKMbsYV5tQVLl/ZjXpKnD2DL60LVG+F Akxg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c19si3529369ejj.206.2021.09.09.18.08.12; Thu, 09 Sep 2021 18:08:35 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234954AbhIJBHQ (ORCPT + 99 others); Thu, 9 Sep 2021 21:07:16 -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. >> >