Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1343040pxm; Thu, 24 Feb 2022 00:57:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwfh9EzcEBUNFclykXwiCj1FsDOsxMHCzTqYu6jnkjLnvTwJGGycVjmip3QSuszYKZ5Pcf6 X-Received: by 2002:a17:906:69ce:b0:6a7:8c03:3caa with SMTP id g14-20020a17090669ce00b006a78c033caamr1432695ejs.335.1645693058727; Thu, 24 Feb 2022 00:57:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645693058; cv=none; d=google.com; s=arc-20160816; b=oh1o7Ei362DvF8weKV7J4YwEovMsIaEOXwizS5hLyFGJkl1B9EurP70whVfmVcByum tRJEp7TwKUWr3QbdIAxVX0UpaJEg9n5x99qYBt+Bcbk3uFvryOXyDzmM6cFBKmjVRNOM QbVi19S9dRDBmnwxGdVghw1t4FlKyzJ+SJevui57Bbs8btHpSSfRTN1aDwEjIhbhkQ2Y 6aTmeaLgZjHPg7raZKuHeL1KMVWtYyLoVHfnmezjv0TpzhaT4hjq4hhQkJOzyFccWH8T jVG4o4wUbkctG8hKCy5ScgY/3iqRdvZhPXgy76iyGrxoaBLsh0JpVCp+F3L41k1NkBHi MuxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=qlaKR81TB9uC2qecK8Ka2Y5+wlvJqCdWDbHzUcfcJ7U=; b=q7kVKmGN0tA8FE0v0kohweV0J62rjnQPWW0oc9IarojuewoQeXZHzZOrmJRZtJ3ut2 72SkImMjKggaaldqXgFLq8iJujIvIJ9JRqNSMNBxjcLTTjUcqCjLSdHCBiw6wxBdoyUy YTNBjiTlwbIwJB46ae7vijjuEz1Qh7QhMV/SPGgbqNbijoWWJr9fIdTh4WvqN5I93jyp SSXZ0QqsnAvqwTkSimYuEbx56vaRYC8uueJSczZzys8tOjnXxX4L8g7i6R9Tlb8s3dbD nChRTUfvmFmrBWrB0V+CtETHMkXUpzer06TV0v9mTvvfKYb7JDqh6t+f+1AUQdq/9qd3 MFyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@iram.es header.s=DKIM header.b=ndlmi1AQ; 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 t23si1198732ejj.850.2022.02.24.00.57.14; Thu, 24 Feb 2022 00:57:38 -0800 (PST) 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=@iram.es header.s=DKIM header.b=ndlmi1AQ; 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 S232130AbiBXIby (ORCPT + 99 others); Thu, 24 Feb 2022 03:31:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232079AbiBXIbo (ORCPT ); Thu, 24 Feb 2022 03:31:44 -0500 Received: from mx01.puc.rediris.es (outbound5mad.lav.puc.rediris.es [130.206.19.148]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA35627AA2E for ; Thu, 24 Feb 2022 00:30:36 -0800 (PST) Received: from mta-out01.sim.rediris.es (mta-out01.sim.rediris.es [130.206.24.43]) by mx01.puc.rediris.es with ESMTP id 21O8U0DJ022857-21O8U0DL022857 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Thu, 24 Feb 2022 09:30:00 +0100 Received: from mta-out01.sim.rediris.es (localhost.localdomain [127.0.0.1]) by mta-out01.sim.rediris.es (Postfix) with ESMTPS id 88B8B300B952; Thu, 24 Feb 2022 09:30:00 +0100 (CET) Received: from localhost (localhost.localdomain [127.0.0.1]) by mta-out01.sim.rediris.es (Postfix) with ESMTP id 78135300C3A2; Thu, 24 Feb 2022 09:30:00 +0100 (CET) X-Amavis-Modified: Mail body modified (using disclaimer) - mta-out01.sim.rediris.es Received: from mta-out01.sim.rediris.es ([127.0.0.1]) by localhost (mta-out01.sim.rediris.es [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id ga1OKfOOAvLI; Thu, 24 Feb 2022 09:30:00 +0100 (CET) Received: from lt-gp.iram.es (haproxy02.sim.rediris.es [130.206.24.70]) by mta-out01.sim.rediris.es (Postfix) with ESMTPA id F1025300B952; Thu, 24 Feb 2022 09:29:59 +0100 (CET) Date: Thu, 24 Feb 2022 09:29:55 +0100 From: Gabriel Paubert To: Segher Boessenkool Cc: Christophe Leroy , Kees Cook , linux-kernel@vger.kernel.org, Paul Mackerras , linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH] powerpc/32: Clear volatile regs on syscall exit Message-ID: References: <28b040bd2357a1879df0ca1b74094323f778a472.1645636285.git.christophe.leroy@csgroup.eu> <20220223232739.GJ614@gate.crashing.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220223232739.GJ614@gate.crashing.org> X-FE-Policy-ID: 23:8:0:SYSTEM DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; d=iram.es; s=DKIM; c=relaxed/relaxed; h=date:from:to:cc:subject:message-id:references:mime-version:content-type; bh=qlaKR81TB9uC2qecK8Ka2Y5+wlvJqCdWDbHzUcfcJ7U=; b=ndlmi1AQs/O8De46rNXAR9JR8GwX4uyB1QBUMFmXWqdacLOh079Mhp/eegPEMKZg954bG9hOoScg VcOb27Mdh41JaedY6PFZMnh+E1lVA4+WkxH+Y7v03pjbdBzUSZdbqKzySXGqABGHYW4pHelBvRwp UlnhV7SXcomMZRou0yHIYHvFYpYhcWiE1aJaPVVegXfMoqKfbaoLTKTWM3Zu+8lDIkHXdmmoUe2i PcC88D9V6X0cikzfXu1DrmE7L5xzrQbi9ilyuINsxvUnFY/725tpUxQgxDFi5mcI5M3Mr1GAyaDn Jh9zAHux/U9FUMGQC8wtxpNNZ0Ab8qT0e82V0w== X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,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 Wed, Feb 23, 2022 at 05:27:39PM -0600, Segher Boessenkool wrote: > On Wed, Feb 23, 2022 at 09:48:09PM +0100, Gabriel Paubert wrote: > > On Wed, Feb 23, 2022 at 06:11:36PM +0100, Christophe Leroy wrote: > > > + /* Zero volatile regs that may contain sensitive kernel data */ > > > + li r0,0 > > > + li r4,0 > > > + li r5,0 > > > + li r6,0 > > > + li r7,0 > > > + li r8,0 > > > + li r9,0 > > > + li r10,0 > > > + li r11,0 > > > + li r12,0 > > > + mtctr r0 > > > + mtxer r0 > > > > Here, I'm almost sure that on some processors, it would be better to > > separate mtctr form mtxer. mtxer is typically very expensive (pipeline > > flush) but I don't know what's the best ordering for the average core. > > mtxer is cheaper than mtctr on many cores :-) We're speaking of 32 bit here I believe; on my (admittedly old) paper copy of PowerPC 604 user's manual, I read in a footnote: "The mtspr (XER) instruction causes instructions to be flushed when it executes." Also a paragraph about "PostDispatch Serialization Mode" which reads: "All instructions following the postdispatch serialization instruction are flushed, refetched, and reexecuted." Then it goes on to list the affected instructions which starts with: mtsper(xer), mcrxr, isync, ... I know there are probably very few 604 left in the field, but in this case mtspr(xer) looks very much like a superset of isync. I also just had a look at the documentation of a more widespread core: https://www.nxp.com/docs/en/reference-manual/MPC7450UM.pdf and mtspr(xer) is marked as execution and refetch serialized, actually it is the only instruction to have both. Maybe there is a subtle difference between "refetch serialization" and "pipeline flush", but in this case please educate me. Besides that the back to back mtctr/mtspr(xer) may limit instruction decoding and issuing bandwidth. I'd rather move one of them up by a few lines since they can only go to one of the execution units on some (or even most?) cores. This was my main point initially. Gabriel > > On p9 mtxer is cracked into two latency 3 ops (which run in parallel). > While mtctr has latency 5. > > On p8 mtxer was horrible indeed (but nothing near as bad as a pipeline > flush). > > > Segher