From nobody Tue May 21 09:31:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=quarantine dis=quarantine) header.from=antgroup.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 169805223229659.80590278599266; Mon, 23 Oct 2023 02:10:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.621107.967198 (Exim 4.92) (envelope-from ) id 1quqww-0004Xp-4W; Mon, 23 Oct 2023 09:10:14 +0000 Received: by outflank-mailman (output) from mailman id 621107.967198; Mon, 23 Oct 2023 09:10:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1quqww-0004Xi-0P; Mon, 23 Oct 2023 09:10:14 +0000 Received: by outflank-mailman (input) for mailman id 621107; Mon, 23 Oct 2023 09:10:12 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1quqwu-0003eK-Ns for xen-devel@lists.xenproject.org; Mon, 23 Oct 2023 09:10:12 +0000 Received: from out0-194.mail.aliyun.com (out0-194.mail.aliyun.com [140.205.0.194]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f0d6f75c-7183-11ee-9b0e-b553b5be7939; Mon, 23 Oct 2023 11:10:10 +0200 (CEST) Received: from localhost(mailfrom:houwenlong.hwl@antgroup.com fp:SMTPD_---.V5qfj36_1698052195) by smtp.aliyun-inc.com; Mon, 23 Oct 2023 17:09:56 +0800 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f0d6f75c-7183-11ee-9b0e-b553b5be7939 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R541e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047204;MF=houwenlong.hwl@antgroup.com;NM=1;PH=DS;RN=14;SR=0;TI=SMTPD_---.V5qfj36_1698052195; From: "Hou Wenlong" To: linux-kernel@vger.kernel.org Cc: "Hou Wenlong" , "Juergen Gross" , "Boris Ostrovsky" , "Darren Hart" , "Andy Shevchenko" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , "=?UTF-8?B?bWFpbnRhaW5lcjpYODYgQVJDSElURUNUVVJFIDMyLUJJVCBBTkQgNjQtQklU?=" , "H. Peter Anvin" , "=?UTF-8?B?bW9kZXJhdGVkIGxpc3Q6WEVOIEhZUEVSVklTT1IgWDg2?=" , "=?UTF-8?B?b3BlbiBsaXN0Olg4NiBQTEFURk9STSBEUklWRVJTIC0gQVJDSA==?=" Subject: [PATCH 1/2] x86/xen/pvh: Set up percpu for stack canary in 32-bit kernel entry Date: Mon, 23 Oct 2023 17:09:38 +0800 Message-Id: <90df6cf5674241a85ac7dfe0a1558f1fd025cc17.1698051454.git.houwenlong.hwl@antgroup.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1698052232726100001 Content-Type: text/plain; charset="utf-8" In a 32-bit SMP kernel, the stack canary is a percpu variable accessed as %fs:__stack_chk_guard. However, the ABI for PVH entry does not specify the %fs register state. It currently works because the initial %fs register is 0x10 for QEMU, which is the same as $PVH_DS_SEL. %However, for added safety, the percpu should be set up explicitly %before calling xen_prepare_pvh(), which accesses the stack canary. Signed-off-by: Hou Wenlong --- arch/x86/platform/pvh/head.S | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/platform/pvh/head.S b/arch/x86/platform/pvh/head.S index c4365a05ab83..cee4dadf5344 100644 --- a/arch/x86/platform/pvh/head.S +++ b/arch/x86/platform/pvh/head.S @@ -121,6 +121,10 @@ SYM_CODE_START_LOCAL(pvh_start_xen) =20 ljmp $PVH_CS_SEL, $1f 1: + /* Set percpu for stack canary. */ + mov $PVH_DS_SEL,%eax + mov %eax, %fs + call xen_prepare_pvh mov $_pa(pvh_bootparams), %esi =20 --=20 2.31.1 From nobody Tue May 21 09:31:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=quarantine dis=quarantine) header.from=antgroup.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1698052239178397.47096626978555; Mon, 23 Oct 2023 02:10:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.621108.967208 (Exim 4.92) (envelope-from ) id 1quqwy-0004op-CF; Mon, 23 Oct 2023 09:10:16 +0000 Received: by outflank-mailman (output) from mailman id 621108.967208; Mon, 23 Oct 2023 09:10:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1quqwy-0004og-92; Mon, 23 Oct 2023 09:10:16 +0000 Received: by outflank-mailman (input) for mailman id 621108; Mon, 23 Oct 2023 09:10:14 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1quqww-0003eK-N7 for xen-devel@lists.xenproject.org; Mon, 23 Oct 2023 09:10:14 +0000 Received: from out0-198.mail.aliyun.com (out0-198.mail.aliyun.com [140.205.0.198]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f1fe0707-7183-11ee-9b0e-b553b5be7939; Mon, 23 Oct 2023 11:10:12 +0200 (CEST) Received: from localhost(mailfrom:houwenlong.hwl@antgroup.com fp:SMTPD_---.V5qfj3u_1698052197) by smtp.aliyun-inc.com; Mon, 23 Oct 2023 17:09:58 +0800 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f1fe0707-7183-11ee-9b0e-b553b5be7939 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R621e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047194;MF=houwenlong.hwl@antgroup.com;NM=1;PH=DS;RN=14;SR=0;TI=SMTPD_---.V5qfj3u_1698052197; From: "Hou Wenlong" To: linux-kernel@vger.kernel.org Cc: "Hou Wenlong" , "Juergen Gross" , "Boris Ostrovsky" , "Darren Hart" , "Andy Shevchenko" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , "=?UTF-8?B?bWFpbnRhaW5lcjpYODYgQVJDSElURUNUVVJFIDMyLUJJVCBBTkQgNjQtQklU?=" , "H. Peter Anvin" , "=?UTF-8?B?bW9kZXJhdGVkIGxpc3Q6WEVOIEhZUEVSVklTT1IgWDg2?=" , "=?UTF-8?B?b3BlbiBsaXN0Olg4NiBQTEFURk9STSBEUklWRVJTIC0gQVJDSA==?=" Subject: [PATCH 2/2] x86/xen/pvh: Use fixed_percpu_data to set up GS base Date: Mon, 23 Oct 2023 17:09:39 +0800 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1698052240953100001 Content-Type: text/plain; charset="utf-8" startup_64() and startup_xen() both use "fixed_percpu_data" to set up GS base. So for consitency, use it too in PVH entry and remove the temporary variable "canary". Signed-off-by: Hou Wenlong --- arch/x86/platform/pvh/head.S | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/x86/platform/pvh/head.S b/arch/x86/platform/pvh/head.S index cee4dadf5344..591ba165215f 100644 --- a/arch/x86/platform/pvh/head.S +++ b/arch/x86/platform/pvh/head.S @@ -96,7 +96,7 @@ SYM_CODE_START_LOCAL(pvh_start_xen) 1: /* Set base address in stack canary descriptor. */ mov $MSR_GS_BASE,%ecx - mov $_pa(canary), %eax + mov $_pa(INIT_PER_CPU_VAR(fixed_percpu_data)), %eax xor %edx, %edx wrmsr =20 @@ -160,8 +160,6 @@ SYM_DATA_START_LOCAL(gdt_start) SYM_DATA_END_LABEL(gdt_start, SYM_L_LOCAL, gdt_end) =20 .balign 16 -SYM_DATA_LOCAL(canary, .fill 48, 1, 0) - SYM_DATA_START_LOCAL(early_stack) .fill BOOT_STACK_SIZE, 1, 0 SYM_DATA_END_LABEL(early_stack, SYM_L_LOCAL, early_stack_end) --=20 2.31.1