Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp952486lqs; Wed, 6 Mar 2024 01:37:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWtsJNyTFDXTa5J5i/15MM9irqVvITEhjstu4DKKO3B6aV6ZI1yg7RwkwAiEpR/HoRBUwFx5x6/NdEyZwaCydk9yBaal0jfCO3HR/+Uqg== X-Google-Smtp-Source: AGHT+IE0JEIGYct/8vBrSdFKG0UHADp/PPAky4xGTuwfQQdWrm2D7Bf4a+dsOWM8DDm6UW3kucaz X-Received: by 2002:a05:620a:88f:b0:788:34fa:3845 with SMTP id b15-20020a05620a088f00b0078834fa3845mr6852889qka.0.1709717834002; Wed, 06 Mar 2024 01:37:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709717833; cv=pass; d=google.com; s=arc-20160816; b=t+m23HjmQYl6NdQEF+eqNzsPj2+0J79ZB2h+D3EQn9mmb2ZhThiEgBtWCiL0aqUl3x y886dvoPTTupD/sOxDex/z2bddPGXHfUsU9kvBR6RDoqowrb2RZuzvpDb34VG2s+1lyX i29JKIPvk66DxXzr7PnuR46Kq2YjOQbfp8Wme+D+WqnQKtHXX0JwKqw0duHb8d92zLr+ Sflr5ssXDNZOkiKJGSYeXJenimFv5/hsHehZgMCYC8pZ/8ujsLaFbYckbc5ujEUrPyNd 6ZXD7a372xJEIREVFB2kZy1+Zj5eGCzZRduXXjOwcJ/cYhqHm07hFUR8TaAKk7op3EqJ 9Jlw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=BNOn4Hs6mfz1DX0cVpLpb6x+NE2cXrLetDBA3Z2YIAo=; fh=pORQo8oSAosK2hTiLZvB8gSkx03+0ofoVmSQt7iEQGw=; b=esWEJkCV7r4Y+mlG7uZbfqcNKkRRAEmA2tfHv4MWHm+g0mFSH1EyjBrgOvSPIhr/70 aUo1JxAaEQR+0GiVLZQX6xgbt1iEJspdFHapMXrIuJ+W8tqkD1N+XrSI1+pmbVt14QGE sfj9x7zJL5I+BilaLUHhgRsap4n8YoVdxNWD5zLA7frf5FgaE8CrUtD68PAl6Xdg7yVz 9vJbxLVvM51cvanH679BFgDjToFR/9KgrYLMdcgYg3ZKoF5ZKhtVynka7X22HTKGI0MU xwrSMxwe48k9QVMc5Ewumdww/XySwYBV1mdn49fMybH40FlCoCFJ29sX+5ukMWEAvWp8 QoHQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OkKyx24L; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-93639-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93639-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id z18-20020a05620a08d200b00788330da3f3si3779737qkz.450.2024.03.06.01.37.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 01:37:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93639-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OkKyx24L; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-93639-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93639-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 9812E1C26DDF for ; Wed, 6 Mar 2024 09:36:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C2D95DF2B; Wed, 6 Mar 2024 09:36:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OkKyx24L" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 48C0D5C5E9; Wed, 6 Mar 2024 09:36:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709717779; cv=none; b=BJyIbee/bQGcB25b0cpXYS18KBr2u+TrJgYZFJbjCzd7MgTu8e/Sh/kdfcN7+VlGYIoINdjz7YHfRw7D30enJ4UJuTZxkyVp2MLVFomxevHinKzqcAVrQEvXl1s7ZVhKpP2Z4DZ1oyt+RDROANKdxU1pN/Lf2l9YSa5PdwJYgNo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709717779; c=relaxed/simple; bh=Se9wdvPcfwsLMnlMhoVHGwUCXB5idZL8wbJKmJcBmmA=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=FHZAWgqyVHh/HPgdt8J/tFlAL9AaqJeBEuwnN57LDCXgp/LNtdT+XgwBCBy+Hek1/YJwEKjeXa3RpLrVGbTN5mGWpG6/ysL2QfAqdLolbUyruU1VNXU+fkfo3LLkMExXYvLrzmS3J114nZnesPmOOG2VibIrpq4guO1ggFgY/PQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OkKyx24L; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCA30C433C7; Wed, 6 Mar 2024 09:36:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709717778; bh=Se9wdvPcfwsLMnlMhoVHGwUCXB5idZL8wbJKmJcBmmA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=OkKyx24LBAtPLpc+TBxhgzpXcEfA6howp/kefDleQHw1Ve1Yoq3DexZu/yWkqCHgy QDAuqr6mNXVpuCReXUD9B+/jcurZcl8jH4IFfS3/ba08mTQB2FhNfK067Lqg99LwPK Dkq+SkOEQ412pRRgAXoWMl8hhq8pFlLpRZqnXWwWX8mlzw5prIMwJybTutxjDby+zy AF/9UmncS2StBFHApltsRz+X9+jo7Auh/y7yeaE9Eg+ZCRRU0nTuJTFvTppQ13LUma wiFfFwyrzxMve+vGQpyCBUTJq+J7LuVTqQtAGZkUPpMemaRtk7pOAJyowoP/uBHmdv y827Gf95BgS8g== Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-513382f40e9so5273787e87.2; Wed, 06 Mar 2024 01:36:18 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUtWvIdys63wkcf90W2MXtReeMx8CFxpavtDftdiEDXcHhCdCPidbE4qkLZ27ZWvGm76AN5AMBrheTKw7iskffH4IcDMy6aa+I4xlpUl9pjWYSZyL9mS1XMdXTL4PN8zvQWZIdm2XSb X-Gm-Message-State: AOJu0Yy47/lDHSzrB992qxAwIEGSrNw7Ewv8yJzUk/Obooo5goiim/8Q 3nkUvORm45p6v6YQPco/WsbZqdT7jGW9XpYbRpjiwic0GUI3ANibrsN9Qca3SyX23L9Qi312JDx 5dW5PzuznXnJesIT23tWy/eHg22k= X-Received: by 2002:a05:6512:2c8b:b0:513:4777:f8c9 with SMTP id dw11-20020a0565122c8b00b005134777f8c9mr3591641lfb.6.1709717776891; Wed, 06 Mar 2024 01:36:16 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240306085622.87248-1-cuiyunhui@bytedance.com> <20240306085622.87248-3-cuiyunhui@bytedance.com> In-Reply-To: <20240306085622.87248-3-cuiyunhui@bytedance.com> From: Ard Biesheuvel Date: Wed, 6 Mar 2024 10:36:05 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 3/3] efistub: fix missed the initialization of gp To: Yunhui Cui Cc: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, xuzhipeng.1973@bytedance.com, alexghiti@rivosinc.com, samitolvanen@google.com, bp@alien8.de, xiao.w.wang@intel.com, jan.kiszka@siemens.com, kirill.shutemov@linux.intel.com, nathan@kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org Content-Type: text/plain; charset="UTF-8" On Wed, 6 Mar 2024 at 09:56, Yunhui Cui wrote: > > Compared with gcc version 12, gcc version 13 uses the gp > register for compilation optimization, but the efistub module > does not initialize gp. > > Signed-off-by: Yunhui Cui > Co-Developed-by: Zhipeng Xu This needs a sign-off, and your signoff needs to come after. > --- > arch/riscv/kernel/efi-header.S | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/arch/riscv/kernel/efi-header.S b/arch/riscv/kernel/efi-header.S > index 515b2dfbca75..fa17c08c092a 100644 > --- a/arch/riscv/kernel/efi-header.S > +++ b/arch/riscv/kernel/efi-header.S > @@ -40,7 +40,7 @@ optional_header: > .long __pecoff_data_virt_end - __pecoff_text_end // SizeOfInitializedData > #endif > .long 0 // SizeOfUninitializedData > - .long __efistub_efi_pe_entry - _start // AddressOfEntryPoint > + .long _efistub_entry - _start // AddressOfEntryPoint > .long efi_header_end - _start // BaseOfCode > #ifdef CONFIG_32BIT > .long __pecoff_text_end - _start // BaseOfData > @@ -121,4 +121,13 @@ section_table: > > .balign 0x1000 > efi_header_end: > + > + .global _efistub_entry > +_efistub_entry: This should go into .text or .init.text, not the header. > + /* Reload the global pointer */ > + load_global_pointer > + What is supposed to happen here if CONFIG_SHADOW_CALL_STACK=y? The EFI stub Makefile removes the SCS CFLAGS, so the stub will be built without shadow call stack support, which I guess means that it might use GP as a global pointer as usual? > + call __efistub_efi_pe_entry > + ret > + You are returning to the firmware here, but after modifying the GP register. Shouldn't you restore it to its old value?