Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp191509imu; Tue, 8 Jan 2019 17:36:48 -0800 (PST) X-Google-Smtp-Source: ALg8bN70G2I3xYJjVPJIpGKay6mVj0DBF8bAcMoiOB++SsvdQqsgdHEFA3F9V74s3m65qjK4so7t X-Received: by 2002:a17:902:6f09:: with SMTP id w9mr4156240plk.309.1546997808677; Tue, 08 Jan 2019 17:36:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546997808; cv=none; d=google.com; s=arc-20160816; b=l3wp4HW/9ns4ma3yzyEYP2VEw6bXxrxqmuRBs00u8VsoBVAsqdIy9Kx4az4LyBVbiJ 63uKzg0trZJqsUSSDf71oftoNRA5ZqFMGwK8a6r/SM+2iVsimOuimQXRQP0rt4BJU3eF /W4Vu59BrvCoE3dsJH8H7MtjQBwDJ8IZPJbPulugfglFXzq22j7ewRQxY2iD9cDvkSfG vFUSWwaQadbR5rGhV9akn4CqjF1rxZrcTSuUhVCcHu4aGMW8rQ5kwTxAX0IoP6qG2S+u xHy66c4S6IMn2yh7mxSFFtvN1VcpL1u/UWrHR73WHmbMZunuvGEilN2CfY61e62Y47xS l9fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:date:cc:to:from:subject:message-id; bh=bfqaVh34w9/j0rKHvwGsuvsDfdOGkNxhdqqh5S/clao=; b=u+NvhodKoIY8HT7lsBdcixo1YDVvWxsYhYDgN7k/AZ/oTaIRn0e45TYUxPxu9Ajwyb P/no+BQ+H4LpZ2LRt2KH2t6I1CvxhyyYMVPDFGsNei/7sPuwkVvwb/hYL23WedtVp456 VOA54QWomBhP6FjMP9qVwho8KX+9YpL9YGt9W3T0Kb6YsBwwvb8RADCpEheIiT9x/Rf/ KcfdXE+gbBaPEg50UNSH/4yhLyrYUcM9q9rvXGyso2Zj608N8xjxFhopUO35cEwxpU25 yWJxqIh2LV0yKAxvhnol5aUKdGrVRY4H9t8OnRowDDj6wP/OPRsO3SOR0dRxwfkTDiU1 nX/w== 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 i16si64622314pgk.445.2019.01.08.17.36.32; Tue, 08 Jan 2019 17:36:48 -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 S1729277AbfAIBf0 (ORCPT + 99 others); Tue, 8 Jan 2019 20:35:26 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:30801 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729067AbfAIBfZ (ORCPT ); Tue, 8 Jan 2019 20:35:25 -0500 X-UUID: 6270caafbefa46bdafaf1b4758890335-20190109 X-UUID: 6270caafbefa46bdafaf1b4758890335-20190109 Received: from mtkmrs01.mediatek.inc [(172.21.131.159)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 346372565; Wed, 09 Jan 2019 09:35:19 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 9 Jan 2019 09:35:17 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkcas07.mediatek.inc (172.21.101.84) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 9 Jan 2019 09:35:17 +0800 Received: from [172.21.77.33] (172.21.77.33) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 9 Jan 2019 09:35:17 +0800 Message-ID: <1546997717.20937.3.camel@mtkswgap22> Subject: Re: [PATCH] arm64: trap illegal translations in __virt_to_phys() From: Miles Chen To: Mark Rutland CC: Catalin Marinas , Will Deacon , , , , Date: Wed, 9 Jan 2019 09:35:17 +0800 In-Reply-To: <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> <20190108121440.GC29102@lakrids.cambridge.arm.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N X-TM-SNTS-SMTP: A3E3E476657A8AEA9A3F13BDF29E0B0E7871C13BB2A5D93DBCA9E749BAB92D162000:8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2019-01-08 at 12:14 +0000, Mark Rutland wrote: > 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. got it. > > 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? panic_on_warn works fine. thanks for your comment. cheers, Miles > > Thanks, > Mark.