From nobody Tue Sep 9 16:58:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16812C7EE2F for ; Mon, 27 Feb 2023 04:06:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229751AbjB0EGt (ORCPT ); Sun, 26 Feb 2023 23:06:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229547AbjB0EGm (ORCPT ); Sun, 26 Feb 2023 23:06:42 -0500 Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4736B11141 for ; Sun, 26 Feb 2023 20:06:40 -0800 (PST) Received: by mail-ot1-x32b.google.com with SMTP id g6-20020a056830308600b0068d4b30536aso2874526ots.9 for ; Sun, 26 Feb 2023 20:06:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2iZgPnDq1wPjqueobf/M4oDcAkjldH92kHB/el5/Fzc=; b=j5tFynW9kqal2hVWICOdqlsKcD+vVI7wEoFzxbjy2/xCQTj05Uai+taTnQRXGpsyI8 yMESjLj9sBUznf1FOaGSt3tR/+R/d0mqELmgYbyWHXeosHGmOGjuxLik1Fo7qzLBQUPO ekV/jARW45eWDoe8h06Kiu6LvwbmkhdGzlTML7MJhSS2+BUErBovbI2KEkA8doS/IyzB YFnrYs9GwnWkmn5V478Tjvxd6NW5PLcnjsD8KDSu/0e8kl/gbVqHuqW+mCxzZyTIUrSo XXFn1QZ710zsozmnsfDTFX8sHtMFkJrZHWQZdb+cVN6W0tEv8Z8QFbpF8eoVtnNw6Hin MWzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2iZgPnDq1wPjqueobf/M4oDcAkjldH92kHB/el5/Fzc=; b=51eCq1MhJOK0iHXcCfzCLL4SUAJ6ssCCx1Fxx4dtPjpm1Nko/8ca8ep6FW9DteTwQn T1CxVvNfLv/0YwkommPUevO6KEFbQ//pI2S1CYGiBRB/Ao4DU3hBQWNhLHUtw63B8QsV hzTsqGMAOBELjeXplcZR8YcyYZd925oKALg8GV41JIScNPFlUcAvcNv1sGKvBeNiAbmv jebHy/hiLlUseaky0pa/GFQabcWj60kFrmssevDqcbGYf0kzIWRKajW4/rC5U8xRrq9p w8biEv1+vqianQo3J8lXZ1gRjUgO2PgXIfPokhJylZxe7AVmfe8NDknR6uqD2Y/rNnRx c16g== X-Gm-Message-State: AO0yUKXDXmU3PiudfXFfAFRilQ1Xp8ZJgFyLwZhZ5nzts79tRKlqk02d f0/SL377fU9na+GH9CL8lBdCkldkFG3AjTvZ X-Google-Smtp-Source: AK7set8p4y0b4YAe33oiCrG1LUD1gNe24YhWPYU7qv5koyxlDrt3YPn3c6QLAh0DJAZGAAl+4OXogQ== X-Received: by 2002:a9d:37c6:0:b0:688:4670:e964 with SMTP id x64-20020a9d37c6000000b006884670e964mr6856648otb.27.1677470799390; Sun, 26 Feb 2023 20:06:39 -0800 (PST) Received: from localhost.localdomain ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id j19-20020a9d7f13000000b00690dd5e7345sm2219589otq.26.2023.02.26.20.06.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Feb 2023 20:06:38 -0800 (PST) From: Glenn Washburn To: Jan Kiszka , Kieran Bingham Cc: linux-um , Richard Weinberger , Johannes Berg , Anton Ivanov , linux-kernel@vger.kernel.org, Andrew Morton , Glenn Washburn Subject: [PATCH v3 1/2] scripts/gdb: Correct indentation in get_current_task Date: Sun, 26 Feb 2023 22:05:59 -0600 Message-Id: <2e117b82240de6893f27cb6507242ce455ed7b5b.1677469905.git.development@efficientek.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There is an extra space in a couple blocks in get_current_task. Though python does not care, let's make the spacing consistent. Also, format better an if expression, removing unneeded parenthesis. Signed-off-by: Glenn Washburn Reviewed-by: Jan Kiszka --- scripts/gdb/linux/cpus.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/gdb/linux/cpus.py b/scripts/gdb/linux/cpus.py index 9ee99f9fae8d..e8d2a62ff119 100644 --- a/scripts/gdb/linux/cpus.py +++ b/scripts/gdb/linux/cpus.py @@ -163,16 +163,16 @@ def get_current_task(cpu): task_ptr_type =3D task_type.get_type().pointer() =20 if utils.is_target_arch("x86"): - var_ptr =3D gdb.parse_and_eval("&pcpu_hot.current_task") - return per_cpu(var_ptr, cpu).dereference() + var_ptr =3D gdb.parse_and_eval("&pcpu_hot.current_task") + return per_cpu(var_ptr, cpu).dereference() elif utils.is_target_arch("aarch64"): - current_task_addr =3D gdb.parse_and_eval("$SP_EL0") - if((current_task_addr >> 63) !=3D 0): - current_task =3D current_task_addr.cast(task_ptr_type) - return current_task.dereference() - else: - raise gdb.GdbError("Sorry, obtaining the current task is not = allowed " - "while running in userspace(EL0)") + current_task_addr =3D gdb.parse_and_eval("$SP_EL0") + if (current_task_addr >> 63) !=3D 0: + current_task =3D current_task_addr.cast(task_ptr_type) + return current_task.dereference() + else: + raise gdb.GdbError("Sorry, obtaining the current task is not a= llowed " + "while running in userspace(EL0)") else: raise gdb.GdbError("Sorry, obtaining the current task is not yet " "supported with this arch") --=20 2.30.2 From nobody Tue Sep 9 16:58:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E337C64ED6 for ; Mon, 27 Feb 2023 04:06:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229775AbjB0EGy (ORCPT ); Sun, 26 Feb 2023 23:06:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229640AbjB0EGn (ORCPT ); Sun, 26 Feb 2023 23:06:43 -0500 Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C35DA10AB2 for ; Sun, 26 Feb 2023 20:06:42 -0800 (PST) Received: by mail-ot1-x334.google.com with SMTP id cc12-20020a05683061cc00b00693daa9016fso2897760otb.2 for ; Sun, 26 Feb 2023 20:06:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=flnML7b+bSQRGsvQ8NZIpa8v6ijknaB9o2IhQpg86OM=; b=HydNKyWBQ6INfb8aCWugSFRRQyXuUfSnrsfrPH0qpTanBmBdOmE1ChbsPcS5RlCnAU L7YgU3avoC/d1NOa46vC/Z+gc+YxTaWNe26fm4YZo8BuRs119GWsZVkQnITEc9jwc0kX 4sVWLWm601f2CzphpW/FitMhVF2j+c/f23fPhsMcXbyEvyIuBJGiDKDo7l7DW6YOq09H X5SB4lV3tIB46+TqV1VsXybHxVk1T84M+hsxfnC+YU97M/vKPdhsTHYx/nqM1G7SiU4/ CMPuvLCgFmIwyxgHgd5J7sXnfAD48nipqDexhVH0QL/7pBPar+sw5XaUQ9wMO6GnjsQF bczg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=flnML7b+bSQRGsvQ8NZIpa8v6ijknaB9o2IhQpg86OM=; b=W0pEkPyqn78OiM/aWBSSreSjlZX/1dge9s8Q9oueUXY/E0vry6u47VA/UD66lVPGfw wSJW5UAJ49IrZ9LTcCT7oKjVDsN8jdZys3xxI3tF7Gfi0qLtFlOf9I+RHTWjzGCSJxWO MnzMIyBsYGNsMF3O/cyeR9udsy7DFoEf6/z+rPzJzvaYS0TYrG3J63vt052VchfrqjYp VsbENQEI6gGEa9NQ1tYA3q18PpaJ9Y3hAMpiJuja1dKnq5QQQ5n2TMtswZoroWqvYWOq BlUGYRwMYBKsnutFaCHWevrsLGD1jHQk+4QR1UxcSJN6rR6PQ/McC+yqs54LZ8KaseHy nlFw== X-Gm-Message-State: AO0yUKUdoq9RohJe3k84FIQSu6IPtUI0+nzvLMnn9NPG3nl3lo3IX5aR spiLWw4mQM4/huzMnFbNkJBOPJZYGQWv8qMq X-Google-Smtp-Source: AK7set9J0nTW4hS4HuqvLTM2KAs1wmypF/nBiEPT9XNeaZovonDhj8PaKB0xQUZm95HarPWlm8HBNg== X-Received: by 2002:a9d:1cb:0:b0:690:edd1:a86 with SMTP id e69-20020a9d01cb000000b00690edd10a86mr12439347ote.7.1677470802128; Sun, 26 Feb 2023 20:06:42 -0800 (PST) Received: from localhost.localdomain ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id j19-20020a9d7f13000000b00690dd5e7345sm2219589otq.26.2023.02.26.20.06.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Feb 2023 20:06:41 -0800 (PST) From: Glenn Washburn To: Jan Kiszka , Kieran Bingham Cc: linux-um , Richard Weinberger , Johannes Berg , Anton Ivanov , linux-kernel@vger.kernel.org, Andrew Morton , Glenn Washburn Subject: [PATCH v3 2/2] scripts/gdb: Support getting current task struct in UML Date: Sun, 26 Feb 2023 22:06:00 -0600 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" A running x86 UML kernel reports with architecture "i386:x86-64" as it is a sub-architecture. However, a difference with bare-metal x86 kernels is in how it manages tasks and the current task struct. To identify that the inferior is a UML kernel and not bare-metal, check for the existence of the UML specific symbol "cpu_tasks" which contains the current task struct. Signed-off-by: Glenn Washburn Reviewed-by: Jan Kiszka --- scripts/gdb/linux/cpus.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/gdb/linux/cpus.py b/scripts/gdb/linux/cpus.py index e8d2a62ff119..255dc18cb9da 100644 --- a/scripts/gdb/linux/cpus.py +++ b/scripts/gdb/linux/cpus.py @@ -163,8 +163,14 @@ def get_current_task(cpu): task_ptr_type =3D task_type.get_type().pointer() =20 if utils.is_target_arch("x86"): - var_ptr =3D gdb.parse_and_eval("&pcpu_hot.current_task") - return per_cpu(var_ptr, cpu).dereference() + if gdb.lookup_global_symbol("cpu_tasks"): + # This is a UML kernel, which stores the current task + # differently than other x86 sub architectures + var_ptr =3D gdb.parse_and_eval("(struct task_struct *)cpu_task= s[0].task") + return var_ptr.dereference() + else: + var_ptr =3D gdb.parse_and_eval("&pcpu_hot.current_task") + return per_cpu(var_ptr, cpu).dereference() elif utils.is_target_arch("aarch64"): current_task_addr =3D gdb.parse_and_eval("$SP_EL0") if (current_task_addr >> 63) !=3D 0: --=20 2.30.2