Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp757277rdb; Fri, 17 Nov 2023 11:45:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IGuRAC3hwPOmgColS8BWFf3l6pGZD0Sw9Er9DzdoIDmapy3KllitDksxTXk5zpt2n3pqCtl X-Received: by 2002:a05:6a00:1bcb:b0:6be:20d5:e8f8 with SMTP id o11-20020a056a001bcb00b006be20d5e8f8mr614702pfw.1.1700250301276; Fri, 17 Nov 2023 11:45:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700250301; cv=none; d=google.com; s=arc-20160816; b=TxgncszTa4OQqmEVulpVYMh83vcMCCPaXrbqCo8Jo7Wx6/2AAhvM7PZqJDCqhBPFfV NLxwVH5l7eyzFN9t2NAKhoSRgyLUqdofPRBtHHkL1QS14dlbj6KJQ07pdHqn/I3LaZ09 M9xuBDeNTFNab+LAJjdDASMZu22+lJio+Dp1WWiKKNZD8VPjN0ChV9vtgw59hoZsTrgi +7rVL0pSKq0E2nXsbqxM9c7+RXJjiUL5RbhwyLOWTbsaxNnY+qFlHNeVA3l3oinUUNQS X+rNT3MAQM8D0HviWUhzivuSOEAf9UPTOkQlqbquU6IXXghBeisrhmEDgvfg0qcZ8mnD IGwQ== 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=ipIG35F0M7cxT+tSacDx0LznY+mEw6VNfAkZj1ICT/E=; fh=4Wi1UgR9/qBjQ64od7CJI+uxpv4ScLqlLpg0JO4HbeA=; b=eLHuFE4R5MUXLYKTUqwHexXgnfqXWHJv22Vv1tCpG03kD07GajLeeU2fgdCXpzkTk4 3STllNykLIX0liHVgYt02H9ggPccYQ1V+0K0RXdvAGxn7yM5VVvrPHdGYKzfgX7NMEuT k2qKOrVqnd/Chp8UBNUfRog1q6zlqqFphYKP8Bhi0Ip+CvIWEE97Q/L1u+vPHXqBsWHv qjwV44JMEwtruv0IB5MOA5Tz5Nm6HIlBO2NwZNcmNOpYAv8BnWLgEJpw1Swcda+zw+KF +UViEuHmgTcyNCB0EOcIoRLRS2n5OdVea3jsoQQjQSzeuesLPLoDUYWxonCFlzzFiou2 d8QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Fb5YcGl5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id s186-20020a635ec3000000b005c1f51c7063si2618767pgb.385.2023.11.17.11.45.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 11:45:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Fb5YcGl5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id ADF5D8246E0C; Fri, 17 Nov 2023 11:44:58 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232010AbjKQTni (ORCPT + 99 others); Fri, 17 Nov 2023 14:43:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231201AbjKQTnh (ORCPT ); Fri, 17 Nov 2023 14:43:37 -0500 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0632D5C for ; Fri, 17 Nov 2023 11:43:30 -0800 (PST) Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-507f1c29f25so3288488e87.1 for ; Fri, 17 Nov 2023 11:43:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700250209; x=1700855009; darn=vger.kernel.org; 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=ipIG35F0M7cxT+tSacDx0LznY+mEw6VNfAkZj1ICT/E=; b=Fb5YcGl5Y4exigAennHb1XX54PadkV17CcheSMcGtW9LAeS5OyhRBWc6T8mPNgd5Dm kVs7gKsd/u0DaR7RuRVnG4FMYgAOPj1iS1UC6LQ8xQAZOuXkorqMzCO4Lsqz4H69M1M5 /QPEf3vUa/gJQe1ceuRBPUK7vZLu+VwaY6SJ4QQYRBncsdtTWD4O8fdoAnhQPTCXeAfQ CUnRPIpDLOJV8zkuJnzPGnue9pKJlusFXVQa4uEEXyoKPEigjRlDvSQj6otG+jt0fhSL VS3NDpKCStV2pZNdE0D8qvfADNkRTrhcL1ciqOnL5Ysl5OYgosKqfomcGeoQMRLgpFSD e/sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700250209; x=1700855009; 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=ipIG35F0M7cxT+tSacDx0LznY+mEw6VNfAkZj1ICT/E=; b=UJ1oDSXlIg//22ex5yik9RppY7y63VWQZMpN49oxxtXO6ATJZjfStyV0ES5bSY0zlQ bvfR+MHq6OSyn5YdO5bbICFpuvQ0Srozl2mlj9VPkiUxcP2mp36h0MlZbvRdFTtQINVn l7+NXzuXH4BHauXNzumneVtESBzdPj1InBE7kEGFsOPZ3HtKC5efFBJNLZhYXu/W91MC 0uc8w2cLWlyrvZ/oojJMl3SgUae6p1uzS3XwrruAM9IBsWVkFNJVKNdCVh2qKXCGmBz2 E6nJnqnAj+eTGzgJOm64UEqJUvSN5L9+0LtkIgF3b6SVDN2+5sDGPHtuWopr/vsJarSV RPAQ== X-Gm-Message-State: AOJu0Yz/GuVXzHiOCk7Vmw0syoAEAvg6Y0E5fcFe1xuAceBoo8d5ReCb i5vvcn41OeylSFqRr5sGb+otSATZtmqXgMhyrg== X-Received: by 2002:ac2:5395:0:b0:509:4709:2104 with SMTP id g21-20020ac25395000000b0050947092104mr316084lfh.67.1700250208559; Fri, 17 Nov 2023 11:43:28 -0800 (PST) MIME-Version: 1.0 References: <20231116191127.3446476-1-ubizjak@gmail.com> In-Reply-To: From: Brian Gerst Date: Fri, 17 Nov 2023 14:43:17 -0500 Message-ID: Subject: Re: [PATCH -tip] x86/mm: Use %RIP-relative address in untagged_addr() To: "H. Peter Anvin" Cc: Uros Bizjak , x86@kernel.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Peter Zijlstra Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 17 Nov 2023 11:44:58 -0800 (PST) On Fri, Nov 17, 2023 at 1:16=E2=80=AFPM H. Peter Anvin wrot= e: > > 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 =3D=3D 0 as an invariant for !SMP? The reason is stack protector, which is still stuck at %gs:40. So GSBASE has to point at fixed_percpu_data, even on a UP build. That is corrected by the patch series I recently posted, though. > 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. There is already support to patch out LOCK prefixes when running an SMP build on a single CPU (.smp_locks section). Patching out the GS prefix would only work if the initial percpu area is not freed. Beyond that I don't think other optimizations are worth the effort, and would get very little testing. Brian Gerst