Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2097836rdb; Mon, 20 Nov 2023 01:39:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IFjOlSK632P8OP+O7QczTt6/zkwD/S4w+JO2JKcWBSrjpIBX33qEl0MlR1jyylRxYjVu1sI X-Received: by 2002:a05:6a00:158a:b0:6cb:4c60:7328 with SMTP id u10-20020a056a00158a00b006cb4c607328mr8020389pfk.23.1700473167448; Mon, 20 Nov 2023 01:39:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700473167; cv=none; d=google.com; s=arc-20160816; b=QymNKRue2aSuKqY/7kb9mzSeBsigejEMjOUxt8a3wFRWpjitVO57LFni0doPJxb2rt MenFr6YhbUAn4eX5OEzo4/SEFQ2q41iHVFDYpVhIZjRiGM7RjeB3YA/02RWxgp9491UZ vuDahuSWKpKB6Ois33v2zM9Id9Z+G7MlA+fWoOSsaGY2+kOwy4fZpCisYGHojICQ2A1R j+Se3TTtqpBftM0qbKJroPpcrGonqNFUAquRIGM00OUwYdHvKoOKPcpstMZNPTweLrsi JnH3xhm8aes4xdPPrxOyvMnh0eIF8zyT8fFez/426mRHNJmdE2kklphv8pPD8zL8/YBh RymA== 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=8y3Ac6lEqMUaiGY4DCcZMXzjYxBTrAXFgt1FNVntx8s=; fh=/Dnf++/2xG0Xi30TGscvcX3UaoYjzLSxPPap0bUcRsE=; b=FK2YqNbYsXEon4ckGsTRNSFal5OybQCQJWfbU5LgIR/5zUTrOXPcmPhJ/w86nYUqlu og7p57NnEQ9GbU/UyvNL7G2By3CtvUvYYxisWxuvqlmQOQbALY9OScnyit/k9gRsQ9cE Y2wtFBgxgrkAM+Gm1RACuznoS718BjmvwbpDoB8PFUczYFe4RJoYsSd30RNrFMClxzKw v/9AwVzsuD6gcxtbM2ZGdTDBzf/Z3VKkfBZsYqvNiKkEpzosQrfeqdbjwfU9Ge/Ed2mD GotaYjae/uZ0hYvYGoDbXVIlDhsH+05dGNT8WMuOVdGKMCakeYLI7AF/UGSOpXeddJfy 0jhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PWQjcyfj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id u36-20020a631424000000b005b56de1fd82si7348135pgl.272.2023.11.20.01.39.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 01:39:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PWQjcyfj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 41D5D802B053; Mon, 20 Nov 2023 01:39:26 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232305AbjKTJj0 (ORCPT + 99 others); Mon, 20 Nov 2023 04:39:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232138AbjKTJjZ (ORCPT ); Mon, 20 Nov 2023 04:39:25 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 286EBBA for ; Mon, 20 Nov 2023 01:39:22 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-5431614d90eso5921782a12.1 for ; Mon, 20 Nov 2023 01:39:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700473160; x=1701077960; 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=8y3Ac6lEqMUaiGY4DCcZMXzjYxBTrAXFgt1FNVntx8s=; b=PWQjcyfjsNOwJynhJAabWsWgVt/ockxP2pLyKUXSccMaQLCpBmYRDQOpyA42A3DgGe d4DOmk32M4w+1LsnhJ6aCpVkR4NBBNZSIaY7S89FMhLj9nfEk8DjqS7QN0cmFPN3AFlH VD7Rc6Ce1uAAaLWTfgvH5HRB1jnzl9ip8yprTrFIryvvJzNWRCZqYpTEkfMSIX79wRCQ CYijZKQWEk9xBMZEyuFvCisRg5ShgVHPy3Tkrsn0GGH8ZxD7rS87jtt+oLleVl3XQ2EB onie3TPfDP4zM+vKErQDddvrEJRsxx0JCkxQs7edyLZcWrB3mDPyCzNiaRQjBfy8j9pw 7NFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700473160; x=1701077960; 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=8y3Ac6lEqMUaiGY4DCcZMXzjYxBTrAXFgt1FNVntx8s=; b=lkHYYbbr8b9MlSQkryFtyi90KZFs5oIB6bcvFn3FNShfkKJdpa/eCGTdLql3pmzyOL JpSxVVNymj5sy7Q5EbjD7mcB9tjLQh8TaryuniJ/0rDXp9p587pq3nNxIix5qVIW7eGV OedzZ9l7IAuE1EPqPMj1OI9Z0Bfn2T7vjz7NDIDexPhYBekvtR86WsdTEZ0LCOF2yKyE 0SciUI1L9XFszPtGzoTiiqNIQbWHeModCRvzB0VJtA9j9Nb2Qxqf8leXvhpX7dRdpFvj FL0LW0F7RamSUnnDoYciWdGh+rIezVWNQkxkxFdFf62ZFpgQptDLRNvR6hfy4bAgGeuZ iINw== X-Gm-Message-State: AOJu0YwvCf64vWQG6NIfLcmXCFpcWXxtkWFpxs6SMQnGbos+OP092HfH 11OSvQbIHeKveQALTjsv1gwibU6dS27q0yj029s= X-Received: by 2002:aa7:d056:0:b0:531:2b0b:9b8 with SMTP id n22-20020aa7d056000000b005312b0b09b8mr5898998edo.7.1700473160385; Mon, 20 Nov 2023 01:39:20 -0800 (PST) MIME-Version: 1.0 References: <20231010164234.140750-1-ubizjak@gmail.com> <0617BB2F-D08F-410F-A6EE-4135BB03863C@vmware.com> In-Reply-To: From: Uros Bizjak Date: Mon, 20 Nov 2023 10:39:08 +0100 Message-ID: Subject: Use %a asm operand modifier to obtain %rip-relative addressing To: Linus Torvalds Cc: Nadav Amit , "the arch/x86 maintainers" , Linux Kernel Mailing List , Andy Lutomirski , Brian Gerst , Denys Vlasenko , "H . Peter Anvin" , Peter Zijlstra , Thomas Gleixner , Josh Poimboeuf , Nick Desaulniers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 20 Nov 2023 01:39:26 -0800 (PST) On Thu, Oct 12, 2023 at 7:10=E2=80=AFPM Linus Torvalds wrote: > > On Thu, 12 Oct 2023 at 09:55, Uros Bizjak wrote: > > > > An example: > > Oh, I'm convinced. > > The fix seems to be a simple one-liner, ie just > > - asm(__pcpu_op2_##size(op, __percpu_arg(P[var]), "%[val]") \ > + asm(__pcpu_op2_##size(op, __percpu_arg(a[var]), "%[val]") \ > > and it turns out that we have other places where I think we could use tha= t '%a', > > For example, we have things like this: > > asm ("lea sme_cmdline_arg(%%rip), %0" > : "=3Dr" (cmdline_arg) > : "p" (sme_cmdline_arg)); > > and I think the only reason we do that ridiculous asm is that the code > in question really does want that (%rip) encoding. It sounds like this > could just do > > asm ("lea %a1, %0" > : "=3Dr" (cmdline_arg) > : "p" (sme_cmdline_arg)); > > instead. Once again, I claim ignorance of the operand modifiers as the > reason for these kinds of things. I have looked a bit in the above code. From the compiler PoV, the above can be written as: asm ("lea %1, %0" : "=3Dr" (cmdline_arg) : "m" (sme_cmdline_arg)); and it will always result in %rip-relative asm address: #APP # 585 "arch/x86/mm/mem_encrypt_identity.c" 1 lea sme_cmdline_arg(%rip), %rsi # 0 "" 2 #NO_APP Uros.