Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2850041ybi; Thu, 4 Jul 2019 20:53:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwE8rOSQTCCJoMFC5QeKyPZmw/847bPJ8mmD7di5KqDEOQM2lANYRB12cDGGijgpTCVz0MS X-Received: by 2002:a65:504c:: with SMTP id k12mr2256821pgo.252.1562298827549; Thu, 04 Jul 2019 20:53:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562298827; cv=none; d=google.com; s=arc-20160816; b=twso+XtKcQectYcOuUZvKbXvBOrrPyNjQnMh8unY42v22jUM63utz/QI+wfMtEDdEO m0JgkTPVYvm/2nTV6GOaUGQu0+K0cTY5FKn0RdZgG+2nuaQ7vLFeZmV/CQ7lF7c9ife7 Pk9moJj6qwvTlbbUtG/Fw4cZ1j0fsLEOxMu5W4rhBfdZhzXNou6rDGWtMfNuGlIisW6R nWKDoP+9GbEjMesjW2GCbmw7zlGwwqT9z9JJl1LmeiXrIMjNVB8dkWwbFsbPGvguhix0 gRSU34iSGAb8+iDgQKyw0HFz4OlHJaNJw6vRcF1Yyf9XJeW1JW7lVjh8YwvemapKiJd/ +ORA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=TgCG2v/18aLvVnJHA93hfe9UUNoDJjfM4smfbeOmGTs=; b=SOmIxyZ8EeOsLYC+gsxRZLNwJcJXl2Wab+VzjF3zxTzr2aiZVuK6pPggVosz7NnFLt pQdFOrxkc0NpfGTrEWTl05fV/1sY2DmSL1DNdHmjBeZLkudpMO78MJd7w/FOFmpJCQQK fHH9izeTezKUAG3iiYyjXj7XGpV4vw/nB33Lc3TZ6ukqaQsV255uRAbBqEvarpCbUXBy rwP/HDwLN/l2MmriP7wV5tBdEPB+LhIpKpxWTYWY/iZ4OPjPuRalyZtfZV6MMJ2qHdEr ecZAkRHugxNz+n2u0Xut2zwvqUrFFM4mmCR1M5bgZsxuNKeNq6R4JXbu+oreH1v6WrUX G9hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=ZKAENLkG; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m14si2118648pgv.97.2019.07.04.20.53.32; Thu, 04 Jul 2019 20:53:47 -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=@linux-foundation.org header.s=google header.b=ZKAENLkG; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727464AbfGED2K (ORCPT + 99 others); Thu, 4 Jul 2019 23:28:10 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:36124 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726404AbfGED2K (ORCPT ); Thu, 4 Jul 2019 23:28:10 -0400 Received: by mail-lj1-f196.google.com with SMTP id i21so7819249ljj.3 for ; Thu, 04 Jul 2019 20:28:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=TgCG2v/18aLvVnJHA93hfe9UUNoDJjfM4smfbeOmGTs=; b=ZKAENLkGf1r+fUGMW12YDOU0HGdQRO+qsTxUG0bZTYQqCvkduK6W3gq0wUb+5AXGha ecmSYa9uzB5kyzf/pLjBmRSSMG3uBQqWlnqvMd5F2KGYxmAA06Xu2NofTloVlimN5tio RNP8VVKzRv1mW6VhS6LEbSnR6Y4vCzkYijDRo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=TgCG2v/18aLvVnJHA93hfe9UUNoDJjfM4smfbeOmGTs=; b=c5BiocTYv7dKk2AuV9S+OP/kDcxUvAoYfCt3pvozMz+d7e9EsA+9kU1ILBqiRkEeQI MCAizATshOIY9fxE5yLLLlvqb4fIMb45aroL4nGYkdd/PkOkevq3+PA/qlqf4ZrGPr+h 72VpSDZ2TYEYeF2gGbIeeZJZJXkU/uNJMmsr43hgsbahfZUmImlh76nuk2b9BkQk1oWx CTUkipS8AyzXlSXYBozVTHeYResiQ2n8DIfieS7eSvSzt26nr0yBBclbjWv57TxyG4QB qxI2ryVuzWJEApVK9vwYI2WpSJTs/o5+BpbgdiuCx79BRFS4ymEJljxMeBsiUC0crqfH 31iQ== X-Gm-Message-State: APjAAAUY6IfpOI0CB7bnzwdXwpiPDPWsy0EPCbktRpKm64uANNmKui0a QmBZsWsDgHuMdpLBGoTEkgOZpRHz+osJZg== X-Received: by 2002:a2e:9754:: with SMTP id f20mr719433ljj.151.1562297287642; Thu, 04 Jul 2019 20:28:07 -0700 (PDT) Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com. [209.85.208.177]) by smtp.gmail.com with ESMTPSA id t21sm1152045lfd.85.2019.07.04.20.28.06 for (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jul 2019 20:28:06 -0700 (PDT) Received: by mail-lj1-f177.google.com with SMTP id 205so7799424ljj.8 for ; Thu, 04 Jul 2019 20:28:06 -0700 (PDT) X-Received: by 2002:a2e:b003:: with SMTP id y3mr781826ljk.72.1562297285520; Thu, 04 Jul 2019 20:28:05 -0700 (PDT) MIME-Version: 1.0 References: <20190704195555.580363209@infradead.org> <20190704200050.534802824@infradead.org> <41D6F2E2-C4CF-41DF-A843-FCBD03B7BEEB@amacapital.net> In-Reply-To: <41D6F2E2-C4CF-41DF-A843-FCBD03B7BEEB@amacapital.net> From: Linus Torvalds Date: Fri, 5 Jul 2019 12:27:49 +0900 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 , Andrew Lutomirski , Peter Anvin , Dave Hansen , Juergen Gross , Linux List Kernel Mailing , He Zhe , Joel Fernandes , devel@etsukata.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 5, 2019 at 12:16 PM Andy Lutomirski wrote= : > > If nothing else, MOV to CR2 is architecturally serializing, so, unless th= ere=E2=80=99s some fancy unwinding involved, this will be quite slow. That's why the NMI code does this: if (unlikely(this_cpu_read(nmi_cr2) !=3D read_cr2())) write_cr2(this_cpu_read(nmi_cr2)); so that it normally only does a read. Only if you actually took a page fault will it restore cr2 to the old value (and if you took a page fault the performance issues will be _there_, not in the "restore cr2" part) Linus