Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1725480pxm; Thu, 24 Feb 2022 08:15:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJzK9dTVB1GYJ3boeGCtig5VN4UUv6xG9U7ojNul9bSPd96wXK+7vpFnmtABSLlA7+yY28GO X-Received: by 2002:a63:e953:0:b0:366:15f5:d6ec with SMTP id q19-20020a63e953000000b0036615f5d6ecmr2817424pgj.338.1645719355579; Thu, 24 Feb 2022 08:15:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645719355; cv=none; d=google.com; s=arc-20160816; b=PFr1thkGMn7DJWao03JpqLHUKCS9OZwA9KZij1RNBeoix7cIxPZjUBZjPnQOTDYdtK v9J4NfvLib62THBDPGuowpWdoh3mmvY8DnXtrfp/xL3zrg/6FlANNslHkNnEKQunat0u etgdrNCMN4L3BcZsS5mj+st9DsAe7oWC1CLb6ymzj7rmVFve8OUZ7p/TOfDZuvVRKU4l Fd2ucOdejwtv6U/AImcx3b0p4cM5+zud9ZsKdWzlUrm4IyD+5iH/LGduyquI4kQ/0tRK Bo45kDMmOI7dmFVWUIsEdPWBujX+DtyM1C6sxPuxjY8s5Mdi+ANmcIpvhDxGYxGKuknq V1MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id:dkim-signature; bh=Yj19WDVgOEiJ0u+eDY2fpBdavc72lJgYztZwSidBut8=; b=PkwcU/Uf6KkugbKvEPPv8bQ/+sh/vX0rapxYfrsq1ZdzbUsZiu2SRDyorf17syzY+f o9wvOyD1/IBC54Z7z8g7Fdz5N/OX3mzGMiQH+qY6H2+LqHcIXeoR6EGVkK8q0zw+LJcn wVGnR+s3mhilUNthyuXeJABL1G0qNVtbrvzsNkLbSNGryPOggtq8+W7S11qsibOA+Z5j zrGQL58ak/Y7S2keOgfEo9XTJmA4dbPj2mvyYWBTxGgiL5W7snO8UZZPFs5NZDM8cZw0 6NdopDDN6m3Wqjianj7wRpbQ9mhcY+6C1J1VvRfGwdX0BT8amvsuCTUMZzvnbqJdz/hw 57EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="huSxBs5/"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id a20si2524036pls.354.2022.02.24.08.15.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 08:15:55 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="huSxBs5/"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C750B1965D6; Thu, 24 Feb 2022 08:08:47 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236077AbiBXPS4 (ORCPT + 99 others); Thu, 24 Feb 2022 10:18:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235964AbiBXPS2 (ORCPT ); Thu, 24 Feb 2022 10:18:28 -0500 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B631E141FDA for ; Thu, 24 Feb 2022 07:17:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=Yj19WDVgOEiJ0u+eDY2fpBdavc72lJgYztZwSidBut8=; b=huSxBs5/4Cw6YNoG7UFgt3t7Ns 8JTYhzjzZxMXNZPcxsVqdc5ldJU1s8lxQHnkQgl915iccJtGVP2ntyVayz+YDtwKo3c6KIGEqEaqy a5edumCOltibzxLR4fYCktPvMWshH8ZUVY64O6Isj7MbvcD7/9QZbQUwnUugKjSJehkPoPeUoCuE6 4HNbXcjzFTedgxPuutn9CJCcrNNS4HN2LpTgoXkLbelKoqKNaOltnPOsF/GoLqQXDcXDhSYoLY0AQ yuXdeOqq8LyZpPjxrTTXMgcZwR4yy41PgDLIWEXZFrjsV2tZY6JEEWk+BWgkz9V6l6FilVmn97BC0 AuDEAZpQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nNFs2-00CeLW-JQ; Thu, 24 Feb 2022 15:17:30 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 66687300727; Thu, 24 Feb 2022 16:17:28 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 24EFD29E75E4D; Thu, 24 Feb 2022 16:17:28 +0100 (CET) Message-ID: <20220224151322.190822141@infradead.org> User-Agent: quilt/0.66 Date: Thu, 24 Feb 2022 15:51:41 +0100 From: Peter Zijlstra To: x86@kernel.org, joao@overdrivepizza.com, hjl.tools@gmail.com, jpoimboe@redhat.com, andrew.cooper3@citrix.com Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, ndesaulniers@google.com, keescook@chromium.org, samitolvanen@google.com, mark.rutland@arm.com, alyssa.milburn@intel.com, mbenes@suse.cz, rostedt@goodmis.org, mhiramat@kernel.org, alexei.starovoitov@gmail.com Subject: [PATCH v2 03/39] x86/module: Fix the paravirt vs alternative order References: <20220224145138.952963315@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ever since commit 4e6292114c741 ("x86/paravirt: Add new features for paravirt patching") there is an ordering dependency between patching paravirt ops and patching alternatives, the module loader still violates this. Fixes: 4e6292114c741 ("x86/paravirt: Add new features for paravirt patching") Signed-off-by: Peter Zijlstra (Intel) --- arch/x86/kernel/module.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) --- a/arch/x86/kernel/module.c +++ b/arch/x86/kernel/module.c @@ -273,6 +273,14 @@ int module_finalize(const Elf_Ehdr *hdr, retpolines = s; } + /* + * See alternative_instructions() for the ordering rules between the + * various patching types. + */ + if (para) { + void *pseg = (void *)para->sh_addr; + apply_paravirt(pseg, pseg + para->sh_size); + } if (retpolines) { void *rseg = (void *)retpolines->sh_addr; apply_retpolines(rseg, rseg + retpolines->sh_size); @@ -290,11 +298,6 @@ int module_finalize(const Elf_Ehdr *hdr, tseg, tseg + text->sh_size); } - if (para) { - void *pseg = (void *)para->sh_addr; - apply_paravirt(pseg, pseg + para->sh_size); - } - /* make jump label nops */ jump_label_apply_nops(me);