Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5404475rwl; Mon, 3 Apr 2023 20:21:38 -0700 (PDT) X-Google-Smtp-Source: AKy350YW2T46ZyMEnG5dXd3+zvst21zlLxWbGY4CoSYOXwVgonRk4qCk2W6yHiC3ozCLRERCSnNg X-Received: by 2002:a05:6a20:b930:b0:cb:7958:7071 with SMTP id fe48-20020a056a20b93000b000cb79587071mr938708pzb.19.1680578498058; Mon, 03 Apr 2023 20:21:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680578498; cv=none; d=google.com; s=arc-20160816; b=gaVn6i7zwZOlcOB25SKa8zANCxzf7lnDHTCTvUYjQi7y6maXMIf0W/2k0jMt6Vv0M2 QdTqd8DqBTVajnoEdjGbQ1LWa+tJdSX7q33zb/FAx13lBhQJkFJbN6FTwq8DNprGQoOl 12PShPNFqXCi0OmNTCipeR9GSlmN8vksQMCIW+pSaz8UHJrIUTgJXALX6mHmW2vGNePe U+/zWVP40gvPVy2w5dY96tViJFuScPhKopt0PmIigPNxVBs7yqeQ3mMhqvpP3Lsux8MO gZicPDvEMRc+BDkrBEqrFoe+ev2JaOO/wgE0bvqLeohesjz3j8etwa9M4n1wGg8yLJuI tSEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Qs3Bti2bEU1Z0C12LLTnFbjadt184MNl6VTmS9vvdvA=; b=jtklyb14ryyjdSo8Iiueux00ZO8w2tU3hTbIH5anWf0+U51kakBTCncTDivomq3xBO 2yvs8LhmccKxw6pLrltasO80L3BlbPd9WuD/KNzZcjGjIQ5QUg1t/3Q/59lvH3H3IDmc 6jrY8VK3yeNYzW1PFk43J9X1DPboWLlN7g/vefC+VV33Lth1chOLv9Ox/ibNo5Nn7SZ2 80fITjwAno1bTaeW1n7jIUD9AaYCx2aA8eW6zvXEYJ3fUYyAVsIWPJvFRw66dL1DhZIq 5PG6avIp5Z7fUCcd9PwDoY0XXr4iW5pZXe5jLIsl3bqK1Ttoq66rPQCOHntWD8rWNlxK dLHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ULfEnAJ5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z66-20020a636545000000b004fc257265cfsi9184809pgb.267.2023.04.03.20.21.23; Mon, 03 Apr 2023 20:21:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ULfEnAJ5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233027AbjDDDRr (ORCPT + 99 others); Mon, 3 Apr 2023 23:17:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231546AbjDDDRp (ORCPT ); Mon, 3 Apr 2023 23:17:45 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 237A6FB; Mon, 3 Apr 2023 20:17:44 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id lr16-20020a17090b4b9000b0023f187954acso32594487pjb.2; Mon, 03 Apr 2023 20:17:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680578263; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Qs3Bti2bEU1Z0C12LLTnFbjadt184MNl6VTmS9vvdvA=; b=ULfEnAJ53opqKjbgs64Ovk34Ol+tT+bg9RrqVWjw5LWPaU60crwA/Zobsk3+pYV5aA M46unl3ZvJn82ASeNzWgz5+bbeBQZ4t1hXoOFc1BaXgjmuZPD7Vc4TsJ38962NntvHw3 rLJc3LUDj9224mn8ipU1wZf2tN3en0ufLPwrNFWDusZ7bV9dcSe3Ixx3pIXByPGtECJM qA2CH/4ZC3vGVsnNHvY67wLIUB++z4OGo8madgRMnz5C8ogko/rNsvmjkT/Dx/60Q+rp Vvj36xMh/64sMAtVLRRiszVIV5lkkMjaWfkQ+QpJmQa1/COYKRW5dCWdk1AEklBJccPB qhjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680578263; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Qs3Bti2bEU1Z0C12LLTnFbjadt184MNl6VTmS9vvdvA=; b=vKCEwHulihQBSTQ33ksgv7N7aIdNOW2E0r/AGnIuqtKs84XedgxcvAr0FnifsfrKds HFQkZjEcyqNeZfdQbS/hibg6EWgL6VgJIyDksHX1KDh/rDjl71g+7BAcpwur72Dkpwyf eX3TxhjCyb081D//0yiqIixtpPnOGBT4PQ8rhuaZMl91hCvSuDSm1bJCUFiT/b0G6jPQ 7dmKgmVPTxf4gBj8OKZW5MMwhh5B8ZUwAGYPpjPj2g/J+rdiqb1yu5qRTkM/GzjyHWmb SeFQuN5Tqj0Ho41fDcRWOdyn/WRiHMu/RQtBF7vOiUr5bOkxgT9es4Fc42MFOBaEuBHl Zirg== X-Gm-Message-State: AAQBX9cgbL0zfLTl03qRDW9YNGjaPDCFoofOl6reudxJCrpzVcvj1sL8 tP6/Sz2MGfuEd9daOSygabwD1Kl+iDMwPRqbiSE= X-Received: by 2002:a17:902:f683:b0:19f:1d62:4393 with SMTP id l3-20020a170902f68300b0019f1d624393mr446573plg.7.1680578263546; Mon, 03 Apr 2023 20:17:43 -0700 (PDT) MIME-Version: 1.0 References: <20230403140605.540512-1-jiangshanlai@gmail.com> <19035c40-e756-6efd-1c02-b09109fb44c1@intel.com> In-Reply-To: <19035c40-e756-6efd-1c02-b09109fb44c1@intel.com> From: Lai Jiangshan Date: Tue, 4 Apr 2023 11:17:30 +0800 Message-ID: Subject: Re: [RFC PATCH 0/7] x86/entry: Atomic statck switching for IST To: Dave Hansen Cc: linux-kernel@vger.kernel.org, Lai Jiangshan , "H. Peter Anvin" , Andi Kleen , Andrew Cooper , Andy Lutomirski , Asit Mallick , Cfir Cohen , Dan Williams , David Kaplan , David Rientjes , Erdem Aktas , Jan Kiszka , Jiri Slaby , Joerg Roedel , Juergen Gross , Kees Cook , Kirill Shutemov , Kuppuswamy Sathyanarayanan , Linus Torvalds , Mike Stunes , Peter Zijlstra , Raj Ashok , Sean Christopherson , Thomas Gleixner , Tom Lendacky , Tony Luck , kvm@vger.kernel.org, linux-coco@lists.linux.dev, x86@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 4, 2023 at 12:53=E2=80=AFAM Dave Hansen = wrote: > > On 4/3/23 07:05, Lai Jiangshan wrote: > > Documentation/x86/kernel-stacks.rst | 2 + > > arch/x86/entry/Makefile | 3 + > > arch/x86/entry/entry_64.S | 615 +++++++------------------- > > arch/x86/entry/ist_entry.c | 299 +++++++++++++ > > arch/x86/include/asm/cpu_entry_area.h | 8 +- > > arch/x86/include/asm/idtentry.h | 15 +- > > arch/x86/include/asm/sev.h | 14 - > > arch/x86/include/asm/traps.h | 1 - > > arch/x86/kernel/asm-offsets_64.c | 7 + > > arch/x86/kernel/callthunks.c | 2 + > > arch/x86/kernel/dumpstack_64.c | 6 +- > > arch/x86/kernel/nmi.c | 8 - > > arch/x86/kernel/sev.c | 108 ----- > > arch/x86/kernel/traps.c | 43 -- > > arch/x86/kvm/vmx/vmx.c | 441 +++++++++++++++++- > > arch/x86/kvm/x86.c | 10 +- > > arch/x86/mm/cpu_entry_area.c | 2 +- > > tools/objtool/check.c | 7 +- > > 18 files changed, 937 insertions(+), 654 deletions(-) > > create mode 100644 arch/x86/entry/ist_entry.c > > Some high-level comments... > > The diffstat looks a lot nastier because of the testing patch. If you > that patch and trim the diffstat a bit, it starts to look a _lot_ more > appealing: > > > arch/x86/entry/entry_64.S | 615 ++++++++-----------------= ----------- > > arch/x86/entry/ist_entry.c | 299 +++++++++++++++++ > > arch/x86/kernel/sev.c | 108 ------ > > arch/x86/kernel/traps.c | 43 -- > ... > > 16 files changed, 490 insertions(+), 650 deletions(-) > > It removes more code than it adds and also removes a bunch of assembly. > If it were me posting this, I'd have shouted that from the rooftops > instead of obscuring it with a testing patch and leaving it as an > exercise to the reader to figure out. The cover letter has 800+ lines of comments. About 100-300 lines of comments will be moved into the code which would make the diffstat not so appealing. P.S. One of the reasons I didn't move them is that the comments are much more complicated than the code which is a sign of improvement-required. I'm going to change the narration from save-touch-replicate-copy-commit to save-copy-build-commit and avoid using "replicate". copy=3Dcopy_outmost(), build=3Dbuild_interrupted(), the new narration will change the comments mainly, and it will not change the actual work. If the new narration is not simpler, I will not send it out to add any confusion. > * Flesh out the testing story. What kind of hardware was this tested > on? How much was bare metal vs. VMs, etc...? It is tested on bare metal and VM. It is hard to stress the bare metal on atomic-IST-entry. The testing code tests it in VM and the super exceptions can be injected at will. > * Reinforce what the benefits to end users are here. Are folks > _actually_ running into the #VC fragility, for instance? > > Also, let's say we queue this, it starts getting linux-next testing, and > we start getting bug reports of hangs. It'll have to get reverted if we > can't find the bug fast. > > How much of a pain would it be to make atomic-IST-entry _temporarily_ > selectable at boot time? It would obviously need to keep the old code > around and would not have the nice diffstat. But that way, folks would > at least have a workaround while we're bug hunting. It is easy to make atomic-IST-entry selectable at boot time since IDT is an indirect table. I will do it and temporarily keep the old code.