Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5617154ybi; Sun, 7 Jul 2019 08:49:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3XtcIIi9rMOyM28ZIRy51tBXCJa1NeacngwIr1JusTiyoiHBrx7cAuRqFBzFn4fWKHRC9 X-Received: by 2002:a63:c64b:: with SMTP id x11mr17676583pgg.319.1562514557036; Sun, 07 Jul 2019 08:49:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562514557; cv=none; d=google.com; s=arc-20160816; b=nFIdJHgcG11e2b+9JHXtjELt3eiSgoQX3QOXfqwiPvP6MOe01K7fhsQPThs0RynLYd czy17qA087oKM6/q5W9tILYjc100ClZtI9yAZZq2GgqH5/amtK2LhaatxdZcjwgtu+S9 vRAtZDVFUWoqQcQ62dPvM6gDyxeLYRdUYaGmOPVMbhphKNEIFMGvr/p7WD5mP199ood4 RcatR6mQWO3GyPwcGeW1qmjXuptQ7116IE/+04g78xNccc2PKsp+l94mFYEOFCJBB7Vy ldELMSl7XXK/3Q+BaXE2t04EFDd5PUhEmme2nUcPieiRoxvv+90XrzKOV12X0URQXzV3 d7Sw== 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=I6xBemICPA5jJ5oMAt9+3xXFtnwLYd8pt7Q3rV5gngw=; b=cY86mLdkGhRqALeYx/969rWCO9lC0MGc18fRcEtmpd9wueNR/koPOxRERvpr2JPx/7 UKLNT68qU0W0N/J8+vLLY/F0uKTxZ52Xt/pTEOzj59RvwEFd1cfb1Y1VPw3V3rmgTK2G IKSrrMw22HS5rc2sihyTj2s+f+zL3A9+kS1IRu9U9/UchyYsc5OFIwtF+PGfo7AD+faP p6NOyIPNuX8u7YxdQ9cXgojhkZKHXqoomvxGIksPxmvGGbln3iQRRlFzza7aRwxmnHeY NrSaQ0KgShr1I5vkcCQJ85HjaKUR2qZUjHzK6/lbxdgRzIhPxCFMPotp5mH0gm6lTlfn gi6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ejEE4w2g; 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 b18si15568382pgm.82.2019.07.07.08.48.35; Sun, 07 Jul 2019 08:49:17 -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=ejEE4w2g; 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 S1726529AbfGGPKi (ORCPT + 99 others); Sun, 7 Jul 2019 11:10:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:56912 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725928AbfGGPKi (ORCPT ); Sun, 7 Jul 2019 11:10:38 -0400 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 6AEA620989 for ; Sun, 7 Jul 2019 15:10:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562512237; bh=xpjZays0fQz+tdQac2BxpVV4yuHltHrUK2Qlejw3t5o=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ejEE4w2gmL5oreRSNJIl4iFxkYVy7+Q/91X9ZHIJU+7gsykAiYZTWThbBEF4GW5lq CS9+uT3r1D/XjvQnpYigSTDN97aC8igH/e9QASDuwqDup9dpLNNZQuev5gpcxKluLL DAmfLVRy3Swbnj7vZ4vPZY9GwF1cY/2R6OsSNl7c= Received: by mail-wr1-f54.google.com with SMTP id x4so14375146wrt.6 for ; Sun, 07 Jul 2019 08:10:37 -0700 (PDT) X-Gm-Message-State: APjAAAUxchX93UzLz7c3SReJeb8muTZO/6gKnE8Y64FPMBQmoggmUrg1 udyi6GyzIMjeHUvWN9MNIFaTZT5zXjC76ZIFecKfsA== X-Received: by 2002:adf:dd0f:: with SMTP id a15mr13241473wrm.265.1562512235959; Sun, 07 Jul 2019 08:10:35 -0700 (PDT) MIME-Version: 1.0 References: <20190704195555.580363209@infradead.org> <20190704200050.534802824@infradead.org> In-Reply-To: <20190704200050.534802824@infradead.org> From: Andy Lutomirski Date: Sun, 7 Jul 2019 08:10:24 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 5/7] x86/mm, tracing: Fix CR2 corruption To: Peter Zijlstra Cc: Thomas Gleixner , Borislav Petkov , Ingo Molnar , Steven Rostedt , Andrew Lutomirski , 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 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.