From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 262CFC636D6 for ; Thu, 9 Feb 2023 14:09:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230181AbjBIOI6 (ORCPT ); Thu, 9 Feb 2023 09:08:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229761AbjBIOI5 (ORCPT ); Thu, 9 Feb 2023 09:08:57 -0500 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFB215DC0D; Thu, 9 Feb 2023 06:08:46 -0800 (PST) Received: from zn.tnic (p5de8e9fe.dip0.t-ipconnect.de [93.232.233.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 732E81EC06C0; Thu, 9 Feb 2023 15:08:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1675951725; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=Xou1RB46SDCgtcotYrQGJuKVYx7el1N56OECne0l+5Q=; b=DlH5Jenzb+b48eoxSOSc/kjrv112GJSGTCU9Q9mdQSdRgxeL9ZhklF4x+j5/OTdI/oVPtQ gX3ifob7NPiXXNoUJ964/uOTG2j1sf1Uv5GUecaxLhjXHdOMjeNW9hFjFGQdJrjlMpY0au M8VjkBac09LEvoBcFVh9jkVrgJ/GBuE= Date: Thu, 9 Feb 2023 15:08:39 +0100 From: Borislav Petkov To: Rick Edgecombe Cc: x86@kernel.org, "H . Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H . J . Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , Weijiang Yang , "Kirill A . Shutemov" , John Allen , kcc@google.com, eranian@google.com, rppt@kernel.org, jamorris@linux.microsoft.com, dethoma@microsoft.com, akpm@linux-foundation.org, Andrew.Cooper3@citrix.com, christina.schimpe@intel.com, Yu-cheng Yu Subject: Re: [PATCH v5 11/39] x86/mm: Update pte_modify for _PAGE_COW Message-ID: References: <20230119212317.8324-1-rick.p.edgecombe@intel.com> <20230119212317.8324-12-rick.p.edgecombe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230119212317.8324-12-rick.p.edgecombe@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-api@vger.kernel.org On Thu, Jan 19, 2023 at 01:22:49PM -0800, Rick Edgecombe wrote: > From: Yu-cheng Yu > > The Write=0,Dirty=1 PTE has been used to indicate copy-on-write pages. > However, newer x86 processors also regard a Write=0,Dirty=1 PTE as a > shadow stack page. In order to separate the two, the software-defined > _PAGE_DIRTY is changed to _PAGE_COW for the copy-on-write case, and > pte_*() are updated to do this. "In order to separate the two, change the software-defined ..." >From section "2) Describe your changes" in Documentation/process/submitting-patches.rst: "Describe your changes in imperative mood, e.g. "make xyzzy do frotz" instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy to do frotz", as if you are giving orders to the codebase to change its behaviour." > +static inline pte_t __pte_mkdirty(pte_t pte, bool soft) > +{ > + pteval_t dirty = _PAGE_DIRTY; > + > + if (soft) > + dirty |= _PAGE_SOFT_DIRTY; > + > + return pte_set_flags(pte, dirty); > +} Dunno, do you even need that __pte_mkdirty() helper? AFAIU, pte_mkdirty() will always set _PAGE_SOFT_DIRTY too so whatever the __pte_mkdirty() thing needs to do, you can simply do it by foot in the two callsites. And this way you won't have the confusion: should I use pte_mkdirty() or __pte_mkdirty()? Ditto for the pmd variants. Otherwise, this is starting to make more sense now. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette