Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp639808rdg; Wed, 11 Oct 2023 00:46:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHIYCt/TDrVQQ7hvX/kB/xZtBwbasJO9xlMB2jNjScoKiZRYpfayaX4Ck6CntkXceeWWH4L X-Received: by 2002:a05:6e02:190a:b0:34f:f2d3:ea70 with SMTP id w10-20020a056e02190a00b0034ff2d3ea70mr28377875ilu.6.1697010379575; Wed, 11 Oct 2023 00:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697010379; cv=none; d=google.com; s=arc-20160816; b=pKb4qdV3z8KSsIdYFjPKXwoykdrhLzvKQCnPHFD96qOVkT1CBoTvfNfTwfYGzKlgON aDYVfxZDeSJR0URjlnq3KEzx6uvnoy/wUbllsYazfth/vPaY5vXGu3N/7r3gnrF3YbPo StxI8NTOJBbxSEBQVke2uJG5raEn8h4TqBR17jPQsUArl5DgX5Wl1Dxd6GLNu0UA3aOY HFD/fvej8gCOUn8Zgd7PtBykQPcxCRBS/Y1nwh9PaUdGplBbcM9kEC1Tl1c+E6jZZ6Cq XVxbuJcW9ZtBqGLiorAq+Mkhk+MrjKoEReKFD9pvAnl5dTF0K/N/XWrsePy1Y7ZkGo7h XJYQ== 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=rNhFI0v6UKt7VgTziyBvjQKuILoZxlQQlESpPcR93wY=; fh=tF7riTkuBa8O3vMSvJNFl/jVCIdpn/sknKnZT2xFBLQ=; b=b4TLmpyP0dWXZl0FG3o23pmvf3dIsWMnILMX/l+fkGF8THmX7zOSoks35204Lc4KSc 9QaGUMAogz2y2JzSLrTRJH//i53sYTKSCtTZmA7/vxX+n1CGDReZLMa/VmAG0IEwke/h pti9PQH6Sc1Euweo+s5F5brBc3Q9Nov6wLtYGj0D3XUAmSajzd09zokid9TQpTv2YGyO kJ1wnCd7PBnpI4rw3XOx4kXahst7LYMWph8F6ieKzIVkH5B4iCOzebPBDVi3ubXr7C97 jkqig2mdAA4YmzAQXjG/ZsPGM+gvynYKZGsNMZnakuNOxIfCuxoHgYipK/VW0CRcEAWt 9oYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GHLOxhv3; 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 f28-20020a63381c000000b0059cd78384fdsi2885362pga.222.2023.10.11.00.46.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 00:46:19 -0700 (PDT) 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=GHLOxhv3; 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 999E0807C643; Wed, 11 Oct 2023 00:46:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345543AbjJKHp6 (ORCPT + 99 others); Wed, 11 Oct 2023 03:45:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345427AbjJKHpv (ORCPT ); Wed, 11 Oct 2023 03:45:51 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 186299B for ; Wed, 11 Oct 2023 00:45:49 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-538575a38ffso10628426a12.1 for ; Wed, 11 Oct 2023 00:45:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697010347; x=1697615147; 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=rNhFI0v6UKt7VgTziyBvjQKuILoZxlQQlESpPcR93wY=; b=GHLOxhv3KUk1L4RHPSrouX+cFSkl2Xi+92kgzHnEviATBkpnxybA+sfuaLM6meH/ob fCWrPGJpR8LpHugAiwXO3ofI7oim2Jm2QTPVrNvIrP2swMrkPDj6262SufI79I9pm3Uw KL/xvCnU9z16OtRRDoOo/cWth3oJtmrgAO246dhuSmh+HeHvUzRKvEe50cQo/oXS2Wpm 8BHJd1+UIaP5Bobjb+5a91niLxTzUtyknUPXaaa5GKtqEDGMentOlU32wFeF5UI9KFn/ ZEZezHWDyD15mL8ZiBcG2cOyp/G2ssieGoS13mbfLwjiKmA8SeACeoSy34P0SHVsmpI7 DZeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697010347; x=1697615147; 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=rNhFI0v6UKt7VgTziyBvjQKuILoZxlQQlESpPcR93wY=; b=dMguxZyd4onuoOBmDBkmY+uDTDqXYQ929/mSVunssFMghMSMZTWTXXlnqnc//Iiuyv LecqzO7qr6qvsaoYMGri/vjWQEX0pDx95GzRd32uLFZa+YvAk1QLxKj0z5jq60i8S/f1 32+3O1Pn0n8I3ZBgQ9OzvfCXdK67PcwHW1s1/w2yfDK8hyfIRevgYJNIcUWf1LmF3AOO 6pF1N/HI3YlOwTmh0vz3fau7wwq87/7+TmDr5/rJ6WLJab2ARsVzxYfSXKncde7+cce4 K5FdWiWTgmX2fHK829/MTYIQa7NdDMVDl8/WeJ6/yN8dFK5DH13jY3q3U3ObZ0+4Zqpl a/ww== X-Gm-Message-State: AOJu0YxwpKIhjogKigSBXNDNgEtXoSYXkLdSZci2eu1LVKKz79aPyRB4 VbkkbZqvzCSvLwPNZ5cEeADDAxwjhB1kqhucL+w= X-Received: by 2002:aa7:cd74:0:b0:52a:6497:d02b with SMTP id ca20-20020aa7cd74000000b0052a6497d02bmr18961168edb.16.1697010347429; Wed, 11 Oct 2023 00:45:47 -0700 (PDT) MIME-Version: 1.0 References: <20231010164234.140750-1-ubizjak@gmail.com> In-Reply-To: From: Uros Bizjak Date: Wed, 11 Oct 2023 09:45:36 +0200 Message-ID: Subject: Re: [PATCH v2 -tip] x86/percpu: Use C for arch_raw_cpu_ptr() To: Linus Torvalds Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Nadav Amit , Andy Lutomirski , Brian Gerst , Denys Vlasenko , "H . Peter Anvin" , Peter Zijlstra , Thomas Gleixner , Josh Poimboeuf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=3.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS autolearn=no 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]); Wed, 11 Oct 2023 00:46:16 -0700 (PDT) X-Spam-Level: ** On Wed, Oct 11, 2023 at 9:27=E2=80=AFAM Uros Bizjak wro= te: > > IOW, something like > > > > static __always_inline unsigned long new_cpu_offset(void) > > { > > unsigned long res; > > asm(ALTERNATIVE( > > "movq " __percpu_arg(1) ",%0", > > "rdgsbase %0", > > X86_FEATURE_FSGSBASE) > > : "=3Dr" (res) > > : "m" (this_cpu_off)); > > return res; > > } > > > > would presumably work together with your __seg_gs stuff. > > I have zero experience with rdgsbase insn, but the above is not > dependent on __seg_gs, so (the movq part at least) would also work in > the current mainline. To work together with __seg_gs stuff, > this_cpu_offset should be enclosed in __my_cpu_var. Also, if rdgsbase > is substituted with rdfsbase, it will also work for 32-bit targets. In fact, rdgsbase is available only for 64-bit targets. Uros.