From mboxrd@z Thu Jan 1 00:00:00 1970 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 E3F79C10F1A for ; Thu, 9 May 2024 19:16:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1EC436B0088; Thu, 9 May 2024 15:16:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 19C486B0095; Thu, 9 May 2024 15:16:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 063976B0096; Thu, 9 May 2024 15:16:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DE3A86B0088 for ; Thu, 9 May 2024 15:16:37 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 60797C0184 for ; Thu, 9 May 2024 19:16:37 +0000 (UTC) X-FDA: 82099814034.12.AEA1923 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by imf10.hostedemail.com (Postfix) with ESMTP id 89FD7C0003 for ; Thu, 9 May 2024 19:16:35 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=kGOJUsuO; dmarc=none; spf=pass (imf10.hostedemail.com: domain of debug@rivosinc.com designates 209.85.214.180 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=1715282195; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WRd0Lx0MMpPCEzZHJ+gP+MBiwgoDsG5pFDJFXbEvS5E=; b=jcQtO44+ZZo4KBtzwsjVODvF7BtDrTOyLaSDiQChLvW/+gW9i8w09M9KMhBHaWKUBHCfJ0 4G9xsqFM1b0DnZsVlUozMUC4djKcSIJMXhrsHGl5PqgI2/udm2zuRMjHInvM3CA5ra3BHJ 8ioFNyRcJwgE7kZM4/w4Ek2chhHdM3g= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=kGOJUsuO; dmarc=none; spf=pass (imf10.hostedemail.com: domain of debug@rivosinc.com designates 209.85.214.180 as permitted sender) smtp.mailfrom=debug@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715282195; a=rsa-sha256; cv=none; b=MetzjHpiyQzxoaUuDE9+Fuug4KiHC3Q617WsjRR8vv2MCaZe+660bc0LXki8xRtnE1JxDL j4/+K4z2j1UKJA+BwNv5j289sURYDvyVMyZqr71vpkodRwEXqtFVnjJ9wgL7OG6hgeYZ0H Fup5uajtLIeKey5sS+ePMgQ4kKgUaP0= Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1eb0e08bfd2so8386525ad.1 for ; Thu, 09 May 2024 12:16:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1715282194; x=1715886994; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=WRd0Lx0MMpPCEzZHJ+gP+MBiwgoDsG5pFDJFXbEvS5E=; b=kGOJUsuO7CMU3X7o+cJtD9LD1jbP2Zd1UcThZMJLz+SIiUYrLdODNozKjWo2ypm1Gv N8ZoBsaOP16UyRCtzF+RpEXVeK49znEDBgx5zFa8igxEr/jPNbyp52pI+GiZE8wQo1aZ YkgJ9LLJYWPJU1HFOrHvrBQ2TrNhtWjPIS7HSCDVRJH5IYp3l40A+Vip3pRo9NmeklCR cLroHTqzaWSRFXNRFGcdbb4yN4EVY3DiyX8cxt0jlcogmMrzDYGHd26vCunH9AF1QI/6 ySYNLMneAlFUUTIMbZHw+i9eq2MxkDTyKJTL9Y9V4H/ucdANn+3VyyUMYXPPh26iTOO4 rQXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715282194; x=1715886994; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=WRd0Lx0MMpPCEzZHJ+gP+MBiwgoDsG5pFDJFXbEvS5E=; b=XMhKvk1krjUdP7S4bkYGFJMISqYvMCel7fGIRq0pSLTauQsHDAzpHvC4BZ+NF+806i oJMyRFCxIvUZBnrzklleYMIpoCx/3FuqEpNnH0Ix7FFsCcTPPc/CuiK04qO1tNXw5FCm vw2M/v0cKYRDLHw9S+zxsnnlhCR6sBV8ZpGfdLWdlVBqI0ywMscrIO7LpOCvlTYev8Gh OxCk35SBtFTK5GX/SQq/566SbQhtAyp8kSqAbXPauu+qIu+90zPTjtaC+KPss3EE8UPg pdqUJtGCW78iGqSz/GWxEJlz7QgwZ4wPikkF2ocd0Up11Hp7DuJPQHT6MGCkTv9oGGdX IfAg== X-Forwarded-Encrypted: i=1; AJvYcCWbap+FXysdND0tNgKgl1OdN7KpUOsXlJ0ZPI62/ncvEXdDFamiVEzBfJStKuclSC6K87mQgBXLqBuZ07uuhOj2REg= X-Gm-Message-State: AOJu0YxbM8rKDd5tjp3Uga/eQf6/tvRVP2kG/s+S+F+hOZQpdTc5heWX e3zGW2RCTyce0VsyUvBWlhYgYXP6ibMQUZ7JJBnSCFq9YjzFv2TYeThUsfDGp38= X-Google-Smtp-Source: AGHT+IGVLZ1hk7FPNudPJKafIIo2jYjbH8+I3TnNil7Sy8OT8DfcbS5dMB3RJTTTCW5vQbF2H1ruBQ== X-Received: by 2002:a17:903:191:b0:1dc:de65:623b with SMTP id d9443c01a7336-1ef4404b8cdmr7695675ad.60.1715282194292; Thu, 09 May 2024 12:16:34 -0700 (PDT) Received: from debug.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0c13692asm17812885ad.252.2024.05.09.12.16.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 12:16:33 -0700 (PDT) Date: Thu, 9 May 2024 12:16:29 -0700 From: Deepak Gupta To: Charlie Jenkins Cc: 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, 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, andy.chiu@sifive.com, jerry.shih@sifive.com, hankuan.chen@sifive.com, greentime.hu@sifive.com, evan@rivosinc.com, xiao.w.wang@intel.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: Re: [PATCH v3 29/29] kselftest/riscv: kselftest for user mode cfi Message-ID: References: <20240403234054.2020347-1-debug@rivosinc.com> <20240403234054.2020347-30-debug@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 89FD7C0003 X-Stat-Signature: ifru7iefydf3ae8kgsdfyq5phxh4dh6c X-Rspam-User: X-HE-Tag: 1715282195-543574 X-HE-Meta: U2FsdGVkX1+LVoPTYONlW2VSF374n1UASw/uvgZYV/AzQQGY3IbrwOIrpt5ifrZXjxjFkO+O7W3gqYkdTpc26XJ0Yw8Pn3FRJyEu9ByO3uCnAg2C51mOzoWAAqv9th504uVXru0P9Qq4DpTsYhEvsv4RzKRwpwdvE79uDGnDKSOUh7NTjdR0ZIgbtkPiSnBIo9tpM2vfmrgV9hhjxAUuneEcwCA16JxA/oEZCUgLy+zPCE7tt3+DO2qdaoZoltm13lfyH8q+JpJMSg9n9Q3MRM5ZDnpyOJdMJjJd+w2kKUfaviDD7IiCsz7kxOAyQGkIDvKj7yD26SCiRpYKUesM1XmbHoHiNEvIbbac9Ost+O80fesLDgGAd8l/5dIh0sW33WqB3folSHsZwIEUetn+64dBl6XvdiuuOytF+BQtTIepcNTRfrnZRIdEjkj2xtnsfk0Jw2wlIDMnEVHYouf0P+GQ9Q31DZJpzE80UHD/+3ChC1KBC3gmT7Zlz3kMd9LSycl4WEk6PqC/MmKy6vRcOAvHgSDDaCQjKBgQahIQ0ZZa1Kn72R043NftjsgphKkhLC73c5uS1VmgOYPj4RWiW0F8ebwlFm4G7BYnliuQ9J367QVOEtMIiw0MZLigHrpYKo2NAn+1h19r7pzZWts3c8TuXJks9lfBKEYpY0msm9niRA48U9E1pEuBs63p/5zk5+foKv58DqEfl4FOUyt8VZMqsct/OKGylfyO4uJHPGF7ooCThJJuCCBT8VXXWXCkJOhO/eGKvXCybAvtbZTCrQsISjj3Z0062R4vEfYGYUYY+qWFVWhKnwkF3aCykXSZs8Rjj3KGIXBgOr9oE5S5+RRDT/g4dqcd3PUYX4Gt1QFZfWABXKLIJ7hQGexCB15qYMBXI+1OiDdsWtGWEcciv0d3b6X8+rpePNJfsH1qxNXqBM4beJLEZME4tbBJlXgXZRK6aIspCq2xGPZZpiP MB8VcT1H 8IgQMk9/TGdPbApy3eWC3rYvuSsqroUN90RriX/ITJTGnYXbiN/oF8b3oGuXRYKrM8Yd3jK6EE3PkVwNJzDNcoFS8EOYR6v2wg/myz6ukrqW+UMdo4f8s50RPD9GP3C7/d4dO9Os6U/yd8jOx3AL2Nol9oJGjUkg7NTWGrK1Mo3ghqfCUAs174+Gd1v2vaR9XVd0ptrxxrDqyjyw2I5jwmRB5LJIJXfUxUYwbU3JpKTbx58Rt7uuIV5nIRabeoOwTJ7p0CuQC2ZA2IqTrr6rmJ295qst1Lfvb5OTXFiBFzfcqej8qbFGuDQJ63LvjT1r6TwVwgOrAQPGaf/dS/kWwtHUudk12Tgl5zLgyJuM5Ht1td4BCfE/1xW2D+t/aODOLpxc1NdpeRJbH7+TWYYIdk8+vMAkYZ3Hy4f5RKOs3F/d+vc/fgFbC0hD7x0Zu9uh02n20hF+HazZURQ6HdqysmLFwi+G1EW0aJfkU X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, May 09, 2024 at 11:21:15AM -0700, Charlie Jenkins wrote: >On Wed, Apr 03, 2024 at 04:35:17PM -0700, Deepak Gupta wrote: >> + >> +int main(int argc, char *argv[]) >> +{ >> + int ret = 0; >> + unsigned long lpad_status = 0, ss_status = 0; >> + >> + ksft_print_header(); >> + >> + ksft_set_plan(RISCV_CFI_SELFTEST_COUNT); >> + >> + ksft_print_msg("starting risc-v tests\n"); >> + >> + /* >> + * Landing pad test. Not a lot of kernel changes to support landing >> + * pad for user mode except lighting up a bit in senvcfg via a prctl >> + * Enable landing pad through out the execution of test binary >> + */ >> + ret = my_syscall5(__NR_prctl, PR_GET_INDIR_BR_LP_STATUS, &lpad_status, 0, 0, 0); > >There is an assumption here that the libc supports setting >INDIR_BR_LP_STATUS but does not support the standard prctl interface >defined in . my_syscall5() is defined to fill in gaps in >the libc, so this test case should also set the status manually rather >than relying on the libc. > >I don't think it's necessary to define my_syscall5() since every libc >should have a prctl() definition. However, these CFI prctls are very new >and glibc does not yet support (correct me if I am wrong) it so these >prctls should be enabled by the test cases. In one of my previous patches, it was setting landing pad and shadow stack enabling directly via handcrafted prctl macro. I changed it to check for status for following reasons - If this binary is compiled with landing pad and shadow stack option then toolchain being used already has libc with shadow stack and landing pad enabling - Currently upstream glibc toolchain dont have support but libc with toolchain has the support. In case of shadow stack enabling, macro is needed and `prctl` function can't be used. Because you enter `prctl` function with no shadow stack but exit with shadow stack and will lead to fault in its epilog. Due to all these reasons, kselftests have to be compiled with toolchain with cfi codegen and thus libc should have support to light them up. Here tests only checks if they are already lit up, If not it fails. Although you're spot on one thing here, since this test is assuming libc already lit-up landing pad and shadow stack. It doesn't need macro here for status check of feature and can simply use `prctl` syscall interface. > >- Charlie > >> + if (ret)