Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2739961ybp; Sat, 5 Oct 2019 19:32:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgBuaK5c/kVVwB6uiTHuUIzJ14Tw83Gh7QZr0sr2+G9cNtYZpMNZLrI76eNf0MU2lLc56f X-Received: by 2002:a50:d718:: with SMTP id t24mr22544650edi.168.1570329178414; Sat, 05 Oct 2019 19:32:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570329178; cv=none; d=google.com; s=arc-20160816; b=QcgrLS1nrakDxex6plrCxBpd1XCWQzc+z62DM+j2x1NMHfniCtc+Sk1GA1zOkIH/no sOL81bzxgWuE3+IIF2JBlXrmLr7GAgHoz9UlMwGldhJBWlf4AXz7jJjzNOpArlDQ04HO C8zsUoB/gCuhE6ITlqIGaoSoAdArUWvNhoO2FtDIoAuSp/wugv6MDOOktXXE7nk75i2B j1MlM4BaWovH/m1WNxWclWBraBWaA/5beZKHXNbZf1aXztxfqhiOyqcf22ewnuBvaItQ 6bmj6ESPYr6x2zaQDGSofRSd601dAghJUy2jfy0INSQXyH3KOIHpHU5JKBHNcpn4fwxS H5FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=YGXf9idAJ+CJ9q4yeCvmnDfU8PF8I7CxRLbmXUnGvaE=; b=RDuOnv2uU3MCFUL+o8rJ1uCYFaiJGEYPg5aSmTebmgEiLpQkTyDxgmekHcEoUx3kmF yU8hmIy9V2ziPsYuy8/ulRFKtNu683POUbFL2sLXXXk/sAcrFgrxZW5KNfTd4QP1xArr 0ulyIl67uqEpptysnADmRHF+1G8+jzqof2G9AfjXsjlm0c6keEp21pgnU4+aPODvySuY F3/CGNVJ6h5FPIk1xaTo0T0tK294IptF3pq1ed1z7jGgmAMtmKYUW051PeWzfxsxvfPP hluq4i3g4IIgoOhOPGmnDZyoC5s33K8yjT/QqGpwUYHRgwRNeCql4M0najC6sNWF0fMf 5qgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bXbR5lRl; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r10si5965966edh.358.2019.10.05.19.32.34; Sat, 05 Oct 2019 19:32:58 -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=@gmail.com header.s=20161025 header.b=bXbR5lRl; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726109AbfJFC3x (ORCPT + 99 others); Sat, 5 Oct 2019 22:29:53 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46167 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725919AbfJFC3w (ORCPT ); Sat, 5 Oct 2019 22:29:52 -0400 Received: by mail-wr1-f66.google.com with SMTP id o18so11203836wrv.13 for ; Sat, 05 Oct 2019 19:29:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=YGXf9idAJ+CJ9q4yeCvmnDfU8PF8I7CxRLbmXUnGvaE=; b=bXbR5lRlZwWTXVwvK015DgZNC+gXgMsDlm5stxRvBjFYfgSjZrLk1/gDpV5MWxUr4V foOM8irTZsUCyvzu7zQaH5tnxXU7lbho45WPbYYlJOZ12WnBymVvmCfVWU4gRJ6wsnoz toLpbD5R53JK/imQA6T4vwVRqF5FhgLSnwSBLii8itUaBoYiVJtIh8ytJNbNi87k16f/ lrZsfLFqg0Y3OEV7sisBz3AIg9+hKLKYfX6AZ+UhzM5F2ohQKK4jii7OStNX6WNSi1HR gyOAVTAEspNzDwu+TqI1JElFNIo6ZXsqlB6svs2rbqEa0Bj7ZPpDVXWAXKFjJTpcNNfC GIOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=YGXf9idAJ+CJ9q4yeCvmnDfU8PF8I7CxRLbmXUnGvaE=; b=EN8Te1fTOAy0YtZD9NphBEtAOJoEvXfhfhkRS8+RsgCLPkJQ2rzoc2ii0y28KbgsVq lqwlAvhJVMRbBSMUxqdgU7RuuoiI5kt8lTMcZzQqukuRKHpzy38vCpIJjAb60mr7aw2p g+4M5aFjZamOF65OZgUK+4GB8mom3R331fq+RVlEY1rVA1zoq7IA2E0H4hnbluFC14hF k4Tkd/nCZuqSpONT/y9yK0HnklexkfXOd6eHmcDIHkGQJ163Nk9dR7PNwnyqfzXkq1Mn yed7e1ZiqmVbGdr6Woh68yr/oyXQ2xcuGKGz4Wwd0MnpOWsAOtZ1l9lnyQf6Tsv3np84 HeHw== X-Gm-Message-State: APjAAAWcGd4KizRmULE/da1CKkBW3JW6KmoztCZiZThml/7tsTfRwMNB 7iJM8dsl5yPAMcKwBq/D4jU= X-Received: by 2002:a5d:4d4f:: with SMTP id a15mr17546051wru.267.1570328990269; Sat, 05 Oct 2019 19:29:50 -0700 (PDT) Received: from mail.google.com ([104.238.174.53]) by smtp.gmail.com with ESMTPSA id w3sm828162wru.5.2019.10.05.19.29.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2019 19:29:49 -0700 (PDT) Date: Sun, 6 Oct 2019 10:29:43 +0800 From: Changbin Du To: Dave Hansen Cc: Andy Lutomirski , Changbin Du , Dave Hansen , X86 ML , LKML Subject: Re: [PATCH] x86/mm: determine whether the fault address is canonical Message-ID: <20191006022941.pvwldrjyhl4z5inu@mail.google.com> References: <20191004134501.30651-1-changbin.du@gmail.com> <2d078dbc-73ca-0868-71f8-16e413ebdbf4@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2d078dbc-73ca-0868-71f8-16e413ebdbf4@intel.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 04, 2019 at 08:14:25AM -0700, Dave Hansen wrote: > On 10/4/19 7:59 AM, Andy Lutomirski wrote: > >> @@ -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. > > For #GP, we do: > > do_general_protection(struct pt_regs *regs, long error_code) > { > ... > if (!user_mode(regs)) { > if (fixup_exception(regs, X86_TRAP_GP, error_code, 0)) > return; > > Where the 0 is 'fault_addr'. I'm not sure any other way that > ex_handler_uaccess() can get called with trapnr == X86_TRAP_GP. 0 is > canonical last I checked, which would make this patch a bit academic. :) My fault. I thought the 'fault_addr' is filled with a valid value. So we really don't know the answer without decoding the instruction which causes this #GP. :) -- Cheers, Changbin Du