Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5411694rwb; Wed, 7 Sep 2022 02:20:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR5EIVn9WO1Tu2Ojhk0jeFXr1ONBIyQtbA/jYixtm22b+FKSD5shG+ud+UdKqU9fZQuVWxUZ X-Received: by 2002:a17:903:244f:b0:176:85e3:4236 with SMTP id l15-20020a170903244f00b0017685e34236mr3026305pls.103.1662542444647; Wed, 07 Sep 2022 02:20:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662542444; cv=none; d=google.com; s=arc-20160816; b=Io+bSXqvL0JlkQUrTLMFtCr84qGacyAvUbaTXY3ZXh3EuQyfzqXFIo6Z+b9ws6FqSG 24E93tx+HG4QF96RYLScG8oGF3UDaPwBhZlWprRW5Fh7+wcjvVm/Dsr4GNjYDsFdWtQ1 5IBFvLdC6Y6ZoD/V5sySYwRpirV4SNKSMn5JpczAKH9Zgjh27ylAltFrZuP06BNZa4Y5 ZdqIrkP08lsc50YPW4oOYrZZj5xmpk/JhyoSYt/RvdUNT4awrBoU+95IWM4DY102OAcA 3ZKFGPCj6r3dE7aFJCAjg3FifraHA4oiAzlOv79CW9ykWJNbNGmhv7TadnIZ19rYaJfv RdXg== 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=M9ffSCcPAJFL/NG3iecTA6XnLuNGeYKgtteM2yRjbw8=; b=ptEmUqep5uRkhdOBKW0xrgtcSTSVCGLaAyxNvq4391b3o3yDtB1iaTAADeX3a98w7y r16BbIUrvuuDz6qSuavmol+rKVmvrlOZfmn60LT+EnfaAEdtGkRuAj9IXqgUy9SxC88D srIKYHNHguw4+SOEb3ZWd6VA2sojeOgog8Tq6wX2tPafB7YZNhnxUDz+r6klNYJT2heX a8NFOy/R106Xwt+paZugfbXdssclE6pkn6PmK1KY0OnDgTf1DUc7Lv556bitLvZoDfgr o0wdivfAnd5Q2d7mpHaA6buhY6pBeUE4NocirVXGd/w0YUYLdY2XnvPSAd8h95A/cR6w p2eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=RkCkoGes; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id na12-20020a17090b4c0c00b001fe1cc52234si3661190pjb.67.2022.09.07.02.20.33; Wed, 07 Sep 2022 02:20:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=RkCkoGes; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229922AbiIGIu6 (ORCPT + 99 others); Wed, 7 Sep 2022 04:50:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229906AbiIGIuz (ORCPT ); Wed, 7 Sep 2022 04:50:55 -0400 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 BC8BE72860; Wed, 7 Sep 2022 01:50:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=M9ffSCcPAJFL/NG3iecTA6XnLuNGeYKgtteM2yRjbw8=; b=RkCkoGesMVEcRNleJvacW27ZN9 eY6mqXlLytLmnVTUKkvVx8upYmP36N0nVMK6OGviCGk0MrGxxqvCKFQ2sVRWckFQAB5ga87K5lECr 7m0wErxJQXSkUWe0P3Qq31N3F9tBcfUN2tNLtWayNUzwxQGjlG35NgtA8f1SDxw4a6Bx/48ySEszA KPjszB/XFsGfcyya0D92vkgmt8MBtS9AeDfzrSfDWIxuZ8jnpXh+c9RTwBZWtiuuZHUMtPsReO5PX Cud2D6l2SHerN+rFL9hFmy6zneagpc7A2yy9HT/ovVqtGCSOiWRuqX7kFvwVUvfahUbviFXUq9k90 gaDEFQVA==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVql3-00APB3-3s; Wed, 07 Sep 2022 08:50:05 +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) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id C72E130013F; Wed, 7 Sep 2022 10:50:03 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 9DD9B20134FB3; Wed, 7 Sep 2022 10:50:03 +0200 (CEST) Date: Wed, 7 Sep 2022 10:50:03 +0200 From: Peter Zijlstra To: Nick Desaulniers Cc: Bill Wendling , Kees Cook , Juergen Gross , "Srivatsa S. Bhat (VMware)" , Alexey Makhalov , VMware PV-Drivers Reviewers , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" , virtualization@lists.linux-foundation.org, LKML , Nathan Chancellor , clang-built-linux , linux-hardening@vger.kernel.org Subject: Re: [PATCH 2/2] x86/paravirt: add extra clobbers with ZERO_CALL_USED_REGS enabled Message-ID: References: <20220902213750.1124421-1-morbo@google.com> <20220902213750.1124421-3-morbo@google.com> <202209022251.B14BD50B29@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Tue, Sep 06, 2022 at 11:00:07PM -0700, Nick Desaulniers wrote: > On Sun, Sep 4, 2022 at 11:02 PM Bill Wendling wrote: > > > > On Sat, Sep 3, 2022 at 12:18 AM Kees Cook wrote: > > > > > > On Fri, Sep 02, 2022 at 09:37:50PM +0000, Bill Wendling wrote: > > > > [...] > > > > callq *pv_ops+536(%rip) > > > > > > Do you know which pv_ops function is this? I can't figure out where > > > pte_offset_kernel() gets converted into a pv_ops call.... > > > > > This one is _paravirt_ident_64, I believe. I think that the original > > issue Nathan was seeing was with another seemingly innocuous function. > > _paravirt_ident_64 is marked noinstr, which makes me suspect that it > really needs to not be touched at all by the compiler for > these...special features. My source tree sayeth: u64 notrace _paravirt_ident_64(u64 x) And that function is only ever called at boot, after alternatives runs it's patched with: mov %_ASM_ARG1, %_ASM_AX Anyway, if you want to take it away from the compiler, something like so should do. diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index 7ca2d46c08cc..8922e2887779 100644 --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c @@ -80,11 +80,16 @@ static unsigned paravirt_patch_call(void *insn_buff, const void *target, } #ifdef CONFIG_PARAVIRT_XXL -/* identity function, which can be inlined */ -u64 notrace _paravirt_ident_64(u64 x) -{ - return x; -} +extern u64 _paravirt_ident_64(u64 x); +asm (".pushsection .entry.text, \"ax\"\n" + ".global _paravirt_ident_64\n" + "_paravirt_ident_64:\n\t" + ASM_ENDBR + "mov %" _ASM_ARG1 ", %" _ASM_AX "\n\t" + ASM_RET + ".size _paravirt_ident_64, . - _paravirt_ident_64\n\t" + ".type _paravirt_ident_64, @function\n\t" + ".popsection"); #endif DEFINE_STATIC_KEY_TRUE(virt_spin_lock_key);