Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4665801imu; Tue, 8 Jan 2019 04:17:24 -0800 (PST) X-Google-Smtp-Source: ALg8bN5znZIDTX2JjYO6j2cZp3G/4MJ1BFjl78ncKRgLTS0pWU4DFxlXFFyWVKVV467u7khAU7LO X-Received: by 2002:a17:902:1005:: with SMTP id b5mr1569896pla.310.1546949844131; Tue, 08 Jan 2019 04:17:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546949844; cv=none; d=google.com; s=arc-20160816; b=Xkrd6QcucDT7tJVI97unzm2uYX8TVsnMbQagLcHeZ0dyU516V+GgiLkM7pz15L898V rm8bqNVwMj5PYGAuMBuLPPgeTlCaRXAApU3o7IFqyDRezbSlAtpPFpPbIYLBzLZc7yOV rjgtvRRXVBzynSaddeObQINNsJih7MkNA9xdyB4YVJJKvbGM8ueZTcXNgMZumdWjjAS2 MtTVR8ojk11t21Gu3C0dN3d5yI7qE3s2ok4Ib4FDo9r/qc/NKiIdaBHhvap2LHydQAw/ Rm4S5wBXfnJZtND9TOxRomI1zwIXWxgpIA4ka/N+lYNQinzdlOhYs+cRieUM8Y6TJCy+ NEzg== 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; bh=3pg+uorl3D/nIt1GbO1PostZ3smTctEBT8SXUFXK8a4=; b=DLNxrscnILSEhdd+fbyARtwwxPvf2q66fOGxqaSSmLv1VV7H50V3sGLOEZrdrFq6Ig XvVx79FIzqejDKjI3bH4kfLYIL+GwF4AkEoHWOfnAyCqPHK/fVL2ZqpvzNibc1E5BR8v qVr2zSx5ue/YQud8yGmd8ciLNEm5IfwXH3AXYeIgav7JUdGGhX432RAAySTWWdcnashe Ylf3PhZOE0BCgIutA6dTN7joynRTExxznWczVpxYwLpmdN1wvMjqLxYThDJvsPmllIlr //nWK+uWTiqLsCo/iCL6ZgRe//4Xt/xB6y7gpdhAdvg1vBawdAm4UAHdpd4xnJW/TCyY cdpw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v4si45126703pfm.71.2019.01.08.04.17.08; Tue, 08 Jan 2019 04:17:24 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728972AbfAHMOq (ORCPT + 99 others); Tue, 8 Jan 2019 07:14:46 -0500 Received: from foss.arm.com ([217.140.101.70]:50010 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728857AbfAHMOp (ORCPT ); Tue, 8 Jan 2019 07:14:45 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1D0481596; Tue, 8 Jan 2019 04:14:45 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B61413F70D; Tue, 8 Jan 2019 04:14:43 -0800 (PST) Date: Tue, 8 Jan 2019 12:14:41 +0000 From: Mark Rutland To: Miles Chen Cc: Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, wsd_upstream@mediatek.com Subject: Re: [PATCH] arm64: trap illegal translations in __virt_to_phys() Message-ID: <20190108121440.GC29102@lakrids.cambridge.arm.com> References: <1546860080-13027-1-git-send-email-miles.chen@mediatek.com> <20190107150019.GC46743@lakrids.cambridge.arm.com> <1546917883.6754.8.camel@mtkswgap22> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1546917883.6754.8.camel@mtkswgap22> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 08, 2019 at 11:24:43AM +0800, Miles Chen wrote: > On Mon, 2019-01-07 at 15:00 +0000, Mark Rutland wrote: > > On Mon, Jan 07, 2019 at 07:21:20PM +0800, Miles Chen wrote: > > > Current __virt_to_phys() only print warning messages for non-linear > > > addresses. It's hard to catch all warnings by those messages. > > > > Why? Are you seeing a large number of warnings somewhere? > > Official kernel works fine. I saw some cases in our internal branch and > we're fixing them. > > > > > > So add a VIRTUAL_BUG_ON() to trap all non-linear and non-symbol > > > addresses (e.g., stack addresses) > > > > > > Tested by pass stack addresses and symbol addresses to __pa(). Result: > > > stack addresses: kernel BUG() > > > > Either: > > > > * Stacks are vmap'd, and __is_lm_address(stack_addr) is false. We'll > > produce a WARNING() today (and return a junk physical address). > > > > * Stacks are linear mapped, and cannot be distinguished from other > > linear mapped addresses. The physical address will be valid. > > > > ... so I don't understand why you need to change this. > > For the first case: for vmap'd stack, __pa() returns a junk > physical address and it might be easier to debug this incorrect address > translation by a BUG() call instead of monitoring the warning log. I think that's an argument for upgrading the existing WARN() to a BUG(), rather than adding a separate VIRTUAL_BUG_ON(). However, there are cases where the junk physical address is not used to perform an access, and the WARN() is more helpful. You can set panic_on_warn to get an immediate panic() when the WARN() fires. Is there some reason that approach doesn't work for you? Thanks, Mark.