Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2303156rdb; Wed, 21 Feb 2024 03:37:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWGm2IycycEJ2Em48dNDi/V39+IHJce5ETyc2uD3EnLvBp414XMIZ9lPnSwNO5/Z+bwR1pwrjo2GCDmhZopX8dvOefq3MrBj6ZMGwPDNA== X-Google-Smtp-Source: AGHT+IEQ2k5nHgPYuiVowQZTHoGAAi5Lb1U9zkI7uKwFcKXIZ2U8fvt0s62YdeiEOlZFTVByiozB X-Received: by 2002:a05:6a00:2d9b:b0:6e4:6dcd:8d28 with SMTP id fb27-20020a056a002d9b00b006e46dcd8d28mr8891539pfb.0.1708515422862; Wed, 21 Feb 2024 03:37:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708515422; cv=pass; d=google.com; s=arc-20160816; b=zhGUF4D3UlWoXBzhbV+KLf1rrm7Jwn4egPlBqeD4T20EROIoLRD4auRFaBYPOBIooc bdjne3lz+Gj+DrtM3mXvvY69IFtST2Z9OZEy5Dg7QKjkIXJQ8gfpKdh++iMqfA+SHewi NNuqLLeczGPISqoQf9Hfzb2FZ4DKed58g0jmTEqQwLL9TRIsn4PMt/Qd0NpIPPmwl5wV Qy0obChCEQ3us8LgRKIPiNiBYQAT1f3JvHzMURiWXpAgmSK1lNo/8c15Ef9OhezGXza+ UTV6gmltxc+WZflL8Hu1Zl7JvjJpFN6xRw2kHtqqaU2LgSOdjaLMhOxp7BYAYLCJIQTV 0Z5A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=gwOWSXeXshx2pDY4YsRb8c4OJtdf4hRb8S0itmSW07o=; fh=fMhMPvo8duafGkM4xZHdH7fULbau3etefTGsKa+Qy7I=; b=nWxcs5cGJwFaXojqZY6DiycVjMvYwanz0HYMz0gNoQ1GQ8Y62bnf9KdPDc/9KDeTIp j6ZWiDk9RD5PK5Vk9CiLc+RwNWjXZGMHM25Zxj8tHBhuuJ2eJVWmMXO0jLVgml1/t9Ha USEVz+/ot8ueEkSJLoTiZbZhvmEgt5OEsl0MUgxvakHiMBO+tcZpciCkC9lT7p56ahio HqO7U9C3HO8b8/kSeslyo1pQgggz02GGJlXJY+cS1Yu8njUWdlbV79/F2QjFwpAOLagk 32ooB8TXxjoCAcdpyIiRr4Z1ibRtrj2oAePjq42+szDu2aPR2n1S9/s1Auncp8ArnBpO zUtQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=GFm1YhzK; arc=pass (i=1 spf=pass spfdomain=flex--ardb.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-74632-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74632-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x62-20020a638641000000b005ceb4a70188si7838369pgd.375.2024.02.21.03.37.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 03:37:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74632-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=GFm1YhzK; arc=pass (i=1 spf=pass spfdomain=flex--ardb.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-74632-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74632-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 70991283EB3 for ; Wed, 21 Feb 2024 11:37:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E5AB487AE; Wed, 21 Feb 2024 11:35:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="GFm1YhzK" Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E8B6481B4 for ; Wed, 21 Feb 2024 11:35:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708515342; cv=none; b=jT+Xl97dQuJIdwVUimGXz7MamZxLlly5oWiR0sINxodwBmc/Tjw0S5for6DG6/3Ksi7v0ev37FVo1qSg+tUTxtUn64jxcRz4ZOhfRGXo/aEnFo/H7yi30ufWqXRySY/quGjiXa9vckLuv0sR9zDSEo+T62Cnf0rUJ78dv4X3Il8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708515342; c=relaxed/simple; bh=/B1OP6vbuA5phGZhjfg4uQ2vHMJ2nJmV3L2eYZwfJcM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=T+YILn2zkPvEeng6U89PlhnP3x0JR2LKa2oEHtgKPZjk5/IR4fECChnuk0KoFVLC5MIt4BjDCwZhGF7uKmdX6AzdBKBwoUeZZIZzJ+IaQFPJ8dyqLumHWcTqD1K/f7/lSv8vqBm6D/AGAAvl72A6aBpLy2W8owY22WARQzBYhkw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=GFm1YhzK; arc=none smtp.client-ip=209.85.221.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-33d6eb5e5a9so860064f8f.3 for ; Wed, 21 Feb 2024 03:35:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708515339; x=1709120139; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=gwOWSXeXshx2pDY4YsRb8c4OJtdf4hRb8S0itmSW07o=; b=GFm1YhzKXCOxWJ742d1dqiKQB7zcXqKlcJY29YH5vgmp2CT2n/lZZ7q5jZ//A8FmYu UOY+2+kkyFTpnIWYAorBz47xlqkdP9wiO2VjdIp18JRtXbY/S5wP3cvhcr1LdPKwXweE lIlRYHcnx4oS4uhh3urfQ2jCVxBuvri37Q2nTInwL7lA4zecL85vrHaYop89H2iDurNz 34ae5Cg6xoeYRxtTQ1Ifd08bC3pfUKcYgNC2TB16kYFBBEMH8lvVzTzTst+Nf+bWWIHs grcfCCnmkI5JjRuWPky9iaBOzDqyNCFyeA9jx9QOexBMhlZguS6A9SJHJLpEhqGQRnAX 42QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708515339; x=1709120139; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gwOWSXeXshx2pDY4YsRb8c4OJtdf4hRb8S0itmSW07o=; b=D4v/NljHIixoaJgbnQd00P7yZqQrRS042piSvPSlXjsWlm64vr1c3KeVjoVBckDH+B a4E03nDFY1zBZ8i77nD2RFIFaqn0YdxJEJnkD9QU93RzS6Zms6QELi2NFRQjR6XSexKZ F4DbfREoj28z8O3vbD5wgnlJRbgrSnXlr5aw6evDOhLm+ciYviE8zyoByQEeRcBqqFDL 9ELXh/A5WRUQbI7W1unaypLiSIvgTdHO+1FpEo4Xiniz5Ddr9N3xPimvjca5j7uLD1eA iC+IDl80iHbTbtIBn0cLFXtHAOHg7TqIIR3n2MmoicgYHZspaFo1HABt3o8fXZDnHD0h t2hg== X-Gm-Message-State: AOJu0YxvrnP8CHqIKAdJ0wWWqrYu84h1Ue2HUyuijoGHDw/WETii0T/4 J6W1Ll2+NJqEyg4qlDTVQouCsowtio5Yu3J5ltepAnbfWh5GbcRP7j7Qtmy1i4j0GLEkdVFS/Q8 lu54rFH4rDGqwcefvUOcHFNRvNibNtdU2YeXciyiBH1pgCNAz0c3ZJeDsfbOM8CpnZAkZQY1Gvy EKSnyK+fJn6HmIla4bXxnX0QteNWwxVw== X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:a05:6000:1c03:b0:33d:804f:7bb3 with SMTP id ba3-20020a0560001c0300b0033d804f7bb3mr2030wrb.7.1708515339021; Wed, 21 Feb 2024 03:35:39 -0800 (PST) Date: Wed, 21 Feb 2024 12:35:09 +0100 In-Reply-To: <20240221113506.2565718-18-ardb+git@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240221113506.2565718-18-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=1451; i=ardb@kernel.org; h=from:subject; bh=HV5cVzg2bsj7zm/lufPEjuRMFtl5r6GlxXU96Wc4Zjs=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIfXq/TfS/Ie8Tyfs4TiZ2dY8/eqXuOJb6hbTC/44bpZM/ NZ6Myeko5SFQYyDQVZMkUVg9t93O09PlKp1niULM4eVCWQIAxenAExk2llGhlXHMqck8tmt/CX0 Ov6+atSy9U7+7FpOJUqvY+44crG28jH8D31+U3aHolG6bniHk2Phz7Pu3be/MxQ4L/q8NmmSX3w YDwA= X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240221113506.2565718-20-ardb+git@google.com> Subject: [PATCH v5 02/16] x86/startup_64: Use RIP_REL_REF() to assign phys_base From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: Ard Biesheuvel , Kevin Loughlin , Tom Lendacky , Dionna Glaze , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Andy Lutomirski , Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , Justin Stitt , Kees Cook , Brian Gerst , linux-arch@vger.kernel.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" From: Ard Biesheuvel phys_base is assigned from code that executes from a 1:1 mapping so it cannot use a plain access from C. Replace the use of fixup_pointer() with RIP_REL_REF(), which is better and simpler. While at it, move the assignment to before the addition of the SME mask so there is no need to subtract it again, and drop the unnecessary addition (phys_base is statically initialized to 0x0) Signed-off-by: Ard Biesheuvel --- arch/x86/kernel/head64.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index 1d6865eafe6a..f98f5b6a06b5 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c @@ -192,6 +192,7 @@ unsigned long __head __startup_64(unsigned long physaddr, * and the address I am actually running at. */ load_delta = physaddr - (unsigned long)(_text - __START_KERNEL_map); + RIP_REL_REF(phys_base) = load_delta; /* Is the address not 2M aligned? */ if (load_delta & ~PMD_MASK) @@ -301,12 +302,6 @@ unsigned long __head __startup_64(unsigned long physaddr, for (; i < PTRS_PER_PMD; i++) pmd[i] &= ~_PAGE_PRESENT; - /* - * Fixup phys_base - remove the memory encryption mask to obtain - * the true physical address. - */ - *fixup_long(&phys_base, physaddr) += load_delta - sme_get_me_mask(); - return sme_postprocess_startup(bp, pmd); } -- 2.44.0.rc0.258.g7320e95886-goog