Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp11078494imu; Thu, 6 Dec 2018 11:10:04 -0800 (PST) X-Google-Smtp-Source: AFSGD/V8Bdka0A+WGkCW+Nqf/HqsTO2fmDwoYBot/vYPxLMbLXer8ZnSzaIdHLK+jq/qn1cFyJfS X-Received: by 2002:a63:2263:: with SMTP id t35mr25116199pgm.69.1544123404767; Thu, 06 Dec 2018 11:10:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544123404; cv=none; d=google.com; s=arc-20160816; b=Z1gGkEjcuLxGlvHdX56Ol4xe/NXSlYxrSCQtMaJenfq8aQK5ZPUs7Sga3C+2qfagI6 T3w7uA8FpIt4oq0gQsBef8WwT9adB6he+mQf/p6Hh7N7iHko50AVLc8iL1oQjbX0JJwo QNPcRhpIMLlNwI6Lafv0K0JsGisyFYdigmVXA0I/9oBSBhJSjqhbv7j5w9Oml3zjbtn3 626lnX8NUm3nPy86m8DbJE4CBT/M7y2+dI4lafNCWtB+NsahtIuXE9bvpuhi2l2SAh1M ED4EeA1nTkcO0y3e8FWKnZ19vMeJnVNLEvf+EBSJTLvSqM9RAbFkbUQqF1exm5L0NZxT oBqA== 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=8NrIpyQbpUt8iW2pmvQ6edlPDYd31Aem+wibxt36PU8=; b=0M1us1PN3hO+t0Mdu60ATwyM4humbG6qAtY81TzBOkDm8LmXn85YcRtGkCMyNZ97Xz D7n5DC1XukMQVXe3O1bdVHwXD6hIqbWRwZhyOBMmD/Ai3zfmOpu0pxNcpUjfD+5/IJPI f8WpDx0wK8dJMyZ7ec/IlaWh2cVtVRZVapwJT5o2TLDscYTze9IzBpUR3Mvvqt6Bbpov g3BJL12hCCGe7efX9ZHE60Kq8S4KAnzfN4625hD20cH2L2Rgl6slMzfhX3v3stmSncV9 LrVUk40fFSfLu+1XFw4Q5c4Mwqcg+rB/TpJns9fHkT5ereB/tgglYDWti1S7bysW6EFp Xgqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=feRJW+RK; 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 q7si925674pfa.99.2018.12.06.11.09.29; Thu, 06 Dec 2018 11:10:04 -0800 (PST) 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=feRJW+RK; 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 S1725948AbeLFTHF (ORCPT + 99 others); Thu, 6 Dec 2018 14:07:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:40508 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725916AbeLFTHE (ORCPT ); Thu, 6 Dec 2018 14:07:04 -0500 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 B1EBA214DE for ; Thu, 6 Dec 2018 19:07:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544123224; bh=PZfFQHgPhfnrQsoGI+ugTruNtJFLmEKXux5V5+SUkEI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=feRJW+RKIiuvTM8LyY7Cd1bQVB73mu6YH0Wa4IslQGjJM313SpRyezF626CqpqMEJ K/WG9E8tj4u65q7RbL67oysTVsI40mKZ7gzGCOaXFdkziQlmPhZpEInvhJ9uZJTcDR fymqQ+v1lqSjD2BwaLHLwPaWoN48O/P+vDyfwpOE= Received: by mail-wm1-f51.google.com with SMTP id a18so2213504wmj.1 for ; Thu, 06 Dec 2018 11:07:03 -0800 (PST) X-Gm-Message-State: AA+aEWZlQloS4BlWtXe2yBGynSsolMvkivEG5RxxtCL/GYOXDHv0cluk XLpHvmQyRUDtiwOUo7lBkMtoM3a8xFSJbPeEXMuQsw== X-Received: by 2002:a1c:b1d5:: with SMTP id a204mr21646562wmf.32.1544123222198; Thu, 06 Dec 2018 11:07:02 -0800 (PST) MIME-Version: 1.0 References: <20181205163624.1842-1-sean.j.christopherson@intel.com> <20181206073409.GA64887@gmail.com> In-Reply-To: From: Andy Lutomirski Date: Thu, 6 Dec 2018 11:06:50 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] x86/mm/fault: Streamline the fault error_code decoder some more To: Linus Torvalds Cc: Ingo Molnar , "Christopherson, Sean J" , Dave Hansen , Andrew Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , X86 ML , "H. Peter Anvin" , LKML , Rik van Riel , Yu-cheng Yu Content-Type: multipart/mixed; boundary="000000000000264e69057c5f34f1" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --000000000000264e69057c5f34f1 Content-Type: text/plain; charset="UTF-8" On Thu, Dec 6, 2018 at 10:15 AM Linus Torvalds wrote: > > On Wed, Dec 5, 2018 at 11:34 PM Ingo Molnar wrote: > > > > Yeah, so I don't like the overly long 'SUPERVISOR' and the somewhat > > inconsistent, sporadic handling of negatives. Here's our error code bits: > > > > /* > > * Page fault error code bits: > > * > > * bit 0 == 0: no page found 1: protection fault > > * bit 1 == 0: read access 1: write access > > * bit 2 == 0: kernel-mode access 1: user-mode access > > No. Really not at all. > > Bit 2 is *not* "kernel vs user". Never has been. Never will be. > > It's a single bit that mixes up *three* different cases: > > - regular user mode access (value: 1) > > - regular CPL0 access (value: 0) > > - CPU system access (value: 0) > > and that third case really is important and relevant. And importantly, > it can happen from user space. > > In fact, these days we possibly have a fourth case: > > - kernel access using wruss (value: 1) Indeed. > > and I'd rather see just the numbers (which you have to know to decode) > than see the simplified AND WRONG decoding of those numbers. That's why the very next line in the OOPS explains this. > > Please don't ever confuse the fault U/S bit with "user vs kernel". > It's just not true, and people should be very very aware of it now > being true. > > If you care whether a page fault happened in user mode or not, you > have to look at the register state (ie "user_mode(regs)"). The code we're arguing over was part of a patch set to fix this confusion in the page fault code for real. > > Please call the U/S bit something else than "user" or "kernel". Dunno. I kind of like following the SDM. How do you like the attached patch? --000000000000264e69057c5f34f1 Content-Type: text/x-patch; charset="US-ASCII"; name="fault.patch" Content-Disposition: attachment; filename="fault.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_jpcz31rf0 ZGlmZiAtLWdpdCBhL2FyY2gveDg2L21tL2ZhdWx0LmMgYi9hcmNoL3g4Ni9tbS9mYXVsdC5jCmlu ZGV4IDJmZjI1YWQzMzIzMy4uZjFmOWUxOTY0NmY1IDEwMDY0NAotLS0gYS9hcmNoL3g4Ni9tbS9m YXVsdC5jCisrKyBiL2FyY2gveDg2L21tL2ZhdWx0LmMKQEAgLTYxMCw4ICs2MTAsNyBAQCBzdGF0 aWMgdm9pZCBzaG93X2xkdHRzcyhjb25zdCBzdHJ1Y3QgZGVzY19wdHIgKmdkdCwgY29uc3QgY2hh ciAqbmFtZSwgdTE2IGluZGV4KQogc3RhdGljIHZvaWQgZXJyX3N0cl9hcHBlbmQodW5zaWduZWQg bG9uZyBlcnJvcl9jb2RlLCBjaGFyICpidWYsIHVuc2lnbmVkIGx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