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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBAD0C4332F for ; Wed, 16 Nov 2022 10:10:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 277FD6B0071; Wed, 16 Nov 2022 05:10:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 228216B0072; Wed, 16 Nov 2022 05:10:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0CA648E0001; Wed, 16 Nov 2022 05:10:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id EF9D06B0071 for ; Wed, 16 Nov 2022 05:10:09 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B1076160338 for ; Wed, 16 Nov 2022 10:10:09 +0000 (UTC) X-FDA: 80138884938.18.4C74BEA Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf04.hostedemail.com (Postfix) with ESMTP id 4314F40006 for ; Wed, 16 Nov 2022 10:10:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=IP43t3hJu1Ut6R9gno8nfJ5M4E7h1wkQRd32HTSGUjo=; b=cwGxlcmqkrn87V+pOU9TIN5gsZ k8k+ZoTpU4HiUzsqFp0EdEccYC9aLsFjSnFJKHVZkUssN+8m1CajV6ccnmwTQLTzAvE3fh0Eg9UWj 8Vjq2DE8gsMlpoe3bNrOPKMnoimSk4Hy4A1AembykPKeRTvnNsVwJrqZ5S5Rq1xy2QrGvR0VQpvzR aqBiXKrgeyXbwJA2FSEv5araqwycTv9CHOUplwwq23PBbX+jaY3gKF6bBpvmm1ZwIvXGV37I2R7kL 9eUIxURMM9d6ZtfgZRR07+9oQGfYZUe+x5IjIJAFy3DxvvCkM9Tm7pQyMPG0BKjuL9SeQ5YQCqn1Q srVTO45w==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovFMY-001GVE-G6; Wed, 16 Nov 2022 10:09:46 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id E8DE730002E; Wed, 16 Nov 2022 11:09:43 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 8B0392B5E08EB; Wed, 16 Nov 2022 11:09:43 +0100 (CET) Date: Wed, 16 Nov 2022 11:09:43 +0100 From: Peter Zijlstra To: "Edgecombe, Rick P" Cc: "bsingharora@gmail.com" , "hpa@zytor.com" , "Syromiatnikov, Eugene" , "rdunlap@infradead.org" , "keescook@chromium.org" , "Yu, Yu-cheng" , "Eranian, Stephane" , "kirill.shutemov@linux.intel.com" , "dave.hansen@linux.intel.com" , "linux-mm@kvack.org" , "fweimer@redhat.com" , "nadav.amit@gmail.com" , "jannh@google.com" , "dethoma@microsoft.com" , "kcc@google.com" , "linux-arch@vger.kernel.org" , "bp@alien8.de" , "oleg@redhat.com" , "hjl.tools@gmail.com" , "Yang, Weijiang" , "Lutomirski, Andy" , "jamorris@linux.microsoft.com" , "arnd@arndb.de" , "tglx@linutronix.de" , "pavel@ucw.cz" , "mike.kravetz@oracle.com" , "x86@kernel.org" , "linux-doc@vger.kernel.org" , "rppt@kernel.org" , "john.allen@amd.com" , "mingo@redhat.com" , "Shankar, Ravi V" , "corbet@lwn.net" , "linux-kernel@vger.kernel.org" , "linux-api@vger.kernel.org" , "gorcunov@gmail.com" , "akpm@linux-foundation.org" Subject: Re: [PATCH v3 15/37] x86/mm: Check Shadow Stack page fault errors Message-ID: References: <20221104223604.29615-1-rick.p.edgecombe@intel.com> <20221104223604.29615-16-rick.p.edgecombe@intel.com> <2766aedef0780f03b81ea7dfea42dffb328e21f1.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2766aedef0780f03b81ea7dfea42dffb328e21f1.camel@intel.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668593409; a=rsa-sha256; cv=none; b=mMaG03YYL2wBh7guuW3m0ioVnBpC1+rzVtQ48o8h5icIaArqwHedgoSKlPD49mT+cZ5rYL /hgwtTzNaLcFAaXOQ3ly6n6S+jeZq3L18fyMgE4Xrg3iCwo/txY1yCccbrN2dNgk2efF9m lCa5vAJYZOOe5QnH6Ssrbm0PXR+fX00= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=cwGxlcmq; spf=none (imf04.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668593409; h=from:from:sender: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:dkim-signature; bh=IP43t3hJu1Ut6R9gno8nfJ5M4E7h1wkQRd32HTSGUjo=; b=dVhxBtnvPH4xcjVWvDLR76MNTntsTslRRfO+pz3XRufF6hfhYoYVbDKulAjBOoxOR3C5os PfkqK4g3qoIpuTyX40Wm+Tx73KjO81/ZLZRdAqHTKDTDxd6qQxU7DvFLBUVtIY5LckmgvI wfhwLTNwkqXafJEnMqvl9Zt4BMdfWHY= X-Stat-Signature: gut8naxr6ue5qbu4geuybyd3xomknbcg X-Rspamd-Queue-Id: 4314F40006 Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=cwGxlcmq; spf=none (imf04.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1668593407-185332 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Nov 15, 2022 at 11:13:34PM +0000, Edgecombe, Rick P wrote: > When a page becomes COW it changes from a shadow stack permissioned > page (Write=0,Dirty=1) to (Write=0,Dirty=0,CoW=1), which is simply > read-only to the CPU. When shadow stack is enabled, a RET would > normally pop the shadow stack by reading it with a "shadow stack read" > access. However, in the COW case the shadow stack memory does not have > shadow stack permissions, it is read-only. So it will generate a fault. > > For conventionally writable pages, a read can be serviced with a read > only PTE, and COW would not have to happen. But for shadow stack, there > isn't the concept of read-only shadow stack memory. If it is shadow > stack permissioned, it can be modified via CALL and RET instructions. > So COW needs to happen before any memory can be mapped with shadow > stack permissions. > > Shadow stack accesses (read or write) need to be serviced with shadow > stack permissioned memory, so in the case of a shadow stack read > access, treat it as a WRITE fault so both COW will happen and the write > fault path will tickle maybe_mkwrite() and map the memory shadow stack. ACK.