From patchwork Thu Oct 12 15:30:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Cabaj X-Patchwork-Id: 1847537 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S5ts34tjpz23jm for ; Fri, 13 Oct 2023 02:31:18 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1qqxeS-00058r-I1; Thu, 12 Oct 2023 15:31:04 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1qqxeL-00058E-Uu for kernel-team@lists.ubuntu.com; Thu, 12 Oct 2023 15:30:58 +0000 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 9EBB4404AB for ; Thu, 12 Oct 2023 15:30:57 +0000 (UTC) Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-65b13c48253so12163126d6.3 for ; Thu, 12 Oct 2023 08:30:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697124656; x=1697729456; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Zw03KgXrlZBa6DWQcHZDJF6FcS+i5xTL3eHP1uC73mQ=; b=fESm0W/oD2o5W4oG+8exIGzR+UZ2QM7lQJETduU3UTorYdCH+hE3WPlhWQZQUDzbTK RKSwnoSJZ9v6bEpOvNqQy5sjn2Zyc/NW+NJhscMncSxBaM24EvzAykM+1HKMANb5DRSo AwtevH8mjh+VXD+1xRbIH2mDEhieGCbpsjFJSdkrfa3jeiDLUcBCpv++nsmWMYDarSvi Kaq4xh/B4h0UrHqX2aQRKeYXccY3cgbepAc7B/SXkK/3myQRQ3Yg9o21YdoGc/0HhpqQ dzaTYk90Mr1VGxfpomrSy+/bWyLEu4ePoirzoewov5Z869QSBBZbc2FDYaW/T+azOt/j f8dg== X-Gm-Message-State: AOJu0Yz6R3wahD/hMBlTh1KlwMsOVonPvrLIoMuHzlytDXZwRQ9lBWUl kG+E6IZ5IO8LeKlKYqHxjrJq+ygK5fzaaSOJ4vHoXuqkpkzqu7VvoiMxwalmyYCGjTIlSPbqq2i EBT3Mut5Iq7Ujr7sbOV25YG9FafO9ETX8W6GvR2rjEjZlvkGVratw X-Received: by 2002:a05:622a:1749:b0:419:4d8a:336 with SMTP id l9-20020a05622a174900b004194d8a0336mr28579475qtk.60.1697124656636; Thu, 12 Oct 2023 08:30:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF0fD3qYoGNCaNpI6DekO8G42fVwIRf5RcrtO8Hk7XxPv5p29TOzntJggHSa7NOzxeydYbvuw== X-Received: by 2002:a05:622a:1749:b0:419:4d8a:336 with SMTP id l9-20020a05622a174900b004194d8a0336mr28579456qtk.60.1697124656350; Thu, 12 Oct 2023 08:30:56 -0700 (PDT) Received: from smtp.gmail.com (h69-130-246-116.mdtnwi.broadband.dynamic.tds.net. [69.130.246.116]) by smtp.gmail.com with ESMTPSA id e1-20020ac81301000000b0040331a24f16sm6258287qtj.3.2023.10.12.08.30.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 08:30:56 -0700 (PDT) From: John Cabaj To: kernel-team@lists.ubuntu.com Subject: [SRU][mantic:linux-gcp/aws, lunar:linux-gcp/aws][PATCH 1/1] x86/boot: Move x86_cache_alignment initialization to correct spot Date: Thu, 12 Oct 2023 10:30:54 -0500 Message-Id: <20231012153054.29953-2-john.cabaj@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012153054.29953-1-john.cabaj@canonical.com> References: <20231012153054.29953-1-john.cabaj@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Dave Hansen BugLink: https://bugs.launchpad.net/bugs/2039191 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 (cherry picked from commit 3e32552652917f10c0aa8ac75cdc8f0b8d257dec linux-next) Signed-off-by: John Cabaj --- 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 6933297b9949..727a82600c82 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1126,6 +1126,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) @@ -1576,8 +1577,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;