Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2926292imm; Wed, 16 May 2018 23:51:58 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqH30btysxyUNCHcj38XifE24G4Yut5ULrNOGPvPq62K02ecT/KixMeFP+geZbg3HVs5jb8 X-Received: by 2002:a17:902:8602:: with SMTP id f2-v6mr4010350plo.5.1526539918585; Wed, 16 May 2018 23:51:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526539918; cv=none; d=google.com; s=arc-20160816; b=utzdy4ODWmd65L0+OZOggvxpSyQhCLec8ZcanUWinfDau24mikRZ9zcw2CDVeD4D0R i63Qf3jsB1gxpFSQghZ5oGmujxZg859rw5PeFK7xD9MtyeYqsbP9tUYStoK1vGcuTGpR f5PnWkuWQeZbUSUQVldydgrP31LNg55pBsREZiHV4mYiq40owD1BwQuNO4rAjv211UHz Z1OV3vclkIRjzEC4TMCuZEhJunaHjeJbZ4eU3gm4psMO5PzBzpnSyUxVZ8fy0yOdCkow pBRA5OqO+/+PbFB9aUmm/Fq82b1SMH2GkCnpyd3ujOzSmbxwVEWh1i1sGWsZFg5WTLe2 x+zw== 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:arc-authentication-results; bh=DggMwL4W/wRPpoWRPTW1a+pKDk6ugQjgKqN8CsfGMwQ=; b=oS0xs821jRMmcIpaJMNI0sOOftx+vpUd+yhRICxOwcrTlEiSak0gBdBokB+v6Ahj7r 3mXIRyf93hcTWlDkripA2TwJfE6maCCwhLjVwyGY2S/gPni4zDigjdYnzH0y7b1peYJP oE8F7n3SJPYENMwuMAF9hvm8gsIC1ofG8h844yOJAcF6Ht2Ab8mStSAqiKHtQxgr6f2S oK4NFC/i7MUwIHB6DTaB6QCKWDXbE8Txx9lBoJlDFUl4cmSQKYpfvgF9ymLf4AYBYfL4 OU7KAUxu+VXNF8VGw7b+25S59g+LdGXxrpWP377Ts3/BOf25CQ2JIXjg2y8rizIvtr8Z STcw== 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 s36-v6si4243315pld.114.2018.05.16.23.51.44; Wed, 16 May 2018 23:51:58 -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 S1752441AbeEQGtm (ORCPT + 99 others); Thu, 17 May 2018 02:49:42 -0400 Received: from freki.datenkhaos.de ([81.7.17.101]:37096 "EHLO freki.datenkhaos.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751995AbeEQGtk (ORCPT ); Thu, 17 May 2018 02:49:40 -0400 Received: from localhost (localhost [127.0.0.1]) by freki.datenkhaos.de (Postfix) with ESMTP id 22ECB91874F; Thu, 17 May 2018 08:49:39 +0200 (CEST) Received: from freki.datenkhaos.de ([127.0.0.1]) by localhost (freki.datenkhaos.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id F1-i6FsJK6VE; Thu, 17 May 2018 08:49:38 +0200 (CEST) Received: from probook (bb2.er-cl-1-2.bb-il.easterngraphics.com [195.191.216.226]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by freki.datenkhaos.de (Postfix) with ESMTPSA; Thu, 17 May 2018 08:49:38 +0200 (CEST) Date: Thu, 17 May 2018 08:49:31 +0200 From: Johannes Hirte To: Borislav Petkov Cc: "Ghannam, Yazen" , "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: <20180517064930.GA26421@probook> References: <20180201184813.82253-1-Yazen.Ghannam@amd.com> <20180201184813.82253-3-Yazen.Ghannam@amd.com> <20180414004230.GA2033@probook> <20180416115624.GA1543@probook> <20180515093953.GA1746@probook> <20180516224641.GA31929@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180516224641.GA31929@pd.tnic> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018 Mai 17, Borislav Petkov wrote: > 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. > Maybe I'm missing something, but those RDMSR IPSs don't happen on pre-SMCA systems, right? So the caching should be avoided here, cause the whole lookup looks more expensive to me than the simple switch-block in get_block_address. -- Regards, Johannes