Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp521700pxb; Wed, 25 Aug 2021 08:35:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0tAriOoaQb3RboUqB+9dx+inqENpXJLP6F5EUTpx8NUiW+MkmRhCpdFrFxmo4SE7znQUu X-Received: by 2002:a05:6638:4101:: with SMTP id ay1mr38902029jab.109.1629905750102; Wed, 25 Aug 2021 08:35:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629905750; cv=none; d=google.com; s=arc-20160816; b=NKp769EO3eJjXtJsYk50cdG8hCu1RvDzAzKm8wK4+MnbaH/1+4z2IKRZYc2XeUc5TR GJuUH6FIb81wztdj0zVJn/9ppBUI/HKgnxAOaVK9KnMW/x38Oby6Al9LagkDF1OE/QR/ vGwzBB8UIXJenlLtHq80Yx3fppQtsYUl9RybJmBmLpsGsBcvKjGDlaJGDPqojSoI+CTj j0LI5WbF/NjepfDxV6RQJJDC1pG4PwmrGq9k/nNHIYS5s2eosi/Hi9/dgYDcz8MZhWFX kXY3WtC5LP1zzkrXAkXNQnTucDf2RlghRZn9dfnXkZAwkJN7pCeFdoCjvNKucXrTjogW rwIg== 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 :dkim-signature; bh=/d2RSJXoiYvwpdqa3PewAfBc2yP4smGwYb0V6Y+Upzo=; b=aTyoAEtnYT7TyGkVFcST6wJ/iWEc9X8eKGgyg38L4FkWmP48zK/kH4ibUE7YcXIk2C nJw67wATyTG63guxFllFn4WC9IUm6g4xLrDpXeRstJVncfaRIRZhLyzbE14kU3VhVQaT 0MCP06GZPSNe29wD5nHm3ZJtq5gpZGrCN4G0T9vbBmTHWq8VLH0M82BcwTXHIWEF0uMl rFNCZXBDLWuHQZvd3dL0BOzdGwZl2WIaMTf70zkMCXolZWA4KfG8kFJpBj4nXF36nSv9 njzUPaMjDAD0dbQEB9zvH3W4Shomy0+Yzj6cvpHVsnSe6UIa4S6B2TAR6qjG/POUEGHD epng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=TnJjPPz5; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t11si277502jal.119.2021.08.25.08.35.38; Wed, 25 Aug 2021 08:35:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=TnJjPPz5; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240737AbhHYPI2 (ORCPT + 99 others); Wed, 25 Aug 2021 11:08:28 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:44856 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231995AbhHYPIR (ORCPT ); Wed, 25 Aug 2021 11:08:17 -0400 Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BC62A2220A; Wed, 25 Aug 2021 15:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629904049; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/d2RSJXoiYvwpdqa3PewAfBc2yP4smGwYb0V6Y+Upzo=; b=TnJjPPz5sXKClNliDjj4T4y6yB7BO3Bnlji44QSDi6x9FmXeHnuOl2sw2OT7lHgAFFMR1H nvXRGufQSECWgwOALkzxELpxvuYmk1PMMKiRVIWRU5rCa0ee71bnhrInvklZyqdKSMURhW V138+hugf8845aj1TAlhbsJ2PIN3ja8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629904049; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/d2RSJXoiYvwpdqa3PewAfBc2yP4smGwYb0V6Y+Upzo=; b=oSObJPLqgQ8+K13tqXXWh+49QBGbp+vhvWoO7oX+EBb3fzHcO9HiouywQud9QIG8HYHAQu mrZcEQgt8+sd4CDw== Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id 91F4113A85; Wed, 25 Aug 2021 15:07:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id xVtWIbBcJmGIVAAAGKfGzw (envelope-from ); Wed, 25 Aug 2021 15:07:28 +0000 Date: Wed, 25 Aug 2021 17:07:26 +0200 From: Joerg Roedel To: Brijesh Singh Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, Thomas Gleixner , Ingo Molnar , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Borislav Petkov , Michael Roth , Vlastimil Babka , "Kirill A . Shutemov" , Andi Kleen , tony.luck@intel.com, marcorr@google.com, sathyanarayanan.kuppuswamy@linux.intel.com Subject: Re: [PATCH Part1 v5 23/38] x86/head/64: set up a startup %gs for stack protector Message-ID: References: <20210820151933.22401-1-brijesh.singh@amd.com> <20210820151933.22401-24-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210820151933.22401-24-brijesh.singh@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 20, 2021 at 10:19:18AM -0500, Brijesh Singh wrote: > void __head startup_64_setup_env(unsigned long physbase) > { > + u64 gs_area = (u64)fixup_pointer(startup_gs_area, physbase); > + This breaks as soon as the compiler decides that startup_64_setup_env() needs stack protection too. And the startup_gs_area is also not needed, there is initial_gs for that. What you need is something along these lines (untested): diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S index d8b3ebd2bb85..3c7c59bc9903 100644 --- a/arch/x86/kernel/head_64.S +++ b/arch/x86/kernel/head_64.S @@ -65,6 +65,16 @@ SYM_CODE_START_NOALIGN(startup_64) leaq (__end_init_task - FRAME_SIZE)(%rip), %rsp leaq _text(%rip), %rdi + + movl $MSR_GS_BASE, %ecx + movq initial_gs(%rip), %rax + movq $_text, %rdx + subq %rdx, %rax + addq %rdi, %rax + movq %rax, %rdx + shrq $32, %rdx + wrmsr + pushq %rsi call startup_64_setup_env popq %rsi It loads the initial_gs pointer, applies the fixup on it and loads it into MSR_GS_BASE.