From patchwork Tue Oct 1 16:06:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak Gupta X-Patchwork-Id: 13818427 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03A8FCEACE5 for ; Tue, 1 Oct 2024 16:08:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 09A822800B3; Tue, 1 Oct 2024 12:08:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 04844280068; Tue, 1 Oct 2024 12:08:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E044D2800B3; Tue, 1 Oct 2024 12:08:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id BE51C280068 for ; Tue, 1 Oct 2024 12:08:07 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 7C0421A16B6 for ; Tue, 1 Oct 2024 16:08:07 +0000 (UTC) X-FDA: 82625515014.30.AB537D3 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by imf25.hostedemail.com (Postfix) with ESMTP id 8188FA0006 for ; Tue, 1 Oct 2024 16:08:05 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=KHBb+TyD; dmarc=none; spf=pass (imf25.hostedemail.com: domain of debug@rivosinc.com designates 209.85.216.50 as permitted sender) smtp.mailfrom=debug@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727798791; a=rsa-sha256; cv=none; b=O58vr4zHQ6jzbn6Q+EdzBrAa0/jt04oWWz0gFiImxGUvhMCzcjwwhp9Npzg7E1o5vpsrTV 9ARCNdbAa+dGS5Vj/jZqrV+ra6TuMCKP/YTwPflA9D8i22IeteOoAKiiNE8WUBCjf6kZ2Y 1ZrI/ng5mYOMI+5Om/RFtCaFkkOCnPQ= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=KHBb+TyD; dmarc=none; spf=pass (imf25.hostedemail.com: domain of debug@rivosinc.com designates 209.85.216.50 as permitted sender) smtp.mailfrom=debug@rivosinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727798791; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=CDZ6InrT+eerMmZ4qSLMUgeWEoIog/HDXgAiPQQVAR8=; b=8B1ngX1/uS8zKBZjbtBHCDxOJex18GhjFOYiVTbr5B5DHTsTFmxBa7JArO06xXIHhKdAF1 EGek7SEenwI/rxFNPke5mw6m/JZuoXP9JhTRf0b5fpHTsY2B9pUjT3+dpKvE4D/Q4QED9L 321dJypRJftvyHvKljP1+yjaXEmHJnM= Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-2e07ad50a03so4286153a91.3 for ; Tue, 01 Oct 2024 09:08:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1727798884; x=1728403684; darn=kvack.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=CDZ6InrT+eerMmZ4qSLMUgeWEoIog/HDXgAiPQQVAR8=; b=KHBb+TyDrJqEmo6GJSEBDmrAZAl4QQimKkYgLOOgz6R8u4eeJbxf3k/R/SWHZa+51y CiTdgsV94ozg1TLOdC/DDJdFKR6KEmhy1hYy/TsTu/xlLPBHaQpcCxukev16D1gn8d+0 v4XS6BKQKNKE56SBFa/Cz14sge/AKdX5Wz3DUK6w7uPySzH9L6q+bpi4HoedN2voYIq7 zDezRLX5e3jEaDew+XI4897lyXooior6gGyQLqcRLQQCabCvDSGEZ+rVlKiDHBNek8f+ e3Kc1vUELmIoWSpMMrxkaC7tpq3aMOkZcs6R+Crw4xWSD6YEoGqMDEHuwIIlQq95ONfI 3HfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727798884; x=1728403684; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CDZ6InrT+eerMmZ4qSLMUgeWEoIog/HDXgAiPQQVAR8=; b=ldurwh7GNZfhgrWtf1rM8Xg+WoozbDftkM9ZlmO74YmXFVtbhB9EdgFCdAyTp54gKP MltYFz/dva1fFZnCrtFUsk3QKcRkYWxoyRBxP6EmRbikEBAiQnGHR8zY/4ccdQL9QuRc AqYNi4qA8Gqa92GGlA819+6JZCzH5LPx3uUOW/RHYS6cWkZ5EXd/zisKWIUL3Ze6MxmX i2qVVTrOJvGB20FqxhXo3Fg9rETgRfsKAP/uz546EBux0CD+/3E/bNQgXGz2gjbTfP/b XQpYlEd1lqJg2F+vRSHSA54QftXSBfjo54nxLWP/szC7os/Yrk7gGITYNUk30ZejEAdi o4IA== X-Forwarded-Encrypted: i=1; AJvYcCUDin3qDra1TxkwELVpj4cDOgZGoanquwe4MhvLOx3LYb1OSHufz6C1osEcIF76xxmXND8ELBhl+A==@kvack.org X-Gm-Message-State: AOJu0YzK0TuSY4EVJPHvWMot0u0j81RmD/IZ/JGzJVvcQ7Vp1zLvvoEs 4mxwogtpWl/SQ/yTbi7LqOER3mwVfupNeo7PwFPgl9waZYKl2KO5eggIRkOw3VU= X-Google-Smtp-Source: AGHT+IHXYXQ1OwFDd1dtv/2VxG8PWP7+nvRdzMjo+9YOaXZGTPtIIOVqtoUXrRFuXQYTqOg0fWXwSg== X-Received: by 2002:a17:90a:4607:b0:2e0:8bf4:f298 with SMTP id 98e67ed59e1d1-2e182cb9256mr279683a91.0.1727798884295; Tue, 01 Oct 2024 09:08:04 -0700 (PDT) Received: from debug.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e06e1d7d47sm13843973a91.28.2024.10.01.09.08.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 09:08:03 -0700 (PDT) From: Deepak Gupta Date: Tue, 01 Oct 2024 09:06:29 -0700 Subject: [PATCH 24/33] riscv/kernel: update __show_regs to print shadow stack register MIME-Version: 1.0 Message-Id: <20241001-v5_user_cfi_series-v1-24-3ba65b6e550f@rivosinc.com> References: <20241001-v5_user_cfi_series-v1-0-3ba65b6e550f@rivosinc.com> In-Reply-To: <20241001-v5_user_cfi_series-v1-0-3ba65b6e550f@rivosinc.com> To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Andrew Morton , "Liam R. Howlett" , Vlastimil Babka , Lorenzo Stoakes , Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , Rob Herring , Krzysztof Kozlowski , Arnd Bergmann , Christian Brauner , Peter Zijlstra , Oleg Nesterov , Eric Biederman , Kees Cook , Jonathan Corbet , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, alistair.francis@wdc.com, richard.henderson@linaro.org, jim.shu@sifive.com, andybnac@gmail.com, kito.cheng@sifive.com, charlie@rivosinc.com, atishp@rivosinc.com, evan@rivosinc.com, cleger@rivosinc.com, alexghiti@rivosinc.com, samitolvanen@google.com, broonie@kernel.org, rick.p.edgecombe@intel.com, Deepak Gupta X-Mailer: b4 0.14.0 X-Rspamd-Queue-Id: 8188FA0006 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: h73gztth4nay9ikqhot76nk5e88xka47 X-HE-Tag: 1727798885-205237 X-HE-Meta: U2FsdGVkX1/TASjIMkRocmRy3NW+7epLybhFwXee40rnG3kkxK6tfQxC/AFrlVDwYZdjX5+jeK+OGjWAct5TKgQWIvXmODK+DxHWjOVkZ4khYsLEa4GwU1TBmpValBhIuw7mUWZdHfKL209u6NPBe9MaPrqIRmvgLhRhJRpQq8Ef2TdYp4Es1WBhBrxccPe7kpFM/VgwBYCQjLRnyEGavb5lhaqFo63Lcq1vNP7kpgjHnC7ancVzWyjQ/7RsUOuHA8fYbM0qrKhJ35TOkodxwK3ErsfSZ5hPkBuQDghVR/KIyMy1hC2VifkBkWJxzDlwCGw+Ut3IW80HTQPJ8OBIxcdRHJZdmsjaVVQT5mBzlG9XF5PFhviblZUW/vncUcZ9WT0lb8ZiDXvFh2U0eVERS30Lz9ofjrVOBgNpxD2sST7cjUbiazzmfdat16mBJwOqplx9p+tVqhQDfcubw/jR/FsLr1yv9+WC339smPM78cEGplPgWheVhut7KIZB3q6JeyPppwvLQDliyrDJuXQotIJf2OG/WP1VY9Gg4Q/WeSrwtFA0+yEt4X0LPmBTFKAExmLX5fuSHau6LWdhOJesZxYBbI9l95XU89RjHrfsv5DbYbYg8PqU+mJxyArd7xi9gemaT3R/kYExn5SWHgJmwMD8NVAafstqNuoVHarjP8Vkie4FPp8MFEIVn3k8bLzCvvs5ua+z4YTCGbQX7tTkYxLUqFZT2kqn7qLr3cyRueDz9bbPqeU4JZs1Dtoi1+rPURz/2kJ5VxDC4htZ8NmTXJD21ddPNvND8v/mu7GuF4nBrSDU14ytJUO7Ym7olbuYRLhyK6XRY8KMnAv6KzeYiKXYSXe/AOzAXBNUpQpPlPnLzc+7g07fZCWNz5ynmk9hG+/jrZU2M7ImxKw7jiqxtM74PgptQtX6WCxse3/FsjIBk67Hcj91W9MG9+UB3xUAE34R6CBMgJ2Lo8AQJAy ZkAsPgfP J7o68hBIRVKV0O6MiyA/5N72huUVX8eavp78LvOjpcTH7WA7i9U6ugD2K0cI5HJFgC9mQZfZPuKRMdMkb9UUVreIT3f+Poy7VtgK3bUyCEeA67vnYGEBmL4LykMZx+ldkpPtlCl+QfXRrogZzxtiXip84sqUNuhhNUhFRwkQKKk9eVgK2mPMM8RlufqUO4hh2UnTCBoB3YBpB4fqGzZL3adavtJ9Nw2vumkAC6KLdixpo02YjONXB1DSILGaqf5Id86pXpbKS9DOp3ytUoD01jUSO6DZD158kz1QDdKWMqF15NgEVMc3HQI4OYyLvIFOuipKU/+7zpVEcGKtoDapyRIzhhx1c1XXZC8jKtmaaosgmwfroB2hNRjR8y+GL6V6nO2oTq54238oyYnoFxqWalPvjT0vck6VL26Jv2iolG5DITOWslTVT8+atjuWqDMzD0CvGRnR7wAYMnygcoyZhr4JhP0gm67cxsCVFn+5SMzlok0Hxlp1VqFdMw6w31oVwzpqE X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Updating __show_regs to print captured shadow stack pointer as well. On tasks where shadow stack is disabled, it'll simply print 0. Signed-off-by: Deepak Gupta Reviewed-by: Alexandre Ghiti --- arch/riscv/kernel/process.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c index 5207f018415c..6db0fde3701e 100644 --- a/arch/riscv/kernel/process.c +++ b/arch/riscv/kernel/process.c @@ -89,8 +89,8 @@ void __show_regs(struct pt_regs *regs) regs->s8, regs->s9, regs->s10); pr_cont(" s11: " REG_FMT " t3 : " REG_FMT " t4 : " REG_FMT "\n", regs->s11, regs->t3, regs->t4); - pr_cont(" t5 : " REG_FMT " t6 : " REG_FMT "\n", - regs->t5, regs->t6); + pr_cont(" t5 : " REG_FMT " t6 : " REG_FMT " ssp : " REG_FMT "\n", + regs->t5, regs->t6, get_active_shstk(current)); pr_cont("status: " REG_FMT " badaddr: " REG_FMT " cause: " REG_FMT "\n", regs->status, regs->badaddr, regs->cause);