From patchwork Tue Nov 8 17:49:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 17142 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2856460wru; Tue, 8 Nov 2022 09:51:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf7EY0bpRh49xnDwnlegm5pxXRZ2f2XZe9Ra7LyisyKZFoqoMmnf99Ll15eldCY6uupBrPbh X-Received: by 2002:a17:906:d89:b0:7ae:6ba5:f324 with SMTP id m9-20020a1709060d8900b007ae6ba5f324mr10087025eji.299.1667929875502; Tue, 08 Nov 2022 09:51:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667929875; cv=none; d=google.com; s=arc-20160816; b=bz1Zl9zQ3ighG+vJv0AIMhnLu0imzt2Hbg6m0KWUSuP6mkV9BIId4lGfhu944U0T1b EXFPKMlnL0tU32zozw6yTwRktSENgcYDf9MnHqQjrlN8bnv7IQ05ivz/hvzIYpmD6HUp FCcI4o5SubED+W0Sm1ifrjOOWtk6AUO5o85BkRbtJgEAIEIPC9Gr/X7Mcz/yodJ30lfd L7c5djwEZ14e+F+qJn8g3HOSNwT73wtxQ0hFBwFAUTo9HAnSCzZYiNrB3i8ax60RZsGZ 5NRkSRJ0qgpSxo5prK5RZgtov/yLAurt5cOBHT4fsBxha+4PjDnXHsYgLThLTsphN217 2wWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=kLkB994OsC2+35KKaFGH5GI/b9wD1ZQaJN3ks33zRHM=; b=Zd2Q9xKplCWDv7sl9z/0nZQc79pr6Zf9CtWIba+QFM+Vg9ZMyWwje1QichKTWvF6EI S6cS8AFXrTekmQGCeRljfIXk7Im3IquMRvylIoM5zgbtakLuVULaJDKGvk3CHWqNYji3 vkGRCyfSARrc0jg/oZXA4M2PFGuS2k1s8rytp9SMvQerZ0lIoK2qibyxruAq5xmE8g9v LO0tUs5Z6gGHd2mbwpQij06wKlhCZ/MSV13uebCXkq8QrKkuQ33simn1E2bFSvMejW/l nVLqTKxcDB1tmCChfk2orrkLS92FVSldhDAAzZdrOEeHJqiCOFqGrFqyf/dkW8P0Iihx m6iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="kohT8c/A"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n15-20020aa7db4f000000b0046159da6233si11042741edt.145.2022.11.08.09.50.51; Tue, 08 Nov 2022 09:51:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="kohT8c/A"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234660AbiKHRty (ORCPT + 99 others); Tue, 8 Nov 2022 12:49:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234686AbiKHRtm (ORCPT ); Tue, 8 Nov 2022 12:49:42 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C18F212ABE; Tue, 8 Nov 2022 09:49:40 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7AD55B81BE1; Tue, 8 Nov 2022 17:49:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AF38C433D7; Tue, 8 Nov 2022 17:49:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667929778; bh=LMhru1+YgBAfi13lBX6Nu1827mByiikg16DD/vba9ec=; h=From:To:Cc:Subject:Date:From; b=kohT8c/A1pFM9cKfrnQiKB/0EL7Yd81dJj1XkPIDip0mbUj/1VHCst+eGjYmjl6/f MScOjDjtsMDMMQrNqzzefQiqSHHxnq4X+q0e1o7I588SbzLVUjLQrS07gufK0i71tL 6HyxWnImwR8m4ejUyyO7D60iwdSZ5V/jHCCVquOYyy+LvqGk6nUY43GsVIC/StXJg+ REW9Dlyhe1QSmlFjq3/zFupSN14aqHZ42bZupr2k4jYoxnSu/5ingp8akG+o/uqGc2 GvAdzuy/TY0ng+3WEVwzUf2frjNpuPHQO8e/zPoBbqV3xNpeBPE/JbHInqSo/rEQGP ohwTxi1rSyzag== From: Nathan Chancellor To: Arnd Bergmann , Kees Cook Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , stable@vger.kernel.org, Ard Biesheuvel , Zhao Wenhui , xiafukun Subject: [PATCH] vmlinux.lds.h: Fix placement of '.data..decrypted' section Date: Tue, 8 Nov 2022 10:49:34 -0700 Message-Id: <20221108174934.3384275-1-nathan@kernel.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748951237104688660?= X-GMAIL-MSGID: =?utf-8?q?1748951237104688660?= Commit d4c639990036 ("vmlinux.lds.h: Avoid orphan section with !SMP") fixed an orphan section warning by adding the '.data..decrypted' section to the linker script under the PERCPU_DECRYPTED_SECTION define but that placement introduced a panic with !SMP, as the percpu sections are not instantiated with that configuration so attempting to access variables defined with DEFINE_PER_CPU_DECRYPTED() will result in a page fault. Move the '.data..decrypted' section to the DATA_MAIN define so that the variables in it are properly instantiated at boot time with CONFIG_SMP=n. Cc: stable@vger.kernel.org Fixes: d4c639990036 ("vmlinux.lds.h: Avoid orphan section with !SMP") Link: https://lore.kernel.org/cbbd3548-880c-d2ca-1b67-5bb93b291d5f@huawei.com/ Debugged-by: Ard Biesheuvel Reported-by: Zhao Wenhui Tested-by: xiafukun Signed-off-by: Nathan Chancellor --- include/asm-generic/vmlinux.lds.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) base-commit: f0c4d9fc9cc9462659728d168387191387e903cc diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index d06ada2341cb..3dc5824141cd 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -347,6 +347,7 @@ #define DATA_DATA \ *(.xiptext) \ *(DATA_MAIN) \ + *(.data..decrypted) \ *(.ref.data) \ *(.data..shared_aligned) /* percpu related */ \ MEM_KEEP(init.data*) \ @@ -995,7 +996,6 @@ #ifdef CONFIG_AMD_MEM_ENCRYPT #define PERCPU_DECRYPTED_SECTION \ . = ALIGN(PAGE_SIZE); \ - *(.data..decrypted) \ *(.data..percpu..decrypted) \ . = ALIGN(PAGE_SIZE); #else