Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp1206307lqb; Thu, 18 Apr 2024 03:25:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXaFzw30oFLYRaA3P3hgzGj/6GDexO/SRtJzsBA0ilDXzVzjfZGPSuEfLrBeGeahRSzPtMhEwvms5t5SOv5oKEFycHuPvTBxnX/yd2vuw== X-Google-Smtp-Source: AGHT+IG8Vh7zuzhv1QM+uz45NLEOJMes1dEgxYJ03b+9XC9nf1pHbj4OV5aVrslNp6aJ9LAZhMzT X-Received: by 2002:a50:d718:0:b0:56c:5a49:730 with SMTP id t24-20020a50d718000000b0056c5a490730mr1284055edi.19.1713435923304; Thu, 18 Apr 2024 03:25:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713435923; cv=pass; d=google.com; s=arc-20160816; b=LYGWMRP/kAEbcUq8kbDC1sE5yYFDARDXwOMS222+1VyhjiLRH3z1RaQYLB5FCfaQ3n +kmW4MxwMjO56z1A4p1HJK0A8mjOts/4qcviKO39yF/DoM2oLO/vUhhWBJ8EYXsWjhaf +WgtA9feJc/EZEE6LgwbdAe1VfDR/enTDIEhkaoWUcfJreM67dA2GbOa30Lt+cLv1JaN yceskCVXpQwNV7ODR07JPKwWlXMp0jjOaB2D6dNjJ3/w8NoO9jT16FAHiQWLywW78yvh QG8mSrc5HOLqTxSWCN/1bCc2DYdVF35Cl5lvjT1k4DeavPpCtI3xnvUIrdEWZD/9B8Zj 7Aew== 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=2z8GbmZZu1iEHIDHgAY9yIb42rFB0lj9RG2efekw8B8=; fh=2qmS+uYLBNBwjFAQBUltbJLTuHFbbrDf4UFYnXMHOcY=; b=zeWSSWYM0V761FAnD+1L5IHKcMTMuIgdM3qMeVYtpt4wVyuaXTM/vaPxqLiHMerzEC mUh9K5FMHYt9LjaT6SQX2EHvCSDvsxW8KORa+Eic0lS0XqUh/h9XdYVShNT7npTIBD4+ ck8/6vYKsbf17dPdCqoV7AugJnoVevPOW3gL7DTmq8bPkZ/qfYBNw8Nw2eX2FdSkT8fV MFHFetBmTVUxF5rDjC0WiX2Wo1ceOOnZTcSypTkBuVfEM/s01XIZJq3vDFUjkoHNvkB2 ey71bVm+keXzBk8y5X8JzsCI8q9em8vjvnGOmNiy91gRl7vrKS6z0S5PLwWEptyjBamC +6lw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r7r3HpYQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-149880-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149880-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id j27-20020a508a9b000000b0056e219b4d29si687923edj.679.2024.04.18.03.25.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 03:25:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-149880-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r7r3HpYQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-149880-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149880-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0DED81F2366F for ; Thu, 18 Apr 2024 10:25:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 64CFC15CD4D; Thu, 18 Apr 2024 10:25:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="r7r3HpYQ" 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 750CC15AAAD; Thu, 18 Apr 2024 10:25:12 +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=1713435912; cv=none; b=av9OfEJ9navaKSI2hVUghjNwxROt4Y3dUBgvCz+xmpvWpG3NfdKUvgVLvVI6YUE6itpRPVyGkeMGGc8pARJemt4A4nmor0OyJKWjjS1xQP5yQM5/E2+os4oBURqf+8spjGR2NHoOUtb9yXhbiSHe75j1S23tSikDkXw6Sxh5YTc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713435912; c=relaxed/simple; bh=YYR+dNmhH5n7QU2mxc3zizI6arTy/RTvZImlW/XQhPY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sOxBs69phnGBVh/0JjdNmSVJTMJq0hfaZ9+ln5E9W/tS/lTkIu2k4BJCpwQdUn4vcoKVGfgCaOHq8nAMp3trHPPX0o/B7FumymXS7Ou7iDZeKwjoP48ONkEl9egCmQLpm5yACWPXCyZuB7HMwBez/m5GJsM1ZBKx9hFGGCEOiiw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=r7r3HpYQ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36123C113CC; Thu, 18 Apr 2024 10:25:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713435912; bh=YYR+dNmhH5n7QU2mxc3zizI6arTy/RTvZImlW/XQhPY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=r7r3HpYQ6nFiS0E8RoFspK8YNTCn1wvgAKmlggqCij/FXkbh7szpgdlp50MnvnkyP lk96Jv8sQ1JdQGAURqqmqgYkF3mGapE5gySL9ZwhZHyzkL0O/RbIQf5t1nWm3gYpbq uEpL9PSB2RTnOFLn1B9HaIE/diUnPoc6ZmU/M8wQ2SoiNmWWCQToS5x4OihQModqbL wQp9NYpGP/8mk1FlFPEVNiGZQBNpmOaQ1CBof6I+gHZEt/zViTgmR/oZTmy5m+cXoj Tt5QDTjkEbUg1MEvU+IXwpfYnYqHcejQQSHvHq4OyuZGU6Xkki5E+LhnslG0zaaCc7 s1wPnD7FtE6tA== Date: Thu, 18 Apr 2024 13:23:55 +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> <20240416075234.GA31647@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: <20240416075234.GA31647@noisy.programming.kicks-ass.net> On Tue, Apr 16, 2024 at 09:52:34AM +0200, Peter Zijlstra wrote: > 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. Well, execmem_fill_with_insns_screaming_bloody_murder seems too long, how about execmem_fill_trapping_insns? -- Sincerely yours, Mike.