Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2305635rdb; Mon, 20 Nov 2023 07:36:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IEkxoHQRth8Stskl63N1b2mnlPKSfFwCZqMktIv/BQrqGNOjD/Cn6O2fT6Xswmt56DecCaO X-Received: by 2002:a05:6a21:33a6:b0:16b:80f2:f30c with SMTP id yy38-20020a056a2133a600b0016b80f2f30cmr6042639pzb.26.1700494587053; Mon, 20 Nov 2023 07:36:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700494587; cv=none; d=google.com; s=arc-20160816; b=LHdJVWqoyjR0DiBFhT2+aF0rwukHJhDSf5c4jFipBCzAUdqnsf/O3qdG5UXkBsYWg6 Gh5gBYw8LRIKGJBm97gnmIxRy/+Jw4Bh6aiDaHG7VOvnrs6NnKgUftkjSA8lvapoMZPV DwE79gMyaV9A+kG8h6jXo2bzvbdnhoJscpSAGBoxrs3L6q6TcCvpH7/3OcijHyTDgBlF D8bA3Xa1JDQ+yaWGdVY0XUE0j5BhGB0mL6pbsBhxpJFUya75mzRfk5wpwkMeVkPtsxMX h5Jq4by6F0MRAGLvP2rjmmtWbGAtaEbhSVtmh6uEgIGv3mDUhBbsU0Jk3NsAhgCnry2F 6O+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=3urVBxbF5NZPUeIYke5inWHKIb6xfBZ0lmHUZJ/m1IY=; fh=26H8/YMwOEIvUVwzOWEUxwSuJMLfoacFvRlzImAZUM0=; b=IRwkUHHXLc5rp13GkdamXiEAS2rruU3FbFvnQpRGMbNenPA61bz2dVRpaiCDhzHSYL M3kuHxxIaPgLuX5gfjmG+Zhyjne9LTHHWcofk47k3EFMkkIP2hss2E+NeDRRn/5QCi9u DKRX4r7sUKb6MfpKvaNrcPpuhVORRft5h0xTL1np0tA6j2EDtA8wL+QClxac5ZALzRp/ jtPhyVnn00Lrm1v6RwITa2bsoRGeU5xLYrhNcLReyzNV93Sh6ZojZMgyIRWvQXdtWmew WqS6fn6WQddAv+DxIA/q6HhPMZNo68MObTNqzAhKSbhU/sX5Eh4C40j89zcm2GcYVpUF ph+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=FtTUpU2X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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. [23.128.96.37]) by mx.google.com with ESMTPS id m6-20020a656a06000000b00563da455862si9206580pgu.311.2023.11.20.07.36.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 07:36:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=FtTUpU2X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 77D6D80A30E3; Mon, 20 Nov 2023 07:34:41 -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 S234309AbjKTPel (ORCPT + 99 others); Mon, 20 Nov 2023 10:34:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234303AbjKTPej (ORCPT ); Mon, 20 Nov 2023 10:34:39 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A53DB4 for ; Mon, 20 Nov 2023 07:34:31 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-332c46d5988so888040f8f.1 for ; Mon, 20 Nov 2023 07:34:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700494470; x=1701099270; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=3urVBxbF5NZPUeIYke5inWHKIb6xfBZ0lmHUZJ/m1IY=; b=FtTUpU2X5cQJWbcF8Cs8LgCW4n4FHQt/+tEUA4LrtBvFR9od4YCVNzsRd5YitYrExP 7aKJw07oDLEEctj37088vIHugH3lTAf2ZG/XipwDljyeTqfhkXKxRgm1Rpkpn1vhQmSo tRlCNTpwS9H9ynXFDIZhg2depIcoeoNzVpHJUIUhEnttucdHk0+q/XfEHwgrGivQT605 QN7tIBOhxL/Eg3F9FqTqmet1A9OCozZfzrKELvsoR9YVx5AsMMCi0zpj2vpWz1E+O4Ps YDC9S895601pk2idqRpJavrvV/AIK1fOhFIaRvvOZ/BCjnKZdWwPpn3SZ9Zllw7zulm7 wgog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700494470; x=1701099270; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3urVBxbF5NZPUeIYke5inWHKIb6xfBZ0lmHUZJ/m1IY=; b=WZ8Xp6sSm7NtzR7ey3MZFMPGtLEPfO3Y7KGuGaH2QkG9vcQSsXoqV21xG0/rHBB59I olNOBQq/Vy3VGmM6jxBEtmr8DD4KxI8zFBYk6KFYUAAf9BkPOqSa0YcZl5a+owqpbg+C fKP2xfmlVFKqxaE09HDt2oar+JW1EyWXmWZo23fhCTxmnl8Zgqs/x4AShLNEwxNZPBLG Xc8Mt3l0DI9OOlqmgYZLiRnCQaB0eTzfS5+/ArHWorWq8xtAmXiLVJUgocQ1r2EE2UaG aXnHBvPWhir+sfV45hKuLxP+iJiV7/sRa8b3FpKlr4wYQrbP7JOTJ77yL3WMnsA/kVRw d/4Q== X-Gm-Message-State: AOJu0YyA+DDy0/gXFS//rafO0xUld45IRcAgF0djjKbPHwtD1IrW0s8l O5+Fk0bMwx3dpixkGD2yQRE= X-Received: by 2002:a5d:6d0a:0:b0:32f:c5ea:72ac with SMTP id e10-20020a5d6d0a000000b0032fc5ea72acmr5924188wrq.46.1700494469688; Mon, 20 Nov 2023 07:34:29 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id v9-20020a5d5909000000b0032f9688ea48sm11555870wrd.10.2023.11.20.07.34.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 07:34:29 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Uros Bizjak , Linus Torvalds , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" Subject: [PATCH] x86/mm/encrypt: Use %a asm operand modifier to obtain %rip-relative address Date: Mon, 20 Nov 2023 16:33:50 +0100 Message-ID: <20231120153419.3045-1-ubizjak@gmail.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 07:34:41 -0800 (PST) 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" 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)); /* * Calculate required number of workarea bytes needed: @@ -582,15 +580,9 @@ void __init sme_enable(struct boot_params *bp) * identity mapped, so we must obtain the address to the SME command * line argument data using rip-relative addressing. */ - asm ("lea sme_cmdline_arg(%%rip), %0" - : "=r" (cmdline_arg) - : "p" (sme_cmdline_arg)); - asm ("lea sme_cmdline_on(%%rip), %0" - : "=r" (cmdline_on) - : "p" (sme_cmdline_on)); - asm ("lea sme_cmdline_off(%%rip), %0" - : "=r" (cmdline_off) - : "p" (sme_cmdline_off)); + asm ("lea %a1, %0" : "=r" (cmdline_arg) : "i" (sme_cmdline_arg)); + asm ("lea %a1, %0" : "=r" (cmdline_on) : "i" (sme_cmdline_on)); + asm ("lea %a1, %0" : "=r" (cmdline_off) : "i" (sme_cmdline_off)); if (IS_ENABLED(CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT)) active_by_default = true; -- 2.41.0