Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1341668lqp; Mon, 15 Apr 2024 03:43:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVuOFwskBtVurKV3J4PNZe1+CVMmrmlbJbQEfF7+CYlKzdeVEr+W8XQ3aFNlcgNe/7d2PIhLr4NV8MAgMCr/3vpANtEYc/uV8E+4d05lQ== X-Google-Smtp-Source: AGHT+IH9VMu+rFqpvxAP33SnOr2fqsX5U6ILl/BqvJRFuzLvZ6p2ij88hRrBb0J9TOG2ObY8ZbUc X-Received: by 2002:a50:8a91:0:b0:56d:f246:bfa4 with SMTP id j17-20020a508a91000000b0056df246bfa4mr9128381edj.23.1713177834230; Mon, 15 Apr 2024 03:43:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713177834; cv=pass; d=google.com; s=arc-20160816; b=eEHVYG1YoPX+T6TGRA+t6xzZRuiPD6fyKWlMvwgZQRS1rT38buCvjOtdtaNYmQ4K1b k5jZDFoK25c26m9YMARUw+hBxTbIpcKJHElP9GH1uVot9K/CQu1zLGi6+nEsvlyT5CCu BZuE0bEDSKO4w1W5WOM4eGenUH6l5sbsJgJe8csFYzuBlLKHp3okNjT+q4U4qD4ZFf2F Q7h3BE25ttJ6evICRaFpGF4Q0tk3cSV8xHBqrTtn1nUGnq9ltK6sJ/B+oq2q1C0boNQ/ tLZebBj+jfqc0tBPaPiHHHGbpm4K1DSBAJAao2St9KpyDQlijfNxSLV3FwpRLHs+L1u2 Z/0g== 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=sHN9K6TMgi0EQGirMl9LJrLTL74puiAUj6pDWO1mbbg=; fh=XKYnOG2LEgj9d4hrUesyoEaXDOn1aeA72pqC6hcTktg=; b=HudHZbUj+zv7prOPBJxIg3m+cmqpjDEkHQ9EXU77iHYBuRn1HhcMQ+9K8qVrxQ6BLm YfMlh8cYFDwuslfWr96/2FTqjSGP5kYOcvvbBnqop5Is1NYU6X9JLOWel9a6lmKw8p47 iMB/eYrhKqB5aKsRM9AmYS9iSi7fzUlCy50J4lCKf+Hgzc2du69+5e4rCMxAdivUi6nx 7dqaloe3f6DRi41bXOlFHcpAdOQe/vmdfFb65oXqw17AoWtZL3AFEeH04p6ZEcVMpcb5 tmUWfFNyi8Xl2egiK/S6r8WL/Tq1TllfDpoTQGkPk/ckFTUDVn+PFfP+1nj9nh7S7DBW 7PXA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=GwGuQ4aH; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-144929-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144929-linux.lists.archive=gmail.com@vger.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 v21-20020a50d595000000b005701ea8c2bcsi1590963edi.336.2024.04.15.03.43.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 03:43:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-144929-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=@infradead.org header.s=casper.20170209 header.b=GwGuQ4aH; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-144929-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144929-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 am.mirrors.kernel.org (Postfix) with ESMTPS id F04931F22700 for ; Mon, 15 Apr 2024 10:43:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4575B5CDC0; Mon, 15 Apr 2024 10:43:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="GwGuQ4aH" 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 EF2DA5C602; Mon, 15 Apr 2024 10:43:40 +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=1713177822; cv=none; b=d+px96eOxravbYrft5qkAIqcNl8bfJbbPsggVJrfldCXVuojpN3D9TcrFjY3DS/YUSY898e3vhAp3yYvPzmsNRZMdnOvg+2iltRZWi+MjZH6gUkjOxna9gA+75m56W1dtpG1K8xuONZEJ9+Y/nlWV62qBHR0hRk693FWwQbzN/0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713177822; c=relaxed/simple; bh=RFYztRJUTq9jSdRkMIaWfGnpsOm5wmTtBN7NNF1RSJE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=p6rRTVXKQJN7Se7fYdqomuaIpZlhev6IUVG71Vd1N6qr6LE0DnNWH86NGp6FnYxwt3qfpRg8a3T+266nQybr4WeLGeh9Bb7QvH14/f7juPHVoFd/WrH6FxPQfY8uImAPwykz3CFW7rG/lhaI5J1eID3nZDOOqM/rC/FuyNQ1eeU= 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=GwGuQ4aH; 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=sHN9K6TMgi0EQGirMl9LJrLTL74puiAUj6pDWO1mbbg=; b=GwGuQ4aHjE28h3DMQEljrl12S9 k7qbRgAehAWmB1KZsKYRkIe5T4YmQ/IK7K1/tscLIiWM+Frzf3BTbHghy00qu8vsdYndUrZk657/5 7U6MObgQX8Hy2DTMmRYPlPtuplIcSQak3GNH/5HdZ6q2oAguSRJjpD+LaJ9a87To/HWlTYLJ9YvvV DlPdjGnZeeuN/uKeKILlCHLcOLy+D7L1I3Tkf+oPOF+MhpDr74c6GfylqnVH3luQcSx0xGQC7Rr+F /Pi5v1/cfv4gkg/y9fqk5azH4jFf+jsMj8+XJZsS62wcfAHMmEcUQTu5cq8eADVZRA0kd303q26id Ns2I29PA==; 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 1rwJnx-0000000FWHZ-0CDf; Mon, 15 Apr 2024 10:43:22 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id ACBA530040C; Mon, 15 Apr 2024 12:43:16 +0200 (CEST) Date: Mon, 15 Apr 2024 12:43:16 +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 5/7] x86/module: perpare module loading for ROX allocations of text Message-ID: <20240415104316.GI40213@noisy.programming.kicks-ass.net> References: <20240411160526.2093408-1-rppt@kernel.org> <20240411160526.2093408-6-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-6-rppt@kernel.org> On Thu, Apr 11, 2024 at 07:05:24PM +0300, Mike Rapoport wrote: > diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c > index 45a280f2161c..b4d6868df573 100644 > --- a/arch/x86/kernel/alternative.c > +++ b/arch/x86/kernel/alternative.c > @@ -504,17 +513,17 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start, > * patch if feature is *NOT* present. > */ > if (!boot_cpu_has(a->cpuid) == !(a->flags & ALT_FLAG_NOT)) { > - optimize_nops_inplace(instr, a->instrlen); > + optimize_nops_inplace(wr_instr, a->instrlen); > continue; > } > > - DPRINTK(ALT, "feat: %d*32+%d, old: (%pS (%px) len: %d), repl: (%px, len: %d) flags: 0x%x", > + DPRINTK(ALT, "feat: %d*32+%d, old: (%px (%px) len: %d), repl: (%px (%px), len: %d) flags: 0x%x", > a->cpuid >> 5, > a->cpuid & 0x1f, > - instr, instr, a->instrlen, > - replacement, a->replacementlen, a->flags); > + instr, wr_instr, a->instrlen, > + replacement, wr_replacement, a->replacementlen, a->flags); I think this, and > > - memcpy(insn_buff, replacement, a->replacementlen); > + memcpy(insn_buff, wr_replacement, a->replacementlen); > insn_buff_sz = a->replacementlen; > > if (a->flags & ALT_FLAG_DIRECT_CALL) { > @@ -528,11 +537,11 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start, > > apply_relocation(insn_buff, a->instrlen, instr, replacement, a->replacementlen); > > - DUMP_BYTES(ALT, instr, a->instrlen, "%px: old_insn: ", instr); > + DUMP_BYTES(ALT, wr_instr, a->instrlen, "%px: old_insn: ", instr); this, want to remain as is. > DUMP_BYTES(ALT, replacement, a->replacementlen, "%px: rpl_insn: ", replacement); > DUMP_BYTES(ALT, insn_buff, insn_buff_sz, "%px: final_insn: ", instr); > > - text_poke_early(instr, insn_buff, insn_buff_sz); > + text_poke_early(wr_instr, insn_buff, insn_buff_sz); > } > > kasan_enable_current(); The rationale being that we then print an address that can be correlated to the kernel image (provided one either kills kaslr or adjusts for it).