From patchwork Wed Apr 3 23:35:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak Gupta X-Patchwork-Id: 13616817 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 890CCCD1292 for ; Wed, 3 Apr 2024 23:42:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 47C7A8D0002; Wed, 3 Apr 2024 19:42:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4045F8D0001; Wed, 3 Apr 2024 19:42:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 195F28D0002; Wed, 3 Apr 2024 19:42:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E096E8D0001 for ; Wed, 3 Apr 2024 19:42:39 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id AA1CAA0ED3 for ; Wed, 3 Apr 2024 23:42:39 +0000 (UTC) X-FDA: 81969847638.18.7772C4E Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf26.hostedemail.com (Postfix) with ESMTP id D11F3140011 for ; Wed, 3 Apr 2024 23:42:37 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=y7L0XcN7; dmarc=none; spf=pass (imf26.hostedemail.com: domain of debug@rivosinc.com designates 209.85.214.178 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=1712187757; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Qc6tDQVZMFWZI8yrez6t0wejTQ8xJVxgJAnHf9JsPCA=; b=d2oWt9LDdgEXqZoqmgtZyb5OtVc0MRfnGzJdb6Z6vKHJadWsIEmd9S4vMRFa0a0l8lMCfZ kZYF6oVO2YJW6rq3ZAJDdwcBseLaCzlSFxT7qMnxlrwAKSX2ndKHjPob+oD3Zb4/OseYcY QHN3Gd3n/+7MbFtBTwFeTKIbILvW5v8= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=y7L0XcN7; dmarc=none; spf=pass (imf26.hostedemail.com: domain of debug@rivosinc.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=debug@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712187757; a=rsa-sha256; cv=none; b=lz9fMBjMNXtvB6p+DzoW4HF8o1rU5mqtIEolqW6tmmtg1zBGozehe03EJOGN2ZUH1H1j0i qssyG8Xww/+V7MYD1yrt79sSzUkIYX7GiQuNf5HNVCk9wEQ9xZJBYsTC/ytOCAmzK1OyaD 89iPmK5XfZVmKA5nTGJCivwZIuM93mI= Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1e244c7cbf8so3460095ad.0 for ; Wed, 03 Apr 2024 16:42:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1712187757; x=1712792557; darn=kvack.org; 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=Qc6tDQVZMFWZI8yrez6t0wejTQ8xJVxgJAnHf9JsPCA=; b=y7L0XcN7JL/lJ375Axwx/szC+4QBs+tXTAiIgP7n/aej4g4BceZSjr0higtgU/eCzb YsrmkNHpCIwh2myCBNcU8SguVD5En3DghfKqz76NkFmHxA1m9QHWBpFirodrYYtBmbhj 1tVg4dBT/zwPQHtrRv8P+TLTz/b0xFVQhlqvL74ZSVv1loIeDeHxhKP4aJ7dLhRragXg urHLFKp9NayyTFvPHfnYWKAswQsYxEK7I/5FSoyC55IB/vuLhY6tMgnUmDyzn8zj5G1O nwiVj20OFzx3taWO2j/7IcvDa7pLkjUX0aTK7DYxQarMtWYbshsi3CUsRaFye0ftZWwE T8fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712187757; x=1712792557; 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=Qc6tDQVZMFWZI8yrez6t0wejTQ8xJVxgJAnHf9JsPCA=; b=rLOkIv0kdy6Trjdb5vvd4w4t2F/J0t/JZ3ys+9Uy5V4BcJDAphl3wVSI90EYLou1To x68VZNXLo2nyh+7MccV5s5945ECn/0MFMDeCXXINXzSPVu+7+dct5h/hSBYypzWbUNZz 2aroSTYAP+5GWlrjv0RdC8nDoHtgoQjnYRRPa2vhuCb1O2Vl7bXIP2VSwlIcdmC+FZHh z1J7//2wF6cTgawK0DZwOtLgSFoeoXOMvwCukBFFRZxs9r4iLV5z6bBBWumkN2gOmhMP 52ea0IraqlAoGECRttxM9Cf2HAcBlWdU2UiUHIDh+z+YTWqHBxM79IoFr13hftL+Fb/O z8Xg== X-Forwarded-Encrypted: i=1; AJvYcCVL0e7xbU96V6sxmOCrY9OZMozZf8vu2Ci6fg6ZBkLH3kNvt6rjgNKIm311m7btXSTEVG8n/pHGQF+x2x2aEaOyydw= X-Gm-Message-State: AOJu0Yxhd3B8ERHBeTluapCaYKuyGm7RbPo0MP9D8PRwItvpLtGxF0II zsvgDgRSIyxkUAMJC5+eRw/R/LbTO4eRFDoEZqSog8OtSE/2o7dkG377YyBoTJM= X-Google-Smtp-Source: AGHT+IEuhCBj/2TDLKKsCyPyIBeMUKZ3rkD1bUlrx/H25eFGajkGFoQcn3/TeMJd7JPKfofV2mRlIQ== X-Received: by 2002:a17:902:d506:b0:1e0:cdbf:24c2 with SMTP id b6-20020a170902d50600b001e0cdbf24c2mr951254plg.29.1712187756641; Wed, 03 Apr 2024 16:42:36 -0700 (PDT) Received: from debug.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id b18-20020a170902d51200b001deeac592absm13899117plg.180.2024.04.03.16.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 16:42:36 -0700 (PDT) From: Deepak Gupta To: paul.walmsley@sifive.com, rick.p.edgecombe@intel.com, broonie@kernel.org, Szabolcs.Nagy@arm.com, kito.cheng@sifive.com, keescook@chromium.org, ajones@ventanamicro.com, conor.dooley@microchip.com, cleger@rivosinc.com, atishp@atishpatra.org, alex@ghiti.fr, bjorn@rivosinc.com, alexghiti@rivosinc.com, samuel.holland@sifive.com, conor@kernel.org Cc: linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, corbet@lwn.net, palmer@dabbelt.com, aou@eecs.berkeley.edu, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, oleg@redhat.com, akpm@linux-foundation.org, arnd@arndb.de, ebiederm@xmission.com, Liam.Howlett@oracle.com, vbabka@suse.cz, lstoakes@gmail.com, shuah@kernel.org, brauner@kernel.org, debug@rivosinc.com, andy.chiu@sifive.com, jerry.shih@sifive.com, hankuan.chen@sifive.com, greentime.hu@sifive.com, evan@rivosinc.com, xiao.w.wang@intel.com, charlie@rivosinc.com, apatel@ventanamicro.com, mchitale@ventanamicro.com, dbarboza@ventanamicro.com, sameo@rivosinc.com, shikemeng@huaweicloud.com, willy@infradead.org, vincent.chen@sifive.com, guoren@kernel.org, samitolvanen@google.com, songshuaishuai@tinylab.org, gerg@kernel.org, heiko@sntech.de, bhe@redhat.com, jeeheng.sia@starfivetech.com, cyy@cyyself.name, maskray@google.com, ancientmodern4@gmail.com, mathis.salmen@matsal.de, cuiyunhui@bytedance.com, bgray@linux.ibm.com, mpe@ellerman.id.au, baruch@tkos.co.il, alx@kernel.org, david@redhat.com, catalin.marinas@arm.com, revest@chromium.org, josh@joshtriplett.org, shr@devkernel.io, deller@gmx.de, omosnace@redhat.com, ojeda@kernel.org, jhubbard@nvidia.com Subject: [PATCH v3 22/29] riscv sigcontext: adding cfi state field in sigcontext Date: Wed, 3 Apr 2024 16:35:10 -0700 Message-ID: <20240403234054.2020347-23-debug@rivosinc.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240403234054.2020347-1-debug@rivosinc.com> References: <20240403234054.2020347-1-debug@rivosinc.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: D11F3140011 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: yg5ms9qe7a73fmg4a9szdrdk3ked1a19 X-HE-Tag: 1712187757-750605 X-HE-Meta: U2FsdGVkX1/cG95Vx1l6it61/0K9ZN5nCCzIJ5aHol7L/aIj3ak7jQBrFayZ/QCz2HpqmcZlEZQHcVaSEvg9HjFHEG4YqZ0w1AcPmWFrqeSyglnY4ArQ4pUiPMfJMPgZFa3Pr20HTcmHx1hgEJDubCKA4PU73bmGDFOF7q3EooulMryetT12xYKBjDsp2opMoU9XXYUM+9493fhBW7M7ZATlFn0dYccyZ2NKu/5aqZ/qW5jvHPizSYeikM7R6JoAu/kfBB8DqwLy9DGnLE6TuhX3USd8zKXE8+5KW/fBLKSCUlwy7+aVovPOKpitu8jeUhwMisXwlMOYwqAfY7F5ZkxJsbrhRix0jhICxMaTggPpwnAk2AFizPNQ4La5Uj5Vrw6aYx+xFQ3/oUT3G/lkWvB5vjVa9EhpBax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sIKISbAVlJOFkivd3oE= 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: Shadow stack needs to be saved and restored on signal delivery and signal return. sigcontext embedded in ucontext is extendible. Adding cfi state in there which can be used to save cfi state before signal delivery and restore cfi state on sigreturn Signed-off-by: Deepak Gupta --- arch/riscv/include/uapi/asm/sigcontext.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/riscv/include/uapi/asm/sigcontext.h b/arch/riscv/include/uapi/asm/sigcontext.h index cd4f175dc837..5ccdd94a0855 100644 --- a/arch/riscv/include/uapi/asm/sigcontext.h +++ b/arch/riscv/include/uapi/asm/sigcontext.h @@ -21,6 +21,10 @@ struct __sc_riscv_v_state { struct __riscv_v_ext_state v_state; } __attribute__((aligned(16))); +struct __sc_riscv_cfi_state { + unsigned long ss_ptr; /* shadow stack pointer */ + unsigned long rsvd; /* keeping another word reserved in case we need it */ +}; /* * Signal context structure * @@ -29,6 +33,7 @@ struct __sc_riscv_v_state { */ struct sigcontext { struct user_regs_struct sc_regs; + struct __sc_riscv_cfi_state sc_cfi_state; union { union __riscv_fp_state sc_fpregs; struct __riscv_extra_ext_header sc_extdesc;