Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp795251lql; Mon, 11 Mar 2024 19:17:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUWdSkM9vT3v1h/DuQfhXO3YS6u95JizLQMLBQmh4NvdRjIsNXGa9Derd3ttSKAtwSH/PLhITzGaPl80zEfE/yN/Z/wJHIgQQgqXqIoSA== X-Google-Smtp-Source: AGHT+IGadAEpGnWt1D1C7t+fakMB83KsHlCM7PPyXAkMxD39eqaHnE3FlyWd9PbmlgJ7KqNDdwWi X-Received: by 2002:a05:6830:1084:b0:6e5:9db:d9d9 with SMTP id y4-20020a056830108400b006e509dbd9d9mr595534oto.30.1710209831834; Mon, 11 Mar 2024 19:17:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710209831; cv=pass; d=google.com; s=arc-20160816; b=iefroyYArCkuPV/RPaaBUdMF1diHsWaoAaYOn2Tq6J1fgND+fqeGqCtI8efNQczlUI Z9onVUaG4l1RbE0XdCtGoKdE/tTBKMZaaSN/VKPU6ANMipMe2SIqdIODpXfkoUmKAkiF YdAzCLKiaPPzt/SfvmxmxMOKFT3dsSqDqwFdwBBf/pBZi65CAF3ZiWcl6FWJCsHFfxqK xHfTNyjxFWMwMuySREQ5O8lxFv8f9OFi6ypDiYgXajDaukyDn9FEk9AuPrgUHwgZo8uI nxmc/1p9soqT0DP0c7LsCNoi5iSlg3Y8k8+GbRVm2DSX9LsHTAvDr8o7QjLiMfpZuK0O VeJw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:subject:cc:to:from:date:references :in-reply-to:message-id:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:user-agent:feedback-id:dkim-signature; bh=huqsfs/gqHP7WNpddQZKi41pXn9innZVvk5Ci35Lw5w=; fh=T5lLuy2xjnLNbQfoyk5PcshQ/RumI2vRxR7sn9IQXeY=; b=XFajRKg/NQri1W/rkugt/Z1pZGyFMydsQMDn83k90NEuXe9Dv0fMVcPGlVE6Bd2Lvr VacSuiCEVCYWqq2/wAWlwTefPqfV+upZKOTmOSwxrdOmO2pFZSFxIMblgvVhEqYE5P98 LkDOSSUWEPsaK5v5UbZ5u0Qnj9/gdGfcwvaRavQ8jZ4oNhSILLk14i9J/qy53kK4Tjbt 1hTxBAYcyGBexk5m6kECtSdqu7wDQ1j6ARZOhAKy+lyUQUM6C65FhOjr4CkueO+0l4zj cA3NsaGHPkxQ0wbpBNLenBV51cNsbByxS+FnmVGqaFT929yKvuEI/TrbmvSuR4ZLw/sV fqDQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jU4tN9T4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-99761-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99761-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id r16-20020a632050000000b005d412d0f51esi5861687pgm.661.2024.03.11.19.17.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 19:17:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99761-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=@kernel.org header.s=k20201202 header.b=jU4tN9T4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-99761-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99761-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7908A2826D1 for ; Tue, 12 Mar 2024 02:17:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E2BCD6FCA; Tue, 12 Mar 2024 02:17:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jU4tN9T4" 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 0728C5CB0 for ; Tue, 12 Mar 2024 02:17:03 +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=1710209824; cv=none; b=BrVTvKDyINv4Jm9hGtzBBEEOj0K0FeGkgWoFMCFbWEBDz+rPhY/68Pw6Ls9NXR43RBQuNlWy3OM0U16ejjJY2oHm2DULP/yyJ178cZPJ4eOGhkOFJbMbz5UJ4o576DkhuueVoPqEaS8GmJ/+NXEjoWEQ12uwF2qmKjUt2RpxsJ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710209824; c=relaxed/simple; bh=nSh75CPRfKS/KL7VFhltqLjVu/hr3RGaBOR3B0hYW/s=; h=MIME-Version:Message-Id:In-Reply-To:References:Date:From:To:Cc: Subject:Content-Type; b=Gy/Ty1FOrtUjTL0UD3KUViFlEAlbCGXXXnCWBqdOuJ0ftL5wbfcEiC1ZHX0aMussdA1OZ7CRPaZPLn7TaRD+npjyq0733taTKKzThOs2R7kT7wN0OewbwMDyDz2y0xp7vVpYrnK9/qdf+/OfVKC7YdvjWZ80WIjacqAFTyBm9Bw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jU4tN9T4; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF8E2C433F1; Tue, 12 Mar 2024 02:17:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710209823; bh=nSh75CPRfKS/KL7VFhltqLjVu/hr3RGaBOR3B0hYW/s=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=jU4tN9T4xZemWRp+aXvoA/nmIstbNbyfBrRtZQV/X1XTyN3vR3RRMsl8Falb/Eapk 0tl7+cFfvtFDNt45YT7ClSm3uUMhKLjnVhRAKj5cDo8eYBkDOAeSBvU4lKodScXl4E daz2W+DaV4Py7qRM+Lw29u3RHVLtSWGJAnYVO27oz/7WsdANyrtYznMz0n1WE+JB8j RVj2AxuemkNpgYsHQ/0DtjjXzw17+hzz8WMq8gsWPYXj2Z5p2ZEa4x0WDV+FJS6PPs Eq4iePJr/YunqK9MORid3S155idnkzu0XYgP4yDE4NWweXpvWtNYJ84FAHMErkGUvt l+2oXSEZOIKkA== Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfauth.nyi.internal (Postfix) with ESMTP id C05B5120006A; Mon, 11 Mar 2024 22:17:00 -0400 (EDT) Received: from imap48 ([10.202.2.98]) by compute3.internal (MEProxy); Mon, 11 Mar 2024 22:17:00 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrjedvgdeghecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvvefutgfgsehtqhertderreejnecuhfhrohhmpedftehn ugihucfnuhhtohhmihhrshhkihdfuceolhhuthhosehkvghrnhgvlhdrohhrgheqnecugg ftrfgrthhtvghrnhepudevffdvgedvfefhgeejjeelgfdtffeukedugfekuddvtedvudei leeugfejgefgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homheprghnugihodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdduudeiudek heeifedvqddvieefudeiiedtkedqlhhuthhopeepkhgvrhhnvghlrdhorhhgsehlihhnuh igrdhluhhtohdruhhs X-ME-Proxy: Feedback-ID: ieff94742:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 328E931A0065; Mon, 11 Mar 2024 22:16:59 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-251-g8332da0bf6-fm-20240305.001-g8332da0b Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <0645946c-f4f5-43b1-a9a0-03ed139036b3@app.fastmail.com> In-Reply-To: References: <20240311164638.2015063-1-pasha.tatashin@soleen.com> <20240311164638.2015063-12-pasha.tatashin@soleen.com> <3e180c07-53db-4acb-a75c-1a33447d81af@app.fastmail.com> <08EFDEDB-7BBB-4D9C-B7E5-D7370EC609BE@gmail.com> Date: Mon, 11 Mar 2024 19:16:38 -0700 From: "Andy Lutomirski" To: "H. Peter Anvin" , "Dave Hansen" , "Nadav Amit" Cc: "Pasha Tatashin" , "Linux Kernel Mailing List" , linux-mm , "Andrew Morton" , "the arch/x86 maintainers" , "Borislav Petkov" , "Christian Brauner" , bristot@redhat.com, "Ben Segall" , "Dave Hansen" , dianders@chromium.org, dietmar.eggemann@arm.com, eric.devolder@oracle.com, hca@linux.ibm.com, "hch@infradead.org" , "Jacob Pan" , "Jason Gunthorpe" , jpoimboe@kernel.org, "Joerg Roedel" , juri.lelli@redhat.com, "Kent Overstreet" , kinseyho@google.com, "Kirill A. Shutemov" , lstoakes@gmail.com, mgorman@suse.de, mic@digikod.net, michael.christie@oracle.com, "Ingo Molnar" , mjguzik@gmail.com, "Michael S. Tsirkin" , "Nicholas Piggin" , "Peter Zijlstra (Intel)" , "Petr Mladek" , "Rick P Edgecombe" , "Steven Rostedt" , "Suren Baghdasaryan" , "Thomas Gleixner" , "Uladzislau Rezki" , vincent.guittot@linaro.org, vschneid@redhat.com Subject: Re: [RFC 11/14] x86: add support for Dynamic Kernel Stacks Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable On Mon, Mar 11, 2024, at 6:25 PM, H. Peter Anvin wrote: > On March 11, 2024 5:53:33 PM PDT, Dave Hansen = wrote: >>On 3/11/24 16:56, Nadav Amit wrote: >>> So you can look on the dirty-bit, which is not being set >>> speculatively and save yourself one problem. >>Define "set speculatively". :) >> >>> If software on one logical processor writes to a page while software >>> on another logical processor concurrently clears the R/W flag in the >>> paging-structure entry that maps the page, execution on some >>> processors may result in the entry=E2=80=99s dirty flag being set (d= ue to the >>> write on the first logical processor) and the entry=E2=80=99s R/W fl= ag being >>> clear (due to the update to the entry on the second logical >>> processor). >> >>In other words, you'll see both a fault *AND* the dirty bit. The write >>never retired and the dirty bit is set. >> >>Does that count as being set speculatively? >> >>That's just the behavior that the SDM explicitly admits to. > > Indeed; both the A and D bits are by design permissive; that is, the=20 > hardware can set them at any time. > > The only guarantees are: > > 1. The hardware will not set the A bit on a not present late, nor the = D=20 > bit on a read only page. Wait a sec. What about setting the D bit on a not-present page? I always assumed that the actual intended purpose of the D bit was for t= hings like file mapping. Imagine an alternate universe in which Linux u= sed hardware dirty tracking instead of relying on do_wp_page, etc. mmap(..., MAP_SHARED): PTE is created, read-write, clean user program may or may not write to the page. Now either munmap is called or the kernel needs to reclaim memory. So t= he kernel checks if the page is dirty and, if so, writes it back, and th= en unmaps it. Now some silly people invented SMP, so this needs an atomic operation: = xchg the PTE to all-zeros, see if the dirty bit is set, and, if itt's se= t, write back the page. Otherwise discard it. Does this really not work on Intel CPU?