Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp111792rdb; Wed, 14 Feb 2024 14:39:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUOGoit9KMFG0rfvUxvtCHWMo4xmrGK82BpJJNEO5lrqgjgAGcTJCTvaFYwVH63MWcGXu/A+da3w/pCenJm/na9bnR2urAAlYi8lnqaWA== X-Google-Smtp-Source: AGHT+IE+zkbF3bTLEgiwr0XPi5Pa2T8d6hDj/nJb33nCsp1CthDi7nbFmQluKMcRZ9N0ly7aR2OS X-Received: by 2002:a05:620a:13c1:b0:785:8c58:e336 with SMTP id g1-20020a05620a13c100b007858c58e336mr108970qkl.54.1707950383037; Wed, 14 Feb 2024 14:39:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707950383; cv=pass; d=google.com; s=arc-20160816; b=YEQxbUYw3vZAHJWEzGiI1alChtZR3/jjF4dSIKVY6Hd9K4bBtQBVVh9Udh8HIvMQl/ iE7KTyIW72xcKtdKyErAISJ9bGolANGkHPnH5xrCjVjiqeQVy8TA+yWgF2nxzskFFHXX tPAFftPNV7xY820kfcFg1JzgTI7WA6pBTmWgu9tUGURf6f8FHS87GFxWhZ777apdnPg7 FkGp5E2J6VV/mTXf9t7nl0Kh2gqV+//z3dMGbUzt6DQ7xyOcaFxjUAfBN2X7orIFVac5 FnDdsUJCA9N5ovyLwD3Y9FUJkrpW6ZEJ4yTVeIJmHeGaWMstoitocQw+7WDl0dgnEn8p p+yg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=PF3adVbDuDOrhrzIcst51oqzg2T1uPdLomNy2PQ/df0=; fh=8Yi9ekhrsZFPoQwI1mqYNWqkTm1Q3iUHpkig+/9/fSE=; b=Ey8m9AlkpF08P+DjEloz+/0o6oIo/gFGlUBhhxgUwsoqLhjQdTZURb6fqe5EXvpHRC 40t7FXuv60oiF9kMmeX4JhmSQZZ5kz58b9+qpAy3qNiNVjjPdsN27NNhVv7wdiVYKGWX 7Nt9TtJI8+zgHfuU6Z07P7A9+G8AFdC68Hn/5dRHRqFL88il4WfODof3ogOl7c10/eKY YKTXW0Kzimk+eSCb1WmXeOlDp2XbdKDaxIzjDTNmGjsYoMbn3WsRW3dBgBLzfv+fSozk HshIU2/eWnEP2CzksghzfHhh78uwKuxPbAOVFIy5lB6jtQ8ugKswyKbNJhz2rcJqzhT1 8BoQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=M+kRMp1G; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel+bounces-66067-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66067-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 5-20020a05620a04c500b0078715f3f27dsi114003qks.154.2024.02.14.14.39.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 14:39:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66067-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=M+kRMp1G; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel+bounces-66067-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66067-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id ADB191C21FF6 for ; Wed, 14 Feb 2024 22:39:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 522A01474AE; Wed, 14 Feb 2024 22:36:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="M+kRMp1G" Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D661E146905; Wed, 14 Feb 2024 22:36:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.165.32 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707950201; cv=none; b=RkKKWbLJCdo2w7e1uDkXkLXSkC8jjvzBmbGhA6Rqm46Q4/t3F/wXBm8TWYmMfA3XswpBmydw0KK/0+wUZJqT1qIBf/YdphyBs4+zEJtMsg9LXWOdgZFNNgKeC7rl8Ib/Q3YXYJVv4uWnh+hfGKBLa8r1pkMW+svx4bwg33KUfpo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707950201; c=relaxed/simple; bh=m2bHNpGe5r8CqcVNY8prSrxrGoSxyq4tKguYKr/hxHE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=atsfdh297p5u7+XjPuY7eHRsXMQ1NBZnAL5DW9I0QEyrBFIvZ7Doe7SQua1g/J/XYeuaTZNhSehfUuS1rUEoY83pcSx9g4SpbHZe9ltYM3tUf18auBbqlroLhCILZOF5UFu4QcrpX+r/wili4WvXxhh2FExBPpddNWqzqzelG7Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=M+kRMp1G; arc=none smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41ELibl7028692; Wed, 14 Feb 2024 22:31:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2023-11-20; bh=PF3adVbDuDOrhrzIcst51oqzg2T1uPdLomNy2PQ/df0=; b=M+kRMp1GkzQLW7EQQw+NXw8RlYqN/WQSA1Q8FMw/Wuml9/fU/ppu2q/xS5lQPY2w2moh K4L9Ml31+ixNBLLA8eUGH+4EkpbQeUQpeeIRRB8zFAV3/cZaJbTxMsQv9l08V1vGj7DU CHt1Pa35KuSpj9O1B7+z9Tnn0S9r13nzfb3N5nzV+wCf+Ao9Ing+BxIkOyZfe1WipDc9 hlDm9hHMO5IO6vwnKR7IAMHsPqqn50aKKpQ7ViruG+twXROdxv38jpIdRHI7zDGxIHyM HWqxBI53+OhdPZuMq6vaY0avHBRd6p4KbiZG6Aq29sYZcHRl1dfujSvUx7tIysQBa2dh pQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3w91f00srw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Feb 2024 22:31:44 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 41EM4k76000873; Wed, 14 Feb 2024 22:31:43 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3w5yk9n7dg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 14 Feb 2024 22:31:43 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 41EMVTVG004281; Wed, 14 Feb 2024 22:31:42 GMT Received: from bur-virt-x6-2-100.us.oracle.com (bur-virt-x6-2-100.us.oracle.com [10.153.92.40]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3w5yk9n72r-12 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 14 Feb 2024 22:31:42 +0000 From: Ross Philipson To: linux-kernel@vger.kernel.org, x86@kernel.org, linux-integrity@vger.kernel.org, linux-doc@vger.kernel.org, linux-crypto@vger.kernel.org, kexec@lists.infradead.org, linux-efi@vger.kernel.org Cc: ross.philipson@oracle.com, dpsmith@apertussolutions.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, dave.hansen@linux.intel.com, ardb@kernel.org, mjg59@srcf.ucam.org, James.Bottomley@hansenpartnership.com, peterhuewe@gmx.de, jarkko@kernel.org, jgg@ziepe.ca, luto@amacapital.net, nivedita@alum.mit.edu, herbert@gondor.apana.org.au, davem@davemloft.net, kanth.ghatraju@oracle.com, trenchboot-devel@googlegroups.com Subject: [PATCH v8 11/15] reboot: Secure Launch SEXIT support on reboot paths Date: Wed, 14 Feb 2024 14:18:43 -0800 Message-Id: <20240214221847.2066632-12-ross.philipson@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240214221847.2066632-1-ross.philipson@oracle.com> References: <20240214221847.2066632-1-ross.philipson@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-14_14,2024-02-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 mlxscore=0 bulkscore=0 spamscore=0 malwarescore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402140170 X-Proofpoint-ORIG-GUID: AdjLhihMV76srjS9pNQqdNP1KlbQKv-p X-Proofpoint-GUID: AdjLhihMV76srjS9pNQqdNP1KlbQKv-p If the MLE kernel is being powered off, rebooted or halted, then SEXIT must be called. Note that the SEXIT GETSEC leaf can only be called after a machine_shutdown() has been done on these paths. The machine_shutdown() is not called on a few paths like when poweroff action does not have a poweroff callback (into ACPI code) or when an emergency reset is done. In these cases, just the TXT registers are finalized but SEXIT is skipped. Signed-off-by: Ross Philipson --- arch/x86/kernel/reboot.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c index 830425e6d38e..668cfc5e4c92 100644 --- a/arch/x86/kernel/reboot.c +++ b/arch/x86/kernel/reboot.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -766,6 +767,7 @@ static void native_machine_restart(char *__unused) if (!reboot_force) machine_shutdown(); + slaunch_finalize(!reboot_force); __machine_emergency_restart(0); } @@ -776,6 +778,9 @@ static void native_machine_halt(void) tboot_shutdown(TB_SHUTDOWN_HALT); + /* SEXIT done after machine_shutdown() to meet TXT requirements */ + slaunch_finalize(1); + stop_this_cpu(NULL); } @@ -784,8 +789,12 @@ static void native_machine_power_off(void) if (kernel_can_power_off()) { if (!reboot_force) machine_shutdown(); + slaunch_finalize(!reboot_force); do_kernel_power_off(); + } else { + slaunch_finalize(0); } + /* A fallback in case there is no PM info available */ tboot_shutdown(TB_SHUTDOWN_HALT); } @@ -813,6 +822,7 @@ void machine_shutdown(void) void machine_emergency_restart(void) { + slaunch_finalize(0); __machine_emergency_restart(1); } -- 2.39.3