Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp242093rdf; Tue, 21 Nov 2023 01:01:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFhqzJhLYy2+ckjNQPYFCmsReDC2kEtjzI63jEpWTDv2pAdRnWbO3yq8LF0e9hC7xz+n2r X-Received: by 2002:a05:6808:f8b:b0:3b2:ef72:f59e with SMTP id o11-20020a0568080f8b00b003b2ef72f59emr13070747oiw.24.1700557273048; Tue, 21 Nov 2023 01:01:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700557273; cv=none; d=google.com; s=arc-20160816; b=MZKwPXJwMFY3NuG7lvjX5zmAq5dz5VpPefdEOJigwz2oRcv7S5XUO0Q0cROOj4zrKe DNZGRbLjhqwzfwn98M31xW3VBeo8LxJxRYSTRhI5m2DSyiYdMw2OpBDdWgDfhTWh5Qe8 Kpkjh8JBihNnBByqM3Hza4Uu6p8ZgKYiG72JQ3jejQyfua02SSFC64B/VaBh+VLUBBFl lQdSLAWVPRcDnQ3HadnUGe6iSnUq9+iyVsxPfjLPDT1H2mwqfQiB+ZaMHjH6Bgq/yPpD WwYEnAn4jwRN5pPvPozMr2bLleQ07V1FeMo29nEOAfDdymit/yQMmN5Xpl1xWvHPWkt4 5kgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:feedback-id:dkim-signature:dkim-signature; bh=xvvWLKkLzuvSAxa33ZZp5h+RrpmORBUXFhEWLoKeOe8=; fh=Z+wlrjwgNSDSwtAM43LSDK+6+YVKjI67pdEh4NFo9dE=; b=BTlTcTDsiufjVReAvOo9XjTgYY4+1TuoLCdWYYjXAxLOB8P935enYlEV1DgwJEJhru HdSyQPFBinUi+u4U8633Q9MQgiFlAnVCmiZAT/g8c82D2oNpBoylMBoEYRlmghPElfUC udg12UeFO0Qv1zak4PDsRrxEXcNNTeg03+PGe8c2sEjzel2l6YyIHY4/C7LXP1K5MoBI IUM+zf8p/4CQ+ej9TfdqsoEI2GRD8zIpss0yN++lgrVCOzutINqTbgVZbnEcGgdMnsRX RaJmF/giukp6Z9yKMJnxL6blnvz1UcjUrYH3cOdsDRLMC5OuyMz9L7lbtBXSYZFwn63/ cdpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm2 header.b=O3neUZnl; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=GSil586+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id el10-20020a05680838ca00b003b8386b8f4fsi58312oib.219.2023.11.21.01.01.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 01:01:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm2 header.b=O3neUZnl; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=GSil586+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 6F53B80CC14A; Tue, 21 Nov 2023 01:01:06 -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 S229840AbjKUJA4 (ORCPT + 99 others); Tue, 21 Nov 2023 04:00:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230243AbjKUJAy (ORCPT ); Tue, 21 Nov 2023 04:00:54 -0500 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45C09E7 for ; Tue, 21 Nov 2023 01:00:49 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 2AB4E5C0A84; Tue, 21 Nov 2023 04:00:46 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 21 Nov 2023 04:00:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov.name; h=cc:cc:content-transfer-encoding:content-type:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to; s=fm2; t=1700557246; x=1700643646; bh=xvvWLKkLzuvSAxa33ZZp5h+Rr pmORBUXFhEWLoKeOe8=; b=O3neUZnlnUz/+TmWXnvDoUrjjrRhQ/ehGcZmFab5K Rkb8n4z0ODZVRITxgs129eOetINtw2TGzN6RUtbYg0V4aAtrvY+S2FfeMjzZIO9N ZgRME4jzziq/7tnh4jn2TdrGRdURUppf/nC+RQzWEfi2wZEg+D9gqXeBm8a8SnSP 1cobglKWQ7UAScI3hpu941jt1GcyoVljnyReDXYuitmPLLoVcE/SU19fB03D047k vPzHqDPL46jHdhMGmka2/ZeUE4uGE54+xmFq852EgosLMf21OnzoVRVPpGAJwsoK 9NKCCJFNGFtIBIqo3WufIBZiWRNZcP8yF7zpNAeC1KCVw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1700557246; x=1700643646; bh=xvvWLKkLzuvSAxa33ZZp5h+RrpmORBUXFhE WLoKeOe8=; b=GSil586+acMyTZrpMCTNKm4YwnsC3XpvK557xfeA/g12bOfysys EnjyjvIVRUmov3AyLJD2ZQsGcGO9RHjE7ppLg9VdxXrYbhWmee3BbVi5F5E1p9Cn AUVBHyZJi1hnXHcc8DPv/LhBovrxR71ASSQSYVSw1hz1jKrbzEGMqiVu0sOX7Q1d nxUpfz+pKxDAMI4tHedyZOAVR/YeKshcklOpMOM5Zvn5fLLbcGGzXpULVb0j+sDK oEi9ONyEYt2YxJ8mr9QMMGVI2MVJGw5NQQZ83dleY8cyPeh8J4dLXNhkahu1qmkb 6RAmjfxJ3RNEWtESWbdXNS1NOz0bKeq6jGQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudegkedguddviecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtugfgjgesthektddttddtjeenucfhrhhomhepfdfm ihhrihhllhcutedrucfuhhhuthgvmhhovhdfuceokhhirhhilhhlsehshhhuthgvmhhovh drnhgrmhgvqeenucggtffrrghtthgvrhhnpeekieduleeugfevhedtieevudeftdfhleef teeuffeuvdetiefgfedutdeggeekleenucffohhmrghinhepghhouggsohhlthdrohhrgh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehkihhr ihhllhesshhhuhhtvghmohhvrdhnrghmvg X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 21 Nov 2023 04:00:45 -0500 (EST) Received: by box.shutemov.name (Postfix, from userid 1000) id A5E5910A36E; Tue, 21 Nov 2023 12:00:41 +0300 (+03) Date: Tue, 21 Nov 2023 12:00:41 +0300 From: "Kirill A. Shutemov" To: Uros Bizjak Cc: Borislav Petkov , x86@kernel.org, linux-kernel@vger.kernel.org, Linus Torvalds , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" Subject: Re: [PATCH] x86/mm/encrypt: Use %a asm operand modifier to obtain %rip-relative address Message-ID: <20231121090041.abqwtkbzzwxq22ke@box.shutemov.name> References: <20231120153419.3045-1-ubizjak@gmail.com> <20231120171507.GGZVuUG9aSLyF52jHd@fat_crate.local> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 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]); Tue, 21 Nov 2023 01:01:06 -0800 (PST) On Mon, Nov 20, 2023 at 08:58:29PM +0100, Uros Bizjak wrote: > On Mon, Nov 20, 2023 at 6:15 PM Borislav Petkov wrote: > > > > On Mon, Nov 20, 2023 at 04:33:50PM +0100, Uros Bizjak wrote: > > > The "a" asm operand modifier substitutes a memory reference, with the > > > actual operand treated as address. For x86_64, when a symbol is > > > provided, the "a" modifier emits "sym(%rip)" instead of "sym". > > > > > > Clang allows only "i" and "r" operand constraints with an "a" modifier, > > > so the patch normalizes the modifier/constraint pair to "a"/"i" > > > > s/the patch normalizes/normalize/ > > > > > which is consistent between both compilers. > > > > > > No functional change intended. > > > > > > Suggested-by: Linus Torvalds > > > Cc: Dave Hansen > > > Cc: Andy Lutomirski > > > Cc: Peter Zijlstra > > > Cc: Thomas Gleixner > > > Cc: Ingo Molnar > > > Cc: Borislav Petkov > > > Cc: "H. Peter Anvin" > > > Signed-off-by: Uros Bizjak > > > --- > > > arch/x86/mm/mem_encrypt_identity.c | 16 ++++------------ > > > 1 file changed, 4 insertions(+), 12 deletions(-) > > > > > > diff --git a/arch/x86/mm/mem_encrypt_identity.c b/arch/x86/mm/mem_encrypt_identity.c > > > index d73aeb16417f..6a351fdd1b39 100644 > > > --- a/arch/x86/mm/mem_encrypt_identity.c > > > +++ b/arch/x86/mm/mem_encrypt_identity.c > > > @@ -346,9 +346,7 @@ void __init sme_encrypt_kernel(struct boot_params *bp) > > > * We're running identity mapped, so we must obtain the address to the > > > * SME encryption workarea using rip-relative addressing. > > > */ > > > - asm ("lea sme_workarea(%%rip), %0" > > > - : "=r" (workarea_start) > > > - : "p" (sme_workarea)); > > > + asm ("lea %a1, %0" : "=r" (workarea_start) : "i" (sme_workarea)); > > > > Yeah, I saw that particular subthread today. > > > > Are you sure this "a" modifier DTRT with all gcc version we support? > > > > I.e., from 5.1 onwards... > > Yes [1]. > > [1] https://godbolt.org/z/aWe7b16rT But Clang generates RIP-relative load only starting from version 15. Clange 11 claimed to be supported. -- Kiryl Shutsemau / Kirill A. Shutemov