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: 156764 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1165751vqx; Mon, 23 Oct 2023 02:10:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE9TQmruQuXnzTfjTfdiRz0/ALCwytJo8xi9a/RW0JfAMyu14IJRxGhKL1T8Y7t16cZ1kL1 X-Received: by 2002:a05:6358:7a6:b0:168:e364:70af with SMTP id n38-20020a05635807a600b00168e36470afmr1507912rwj.25.1698052217025; Mon, 23 Oct 2023 02:10:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698052216; cv=none; d=google.com; s=arc-20160816; b=h006sVUiQCn3+RDCjIcqYV9KxcLFXtvF2AJ81XDeq7D3+Fx7Nj+RCMo6hh2tiIbgYd we9RuS2demP1AvN9AEZyNq3Vre6oSpe0GT89gQYwiUs4Fl48ue2lgDx18ry/AVLlNG0b OuDxFXhA613n/o2R8sFkSmrwaM/xmPZuIYxv88QGgbM2ajkzUx/Iz3CZbdLz9q7hkraG 97muH4S3d1vMCsb5fwyRkV3wyzz4aZ8demcR6iYhi/rteAIwEwkTPbOlfXXGbGeJbOys VazBmryzxXH0yPaKzQwf8kUPa+c1eyVZXePdYZhCk6OUaY799oa66yU4j7VyNj6S/d1g Dr2A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=cbyLZqfTZoCvuMFFQrlhyntqyiGo2FgckIzhMOUyxQg=; fh=hKzLdgK4HR+tiTg9dLSK89ALadeChc5zAyrWEZxRg98=; b=RsXwnA4ZujCR99VPprD8cs9ClFpJWUu/jQdj+KbgjcOdNqlEsHJbolyP86EJCrRX0t 5U34z4VCPFk95tKLqhxGQ7P3numn6wio2hArRF59c1/AWevaTXzvmaGP80qJLij4L350 wjv7WbEHxWznifPHi4Thu/vGDatoXDn1bFk74i4JHSHV9znQRCoOeYraBrXhsPoJUFTH xtwqgHa+tcjlHi3DJ3FYev1a2a+H5LzX8eOj/GfUJPDeViIq/Eaywv94jWBrpwHcqTT9 QxQe6qC7uD5S2CX4a8/7RJsuCkxS/eNHlKqcQfgjnOg+rffgdnJydVQasKFEd+D7y1b7 pssQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id ck28-20020a056a02091c00b005af21fd2c64si6069639pgb.870.2023.10.23.02.10.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 02:10:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 2316480681D6; Mon, 23 Oct 2023 02:10:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230151AbjJWJKF (ORCPT + 27 others); 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_lis?= =?utf-8?q?t=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 X-Spam-Status: No, score=-0.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 23 Oct 2023 02:10:15 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780536801614737949 X-GMAIL-MSGID: 1780536801614737949 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