Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp935696pxb; Wed, 15 Sep 2021 17:21:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFwYDShF8/fK0V/0KdTys6ZeBAK9k6uVR3bArp3pwgxDzIipcvRfB6QcT957VCenGKCp4t X-Received: by 2002:a17:906:f0d4:: with SMTP id dk20mr3065617ejb.199.1631751688539; Wed, 15 Sep 2021 17:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631751688; cv=none; d=google.com; s=arc-20160816; b=C7HSp6HJrL4S6/LwIiLHt7atygcL6JZ5qOBQW1inGy3YMTuThgMqQov7JSSegqhthu hzoQWw/f9OSYqtM9CWezJ9OVYN9GyJIN4mKFu4VUdzoYuPhRt9TU43NaKlgcuOyrzVeK kUopLt/y0iuV/+toSpYPQgLEjacXmOcKFckEYm1ZMUuQ+1y+P4wHxHPyPd2j6W1OX0pC dRSLuTU0TB8c2nnxxQkkfu4hSmd/+LBi/KXm0iwInTgjz7xcn8pA/Qaj1nsTN1FTeSn/ VIAqEeHKaZYXD8gRBHCGhToQGo+2ykEw2eK6F7DosgM/2JzVjL93OLQ9Z4pm3xhivQiK vFuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=cEaPUd4YZq6PFEjjPsFcdzyke5hSU9t0xQXFfIp6A+A=; b=lrS4GfqJKIfexpULXkjV7NX2GzqwRRt2uqXHUjUjQJ1d3NhhmSPjxbx80QrmKMjEPr clz8Lt4D4MdQD/rAVenM7BN1jaL1jAs5Bhk91y2kR5ppmDe02NjkukzYf9a4pXaXcUKB nhxDatdlwDBsLR7J7D6lQlhd4ijyhXrAhgNmVrUpTcFfmgq12Mh4seoJGeybMH6bW0ji FiTzYPP+V/bW8XrBzDooQ++C9WHb4qxfjdZ1bneJ3yn2V6Qyzabp3JDUGx2TRE83x8EE yL2ommt25Cz+Lwpd6L27YseQCYJ8RTNVKgF6pFIvsydBIkrRF+fvexhgOKAn5eBbw7sy qDIg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r12si1501895edc.335.2021.09.15.17.21.05; Wed, 15 Sep 2021 17:21:28 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233389AbhIPAVI (ORCPT + 99 others); Wed, 15 Sep 2021 20:21:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232836AbhIPAVH (ORCPT ); Wed, 15 Sep 2021 20:21:07 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07CBCC061574; Wed, 15 Sep 2021 17:19:47 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mQf7v-004Y0I-Rg; Thu, 16 Sep 2021 00:19:43 +0000 Date: Thu, 16 Sep 2021 00:19:43 +0000 From: Al Viro To: Michael Schmitz Cc: linux-m68k@lists.linux-m68k.org, Geert Uytterhoeven , Greg Ungerer , linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] m68k: leave stack mangling to asm wrapper of sigreturn() Message-ID: References: <08183665-f846-0c5e-a8c7-d0a65e78a3da@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <08183665-f846-0c5e-a8c7-d0a65e78a3da@gmail.com> Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 16, 2021 at 11:35:05AM +1200, Michael Schmitz wrote: > This one's a little harder - you use a 84 byte gap on each sigreturn, no > matter what the frame size we need to restore. The original > mangle_kernel_stack() only makes room on the stack when it has no other > option (using twice as much size - correct me if I'm wrong). > > Ideally, we'd only leave a gap for mangle_kernel_stack() to use if the frame > size requires us to do so. Working that out in asm glue would be > sufficiently convoluted as to cancel out the benefits of cleaning up the C > sigreturn part. Probably not worth it. You'd need to * load the frame type from sigcontext (and deal with EFAULT, etc.) * make decision based on that * pass the type down into sigreturn(), so we wouldn't run into mismatches. And all that just to avoid a single "subtract a constant from stack pointer" insn. We are on a very shallow kernel stack here - it's a syscall entry, after all. And the stack footprint of do_sigreturn() is fairly small - e.g. stat(2) eats a lot more. We are not initializing the gap either - it's just reserved on stack; we only access it if we need to enlarge the stack frame. IOW, what would be the benefit of trying to avoid unconditional gap there?