Received: by 2002:ab2:68c1:0:b0:1fd:9a81:d0e4 with SMTP id e1csp235716lqp; Sat, 8 Jun 2024 13:55:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXY6YUVNtdTNUIG5xphOv4UZx0gBEG+JO0JsO3L36J/aWkP4ocVaH4VXRaIgXmdT7f59KL4xxv2f7JKaAXYrK7dHIh4uLh8xqHIKGj/WA== X-Google-Smtp-Source: AGHT+IGDnpH7ZO/RPTTm3mlOzylb8muWzjRIw5IBgaIEBgkVGpDkUA+IBlWsky1xeyejHs7VX4GE X-Received: by 2002:a05:6214:448d:b0:6b0:72c7:88d8 with SMTP id 6a1803df08f44-6b072c78912mr14919176d6.35.1717880135793; Sat, 08 Jun 2024 13:55:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717880135; cv=pass; d=google.com; s=arc-20160816; b=lTUrEaYsRSEIXB5hKF8WP9DNG+QuM8H0Fe9v/w4O3gstMcjJxisNYLNjiKNNSPYgol MXDZdDPc5Mr+SaE/FMpPERM29S8VAxgWs6x7UA74nVTFGWULPlp91jaHs2prd7UY0TJx m83/wq5XpF0q/ypHAnM1M0+3lqGAq2kJErXoUPkTTyspyF+h8wM/s/g9QF50E5zplhaR b7FMi4DL2kednPVgzZ7DK3HwDuubTcbntC3gEY9LgoeBAJYn8c84252uLVCO/RVqdLcM 8rcrD04sByy/DC/xJVaDraLwy805lrNQk3jYQjc1TRDVdi8KBG658Fw6eq0PYoUNI0F7 wnmQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=8fZXZV0kR4ym1XRcBTj6zdWLTsFZy0CZQ2wcW79A4Pg=; fh=vJGOYGd8DOMGKLNdyWvDGzKVJcq+H1WB8+TXzO9QZ18=; b=abDrTlmFfuy6859QRQ1k2KEQxmt2KwfGfLJAnVwEibSx7jgbOhn+388sOK8nuxSkL6 sH9zVsT9wKW21dQegUIabh2MhBUxVGeU9sAwx+ZTV3cZGCTrc+AFlMpTN8GWwWI5bOHt hIXjsxzk+8O2OqStolMXqObe/E19zMrv0OKOOTpF0htDpwBvRgr6yjPslL1KkMOZCmhR YQYafMMnrmZNVMJi6hdpYwlOZVEsGBlNIojch8/m2cnPTsAnCziTVEO6uv/Ty47u4jRM VLk+RJ6fRjbz8tQblptyTwufsScxqg/l1D0mDq5mW9/E1Asdhfz5PnE8TDnQgFHO4SIH scrA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="YQ5fiA/i"; arc=pass (i=1 spf=pass spfdomain=linuxfoundation.org dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-207189-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207189-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6b06e336c99si16498386d6.127.2024.06.08.13.55.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 13:55:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207189-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="YQ5fiA/i"; arc=pass (i=1 spf=pass spfdomain=linuxfoundation.org dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-207189-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207189-linux.lists.archive=gmail.com@vger.kernel.org" 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 667EE1C20D9A for ; Sat, 8 Jun 2024 20:55:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AE9E321A02; Sat, 8 Jun 2024 20:55:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="YQ5fiA/i" Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (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 23CC21B966 for ; Sat, 8 Jun 2024 20:55:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717880128; cv=none; b=eQc7MCY7WU8AYICheZySJFCgCS6rZxlJzydOgOQ7AoAVoH4LAROPM2rhjII1Il5EE6kTrA+SoO4mV93yG7G6KlLBtvQCwpuC38B72Lm8A1QlIQiQ2f7mTY5XDiIN5nTONd/cnnDfT9FjqSojSKYfBzJnGqPdmRYTmCvKDVYpJk8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717880128; c=relaxed/simple; bh=85qXbyqX6RxIt4uYLrSaAWXRZLFbmQAyyxDKG3decKw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=RreMcslfyPUoltGH+D1IMI0Fu3IlpTgLPzsbSWlKlZjA4mkq9LuAjuD2YVRHmxCT2WB3dQbS4rw5QZcVEfcPDzYCqNlgxBjlZQRuKRa3DwgT84C5ixISVpSmV7d/mpgEyR2Bo/aSuFv6PrHioeZ56hKlXjQXwNww6/7m9Eq2NKk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org; spf=pass smtp.mailfrom=linuxfoundation.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=YQ5fiA/i; arc=none smtp.client-ip=209.85.208.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linuxfoundation.org Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-57c7681ccf3so49605a12.2 for ; Sat, 08 Jun 2024 13:55:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1717880124; x=1718484924; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=8fZXZV0kR4ym1XRcBTj6zdWLTsFZy0CZQ2wcW79A4Pg=; b=YQ5fiA/i9irEZv950RSdF+rt1Q/nv0owxU5c2taFyR9SX5KN64c+AN0WKrr2ViIJv+ ZRGAVMLeYhfyDW9E1zmpcir+XT+EIy2/jKRwVZqm3eYUyX2zeoyijsUwyj+izMS/+v3m PtmzSG44bHWQU/+fk4scIfw1KPRf2uIdpLLfc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717880124; x=1718484924; h=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=8fZXZV0kR4ym1XRcBTj6zdWLTsFZy0CZQ2wcW79A4Pg=; b=jXJEyUu1btWbu9wkd2UKd2GdvpvtjXx8iz/w1dYigszbndyRLBczbtN8TVqTJgxV0/ kRIWl96yDX25Bt70++E/VqXrH3aG0i+AGwWqBtbL6wBVgvHKISxPdIa9NTRsCgELbIoK Y+XMBxhWPasFy4ZxZezxuaecCTqReDD2IZeaQpjnBTcmmB/ajFrQFDKAXV7w9Wp1Edoq PUa0eTc4mUhmRl2hDs3jjgmvruv1wqUmtj5Ny+PNH4z8mOzkfG3wKN637I422yjC+O0p a1xKTRLLF8nkYMbML04R4SvDNJ4B88U7pil0ZabSLM55VwTmMszgHGDb4U+4HO5Jq3O9 9k8Q== X-Gm-Message-State: AOJu0YzfE9zT2rzKFsHjYCtnhFY39lwacao7K70bwRtSMy4ir3Xv/Wyj z8CWqu+RRuR6pF+4P2Gi5pEIkSCrwlq5zJuP9kkImAEQJ0rquLL/XDLCQ5469Q58GMMpq8o4LHe +za8= X-Received: by 2002:a50:999b:0:b0:57c:610a:6e7f with SMTP id 4fb4d7f45d1cf-57c610a6eecmr2692272a12.11.1717880123927; Sat, 08 Jun 2024 13:55:23 -0700 (PDT) Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com. [209.85.218.45]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57c5fd78477sm2582194a12.40.2024.06.08.13.55.22 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 08 Jun 2024 13:55:22 -0700 (PDT) Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a68b54577aaso418815766b.3 for ; Sat, 08 Jun 2024 13:55:22 -0700 (PDT) X-Received: by 2002:a17:906:585:b0:a6f:1235:d82 with SMTP id a640c23a62f3a-a6f12350ed3mr42380466b.13.1717880121989; Sat, 08 Jun 2024 13:55:21 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240608193504.429644-2-torvalds@linux-foundation.org> In-Reply-To: <20240608193504.429644-2-torvalds@linux-foundation.org> From: Linus Torvalds Date: Sat, 8 Jun 2024 13:55:04 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] x86: add 'runtime constant' infrastructure To: Catalin Marinas , Will Deacon Cc: Linux Kernel Mailing List , linux-arch , Linux ARM Content-Type: multipart/mixed; boundary="0000000000007054e4061a6722a6" --0000000000007054e4061a6722a6 Content-Type: text/plain; charset="UTF-8" On Sat, 8 Jun 2024 at 12:43, Linus Torvalds wrote: > > Needs more comments and testing, but it works, and has a generic > fallback for architectures that don't support it. .. and here is the TOTALLY UNTESTED patch to implement the arm64 version of runtime constants. It almost certainly does not work. I'm too scared to test it. I may start to recognize arm64 instructions, but rewriting them on the fly is another thing entirely, and I'm fairly sure this needs an I$ sync and probably modifying the instructions using another address even during early boot. So this is a "throw it over the fence to the actually competent arm64 people" patch. Catalin, Will? This depends on the infrastructure that I added in https://lore.kernel.org/all/20240608193504.429644-2-torvalds@linux-foundation.org/ which is actually tested on the x86-64 side. I did test that the code generation looks superficially sane, and this generates mov x1, #0xcdef movk x1, #0x89ab, lsl #16 movk x1, #0x4567, lsl #32 movk x1, #0x123, lsl #48 ... lsr w0, w25, #12 ldr x0, [x1, x0, lsl #3] for the dcache hash lookup (those constants are obviously the ones that get rewritten after the hash table has been allocated and the size becomes fixed). And honestly, I may have gotten even the simple part of instruction rewriting wrong (ie maybe I'm filling in the wrong bit locations - I'm reading the architecture manual, not actually *testing* anything). Think of this patch mostly as a "look, adding another architecture isn't *that* hard - even if the constant value is spread out in the instructions". Linus --0000000000007054e4061a6722a6 Content-Type: text/x-patch; charset="US-ASCII"; name="0001-arm64-add-runtime-const-support.patch" Content-Disposition: attachment; filename="0001-arm64-add-runtime-const-support.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_lx6lemy50 RnJvbSBiZWZjM2Q0OTM2NmZiMDQ5YjY1Njc5ZmIzN2ZhNzAzZmU0MTlhN2U4IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBMaW51cyBUb3J2YWxkcyA8dG9ydmFsZHNAbGludXgtZm91bmRh dGlvbi5vcmc+CkRhdGU6IFNhdCwgOCBKdW4gMjAyNCAxMzoyMj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