From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752955AbdKJM4g (ORCPT ); Fri, 10 Nov 2017 07:56:36 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:55179 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751095AbdKJM4f (ORCPT ); Fri, 10 Nov 2017 07:56:35 -0500 Date: Fri, 10 Nov 2017 13:56:32 +0100 (CET) From: Thomas Gleixner To: Prarit Bhargava cc: linux-kernel@vger.kernel.org, Andi Kleen , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Peter Zijlstra , Dave Hansen , Piotr Luc , Kan Liang , Borislav Petkov , Stephane Eranian , Arvind Yadav , Andy Lutomirski , Christian Borntraeger , "Kirill A. Shutemov" , Tom Lendacky , He Chen , Mathias Krause , Tim Chen , Vitaly Kuznetsov Subject: Re: [PATCH v5 2/3] x86/topology: Avoid wasting 128k for package id array In-Reply-To: Message-ID: References: <20171105165428.32108-1-prarit@redhat.com> <20171105165428.32108-3-prarit@redhat.com> <372083ad-2a77-4646-bc67-dd4348a521d9@redhat.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 10 Nov 2017, Thomas Gleixner wrote: > On Fri, 10 Nov 2017, Prarit Bhargava wrote: > > On 11/09/2017 07:43 PM, Thomas Gleixner wrote: > > > On Sun, 5 Nov 2017, Prarit Bhargava wrote: > > >> [v5]: Change kmalloc to GFP_ATOMIC to fix "sleeping function" warning on > > >> virtual machines. > > > > > > What has this to do with virtual machines? The very same issue is on > > > physcial hardware because this is called from the early CPU bringup code > > > with interrupts and preemption disabled. > > > > There was a Intel test bot report of a failure during boot on virtual systems > > with Andi's patch. > > Sure, but the problem has nothing to do with virtual machines at all. The same is true for the KASAN report of out of bound access: new = logical_packages++; - if (new != pkg) { - pr_info("CPU %u Converting physical %u to logical package %u\n", - cpu, pkg, new); + + /* Allocate and copy a new array */ + ltp_pkg_map_new = kmalloc(logical_packages * sizeof(u16), GFP_KERNEL); + BUG_ON(!ltp_pkg_map_new); + if (logical_to_physical_pkg_map) { + memcpy(ltp_pkg_map_new, logical_to_physical_pkg_map, + logical_packages * sizeof(u16)); That's caused by incrementing logical_packages _before_ the memcpy(), but the old array is one u16 shorter than the newly allocated. That's reported on a VM as well, but is a genuine code bug. Thanks, tglx