Received: by 2002:ab2:3b45:0:b0:1f4:bc7c:a2d3 with SMTP id t5csp2336627lqf; Tue, 16 Apr 2024 07:06:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUEGfdvdr+XBbXuIuaUdjOV6I0iUISrzW824XeCn0PNB5aEsj0ldxc7FT0ke5uWmaYmVdcj3JWU93yC0EQh7o7G2RiXpmU58Tl62ETPOg== X-Google-Smtp-Source: AGHT+IFrH4XiBJw0nVOfBfNpd8slJ0kK2v9MArss4Ll5lgDpWwS/erobhCRnafEKTIHU7vuEY5oj X-Received: by 2002:a05:6a20:8428:b0:1a7:89df:2707 with SMTP id c40-20020a056a20842800b001a789df2707mr12982870pzd.10.1713276385653; Tue, 16 Apr 2024 07:06:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713276385; cv=pass; d=google.com; s=arc-20160816; b=toEF8u+ZyLGYFckbyWoStGfLvuJTQ8JaW3asWxiHZTHGmiVGGOBeWdtUuSvD1Yfim1 2e1kbe514LOgA+1MOK4nkHErRc7YEYaLk2uazFt5YgmMw+0ZLKUMjPKYVwdsL+vhWOoE Hbj9e2cgSYz7zQXHoCJPi4dvmL1zPURRopnjOglmEdv7HxLCImWlNw4RtoPCcoOKBXBx 5NAaM3ZhZ9pKyJTYnwXs5qBkHYktRKef83U6urKt19ph74JGd3PgIyMezB062HOnxtuR dBiFQr2oBA0+yiWG6bmN4KgYJHU6qNrzwGK6z/t7eT6B2QWfTUAam26WTEehe2UTcY7M 0oqw== 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=507ZBsLeuCe8QOYcleBeRL5NXt96hdJ7/5G0PziK1K0=; fh=XKYnOG2LEgj9d4hrUesyoEaXDOn1aeA72pqC6hcTktg=; b=uCRbnsuuxE3neJkxwUTa+bmjl54WQcUC/daT+A3EFUeMd4mUI4qm5p9Pb3VEqTBpmY gegQAHrDrM8nblQsV4SfXMfdnKc7ugYR01fcxdMwtMrb5tFI6XdPNcaFpL+yEYHygC2u o4hR9HgTuzxL8G5Ko60Asm0zRknonWKBZEVs94tcFSQaaiaqs1gQl9s3jrEdU4yw3oLs qV9rKG3QYtyviZRizlLcDtABbwnBVU8ej7KPcdA7EGY6YOpNdBgaJjGgnyzZbVHZ578r t8j7XuCvd5AxxcDF+C9zAm1oU6R2l8Oy2QY/qsaUPotoI7b0uf0P/CW2HEVVRGkv95/B iIXw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="fU/cNEu5"; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-146450-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146450-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id w24-20020a63fb58000000b005dc504b30ecsi9730207pgj.108.2024.04.16.07.06.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 07:06:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146450-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="fU/cNEu5"; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-146450-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146450-linux.lists.archive=gmail.com@vger.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E0190B22019 for ; Tue, 16 Apr 2024 07:53:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5726A12837B; Tue, 16 Apr 2024 07:52:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="fU/cNEu5" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 39FC27FBBA; Tue, 16 Apr 2024 07:52:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713253978; cv=none; b=VMOUCcfMZ/8ldRjdrvv5QxazZlhRcEwZMaZFpUVUfH3blcbyp/HEASK2hUP/+/RksSmf6UlDT0INiFVDcEplNgx/ig+tR7peuFgm9nzHgEAFcVwZqDB3l+n8FOB01+c0Sf15rmWW9U3Pz0Spe5h7HEMOjBIIxeiRmkSWbR+ufUU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713253978; c=relaxed/simple; bh=i4wZ/rKAd8t/gotjo/bAEFp0Lbj6N0UFOKrt5kXOcq4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ougX+RgZQZXSIA5SuCZrgrp6r79/skGa4vJcoqNMQDYUWvrx5tWvCZSSghcGpGGO1yIMEffDrQS6JIGAfBgonhaI1Jgtt8/rLr0vCSBs1iPwcWqcaZn6ZFbuN/XlLhwCcq26uDDB5qW+zwAT1FmvVcFbCTCsD3sf4VVkHVIFfW8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=fU/cNEu5; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=507ZBsLeuCe8QOYcleBeRL5NXt96hdJ7/5G0PziK1K0=; b=fU/cNEu5qw/O2Klf8s6HCr+ThI AhpI1nEs4Up9XFmJBI03cktnXOkGdoRbOvIZzjK48ok45c2JILgNd4BIrGYsKyEjDF0eQQL+HYJwR Yiyrnny32/na/Ys3afDWWVnk61J34su4s2sCj0Ub01AHgZcx+Fsp5j+qrF1A8v0sYzXZMlCD5kjBk s3viP3O4TygKJJxdljC/ZTymqUoM44K9+R+bQ//RVwqZYO5nBn5merN0aN+obc8V8nFi/A7z6wGAX iEjE6w/enUoiPeoQuWrQTmG1HLtwkxvfU1NO54vIH5bCDXvS5cudA99gRVmIMYwS4kC9jIInm3J/Z dg+Vrz+Q==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwdcJ-0000000HZIl-1TGs; Tue, 16 Apr 2024 07:52:35 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 0630E30040C; Tue, 16 Apr 2024 09:52:35 +0200 (CEST) Date: Tue, 16 Apr 2024 09:52:34 +0200 From: Peter Zijlstra To: Mike Rapoport 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: <20240416075234.GA31647@noisy.programming.kicks-ass.net> 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: On Mon, Apr 15, 2024 at 08:00:26PM +0300, Mike Rapoport wrote: > 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? Poor naming, mostly. #BP handler will still scream bloody murder if the site is otherwise unclaimed. It just isn't an invalid instruction.