Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp10383622rwl; Mon, 2 Jan 2023 01:22:34 -0800 (PST) X-Google-Smtp-Source: AMrXdXtH5v5/EWAOZtyr0jDNw1/OMMWoNByvccaVoetW6AkKCnP127chhwscLgVpM2FAsbQrkasE X-Received: by 2002:a05:6a20:9391:b0:ad:2f8b:ed7c with SMTP id x17-20020a056a20939100b000ad2f8bed7cmr69390213pzh.56.1672651353807; Mon, 02 Jan 2023 01:22:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1672651353; cv=pass; d=google.com; s=arc-20160816; b=PIqNpP94X5ztpaUfoVx/tGslW3w/RoMKlkdHtkKSLWOXjlgoppfOxy4TBmKnSOIkHa 1Aq09DeS3PNF8l6aL94y9LJprjds24yGSk+dTpQFUqSIoQu4sb3OVOwN40csK2uw8qAy RInOKCslHsb6JMsXbBN/LMimFTpnsT1XGT2gYMymtoNfoKcPyLcpANg2grDT6vGKWeH+ T26tEXGQde5VPcjpNu95zl+3nVkPgr9BCv1O3zttbrjy/mii+hDqYrhg5Fdle9NX8nod h04+N64fE/fM8BOrn6l4/gjrfqxcG4BUF+zGYG2o09oT+PIVDHeQaSkj8E7t5r/k1Mph Sxvw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=gbylX+XHhd6SHcb5CjIqlAdk+kHMr1oxE/EtNSNK2kU=; b=dapJwWj7vtgf2Fl7sc5+tjf5YNUv59U5GWLe/+rWeRauNKQyFoTltP7IOpSiFwTQ1v Op8d7+apQ0WrSpf9XI21rvPjm7gWliXV+ZH+cQxaquK18uKcYe24cQcQ2mV3aOoTPciH 0LrVmdfkAyMSM44uIdMiyeEmGLUWkwO8w4r++M4s/hGkEymqtdu654wwpE/9qYRT6XEi /pBauTWKtlL7hvR72jS1WPwaTudHWWEGodyxomREX76e1B5kKfdlU263FvDq7h/NlZET bj1ZQQoE0KuIG7M4gwLYlEwrCzvzO6BAXyMudyTznxeQ67P21ZQXqA3a4am5yaJnfy2n 7FmA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@siemens.com header.s=selector2 header.b=Rt+7eJXh; arc=pass (i=1 spf=pass spfdomain=siemens.com dkim=pass dkdomain=siemens.com dmarc=pass fromdomain=siemens.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h128-20020a636c86000000b0043c05df34c0si29800874pgc.411.2023.01.02.01.22.26; Mon, 02 Jan 2023 01:22:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@siemens.com header.s=selector2 header.b=Rt+7eJXh; arc=pass (i=1 spf=pass spfdomain=siemens.com dkim=pass dkdomain=siemens.com dmarc=pass fromdomain=siemens.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230444AbjABJJJ (ORCPT + 58 others); Mon, 2 Jan 2023 04:09:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbjABJJI (ORCPT ); Mon, 2 Jan 2023 04:09:08 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2077.outbound.protection.outlook.com [40.107.8.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C563D8A for ; Mon, 2 Jan 2023 01:09:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k7Td/xzKuZxURMyWDgYdT3r3yP/Qwy2IBAifR2bqllXEgan52QJLXPWXNHSs4n5zkZzNgcXVJYpsPitarpNJcAfxV+0kPCxuNc8VYo0XxW9QmnIIfBo1ix7mQMwFFM2kXW9G5ZbU+kPLi6Htk55SLbxbC7+n3IpmXjzBEzKoPqJojlW26wSPnEONcMpqiNPiu29LHQojPqAwaxzSfL/GZ9MsmKlm8br/W8vZIafqBOuZ2ykpuEBZrIbIZmq7ReS9ls/hlZkqx/DuWqq+gxLWJM/1FfocQhrxopHfBhpPsS/6SsJoxenvPNqjMDt7X3oIkh+bbt31XW2q8LsIONX8yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gbylX+XHhd6SHcb5CjIqlAdk+kHMr1oxE/EtNSNK2kU=; b=eH9YrxabXOSzrYQDQEvWV75EhOwqYZpSU42CT8CX6LD+sxx3OlejPRnUmnGulrHz0BXsLClAs/citmzmPtXmfeGIDhR1qNW20iqUP6esW629PnKH0dLgulVM4Ijz1i3EF843QampOkEK526wyLjxFK1iJUs1YZQ4UKKw6fXv8Iaopa+OoLiIGrCAjFVdE4u134efbvGC/fd0u2XX7ssjgwsTLyvWEyu2m96rKEKwNGvZop1m5AX2+hdAWZg3G1zzgRiO+Z4MrQBKb9bT7Q69jekexZ60p627idZmFkud7044Ag2QOGcZVSjMYBWG89y6toEmOToGRuSpMie3bNh2IA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=siemens.com; dmarc=pass action=none header.from=siemens.com; dkim=pass header.d=siemens.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gbylX+XHhd6SHcb5CjIqlAdk+kHMr1oxE/EtNSNK2kU=; b=Rt+7eJXhVlBmDt4rViwLzDke3aLKpa2LmiUMRUazKyWpb2jsGYA//SBopah87BGiwcEBTdp5sVSraiO5u2NwQp+sXFpU2PfRHp7cCdlXd2pAWvZRoObsBhCZG40bDeNY9gpiLJO4PALDsBmDEoWJt/4HZGo7xszek1MFA7hsqkQGmJHAndU7H/rRcg7D5a5kz8DxCyQBH0xKK/UFukK/FR3g3ZZabHN5yiCxvFhZp8ws13/kLwH9fXuxaPSq/VqT1RksWPu05bxjOeAbjW1IEAxkTc+EHHaWuPFMBuV1q9UkkU11lSxovndaKN+y4nZ4YeQVEx1tEPVEAdt/O4xYCw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=siemens.com; Received: from AS4PR10MB6181.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:588::19) by DB8PR10MB3740.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:113::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Mon, 2 Jan 2023 09:09:04 +0000 Received: from AS4PR10MB6181.EURPRD10.PROD.OUTLOOK.COM ([fe80::2957:50e8:8ce6:124a]) by AS4PR10MB6181.EURPRD10.PROD.OUTLOOK.COM ([fe80::2957:50e8:8ce6:124a%9]) with mapi id 15.20.5944.019; Mon, 2 Jan 2023 09:09:03 +0000 Message-ID: <98eb5bc7-dee4-b36e-a219-17b1e08d85f6@siemens.com> Date: Mon, 2 Jan 2023 10:09:01 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH v5] scripts/gdb: add lx_current support for riscv Content-Language: en-US To: Deepak Gupta , conor.dooley@microchip.com Cc: ajones@ventanamicro.com, aou@eecs.berkeley.edu, kbingham@kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, palmer@dabbelt.com, paul.walmsley@sifive.com References: <20221115221051.1871569-1-debug@rivosinc.com> From: Jan Kiszka In-Reply-To: <20221115221051.1871569-1-debug@rivosinc.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FR3P281CA0076.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1f::14) To AS4PR10MB6181.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:588::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS4PR10MB6181:EE_|DB8PR10MB3740:EE_ X-MS-Office365-Filtering-Correlation-Id: 333d95cc-0740-4612-697b-08daeca0feb4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H4HLxANDuv29hll3lUhh174Jj3pcs4e6zxaCPi2YLoWBl3mCfDZPhghVisfOzQXpOh8nAjLtMicyfZ6ls/g3WYW2N6xE3JB/kl7XHpPcMjEBDj8nnR+F8MAA+0Y5WPaUqqTm9F6JiAuqOAiAR9nlkrvJODOejsOTTE1pwj0ek42cMYug5oWrzs/Lc8LsxU/oBaY2S8EXnLD+nlcoUN9qPeIRrbxX8hgVP7JsS/Ib5Iqg3X7i/JHOoLr5LMhcHLpuo626M2W8pz9iAfHOTkd9T4k6xKOV4K09mJm9e3oW/+pQ2WxMAXFBatwSOAzmgu91rnzwE/z17/moKH6QroUc7vKF9XMZJHV4l/xGaMdbB7m8tfO0FMGLMRjyc8r6cml0OD3SOq4FsT6KzAGXR6K18MGSI6dQpeCE2LKspvZTBbwODNfj23B3I5JDegdjhjXbJ0zFH5ItWIlgT+CuIrO/S7ojFpn4OdfP+A+Wq9yi4ZejUVr0YgQvqPJm6r81Sz/pXbfjINftp9VuFFEbrgi6QAlV6DvMkVmsutkF14cTXDa7e8W/o8VlPrJlotrpUwVXty88McTQJ9GfW7Ebzz5Dhz9AZdevX8hrxO8YzSqVYin8jks+MIcGjyqvo1qo0omUeWdJyTcrnSa7S0MEiM6g0ThJEZpr/tEjJTS/GWMFHnkkDXEE1wvqHmpM+ASHex76SIP0G13USYjEQ2QXDUvthPjL0nV9iyrsIqlFnShk6mDZYA4pwt1Fosm3h9/pympoQefMnGA92UaCDS+f+syhwA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS4PR10MB6181.EURPRD10.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(396003)(136003)(39860400002)(376002)(366004)(451199015)(83380400001)(2616005)(31696002)(86362001)(36756003)(38100700002)(82960400001)(66556008)(8676002)(66476007)(8936002)(4326008)(2906002)(44832011)(5660300002)(316002)(66946007)(6512007)(53546011)(6506007)(186003)(31686004)(26005)(41300700001)(6486002)(478600001)(22166006)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ejZOOW9DVTMxb3VQSmJKT05LaXBXcThEZ0hNSUhuT1RIOXBrOXc5MFJhQ3Ir?= =?utf-8?B?WnRBKzJqTlBxSGJVL29OZXROZ3dLUXhxeHVPSUJDbzYwS21SN3VOVGlTR1pO?= =?utf-8?B?MTg3N2NKZEI0OSt1azIwdWNZaUR1bzU5cmVsWDBUUEVIaW9sbXkvOCtCay9F?= =?utf-8?B?d3dqK2JQSGhXczZ1M1RvNlpvdVh3M250ZzVvMFFGdHFjNnkzNlJKSFhkRlVz?= =?utf-8?B?eHNBQ3prNnd2cXRLVTRzL0UzUGgra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FZUFI?= =?utf-8?B?TnRIOHppTVZBQ05pMm1Za3FLbmJ6cjVPSmdaR3JjV0lqcjZUMWpYUEJBbi92?= =?utf-8?B?WGp1NTRoME9ORGVGL2ZDWndDL1NZM3J0UXNyaXFJZzhobERyTGcwOWhMTDJu?= =?utf-8?B?UlE9PQ==?= X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-Network-Message-Id: 333d95cc-0740-4612-697b-08daeca0feb4 X-MS-Exchange-CrossTenant-AuthSource: AS4PR10MB6181.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jan 2023 09:09:03.9442 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +CtdKOoNL5uh3Yai8LZtxUID/XXGzolqWPMi2fnO9985WZ+LFZcDlUOzBSNRcbuSvpO2YiL94kInex1jyGqWOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR10MB3740 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15.11.22 23:10, Deepak Gupta wrote: > csr_sscratch CSR holds current task_struct address when hart is in > user space. Trap handler on entry spills csr_sscratch into "tp" (x2) > register and zeroes out csr_sscratch CSR. Trap handler on exit reloads > "tp" with expected user mode value and place current task_struct address > again in csr_sscratch CSR. > > This patch assumes "tp" is pointing to task_struct. If value in > csr_sscratch is numerically greater than "tp" then it assumes csr_sscratch > is correct address of current task_struct. This logic holds when > - hart is in user space, "tp" will be less than csr_sscratch. > - hart is in kernel space but not in trap handler, "tp" will be more > than csr_sscratch (csr_sscratch being equal to 0). > - hart is executing trap handler > - "tp" is still pointing to user mode but csr_sscratch contains > ptr to task_struct. Thus numerically higher. > - "tp" is pointing to task_struct but csr_sscratch now contains > either 0 or numerically smaller value (transiently holds > user mode tp) > > Patch also adds new cached type "ulong" in scripts/gdb/linux/utils.py > > Signed-off-by: Deepak Gupta > Reviewed-by: Andrew Jones > > --- > Since patch has changed a little bit from v1 and I didn't include > changelog earlier, here it is. > > v1 --> v2: > - added logic to locate task_struct irrespective of priv > - made locating task_struct agnostic to bitness(32 vs 64). > - added caching of ulong type in scripts/gdb/linux/utils.py > - added more descriptive commit message > > v2 --> v3: > - amended commit message and source line to fit column width > > v3 --> v4: > - amended commit message and remove whitespace in source > - added Reviewed-by for reviewers > > v4 --> v5: > - changing the order of changelog and sign off/review tags in commit > --- > --- > scripts/gdb/linux/cpus.py | 15 +++++++++++++++ > scripts/gdb/linux/utils.py | 5 +++++ > 2 files changed, 20 insertions(+) > > diff --git a/scripts/gdb/linux/cpus.py b/scripts/gdb/linux/cpus.py > index 15fc4626d236..14c22f82449b 100644 > --- a/scripts/gdb/linux/cpus.py > +++ b/scripts/gdb/linux/cpus.py > @@ -173,6 +173,21 @@ def get_current_task(cpu): > else: > raise gdb.GdbError("Sorry, obtaining the current task is not allowed " > "while running in userspace(EL0)") > + elif utils.is_target_arch("riscv"): > + current_tp = gdb.parse_and_eval("$tp") > + scratch_reg = gdb.parse_and_eval("$sscratch") > + > + # by default tp points to current task > + current_task = current_tp.cast(task_ptr_type) > + > + # scratch register is set 0 in trap handler after entering kernel. > + # When hart is in user mode, scratch register is pointing to task_struct. > + # and tp is used by user mode. So when scratch register holds larger value > + # (negative address as ulong is larger value) than tp, then use scratch register. > + if (scratch_reg.cast(utils.get_ulong_type()) > current_tp.cast(utils.get_ulong_type())): > + current_task = scratch_reg.cast(task_ptr_type) Why not if-else for the assignment here? > + > + return current_task.dereference() > else: > raise gdb.GdbError("Sorry, obtaining the current task is not yet " > "supported with this arch") > diff --git a/scripts/gdb/linux/utils.py b/scripts/gdb/linux/utils.py > index 1553f68716cc..ddaf3089170d 100644 > --- a/scripts/gdb/linux/utils.py > +++ b/scripts/gdb/linux/utils.py > @@ -35,12 +35,17 @@ class CachedType: > > > long_type = CachedType("long") > +ulong_type = CachedType("ulong") > atomic_long_type = CachedType("atomic_long_t") > > def get_long_type(): > global long_type > return long_type.get_type() > > +def get_ulong_type(): > + global ulong_type > + return ulong_type.get_type() > + > def offset_of(typeobj, field): > element = gdb.Value(0).cast(typeobj) > return int(str(element[field].address).split()[0], 16) Looks good to me otherwise. Jan -- Siemens AG, Technology Competence Center Embedded Linux