Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2092523ybg; Thu, 24 Oct 2019 04:43:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJcN6AiQzWYgC55Mi1CzDQn/Gu1B4DE/Sg8MkIn45tRd4+RPm9AU/SOnomD5vw4MvTLbst X-Received: by 2002:a50:b5e3:: with SMTP id a90mr41834309ede.201.1571917439170; Thu, 24 Oct 2019 04:43:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571917439; cv=none; d=google.com; s=arc-20160816; b=Tdv8NU23cZRA/kwnjyvtw6/h1ZTSIBUKFnYmxNonVnt7qGfrzdOZ1xk4eCUQj7VHoM 6CcVslMSeKwq6KkW19GrwHMmkIKPvTy5VyZjrU0+Vlwm6VXPRmGq+Ja6mVDQ/FjM10L/ e6R/GE0DOcoZq9U324aWGd7gMkxytaCinxfNIm5SFdubonkp83fkpXs7GMRYXYNPCxhZ 4l5l46QEJmBriyH1mr3rkG4NWMzyXidi5XzgWN2atGNYqSX/QSfkCPzNMUj4kleF+/Wy 2ZyF1rY37tDj3nO2w6TkqmVUNEjfA0cOg+EdbHeNcbJcJgCDxumRYTpkH0xQcAD/i93A w62w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:user-agent:in-reply-to:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=mS56Ocf2Wr6s6lxq3UrbaaoGODBCpGlIzwdbwNzrmFM=; b=MMaStvzs0Os5mBq9FT6DMeOQCm0Z0iTjeDM7CrHJ11aTb4oLSs1PS4RADIJt8XPLKQ bfpMVPwmlppkBD77lhThDuem+0TSSSitl0CiV1Y2XQswSvBnYPmzV58kGL/4IiIp1mCe FBNducI5XpzAbUDJ2d7OsqUWlUtdTuK9iV0Uas2kKqty1tUvmb4Rbhv7mbejLGEc5EHD 6XL946P8M+AVnDKgH7rqUFX9qGFrlpAgnCHOvK0pow9b9Gp3KofqQJevdyX4xpfDitBL IReXV88GJKrn1pxInw1LOuqn/SpcH4ZOnJCq/bAXXpD4BMR5lz+4Q7TfmiPxlu1bgWf/ piQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=A6f167nn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g20si8546827eda.229.2019.10.24.04.43.35; Thu, 24 Oct 2019 04:43:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=A6f167nn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726861AbfJWRAk (ORCPT + 99 others); Wed, 23 Oct 2019 13:00:40 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:37618 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726316AbfJWRAj (ORCPT ); Wed, 23 Oct 2019 13:00:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571850038; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mS56Ocf2Wr6s6lxq3UrbaaoGODBCpGlIzwdbwNzrmFM=; b=A6f167nnaJ6DttIs4zWbA1olBTys1ifRwlWe0+2BHJqeiNrrz5hF6NX0n/fJzBPJ4cpbrh dj6MiydnVp654E3/SS5/MkswuL+TgKl4xzPvc139mDR1g2Urpaor/uj3LsmDwuNycVccHF Y8DCdzBiHYtWRH1pA4Eb+ePY5/E41M0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-182-adgGpz8OP6mPpsyr71ygaA-1; Wed, 23 Oct 2019 13:00:34 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 70B2C1800D6B; Wed, 23 Oct 2019 17:00:32 +0000 (UTC) Received: from treble (ovpn-121-225.rdu2.redhat.com [10.10.121.225]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A93D16061E; Wed, 23 Oct 2019 17:00:27 +0000 (UTC) Date: Wed, 23 Oct 2019 12:00:25 -0500 From: Josh Poimboeuf To: Peter Zijlstra Cc: x86@kernel.org, linux-kernel@vger.kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, bristot@redhat.com, jbaron@akamai.com, torvalds@linux-foundation.org, tglx@linutronix.de, mingo@kernel.org, namit@vmware.com, hpa@zytor.com, luto@kernel.org, ard.biesheuvel@linaro.org, jeyu@kernel.org, live-patching@vger.kernel.org Subject: Re: [PATCH v4 15/16] module: Move where we mark modules RO,X Message-ID: <20191023170025.f34g3vxaqr4f5gqh@treble> References: <20191018073525.768931536@infradead.org> <20191018074634.801435443@infradead.org> <20191021135312.jbbxsuipxldocdjk@treble> <20191021141402.GI1817@hirez.programming.kicks-ass.net> <20191023114835.GT1817@hirez.programming.kicks-ass.net> MIME-Version: 1.0 In-Reply-To: <20191023114835.GT1817@hirez.programming.kicks-ass.net> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: adgGpz8OP6mPpsyr71ygaA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 23, 2019 at 01:48:35PM +0200, Peter Zijlstra wrote: > Now sadly that commit missed all the useful information, luckily I could > find the patch in my LKML folder, more sad, that thread still didn't > contain the actual useful information, for that I was directed to > github: >=20 > https://github.com/dynup/kpatch/issues/580 >=20 > Now, someone is owning me a beer for having to look at github for this. Deal. And you probably deserve a few more for fixing our crap. The github thing is supposed to be temporary, at least in theory we'll eventually have all klp patch module building code in the kernel tree. > That finally explained that what happens is that the RELA was trying to > fix up the paravirt indirect call to 'local_irq_disable', which > apply_paravirt() will have overwritten with 'CLI; NOP'. This then > obviously goes *bang*. >=20 > This then raises a number of questions: >=20 > 1) why is that RELA (that obviously does not depend on any module) > applied so late? Good question. The 'pv_ops' symbol is exported by the core kernel, so I can't see any reason why we'd need to apply that rela late. In theory, kpatch-build isn't supposed to convert that to a klp rela. Maybe something went wrong in the patch creation code. I'm also questioning why we even need to apply the parainstructions section late. Maybe we can remove that apply_paravirt() call altogether, along with .klp.arch.parainstruction sections. I'll need to look into it... > 2) why can't we unconditionally skip RELA's to paravirt sites? We could, but I don't think it's needed if we fix #1. > 3) Is there ever a possible module-dependent RELA to a paravirt / > alternative site? Good question... > Now, for 1), I would propose '.klp.rela.${mod}' sections only contain > RELAs that depend on symbols in ${mod} (or modules in general). That was already the goal, but we've apparently failed at that. > We can fix up RELAs that depend on core kernel early without problems. > Let them be in the normal .rela sections and be fixed up on loading > the patch-module as per usual. If such symbols aren't exported, then they still need to be in .klp.rela.vmlinux sections, since normal relas won't work. > This should also deal with 2, paravirt should always have RELAs into the > core kernel. >=20 > Then for 3) we only have alternatives left, and I _think_ it unlikely to > be the case, but I'll have to have a hard look at that. I'm not sure about alternatives, but maybe we can enforce such limitations with tooling and/or kernel checks. --=20 Josh