Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp949715img; Fri, 22 Mar 2019 12:06:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqw70Ka2z+GMSwsea+clm7uIC6hBALsMoDrtQQywng38zjtsMSZl5TzMbBfOXMO51+Qaw7Zr X-Received: by 2002:a63:525f:: with SMTP id s31mr9052019pgl.172.1553281581110; Fri, 22 Mar 2019 12:06:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553281581; cv=none; d=google.com; s=arc-20160816; b=reyCp/83b8eUzoxupcwD6E+XMWV0El98d1J2lY8BxbMlD+0SYI97tlGLJs7LPE4b6y /t4AFHG8UFXggNLEUYx0IftIuPeBWsphBprRuv7LLQ/RK2Lilj4xJKq3mvMQRBgpZLQV x3GVmBKpPQ79Ge9SaiMwGjWFAWgZrb9ZkrEdlVBIbNc7ytC+uWJSDphBHSROItBBBth0 vRwjRP1lOSP0m1O33ccbA8j3Hi8g2O+5EuGyri4o/t1TGH8TRzUlSkWoOl8JiuUEK3BK QRAA/GfVfwg22+dPN4qp5mTHNDycuu1HViTPza2YrDf8wsNX6rhg9s7johp+MqmQ6VoD QzBw== 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=GuGeYXYMxPj1xf5ZZS06FwRXke7aLba1dEUVGe11Odc=; b=iPBlWc0tJ2fvPLRe1yRTLPW5IfrI70ml0buiwom0UA8+sCZxq5aob70xxBjkDTy6/d ciLakzJEy8ueNs5BNkkKUfXgyXHK17sCGUZMfLduWiiPXHJ8cN33csmhOZjotX4IJzgG uDsKBcxLj+W2P+0zp3F06+0bWFibotWka4jHyDJD0ITK/4cFll+qCjtHNCeP4eByaGed LyWuxuaCvFuvPA7QVPzM9fUJqSldV2T+kvAp1kcrI95ajOiWJcKWREL7b8D7tXzLq/0x LVIW3Eax37ZUjKb7/CNqpeglPbtHad/YmTzGMLdc/205H75oMCaVHt7kD5OrE6Df6K8d oyXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=C3NL5OAZ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g35si7274077pgm.540.2019.03.22.12.06.02; Fri, 22 Mar 2019 12:06: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=@google.com header.s=20161025 header.b=C3NL5OAZ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727688AbfCVTFJ (ORCPT + 99 others); Fri, 22 Mar 2019 15:05:09 -0400 Received: from mail-vs1-f68.google.com ([209.85.217.68]:33757 "EHLO mail-vs1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725781AbfCVTFJ (ORCPT ); Fri, 22 Mar 2019 15:05:09 -0400 Received: by mail-vs1-f68.google.com with SMTP id z6so2004772vsc.0 for ; Fri, 22 Mar 2019 12:05:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GuGeYXYMxPj1xf5ZZS06FwRXke7aLba1dEUVGe11Odc=; b=C3NL5OAZV4Kwj1I3rcIL7w++E99EMJ2BemYTOZfSlJWRilxLJgnYyKpc/WJXnywa+R +o4y/z+fxNHoBFH+ee9GNF1FemPEgr/KP8FeSvhZNxvHR7pZzLlmUYtJplDMc426p6jT n1ZOjCQu+ChmL6ELTd6sMVfgepveVeCuSNGmrKUwN1RQmbfgqnB47p6HJEdKiP52HgKu cjJQIfClJRJUj1jskv2mnYdtqkiaLGuN7cTb2xU8aGPaKeLcFNNqiFYEOk5h3BcXZBBB J+555EhC4G5b6f18EGJruwHlLLo1KzEDVVvby4YYd+WngKFi3huzy3LzFWqK2uCmPpH1 PyFQ== 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; bh=GuGeYXYMxPj1xf5ZZS06FwRXke7aLba1dEUVGe11Odc=; b=Qg9HOZ+L3lgGkdyE8ABYaBAdqJegxdgiQD8D4aAbx+z8bVB1fx3mcLl2O0HZv+QfUV lfQwPcSYP/vyG2JxPJ/X3KEl6MJp9/IN6znayH6+IevkpACrh0GXxM1z3eYzsQurZiuC GKkx0fMiQJlR/7Py7VS7iRBbAcOCJTY7GyJjpskBtAzqV8O5ZQgGszkwGHQFTmbS7KjF tFYbUwk/z/iCWYVrRWEO6kvF4nlYh9YbUiBw5njV6GD/nQCBPDPjjymH1wHdfzMDE8At iLyWn0HL5ZEBYwpCl1ga5n1UxrDjKL+9ULPsAWBuwqgK/D3jnQMvJT/PI5D0aNI6ciBJ K3Dw== X-Gm-Message-State: APjAAAX6bKLWI456PmbmRQa8B/va7h53JE3/GdkWHygT2lu86pdaX7ic ewgUokMW1hYuyy2/Ka+kSsh9zCBYSqUVqK5PD7b4cw== X-Received: by 2002:a67:e9cc:: with SMTP id q12mr7026549vso.208.1553281507110; Fri, 22 Mar 2019 12:05:07 -0700 (PDT) MIME-Version: 1.0 References: <20190314130113.919278615@infradead.org> <20190314130705.441549378@infradead.org> <20190319110549.GC5996@hirez.programming.kicks-ass.net> <20190319182041.GO5996@hirez.programming.kicks-ass.net> <20190320222220.GA2490@worktop.programming.kicks-ass.net> <20190321123849.GN6521@hirez.programming.kicks-ass.net> In-Reply-To: From: Stephane Eranian Date: Fri, 22 Mar 2019 12:04:55 -0700 Message-ID: Subject: Re: [PATCH 1/8] perf/x86/intel: Fix memory corruption To: Thomas Gleixner Cc: Peter Zijlstra , Ingo Molnar , Jiri Olsa , LKML , tonyj@suse.com, nelson.dsouza@intel.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, Mar 21, 2019 at 10:51 AM Thomas Gleixner wrote: > > On Thu, 21 Mar 2019, Stephane Eranian wrote: > > On Thu, Mar 21, 2019 at 9:45 AM Thomas Gleixner wrote: > > > > > > On Thu, 21 Mar 2019, Peter Zijlstra wrote: > > > > Subject: perf/x86/intel: Initialize TFA MSR > > > > > > > > Stephane reported that we don't initialize the TFA MSR, which could lead > > > > to trouble if the RESET value is not 0 or on kexec. > > > > > > That sentence doesn't parse. > > > > > > Stephane reported that the TFA MSR is not initialized by the kernel, but > > > the TFA bit could set by firmware or as a leftover from a kexec, which > > > makes the state inconsistent. > > > > > Correct. This is what I meant. > > The issue is what does the kernel guarantee when it boots? > > > > I see: > > static bool allow_tsx_force_abort = true; > > > > Therefore you must ensure the MSR is set to reflect that state on boot. > > So you have to force it to that value to be in sync which is what your > > new patch is doing. > > The initial state should be that the MSR TFA bit is 0. The software state > is a different beast. > > allow_tsx_force_abort > > false Do not set MSR TFA bit (Make TSX work with PMC3) and > exclude PMC3 from being used. > > true Set the MSR TFA bit when PMC3 is used by perf, clear it > when PMC3 is not longer in use. > I would expect this description to be included in the source code where the allow_tsx_force_abort variable is defined and somewhere in the kernel Documentation because it is not trivial to understand what the control actually does and the guarantees you have when you toggle it. > Now, if the firmware or the kexec has the TFA bit set in the MSR and PMC3 > is not in use then TSX always aborts pointlessly. It's not a fatal isseu, > but it's inconsistent. > > So independent of the state of allow_tsx_force_abort the kernel has to > clear the MSR TSA bit when the CPUs are brought up. > > The state of allow_tsx_force_abort is solely relevant after CPUs coming up > to decide whether PMC3 can be used by perf or not. > > Thanks, > > tglx >