Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp986980ybp; Fri, 4 Oct 2019 08:00:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqy895K/NJkHctq6QOntTl0UoSQrUBpP3Hseh9om88xPVlDFq20wtVs7KWPKxTP3uZYcPNqL X-Received: by 2002:aa7:cdd6:: with SMTP id h22mr15924172edw.132.1570201207658; Fri, 04 Oct 2019 08:00:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570201207; cv=none; d=google.com; s=arc-20160816; b=Of+d6kE4pCPa0o2diAJx8WKOLQbOR00cD0arM7L8MjXBlN1YO+fC4ivFDfZ2ZGf4ce PQ2651ymKxpaEdM44p8Iww9birbkPArWv15rtCEsZ0kfP2c5SFiEy4MI3ImiuHoWqeCe B2A7fawK5L7s7bxjKfjvCKevGIWk5IIzRel/ULS3b2gefvDanMDsJxIWnhklhfIutYhx 2qQtMPRYHQxp+u4+ScwkLINlLjGZBviV0XObUi0zAmp/QvmpFAp30zeXcP0Ub8dSSxdF /3DRl/DFme1nU1xkyThrZlWwebgEFgR/U3qF0OWZEs7GHK+fo6/MgxZwZSBO5WrugTtF DEsg== 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=Js8Wa57MD2nfsPb5Po/QzFIqfoKNw8ptsi0aBfWX4is=; b=Bfc8nT+0HGVCYLLoDsZohlBH1PnINizMR0HYkTfGBZGfFsL+uP4Go76cIKmUcZXRZe N3l1/PUbF4uw1l+rwWRD6X3oOt5UY9xzCyC8FGCoRKIjy9L2QxLf7EoFDwbeQjocTfhI xjWEQz67OBPyCMHKXktJvjK5o8otdytVYvCeTS5Wvm8Ut6/ucTRtPUlh8Sq3sgKJv7Fe K9qyetBSCGWR9vOU+BvnafjXsuaVqFY5ahchjqq9uMJaUGiPEkD47bU5LgyTegFPoPfW 3P/JP4Cy/y6PpSjOHPtX5MuA8ikrkD/ZGFp/ErfpsUWol2dyyOgOuP/gUSrJYlNGlmHe 27fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DFpBrok+; 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 i12si3083745ejj.119.2019.10.04.07.59.43; Fri, 04 Oct 2019 08:00:07 -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=DFpBrok+; 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 S2389510AbfJDO7O (ORCPT + 99 others); Fri, 4 Oct 2019 10:59:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:48018 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389131AbfJDO7O (ORCPT ); Fri, 4 Oct 2019 10:59:14 -0400 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 5D9DD222C2 for ; Fri, 4 Oct 2019 14:59:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570201153; bh=qygk6kuolBy5BE+vN0iXiRBRAGyd2GOtM73uWd/QIVo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=DFpBrok+h7gMPfvyWty9YFwtn8fH5NTETRQm2W4h+BRXGah0gjMkQDB3n1qaNZDqx 6iHyg/6Rx+49eWX8VBlUPrq86xlgX9F4Ha2Q7eAM5ODiEC3CU8N5jbkAfz2RIYlKoY 7v4HZKARI3/Tmyzcyn8AMZ3/pFW5qPrRomXCudr4= Received: by mail-wr1-f43.google.com with SMTP id o18so7568334wrv.13 for ; Fri, 04 Oct 2019 07:59:13 -0700 (PDT) X-Gm-Message-State: APjAAAWwgVPWqpJWHDtnXVsNk/4VxrFKRt89olbkEETgpOkxUw65M4d/ 3mXEkIYe3aKTF3HQdOT4iR3ibRqUPAtdtZlZTm1Y0Q== X-Received: by 2002:adf:cc0a:: with SMTP id x10mr8206649wrh.195.1570201151831; Fri, 04 Oct 2019 07:59:11 -0700 (PDT) MIME-Version: 1.0 References: <20191004134501.30651-1-changbin.du@gmail.com> In-Reply-To: <20191004134501.30651-1-changbin.du@gmail.com> From: Andy Lutomirski Date: Fri, 4 Oct 2019 07:59:00 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] x86/mm: determine whether the fault address is canonical To: Changbin Du Cc: Dave Hansen , Andy Lutomirski , X86 ML , LKML 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 Fri, Oct 4, 2019 at 6:45 AM Changbin Du wrote: > > We know the answer, so don't ask the user. > > Signed-off-by: Changbin Du > --- > arch/x86/mm/extable.c | 5 ++++- > arch/x86/mm/mm_internal.h | 11 +++++++++++ > 2 files changed, 15 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c > index 4d75bc656f97..5196e586756f 100644 > --- a/arch/x86/mm/extable.c > +++ b/arch/x86/mm/extable.c > @@ -8,6 +8,8 @@ > #include > #include > > +#include "mm_internal.h" > + > typedef bool (*ex_handler_t)(const struct exception_table_entry *, > struct pt_regs *, int, unsigned long, > unsigned long); > @@ -123,7 +125,8 @@ __visible bool ex_handler_uaccess(const struct exception_table_entry *fixup, > unsigned long error_code, > unsigned long fault_addr) > { > - WARN_ONCE(trapnr == X86_TRAP_GP, "General protection fault in user access. Non-canonical address?"); > + WARN_ONCE(trapnr == X86_TRAP_GP, "General protection fault at %s address in user access.", > + is_canonical_addr(fault_addr) ? "canonical" : "non-canonical"); Unless the hardware behaves rather differently from the way I think it does, fault_addr is garbage for anything other than #PF and sometimes for #DF. (And maybe the virtualization faults?) I don't believe that #GP fills in CR2.