From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id VExFJlPdmGepNR0AWB0awg (envelope-from ) for ; Tue, 28 Jan 2025 08:36:19 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=IbEYVJKp; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 8CB461E105; Tue, 28 Jan 2025 08:36:19 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id B9C581E08E for ; Tue, 28 Jan 2025 08:36:18 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EE0B83858031 for ; Tue, 28 Jan 2025 13:36:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EE0B83858031 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=IbEYVJKp Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 58FDC385841C for ; Tue, 28 Jan 2025 13:35:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 58FDC385841C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 58FDC385841C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1738071336; cv=none; b=DbHC9EOFzqxzQzogl/Dl6A+DwSzmrR/UhXA/UtnicmC35Wiqzjq1FBy9nYSbA0gW4xkXnH13Omue9b0OnRuGQCtyVAFprPmDCa4rqcZGp4T2FMy9I0bOzeq07i2Wv4shTS5MIWYmYjGrNrbaUw6ThYLOh6/FxLdWrvM9u7j2KRw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1738071336; c=relaxed/simple; bh=z6Gsxikw4qsWskQsyzyt/zb2phh9RnzqB2QtlYf5cRE=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=cXA8e4j2X1R7ddGWA34SVIU+zCvPdCkUO2g43aoqiUzd94JM2KGiJ76nIhadwP5e9qaXRAr3hr2FllgLwc6x2rTPDzYEbhP5WpizNrEwsITQ8zPsFRCdrVXTpb6130tGFB6oBC25VZENlFg9aYKxT+nSlEknH0+1TW4bEMU3v4g= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 58FDC385841C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738071336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5GsE6exnTnm7F+8eQdX5o1M/KLzHyT3I0/e/80WCCWM=; b=IbEYVJKpzmX+N9PjLas/isit64QZtX2HzU+cbCjClrF3dZn2m+eY/Q7lFUaPj06/xCliMb YFXmivXwlUJqWjDcYYggHJhAddfLoXj/nCh4YXCAstDTsRDHzA+Klmm2or8bNYLXQaGHJP 82FW3vmXFOTDkbYsCmETfO3Sh0uH2XU= Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-373-5mzd6wXLO92cVH-Th-w3Wg-1; Tue, 28 Jan 2025 08:35:35 -0500 X-MC-Unique: 5mzd6wXLO92cVH-Th-w3Wg-1 X-Mimecast-MFC-AGG-ID: 5mzd6wXLO92cVH-Th-w3Wg Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-21681a2c0d5so100935925ad.2 for ; Tue, 28 Jan 2025 05:35:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738071334; x=1738676134; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5GsE6exnTnm7F+8eQdX5o1M/KLzHyT3I0/e/80WCCWM=; b=fDeTNR5zT2WXmsRKON8lnBGKB5lYNZbxbKXhhsgY701ZvwB+V+AXuXQmq7Cl02T6Cn wDA6OHKGDgWj4csGZTMwm+5EC4+6TnBMRiocUuZT7825GjK6cEfh9Z1yakK4hWrW0ZP8 g5a+x3ExlfkK13v9oZw/Ja6MA7BbgoUtMHPfuZgmA5KvoIYHTktVrsLqtXBp7xq5QSDj 6X3vlHv0kvSYR/QySsfiIoh3B2+G/kTYG/PlhOLg/JxROkJ1/r4nz0otd6B1Qthib+TC alDsspr2IzNl+Yz3RVLwtSmXIhUr4OdosTBwe8ejU0QNcf3lKTWKcZ85itkH4Bf+3spN pOzQ== X-Forwarded-Encrypted: i=1; AJvYcCXJdsyc9DCtjMDWUm1QevydZVZKvuOeyzeah/RQUM4CsIdIgOuD5qzHw4y73a/F3evm53OV5nGGxmB4qQ==@sourceware.org X-Gm-Message-State: AOJu0Yy9b7ubzsIFCA54piA2nBfMTMsKdpncVor2axgEkKxR79TMRRw4 69qEuk5XHdRpGesAMiRoABK4uNyaLCXWf1bRN+vz4HXZkItF7ZF4aEG4CkdzByeuEuFeVs1fjpz 3wrionr/AlEyUcMDCRLzFQiQyhrSnYfdDDq1E7DE1FPOtqbleLtIcEKIhEZHgebOhVaI= X-Gm-Gg: ASbGncsFBzpfOmaOYDQqRl+Zd+K1ULVe43H7uwCKjCxWPuXD6YtGF87VQfWOXkfUrap YYUMngYuuAkQkaUkhZ6aIBwaVs1F+Wj/n5XBt65RokZv4NTFhzuHXnffvf14MkAGnVne4WGkwE3 /+6JoRc4i0WE4QQohB3QlUxnX/b9l1ZccDqHUucHpeWZ2S5/WCzxPYGVsZFHXMsjSAxGVPKxd24 Xj8Ujw2l2leGhFeMqibIl2/2ZihOCUzV/l5ugebLSU7I9/pfUWMOBvIKZZvgzUuy69CgFBAKBvv LowBnqvowxH0UtUY X-Received: by 2002:a17:903:2381:b0:21a:8dec:e596 with SMTP id d9443c01a7336-21c355b54e7mr761714625ad.35.1738071332226; Tue, 28 Jan 2025 05:35:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IGekVUx/zH3aYzZxIjD7WmqS3NgoZJulcWd+XEqkK2oqI1JoA3eQTER9cpWEaoTmwjuzZk6KQ== X-Received: by 2002:a17:903:2381:b0:21a:8dec:e596 with SMTP id d9443c01a7336-21c355b54e7mr761714245ad.35.1738071331848; Tue, 28 Jan 2025 05:35:31 -0800 (PST) Received: from ?IPV6:2804:14d:8084:9a69::1000? ([2804:14d:8084:9a69::1000]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21da4141dc5sm81343805ad.113.2025.01.28.05.35.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Jan 2025 05:35:31 -0800 (PST) Message-ID: <17373ce7-75d2-458f-a9a0-dd9db428371a@redhat.com> Date: Tue, 28 Jan 2025 10:35:28 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 02/12] gdbserver: Add optional runtime register set type. To: "Schimpe, Christina" , gdb-patches@sourceware.org References: <20241220200501.324191-1-christina.schimpe@intel.com> <20241220200501.324191-3-christina.schimpe@intel.com> From: Guinevere Larsen In-Reply-To: <20241220200501.324191-3-christina.schimpe@intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Fplpm7NAEnKHKz00WktqYAEr5mihWg3hyhjizN-NBAQ_1738071334 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 12/20/24 5:04 PM, Schimpe, Christina wrote: > Some register sets can be activated and deactivated by the OS during the > runtime of a process. One example register is the Intel CET shadow stack > pointer. This adds a new type of register set to handle such cases. We > shouldn't deactivate these regsets and should not show a warning if we > fail to read them. > --- > gdbserver/linux-low.cc | 40 ++++++++++++++++++++++++++++------------ > gdbserver/linux-low.h | 7 ++++++- > 2 files changed, 34 insertions(+), 13 deletions(-) > > diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc > index 50ce2b44927..355b28d9fe4 100644 > --- a/gdbserver/linux-low.cc > +++ b/gdbserver/linux-low.cc > @@ -5007,23 +5007,31 @@ regsets_fetch_inferior_registers (struct regsets_info *regsets_info, > if (res < 0) > { > if (errno == EIO > - || (errno == EINVAL && regset->type == OPTIONAL_REGS)) > + || (errno == EINVAL > + && (regset->type == OPTIONAL_REGS > + || regset->type == OPTIONAL_RUNTIME_REGS))) > { > /* If we get EIO on a regset, or an EINVAL and the regset is > - optional, do not try it again for this process mode. */ > + optional, do not try it again for this process mode. > + Even if the regset can be enabled at runtime it is safe > + to deactivate the regset in case of EINVAL, as we know > + the regset itself was the invalid argument of the ptrace > + call. */ > disable_regset (regsets_info, regset); I'm somewhat confused by this patch. The commit message and other comments here say that optional_runtime_regs shouldn't be disabled. However, in here, if we get EINVAL we *will* disable the regset. Did you mean to use != instead of == ? I'll be honest, I don't know enough about the regset subsystem to know which is the correct option, I just think it has to be consistent. -- Cheers, Guinevere Larsen She/Her/Hers > } > - else if (errno == ENODATA) > + else if (errno == ENODATA > + || (errno == ENODEV > + && regset->type == OPTIONAL_RUNTIME_REGS) > + || errno == ESRCH) > { > - /* ENODATA may be returned if the regset is currently > - not "active". This can happen in normal operation, > - so suppress the warning in this case. */ > - } > - else if (errno == ESRCH) > - { > - /* At this point, ESRCH should mean the process is > - already gone, in which case we simply ignore attempts > - to read its registers. */ > + /* ENODATA or ENODEV may be returned if the regset is > + currently not "active". For ENODEV we additionally check > + if the register set is of type OPTIONAL_RUNTIME_REGS. > + This can happen in normal operation, so suppress the > + warning in this case. > + ESRCH should mean the process is already gone at this > + point, in which case we simply ignore attempts to read > + its registers. */ > } > else > { > @@ -5111,6 +5119,14 @@ regsets_store_inferior_registers (struct regsets_info *regsets_info, > optional, do not try it again for this process mode. */ > disable_regset (regsets_info, regset); > } > + else if (errno == ENODEV > + && regset->type == OPTIONAL_RUNTIME_REGS) > + { > + /* If we get ENODEV on a regset and the regset can be > + enabled at runtime try it again for this process mode. > + This can happen in normal operation, so suppress the > + warning in this case. */ > + } > else if (errno == ESRCH) > { > /* At this point, ESRCH should mean the process is > diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h > index 5be00b8c98c..da5aa26a993 100644 > --- a/gdbserver/linux-low.h > +++ b/gdbserver/linux-low.h > @@ -42,7 +42,12 @@ enum regset_type { > GENERAL_REGS, > FP_REGS, > EXTENDED_REGS, > - OPTIONAL_REGS, /* Do not error if the regset cannot be accessed. */ > + OPTIONAL_REGS, /* Do not error if the regset cannot be accessed. > + Disable the regset instead. */ > + OPTIONAL_RUNTIME_REGS, /* Some optional regsets can only be accessed > + dependent on the execution flow. For such > + access errors don't show a warning and don't > + disable the regset. */ > }; > > /* The arch's regsets array initializer must be terminated with a NULL