Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1326829lqb; Thu, 30 May 2024 07:13:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUD4FyvCwYIoCpZs1/Vva6fRsyNcIQT0hv5+M3+WlBXbNzQokFpnhdAM2OxuRYz/XHYOJWrizx6THQOkMjdxMj7joUBmAgdE/XZvFPBJw== X-Google-Smtp-Source: AGHT+IH46cHM7GGfLJY/dPuw+I9B/hosHyWhV+2tHlzsf8C5MWqogT1igFVSFIlB8bFCp6nQInUc X-Received: by 2002:a17:906:2812:b0:a64:c42f:a99 with SMTP id a640c23a62f3a-a65e8e5434amr153366266b.19.1717078422015; Thu, 30 May 2024 07:13:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717078422; cv=pass; d=google.com; s=arc-20160816; b=JaBBbUPMyYq7uIZ/NOPJT7lt4AK2wR0IJMgMLdW7WDRVBCE6BN76HZBPaSxqEvgsP4 1aUOg5ljq/E5Cf2SGvRCmYJwhOmdfACaOfZ00T7NCN3UiXUDnwF3BFFHMX8ooR+Yd1fG XA7bzj/AaIAxWCkfGGuAIrAtLaJsglSGUYpOGmMHuEG7Kq1gKby6Rg5Avauq63y+pCT2 4Yy7cs72127/L6XUMgVqqQ1UA/o6MkAMGHvyYO+9QCNSP90AB2BmD1cnJKCQt1ZM/s25 lxTdmpGMBlykFyaqGk4sD9hryLAUb5nsB2ftwVRprRAF8hRv8p6N8t7nIBm1WTzQz1gA huRw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=organization:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=4+QAOgEDemDgcNj9HZLqJ18PLIdq81xshoNAIeYYG7A=; fh=Qum7TmsMs8yROppWnP5CEi1baWLwZPZLYbm6tZNe7eY=; b=A3adS1Ukm0J+hqWiEMPV56FfgFUB3eo1z0pIsSq9zGal4lJBQLGmHlwADruUB98tUi kOhUzKI7pDMp9fqKelI//SarzckTSSnamc8ukvTT6YLnxsBddfn/1II031BKykMOOF3G 6qsbHancZnjy3u7KgmmmnngPBbuPzonAhA3P5dNQBYARV28ooyJJIMXYhC+fqFRrj4sN rDdir0AglvP0DFXi+M0Lu/VLRE7/+RNE908HL1HywNIqvkNWnDdiJB+JYew0aU43ZHy5 0YrwZvnm7/KlqrZVfgMoRvs1JOS3cndbv87t0vBKAr/dEYRJePr5o7z/cBP7dU5SkW+p Nyxg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="YjU/3dBI"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-195498-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195498-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a626c919989si731646566b.223.2024.05.30.07.13.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 07:13:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195498-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="YjU/3dBI"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-195498-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195498-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id BB27E1F22575 for ; Thu, 30 May 2024 14:13:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0BBD816F0DA; Thu, 30 May 2024 14:13:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YjU/3dBI" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 830CC186E26; Thu, 30 May 2024 14:13:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717078415; cv=none; b=dSLmEiMmzBx+Ffi22BU7Nh1qoF2nSF02X7F91Rn4n/xW9funnAsDcZRYe8WIYZKrfJIByrvHKemRmxHWLG9sya87zBGUSN2tBBgT7SoJ8iQrGd/MhA5/LI1CW6soe8pzkg/PalvQ2h3Js+ZBRx4ZAA7A1mUbgFvicJ4pjbtuRCA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717078415; c=relaxed/simple; bh=z9Oe7jqbSwx2iocRxL1M7VOvOhXgSU85JZly6jmOudU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=G3ssY8LXldW9MHyDO18YiHEwgFKiu6Nl+xnpbrjvolJlHCg8sLyxr3Wd8LbCjNHMGTiwqS+cqpfloZKx3Hwo/kX7naQKIVB/421ia2qThyVmSAiSfND0mmkNXLmi8+vaKdMck0cI9eeGQQlM2JWqAAo6aqRx3vxIPfikasu4qOw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=YjU/3dBI; arc=none smtp.client-ip=192.198.163.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717078413; x=1748614413; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=z9Oe7jqbSwx2iocRxL1M7VOvOhXgSU85JZly6jmOudU=; b=YjU/3dBIUV7Gw3ownTyEYnMoF9SygYlEiV1D00II2U2R3M+fwUKluuxY LB9sDBpteLYEkdPedi3Sl6e3nS4MLBqR6gfYtbb9kipM5zTdYAncgsqsD iCi8aYKZSC52TzXkv5RfA0binK+cgdtqnuh849JeCG9UETa4tRKOvc6uK OBP2OWr7tpsLhECukbiNK0rNWa4ZXKQKwKc5CYj1Zpy3M6+xwJ7/otAWd QlLdn6bZjt2QqUJmfVgRihWhu0GTn6K3yZFL7JQMJIKRzBikZfOj0Z1zE EmWz4BCkpaPRAc/axWJA8H5Fbc8cf5NdSZMfLMcK8L1kY1GVeWqGgZUBe w==; X-CSE-ConnectionGUID: lFxtRL+GQyyMUb8vjHpn5Q== X-CSE-MsgGUID: BVmvn9rUSQGpOiU4IEhJhg== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="13327826" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="13327826" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 07:13:32 -0700 X-CSE-ConnectionGUID: 4/dRRaIzRKStKyFjZWQwQg== X-CSE-MsgGUID: JxYpurK5SliCnGzo8pGCGQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="35767692" Received: from smile.fi.intel.com ([10.237.72.54]) by orviesa010.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 07:13:30 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.97) (envelope-from ) id 1sCgX2-0000000C6Jn-0zHu; Thu, 30 May 2024 17:13:28 +0300 Date: Thu, 30 May 2024 17:13:28 +0300 From: Andy Shevchenko To: Dave Hansen Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, x86@kernel.org, bp@alien8.de, stable@vger.kernel.org Subject: Re: [PATCH] x86/cpu: Provide default cache line size if not enumerated Message-ID: References: <20240517200534.8EC5F33E@davehans-spike.ostc.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo On Mon, May 20, 2024 at 01:43:42PM +0300, Andy Shevchenko wrote: > On Fri, May 17, 2024 at 01:05:34PM -0700, Dave Hansen wrote: > > > > From: Dave Hansen > > > > tl;dr: CPUs with CPUID.80000008H but without CPUID.01H:EDX[CLFSH] > > will end up reporting cache_line_size()==0 and bad things happen. > > Fill in a default on those to avoid the problem. > > > > Long Story: > > > > The kernel dies a horrible death if c->x86_cache_alignment (aka. > > cache_line_size() is 0. Normally, this value is populated from > > Missing ) ? > > > c->x86_clflush_size. > > > > Right now the code is set up to get c->x86_clflush_size from two > > places. First, modern CPUs get it from CPUID. Old CPUs that don't > > have leaf 0x80000008 (or CPUID at all) just get some sane defaults > > from the kernel in get_cpu_address_sizes(). > > > > The vast majority of CPUs that have leaf 0x80000008 also get > > ->x86_clflush_size from CPUID. But there are oddballs. > > > > Intel Quark CPUs[1] and others[2] have leaf 0x80000008 but don't set > > CPUID.01H:EDX[CLFSH], so they skip over filling in ->x86_clflush_size: > > > > cpuid(0x00000001, &tfms, &misc, &junk, &cap0); > > if (cap0 & (1<<19)) > > c->x86_clflush_size = ((misc >> 8) & 0xff) * 8; > > > > So they: land in get_cpu_address_sizes(), set vp_bits_from_cpuid=0 and > > never fill in c->x86_clflush_size, assign c->x86_cache_alignment, and > > hilarity ensues in code like: > > > > buffer = kzalloc(ALIGN(sizeof(*buffer), cache_line_size()), > > GFP_KERNEL); > > > > To fix this, always provide a sane value for ->x86_clflush_size. > > > > Big thanks to Andy Shevchenko for finding and reporting this and also > > providing a first pass at a fix. But his fix was only partial and only > > worked on the Quark CPUs. It would not, for instance, have worked on > > the QEMU config. > > > > 1. https://raw.githubusercontent.com/InstLatx64/InstLatx64/master/GenuineIntel/GenuineIntel0000590_Clanton_03_CPUID.txt > > 2. You can also get this behavior if you use "-cpu 486,+clzero" > > in QEMU. > > Tested-by: Andy Shevchenko > > (as this obviously fixes the issue as it makes a partial revert of the culprit > change). What's the status of this? (It seems you have to rebase it on top of the existing patches in the same area). -- With Best Regards, Andy Shevchenko