From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f172.google.com (mail-dy1-f172.google.com [74.125.82.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E08B40C5AD for ; Fri, 15 May 2026 21:15:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778879755; cv=none; b=ovPxtVAhuxAPKoQSK9YR/4nAIOqdtn8Lzbu8cslW/I23QcPM1A+MI3Wr3u9AsSBD60sCDUxFmXne2sGa5PcKLyyQ9GAjNk+kxsGb0MdXCtvcGX+FTPhMQiYnr6uMPhBAUMqkvsNYYfXzhPQQd6OZzuvqDSNDlJMclrGB1n8H5dE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778879755; c=relaxed/simple; bh=k11liqjn7SKCyf9jqrs9rTU6kFg+eJg4IVC5ddHmpkI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OIjc6D/GPfXJWuwACytF/km+7ts/5vPIIffXzua6Rad8ZkD136rNu2UBIsMkL+hqmLmK+IKxSKmX73X2S3Nv4GPrhZNej3eoxyLLN7POTr6G5D7Z6Xpyx869KeMhNkeHnxQQ+tq0NCVNigdcXTyRrvRkDJUcisNcr91++6XzY10= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MW3f6p1L; arc=none smtp.client-ip=74.125.82.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MW3f6p1L" Received: by mail-dy1-f172.google.com with SMTP id 5a478bee46e88-30246cfd41aso1516329eec.1 for ; Fri, 15 May 2026 14:15:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778879753; x=1779484553; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d0sYZnhQeLyzvjO7vpNeSMDXaPgGF/81BOZ3a8GGZZ8=; b=MW3f6p1L5kudegGCItpuYAXS0RaiDi4aNt4p22EfgX11pgRsZn0lkRN/b11rRXCWh4 Timw43kcCzZdNRr8jfGYUIrLHf+Zq71fP9atGwGnaPZPEuqF3JRXOybBWGN4Bcj7+wZV pJXY/7KvNXuCNw2IDafGifFgt/qPqSJgSY4Fyjg3I1GtfYy446IuqHKyhO1W93TZhUv0 I3XOK9esj/N/vrNMe11n9gSuwnxhphCC0RvnmwruX4gebJ+nWhpgGJcvAQ9cDtmshGJX SYNUKSX8YPQrZ/gxyiK/aMBuXXZaVh9FhVgzgM56noTmG9GcF6/S4kcU1vGe9grQL/2I yu8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778879753; x=1779484553; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=d0sYZnhQeLyzvjO7vpNeSMDXaPgGF/81BOZ3a8GGZZ8=; b=a6AiI6DmfI/lKd31PT5USnSxug6OMe7ilICrfyfK4xGGPIVPbcRWnOTA16VqP4oIzT pUsJzVUjiXfFBttAI/WLzcdle/RSuznxSqaaiYKaDoUTXYwXEaDYihLaY4VqoXJHmuEQ Fhh90snX/P7iIT/1wgtF1p+mS1f7pAH9hi4PqQA6TapkmvKXkYUVqRpn7/KYhVo1z/8W Ncw5YYkENhhLYNP3Alic7K1ewEOtlw3/8NVGzdYHQPU/6aoklEYz8NOg0YQsm537a+rn 41UZCdwm9FJOflvml7mvbr6t13GxCfy5aUr6V4Q9UeXj7azlToEOP80081OOz59sCpNc 1EgA== X-Gm-Message-State: AOJu0YzENTIx6GeUgSp/CzCPTF+24Xc8B1fz7qt9Q96PkHEqBuvgKAqZ EGxVK9q57eetUJy+XdgRYgY06TQsXv8V/pU9UkK79evVRmXY0xDBl6yq4H0lBPxy X-Gm-Gg: Acq92OHLIxe7adHFLoLCJRY8mzPeL3PQBWy1pP8WqrkqZN7p62iDUP+2vMmTjaK2kFE s8lhlJAx73VKLtFnfdk9cV0vtArS07N1BXSl0WoQqx5ln9eKxg/snabDijM6k/F4uYFKdtm/NPo emqqUpycZ5jcljgDjsaR4OMyZiMjOziVR3JlmUAxVjuIU+e7XoFYxdorFhcc1EfHdSdTv//ZPZO VHZvFnVF1ncOS2oUURqgp+XHyd903o9onosRbvlQzM3sZ3l9lJ+OOLnY/o5RNSWWwR4GLgmYdbK MQKGxOjNVoaq/njlwHU9quOWWxcZ2F05D9Za6VFa++RLam7BhwpSbtugG4Ru2lbB8xg5hi2vKZT enn6RT0c0TG8nHurHcF787JnSNfGNz4kuQYqKGYdOFNqcMBYdQydp2KCtgqOU0xU++3FRbaj7Pk aMQMYXvKzpbmtWyrA5or+EjlGo8UJrmT8FvycK+hHvJA== X-Received: by 2002:a05:7301:290f:b0:2da:7e33:9261 with SMTP id 5a478bee46e88-3039869b7b3mr2853046eec.27.1778879752504; Fri, 15 May 2026 14:15:52 -0700 (PDT) Received: from mimas.lan ([2603:8000:df01:38f7:a6bb:6dff:fecf:e71a]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-30297bbc9a3sm8132550eec.31.2026.05.15.14.15.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2026 14:15:52 -0700 (PDT) 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, iommu@lists.linux.dev Cc: ross.philipson@gmail.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, corbet@lwn.net, ebiederm@xmission.com, dwmw2@infradead.org, baolu.lu@linux.intel.com, kanth.ghatraju@oracle.com, daniel.kiper@oracle.com, andrew.cooper3@citrix.com, trenchboot-devel@googlegroups.com Subject: [PATCH v16 35/38] reboot/slaunch: Secure Launch SEXIT support on reboot paths Date: Fri, 15 May 2026 14:14:07 -0700 Message-ID: <20260515211410.31440-36-ross.philipson@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260515211410.31440-1-ross.philipson@gmail.com> References: <20260515211410.31440-1-ross.philipson@gmail.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 If the MLE kernel is being powered off, rebooted or halted, then SEXIT must be called. Note that the GETSEC[SEXIT] 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. Co-developed-by: Daniel P. Smith Signed-off-by: Daniel P. Smith Signed-off-by: Ross Philipson --- arch/x86/kernel/reboot.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c index 6032fa9ec753..87835706bb4f 100644 --- a/arch/x86/kernel/reboot.c +++ b/arch/x86/kernel/reboot.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -779,6 +780,12 @@ static void native_machine_restart(char *__unused) if (!reboot_force) machine_shutdown(); + /* + * The comments for slaunch_finalize() provides the explanation for the + * conditions required to do the SEXIT op reflected in the conditional + * parameter do_sexit. + */ + slaunch_finalize(!reboot_force); __machine_emergency_restart(0); } @@ -789,6 +796,8 @@ static void native_machine_halt(void) tboot_shutdown(TB_SHUTDOWN_HALT); + slaunch_finalize(1); + stop_this_cpu(NULL); } @@ -797,8 +806,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); } @@ -826,6 +839,7 @@ void machine_shutdown(void) void machine_emergency_restart(void) { + slaunch_finalize(0); __machine_emergency_restart(1); } -- 2.47.3