Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2590873imm; Wed, 16 May 2018 15:47:50 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoYfrxRAA3e9JU/zA4VeQyez7D4TlBDwON56S2fx4MTu5aRjY9B4qLEeeHRr4aq6P+IM7vv X-Received: by 2002:a63:784a:: with SMTP id t71-v6mr2205061pgc.382.1526510870057; Wed, 16 May 2018 15:47:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526510870; cv=none; d=google.com; s=arc-20160816; b=M0xS5jRm5WmL6bsKcSSrYCynvv6MpxpiCoMKEkJdEAAJ5NmXlWlRhAYmcSC1jJkVYG FT3C+TkmJn/cbRZxBBhznh/2DPNnhw9AGze1bf2a+TQF7FWrzmnyQzFL2i7bio5zWGxp VeR4MTu+1Vpgn2+Bb6qmQsnUqHp429I8vNNEyH6S/DRC9ki7OJvz0dOH/yYxm+FTVE6F TLF8x/DED3XH4JFx9P3IyMjBhhGGZclq+x6sKnW50d1AQIhjzs8LnPIchRmzjsRESa8Q Aa83dpsxjbQCIn9oVk9+3mjkE+jV90tv09o79W246lw1nSSPHGV7ZrFjsnnh4JfrTMrW cMhw== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=zeln/8mZmwmsEcdKmVcnnB3BMYXf0YUZX9u3nb8DauM=; b=zF78uZaYwOSedyXCklPLvhjdK4LjgaJgG3eXZM3kv1kyhQ9YlIBcBQ1P+AFhCcj+uR JC/pxiycwYEI6+tG9qdd6hklCbtJ406e9topuf3ExAMfuwE2dq+NiyfJ7leuPdZh6Nc6 UBOqNj6faU4J9S/FBsVh4zxgntzl2O0Hd9nejiQjYYHObFoA8O2+D+8uzmV67c9tngSB UfKxPw9oDN3TR7DHDh8pLUpZMcxdZSKj0hQUdtAEE4q1b2xUshYB/1PB4tmDvohC6NS4 F8QywbOcZdrOY9MEr18HjfpG3O4jYu6Fmkx0V85X4L5zStYtRWw5mmP7Wjnr/xmdyRDg lSqA== 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 127-v6si3794823pfe.49.2018.05.16.15.47.35; Wed, 16 May 2018 15:47:50 -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; 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 S1752171AbeEPWrB (ORCPT + 99 others); Wed, 16 May 2018 18:47:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:57524 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751880AbeEPWrA (ORCPT ); Wed, 16 May 2018 18:47:00 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C0423AAB2; Wed, 16 May 2018 22:46:58 +0000 (UTC) Date: Thu, 17 May 2018 00:46:41 +0200 From: Borislav Petkov To: Johannes Hirte , "Ghannam, Yazen" Cc: "linux-edac@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "tony.luck@intel.com" , "x86@kernel.org" Subject: Re: [PATCH 3/3] x86/MCE/AMD: Get address from already initialized block Message-ID: <20180516224641.GA31929@pd.tnic> References: <20180201184813.82253-1-Yazen.Ghannam@amd.com> <20180201184813.82253-3-Yazen.Ghannam@amd.com> <20180414004230.GA2033@probook> <20180416115624.GA1543@probook> <20180515093953.GA1746@probook> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180515093953.GA1746@probook> User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 15, 2018 at 11:39:54AM +0200, Johannes Hirte wrote: > The out-of-bound access happens in get_block_address: > > if (bankp && bankp->blocks) { > struct threshold_block *blockp blockp = &bankp->blocks[block]; > > with block=1. This doesn't exists. I don't even find any array here. > There is a linked list, created in allocate_threshold_blocks. On my > system I get 17 lists with one element each. Yes, what a mess this is. ;-\ There's no such thing as ->blocks[block] array. We assign simply the threshold_block to it in allocate_threshold_blocks: per_cpu(threshold_banks, cpu)[bank]->blocks = b; And I can't say the design of this thing is really friendly but it is still no excuse that I missed that during review. Grrr. So, Yazen, what really needs to happen here is to iterate the bank->blocks->miscj list to find the block you're looking for and return its address, the opposite to this here: if (per_cpu(threshold_banks, cpu)[bank]->blocks) { list_add(&b->miscj, &per_cpu(threshold_banks, cpu)[bank]->blocks->miscj); } else { per_cpu(threshold_banks, cpu)[bank]->blocks = b; } and don't forget to look at ->blocks itself. And then you need to make sure that searching for block addresses still works when resuming from suspend so that you can avoid the RDMSR IPIs. Ok? -- Regards/Gruss, Boris. SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) --