Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1598222lqp; Mon, 15 Apr 2024 10:57:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWl0tx3ohSC4ThuaiUT7G2wD8fBJvTNNFTVxjG5J7gkbTRpxUnotoHF58d3gqKkJ1ZyoPsZnRCCk6VeoG2wOmanvCepHtHkRKU/Q5JyNg== X-Google-Smtp-Source: AGHT+IGvialI5vNWkKC+SsjyYJwcjr7euLLS/RUGWqpcDD8VHvCUdqX0+ZFyTF8TU/zriuqqPFDI X-Received: by 2002:a17:90a:17ea:b0:2a7:b6ee:2ed0 with SMTP id q97-20020a17090a17ea00b002a7b6ee2ed0mr3865673pja.7.1713203845088; Mon, 15 Apr 2024 10:57:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713203845; cv=pass; d=google.com; s=arc-20160816; b=qZfhY1OG1N1Wj1hkO26Xc7jZTHZv66cw33kd40EM2zUVRvUw46gMwlVsLXCo3PfIHr t4BxDpEyMPux7+bKggBNqAagdos3dJWZ7+/kmX/ZsauTi7SNXwrcmyCHdyDxTtvYTjHA UYKqtL3lWI00gynsHF/uihrlR5bRhqf+py0BjpdVh+ZAwiv9en52TFqJ3PbUEWX8yLYN yj/MvZkatwUYR8GZKAwnJ98EZ15owqJz+hIvsMSb4fBGIOVCQszzds9mVjggtcA4odSp IelOd+nYihHlpAFNGfz14QU1oNvz5ZBh3fdGFNzPCZYcRK7iiS0L7YGbipaIFIid6EJo HSGA== 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=RaoQRV0+66EHGN6m1Ed2GcaJhrluoYf96YNmq1kLoeM=; fh=XKYnOG2LEgj9d4hrUesyoEaXDOn1aeA72pqC6hcTktg=; b=jTw8aNWSAl3moozQmdQc0EhXXdtKXuEzz00cc9Bzz9LrrFl6KiSZyEeb4935Dn9Mqr xU4yqui/MtEfRV6YsRAZfM9uFNWN+jAn8JlaThSV9BpkAEOGJlj02XmrxkpBfE0EAyeh Gsv/X98y0sSTcPi3LlhzQMHJ46j7N9fbn/qm6raVfRMxTshW39i2bB2Oc+SslT3F0LPb DUNK2MvJUsaYYH2jfl+GCxFVvQ2qDR0QBjmzScg0dCIcv4NrT2jU+sqEOuyBSsTDj83p Q2BHnmJviUmCho6w0NOLO8yHPyL1po1DHGnXj/jEhHifaU8NaP0rbKU+mDFCf9y5F2JO RUJg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=DmPlp+Gw; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-144934-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144934-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id dw15-20020a17090b094f00b002a0316b2238si10494711pjb.186.2024.04.15.10.57.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:57:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-144934-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=DmPlp+Gw; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-144934-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144934-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0853A284482 for ; Mon, 15 Apr 2024 10:48:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B84C95D47F; Mon, 15 Apr 2024 10:48:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="DmPlp+Gw" Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 9EF5F5B692; Mon, 15 Apr 2024 10:48:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713178092; cv=none; b=eF9m+gcFYoIAOdb/tKTW7zNcwOvur2xrhjtUt0JJDkDK+CF9nOizyaYr+T4mR4jK+wjpe6wtmUSeLbLunGCM4dC5GgQYZNz6cX7whJcLI8czLWAZnERRuy/tQQkX48yyip/QE0CxbwN+6FN8k8aU4c57GyfSzI8jcQsduIMPX0o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713178092; c=relaxed/simple; bh=DHHOkCShD1hzMwPMuxL6SrFxpgSganyXDD6xvwRxLUY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EU1CxCT0GTZouk3hhRqsio4WG8qRUPN4esVBqcXPmqoFeLFNrnuWTqDPCWhFSPIkR3Ic5STiyt9dz5zfaFqkpa6lq1POtHwKogDejCt5eCwgzPcl5sS6mpWsMWaWuKaDkAxA5O6rxHgFQje/lqj1LSuZsdDx/gbMu9zY0CJt5zc= 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=DmPlp+Gw; arc=none smtp.client-ip=90.155.92.199 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=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=RaoQRV0+66EHGN6m1Ed2GcaJhrluoYf96YNmq1kLoeM=; b=DmPlp+GwTjnqhKH6J+sryoEdrY Bs7/bAK5dGN/tvOZpggS1MRWFWhxCzXtg3Kme5+z0u7Td+mbEbDDM50WNlWh1bBT5LGWUxcb+bGHm elRahugHUcxnEkAqkbSjVEdy4EY9K3hAojTO6rN2gFUgyfCr0rBFNu0FLG+U39e1a1V9WMtD/KjXZ Zp9hCayzKEN/2qzib0qaBIaeLkLJf4Ht0/GJYYy/QPucZKIP2egPoJY7GIjLvQztCzQtItKx8NefU MgyHUypo6g915o9W6pq9YTc3bSEs3SrWCDaJITQ7Iyh1VXY7BNiW5EFf6MEbQ4nSlfuaPnF415DH5 Z7AJDBhA==; 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.97.1 #2 (Red Hat Linux)) id 1rwJsN-0000000AXAk-0b8k; Mon, 15 Apr 2024 10:47:52 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id C563430040C; Mon, 15 Apr 2024 12:47:50 +0200 (CEST) Date: Mon, 15 Apr 2024 12:47:50 +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: <20240415104750.GJ40213@noisy.programming.kicks-ass.net> References: <20240411160526.2093408-1-rppt@kernel.org> <20240411160526.2093408-7-rppt@kernel.org> 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: <20240411160526.2093408-7-rppt@kernel.org> 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.