Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp254521rdf; Tue, 21 Nov 2023 01:30:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IEETiUmfZUjO9rOtDsvuaBrb0k22yToTLI77IlW7jUdHfR5Q/rLfPw9K7OP96IbzzK7FHhY X-Received: by 2002:a05:6830:1e19:b0:6af:7760:f2d0 with SMTP id s25-20020a0568301e1900b006af7760f2d0mr10035368otr.32.1700559004560; Tue, 21 Nov 2023 01:30:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700559004; cv=none; d=google.com; s=arc-20160816; b=fLzprOy4OhilPsBMptYT1Tb4V0qjuza0ANlqzKYwy2JEu3Sle/Xu/D70ohRNrEQh6b mdzjiVeEchexz/yO4HDS3OETSoz7kMdyoL9NuXTapcM7758570Fs1VjsESH/nS/fHHYH j9XnGfW8gUz4ddvx21GxfOO+MuBugF9yqlf0Bgzu0IPn0WFahXZXApNwDsi2lKwU8AxH oHITLIQkXkTMXXCXy7GfekqlzRjd6ESX9dSB9Gv2ufKKkaBDocDHgCaRTur48FDOqfFO ywl7NId4+qsTNMKeQ5CyjNMuXdhWTKJu1/vq+Zvo+o7+K7fZx7KmnHZathctiKs1QeUK Qyag== 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=HWWIejbf4V8Ii2I3PkswFty/DaeIXLclOkLCoHazGNM=; fh=EmCZj+EoSWCZaH92ZiMSZrrOFb/Myle2iVIs8shAoHg=; b=m2tXYrQPy2xj/j7OrbS+qO3hc3LsDQPchZeHiYRelRo5j0zkOk/0Hl83g9YZGyP0DO DH9VZwR2719TGDVGLeH5SQpGJC1APcK8fSYDiQ3OJKcYduMPiLdSRbSSImiZ9+44Cy9f Za5Ib1ukWhcBzQvgWZIm+l2AdHSpqfRTZk/NWzb3JzG1R+2YSGVzxoGa8wBHiINbB2sx MwwIqWUUGCY7sG+khGOlekwW4qjh6OYMLCOoVSkd3ut4L24k11FLiGjGEGS9nyu1S/tz 30N16za1wN9by/7r3PWkDHsOkvV9I8e1/Yj7O47s6Wty+bIxnBPEIaqrn+0wntAjhArh Ap8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Pzdt7G3f; 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 1-20020a631041000000b005bdd76219edsi9297250pgq.675.2023.11.21.01.30.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 01:30:04 -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=Pzdt7G3f; 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 388B580EA8C2; Tue, 21 Nov 2023 01:30:03 -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 S233511AbjKUJ3q (ORCPT + 99 others); Tue, 21 Nov 2023 04:29:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232702AbjKUJ3f (ORCPT ); Tue, 21 Nov 2023 04:29:35 -0500 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9582EC1 for ; Tue, 21 Nov 2023 01:29:29 -0800 (PST) Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-5482df11e73so5707774a12.0 for ; Tue, 21 Nov 2023 01:29:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700558967; x=1701163767; 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=HWWIejbf4V8Ii2I3PkswFty/DaeIXLclOkLCoHazGNM=; b=Pzdt7G3fo3pMrHJ+O6jeD5K5v2XZFmr2tZK2fUtaoaKPu1tmJavw5kTwc7O5ci1Add PdfuHJqfqpyLfDKyxwXaB5wFHOuLIWhXIXRwrS/GjLVib0LXxNf8BBihBNfohdfs5Lvb VV7yRm2cGER9WCQdmEtV85wnCQY9kRB304wTKxRlW6ru7Wm+w01FPruswZo9SXhLHGHO JuFjbEKF2vfKOs3VDNuFoZ5+GDwPbnJ/BvkXz1E1cI4y/Qm86wbGPR0e85l+rxqKMqCE TU+CDfi2uLMVjdL8qSkaLQO3Y8K8jh36zVEyHy9eP78f3kZ+fD933kl4/WL1tg9BiOzY d3eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700558967; x=1701163767; 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=HWWIejbf4V8Ii2I3PkswFty/DaeIXLclOkLCoHazGNM=; b=vdm+q5gIM4OiJFwCNAfoKZjZXeCkD1l4NYdVnJqszNd2jv8HaM/PapxVDjk/nCcsfF rQpLCTlYSqZSTJ464L9PzKx2ew5jze6gkJVujwgs+GUxgsZtx5bvxkBWWEZ8KcHo/5iS ff40uxoIR8hc+tOz1IrxXXT6vlmlarv+uy2cJOZfCWWyU/LrtUtYXrM71K1PHUmiqJmh Xl4rsfxs8o79pF7EkKLd/OUMzytk/Kq0hjopXxZv/PUtYSfsf/lBfPlUEuQPmty67EOg bwY849iwm2kvPaIWT1JQUo1DpgKGGkQfoBneExuqXDVkmwxWlvHeYfIMQvRnL1bU149a A9Aw== X-Gm-Message-State: AOJu0YzDHvF28PVtrCQbM3r1+9gM9iFLzUhTM4g5z8ltc21Z1V33B0Iu Z910h1QdL2aZbkoLI6dfDKotkVgnXJZgIbGRbXYlL1V+4SxWjQ== X-Received: by 2002:aa7:da54:0:b0:543:5741:c9cd with SMTP id w20-20020aa7da54000000b005435741c9cdmr1362110eds.34.1700558967422; Tue, 21 Nov 2023 01:29:27 -0800 (PST) MIME-Version: 1.0 References: <20231120153419.3045-1-ubizjak@gmail.com> <20231120171507.GGZVuUG9aSLyF52jHd@fat_crate.local> <20231121090041.abqwtkbzzwxq22ke@box.shutemov.name> In-Reply-To: <20231121090041.abqwtkbzzwxq22ke@box.shutemov.name> From: Uros Bizjak Date: Tue, 21 Nov 2023 10:29:16 +0100 Message-ID: Subject: Re: [PATCH] x86/mm/encrypt: Use %a asm operand modifier to obtain %rip-relative address To: "Kirill A. Shutemov" 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" 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]); Tue, 21 Nov 2023 01:30:03 -0800 (PST) On Tue, Nov 21, 2023 at 10:05=E2=80=AFAM Kirill A. Shutemov wrote: > > On Mon, Nov 20, 2023 at 08:58:29PM +0100, Uros Bizjak wrote: > > On Mon, Nov 20, 2023 at 6:15=E2=80=AFPM 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 t= he > > > > 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" modif= ier, > > > > 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_e= ncrypt_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_para= ms *bp) > > > > * We're running identity mapped, so we must obtain the addre= ss to the > > > > * SME encryption workarea using rip-relative addressing. > > > > */ > > > > - asm ("lea sme_workarea(%%rip), %0" > > > > - : "=3Dr" (workarea_start) > > > > - : "p" (sme_workarea)); > > > > + asm ("lea %a1, %0" : "=3Dr" (workarea_start) : "i" (sme_worka= rea)); > > > > > > 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. Huh, what a bummer... The patch is retracted then. Thanks, Uros.