Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1720880ybh; Thu, 23 Jul 2020 16:25:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwN6GdrS86z7XvC+9OOVD5X2mWoLonb+6ftdr7eiYyuKELDUnPcNMWQXWuLXngn32R3/hie X-Received: by 2002:a05:6402:1c10:: with SMTP id ck16mr6520491edb.72.1595546743941; Thu, 23 Jul 2020 16:25:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595546743; cv=none; d=google.com; s=arc-20160816; b=pJySVwmfE5Qsg2SiLPPBUIPyb/pvUKej/FFQuGqhHTkt4n13NhTGSAhgaeENiT4tc6 QgBv7hMH7CPOR6pCiM6dp01VG70IwWsdbfcH80UVWiorBVl+QePFl+fbq3Re/lE1aUkF rC8N97y9Pyh3ziIVWPQA3uiey4yWbykjpI+5TmLlpa4kvrCwP/jINkdY72wgqfbvwFoc Z3Y6uSR3Yn1PpCBuXPQE08hHtoW7FTTWuq15Ojf9JOx4vV1JuqL7KkvhLbsysuAhXA1n dNiKuOPia+5Vm8RnYq2CGyCbrhM1/x032vHLBtcUBcxd8KNWm1DBzx2Tut+BoilQIgfR b3fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:wdcironportexception :ironport-sdr:ironport-sdr:ironport-sdr:dkim-signature; bh=rkg+qAyEuBtAA1cbuksIPkT/6bIWeO93PiPv/wolbAw=; b=IEXlnUhrC38QEgSii9uXG2D7mMUR9fbvTyuK2uc1XgOZmEgsSs4umszEOPTXIz0XGK ZqlPQcmT/+fe5dAcpCTyM2WHTjn0RVIVHj5QNb0hhX2+YdfcKHKBCWbFv90Q9srla/W2 jMqvxliG5WDsD6tnf8swrOInTx+clnkx6YMpbC2JAbeWj668oHAvlpjDPjAqqal/VW7u n3tQqXkQsW0f5fDou8o2XHZDbCHqwM/Zr7Kpi5f5OEvRQscwPwEA9A8XpZaoemhUXEaF D6LWN2kos9esCRzf4f24avq0aSK3mN4wn9ipj/kDJpsBCV1ssYt4j/9m+KZ4wkxRtMOx B2IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b="oud/p3Pa"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f21si3315585ejl.362.2020.07.23.16.25.21; Thu, 23 Jul 2020 16:25:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b="oud/p3Pa"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728229AbgGWXWU (ORCPT + 99 others); Thu, 23 Jul 2020 19:22:20 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:53896 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726723AbgGWXWT (ORCPT ); Thu, 23 Jul 2020 19:22:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1595546539; x=1627082539; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=/iyoglcxkS318Sg6qJHiPt3/SwDfA+JjozFFVeV5pMY=; b=oud/p3PaQA2IdECPHtFnsW/vYe9neqgVM0hNfVbUTDAGNNyXIvlL6h44 XL5hQaOolJNAFw/Wvx6ys11fJa6frBG1q8kADPZVeWLPtkSZxf85ZOwuz jwfVzVX8522wBpaL/TwuRxGhmvoU3qT5tseW8yZ3zS2zEdZXgbEEUdenK VpWONNnA4qnoRsradMe5p9/tmHz3kJ8h8g2U3E36lP2NMa0hPnqBAewoo gLSBx/sMIgF5WQNa+V+LulvRzcOS1ojsvAfUzC8bKqjoNVgXZrsRuK34j 6kogCB15refiqLv9fOhJuiUI/DUB2MINi98HVbyFlACgqgf6GRGJuNk4i Q==; IronPort-SDR: E6xkxJhAvk9IlxlmmSNdZvH60YJz0d86nUEb+WOlVOVOWlmPoC1UU1Z7TvxOeXJ7whK45egdpJ mZfBUXqp2OA3qVlY+oVog6Ouusc80hYpMzTCg+q1x7LPlnO7rKVD9lkmQUrOfmX2Ve8NxS5kWm 3+O1Weph0AMGPrwFAZo1JxFn7vopuVLZjr3kn9CxlpPrVxqalFOGB4I1BFyvJ0rij95RRKknlc 4tnj3cgA2cF08C2Jrhor8mVUMydx3dTDcblT76YB9dY4OKsVo5TQNMJ/iuC7HbUAGM+szMz2Cx SR4= X-IronPort-AV: E=Sophos;i="5.75,388,1589212800"; d="scan'208";a="252546067" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 24 Jul 2020 07:22:19 +0800 IronPort-SDR: IdIlcPUalfm/E3xDxAJnovdA1QJlRREpBk3ZaOD4vPpIxTIfYPQ/TrBqH5v1IZyPLH7Ot5Hsgj MSVAd6M7mz/vKe12i5bB53cZ9xXT/Rk8E= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jul 2020 16:10:33 -0700 IronPort-SDR: jN5CtwZpnd+5N/goMHUWZJYQbmHItg8c2A91kwQxZACRbomktFOQsOgxQ5XD6qEzTP31o6d/nC A3tRmg5flFsg== WDCIronportException: Internal Received: from unknown (HELO redsun52) ([10.149.66.28]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jul 2020 16:22:18 -0700 Date: Fri, 24 Jul 2020 00:22:15 +0100 (BST) From: "Maciej W. Rozycki" To: linux-riscv@lists.infradead.org cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 1/2] riscv: ptrace: Use the correct API for `fcsr' access In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adjust the calls to `user_regset_copyout' and `user_regset_copyin' in `riscv_fpr_get' and `riscv_fpr_set' respectively so as to use @start_pos and @end_pos according to API documentation in , that is to point at the beginning and the end respectively of the data chunk to be copied. Update @data accordingly, also for the first call, to make it clear which structure member is accessed. We currently have @start_pos fixed at 0 across all calls, which works as a result of the implementation, in particular because we have no padding between the FP general registers and the FP control and status register, but appears not to have been the intent of the API and is not what other ports do, requiring one to study the copy handlers to understand what is going on here. Signed-off-by: Maciej W. Rozycki Fixes: b8c8a9590e4f ("RISC-V: Add FP register ptrace support for gdb.") Cc: stable@vger.kernel.org # 4.20+ --- arch/riscv/kernel/ptrace.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) linux-riscv-ptrace-fcsr.diff Index: linux-hv/arch/riscv/kernel/ptrace.c =================================================================== --- linux-hv.orig/arch/riscv/kernel/ptrace.c +++ linux-hv/arch/riscv/kernel/ptrace.c @@ -61,10 +61,13 @@ static int riscv_fpr_get(struct task_str int ret; struct __riscv_d_ext_state *fstate = &target->thread.fstate; - ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, fstate, 0, + ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &fstate->f, 0, offsetof(struct __riscv_d_ext_state, fcsr)); if (!ret) { - ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, fstate, 0, + ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, + &fstate->fcsr, + offsetof(struct __riscv_d_ext_state, + fcsr), offsetof(struct __riscv_d_ext_state, fcsr) + sizeof(fstate->fcsr)); } @@ -80,10 +83,13 @@ static int riscv_fpr_set(struct task_str int ret; struct __riscv_d_ext_state *fstate = &target->thread.fstate; - ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, fstate, 0, + ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &fstate->f, 0, offsetof(struct __riscv_d_ext_state, fcsr)); if (!ret) { - ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, fstate, 0, + ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, + &fstate->fcsr, + offsetof(struct __riscv_d_ext_state, + fcsr), offsetof(struct __riscv_d_ext_state, fcsr) + sizeof(fstate->fcsr)); }