Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp3024735pxy; Mon, 3 May 2021 13:19:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSYKiSAThVQg2F2NM5FYexWUxMBW2SeJVuANWZg9cxBgAHZszvAB6DAl3HQuIsjVlDBTC0 X-Received: by 2002:a17:906:5285:: with SMTP id c5mr7741820ejm.282.1620073162037; Mon, 03 May 2021 13:19:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620073162; cv=none; d=google.com; s=arc-20160816; b=LBZ1nfq5+eYu2EeEbvt5guUrXsNsnvPUJd7l0/c3Zm9CNzp0t77UT3fgACFJy6fQ46 LAaVM8gWjTwZCeBqchzU4ypYHCmMr2xg673bV15DRM8RvK9KuNQzxsXufwlo5/b0yV7f W5xC4hVOAg6audoMnHxL/9ZGflh4yuTuhqAbims5lBmtFTov2oKfY3hbhIU+mYlc7IeT Wdi8pRhnn6e9Tl6fQOTlezVqGh53G4vzx++6aqHmUHXtCOpyClGVf/3x+UA3UyNBDJsg gsLgeiA7p48FLzCqkBZfTwSv5o5uFp4/xl+njGJnC9O3kpbPqgtO7wZbCcOjQFZqQ6aq Z9kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=HvQ7u7A8iAj2FBn0UjXoxB+opXdCsfuP4o1Z1osVN0g=; b=ylcxMGaIKUs909gL3C0Bg+z4mxPxQbRX8+bS44uD9AloOuEGK5rFoxqTKMb+cZOmUu Kfys9DNImxONrE+YA/Uyv6us766KPZgtd1/SXTcuHukWiUTaB/TbHC1HO3EOZzzvmtL3 UrDV3XBgUWDIW0zYZbv9Qs4R6PbwsXtOCvDFakGYiIKvY7+RdroKFFm6oUI06hOjDanK ESU4LJWOY8d6bInGc6f1DhMBrRRGxuRNqYRGAyiJq3DmbDcR01e1FYl+mkKZnoaTQKRl Q6/c2j+q3jvLaFb6VflRZRevZuP1LfQ4DwJf2HPQnqfe1KDz5u9qIuZ/q/Ma2zuVtGn5 H7hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=avmp6FZK; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h15si813935eje.694.2021.05.03.13.18.58; Mon, 03 May 2021 13:19:22 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=avmp6FZK; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229620AbhECUQ2 (ORCPT + 99 others); Mon, 3 May 2021 16:16:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:51282 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbhECUQ2 (ORCPT ); Mon, 3 May 2021 16:16:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DB49B613B4 for ; Mon, 3 May 2021 20:15:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620072934; bh=mP8Y7U43gy2c5RTnca0Wv9xuHE58Zvi51r0OQS2/7/0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=avmp6FZKS+si9oRkKl/vvk04008WSnuDrPtqS7fFY/Hp8cT8mscn2JfnY3/rouno9 L2kFyCLcQBNKS1kh9nd21PFuC/kXyZ1uge1wbqyA+kjEUEZgnJx0npPm2zmndMdEBV thrzn0YPQN230jDVfJO5a/dCWaX6hNfFBZtBWTFT2jwuNRuE/cR0jY4ejH8o8+8v+q ryi9dmvInZ8ApsJPlGyRpQkRupK9Tout99v327RXZdc9wDmOMmUdWT47KuG/SCbVf3 bFJ++wBbJBodw5HLVoHRk76GrcBd1c9/fTUH4dAbFkRXdVO7H/Ygus1agH1tQ1GJYU 4MWYFbtvYBCbg== Received: by mail-ej1-f42.google.com with SMTP id t4so9815784ejo.0 for ; Mon, 03 May 2021 13:15:34 -0700 (PDT) X-Gm-Message-State: AOAM533B+bL5TODKlSYPBLdzyCAXAk1dVqqio1sUYVcWAfMkBfjnq1dM C73RJUaWWRLmf/8QmGciGxOotUMPQrZkSUNzvxD2uA== X-Received: by 2002:a17:906:ccc9:: with SMTP id ot9mr5555145ejb.253.1620072933403; Mon, 03 May 2021 13:15:33 -0700 (PDT) MIME-Version: 1.0 References: <8735v3ex3h.ffs@nanos.tec.linutronix.de> <3C41339D-29A2-4AB1-958F-19DB0A92D8D7@amacapital.net> In-Reply-To: From: Andy Lutomirski Date: Mon, 3 May 2021 13:15:21 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] io_thread/x86: don't reset 'cs', 'ss', 'ds' and 'es' registers for io_threads To: Linus Torvalds Cc: Thomas Gleixner , Stefan Metzmacher , Jens Axboe , Linux Kernel Mailing List , io-uring , "the arch/x86 maintainers" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 3, 2021 at 12:15 PM Linus Torvalds wrote: > So generally, the IO threads are now 100% normal threads - it's > literally just that they never return to user space because they are > always just doing the IO offload on the kernel side. > > That part is lovely, but part of the "100% IO threads" really is that > they share the signal struct too, which in turn means that they very > much show up as normal threads. Again, not a problem: they really > _are_ normal threads for all intents and purposes. I'm a bit confused, though. All the ptrace register access (AFAICS) goes through ptrace_check_attach(), which should wait until the tracee is stopped. Does the io_uring thread now stop in response to ptrace stop requests? > > But then that (b) issue means that gdb gets confused by them. I > personally think that's just a pure gdb mis-feature, but I also think > that "hey, if we just make the register state look like the main > thread, and unconfuse gdb that way, problem solved". > > So I'd actually rather not make these non-special threads any more > special at all. And I strongly suspect that making ptrace() not work > on them will just confuse gdb even more - so it would make them just > unnecessarily special in the kernel, for no actual gain. > > Is the right thing to do to fix gdb to not look at irrelevant thread B > when deciding whether thread A is 64-bit or not? Yeah, that seems like > obviously the RightThing(tm) to me. > > But at the same time, this is arguably about "regression", although at > the same time it's "gdb doesn't understand new user programs that use > new features, film at 11", so I think that argument is partly bogus > too. > Fair enough. But I would really, really rather that gdb starts fixing its amazingly broken assumptions about bitness. > So my personal preference would be: > > - make those threads look even more like user threads, even if that > means giving them pointless user segment data that the threads > themselves will never use > > So I think Stefan's patch is reasonable, if not pretty. Literally > becasue of that "make these threads look even more normal" I think it's reasonable except for the bit about copying the segment regs. Can we hardcode __USER_CS, etc, and, when gdb crashes or otherwise malfunctions for compat programs, we can say that gdb needs to stop sucking. In general, I think that piling a bitness hack in here is a mess, and we're going to have to carry it forward forever once we do it. Meanwhile, I am going to put my foot down about one thing: NAK to this patch until it comes with a selftest. That selftest needs to test the cs behavior, but it also needs to read the FPU state from an io_uring thread, write some FPU state to that thread, and read it back. And it needs to not OOPS. Not breaking ABI is nice and all, but even more important is not breaking the kernel. --Andy