Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5617197ybi; Sun, 7 Jul 2019 08:49:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwAyoHw+iesdekXmw6J6MvKQJnbuZ+b6O+y7PF6pK+9utrojtJV3ZEccRBnsrADk+9g1P+g X-Received: by 2002:a17:902:e281:: with SMTP id cf1mr17767006plb.271.1562514561286; Sun, 07 Jul 2019 08:49:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562514561; cv=none; d=google.com; s=arc-20160816; b=ut5DPYJKdLqcjWBsyxZne55Fau6GYmAE/asHfchwIFxyZDhPhmptsJS0F11G6TnohU r6kHRjncYBiab3xQbS+r+/T2J7GYrGiVk6bLelA5ow8mo/sDDD1VlZHSB599F7gzPQEX wq8Toxn5fxG546RERDFj82HqJjkI2bUL1DQuosRS8zQ30BF28eMMOVA+Oveo+dY1E9dw WqmOcMtc8QYvMMmAaDQxJ//PVSvS8i3ooSSM4iM2Xaz3KhzGrUjbw3gcmC06glATN/C1 z0q9H8jq9LLIbwoC8clfig4MO/6ORLulDTEY3PFDz5K/kQAKbAhVqUI4VeG+DsRmtSQU IP3g== 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=nao3wBho3MjTDg3p2oxu3Od5jXwzxBu5C0xXZ4I76LQ=; b=mDpXGwyZMnwuaAqe3WcI4NcWlIXgbsR8yv05Q8+uiZO9xsZjC56Ampc9LM92Ow06Lu rfk1y2bveqSM2DhphpbkQ5VPlh+ftvkkB4MO17uOdhCdewqqi3D7FNO39i5sUaoIqtS6 lIubxlcnkPJxKBqYk+5XvKgbNLYjf8AAwZSnrWqUv98CuVh32yF1vnF/FiOHLdO923Hl VDLFDyB+w+//PEq9YzxRSAqTbcjRCc+FtT/Nd8JIaGhydTsnVTPXx8sJuarAp8Ge7RgC xZAT1+W16QkTyxGsezobVE3f2NuNIScvUQ8BgBeIiIP0EFhBCfq4k6T6OEUBOG/K/kae fQlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yMBTRU9v; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id r22si15537957pgo.420.2019.07.07.08.49.06; Sun, 07 Jul 2019 08:49:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yMBTRU9v; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726983AbfGGPLi (ORCPT + 99 others); Sun, 7 Jul 2019 11:11:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:57466 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725928AbfGGPLh (ORCPT ); Sun, 7 Jul 2019 11:11:37 -0400 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.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 563CB20830 for ; Sun, 7 Jul 2019 15:11:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562512296; bh=DlD0ZqCFs4Sd1QYpz2g8ouRwGt4Zydb3dTYVQkQrzig=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=yMBTRU9v7y9YWuA6gCalyBmzTkpUjdkduuwvitKnTbmancNxL4i30NpQDVthB3HwD jxKgJiQxlD94BaskHuw/HvXvCCpCJbhyizTcJRoymZSQZSdMQGWlBoOCWI1KexXTWx IXMCjp3v/MsZRM909BAgA4QC61nJOke6AjntemzQ= Received: by mail-wr1-f45.google.com with SMTP id g17so4249373wrr.5 for ; Sun, 07 Jul 2019 08:11:36 -0700 (PDT) X-Gm-Message-State: APjAAAXmW6PlBCb5GBxCPU0F53eRo+p0TFSSM0enZmHl+cXKNZOpaDr/ /apbB6pY++SEq3ESH/yaR2whJJl9LLrdl4y3UNiXBg== X-Received: by 2002:a5d:4309:: with SMTP id h9mr13538308wrq.221.1562512294975; Sun, 07 Jul 2019 08:11:34 -0700 (PDT) MIME-Version: 1.0 References: <20190704195555.580363209@infradead.org> <20190704200050.534802824@infradead.org> In-Reply-To: From: Andy Lutomirski Date: Sun, 7 Jul 2019 08:11:23 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 5/7] x86/mm, tracing: Fix CR2 corruption To: Andy Lutomirski Cc: Peter Zijlstra , Thomas Gleixner , Borislav Petkov , Ingo Molnar , Steven Rostedt , Linus Torvalds , "H. Peter Anvin" , Dave Hansen , Juergen Gross , LKML , He Zhe , Joel Fernandes , devel@etsukata.com 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 Sun, Jul 7, 2019 at 8:10 AM Andy Lutomirski wrote: > > On Thu, Jul 4, 2019 at 1:03 PM Peter Zijlstra wrote: > > > > Despire the current efforts to read CR2 before tracing happens there > > still exist a number of possible holes: > > > > idtentry page_fault do_page_fault has_error_code=1 > > call error_entry > > TRACE_IRQS_OFF > > call trace_hardirqs_off* > > #PF // modifies CR2 > > > > CALL_enter_from_user_mode > > __context_tracking_exit() > > trace_user_exit(0) > > #PF // modifies CR2 > > > > call do_page_fault > > address = read_cr2(); /* whoopsie */ > > > > And similar for i386. > > > > Fix it by pulling the CR2 read into the entry code, before any of that > > stuff gets a chance to run and ruin things. > > Reviewed-by: Andy Lutomirski > > Subject to the discussion as to whether this is the right approach at all. FWIW, I'm leaning toward suggesting that we apply the trivial tracing fix and backport *that*. Then, in -tip, we could revert it and apply this patch instead.