Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4388230ybp; Mon, 7 Oct 2019 07:47:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4Ss4WgLZnO6RQb8R7Uo6bIdj3IgnBhufAmm+K8LEHnrvdwyRhVNe/v1k92OEMiyjNauHe X-Received: by 2002:a50:8a9a:: with SMTP id j26mr29481146edj.251.1570459628111; Mon, 07 Oct 2019 07:47:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570459628; cv=none; d=google.com; s=arc-20160816; b=JxMvw4gQhmknP/8FPdAxjjU0AZVverQjRFt1dz6b0L7ex8rfgXw4r/L20A/tXxqIhk 4J0sUIkkzAiGdhzfGN7wAjichDNvChSxTw7eddZxABmQ73jZ5xup2zTgfOWhGyvPolAb M6BOQ/A4duLtX4EiyA86oWIJaXyQE2RcIC7CHYSAeFvmH38cJ7FPyHdBkGfk2GR3e+Uq 2zmRzJ0+iwwLVmaYjSiA65sjhYQAKIUyXGXkP2rDFl/kHnzv+zRQCb7DH3nf8L3BvjcV UOfBq68Omau5esZo5Ux5T9TPe4chmTcFWPUkf625PRfM5cu5sP6jxSIA4JPLq7ZzZy5q xD8w== 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=PpPxy8fAMLPn9IHnNNOb8/HlXzEm8SFbpPhsOWCIm70=; b=zaAl3mWEDcygrLor2HiqdsYx6uWA1CyEPbseJZ2XnyeEd3ZIhTD0ZEArk4KBYDwIZs vLyM1VqfX0pbO0nJmZQocxMSic5ZdwUDp9GPbhLjhbarF2ZIld66D2V/7k32v/s34Nlk XPEFs6Kr6TTgRb2CKmXMyo8wDeySsHInPM4xgPrE+RDDCkv7JJE6iSMl4FuauJ9t2YII WwwT6TtuqQwC2t10PROUIGxSRw+j/66R6Y+TgNI7PrW7qn0Q+Ej73ZtuNBUfwxi1WAKq 579VJixNd6hESbyI1Ud0Hqm8kI0eEGrAkaCeEpvE5xfYoOyc6eqEeNvqJsyO6rQa6tAE fk3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=mDDOhpkJ; 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=fail (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 e14si8898068eda.104.2019.10.07.07.46.44; Mon, 07 Oct 2019 07:47:08 -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=fail header.i=@gmail.com header.s=20161025 header.b=mDDOhpkJ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728132AbfJGOo2 (ORCPT + 99 others); Mon, 7 Oct 2019 10:44:28 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:42775 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727490AbfJGOo1 (ORCPT ); Mon, 7 Oct 2019 10:44:27 -0400 Received: by mail-wr1-f65.google.com with SMTP id n14so15607335wrw.9 for ; Mon, 07 Oct 2019 07:44:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=PpPxy8fAMLPn9IHnNNOb8/HlXzEm8SFbpPhsOWCIm70=; b=mDDOhpkJKustOCnU2QXHxhnAUHg5CU3ynsH42eutOYAhbsg5954jl8uZ5c71QNALza 1VZE3Tpw99uE6Fm4UFOFAN/ZWyMr3QuP4gttX//k8MgsrU41rUG5MVqbE73a0gv/1rRZ e4uh581uCdy7f3i1dafvkUcxa1DP54dPjynokCQB6NHkgWiGL4CIYUkptnSns0Mft4SZ cdPMpkm5nqvQcRH85EMPAFaNrBny5bnB8fBXUD/8tDPXYN0gWq5FpVZPe/gJSUnZzXJd pa9Wzj6+s44n/vh+emOacm3K6djFZfz5UyzqV5iLO+hPzRMW0tY+ZUg8VoeB2CiOMCNo Wszg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=PpPxy8fAMLPn9IHnNNOb8/HlXzEm8SFbpPhsOWCIm70=; b=Wh4roxXfBuw0un37Q0giGjuPJ/gmp5CxlTn0bcn4B+mVMaSGJo2ay5ZVXIl2rEgYYi OpPbX1dK6fcHoJ/lr/+pqTq1ZXDOQbOwJdLbzeGVF9+RR+HzSfccD4ldJ/+0iNdiWSrF tmsI/rcq85Y9pwaKsHQwtnWhp3DVogscTIDiVcoCILq89l5TntdD13X3kcLio/cnEM36 XZ3C9YlWbRe8SHO5+NhTl9KP+EUnoM6uakkORNI3tAsGjLuQpfVlcvbZ19Z9fKX7wfaK xUsTMu0sKAZu1NaSsE8HaIhS9VdSrqxZKbmFkq9WrLdZQUzhUNBS6m+tu+5IkHrCfumz /nMg== X-Gm-Message-State: APjAAAX6R53gMVM/7W/MB0rnggcNauLZ2axhIuKOi0ZLH5/SqZ8tqJxF dw/jaA5qW+eags8EWFFDp5I= X-Received: by 2002:adf:f9c2:: with SMTP id w2mr2357241wrr.41.1570459465831; Mon, 07 Oct 2019 07:44:25 -0700 (PDT) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id q124sm26926115wma.5.2019.10.07.07.44.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 07:44:25 -0700 (PDT) Date: Mon, 7 Oct 2019 16:44:23 +0200 From: Ingo Molnar To: Sean Christopherson Cc: Dave Hansen , Changbin Du , Dave Hansen , Andy Lutomirski , x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/mm: determine whether the fault address is canonical Message-ID: <20191007144423.GA25181@gmail.com> References: <20191004134501.30651-1-changbin.du@gmail.com> <8b2c8164-d7ae-20b7-ff48-32eab9ec9760@intel.com> <20191004153115.GA19503@linux.intel.com> <20191007143255.GA59713@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191007143255.GA59713@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Ingo Molnar wrote: > > All the other reasons would require a fairly egregious kernel bug, hence > > the speculation that the #GP is due to a non-canonical address. Something > > like the following would be more precise, though highly unlikely to ever > > be exercised, e.g. KVM had a fatal bug related to injecting a non-zero > > error code that went unnoticed for years. > > > > WARN_ONCE(trapnr == X86_TRAP_GP, "General protection fault in user access. %s?\n", > > (IS_ENABLED(CONFIG_X86_64) && !error_code) ? "Non-canonical address" : > > "Segmentation bug"); > > Instead of trying to guess the reason of the #GPF (which guess might be > wrong), please just state it as the reason if we are sure that the cause > is a non-canonical address - and provide a best-guess if it's not but > clearly signal that it's a guess. > > I.e. if I understood all the cases correctly we'd have three types of > messages generated: > > !error_code: > "General protection fault in user access, due to non-canonical address." > > error_code && !is_canonical_addr(fault_addr): > "General protection fault in user access. Non-canonical address?" > > error_code && is_canonical_addr(fault_addr): > "General protection fault in user access. Segmentation bug?" Now that I've read the rest of the thread, since fault_addr is always 0 we can ignore most of this I suspect ... Thanks, Ingo