Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1009141pxb; Thu, 9 Sep 2021 17:52:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw44voSsQoQo94Mu80GvCX0x6cE9EAja+QwfsX4EmgvggvCyrAASERjl8Q4LxloVO5QYSVG X-Received: by 2002:a17:906:7154:: with SMTP id z20mr6446776ejj.547.1631235130404; Thu, 09 Sep 2021 17:52:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631235130; cv=none; d=google.com; s=arc-20160816; b=wI0JvcaKeRYly9utO7XSP+kUmm4gGuP5fpiEQVsenCMToGaHFvF7iijtPjJsetLDu5 X9RVh0fRDvWyoLv1K1mVpsSTbSXVQ4jSJ8Mb1mG03JpX67cNgtmfxlZyQPVJY0+dm8a4 VsCGkseHkMAgzClg75zRXaTGkBx35uqci7XPqYyTFoumRtMHB4aSpOPhxyQ/k+acsrzT 7BydUh0oICMdLZXEseUUygRDDVeCZFQVvQ8iyjj9DGDGGE4M8ebUFkKykMKiizc1RNrq eacmGsQckHgl532/0e170eWSXaV7Tz09lTQxM07lrU5ktbnnby+WXqGqM69mOWMUufEd WHzQ== 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:from:references :cc:to:subject; bh=yawdtQZ+DlrbK8I8IfqygPISaJXJPcC5nK+zDBREYzI=; b=o24HdIlpIfRPV3BGnWsDx63S/FYHf6Ill0TJiacDI89qcl0ey29bpjm03iK70AD8NY oHuRm25kOuCmD9MOWQ3OtoTVb6p2pVAmPacWCOqfN2r+yMM9ANJtMK/x93YdSnB/2Bnx JeAc5J9q6hsTYymw6Z95TjBQhMLQ50FKIuSLVNRUnCdyP6B0iwiuh7L8xnvL+PVj0csa 4799LFxTvTbUXW+Sa1rSyyAU4jAVUqJ7kLAXOkkwYhfu9K647QqR3jflB6ep7h0MtWAu rXpOsS3Ha+1sz2ABoIbh7gEp1AxqEmWji/TxgMpNV1BNLrQ9c1tlbQ5UhBGYrGqJJ6a1 PIlw== 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 n9si3430113edw.373.2021.09.09.17.51.46; Thu, 09 Sep 2021 17:52:10 -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 S243257AbhIJAty (ORCPT + 99 others); Thu, 9 Sep 2021 20:49:54 -0400 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:36237 "EHLO out30-56.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233498AbhIJAUM (ORCPT ); Thu, 9 Sep 2021 20:20:12 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04420;MF=laijs@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0UnpwgrP_1631233127; Received: from C02XQCBJJG5H.local(mailfrom:laijs@linux.alibaba.com fp:SMTPD_---0UnpwgrP_1631233127) by smtp.aliyun-inc.com(127.0.0.1); Fri, 10 Sep 2021 08:18:49 +0800 Subject: Re: [PATCH 17/24] x86/entry: Introduce struct ist_regs 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> From: Lai Jiangshan Message-ID: Date: Fri, 10 Sep 2021 08:18:47 +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: <20210831175025.27570-18-jiangshanlai@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > > 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. >