From patchwork Mon Oct 23 09:09:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hou Wenlong X-Patchwork-Id: 13432546 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC6CFCDB474 for ; Mon, 23 Oct 2023 09:10:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230063AbjJWJKF (ORCPT ); Mon, 23 Oct 2023 05:10:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229517AbjJWJKD (ORCPT ); Mon, 23 Oct 2023 05:10:03 -0400 Received: from out0-206.mail.aliyun.com (out0-206.mail.aliyun.com [140.205.0.206]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1877A98; Mon, 23 Oct 2023 02:10:00 -0700 (PDT) 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; 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 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?q?maintainer=3AX86_A?= =?utf-8?q?RCHITECTURE_32-BIT_AND_64-BIT?= " , "H. Peter Anvin" , " =?utf-8?q?moderated_list=3AXEN_HYPERVIS?= =?utf-8?q?OR_X86?= " , " =?utf-8?q?open_li?= =?utf-8?q?st=3AX86_PLATFORM_DRIVERS_-_ARCH?= " 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 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org 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) 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