Message ID | 20240221113506.2565718-20-ardb+git@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-74632-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp978561dyc; Wed, 21 Feb 2024 03:37:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVJcVjE1zaGRj3PODAzxXMn8eGdHQNMVHC9qlO/G31Lo58LyjhkjFvOQs9++ugyERGT9/8GhQWvb3lE0kO62qdTemu40A== X-Google-Smtp-Source: AGHT+IETutsDe+m1/stNkWncmK4aLflFgG1netiCsY4gqAGYAXpBh46XN0mzo0DjhVM1q3hlhqcU X-Received: by 2002:a9d:69c4:0:b0:6e4:3775:683b with SMTP id v4-20020a9d69c4000000b006e43775683bmr14356946oto.34.1708515466996; Wed, 21 Feb 2024 03:37:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708515466; cv=pass; d=google.com; s=arc-20160816; b=NYcdsNehJPAxtjVdH1B9UQWRzWyE9b29C4ZkIOiV4wu+VvuftRDJMeoCpSjfLVdB4n xKCOpCGgG2/ceMXGcepFT3fIugHJ+Q+lMAzvBKVcS4aqU7BaKlcgoQoxY3gk9yjWJEpN TStC710IS5hTTh3D4FgTKxBMZlzagR1yWlictTY1d/pJr0REz1+UagQjy+LItQGy8ftC J7YD8vPPRPFslRH91GGWyaU6NJPOowsQAepnq2sPwZTeF58djHChc5oAZNcS+J5ZTKeG sYDIdGk4X8vlvMreG8foZJ8FYLlGIobWjIujzkaM/986fZrfISf+VmBiCHyWgBI5L99o sU5A== 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74632-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b22-20020a637156000000b005e1c5c9a11esi6045819pgn.230.2024.02.21.03.37.46 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 03:37:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74632-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74632-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 09FF8B241AD for <ouuuleilei@gmail.com>; Wed, 21 Feb 2024 11:37:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AFC034C630; Wed, 21 Feb 2024 11:35:45 +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 <linux-kernel@vger.kernel.org>; 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 <linux-kernel@vger.kernel.org>; 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: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> 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 <ardb+git@google.com> To: linux-kernel@vger.kernel.org Cc: Ard Biesheuvel <ardb@kernel.org>, Kevin Loughlin <kevinloughlin@google.com>, Tom Lendacky <thomas.lendacky@amd.com>, Dionna Glaze <dionnaglaze@google.com>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, Andy Lutomirski <luto@kernel.org>, Arnd Bergmann <arnd@arndb.de>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Justin Stitt <justinstitt@google.com>, Kees Cook <keescook@chromium.org>, Brian Gerst <brgerst@gmail.com>, linux-arch@vger.kernel.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791508314537331794 X-GMAIL-MSGID: 1791508314537331794 |
Series |
x86: Confine early 1:1 mapped startup code
|
|
Commit Message
Ard Biesheuvel
Feb. 21, 2024, 11:35 a.m. UTC
From: Ard Biesheuvel <ardb@kernel.org> 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 <ardb@kernel.org> --- 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); }