Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1573440lqp; Mon, 15 Apr 2024 10:09:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUlPWfKsvrOIf/e9kCEOSEe3uIw04+gfWHPldAI2yqt5qpqkqqqC9VGkL6IDqAJchajtL6j/9l0nZ+hB68uoynDWn0sRSWWxW1mvWte4A== X-Google-Smtp-Source: AGHT+IE5l8yXuE73NCBhh7ao1gfn7iD7L0HIrcKeWOaeA6sbxFJCucjmK+san7euTr2d4DkmXwBc X-Received: by 2002:a05:6358:6996:b0:183:cd9a:b2dd with SMTP id a22-20020a056358699600b00183cd9ab2ddmr11293258rwi.23.1713200950572; Mon, 15 Apr 2024 10:09:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713200950; cv=pass; d=google.com; s=arc-20160816; b=nsKCFhz5gmFUu2PoT+OkJcqrDxUJutEyIoUtHVzrLxiBgNXPz0p90ofPfpn3Afl3k3 FhH7hIsITpL0Q3YTh3Gnky13/qsQyIAK1ZOUV0YYOyDj+9SZjMXwsdMP/w+Q/32S0Gw5 jy7yIzxPJrQ/UNBG5/WuMdkp9hFb+B7T4vMM9o8VrJYbRlP4sBpP5COwAJUIIfCMTU+w 5x9Jg/mCRDKboKmioJ9jLZMly89M3zPle/81pR00lBL3Berb8N9tkdzglk4YpfsGlt6Z BXez+3fT67wOefeZpbflqV7ys2Vb0iHWlQ58TBCGv3spcSZFqZUnwAH1ZaxMit/iVB7u T3Xw== 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=jMkJQsuyofl49eBsJIbfYXPbxVppRwI7ZtbFCbtgk4k=; fh=2qmS+uYLBNBwjFAQBUltbJLTuHFbbrDf4UFYnXMHOcY=; b=zwtW0ZFNhfl4dEH4G+LZyp9al8IPqXmq08yJHli75qECebdU9jLfIfJpHKNpWLIlvS KZyjxbQHAejZn0d0Y6VMzcftN6KmfDIbTl3D8jsn1v0HZxl7f4NkdGKIIw6ekzXoAQQS XHvQZz0uYXT/qlGu/UOQ1EZ9HrErL1ao5SJesLDbK7dYj4r1z10JhlC3RCxO8de2cD93 kq7FJ9S1txk7ZRHa7wzTu7LWtJKwgOGjYekVd7goCgONv7gOcnn8l8OVozBeXpJUI7eE h83rgjlDv5J/xYMdyO0AHrJCS+Nu7QtvRFy0wep6lu1ubBnZEDZgO99HC73XRbY02jpo eX3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eA4Y4x6L; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-145625-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145625-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id r198-20020a632bcf000000b005df43caee00si8006772pgr.318.2024.04.15.10.09.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:09:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145625-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=@kernel.org header.s=k20201202 header.b=eA4Y4x6L; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-145625-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145625-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 21F4E28408E for ; Mon, 15 Apr 2024 17:08:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B37A884D39; Mon, 15 Apr 2024 17:05:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eA4Y4x6L" 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 BAACB83CD8; Mon, 15 Apr 2024 17:05:26 +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=1713200726; cv=none; b=D4vR0jY7jASS66cIUiPvhMUynlacCLw48FpDomi3EDrtjqnh92neyxuBDFy+fzANysgZodViBbPfK6h/M+e/GK5gjOZhf1KdbtDMrGyuVQl9wYPXcB6Afs1PLIg2PrGmcGtRv63QvWGUGYI6dT1+AzPvetFtgaARQ1z4mwOZwvU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713200726; c=relaxed/simple; bh=brTfnO2VyUJAmFmt0xYsxELn1GfIqBydjJY5MAA2GwI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AZJ85qC0HBDw3r8J0cbDsDD19Con1J0u4NqUej0Xl7wSVVGFmg2MnW/4izSnPX2CceHFQUwIrH3CK8Bw518QCYq55bFdV8XkkH26qSJK/GGc8rwELB/XLp19CRGemip2i30yBHN1z9K2+/8jXI6HXkr3YQYqPK5KVKouSBNu15w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eA4Y4x6L; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9EB7C2BD10; Mon, 15 Apr 2024 17:05:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713200726; bh=brTfnO2VyUJAmFmt0xYsxELn1GfIqBydjJY5MAA2GwI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eA4Y4x6LpKDmJlhsFuCKUKDWszVPc0aMol9ibBC4zWuhXiukyHzmx+wctUQDy9YcO SgrxzhBVYrKzoib5nD4pxj58Yru3AKozTZkN+TvcG/88RKgokKwWdJ7ot3KrqKc7Eq DUMXngRm3Kt+F/W7nD5rsdsyrXI/SKwSE27eJw0RyuFsxXe2CY8Th13OWBhzodIeFI g3IfMeClHVfNPTzOpcIibEz/rTBRU3MdIzMovL+lADX98nFVYDJgBcU0E0gUS/Sp3y NkyrAJJ3bphAZ5D3Vr/0URqS2QdYx5P8qEukDaFoUJqWeYw/1mketQaU4aGKwRL5Ma kNnuFlXqLWYaw== Date: Mon, 15 Apr 2024 20:04:13 +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 5/7] x86/module: perpare module loading for ROX allocations of text Message-ID: References: <20240411160526.2093408-1-rppt@kernel.org> <20240411160526.2093408-6-rppt@kernel.org> <20240415104316.GI40213@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: <20240415104316.GI40213@noisy.programming.kicks-ass.net> On Mon, Apr 15, 2024 at 12:43:16PM +0200, Peter Zijlstra wrote: > 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 I've found printing both address handy when I debugged it, but no strong feelings here. > > > > - 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. here wr_instr is the buffer to dump: DUMP_BYTES(type, buf, len, fmt, args...) rather than an address, which remained 'instr'. > > 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). -- Sincerely yours, Mike.