Fix incorrect DCHECK in CET contexts

This DCHECK() was not correct. When dumping a process with CET
enabled the cetumsr and cetussp registers are not available in
the context obtained for the exception record. All contexts to be
written to a minidump must have the same context format so those
registers will be present for captured threads. It is therefore ok for
the context to expect extended xsave registers but for them to be
zero in some cases.

Bug: 337665168
Change-Id: If7e5f40fe8eda6799b034991cb87e89437cb4821
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5507588
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
This commit is contained in:
Alex Gough 2024-05-02 09:51:39 -07:00 committed by Crashpad LUCI CQ
parent 76badd4c20
commit dc489055ed

View File

@ -367,7 +367,11 @@ size_t MinidumpContextAMD64Writer::ContextSize() const {
bool MinidumpXSaveAMD64CetU::InitializeFromSnapshot(
const CPUContextX86_64* context_snapshot) {
DCHECK_EQ(context_snapshot->xstate.cet_u.cetmsr, 1ull);
// Exception records do not carry CET registers but we have to provide the
// same shaped context for threads and exception contexts, so both 0 (no ssp
// present) and 1 (ssp present) are expected.
DCHECK(context_snapshot->xstate.cet_u.cetmsr == 0ull ||
context_snapshot->xstate.cet_u.cetmsr == 1ull);
cet_u_.cetmsr = context_snapshot->xstate.cet_u.cetmsr;
cet_u_.ssp = context_snapshot->xstate.cet_u.ssp;
return true;