Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1568954lqp; Mon, 15 Apr 2024 10:03:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWjAAsjnrsM/BsvxpbiXEThBINxwhWwaujCQDMTZVDXfJTQ6x9fpqSmyINNOuicdlorvCgLhjLA4+z5c2JI/9+ipJv+RBcjSS3mlwkmYw== X-Google-Smtp-Source: AGHT+IH345eSubS6rQc7VWzXFX1O4Ez1mCCmiRaIi+vCJGn8U/nqaNZcZPFaOmooD9s9/4ZRJx+Q X-Received: by 2002:a17:90a:b28f:b0:2a0:1c:c91a with SMTP id c15-20020a17090ab28f00b002a0001cc91amr5725516pjr.13.1713200579751; Mon, 15 Apr 2024 10:02:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713200579; cv=pass; d=google.com; s=arc-20160816; b=FehOlS/Jn7KW7lk4W08NNKIaJv+cbJR1NgBN1rHR8SZhPv+vqR8LHko5UjHN1Z2fdk Ck2nX5OOGnH8op1lnjfj7s7qMVb8GtcidkKwTE6fg/7Y+RV5n/0Z6VfztdfLBuS7aSvq nUEQSYcmLfJnEpFBgbZEe+kn3Ns+rtLcutZL6r56ATBUIDQaw6Dxc3hQGYJ9BoUz0+1/ 5KJXCWJHGtpPiFvQjY0VXzy8zZi/UUeM2X3A8Lp3Cpo6Sbec4YwDN9QsTBK+vC/aT2Ci t4sx/svwGPI+RC0q37i1e1LnqBpzhFbPwjYkiFO8gHTY3Mx0A3cOQS7WMSuDYhAbnW1q ABvw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=7GJpYcHDY0Ys7MWOFpmEFiftUtk10pFfttHr/rIW6NQ=; fh=2qmS+uYLBNBwjFAQBUltbJLTuHFbbrDf4UFYnXMHOcY=; b=PA5oKInUbirCLi4yu0ZY6jzwvxLA8CvqsGdv0wQOoPfwAytD6pSkHzpauHtu3heHD7 Y77sVmXCUcUPzsz/Z/1nGcka1WD+6qioKVgGI0zcJ8xBoD8GsAwuvdOTjAijDtoNdXYf GLGMaXexihQ8GS0EyFsWADvglJBBKmHCkMVt9QR72+d7b/oJgjeQIC6h0OydHbfKmErK axMLqdlGYTr2OzC0Nj3EKgXzyAPCv4PNOWKyllNX9Wi1PxzKyFicQrk7NVO/fN0Q+Sdt TJkRaYFEK+0DU0k6SphrGzF4DELK110rpF7awv5d/OMZAbED9ZJshMYhxkLFU642dp48 XNUw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JQhmkrbx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-145602-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145602-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 k4-20020a633d04000000b005dc42014e30si8353158pga.692.2024.04.15.10.02.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:02:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145602-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=JQhmkrbx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-145602-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145602-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 F1961283F58 for ; Mon, 15 Apr 2024 17:02:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5567884A3B; Mon, 15 Apr 2024 17:01:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JQhmkrbx" 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 6825B82C7E; Mon, 15 Apr 2024 17:01:40 +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=1713200500; cv=none; b=bwdikHusouShZVLgHAnumUH/2sEBpBRm7UcbMQrs87eDwT5/4lCt2VjYDaUxLi/t1ysMVwHchbt4nfmsZ1wBfB/UjG/dPov4ccMMrIgMaObrdxpNhvrSL3wKpGiO5aQewoOvrXEINy+qIODxfEZ0ZHNFFP5sXGhhMKw/LcCTraQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713200500; c=relaxed/simple; bh=i8/bH2GflHHwL9Q6O831fT+UJyy/N/JxZRrEitYoDU4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mCWwxNYqABT7CbdlXiR+KpKFX0iWFQMd/EwniO/BS3wZtmvIyYDhM5mY6ks4fzs6TOEbIa0FRpCr0dFjvad92c3p6qb3P2NghMfeR3m+8Sn3S0i9RUzyUklhOfy0ShwyNNKN2Dh51cJDwIFbk7rT085FFs+g5YWPO0tAVxSAO0s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JQhmkrbx; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D14FBC32783; Mon, 15 Apr 2024 17:01:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713200500; bh=i8/bH2GflHHwL9Q6O831fT+UJyy/N/JxZRrEitYoDU4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JQhmkrbxlkokAIFsbHYvCZlDdyYFqLoERLQD9UjXNswKquLP0xtcV1u+YOoMVBYzN Sb7LZUsXfhw2SSDicmJPXX6wJEySR7qXgqeF6WRCMsTmaxb6dTEEvdKVJ2QF8xV73M zWVAeo2j5d2mIhRamGxbmxaN76CTvh0ZT5e287zxh62+7uCraDbeX1crXvejWzPawj XA+nSfS1WF1QUSKZ+OwNWlmE2LS69a8cbAEH8Ow0G8h8jNNt9mOeOurVvGxQejJFIq lJWV1cL3Cak0wByUAJkuz9CCwdQLw1/FNbKBb/4i5MFAWn2PKkhEyDcE8g7rJ9Kbjc EpnrFltAXi4ng== Date: Mon, 15 Apr 2024 20:00:26 +0300 From: Mike Rapoport To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Andrew Morton , Andy Lutomirski , Arnd Bergmann , Catalin Marinas , Christoph Hellwig , Helge Deller , Lorenzo Stoakes , Luis Chamberlain , Mark Rutland , Masami Hiramatsu , Mathieu Desnoyers , Michael Ellerman , Palmer Dabbelt , Russell King , Song Liu , Steven Rostedt , Thomas Gleixner , Uladzislau Rezki , Will Deacon , bpf@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-trace-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org Subject: Re: [RFC PATCH 6/7] execmem: add support for cache of large ROX pages Message-ID: References: <20240411160526.2093408-1-rppt@kernel.org> <20240411160526.2093408-7-rppt@kernel.org> <20240415104750.GJ40213@noisy.programming.kicks-ass.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240415104750.GJ40213@noisy.programming.kicks-ass.net> On Mon, Apr 15, 2024 at 12:47:50PM +0200, Peter Zijlstra wrote: > On Thu, Apr 11, 2024 at 07:05:25PM +0300, Mike Rapoport wrote: > > > To populate the cache, a writable large page is allocated from vmalloc with > > VM_ALLOW_HUGE_VMAP, filled with invalid instructions and then remapped as > > ROX. > > > +static void execmem_invalidate(void *ptr, size_t size, bool writable) > > +{ > > + if (execmem_info->invalidate) > > + execmem_info->invalidate(ptr, size, writable); > > + else > > + memset(ptr, 0, size); > > +} > > +static void execmem_invalidate(void *ptr, size_t size, bool writeable) > +{ > + /* fill memory with INT3 instructions */ > + if (writeable) > + memset(ptr, 0xcc, size); > + else > + text_poke_set(ptr, 0xcc, size); > +} > > Thing is, 0xcc (aka INT3_INSN_OPCODE) is not an invalid instruction. > It raises #BP not #UD. Do you mean that _invalidate is a poor name choice or that it's necessary to use an instruction that raises #UD? -- Sincerely yours, Mike.