From patchwork Tue Sep 19 10:35:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13391141 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 10482CD54B0 for ; Tue, 19 Sep 2023 10:35:37 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.604575.942030 (Exim 4.92) (envelope-from ) id 1qiY4h-0002hQ-Ci; Tue, 19 Sep 2023 10:35:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 604575.942030; Tue, 19 Sep 2023 10:35:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qiY4h-0002hJ-9t; Tue, 19 Sep 2023 10:35:23 +0000 Received: by outflank-mailman (input) for mailman id 604575; Tue, 19 Sep 2023 10:35:21 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qiY4f-0002hD-HJ for xen-devel@lists.xenproject.org; Tue, 19 Sep 2023 10:35:21 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3a59dfc3-56d8-11ee-8789-cb3800f73035; Tue, 19 Sep 2023 12:35:20 +0200 (CEST) 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: 3a59dfc3-56d8-11ee-8789-cb3800f73035 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1695119720; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=zKZCH9nJHrXn1p8XYZtvRYn8I1OYqaz+OOrt3ynG/W8=; b=O4zxLHIMNgLIl0WcH1MoRfrNDL5AvgmVkyY9njGnIUA0euWTwom2xEY6 FgIG3lu/uTDI2HmDxykTBnIcywQalCjGCUI+mnU1UEBNFO8c6D+dGhA0M zFSq/0JnClOb+2ES0K31rnqCl/fxT6N6y8QCVunSr8F6X8cF2M8nQzUwJ 8=; X-CSE-ConnectionGUID: CLO9MMtsSBqiBvKCKx9uZQ== X-CSE-MsgGUID: MY3B9KXPRSuXwiQfbJiiKw== Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 122938254 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED X-ThreatScanner-Verdict: Negative IronPort-Data: A9a23:S8N6h61tAdU/laFkEvbD5cVxkn2cJEfYwER7XKvMYLTBsI5bpz0Oy 2YZCzvSbP2NYWT3eY9/bI3i8RwB75HcnINqSVFopC1hF35El5HIVI+TRqvS04F+DeWYFR46s J9OAjXkBJppJpMJjk71atANlVEliOfQAOK6UbaYUsxIbVcMYD87jh5+kPIOjIdtgNyoayuAo tq3qMDEULOf82cc3lk8teTb8nuDgNyo4GlD5g1nNKgR1LPjvyJ94Kw3dPnZw0TQGuG4LsbiL 87fwbew+H/u/htFIrtJRZ6iLyXm6paLVeS/oiI+t5qK23CulQRrukoPD9IOaF8/ttm8t4sZJ OOhF3CHYVxB0qXkwIzxWvTDes10FfUuFLTveRBTvSEPpqFvnrSFL/hGVSkL0YMkFulfKkVpp Nk9NCs2RAmCrfyV65GrG/Rev5F2RCXrFNt3VnBIyDjYCbAtQIzZQr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ujzk3wWI6kdU11bSjWWAhGflo4jHSCkhC8xH7LgpCCfk1w== X-Talos-CUID: 9a23:UAsBimmbbBX2bYRhAfzsMOR9snnXOVb56yb1BlOjMkxwSZeLanSz6PJ5ofM7zg== X-Talos-MUID: 9a23:ElNzCwSMPPf+qnydRXTJtWpIZeRY256VFXASkKwIseuFNA9vbmI= X-IronPort-AV: E=Sophos;i="6.02,159,1688443200"; d="scan'208";a="122938254" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu Subject: [PATCH] x86: Fix check_ist_exit() assertions Date: Tue, 19 Sep 2023 11:35:14 +0100 Message-ID: <20230919103514.1076888-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 The patch adding check_ist_exit() neglected to consider reset_stack_and_jump() leaving C and entering one of the Xen exit paths. The value in %r12 is stale, and depending on compiler decisions may not be 0. This shows up in Gitlab CI for the Clang build: https://gitlab.com/xen-project/people/andyhhp/xen/-/jobs/5112783827 and in OSSTest for GCC 8: http://logs.test-lab.xenproject.org/osstest/logs/183045/test-amd64-amd64-xl-qemuu-debianhvm-amd64/serial-pinot0.log The justification for ensuring ist_exit is accurate in the exit paths still stands, so zero %r12 in reset_stack_and_jump() to indicate a non-IST exit. Signed-off-by: Andrew Cooper --- CC: Jan Beulich CC: Roger Pau Monné CC: Wei Liu --- xen/arch/x86/include/asm/current.h | 1 + 1 file changed, 1 insertion(+) base-commit: ea36ac0de27c2a7c847a2a52c3e0f97a45864d81 diff --git a/xen/arch/x86/include/asm/current.h b/xen/arch/x86/include/asm/current.h index da5e152a10cc..2ce43e275784 100644 --- a/xen/arch/x86/include/asm/current.h +++ b/xen/arch/x86/include/asm/current.h @@ -178,6 +178,7 @@ unsigned long get_stack_dump_bottom (unsigned long sp); SHADOW_STACK_WORK \ "mov %[stk], %%rsp;" \ CHECK_FOR_LIVEPATCH_WORK \ + "xor %%r12d, %%r12d;" /* non-IST exit */ \ instr "[fun]" \ : [val] "=&r" (tmp), \ [ssp] "=&r" (tmp) \