Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp707772rdb; Fri, 17 Nov 2023 10:17:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IHouIMH8IaNmm/AmJsnaL43FiQZN+y7Np5Sh0+mlIFD6rlguGrEk4c/eMBSuFa6dZNiYTlg X-Received: by 2002:a17:902:ec82:b0:1cc:5549:aabd with SMTP id x2-20020a170902ec8200b001cc5549aabdmr504979plg.8.1700245026633; Fri, 17 Nov 2023 10:17:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700245026; cv=none; d=google.com; s=arc-20160816; b=HJj0atCpfdMHgsTCtaBcm09Ph4SAYRLagYcavDRYMz35dupJA33faAuXIwiTvtzU2d Tbi0w4YrdNrvnQQo8f3KBtmxb6TQFJQ+nwrUs6O0FryIyhh72jJIHMUauJY+jWzJAS9I oNBe1OD5LuJPaTJ8jWet/1AL1Al0hZ9WpKfKRpXCpeVk035I59DD90W3eelXMqUjqs+0 htKVVwEuxjhhHn7XbCMAWX8IVUbOqXnJoYLOYl3kB+VlzUo/zb5sjyVktMVXsPjQ65DX jGqe9V1JaoZXge8VkEY4OLSQSatet1iGtvXrTr1DBYTg9NnJ23bA32kfxjhcqaCq7RKv IsAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-filter; bh=rldfpkIKQWTQW6V8Tvh/c478ucg2EydlDLInfQStja0=; fh=dZ8SuL6XhPFTs3Fi37x0IKm9Z4lNvfyKZc5pKmgAApg=; b=UtVyWXzmfHq2EgWoB9vvUQfTODzCcXnNs5QDUxma/Xz29pE4PD6v9ztYDXG45NygMP C5Ca8zh9J4t/VXdJ0g4UEgIFD/ZznNwLxXVLFHuKPfXBPQ3BRmJTNXmm2dompWXlQ/pW aHvVaeWSgoPMm1YBxc8raSz0k8NZ5xXBQxKX8X3v23pKgzIGfvwLqbOA3X6bl0XMv4t6 MHiLqPJFG0yaXDXFP7Fef/R1y1iiituaGMNk0nOSRA1QjypXpRUiEkKevEUXrZn9kk5M YCzAababQTNt/t1p6H1IGRtAsOpfF5XKXYgn1/rmtEZ292t0lxL9gLlTpYcl5ltOtGKr fOGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2023111101 header.b=zugJ26aw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id b17-20020a170902d89100b001cc644a2131si2263076plz.74.2023.11.17.10.17.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 10:17:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@zytor.com header.s=2023111101 header.b=zugJ26aw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 1F5F881EB0EF; Fri, 17 Nov 2023 10:17:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231693AbjKQSQs (ORCPT + 99 others); Fri, 17 Nov 2023 13:16:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231561AbjKQSQr (ORCPT ); Fri, 17 Nov 2023 13:16:47 -0500 Received: from mail.zytor.com (unknown [IPv6:2607:7c80:54:3::138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C84FFD5B for ; Fri, 17 Nov 2023 10:16:42 -0800 (PST) Received: from [IPV6:2601:646:9a00:1821:450e:710e:ed94:8bf9] ([IPv6:2601:646:9a00:1821:450e:710e:ed94:8bf9]) (authenticated bits=0) by mail.zytor.com (8.17.1/8.17.1) with ESMTPSA id 3AHIFtUU324528 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Fri, 17 Nov 2023 10:15:56 -0800 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 3AHIFtUU324528 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2023111101; t=1700244957; bh=rldfpkIKQWTQW6V8Tvh/c478ucg2EydlDLInfQStja0=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=zugJ26awpulXFLHfyAsUg2BKPMrsxcnuWWyQQj2g1aCAkJXHvT0gGsOJxM9ITp1OL HGbtOA9mkjsqpaTbvCqYFEAaIlg2xc+Y527FP4/IodDK86Sm8h3f4Eop8fSgDsyw6r 2eD2ztygTRXKLYEWTtgxhzOLwm49Xf9CGXYzkWcWx4YvmAWjkUSzFVfbuDdpv7a/M5 lwHVNHoupqFuRWI+wcWIYB9w910JA4hJeXDs+MntW1qK8IDQ6JZw7uodOOEs0ZUehN ScSAzs42AB5ikGunu3Z765QciTeR1RX5HFQdgbetjyskoS+gdolQ4QAMevL4Hnq8an SeAJcvsou/l3Q== Message-ID: Date: Fri, 17 Nov 2023 10:15:50 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH -tip] x86/mm: Use %RIP-relative address in untagged_addr() Content-Language: en-US To: Uros Bizjak , x86@kernel.org, linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Peter Zijlstra References: <20231116191127.3446476-1-ubizjak@gmail.com> From: "H. Peter Anvin" In-Reply-To: <20231116191127.3446476-1-ubizjak@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 17 Nov 2023 10:17:01 -0800 (PST) On 11/16/23 11:10, Uros Bizjak wrote: > %RIP-relative addresses are nowadays correctly handled in alternative > instructions, so remove misleading comment and improve assembly to > use %RIP-relative address. > > Also, explicitly using %gs: prefix will segfault for non-SMP builds. > Use macros from percpu.h which will DTRT with segment prefix register > as far as SMP/non-SMP builds are concerned. OK, this is starting to feel silly. One could seriously question the use case for supporting !SMP builds x86-64. It isn't like our performance for SMP builds on UP systems is significantly worse, it is mostly just a matter of code size, and the difference isn't huge, either, especially considering that on systems of the x86-64 era the kernel is a rather small part of system memory (unlike the very early i386 era, for those of us who remember those ancient times.) The number of UP x86-64 systems is really very small (since multicore/SMT became ubiquitous at roughly the same time x86-64 was introduced), and as far as I know none of them lack APIC which is really the most fundamental difference between SMP and !SMP on x86. Why don't we simply have %gs_base == 0 as an invariant for !SMP? If we *REALLY* care to skip SWAPGS on !SMP systems, we could use alternatives to patch out %gs: and lock (wouldn't even have to be explicit: this is the kind of thing that objtool does really well.) We can use alternatives without anything special, since it only matters after we have entered user spae for the first time and would be concurrent with patching out SWAPGS itself. If we really *do* care about UP builds, we could teach objtool to do this patching at compile time for the !SMP builds. Also, didn't we at least use to have a way to mark a function as "init on UP" so that it could be jettisoned with the init code if we find ourselves on a uniprocessor system? -hpa