From patchwork Wed Feb 21 11:35:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 204167 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp978522dyc; Wed, 21 Feb 2024 03:37:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXqNyG+zj58mFoWIv6aYnIk0OU36V4B8H3AuJWQhumD3zUC8T6pNn4I88qa/OCTpUnIjO6dmJTZAPkowV6Rspyl3m2Z4w== X-Google-Smtp-Source: AGHT+IEl3Qrcc3VLHpw1sd9rMeCagWl/ctP+eDCAbbWxJbgPTTFjD7YR0uk5CA961j0lBa0Hhpgq X-Received: by 2002:a05:6218:2615:b0:17b:f62:b45 with SMTP id oy21-20020a056218261500b0017b0f620b45mr19651824rwc.12.1708515460743; Wed, 21 Feb 2024 03:37:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708515460; cv=pass; d=google.com; s=arc-20160816; b=GT9Zvw4Hh93dLG54oiPlhLBhC/PGdO0D7pIeVVwEOWMwu2FA4iVpUyCkaym8lqpYYs t1KPHbaT00jwIVLAV/QmRFTHjyirZgUaJLIf0eQauY8YbX0Q/mTbd8NnW1aCpLCaidUA LW7TilhWgrGKZNRPTWczmh18mP6SymYCvrORQin2iD5Aimc/nUwyuQIEnEAVHkKeNYzn RQ/YI5VNWdIelX/s6ASbxx2hAz5fXmy+7cfy4D7lejXfEq+4OVUWcf6Zyg81RbZPoglC c/Grlta+q0MlIbKBq0pHsnmC2Rl1PpeRf2OeA/hP2rWFhOHfn62dnyz7DI1xgJrJOJvl TqyA== 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=0rqzUwS6BdxGjI3H1JUFmWLh2DB/nlQLPYKogLCLbB8=; fh=fMhMPvo8duafGkM4xZHdH7fULbau3etefTGsKa+Qy7I=; b=Rj0coEv/QiqQiA8xub6+TZUDr1ZERq1zcQIFbwgZ3ozGtE7J3YJIvjIod+HBptpK1V I2+FtWMGVclpDBZ0e2YIdDG5pJ4cTKBXnwTz6nx0PMgQWpJJy8VnYqXjQQwOFQNEzWQg Eq4O3VqoqgeTqXCoYkzNEZZOdgMPo6BHv0PCIrDuTh4FkBhlSU5d7PooYsH0BwrlA1X5 L0J9yO3iIiTHrieiuPMYu7pLCh1T9IsCYJ+gwYlaL2oKLXv273j3SWRh1L3+II3Gnm80 w7ic6x4HaDAP1uu1l96hGkJbxXMbxx6P5JEvb4CxdzqoXeYdxI+cZ+VggcUaTcjoX2ie 5pvg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ysv8a2Xv; 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-74634-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74634-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id cj22-20020a056a00299600b006e48313db5asi2239836pfb.83.2024.02.21.03.37.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 03:37:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74634-ouuuleilei=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=ysv8a2Xv; 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-74634-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74634-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 88C3B283ABF for ; Wed, 21 Feb 2024 11:37:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F23E24CB4A; Wed, 21 Feb 2024 11:35:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ysv8a2Xv" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (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 CC6314C634 for ; Wed, 21 Feb 2024 11:35:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708515347; cv=none; b=P6XlCJjqZnYzzv9q6+mVUFHYU+2wrsBSWEVMrhBTwURHielBrUNKzQ6yEd2EUssnY/6JrA40onD91yDUmjc5Kk3dDO6j1TJr7FLSDDXL9Smb9FC5+6HDl/XeyHGGIi5sjOXC/WHmVJXtOryxf5biLqEZEfWlS0Cs4XL+gyO2Lx8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708515347; c=relaxed/simple; bh=6Y7B3eAU7WFGxIfJIx2em1X2j1KbkoJBGgvBRFQVJuk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ctCkypFDhxQBR4w+n8Y9dZDufkA4NCFvgBHqcs5cfsKv2DFZ2gWBh07LF+7lql5IiW5jvZdR7dWzGw7u0m5v22x6CdPAlk6964j77xeOMYtYZGZNq3QZ1NrJwJ2yDBPAX4jQ7/pVA/zVOQgWvR+vPSl0/vcIhWtaec522CgsI1k= 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=ysv8a2Xv; arc=none smtp.client-ip=209.85.128.202 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-yw1-f202.google.com with SMTP id 00721157ae682-6088a755299so4077387b3.1 for ; Wed, 21 Feb 2024 03:35:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708515345; x=1709120145; 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=0rqzUwS6BdxGjI3H1JUFmWLh2DB/nlQLPYKogLCLbB8=; b=ysv8a2XvMPZsZwkeZTnIkW8Dbj6ADJcYD6YqvfAITSGcBc13xHyDbI1xO6jTYs4Hre DNu2TS74LhzOWhjDEz3FvtS0eQ8k336xSXvbj2ucGOG6wrrgsZAhFKbRjJFO4HEYACEo MJJU7bowIeaScEJjDX0mY+iP5VcpFw/JH2hH0KxEJUlDplgBuRzERISP6eJkTYvMBO8O 2yFjjlpWHViUzlN6/UYiN0/9dtQ++68Tt4CfEHqaTl1d92HDDjmIrMguX7BF5t1AR7bL pkvm1Gr5VpeFK5/9JD4KCWWWZ1Vy9PNWb+QpDSnG/Mxfdb/5w5W1HUXsj4fOvgTNhrIk J5jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708515345; x=1709120145; 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=0rqzUwS6BdxGjI3H1JUFmWLh2DB/nlQLPYKogLCLbB8=; b=jHw4pezBzsMpe7Nlm9RkSUbNPlpCC8cmFCy8HXwXKry1iEi/GipaK5reKl2b7hNRfU RRFLTzUhMKTAVnCssLKDwwIggrC8AptD6Gkm3+GzZgBUqQ+cPeUmbbrJFTMP26f7d/Lf 5Koco5XmFJq5YPAzWVpzF08/lmi4wNMYSGiNz83nMIWBTTNHIlO61xrE/fKAnMLFaWgM rmH5qXlmhd0uMpwoxXdFYxM6wEvI7Fu69XB48kbFUh31x6yx6lnLpj+dakJ6PcLtvwnf Xj17l48uV0NV8RvGsLm2hYl++JyzrE8Nu40o90jmqOtLfweiEhu4f49BcvdqJcReezNl b7Zw== X-Gm-Message-State: AOJu0Yw0bq42u8n+U8ijpYkZa0G4ohUha9N2KLkrWC+bDJigkJqZga1r NZHPJfflgkxi1edr7m9HaDCKp+Hiw8FDp/IrDiCd/8Wjc+lo3NvN5ZHF0mPwudx7elIEhqpJt8a DHss4yu6dBZ8USg6Q82Ki37SqSu1pjhTjxk8/kCaZcaQmSR2Bw//zWItecA9bQvK0RAS4Kc4gtQ Shv9653MeCMn00y7045hz5+6idEYYlIw== X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:a81:5748:0:b0:607:c418:33ba with SMTP id l69-20020a815748000000b00607c41833bamr4147129ywb.8.1708515344377; Wed, 21 Feb 2024 03:35:44 -0800 (PST) Date: Wed, 21 Feb 2024 12:35:11 +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=1147; i=ardb@kernel.org; h=from:subject; bh=e7Puh3E2XK1VJqqP8geKZexKLK94zY042KFjfKEULUs=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIfXq/bd/VsVJTi+bPPmYuH9fB1t473PjspnToo1YUsxUq 2rZ/8p1lLIwiHEwyIopsgjM/vtu5+mJUrXOs2Rh5rAygQxh4OIUgIlcn8fwP59By9ztn+WWpIp/ Ox3ZZ2pacQjfWxM61eabxvsZwdx2xxj+2ZrtjxF+psy/dvm6zgKZQ2ypEpVS2Y8L2oKWh7RmbCt kBgA= X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240221113506.2565718-22-ardb+git@google.com> Subject: [PATCH v5 04/16] x86/startup_64: Use RIP_REL_REF() to access __supported_pte_mask 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791508307867700271 X-GMAIL-MSGID: 1791508307867700271 From: Ard Biesheuvel __supported_pte_mask is accessed 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. Signed-off-by: Ard Biesheuvel --- arch/x86/kernel/head64.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index 2ac904110f6a..e2573ddae32f 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c @@ -177,7 +177,6 @@ unsigned long __head __startup_64(unsigned long physaddr, p4dval_t *p4d; pudval_t *pud; pmdval_t *pmd, pmd_entry; - pteval_t *mask_ptr; bool la57; int i; @@ -259,8 +258,7 @@ unsigned long __head __startup_64(unsigned long physaddr, pmd_entry = __PAGE_KERNEL_LARGE_EXEC & ~_PAGE_GLOBAL; /* Filter out unsupported __PAGE_KERNEL_* bits: */ - mask_ptr = fixup_pointer(&__supported_pte_mask, physaddr); - pmd_entry &= *mask_ptr; + pmd_entry &= RIP_REL_REF(__supported_pte_mask); pmd_entry += sme_get_me_mask(); pmd_entry += physaddr;