Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp637840pxb; Wed, 11 Nov 2020 12:18:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJyCLn205AbSn4WgFpQDHG/p1bDJh3OZXhiZhYPXwHavtkgIIq/YdCnTsGuA7vEpb350BaSg X-Received: by 2002:aa7:d514:: with SMTP id y20mr1342579edq.384.1605125899048; Wed, 11 Nov 2020 12:18:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605125899; cv=none; d=google.com; s=arc-20160816; b=SbxklxuhRW6CjSlsYRXmQ/WssRCQIwqjzRHkFW3Ax7I8ah0PrWf5p9zE4olVkyZZEf 1KiPXZkPK9rQgZ5RdkFs6GSY8IWl4zoaW1hmSTqV8fCL9A0i/uboZgy4a9QMnoU08oXw tAfWVsCOWEAL3h0m7GCXx2OlCHByjDD1OFtO67nr8WPWlHvXVWehXUGeNOG01fx71ah9 JqYhfHL6tKqIbhMiC+In9wXh88WJQ0RBShjyBKGqzxzSYmj9v0GlCDqo5VFyQBbhlxIC NP8bkSl/pCoQ/wFvit+wkuRjxlWNP80RL17WCN7ZD26SIr25kZcceRIc2LrA7rYIwcQg DQqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=JpRkl5+vsWXIs7CNuFJmsCnDy55m6W35mOUG4Lg8vTo=; b=pY5nzuwAuUNCSc3AlQZh676c6814c2Yn6ndQAwwUeKT4H/RFRe+QSKHEeMF+Y8Owc6 /yMAmwq5XbfvlsLeBCAil1puUFixG67CsoA7k18nW2DLGkq7rg1G75KBus3GnHVsSvV9 WRQJw1YsfwxaGLrqUAubGcdVNlRdX24s7R+J1D9rh9m6T3eJtbi+E2EOSjSQR6EucHZ+ +Kgf8O/UhPgB1SK9P5NepQduLijd/G0vw4W7hyWj8FAbsqIk/jRVawdIeMt5lWrotUP/ H1YwYA2n8HUrv/2jgGfrziYiDSjQP1lGRfzK8dbB6KQkRRW7DuZ41r72ADDvTuq82fDy tLBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fmbX1NDH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id k7si2117956ejv.487.2020.11.11.12.17.55; Wed, 11 Nov 2020 12:18:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fmbX1NDH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726020AbgKKUP1 (ORCPT + 99 others); Wed, 11 Nov 2020 15:15:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:44748 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725860AbgKKUP0 (ORCPT ); Wed, 11 Nov 2020 15:15:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605125725; 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: in-reply-to:in-reply-to:references:references; bh=JpRkl5+vsWXIs7CNuFJmsCnDy55m6W35mOUG4Lg8vTo=; b=fmbX1NDHHRVe5bEn5NJt7yRVmrwLWcYyZNwtKrnVkbxnhoPM6/rAbSKNE99W5zRsNpH6sB EqNV9SoQVq8C7RhlTM65U7chECB1uWEr1XQSP3VfHRL3wPo+gpWAnqdcTll7hk/a2AwFG3 wsvRDPQ7yNMzKkufuJQwrkM3FjX62L4= 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-306-yKTMK7KPO6qtrD6ljA9kMg-1; Wed, 11 Nov 2020 15:15:15 -0500 X-MC-Unique: yKTMK7KPO6qtrD6ljA9kMg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 33CB8100855E; Wed, 11 Nov 2020 20:15:14 +0000 (UTC) Received: from treble (ovpn-120-65.rdu2.redhat.com [10.10.120.65]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 206C15C1C4; Wed, 11 Nov 2020 20:15:09 +0000 (UTC) Date: Wed, 11 Nov 2020 14:15:06 -0600 From: Josh Poimboeuf To: Peter Zijlstra Cc: Andrew Cooper , Shinichiro Kawasaki , "linux-kernel@vger.kernel.org" , Nicholas Piggin , Damien Le Moal , jgross@suse.com, x86@kernel.org Subject: Re: WARNING: can't access registers at asm_common_interrupt Message-ID: <20201111201506.bftpmx4svxn376tn@treble> References: <20201106060414.edtcb7nrbzm4a32t@shindev.dhcp.fujisawa.hgst.com> <20201111170536.arx2zbn4ngvjoov7@treble> <20201111174736.GH2628@hirez.programming.kicks-ass.net> <20201111181328.mbxcz2uap2vnqpxq@treble> <33843b7f-ed8a-8fcb-19bc-c76cf00f453d@citrix.com> <20201111194206.GK2628@hirez.programming.kicks-ass.net> <20201111195900.2x7kfce2ejkmrzi3@treble> <20201111200730.GM2628@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20201111200730.GM2628@hirez.programming.kicks-ass.net> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 11, 2020 at 09:07:30PM +0100, Peter Zijlstra wrote: > On Wed, Nov 11, 2020 at 01:59:00PM -0600, Josh Poimboeuf wrote: > > On Wed, Nov 11, 2020 at 08:42:06PM +0100, Peter Zijlstra wrote: > > > > Would objtool have an easier time coping if this were implemented in > > > > terms of a static call? > > > > > > I doubt it, the big problem is that there is no visibility into the > > > actual alternative text. Runtime patching fragments into static call > > > would have the exact same problem. > > > > > > Something that _might_ maybe work is trying to morph the immediate > > > fragments into an alternative. That is, instead of this: > > > > > > static inline notrace unsigned long arch_local_save_flags(void) > > > { > > > return PVOP_CALLEE0(unsigned long, irq.save_fl); > > > } > > > > > > Write it something like: > > > > > > static inline notrace unsigned long arch_local_save_flags(void) > > > { > > > PVOP_CALL_ARGS; > > > PVOP_TEST_NULL(irq.save_fl); > > > asm_inline volatile(ALTERNATIVE(paravirt_alt(PARAVIRT_CALL), > > > "PUSHF; POP _ASM_AX", > > > X86_FEATURE_NATIVE) > > > : CLBR_RET_REG, ASM_CALL_CONSTRAINT > > > : paravirt_type(irq.save_fl.func), > > > paravirt_clobber(PVOP_CALLEE_CLOBBERS) > > > : "memory", "cc"); > > > return __eax; > > > } > > > > > > And then we have to teach objtool how to deal with conflicting > > > alternatives... > > > > > > That would remove most (all, if we can figure out a form that deals with > > > the spinlock fragments) of paravirt_patch.c > > > > > > Hmm? > > > > I was going to suggest something similar. Though I would try to take it > > further and replace paravirt_patch_default() with static calls. > > Possible, we just need to be _really_ careful to not allow changing > those static_call()s. So maybe we need DEFINE_STATIC_CALL_RO() which > does a __ro_after_init on the whole thing. But what if you want to live migrate to another hypervisor ;-) > > Either way it doesn't make objtool's job much easier. But it would be > > nice to consolidate runtime patching mechanisms and get rid of > > .parainstructions. > > I think the above (combining alternative and paravirt/static_call) does > make objtool's job easier, since then we at least have the actual > alternative instructions available to inspect, or am I mis-understanding > things? Right, it makes objtool's job a _little_ easier, since it already knows how to read alternatives. But it still has to learn to deal with the conflicting stack layouts. -- Josh