From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id C02C23858C62 for ; Mon, 28 Nov 2022 15:07:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C02C23858C62 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca Received: from [10.0.0.11] (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 3EC541E0CB; Mon, 28 Nov 2022 10:07:33 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1669648053; bh=vgZKzOUsF8e1xcgcWhw2dguVN/8KqW/Fgpcx9xgvGbI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=hBfHK95TP44IkjmRb5xY3/iDUcsF4VOxaDmRC5srTKFpdXc8KXHIklAi80qnNWT6B KdbDd29wn/tuKUrMjy+Y+o0ljkD3DBLGLtIBOvJZTLaUFnua2onEiWLpMOU+kBJ3Ap dP9TvIvgmZM+Ivc4P1tx9ahJ67BvfNHWGsNaX9cQ= Message-ID: <43979fb5-a40b-9dd8-f4e6-bde0a598e505@simark.ca> Date: Mon, 28 Nov 2022 10:07:32 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH v2 2/6] gdbserver: Add PID parameter to linux_get_auxv and linux_get_hwcap Content-Language: en-US To: Thiago Jung Bauermann , gdb-patches@sourceware.org Cc: Luis Machado References: <20221126020452.1686509-1-thiago.bauermann@linaro.org> <20221126020452.1686509-3-thiago.bauermann@linaro.org> From: Simon Marchi In-Reply-To: <20221126020452.1686509-3-thiago.bauermann@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,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 11/25/22 21:04, Thiago Jung Bauermann via Gdb-patches wrote: > This patch doesn't change gdbserver behaviour, but after later changes are > made it avoids a null pointer dereference when HWCAP needs to be obtained > for a specific process while current_thread is nullptr. > > Fixing linux_read_auxv, linux_get_hwcap and linux_get_hwcap2 to take a PID > parameter seems more correct than setting current_thread in one particular > code path. > > Changes are propagated to allow passing the new parameter through the call > chain. Thanks, this is ok, with the following nits fixed: Approved-By: Simon Marchi ... unless Luis is strongly against it. > --- > gdbserver/linux-aarch64-low.cc | 7 ++++--- > gdbserver/linux-arm-low.cc | 2 +- > gdbserver/linux-low.cc | 18 +++++++++--------- > gdbserver/linux-low.h | 9 ++++----- > gdbserver/linux-ppc-low.cc | 6 +++--- > gdbserver/linux-s390-low.cc | 2 +- > gdbserver/netbsd-low.cc | 4 +--- > gdbserver/netbsd-low.h | 2 +- > gdbserver/server.cc | 2 +- > gdbserver/target.cc | 4 ++-- > gdbserver/target.h | 2 +- > 11 files changed, 28 insertions(+), 30 deletions(-) > > diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc > index db5086962612..a6ed68f93029 100644 > --- a/gdbserver/linux-aarch64-low.cc > +++ b/gdbserver/linux-aarch64-low.cc > @@ -823,12 +823,13 @@ aarch64_target::low_arch_setup () > if (is_elf64) > { > struct aarch64_features features; > + int pid = pid_of (current_thread); > > features.vq = aarch64_sve_get_vq (tid); > /* A-profile PAC is 64-bit only. */ > - features.pauth = linux_get_hwcap (8) & AARCH64_HWCAP_PACA; > + features.pauth = (linux_get_hwcap (pid, 8) & AARCH64_HWCAP_PACA); Avoid adding the outer parenthesis. > diff --git a/gdbserver/target.h b/gdbserver/target.h > index 18ab969dda70..fe7a80b645bc 100644 > --- a/gdbserver/target.h > +++ b/gdbserver/target.h > @@ -175,7 +175,7 @@ class process_stratum_target > /* Read auxiliary vector data from the inferior process. > > Read LEN bytes at OFFSET into a buffer at MYADDR. */ > - virtual int read_auxv (CORE_ADDR offset, unsigned char *myaddr, > + virtual int read_auxv (int pid, CORE_ADDR offset, unsigned char *myaddr, Please update the doc of the method to replace "from the inferior process" to from "process with pid PID". Simon