From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id 341DB3858D20 for ; Wed, 29 Jan 2025 07:06:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 341DB3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 341DB3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::632 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1738134396; cv=none; b=hvzEnf15AFymWO15ZnME+t5/EkcVZ1NMShOYaMAPBDnZv21zXXrEcp6tGQY4zgIZINhI5XlurT2oI+7QPTjPZt56PpeLakf4xlkBWcqpNtCe4LVH4J3T+ilrtcWAiAtHVusWpCpcnhgD82qmNi3dhlCNtlAVWIPJFarOngkMXIM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1738134396; c=relaxed/simple; bh=TFQfFEZdgWcMN8ffKhgn4tJzp9ra6dFSxOdARFsXJsI=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=LZ+0syZB1zXyT9psvKHbBhdWBJiUo3LV9MMTKZgzMc0pmFUj/iOsrriN6yCBLNBEcoGAHNJ8Ay+Em4d7iXOvfCxzQ3KisX6SiBCfPmhz7HN6emRELMpwyO4l+ererY2umId8eMKdTLWAi75YRlQdDal6pHSn6rWkHlYPyvadkaU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 341DB3858D20 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=google header.b=gxbOSzfw Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-aaf0f1adef8so1129867666b.3 for ; Tue, 28 Jan 2025 23:06:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1738134395; x=1738739195; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=wouYIQJTHufH1I7z6WidBXbVJKITVjIfpPeYVN54Ec4=; b=gxbOSzfwxIOyYL8Qsi38AgD1u+ugS9Jswhon5qAUtgUrX+5dcuOlB1K4DtMyxfn8uK u3X+teLWVNqGs4P0U6jPG7Zp5x2bh/ihaSSXUwTixT0fEXcavJvAesIkOrTSzZ9LTzTb 3evHS30TV6muHy7nOPMbCMHGc8+YDw8hDnXVYpdfiJGu1z0QezqwEVM0vcjB1WTABjpf KPZR7egiJK1RG5ayeNd5JPrkUdYHhjH092nfeLXOgRaW7LPUPbYSp8crFKZOMlcsw4Cw EXc2wAS1ZVVp+brsReqETZ3OYvFhw0xUhfeFL71Hd2GOvWqV8NBkQ5rMFLF9qDYcNhXo oRhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738134395; x=1738739195; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=wouYIQJTHufH1I7z6WidBXbVJKITVjIfpPeYVN54Ec4=; b=lT8ZOL6pQOvAncO51LDoW2cOG0knxxyeZIwY0Qo0PXx7LKAARzD12/7rtWry++8TAE YUvpomq7GNZ8flt70OOQHscc9a46tIAdlqz/u7k9mb+3BJH0VbvKBK9otaiahKc704rC CROT0jnvMTPyWpCaeg2Q/cRcW16C+IGP7ee8/4NmJ//pXBA0bpctzCa8Ty3sI+XaeqrE FEv1a9oP6IQSWr4q6V+b7PUKfixDUJIl3jchaVZdM3kY0LHgDWV5GpFdYpmQpd82zFpb QTzgdqIA66DXCdSAomlY34pYLwDGNkkTDq/9IvnjTXGv4UHvL9Y5YxAWB6+qA0WBUKHb FRLg== X-Gm-Message-State: AOJu0YzDajbGpnZHR6N8JIxFyL+hIP+pblN9B585N/obRNOCXre/1TsQ dA/TLP9CE2+Dte9sQJbwRMADOnDnyrQsbd3JuuWXBT4qo8ZiQat04LUZJb8yRkgSKZHDb6jVeI0 = X-Gm-Gg: ASbGnctStUyN9Yzxz9kjwCYHj+TFJgEJWTv4GeUdbnGmwoxlegZCrg3/RlFMrXpOz8E FjgNlzhulhgroM6KkfEQzGl92AVag31XIM90Dy19+nNfGZGBjCaZSMcRpsanzYvuSX3UsCuGbbi G/oFvi2Bsq5EsQNIvpc28itvJXz49pGymGr5ng0iM8GPKY/kpEew7TNfTfAEfZrT2kyrb9FEONY W5gO0CjZwyDcXM5q8LdoRlTJcQgWceyYCLX68EV1fbLMyzGRWWhRn4Ju3tU7w+UpzO21aSEPGYu c/t1C8rykl5VqbeZRNIcr+Jp3Evr1jRD1ZVBlwrIoBGVpMTws/TsXU40qchFKIpZ0dkoVbfl7/S u X-Google-Smtp-Source: AGHT+IH3ElMRK1zma/XsCzyhq+XLq4ZYlRWYjeuxAMnanABMWwAB0P74KwkhSA02BdoK5RcGSbISzQ== X-Received: by 2002:a17:906:3455:b0:ab6:d59b:614d with SMTP id a640c23a62f3a-ab6d59b86cbmr54046366b.23.1738134394730; Tue, 28 Jan 2025 23:06:34 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab675e5ca68sm925261966b.38.2025.01.28.23.06.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Jan 2025 23:06:34 -0800 (PST) Message-ID: <9ed0d494-f962-439a-ae25-604fa544c0cf@suse.com> Date: Wed, 29 Jan 2025 08:06:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] gas: sframe: partially process DWARF expressions in CFI_escape To: Indu Bhagat Cc: binutils@sourceware.org References: <20250128005722.2970354-1-indu.bhagat@oracle.com> <10038860-1fd8-4b2c-95ad-dcb215c23691@suse.com> <7cf14752-9aa3-4c7a-9293-88f493a4b475@oracle.com> <83efd6ce-4363-4f63-89c3-7d107ab55b25@suse.com> Content-Language: en-US From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3022.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 28.01.2025 19:09, Indu Bhagat wrote: > On 1/28/25 7:31 AM, Jan Beulich wrote: >> On 28.01.2025 16:24, Indu Bhagat wrote: >>> On 1/28/25 12:03 AM, Jan Beulich wrote: >>>> On 28.01.2025 01:57, Indu Bhagat wrote: >>>>> + switch (op) >>>>> + { >>>>> + /* Of all the possible opcodes expected here, it is safe to >>>>> + ignore DW_CFA_expression and DW_CFA_val_expression, provided they >>>>> + do not impact the SP / FP register. */ >>>>> + case DW_CFA_expression: >>>>> + case DW_CFA_val_expression: >>>>> + /* Both DW_CFA_expression and DW_CFA_val_expression instructions take >>>>> + two operands: an unsigned LEB128 value representing a register >>>>> + number, and a DW_FORM_block value representing a DWARF expression. >>>>> + For the current purpose, we simply need to know the register >>>>> + number. */ >>>>> + e = e->next; >>>>> + /* Keep in sync with the behaviour of cfi_parse_reg (). */ >>>>> + gas_assert (e->exp.X_op == O_register || e->exp.X_op == O_constant); >>>> >>>> ... you're asserting on user input here. Afaics neither is in any way >>>> enforced by dot_cfi_escape() / do_parse_cons_expression(). As to the >>>> comment - how does cfi_parse_reg() come into play for .cfi_escape? >>> >>> IIUC, the first operand of both of these opcodes (DW_CFA_expression, >>> DW_CFA_val_expression) will be a register. Hence, cfi_parse_reg () >>> behaviour is being cross-checked against. >>> >>> This function only aims to process some "simple DWARF expressions", and >>> if they are benign (OK to skip), we do not warn (nor error out with >>> SFRAME_XLATE_ERR_NOTREPRESENTED). E.g. for, >>> >>> DW_CFA_expression: r1 (rdx) (DW_OP_breg7 (rsp): 136) >>> DW_CFA_expression: r0 (rax) (DW_OP_breg7 (rsp): 144) >> >> Yet .cfi_escape accepts all sorts of expressions. It's okay to tell the >> user that for SFrame this isn't supported. But it's not okay to hide >> this information behind an internal error (that the failed assertion >> will result in). > > FWIW, cfi_parse_reg () will issue an as_bad () already. I can change > the assert to if () and continue to warn and return > SFRAME_XLATE_ERR_NOTREPRESENTED. Yes please. >>>>> + reg = e->exp.X_add_number; >>>>> + /* Get the scratchpad FRE. */ >>>>> + cur_fre = xlate_ctx->cur_fre; >>>>> + if (reg == SFRAME_CFA_SP_REG || reg == SFRAME_CFA_FP_REG >>>>> + || reg == cur_fre->cfa_base_reg) >>>>> + { >>>>> + as_warn (_("skipping SFrame FDE; .cfi_escape with reg (%#x)"), reg); >>>>> + err = SFRAME_XLATE_ERR_NOTREPRESENTED; >>>>> + } >>>>> + break; >>>>> + /* FIXME - Also add processing for DW_CFA_GNU_args_size in future? */ >>>>> + default: >>>>> + /* In all other cases (e.g., DW_CFA_def_cfa_expression or other >>>>> + OS-specific CFI opcodes), skip inspecting the DWARF expression. >>>>> + This may impact the asynchronicity due to loss of coverage. >>>>> + Continue to warn the user and bail out. */ >>>>> + as_warn (_("skipping SFrame FDE; .cfi_escape with op (%#x)"), op); >>>>> + err = SFRAME_XLATE_ERR_NOTREPRESENTED; >>>>> + break; >>>>> + } >>>>> + } >>>> >>>> Doesn't all of this need to go in a loop, as a single .cfi_escape might >>>> specify multiple successive DW_CFA_*? >>> >>> The function intends to process only some DWARF expressions (basically >>> some commonly-occurring, but safe to skip from SFrame perspective). >>> Going into a loop may be necessary for opcodes other than >>> DW_CFA_expression or DW_CFA_val_expression, but at the moment, since we >>> prefer to cater to only the simple expressions, parsing the complete >>> expression is not required. >> >> No, wait. Simple expressions or not isn't the point here. The point is >> that with a single .cfi_escape you can specify any number of things, >> i.e. also multiple operations involving multiple expressions. There's >> no limit to the number of operands to .cfi_escape afaics - it could >> literally be hundreds. >> > > (Sorry I am still missing the point) > > Yes, potentially large number of operands may follow a .cfi_escape. And > for all of those, we will hit the "default:" case of the thw switch and > warn and bail out (like we are doing currently on master). > > The only "safe to skip" cases are possible when the first opcode is > DW_CFA_expression or DW_CFA_val_expression (for now). Even when others follow? You look at only the first two elements of the chain starting from cfi_insn->u.esc. That chain, as said, can in principle be hundreds of elements long, and can - aiui - contain any sequence of DW_CFA_* (including their operands). Jan