Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2317405rwb; Sat, 8 Oct 2022 06:02:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4HHqhmyOvHXWLj8i8smoQvarU52cJb24IXMC9vc0nzYkNKaZSMhPiO/sl6YLfg4FqG6gq6 X-Received: by 2002:a17:902:b589:b0:179:f8c5:7212 with SMTP id a9-20020a170902b58900b00179f8c57212mr9884686pls.174.1665234132866; Sat, 08 Oct 2022 06:02:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665234132; cv=none; d=google.com; s=arc-20160816; b=HhHDKwevy8hk2/+eJsqF5cJULsTGRplsCUdbPUDGw1t+BuW492kmfT8dQcrrA3NbBu qBMdoztshkIENoT4TfieRUuE9I5HWE8lOh66FH+LUJwr94b8aDKiu2J6sYLx34IeuULW +DAX5jgi78uCyvIyhwN/84lrPrtTvWepebwyqhOpAn7jYU0arhob+4ahb6AkJ0QPYTyv e3QNEEyiZsFiqRaK9ujC5AVjOYLXbpMqlLkJPMVbbs/kcvE5UdqgPosDrT895UNiKf1M EYIWZvJBikaOUqizuVV6cFnAdO5+K6WHQM6wsqqb4ZWT6Lhb/T2aHX/P7q4a0h068F9O jR6w== 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=CQeqKM4cX5wLbNYTV5WzNxWIUu9O9xoqEIDAJBgyPUE=; b=z9qtpG839rink/utYEn53W1irLU7cGqHKyqqDGT/KEE3JODPDR8Vcm/jgJm0X2+QX7 a62z4f6PaQmgiOwsdj+INszR7AGdlHquks3c9+GoMshqw91uPNvJhcKzryGgu/UyuX3m NdBJlzXD7g05qygXD8BLwdSL8a3LSXTUPVfVyFAQoeSpNEPJFsgVsx0bY8+WGgPC5LRS tao/kVY5dUwUYHwSrcD9nMllNh8nEAlJ+XWtkRAds/S5Ld8poQgbWuTR09f0zx+Ba9P9 56+m7J36y238j2TmCYrYVp4pCaUS/g/vFNPQZmsDB3bn/4+w0XpxXbPa4APc7Oel3uJi 4kbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Yzc+yyCT; 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 b17-20020a170902d89100b0017a0582050esi4975598plz.59.2022.10.08.06.01.49; Sat, 08 Oct 2022 06:02:12 -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=Yzc+yyCT; 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 S229481AbiJHMkV (ORCPT + 99 others); Sat, 8 Oct 2022 08:40:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbiJHMkT (ORCPT ); Sat, 8 Oct 2022 08:40:19 -0400 Received: from mail-oa1-x34.google.com (mail-oa1-x34.google.com [IPv6:2001:4860:4864:20::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD2572F01C for ; Sat, 8 Oct 2022 05:40:18 -0700 (PDT) Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-1364357a691so1728475fac.7 for ; Sat, 08 Oct 2022 05:40:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=CQeqKM4cX5wLbNYTV5WzNxWIUu9O9xoqEIDAJBgyPUE=; b=Yzc+yyCT6AvcVQzVoHfV0l6juxjzxajCTMpICrIyvm/dHrYKZc0EvOuO5xqecvAIZZ jENBxCxZNYjdITjOBomGwBnaFdh4/dRqNvXJNd8imkInxBvX0143Ehquoae/qIs7oDNP Esv2ri9qqhdYtCYBez+IWzll5XZXXS15IH87jhE+CbkbsNALbf+j3Q32PizSMC3Ppg0K aZ8HahOx08Goyb6DoKMzuq5v9IsZ/TIB3laAl8VZZwBzwQSM9xJq6WykZiPxd3/3g2hU M9i9Z/Kp+pzf9bAJITB+YLkX0STL0BSomTJGWCob9QmStA8ztO0Ut1sbrvMMnAxxJjps 66cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=CQeqKM4cX5wLbNYTV5WzNxWIUu9O9xoqEIDAJBgyPUE=; b=3sGmpIFCWpdBlVOqTTsCTm0LZ8A9L/Wi4kwjOE/YChzj23MlMJdsbqs/d2erkkeFig VxsTXq5jqJzpqMWJXfr+YE4yr/2ROVVAkpNNOwxGMfv4fjWU6dKWLw57eH3eyCTin8ix dU24b1rUgHLXwieFZBGvQ/2mERXTjwnBZ/M9gniW+G7MgagNDX/r5+E4B3PDykZdXAgg ERxHJkwaM5mVMqH5i0+sP6f4hbRtT+EsyvCS5TjZr43i4Ponj+3wKVM1wSCkfGu4PBzs hBQkTLZSkmJR76ny8+OSb5lZu1xLkebVZnoSQh+Qt8JqahMZOfwhZGs8Q9mkTFEhXqlQ pqjQ== X-Gm-Message-State: ACrzQf2jxBy60KvXeNezH7KuzM7FKwr/l9yW6+U4QVSeKkxLhoVo6lcE SbKlKy8YXRNZPdWonB7/+M5Ds6F1rCL0gqgaBXpynQY= X-Received: by 2002:a05:6870:8a09:b0:132:554d:2f3d with SMTP id p9-20020a0568708a0900b00132554d2f3dmr10623536oaq.194.1665232818117; Sat, 08 Oct 2022 05:40:18 -0700 (PDT) MIME-Version: 1.0 References: <20221006154041.13001-1-xin3.li@intel.com> <20221006154041.13001-7-xin3.li@intel.com> In-Reply-To: From: Brian Gerst Date: Sat, 8 Oct 2022 08:40:06 -0400 Message-ID: Subject: Re: [PATCH 6/6] x86/gsseg: use the LKGS instruction if available for load_gs_index() To: "Li, Xin3" Cc: "linux-kernel@vger.kernel.org" , "x86@kernel.org" , "tglx@linutronix.de" , "mingo@redhat.com" , "bp@alien8.de" , "dave.hansen@linux.intel.com" , "hpa@zytor.com" 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 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 Sat, Oct 8, 2022 at 1:40 AM Li, Xin3 wrote: > > > > + alternative_io("1: call asm_load_gs_index\n" > > > + ".pushsection \".fixup\",\"ax\"\n" > > > + "2: xorl %k[sel], %k[sel]\n" > > > + " jmp 1b\n" > > > + ".popsection\n" > > > + _ASM_EXTABLE(1b, 2b), > > > + _ASM_BYTES(0x3e) LKGS_DI, > > > + X86_FEATURE_LKGS, > > > + ASM_OUTPUT2([sel] "+D" (sel), ASM_CALL_CONSTRAINT), > > > + ASM_NO_INPUT_CLOBBER(_ASM_AX)); > > > } > > > > > > #endif /* CONFIG_X86_64 */ > > > -- > > > 2.34.1 > > > > There are not that many call sites, so using something like this (incorporating > > Peter Z's suggestion for the exception handler) would be better from a code > > readability perspective vs. a tiny increase in code size. > > The existing approach patches the binary code thus we don't need to check it at runtime. static_cpu_has() uses alternatives to patch the branch, so there is no runtime check after early boot. -- Brian Gerst