Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp78788ybk; Fri, 8 May 2020 14:32:28 -0700 (PDT) X-Google-Smtp-Source: APiQypKXkSW1KTWJcjoHxV1hDyy/Hm+sW8nJB6RpxrmR5ufwU7yuB+09gvXMKVNqeJ6wG82y5dIi X-Received: by 2002:a17:906:7717:: with SMTP id q23mr3716074ejm.38.1588973548371; Fri, 08 May 2020 14:32:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588973548; cv=none; d=google.com; s=arc-20160816; b=Qxs/tIVE082DtnqFWU0OXJ+/Ud96AAg2fkR97I68ofMSSwjTQ7bGoUPQYp9Z0h3/of kSGOzJ/rN1z1M4bXg+GvsU8gahPsyQW2kNhCe0naqOUMocslXPhaw6ty4Q23dEvxgwh6 u/gUHtZyYti6tCJ7xYyJuuJnFpwiE2KdO364KgkU0QhJrfVZAxu5ao1omCMCoFeQwoXv 0JLWEAS+gzgKAMc0VVWjrOg5P2XtDsV6dtsDTRNKuu/zSqQxrUq8zAixjhTvsvM1mRRQ Mk0Sy0Cspayshd96SCBhITglAl/XT7CLy787l0SbO+AJqXzsIUhdIN7+xdt2xweGwmoD zz4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=CqtPftNApDWDzyF6kYoZiDQIR7lhRo841FyGIfBz7wA=; b=nPVROQTAM4xxu2zeoq/r5nG6XlQZ2TMurldUqQy2vKhvVp1/4Rd7R21LPxxDgsrWxY 6qNz5bK5Cg4GvQtjEN7dxUChuHPdFsZXH+fDjpuzpsT77KnRXjFLtferkBANcJK2iQ22 nYupf8RpfaM+R3XImVzk4ICUL8iQBLdfoI7zZrFcD1311pQ6EPnCfECqq0UsECPvUdqf klyDgRcSSKYEPOJGMKwjIO1z4fojkYH2B76IPU5xw8toATvVX4frTMvm8qS8sFOpFR/5 ZF7KLLPNWowliJQefCvnhixymwDVuxm6vlMe+36Z1+j3f/FSkpFrDl2teEfRFTbQaLhh XaMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="oW/Pm4ZZ"; 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 32si1636336edr.575.2020.05.08.14.32.05; Fri, 08 May 2020 14:32: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; dkim=pass header.i=@kernel.org header.s=default header.b="oW/Pm4ZZ"; 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 S1727950AbgEHVaP (ORCPT + 99 others); Fri, 8 May 2020 17:30:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:56446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726811AbgEHVaO (ORCPT ); Fri, 8 May 2020 17:30:14 -0400 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CC5A724956 for ; Fri, 8 May 2020 21:30:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588973414; bh=EyjmbmXI3g+Mp7HyMVSIq0UHOgJUZrYjphlm8BnwL3s=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=oW/Pm4ZZxxmIR0YODD3+3/JxEs0EHH9l713SREJn88P52HWJ64NQa2n+xxP/EQjJO QDb+khPTXffJzSk0eTW+EKdhnCik8V/S2XyC5xBcuQblU5Kj+AksEb8T93JKZBGC2N Bvu0my9UNCJL/38cS8AwkgHVyeWnrt8hE/L6zkoA= Received: by mail-wm1-f45.google.com with SMTP id g12so12217718wmh.3 for ; Fri, 08 May 2020 14:30:13 -0700 (PDT) X-Gm-Message-State: AGi0PubimyoXXYDJyQ4OtN5+LrLo2XxA/+x5Nl6nB/rsEmu0wU2maGbB 8YLmHl/0lbVkwWJMCiUOi/iZaSbqrp56aga2a95t9w== X-Received: by 2002:a7b:c5d3:: with SMTP id n19mr11007945wmk.21.1588973412230; Fri, 08 May 2020 14:30:12 -0700 (PDT) MIME-Version: 1.0 References: <20200505131602.633487962@linutronix.de> <20200505134100.957390899@linutronix.de> <20200508084809.GS5298@hirez.programming.kicks-ass.net> In-Reply-To: <20200508084809.GS5298@hirez.programming.kicks-ass.net> From: Andy Lutomirski Date: Fri, 8 May 2020 14:30:01 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [patch V4 part 1 29/36] x86/mce: Send #MC singal from task work To: Peter Zijlstra Cc: Andy Lutomirski , Thomas Gleixner , LKML , X86 ML , "Paul E. McKenney" , Alexandre Chartre , Frederic Weisbecker , Paolo Bonzini , Sean Christopherson , Masami Hiramatsu , Petr Mladek , Steven Rostedt , Joel Fernandes , Boris Ostrovsky , Juergen Gross , Brian Gerst , Mathieu Desnoyers , Josh Poimboeuf , Will Deacon Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 8, 2020 at 1:48 AM Peter Zijlstra wrote: > > On Thu, May 07, 2020 at 11:02:09AM -0700, Andy Lutomirski wrote: > > On Tue, May 5, 2020 at 7:13 AM Thomas Gleixner wrote: > > > > > > From: Peter Zijlstra > > > > > > Convert #MC over to using task_work_add(); it will run the same code > > > slightly later, on the return to user path of the same exception. > > > > I think this patch is correct, but I think it's only one small and not > > that obviously wrong step away from being broken: > > > > > if ((m.cs & 3) == 3) { > > > /* If this triggers there is no way to recover. Die hard. */ > > > BUG_ON(!on_thread_stack() || !user_mode(regs)); > > > - local_irq_enable(); > > > - preempt_enable(); > > > > > > - if (kill_it || do_memory_failure(&m)) > > > - force_sig(SIGBUS); > > > - preempt_disable(); > > > - local_irq_disable(); > > > + current->mce_addr = m.addr; > > > + current->mce_status = m.mcgstatus; > > > + current->mce_kill_me.func = kill_me_maybe; > > > + if (kill_it) > > > + current->mce_kill_me.func = kill_me_now; > > > + task_work_add(current, ¤t->mce_kill_me, true); > > > > This is fine if the source was CPL3, but it's not going to work if CPL > > was 0. We don't *currently* do this from CPL0, but people keep > > wanting to. So perhaps there should be a comment like: > > > > /* > > * The #MC originated at CPL3, so we know that we will go execute the > > task_work before returning to the offending user code. > > */ > > > > IOW, if we want to recover from CPL0 #MC, we will need a different mechanism. > > See part4-18's IDTRENTRY_NOIST. That will get us a clear CPL3/CPL0 > separation. I will hold my breath. > > > I also confess a certain amount of sadness that my beautiful > > haha-not-really-atomic-here mechanism isn't being used anymore. :( > > I think we have a subtely different interpretation of 'beautiful' here. Beauty is in the eye of the beholder. And sometimes in the eye of the person who wrote the code :)