Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1924194iog; Thu, 16 Jun 2022 17:33:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uEp7yU3Ks+HoJDn0XEyamrvCX7CRcIrMR13yGy2NRMQoIYngAe9aGpc7NW9NI2ybHfG9Te X-Received: by 2002:a17:903:2592:b0:168:9708:ad73 with SMTP id jb18-20020a170903259200b001689708ad73mr7290374plb.59.1655426001222; Thu, 16 Jun 2022 17:33:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655426001; cv=none; d=google.com; s=arc-20160816; b=ONmmW2tYjVWYKkBlYSxXlloJtEn58UDEQTT0gPVdAZiP+aMnbAXS/mkvo3O9hVNyBG kmM7xAAeS4+YCtoCsyh0KQcV171Qvin0HlxARaxk6VHIJbenklgchwV3minKdDU4yZml WmAxmhZKmDbvPHTIA+Uo6humbeF03fXxFjHz6F799SalolOd2Ucsg0+IfMfOM26Tysim oPU2t2RUV/3J0yV1hSiaYXOfYgH8w4dG7SPZTcywHIw7pX+fkrszjZwIYkDjQI8IeDv6 bkBCJx1DLZa+CBQdNbtduFsa/PzWZHQAZzDFeHo53fpxNgmUoB3yv74Y73At/6fhN3Iv CHVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=io8CZjDNsxDNt2a2JckWTmJznoi+vPqiO8J1er/GsfA=; b=Rxvkn14TRy02QuPCj5GLIWkRosAA+8GEOds5yqfcRANKIBU8MW8egEUGVSeiJgPgI/ /zQXi/BW9+pA0dpnUJP1cjDTRtjUA99wgmv8R/h3tgKJWKsTGMYJmlK0xR8h5D7tT5u6 ey/A9qjLxJKFGmRj6tEzgIyi0tZyHIltamiYAff6Pj+MDHGef+ApcXX0aZB5CkpEBYvM M7n0Wu6brPklQJwHriwof4Izz6EyQKhMUHQIHEL7ub6Agu2Xplq0nRjUJjt5dRtP3Ah3 7XdRyIFgC5iEdoXqePHJ08bhdoLZ+FAdkxtycSG+f4j9K2hNxNT8PRk955oaLD6Tp1QW 00Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dRFeizHB; 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 q9-20020a656249000000b003c626c711a8si4235185pgv.108.2022.06.16.17.33.06; Thu, 16 Jun 2022 17:33:21 -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=dRFeizHB; 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 S1379381AbiFQAWK (ORCPT + 99 others); Thu, 16 Jun 2022 20:22:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379274AbiFQAWJ (ORCPT ); Thu, 16 Jun 2022 20:22:09 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFB2B63397 for ; Thu, 16 Jun 2022 17:22:07 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id l126-20020a1c2584000000b0039c1a10507fso1620133wml.1 for ; Thu, 16 Jun 2022 17:22:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=io8CZjDNsxDNt2a2JckWTmJznoi+vPqiO8J1er/GsfA=; b=dRFeizHBQdzMUQAVLvSN7yWFOENeCVNr+n1Gu2uySpzuJNTL1YzNNM8sP6Fm6Wr4iy zKXSdfyeo/0VUUdCx2g/2OKB39F/sl5+l/YaadCnmMb9gIhS8zJgalu3Yu4Xm5ZlvEJS csb6cuG4F+MKQosWjbmXViwmbBL/CdEOETkkIyI8zGlNSP7ixq14qLenivvvXnnsslMS AGtM4UbVbR1o6ZxOxZWYhh+ReXbFVP8EHITFqwImWVF7ZYdRa7qUs6CBhI0EZ81jP7aZ 4IFSFwWni/+lgjBhbyJdfHYfZWiH6ZNVY7vrr+FeZI1bWc+zsLSfI1tcWLCr1IbmXrea By1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=io8CZjDNsxDNt2a2JckWTmJznoi+vPqiO8J1er/GsfA=; b=IaLXMd6Hq77cAWgfbARqeznMuYBfhmdl1/IbO+KuDBbTVC5/C/POG7FCVNmbeedRoV uLjZLOrOlqo3hYQlDVacK0GZ5Gw5Z9tozsfHXUx4a/2jJbykUWa8Vn8jhH32DClgB8Es ZYdruTr0mVfuENSKUNbVS33ntoW5qlpnNbxPAfvT5SdXAFEOqqgi8npHjVZG1rKwaEGo i0GvtxUVcRjifU1a18FLw64LKCB0sXu4TP90eYJdm91naoN4e3OMwiEx8+i7pD8FTckn gblPn0850SIJboMm3sWs6o0kiy6nGPxJLl1tO5N/S3piu9o6taEJmTDDJR569Mv0ms4V 5eUA== X-Gm-Message-State: AJIora/lof7qNjewKFkLdlyv1IoLd4Ftjf7HlemYsZrYsLeAcIGxwpaS CRywZ4uVPSBqVLC/qt2ekc1AbPQ8n+vYWqgqhyuaq64E X-Received: by 2002:a1c:25c4:0:b0:39c:9a08:452f with SMTP id l187-20020a1c25c4000000b0039c9a08452fmr7349817wml.199.1655425326210; Thu, 16 Jun 2022 17:22:06 -0700 (PDT) MIME-Version: 1.0 References: <20220606144509.617611-1-jiangshanlai@gmail.com> In-Reply-To: <20220606144509.617611-1-jiangshanlai@gmail.com> From: Lai Jiangshan Date: Fri, 17 Jun 2022 08:21:54 +0800 Message-ID: Subject: Re: [PATCH V3 0/7] x86/entry: Convert error_entry() to C code To: LKML Cc: Borislav Petkov , Peter Zijlstra , Josh Poimboeuf , Andy Lutomirski , Thomas Gleixner , X86 ML , Lai Jiangshan Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Mon, Jun 6, 2022 at 10:44 PM Lai Jiangshan wrote: > > From: Lai Jiangshan > > Add some C equivalent functions of the ASM macros and implement the whole > error_entry() as C code. > > The patches are picked and re-made from the huge patchset > https://lore.kernel.org/lkml/20211126101209.8613-1-jiangshanlai@gmail.com/ > which converts a large chunk of ASM code to C code. > > The C version generally has better readability and easier to be > updated/improved. > > This smaller patchset converts error_entry() only. > The equivalent ASM macros are not removed because they are still used by > the IST exceptions. > > No functional change intended and comments are also copied. > > The complier generates very similar code for the C code and the original > ASM code except minor differences. > > The complier uses tail-call-optimization for calling sync_regs(). It > uses "JMP sync_regs" while the ASM code uses "CALL+RET". > > The compiler generates "AND $0xe7,%ah" (3 bytes) for the code > "cr3 = user_cr3 & ~PTI_USER_PGTABLE_AND_PCID_MASK" while the ASM code in > SWITCH_TO_KERNEL_CR3() results "AND $0xffffffffffffe7ff,%rax" (6 bytes). > > The compiler generates lengthier code for "cr3 |= X86_CR3_PCID_NOFLUSH" > because it uses "MOVABS+OR" (13 bytes) rather than a single > "BTS" (5 bytes). > > ALTERNATIVE and static_cpu_has() are also different which depends on > what alternative instructions for ALTERNATIVE are. > > [V2]: https://lore.kernel.org/lkml/20220516131739.521817-1-jiangshanlai@gmail.com/ > [V1]: https://lore.kernel.org/lkml/20220511072747.3960-1-jiangshanlai@gmail.com/ > > Changed from V2: > Fix conflict in arch/x86/include/asm/proto.h in patch7 > > Changed from V1: > remove unneeded cleanup in patch2 > > Changed from the old huge patchset: > squash some patches > Hello, ALL, Ping Thanks, Lai