From patchwork Fri Mar 29 04:44:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak Gupta X-Patchwork-Id: 13610065 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 69C27CD1283 for ; Fri, 29 Mar 2024 04:46:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E83206B00BA; Fri, 29 Mar 2024 00:46:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E31D46B00BC; Fri, 29 Mar 2024 00:46:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C5DDD6B00BB; Fri, 29 Mar 2024 00:46:56 -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 A187F6B00B9 for ; Fri, 29 Mar 2024 00:46:56 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 66198410B3 for ; Fri, 29 Mar 2024 04:46:56 +0000 (UTC) X-FDA: 81948841632.14.F902BB5 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf23.hostedemail.com (Postfix) with ESMTP id 94E75140012 for ; Fri, 29 Mar 2024 04:46:54 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=NfQz715x; spf=pass (imf23.hostedemail.com: domain of debug@rivosinc.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=debug@rivosinc.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711687614; 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=Cq1CSuTaMxvWM87Thd+u9NfRT381xElf57qxmCs9O/Jpy/UUr3DgqCvV77OB5vOw+t6ct5 ryYP5/iHE8l+xMaZJRgaYDUbPY8reCPyoucqHRxjIi2xQU1scc+puy4elcY12HsxIdcU8d LytZtvnHk/NfpB0HKJS2jTSoU5by0sg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711687614; a=rsa-sha256; cv=none; b=Jr8ZPzxD4Axccbq/M/EPy2a8MKdwgnZ/bbbjTJJjYcpmsXmBipV+fZHMAZ1VeQEoejOkr5 Fo+O8GQA9MbkjcoaqiRoCNXEt3WMyNJppqjuo8cgcU7zB2P0jOIbvgs7cJ2ELVO4Zjejhw 1XWRFaeEkAAXvQ/WuQnbtD5mXloOQyk= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=NfQz715x; spf=pass (imf23.hostedemail.com: domain of debug@rivosinc.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=debug@rivosinc.com; dmarc=none Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6e73e8bdea2so1540786b3a.0 for ; Thu, 28 Mar 2024 21:46:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1711687613; x=1712292413; 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=NfQz715x7U7Z36kOeZJdfAfv4gZ4Wg0b4LBLbLdE6YtY5NGas0w5t529qJthsphsc5 u/ovrHtzHxfZ5NOFPe01ToxgmndAMdOr8qrJvnFz2xJamU39++Ojj0nMNaxBrB2xR80o U44USr6FsdFG+HKW0uQglEY55r42tlqDcnl+2mpSvl7c0B5vCj7AGdVozhD73U8opmk2 847U+zSCs6/EJT20zWcP6XPKjICULNbHZrWE6IOVP6S7CkZoNddLTbrgGiBD8A4v9RZs DG5LOHatsm9vxMVgpqAvXN9qKdikqa8pjaROy4a/hrDjCmSi07ZsshppCXKNEjRD03qF N2Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711687613; x=1712292413; 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=FsGgkMqE+YkRq32AgUo3bhp+d57LxqQZr02WDd5+C4c2k4BcA5vPJhBEWzoSLFewk+ EgWgVf0LXxSVxfH30/ae+3uiiGSUXQIAtUKOKt9qUy9LIcle3WjZNsLiHLWHxMKp8ntx KQz4dgK2msXVvQXcAfu9KP/gNwJOTq+c/Gb7Op6slfXOkv7bWeYxZBMk9CP8VjqPjBh/ 95Gquu3l1KlfM2rSL2UGtDtiy1qaXp0yhlqRXkUPxhOxA1hRcmX2+1qgaHexlGMugT8U EyxMIZLiaaoDVdceuirGT2U3OLxXjPe49GW9l1vXqgdjZZN0uDY++NrjK117qiSdJ2q4 YegQ== X-Forwarded-Encrypted: i=1; AJvYcCX+9eh0i0cyCJMU8BvtuddV3M1R0w1XyM19HRXGRlKBYjNc0e/NMqXI4FWHMH2NB98dydVtuRaLckRMFrs/EKbY/jM= X-Gm-Message-State: AOJu0YxD823WYWEHIdKxSbfDMPnrNNsrJWNHQYpGS/DEGIqCKcHeWNEN hotgk7z0SqWEhvqzQeNozc7XLG+7FB41grTfHawhyTYDkLaE9eoB9BqBCTQ1B4M= X-Google-Smtp-Source: AGHT+IFBk57ft/Dc+APgv9AeEcPOk/3EIqo0N/RGN7QySteb+aQBmtUdNC7Hb3LMWHIl2juUfBH7Ig== X-Received: by 2002:a05:6a21:151b:b0:1a3:dc13:9146 with SMTP id nq27-20020a056a21151b00b001a3dc139146mr1392928pzb.8.1711687613465; Thu, 28 Mar 2024 21:46:53 -0700 (PDT) Received: from debug.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id i18-20020aa78b52000000b006ea7e972947sm2217120pfd.130.2024.03.28.21.46.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 21:46:53 -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, palmer@sifive.com, conor@kernel.org, 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 Cc: corbet@lwn.net, tech-j-ext@lists.risc-v.org, 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 v2 21/27] riscv sigcontext: adding cfi state field in sigcontext Date: Thu, 28 Mar 2024 21:44:53 -0700 Message-Id: <20240329044459.3990638-22-debug@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240329044459.3990638-1-debug@rivosinc.com> References: <20240329044459.3990638-1-debug@rivosinc.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 94E75140012 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: tascu7mjzaa48tqo8gbd8gk4e1st3qsg X-HE-Tag: 1711687614-665975 X-HE-Meta: U2FsdGVkX189DoNgjkO0DdQaKDZdvKXI8fF2XaHPvacmhJp6AJqkFTgR5OHwaBjsUGjE3Jjl/RfBslNOr7Zfp42DpC66UjC5wAyJbuA3Yg8nQpcaxdIGF5K7H16bKpBe+RVVe8lz+peKzrXoeVw+aZLB12di8Zb8pbL5veCkppXCy4saUE+K++BDwJ+VnMBx8Et7Xs9yWeOzbTy9XtL5R/J9hBgW9f5ApdJwrmJGyKr0VRo9OMj97Jhv3K3b7UX7Ir6A4qKNhqfQea01GcdXmdkUApogtvzQqk/clbE2/XLlNO5lT6oTTBnU8bgeAxl4PXhOdSjwm8wB01aO2BzdgdKuhMyI1fnhFWBUtea9thLah+Twm1DLgxGpMriI4dV33cTvjXbjz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ufPZYE8NUb5FiptbkUsmqviQ8K7K3sLgOGl+pMrmlg= 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;