Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2159805rdb; Sun, 11 Feb 2024 14:37:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV1DYC/E8OUepQ58Amm6XMRIga9YZ5VXdeuZ22iqHYbAhNDn6QJjLEv1cYFa9FK2PGyfJwiZZNcoTOQHFhMEqB7bZ9Ec+DAev6OM2s63A== X-Google-Smtp-Source: AGHT+IEW+9HGzLaOyHMicNDH4A1kGZMaKCt+au7gQaBwZyItLq5BD068dRtNgKjx+hC3gGpsvOJT X-Received: by 2002:a17:906:cf8b:b0:a30:8c7e:5f7e with SMTP id um11-20020a170906cf8b00b00a308c7e5f7emr3442943ejb.28.1707691034765; Sun, 11 Feb 2024 14:37:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707691034; cv=pass; d=google.com; s=arc-20160816; b=DsSRKv0SNDJJzP2Sp8eQtlKXERL+azlg3HUKqknCXeOOY80ORl9ZqeJufsZIlYzKlA mIMf0pgiIrBHTUF+jFxnwTI2HT+4ji3hGw3nc4NwvRKK01RZ0/jVuxTi8/cH3T9aAGjx 7oFa54L/qq9jYq8aOYy59ZXF7uZTZf4ky7NONegDqiExQFL0wog4eBKxOwcQaut+iUtJ sC2+3zm5jQ3Pjz4sFVwpDi+v13yFx5HFAI5rfY1Kwqr1PqtxvrTn4ngS/3AX/MRcjODd YwF2et4jGwUSmzwiCKOCvHVR4P1Bwf4zKMzJXUEqz6s8aeR+kJYy07qpybWmH35oVRF6 1DEw== 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=AVsG8xx2gdw0w3VwalmCQ9LcJIy7NUUicNPAWxxGxaU=; fh=go0zg9QUgYiDripHuP1efkQkPUpVzdkKRx5SPx8fYnw=; b=u9cwUctbVmmLrwsYVEIPfAyhDquYpbda+VhWZmE/xVRsf3gw8vyrYPojNLWW3NP9Sb PZf/3y0HDm6a1fa9rlbhgmvHgJNA0X2ddhVmN1DufwZqZ+710JCs/d8doQT2TVWnov4B rgH9tpREYozwOEHEONqCASjFvyNAY5Fe8OSNNhUfyOdLhFxKxvwOHswIO3q4EkcD6kiG Cj6uD0Hg9oVyznJGyxNFOaUwkz7bspioMAC1bpYvabCN/vdTfhwnVeKE5EX8/emhiLP0 ORqb3YsE63DGcAJeXe2SNLNWekkl4kva+dB5WOfsCC8bBil35/TMiY8DDkk8a7gXi9jk GO8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="TIFMKM/c"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-60972-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60972-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCVTFNiKIqHJgCNYrGvOMejbfvXt6E6oj2R8bcJ5sBUtDIx5oRAXDJoG28v2R2bKXb3Jt6tloHPZs+RGZbIbAD8u21zoRtf/BZjCdSLZ8w== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i8-20020a170906250800b00a3c46f38f6bsi1621120ejb.385.2024.02.11.14.37.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 14:37:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60972-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="TIFMKM/c"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-60972-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60972-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 8616A1F22097 for ; Sun, 11 Feb 2024 22:37:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61C4E17542; Sun, 11 Feb 2024 22:37:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TIFMKM/c" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83ED71426A; Sun, 11 Feb 2024 22:37:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707691025; cv=none; b=iyq9b5JgEHQ8evO4YjzIbWG4+U51h7Nnz+/np+Cqwz5zvJ0CaP+ICMwOAeymjFYSGlIRnykscyBnwrybRPilY+ohT3ae+qPIUShwoQxI0bI30wkWy3jxSNKpd3fhcYRu4ysN2G4c6WUjpEheDqCkRKoTchcRjlrTkIyUQR7NLP4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707691025; c=relaxed/simple; bh=v4G6ehhPG/T4ElMEaTqhlNoQjbCZltvlaQ9iSgQ/jqs=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=CjWu3huFL3kI3GqJrKWyf7q2ID5d19xJ0lrgUmdcnjFrZ9xxOP7IHsWuXd29YAXjZ6Woga4rtbWdrCHyunEWY7gEr4w2f7sG65OM8JPdG5i4Egp3AENc7l+zzc26wjqT+Jkmn8xwzQ+wCR1y8dqlj6WwBC7Akc2r1LtnpRVigQw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TIFMKM/c; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D3D6C43390; Sun, 11 Feb 2024 22:37:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707691025; bh=v4G6ehhPG/T4ElMEaTqhlNoQjbCZltvlaQ9iSgQ/jqs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=TIFMKM/caEh5dJ+bulkCR0q0gdp8pENZGkgU9CkmDCd5Oq1bSaUzntyguvgsJOvv4 gjTjnGKCNzWlTToma07fms9Vcw2c+AZ0gxd1qaIR1L+7WNH8f+CnvuF/kDaPJJMAgG OeXcjmQI/c3V4bHwvSaaqgOu2o7bzLd42KFmhOPW3zZSd25LDzQ1deBLdDJyQTCzkK ikJMXpN0zJjpVanMBA070l+UVbhVC9+PLB5jUZdeLdtYULy1GMvyS17nC0QHaYBTIc wJ2pxMbg199kFs/b3OTVOd+tYLkfoSzSiUWVWn3jKHzcu/N7DK8DUYZWSXVavA0Mo/ /2qdpBvaOXosg== Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2d0dc3fdd1bso26130321fa.0; Sun, 11 Feb 2024 14:37:04 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVQ/g7EfLcg1gzoWUj9jQYcaXoZ2VERuquZ5TNFhkfE1K6LS1xULNTKgO/R3EPf8zM4mOFDPGye7x//F+qyXxobDwsVfXxPJL+/suJ44zlRDHftPQiflJ1gFvTZIyQnZPrfg7jWpgOJTA== X-Gm-Message-State: AOJu0YwZEsIYefjsmgn+EReJXTSbAd8m3aC83NO/nsK/dYlUH4KnLoa/ p+/5oHjTcRbuzvCLnXfgu6/ASh5jGzOf9rRi8l0vl9q/R8874FXQ58hG2br0nyI+NLBaRKjoQJv 4C+zFU4FfdT2rci3v4sWpYl/WWBg= X-Received: by 2002:ac2:4579:0:b0:511:87b7:6d88 with SMTP id k25-20020ac24579000000b0051187b76d88mr1609035lfm.32.1707691023239; Sun, 11 Feb 2024 14:37:03 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240129180502.4069817-21-ardb+git@google.com> <20240129180502.4069817-27-ardb+git@google.com> <20240207132922.GSZcOFspSGaVluJo92@fat_crate.local> <20240210104039.GAZcdSp7dRbgqBy3fg@fat_crate.local> In-Reply-To: <20240210104039.GAZcdSp7dRbgqBy3fg@fat_crate.local> From: Ard Biesheuvel Date: Sun, 11 Feb 2024 23:36:51 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 06/19] x86/startup_64: Drop global variables keeping track of LA57 state To: Borislav Petkov Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Kevin Loughlin , Tom Lendacky , Dionna Glaze , Thomas Gleixner , Ingo Molnar , 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" On Sat, 10 Feb 2024 at 11:41, Borislav Petkov wrote: > > On Fri, Feb 09, 2024 at 01:55:02PM +0000, Ard Biesheuvel wrote: > > I was trying to get rid of global variable assignments and accesses > > from the 1:1 mapping, but since we cannot get rid of those entirely, > > we might just keep __pgtable_l5_enabled but use RIP_REL_REF() in the > > accessors, and move the assignment to the asm startup code. > > Yeah. > > > asm(ALTERNATIVE_TERNARY( > > "movq %%cr4, %[reg] \n\t btl %[la57], %k[reg]" CC_SET(c), > > %P[feat], "stc", "clc") > > : [reg] "=r" (r), CC_OUT(c) (ret) > > : [feat] "i" (X86_FEATURE_LA57), > > [la57] "i" (X86_CR4_LA57_BIT) > > : "cc"); > > Creative :) > > > but we'd still have two versions in that case. > > Yap. RIP_REL_REF() ain't too bad ... > We can actually rip all of that stuff out, and have only a single implementation of pgtable_l5_enabled() that is not based on a variable at all. It results in a nice cleanup, but I'll keep it as a separate patch in the next revision so we can easily drop it if preferred.