From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAFD22FD7A3 for ; Thu, 4 Dec 2025 17:19:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764868755; cv=none; b=H3Xiz1ruVd+2CeXpQmOQ7y0fdVzChUmWmcM8no9AbeWaxreY/ABEB9L+gAsXL+C4TuHcBNCye/3qdrrA7uFol5f3Fo1XyHnSpbJKZaP/bsqYQgBWybvuPrhCXi+SDsF5GJhYqMWOfbQXcZUNe3RoLW7dMDkY7sf84j3AYVrShLk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764868755; c=relaxed/simple; bh=tbhl1hB6Go7cKeEzi9fq0ksxVXWeewQm1ULfbDi4zC4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=drC/a3l6Lj68z4QBDZcsrTc8TQLSBf1CPYF7i9uOWqa9NyjneqKizSngX8bp2DqJSGbs3PllXk7OXhy1o94Qf6gRmZ0pl+mxoTdpLe785vyQnDdA+30/bQDscBCgtJt7iZJMvptluP+T4x7xS8WqpLKHEJntIRrGNjVBCoFsetA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=TS5lSMNY; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TS5lSMNY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764868751; h=from:from: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; bh=tbhl1hB6Go7cKeEzi9fq0ksxVXWeewQm1ULfbDi4zC4=; b=TS5lSMNYD35/wAmr4rMYBl+UllFP4mLh2L185PF1q4woIPAbSZsz8L1x5lqeq9LaYONq2W 01NQ8rgBBbkU0xhqnI1dzbvhxlTa0QsnUf8EX8feBKyKLCfptQF6NGNYArP9WJjkwe2l4e Y7GMbbyrKy7gIYf/Q3PibphGczpFohQ= Received: from mail-vk1-f197.google.com (mail-vk1-f197.google.com [209.85.221.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-694-_nRSLfdDOeeZdPXmbhp0Ig-1; Thu, 04 Dec 2025 12:19:10 -0500 X-MC-Unique: _nRSLfdDOeeZdPXmbhp0Ig-1 X-Mimecast-MFC-AGG-ID: _nRSLfdDOeeZdPXmbhp0Ig_1764868750 Received: by mail-vk1-f197.google.com with SMTP id 71dfb90a1353d-55b0cfe81afso1999484e0c.2 for ; Thu, 04 Dec 2025 09:19:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764868750; x=1765473550; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=tbhl1hB6Go7cKeEzi9fq0ksxVXWeewQm1ULfbDi4zC4=; b=dYYSsDCvCR9ym9PSK88R5rqVLhmmdOhov0PnfZ4x6adt3ll9GsqY7SJtE3CFDtJVFv eQEQSdU0Dc//Qup5lhnpXMIsI56F7GIpOEPoz4NsK8UuGCs3DONDStxv/IhxZ0EiQ481 KpfkMECBJg63NLlb+vd0zZmN2jbHFe/8cmlE/ZXijw8MPxO9ZOPm7RMg8Uj8Vos6Dgnj JbhuxlClDTknEjFM42bdaBCT5/PtDJLmef8NSfUvziN+sYDHDeqSadZWwEcQOOlLNp7n rluA4gKWp6T9Hgl3txr+GVy6TuAPMSNnORp+mo2fSJdzmuZKabdGzYia+cIS6acBmEyF dh0g== X-Forwarded-Encrypted: i=1; AJvYcCVvonnng19j57Qt/GaYnO7kaHADlO4I6rB/I7UWi5POluNZdzXSLpDmglt1uv7WF0mQQ3LOeSv1POTHijvfvQ==@vger.kernel.org X-Gm-Message-State: AOJu0YxwFhgJEDFfQAOt4xn4Sswd+5gBh2vCjlZmFIxfl5I6fNTPERxg zqnTBmMql6dHvyWxFlqwdjE6xHGrKBYWKUE8Ed3kVCWRhl8g0YTnwT5v+6hbn2ulfRxlEMIXqPh XxVsgoWqe17xcL5kmL4vpVTit3e2cZtdrOBHSqi4tRnrPpLVSi6Irf3VLPpPmx0ERQl9JTIGRHu d8VTM3NggMWMKyjEuDrc4CRB7OxbLpzckkvjgR2vQczKE= X-Gm-Gg: ASbGncsmoBcP1ajTrx9FzcjqCWYXYlh/M/0zoE6hcfJtGckKqjP/fv4KyQDWyotOqSA QY1jZ1pYFDYL5tXyDfH/iDL13eMbStr7zFpSf7YmiyA//+nQJNZ1EK85jYNwadmQbCSytpt6nnz MbXTc11An2GxsYydTcKIWnYylUhYOJeIxt19DSEZ0SKbyJWDQDLkBREgEYDGF43+U8SQdZtRxfw 4w= X-Received: by 2002:a05:6122:219e:b0:55b:d85:5073 with SMTP id 71dfb90a1353d-55e69d33928mr1380189e0c.4.1764868750229; Thu, 04 Dec 2025 09:19:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IEeIB0YNcpJAiGx/GNuObvXw/sfsBoL+Pu7iwpKlscfZjHDAR4upRzogd+N3zgiWodvzIxUpcfLPOjZg7ZeO+k= X-Received: by 2002:a05:6122:219e:b0:55b:d85:5073 with SMTP id 71dfb90a1353d-55e69d33928mr1380133e0c.4.1764868749828; Thu, 04 Dec 2025 09:19:09 -0800 (PST) Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20251112-v5_user_cfi_series-v23-0-b55691eacf4f@rivosinc.com> <20251112-v5_user_cfi_series-v23-24-b55691eacf4f@rivosinc.com> <20251204175055-fefb76ff-2ff2-48b8-b92c-3d3ce33ec9f5@linutronix.de> In-Reply-To: <20251204175055-fefb76ff-2ff2-48b8-b92c-3d3ce33ec9f5@linutronix.de> From: Charles Mirabile Date: Thu, 4 Dec 2025 12:18:57 -0500 X-Gm-Features: AWmQ_bn9PjdtETVMsD9KORY8lffIPeFGUkSijG0lA3xh-eP2WvDjQUg18Xtxf3s Message-ID: Subject: Re: [PATCH v23 24/28] arch/riscv: dual vdso creation logic and select vdso based on hw To: =?UTF-8?Q?Thomas_Wei=C3=9Fschuh?= Cc: Deepak Gupta , 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 , Jann Horn , Conor Dooley , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , Alice Ryhl , Trevor Gross , Benno Lossin , 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, rust-for-linux@vger.kernel.org X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: rqCouQWczXeWSR_W6L6cuKeaEIuTRPJmVh_7EMOyDfs_1764868750 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Dec 4, 2025 at 12:04=E2=80=AFPM Thomas Wei=C3=9Fschuh wrote: > > On Wed, Nov 12, 2025 at 04:43:22PM -0800, Deepak Gupta via B4 Relay wrote= : > > From: Deepak Gupta > > > > Shadow stack instructions are taken from zimop (mandated on RVA23). > > Any hardware prior to RVA23 profile will fault on shadow stack instruct= ion. > > Any userspace with shadow stack instruction in it will fault on such > > hardware. Thus such userspace can't be brought onto such a hardware. > > > > It's not known how userspace will respond to such binary fragmentation. > > However in order to keep kernel portable across such different hardware= , > > `arch/riscv/kernel/vdso_cfi` is created which has logic (Makefile) to > > compile `arch/riscv/kernel/vdso` sources with cfi flags and then change= s > > in `arch/riscv/kernel/vdso.c` for selecting appropriate vdso depending > > on whether underlying hardware(cpu) implements zimop extension. Offset > > of vdso symbols will change due to having two different vdso binaries, > > there is added logic to include new generated vdso offset header and > > dynamically select offset (like for rt_sigreturn). > > If the used vDSO variant only depends on the hardware and nothing else, > why not use alternative patching and avoid the complexity? > I see that RISCV_ALTERNATIVE depends on !XIP_KERNEL but the vDSO code is > moved to dynamically allocated memory in any case, so it is patchable. These instructions are emitted by the toolchain in the C code, so a traditional approach with alternatives is not exactly feasible. Maybe you could do it by scan the binary for them, but that sounds dubious. > > > Signed-off-by: Deepak Gupta > > Acked-by: Charles Mirabile > > (...) >