Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2479831rdb; Mon, 20 Nov 2023 11:59:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IFrlVmpYIIyHUzrUTX/4PAnfimxVcOE47m/j8u0Zqvbf2AqWE2IC2Z1q7CKjCJqueyrB6+R X-Received: by 2002:a05:6a20:c1a9:b0:187:da70:62f1 with SMTP id bg41-20020a056a20c1a900b00187da7062f1mr10296557pzb.27.1700510355542; Mon, 20 Nov 2023 11:59:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700510355; cv=none; d=google.com; s=arc-20160816; b=QB65uespwR++mAmVm6Q0x+iObZqn5m2Yvk+Ksgshi99qFetfDpDZdpqjvacWAK1jBY WymmOVXZlkPswBz0dC5VyLNL6EK2OJ/myiJWrw/cFxHGE4PGIZxjpN2gB2/O/7kEYRQ7 yojaJST6hmQoyro0rr9aut+pfVGGPRqvAnWH1gSTDg4Fu93H5WYiqKDgM9bk5zk9jfR3 Uk8CUbIQ5zhBrXLByHmmyWHfM5FKA64kJ56zztUdfpaBNKi9D8XgSWQxH7jc5+Qooeyx T2UB4qXCxhAQjNsUoQYNEeCkj0l26jHOwBMQSCiWVWTT6ljKBj6HdGJ3ngI0UPUCRHte Tq3w== 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=C6WkgVUoD3SnWmkPFjtoqV6NgRmZV236ikrSdXbMFDs=; fh=fpxg5uxrlSkbYdp3rxpH997OeIp/F1f43Jt4apTOhYU=; b=Ac5A5bqo0yGeDIRWA31By2iMS3uzunVn1pKquVkGVbTzI3HPGsUc0piR5iVkMJ7nMA DwYkELJq9a5A4p9svRrQiAG7UBu0939V3zJbg0xXA5qTaJdo7hZyf2g4DvkkTbempLnl LhOjMNcdPDuFMTO+plsICFriI6VmWN5g4X7m6/ZbEe0cVeCcJBQjnbvlc+lIy1kLXmGo Mo10LMVwDzzZ79TykqlLKs7pDVyzv3elOSoyugxrz5DB0QebfUD2F1DgC/ZWbpaOmhDb rXYsI1pHgrYNfRKif7JcxhCtwTJItq5goyK9EgSW7d6j3uXB8gcsVZjKtxpokcHpIQbX oMlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WRilgRtx; 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 y5-20020a633205000000b00584e65212d4si8505120pgy.609.2023.11.20.11.59.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 11:59:15 -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=WRilgRtx; 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 1ED0A802795A; Mon, 20 Nov 2023 11:58:54 -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 S229721AbjKTT6s (ORCPT + 99 others); Mon, 20 Nov 2023 14:58:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbjKTT6r (ORCPT ); Mon, 20 Nov 2023 14:58:47 -0500 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 888BC92 for ; Mon, 20 Nov 2023 11:58:42 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-507b9408c61so6435909e87.0 for ; Mon, 20 Nov 2023 11:58:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700510321; x=1701115121; 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=C6WkgVUoD3SnWmkPFjtoqV6NgRmZV236ikrSdXbMFDs=; b=WRilgRtxvpWMwFhorRm/HYaaLUvx6bj5clcUzG0mAWQUUvoUXmmwZhD+IgbI+GNK3r LaI1oJ2nQ7QNzXTOEr+sl+pTQswWIH4PLBUzQNEbNFRy71G1aKXqcYsJN9JvTXVKt5Ae tGIGr/+UgDbYmypQi2BuLw9NpH+b3X2UWd9Vbm+DeR4dfVVkXLEE1HZsyqyHapJ4DLfk eulTUyi83RDouVQDoYAHeYL2BR2tUVpsn3iyhJM4IgSpY1Kh510lWB6S30PQddq8iIdG q2IZykYBZYzOweU3I3MV9tmwMK65GrB9BHfPyfwEtp7yj74e/1ahf5tnPv71d1dQRsLw Rexw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700510321; x=1701115121; 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=C6WkgVUoD3SnWmkPFjtoqV6NgRmZV236ikrSdXbMFDs=; b=c+iNMKHVlbkAMaHhZLTn9kTHIdDREP6ZfpMHtHP/f21JROUMWRwvrY05OXGmLWdTeN 91WGe8k6UY97BN0SHR5pNfy8u3jE1ujQKf3UOxFLbyx1yb/QfhYmd3sRzWLDiTv3RCCe AaAMfUvvqU8ibsSRe/l3luX8fWseLcVB1R15NRyvnkoJUtk5AzCNK82b78uebvEqmKWs 4P13OZQcz/nM0Yqbc1FxSbAK4cFSASKYJGaAurr58nZYziCTX761vneKuI1d+52Lv4A9 Mp+qSNjnKeKR9tF2gaup6c6pdN7b0XituPgWkzKE4yCYFsE9DehOcHccoPr7yoFsNyXy +3fg== X-Gm-Message-State: AOJu0YzZiScMvBIZ0SDmNzFYrgF8GV+zHNPA89KYHTQZjpSjEYfxmm7i 704uPRFkSQaAOngm8zzDAlH/eyh+9GpuosIkg4Q= X-Received: by 2002:a05:6512:312a:b0:500:99a9:bc40 with SMTP id p10-20020a056512312a00b0050099a9bc40mr6023187lfd.69.1700510320296; Mon, 20 Nov 2023 11:58:40 -0800 (PST) MIME-Version: 1.0 References: <20231120153419.3045-1-ubizjak@gmail.com> <20231120171507.GGZVuUG9aSLyF52jHd@fat_crate.local> In-Reply-To: <20231120171507.GGZVuUG9aSLyF52jHd@fat_crate.local> From: Uros Bizjak Date: Mon, 20 Nov 2023 20:58:29 +0100 Message-ID: Subject: Re: [PATCH] x86/mm/encrypt: Use %a asm operand modifier to obtain %rip-relative address To: Borislav Petkov Cc: 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_BLOCKED,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 11:58:54 -0800 (PST) On Mon, Nov 20, 2023 at 6:15=E2=80=AFPM Borislav Petkov wrot= e: > > 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_encry= pt_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 t= o 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_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 Thanks, Uros.