Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp444738ybm; Thu, 28 May 2020 06:53:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsz3EBrbMNlXcs32fgt4DVvqA8z9pfao9FvNLgI9f9YLlCq+XZa1KMuHTfbIu/B/SvZG8E X-Received: by 2002:a17:906:48ce:: with SMTP id d14mr3424075ejt.468.1590674020328; Thu, 28 May 2020 06:53:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590674020; cv=none; d=google.com; s=arc-20160816; b=e8Oc3zueCZlAW3HSRgtGj9JMCsPO1/jZndnCX1bA35D8a0s7gmBiqp6GJC47rY8jkO ibn64JwC3XD4gE10XBzXBh8FPSwWCeYCLC7vJdp5XIH5g7uV0wCBsCF62bzkipjRnAVT OiYgER3XBhjGW9Xwc//dTLR2AUMTDkkjBr2+OlczMQhz4IGeayD2YOXCJUOrq7Nk4pmY fB74JsMYn1zH17pakt+GFBN8POpGJ/O0aJD5MWWTkvYTJuGK8HMIP7s6W2MCsJc51Odc u9qW7IK8POEafnjf6emvQcVu59aUUVSIN71ZjALtxfI7tmj35Mb7Xwc28HIhF3hbnx5k ekcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=AHpPLCFHPXhhfLo5CCKKqEyOgFhcW4TuprwsOW8yS2Q=; b=N0LUkpOnPZsKcm0R9hsRFGU2KH3VMAAc2vWeq/Hzp/acF79n+SGCsi8OWBguPHrikB wh/FwEla/+DbBEdBbe6prrpzJv4n0q1R8kk843JPYRrCurEw7n/xOU/FlFusqRw6rU1X M3C/K+XU+ffOtQixc/8UG0iYR/4OBNuJH6q8y0Pt5tg/inJLq4NAWMEOunULZPOl4p86 R/aSFR8mAXLZ/FjUowjqNfumwKfHhxpIVyQz5T5IeT2bDZt/bgkYBXDGU2zN6NHAQZUo apYh8wa/WknD2Z4JfTEtvqXbjETqtgHQzNWaLVSdbtUmseeZQ9YE8W0E/QvDFblemIC4 IpOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r1si3968640ejs.406.2020.05.28.06.53.17; Thu, 28 May 2020 06:53:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390583AbgE1NtU (ORCPT + 99 others); Thu, 28 May 2020 09:49:20 -0400 Received: from mga18.intel.com ([134.134.136.126]:54810 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390538AbgE1NtT (ORCPT ); Thu, 28 May 2020 09:49:19 -0400 IronPort-SDR: uLsYf4l7ip9LRWgVbFby9B4rvDC6A/ym5wCOfkodI7r3fc42hRLBbdOlNHSOhac3p3BJKECHwV O35QA3iTDwxw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 06:49:18 -0700 IronPort-SDR: 7PtZOYa/KJHSLJqDQs9bszImv8C6YZzwCdFnCN4Mo/rdidXyrdGfN4dENeAetGqtVQ9/Al4Tcj gY7mE9YzvK1w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,444,1583222400"; d="scan'208";a="376373987" Received: from linux.intel.com ([10.54.29.200]) by fmsmga001.fm.intel.com with ESMTP; 28 May 2020 06:49:18 -0700 Received: from [10.251.9.11] (kliang2-mobl.ccr.corp.intel.com [10.251.9.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id A32185803E3; Thu, 28 May 2020 06:49:17 -0700 (PDT) Subject: Re: [PATCH V2 3/3] perf/x86/intel/uncore: Validate MMIO address before accessing To: David Laight , "peterz@infradead.org" , "mingo@redhat.com" , "linux-kernel@vger.kernel.org" Cc: "ak@linux.intel.com" References: <1590671727-99311-1-git-send-email-kan.liang@linux.intel.com> <1590671727-99311-3-git-send-email-kan.liang@linux.intel.com> From: "Liang, Kan" Message-ID: <79403443-e893-da26-ee6d-1fd7f252bbfe@linux.intel.com> Date: Thu, 28 May 2020 09:49:16 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/28/2020 9:33 AM, David Laight wrote: > From: kan.liang@linux.intel.com >> Sent: 28 May 2020 14:15 > ... >> +static inline bool is_valid_mmio_offset(struct intel_uncore_box *box, >> + unsigned long offset) > > You need a better name, needs to start 'uncore_' and 'mmio' > probably isn't right either. > Sure >> +{ >> + if (box->pmu->type->mmio_map_size > offset) >> + return true; > > Swap over. > Conditionals always read best if 'variable op constant'. > So you want: > if (offset < box->pmu->type->mmio_map_size) > return true; > Sure >> + >> + pr_warn_once("perf uncore: Access invalid address of %s.\n", >> + box->pmu->type->name); > > Pretty hard to debug without the invalid offset. > I will dump the box->io_addr and offset for debugging. Thanks, Kan > I've no idea what the code is supposed to be doing though. > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales) >