Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1609545rdb; Mon, 2 Oct 2023 15:24:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFkURbADS1Lz2e1UPSx6hX5QQSIHuwkgR4NcOgdmwxLLIhYZPZVX4gBByp/yiwEa57VYd33 X-Received: by 2002:a05:6a20:d428:b0:14c:d494:77c3 with SMTP id il40-20020a056a20d42800b0014cd49477c3mr9461906pzb.33.1696285450439; Mon, 02 Oct 2023 15:24:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696285450; cv=none; d=google.com; s=arc-20160816; b=sWIwAYXRAyjdrlizKYiZkH9aAAnMaCO8l1/kk0K+jgahDN/ji8CRjKFf55Oqivg/B+ N0yAKRDkwhVVATJLxANSQzzxAF1QKGT/18xmVw52vFMWqRuoTTTvaZJDShapyOc4INxH VUALUtZYqnmE8/k1MEEYlGy0FuSlQliSBVs1O3vK7CTBW7WC1l+jof2lpKjQeY7KKiZF ZtI8DlSF+6ElQdDyKavk3i2ziu4lx938aYvlI7hwNesWLoDK16w96O3+h+hJO7RzH569 NgZaVrL7Rpq5aZges/24HkQU3Sv0HIbgYcGit1kT5R+42ZPgoL3HlGOhuj0EzZCxU7MF Al/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=b4Co2IoRBwh3hIRS5xNghqEOtm1raaagEQl/TRV+0WI=; fh=FV96hQUlF8WIAUdp0Fev52gGLPyUrRshQ4FGtgksMnI=; b=vepub69yIEgHcz5KES9FbC3OgPG+xsi98OxxT2iCp6zivpdFfpSfwcQ+oOlCdC/LbY 3zQC78XPTPSAhK4j4cYl752NOdr5kvXKLwuIptamYGvL5OlnJVNgOUJuAGKWMpkHge8w SwOHz8/dKNTaklJgv98ISne2zSilEqgsGZbcdL0a6xxl8tG6FjmZ97MJE+vJqvgIV+VZ hKplCT75GUFhQwGy9X0lUckLpHufOTf7KGQZ1/5Sg6rVS9RXaId00v3NNNI4PwRRAUJz GxyH8/PsqNn2z71W51QYMZY53/ZkkIdK8BRp3YiRnEkKVGHtEX1290/r1qwIZwPic//H jYcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Y2TRtauf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id n14-20020a170903110e00b001bbcb3d9265si29490523plh.68.2023.10.02.15.24.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 15:24:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Y2TRtauf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 9ADF180AEE02; Mon, 2 Oct 2023 15:24:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230043AbjJBWYJ (ORCPT + 99 others); Mon, 2 Oct 2023 18:24:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbjJBWYI (ORCPT ); Mon, 2 Oct 2023 18:24:08 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F411CCE for ; Mon, 2 Oct 2023 15:24:05 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2975CC433C8; Mon, 2 Oct 2023 22:24:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696285445; bh=6qGFQixEXCDQMv2uE867U8nPAhyA6HAp0HAbQvXyowI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Y2TRtaufDtXKOBdW9HsEg/4Cmcj6gp1POmp49UuRFnR2kVNi6LhQ/dk+zg58rc3+8 +6FVlz++Oaz7IchukZ9Z4RW4H2zeOpQQ+f1DfZVwZD0wMV3ljNFYNDNy3ELFQXvazN QZVDlrBL0cUsmlPqSH4y9emJ0b+xuoIaNXFFGvBcKNdPT4ZmE+pavRhKLe80n/yG/s R7v2Djgr5y/m6t+4wH+ghlMXbZ5MRkpvDYoIKuFetKi0ovvbuLfOi53Dcf/omzVeID QNWRjCHzKQs06ecWZbgC6iO2UnYTdX6ImkTfuxL40T7EhC4Cwdq/oWbMB3pxe8KM5f +fEvxSSZ2GEoQ== Date: Mon, 2 Oct 2023 15:24:02 -0700 From: Nathan Chancellor To: Dave Hansen Cc: linux-kernel@vger.kernel.org, x86@kernel.org, acdunlap@google.com, ashok.raj@intel.com, bp@alien8.de, david@redhat.com, dionnaglaze@google.com, hpa@zytor.com, jacobhxu@google.com, jgross@suse.com, jroedel@suse.de, khalid.elmously@canonical.com, kim.phillips@amd.com, kirill.shutemov@linux.intel.com, llvm@lists.linux.dev, luto@kernel.org, mingo@redhat.com, nikunj@amd.com, peterz@infradead.org, pgonda@google.com, rientjes@google.com, rppt@kernel.org, seanjc@google.com, tglx@linutronix.de, thomas.lendacky@amd.com, Ingo Molnar Subject: Re: [PATCH] x86/boot: Move x86_cache_alignment initialization to correct spot Message-ID: <20231002222402.GA486933@dev-arch.thelio-3990X> References: <20231002200426.GA4127272@dev-arch.thelio-3990X> <20231002220045.1014760-1-dave.hansen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231002220045.1014760-1-dave.hansen@linux.intel.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 02 Oct 2023 15:24:09 -0700 (PDT) On Mon, Oct 02, 2023 at 03:00:45PM -0700, Dave Hansen wrote: > c->x86_cache_alignment is initialized from c->x86_clflush_size. > However, commit fbf6449f84bf moved c->x86_clflush_size initialization > to later in boot without moving the c->x86_cache_alignment assignment. > > This presumably left c->x86_cache_alignment set to zero for longer > than it should be. > > The result was an oops on 32-bit kernels while accessing a pointer > at 0x20. The 0x20 came from accessing a structure member at offset > 0x10 (buffer->cpumask) from a ZERO_SIZE_PTR=0x10. kmalloc() can > evidently return ZERO_SIZE_PTR when it's given 0 as its alignment > requirement. > > Move the c->x86_cache_alignment initialization to be after > c->x86_clflush_size has an actual value. > > Fixes: fbf6449f84bf ("x86/sev-es: Set x86_virt_bits to the correct value straight away, instead of a two-phase approach") > Cc: Adam Dunlap > Cc: Ingo Molnar > Cc: Jacob Xu > Link: https://lore.kernel.org/all/20231002200426.GA4127272@dev-arch.thelio-3990X/ Tested-by: Nathan Chancellor Thanks for the quick fix! > --- > arch/x86/kernel/cpu/common.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c > index 8d7063e4f63c9..9c51ad5bbf319 100644 > --- a/arch/x86/kernel/cpu/common.c > +++ b/arch/x86/kernel/cpu/common.c > @@ -1141,6 +1141,7 @@ void get_cpu_address_sizes(struct cpuinfo_x86 *c) > } > } > c->x86_cache_bits = c->x86_phys_bits; > + c->x86_cache_alignment = c->x86_clflush_size; > } > > static void identify_cpu_without_cpuid(struct cpuinfo_x86 *c) > @@ -1594,8 +1595,6 @@ static void __init cpu_parse_early_param(void) > */ > static void __init early_identify_cpu(struct cpuinfo_x86 *c) > { > - c->x86_cache_alignment = c->x86_clflush_size; > - > memset(&c->x86_capability, 0, sizeof(c->x86_capability)); > c->extended_cpuid_level = 0; > > -- > 2.34.1 >