From patchwork Tue Oct 3 07:38:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 147687 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1916505vqb; Tue, 3 Oct 2023 00:38:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHg85a+qnOCNzJ4A+zK9k98GBpvxjapvq8pW4mLENSPureYVAAa21vFqd9MMug9aJ9s976t X-Received: by 2002:a17:902:db02:b0:1c5:fe75:b304 with SMTP id m2-20020a170902db0200b001c5fe75b304mr14278736plx.59.1696318737357; Tue, 03 Oct 2023 00:38:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696318737; cv=none; d=google.com; s=arc-20160816; b=L0AVX7sdPrfLftSJifsRNrfKPX3fJTgGHrpRUOhYkD+sXTkenGdjqCUv6MqINqMgZb fv2OU0XO156nIUBQk44PvxbQxEEHUr2Ys86rznoLGACME35x/ReOGk4x1wyjvwUFK38s wNacCGBxd7mMBfKSWdH2lcWOSUWhJyzbnRNdwow1TeJh82Bew3FkJrg5VbLJZv0QW7qH 2Pz87IemvhB6WQBYfY0AkKO3iZyL3ZIpE2OXdcO2SLKQdqIz8hRc3GmWn9Hc96qgw27E enU93GHaxrljAZcRt1s4ZwD+0ztAnG0GjoTynQ1Xc+iJNrNH2WXV8UZ4w3Ej/DaQAME2 GWlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=rgSGq3Z6E3846QpBwJ+wxMSZWZxgv5W9g5Ebek0aVvE=; fh=fCoAoitlvbhFAXpA5go1um80B4fm7ubhXNGyfP1GVSg=; b=dN9TBgy91QHB2xX2Dmhj4aV9/wMOMmyRZ5jPpjjO5Ed7NkfQdiRNRdGOiXg/jxPglT yXXQ94F+zGd+945JwVJz0BbImrP6O/FI9xNYyfKTotzNqLHxucQkHwtswa9K5cnQ311o rOKbS7tNHJbElBRYrZ1mbBkNgNwHphXqhX8gEWIcSP6whrV6e945X9ZtoXI3zYl46oDX 0zkcUd3ReVjelcRPqTPxrmVtnS4qV8D/gvf0Z7X+MBW+nu+krSLS8wnqTBnVWs1/pavS 0+WWmCFseJpNiZ9ZDlxa19fIKwZt4M94Jraf+TqUKcbTCpF8a2MrsqWsTo9u/ydVPwn2 QugQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=RdYF3n1z; dkim=neutral (no key) header.i=@linutronix.de header.b=KdSWxw6j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id h3-20020a170902b94300b001c6138350b4si806981pls.431.2023.10.03.00.38.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 00:38:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=RdYF3n1z; dkim=neutral (no key) header.i=@linutronix.de header.b=KdSWxw6j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id BAA6280FA9E0; Tue, 3 Oct 2023 00:38:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231468AbjJCHiz (ORCPT + 18 others); Tue, 3 Oct 2023 03:38:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230359AbjJCHiy (ORCPT ); Tue, 3 Oct 2023 03:38:54 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB45290; Tue, 3 Oct 2023 00:38:51 -0700 (PDT) Date: Tue, 03 Oct 2023 07:38:48 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696318729; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rgSGq3Z6E3846QpBwJ+wxMSZWZxgv5W9g5Ebek0aVvE=; b=RdYF3n1z6ztLNQitGrdJUUMuarthGXZKpoYQHQTaRLDwE3fPdIGSz1jUdDx7yyXO0Xaqw8 yuxhYDNAvfx/4wzZYg2JIIk9Sg5EvQRm/bG/NbWQXdkIaMisIr8KlkjPy1P6jFBFHud71c VzsAmbMCL9oNXktSb3kW38q4lg3ROXQJsSDp+c160etF9KC9LV5YGWleSuT+K2XW3h9eWg EGtAoawtSnwWCmq0MUpTIyx3CLKq1UM6AE4wIfP/WmCWvaZrdFewHyY0nPQB4gjiuzXOj7 8gjhLZpYPqCSU/Nx0UfVVDnXnQYOpSh+F9fW3lz+WIPXwJtFEwoJ1Z6HtWQWyg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696318729; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rgSGq3Z6E3846QpBwJ+wxMSZWZxgv5W9g5Ebek0aVvE=; b=KdSWxw6jsHelXvChuerF23cJXNwgH5uUCRXXy6shPNT6KP+kWEpKCLMiGZaw/Qu2oul2nW 3WcqEMcGCr/GsbAA== From: "tip-bot2 for Dave Hansen" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/mm] x86/boot: Move x86_cache_alignment initialization to correct spot Cc: Dave Hansen , Ingo Molnar , Nathan Chancellor , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231002220045.1014760-1-dave.hansen@linux.intel.com> References: <20231002220045.1014760-1-dave.hansen@linux.intel.com> MIME-Version: 1.0 Message-ID: <169631872850.3135.7519973576478959373.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,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 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 00:38:56 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778682961505061849 X-GMAIL-MSGID: 1778719115979365052 The following commit has been merged into the x86/mm branch of tip: Commit-ID: 3e32552652917f10c0aa8ac75cdc8f0b8d257dec Gitweb: https://git.kernel.org/tip/3e32552652917f10c0aa8ac75cdc8f0b8d257dec Author: Dave Hansen AuthorDate: Mon, 02 Oct 2023 15:00:45 -07:00 Committer: Ingo Molnar CommitterDate: Tue, 03 Oct 2023 09:27:12 +02:00 x86/boot: Move x86_cache_alignment initialization to correct spot 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: fbf6449f84bf ("x86/sev-es: Set x86_virt_bits to the correct value straight away, instead of a two-phase approach") 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") Signed-off-by: Dave Hansen Signed-off-by: Ingo Molnar Tested-by: Nathan Chancellor Link: https://lore.kernel.org/r/20231002220045.1014760-1-dave.hansen@linux.intel.com --- 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 8d7063e..9c51ad5 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;