From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3348280308 for ; Fri, 26 Sep 2025 19:57:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758916666; cv=none; b=eI8SJBiCkNHR19CwvjSLLKZrxXMkc3qlVhpwj7bRhX5FLu+ZlcjqwwNqtn133SDfe2wGmEnGm1fZEn96utcpe1DtuhD2/o7SbawoT3/7gddrdHWZiN0BPN5gmhSIy35ZYS2Lzhhfp9uaeEHCSsmcMlKlkBFUfFtKG343JrERCWU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758916666; c=relaxed/simple; bh=Ul90A3WXVjVOQtEWkwJb9B/4dc313g79jNrBflolSiA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ENzSKNFSg4qfcK4j8RsLS/OlUSWPjtSD7cVujepMSFw5GR93uMDWhGtcE0ZJAF/EvPGwl6dpasek74ogPISQ8WUqPyQt8el1LSajmUZSxStp7s8JhmwjsWqz+Jhjc2K4hbAZzhW5j8Qu4/qpkSWxL1f+oMf1P5217Uil4WatuEA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc.com header.i=@rivosinc.com header.b=aualodt1; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc.com header.i=@rivosinc.com header.b="aualodt1" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-27edcbbe7bfso25855265ad.0 for ; Fri, 26 Sep 2025 12:57:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc.com; s=google; t=1758916664; x=1759521464; darn=vger.kernel.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=zASiJDz4r3vYQO3vYDYkcyVx79ekhPk89WizJj5Iigg=; b=aualodt1PB8GaT0QZpHJ965PFhcpyeJMzNUBRv2XWnNdt8cTWcjm6LVoHEg9lgPvq6 Y6EVSKbbIzLn2glHOMhnwdRI+uGTGtXVpahrRcWiz8UH2CigIEs9C9VAy2CVf1+gHd4X me8zwNTVU5hpTV56K2l1RaCqaFLP9yBlWK1W++wrjApNcXqbCyY/GedFNndGQN+Ppawx m/HBBSrQDK5TLjqWuTj+FSBJb8UWZQBUpT9DZRYnPKyyL2ZRhAxio3tpyq+kc8n4kJXc zpqCSBODWdqUUNvxKi3MeHwqODe4NSJ7bMNGFe+DcBX5Xq1c1XUcZRSHDsZu8Q7mIEar DZSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758916664; x=1759521464; 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=zASiJDz4r3vYQO3vYDYkcyVx79ekhPk89WizJj5Iigg=; b=ISDIgHio01rS0AjrP6BeN8788X3csORcZhr3LjfUi52CX56Wp1vF59+S006D55Fcy+ URGGgdSh6IiaLvGNi4QdYRCz5BpZs+Wwa8QsbPWnw/84cZIUb5onwDAw32VJOnZffU2k 5dcMbSffI1/l3FINAF+iRKXZa/4NtG28JdqC1ONlC5/8i8i9P92RSnLg06Pf/vAK7zOU qeYEg9p7WWt9JjWKHUjdOLMSvPuWG8uPcatdJpIB88ugRNPsE/N/UPBW/+KO+3BZcRZ0 O/YKkRn5Ku8VORq2e16pIhi1VioLu2sTiH7Mik68A8VMDT8i1M8UGvaugKNiXWPEjG0A Z11g== X-Forwarded-Encrypted: i=1; AJvYcCXuGgzL2LTeWomvhnb6qsT6Dn2aurE8x1ESRFaJcmAmfltHCuVcjFkLHkFmtmOzfWFmZDwGb2GHjaLlTTw=@vger.kernel.org X-Gm-Message-State: AOJu0YwdBHjWNCDzTjc27Qdkh5crqMty1SZCeCGBiapHZIAxMRO1zlPN bGn6auP4TRADayzP2MZSJxh4mjXge/u+puYAc9a2roPPU1w3mIMVbsfkiavlIZC4VUo= X-Gm-Gg: ASbGnctIN/8xE8lRXf+pXd8pYj2Dw2PQ8ffts96BRVWXxghPV0/DgcuERPaNMHfAq9H QjydYGeVsbBtNjko5n+Mge2ixST115E/C+6QTSO2/y+6VERIUg+2qX5CZQw+W4+M4kjh3Wd2SSR z46wiSq6MFCKKHt3rm4IR5ueQuAM6nEel/f+HdnNNP5jYxVbbou5uYMSfXrOMwiqsAaaevt/s1o GDrQ1mnWLZL84owdWx9z5whTy0BqD+YqPYFTLhLnYRLmhLyMSxdg7FxMZRXLjL/Nj0HhPaXaitK WPmMoJYvrOasOTVTn8+oZvZ2OAtyrHQ2+pgDvQ8r3Ycb/Hp6Y2PriXz8vNf6IZehgDQxZVbjUeU 9b1Shk/uxp7IeE32I9zed/vA8a3cu7unFCcrJsdcb821kA9xTh3r44g== X-Google-Smtp-Source: AGHT+IHlUtnIvbNYTp+NBwFL5kAnFfogcOgIaJtDWQxwNZ7YmExERR63uIq8FMCY+Zw0lEPHKpWKJg== X-Received: by 2002:a17:903:28c:b0:26f:f489:bba6 with SMTP id d9443c01a7336-27ed4a5ec62mr76915745ad.50.1758916664000; Fri, 26 Sep 2025 12:57:44 -0700 (PDT) Received: from debug.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-27ed66d43ecsm62938985ad.24.2025.09.26.12.57.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Sep 2025 12:57:43 -0700 (PDT) Date: Fri, 26 Sep 2025 12:57:40 -0700 From: Deepak Gupta To: Charles Mirabile Cc: pjw@kernel.org, Liam.Howlett@oracle.com, a.hindborg@kernel.org, akpm@linux-foundation.org, alex.gaynor@gmail.com, alexghiti@rivosinc.com, aliceryhl@google.com, alistair.francis@wdc.com, andybnac@gmail.com, aou@eecs.berkeley.edu, arnd@arndb.de, atishp@rivosinc.com, bjorn3_gh@protonmail.com, boqun.feng@gmail.com, bp@alien8.de, brauner@kernel.org, broonie@kernel.org, charlie@rivosinc.com, cleger@rivosinc.com, conor+dt@kernel.org, conor@kernel.org, corbet@lwn.net, dave.hansen@linux.intel.com, david@redhat.com, devicetree@vger.kernel.org, ebiederm@xmission.com, evan@rivosinc.com, gary@garyguo.net, hpa@zytor.com, jannh@google.com, jim.shu@sifive.com, kees@kernel.org, kito.cheng@sifive.com, krzk+dt@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, lorenzo.stoakes@oracle.com, lossin@kernel.org, mingo@redhat.com, ojeda@kernel.org, oleg@redhat.com, palmer@dabbelt.com, paul.walmsley@sifive.com, peterz@infradead.org, richard.henderson@linaro.org, rick.p.edgecombe@intel.com, robh@kernel.org, rust-for-linux@vger.kernel.org, samitolvanen@google.com, shuah@kernel.org, tglx@linutronix.de, tmgross@umich.edu, vbabka@suse.cz, x86@kernel.org, zong.li@sifive.com Subject: Re: [PATCH v19 00/27] riscv control-flow integrity for usermode Message-ID: References: <20250926192919.349578-1-cmirabil@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20250926192919.349578-1-cmirabil@redhat.com> Hi Charles, Thanks for response. Rest inline On Fri, Sep 26, 2025 at 03:29:19PM -0400, Charles Mirabile wrote: >Hi - > >Hoping that I got everything right with git-send-email so that this is >delivered alright... > >Wanted to jump in to head off a potential talking past one another / >miscommunication situation I see here. > >On Wed, Sep 24, 2025 at 08:36:11AM -0600, Paul Walmsley wrote: >> Hi, >> >> On Thu, 31 Jul 2025, Deepak Gupta wrote: >> >> [ ... ] >> >> > vDSO related Opens (in the flux) >> > ================================= >> > >> > I am listing these opens for laying out plan and what to expect in future >> > patch sets. And of course for the sake of discussion. >> > >> >> [ ... ] >> >> > How many vDSOs >> > --------------- >> > Shadow stack instructions are carved out of zimop (may be operations) and if CPU >> > doesn't implement zimop, they're illegal instructions. Kernel could be running on >> > a CPU which may or may not implement zimop. And thus kernel will have to carry 2 >> > different vDSOs and expose the appropriate one depending on whether CPU implements >> > zimop or not. >> >> If we merge this series without this, then when CFI is enabled in the >> Kconfig, we'll wind up with a non-portable kernel that won't run on older >> hardware. We go to great lengths to enable kernel binary portability >> across the presence or absence of other RISC-V extensions, and I think >> these CFI extensions should be no different. > >That is not true, this series does not contain the VDSO changes so it can >be merged as is. Look at patch 23/27. It does have vDSO change. Although shadow stack instruction are inserted as compiled flag for vDSO only when cfi config is selected by user. Right now default is "No". So it won't impact anyone unles user explicitly says "Yes". > >> >> So before considering this for merging, I'd like to see at least an >> attempt to implement the dual-vDSO approach (or something equivalent) >> where the same kernel binary with CFI enabled can run on both pre-Zimop >> and post-Zimop hardware, with the existing userspaces that are common >> today. > >I agree that when the VDSO patches are submitted for inclusion they should >be written in a way that avoids limiting the entire kernel to either >pre-Zimop or post-Zimop hardware based on the config, but I think it >should be quite possible to perform e.g. runtime patching of the VDSO >to replace the Zimop instructions with nops if the config is enabled but >the hardware does not support Zimop. Why kernel need to do this extra work of carry two binaries and patching it runtime? If for instance we do this, and then this allow this kernel to be taken to pre-Zimop hardware, it is assumed that entire userspace for such hardware was compiled without shadow stack (thus no zimop). In that case, kernel should have been compiled without CFI option. Just for sake of thought exercise, let's say Fedora 43 is first release with RVA23 compatiblity (zimop and shadow stack), there is no way this and future release will be able to run on pre-zimop hardware. Unless redhat is going to start two different binary distribution. One for pre-zimop and one for post-zimop. If that would be the case, then compiling two different kernel for such two different hardware would be least of the worry. Only other usecase is of a seasoned kernel developer or build your own stuff in embedded environment, those users can anyways are advanced users. But it forces complexity on rest of kernel. There will be more extensions taking zimop encodings in future, we will end up patching vDSO and keep this complexity while rest of the userspace will not be patched and will be separate binary distribution (if OS distros endup distributing multiple binaries per release) > >However, that concern should not hold up this patch series. Raise it again >when the VDSO patches are posted. As I said earlier, these changes default cfi config to No. So whenever this is selected "Yes" by a distro, they can drive such patches (if there is a real need) > >> >> thanks Deepak, >> >> - Paul > >Best - Charlie >