From nobody Sat Jul 25 05:59:33 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 D929631B838 for ; Fri, 17 Jul 2026 08:06:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784275613; cv=none; b=bMnCuhXXis2Wb/BH4DEXgqP2yK3GAH4ckEkjD/SiSchy/vYeJg9YejiWqrutgr8pwGuB0vttpE5yLjybIbrHfaVbh4UABnfo1O+sDnlEN/yOSsu3kS4sz7hG8wvNZkVOWwEsYiPicRqNgsH7hG+qFk26YAd1Vn/po1dfwiiyVKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784275613; c=relaxed/simple; bh=Xbx0Xa6exR2m+uqfgf5wH7ZWdOL1Zxul2HP+LIFXESk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ztsr8fCJABsGDz9YCi1b2kbsMATm2LAD1ltGTaxrBelD9LHX7xF72gjlcVPTvo7WAIgzEW3rWk8/zvkwlVYdsN3gULvFbqlxg/UxRV2djuQ6q5G8Gk+uadr+nfY0d8CbQ9yQl8nzry8mDlelf7WLmGjyEFy1zMm2VwNF3ivR5i8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=et8fywNo; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=/vrAmpzJ; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="et8fywNo"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="/vrAmpzJ" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1784275610; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dH1Ph/iNnvbnyeD8/iV1ti1OQkX07oDM9rVdvOySvPk=; b=et8fywNoRqrFW6gEfyis5kmBILAozgP9q/8H+2cBn/3Q8/4hTTjShSIdNIP+LFXG/rSSIH HIBPOUenk20MvFDB5PoC54I6Uyt206LIpVhnyKyoQZhUFjuIPa4Qu0amdSk9wq/yF1lEE+ gw35WmibJpVL6ixd68Fwad+aq8pavOncA+u5rivnLhsqURRPpAINWEpoefK3l0uBz03I7N cMXzr09QebLr8EW6aYkXNgVdZGigDZAOxDwL8Z0YUPVoqLWhZ102nBui8o8sGn8j0XdU0i QKV76H0VzCZGLqxYMf4OBfPxzcI5w9x3cF/K/lrLjaYBkeexsqKJqbqPk5QILQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1784275610; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dH1Ph/iNnvbnyeD8/iV1ti1OQkX07oDM9rVdvOySvPk=; b=/vrAmpzJV2z90yH6e59XzVW6FUAo8a4CQUv4LdbnHXfHefQ/NZxANCOteUeo/ztSTFzUyM 6d2BjLjC+lE6GECQ== To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , =?UTF-8?q?Andr=C3=A9=20Almeida?= , Mathieu Desnoyers , Thomas Gleixner , Peter Zijlstra , Sebastian Andrzej Siewior Cc: Nam Cao Subject: [PATCH v3 1/5] riscv: compat_vdso: switch to standard kbuild rule Date: Fri, 17 Jul 2026 10:06:34 +0200 Message-ID: <0bf254c6a3a6070938d78bebddd67b3093ac811b.1784274927.git.namcao@linutronix.de> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The compat_vdso Makefile has a custom build rule for *.S files. This is unnecessary, and makes it hard to extend this Makefile to support building *.c files. Switch to standard kbuild rule instead. Signed-off-by: Nam Cao Reviewed-by: Thomas Wei=C3=9Fschuh --- arch/riscv/kernel/compat_vdso/Makefile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/riscv/kernel/compat_vdso/Makefile b/arch/riscv/kernel/com= pat_vdso/Makefile index 24e37d1ef7ec..8a395b5dd037 100644 --- a/arch/riscv/kernel/compat_vdso/Makefile +++ b/arch/riscv/kernel/compat_vdso/Makefile @@ -8,7 +8,6 @@ compat_vdso-syms =3D rt_sigreturn compat_vdso-syms +=3D getcpu compat_vdso-syms +=3D flush_icache =20 -COMPAT_CC :=3D $(CC) COMPAT_LD :=3D $(LD) =20 # binutils 2.35 does not support the zifencei extension, but in the ISA @@ -43,8 +42,7 @@ $(obj)/compat_vdso.so.dbg: $(obj)/compat_vdso.lds $(obj-c= ompat_vdso) FORCE LDFLAGS_compat_vdso.so.dbg =3D -shared -S -soname=3Dlinux-compat_vdso.so.1= \ --build-id=3Dsha1 --hash-style=3Dboth --eh-frame-hdr =20 -$(obj-compat_vdso): %.o: %.S FORCE - $(call if_changed_dep,compat_vdsoas) +$(obj-compat_vdso) : KBUILD_AFLAGS +=3D $(COMPAT_CC_FLAGS) =20 # strip rule for the .so file $(obj)/%.so: OBJCOPYFLAGS :=3D -S @@ -66,7 +64,3 @@ quiet_cmd_compat_vdsold =3D VDSOLD $@ cmd_compat_vdsold =3D $(COMPAT_LD) $(ld_flags) $(COMPAT_LD_FLAGS) -T= $(filter-out FORCE,$^) -o $@.tmp && \ $(OBJCOPY) $(patsubst %, -G __compat_vdso_%, $(compat_v= dso-syms)) $@.tmp $@ && \ rm $@.tmp - -# actual build commands -quiet_cmd_compat_vdsoas =3D VDSOAS $@ - cmd_compat_vdsoas =3D $(COMPAT_CC) $(a_flags) $(COMPAT_CC_FLAGS) -c = -o $@ $< --=20 2.47.3 From nobody Sat Jul 25 05:59:33 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 7A6613AC0ED for ; Fri, 17 Jul 2026 08:06:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784275613; cv=none; b=HUhnRmK20ourAhBta6OECl/+XIyXvttMhcGG1mNH0QFJ1h52N2K7VdrrLnMX9lmiBpk8mH/IF11eodrMTuzA8jqcTadcn+YW1lk9z+LecOdo4EPDp/lBYoh/5ThLqNHOAENt2qWx0SUoYQ38VWTbfCi7vWSJtd1YZXS3fvU2D5M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784275613; c=relaxed/simple; bh=p41PrJgmwTYWlQ2ZRbQEWWwgX3YpWPp1N29geClBAbI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iT88FKreGGiBRtrN9gGENlTIYBSbgvbKrGeoZutOREK1uIpjjSXr3CMJul6TKNt0M9lH+mJdXxxpgCaEay+22rH2KmKkyv2bcHFSuGDw+vSRA+chdzRGmfbV+LrtyTrciU0jxtfIIklUUPBFioxbJRVUm7Eo+4yk54obLZHLPE8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=R634B8Qj; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=QC87geyn; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="R634B8Qj"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="QC87geyn" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1784275610; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NG6JIULwe8wy/ye1EBaAbIcLezxqJJAlgHFLjbP0wy4=; b=R634B8Qjo7yrNH+qeDKs73Nj/gEnxNpIACH2WRgiC5mnjQqWg1BdJ1pGJvwT+zBMf9z+pQ KeE1687ExuYWhZVsCz7qOsjPse1McAMLQ5rB+/ggtfjyqt0y00Dk+ar6AeagtQxNfyFnrC LOXpX87Z0pLOHvb6aICGXBIJrZGrADTbVAkEaz8apb+jBfEJyTv8XmketrDhCTvFRvxeQX GA1IgwETPRogLD2h1nfqpRpfbcrNu9onQ9nrIc5AjAuywpiQ1iCZMlC9+e2B/DNMvLHalp 9Vii+NLhGbiDn6JTuQ+SdXl00KfFEgaxgXdruVpUb9oW6ZDl7mUraNZfSBabbw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1784275610; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NG6JIULwe8wy/ye1EBaAbIcLezxqJJAlgHFLjbP0wy4=; b=QC87geynQlv7U9Z8+KdjQQPHbnoAlcgW1wy4EcYaRVpouvuDLHWvi13klfWdnozEkJ5F1v nGn2vcpAaa8CLBCA== To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , =?UTF-8?q?Andr=C3=A9=20Almeida?= , Mathieu Desnoyers , Thomas Gleixner , Peter Zijlstra , Sebastian Andrzej Siewior Cc: Nam Cao Subject: [PATCH v3 2/5] riscv: compat_vdso: Allow *.c source files Date: Fri, 17 Jul 2026 10:06:35 +0200 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Extend to support building *.c files. This allows adding futex.c in a follow-up commit. Signed-off-by: Nam Cao Reviewed-by: Thomas Wei=C3=9Fschuh --- arch/riscv/kernel/compat_vdso/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/kernel/compat_vdso/Makefile b/arch/riscv/kernel/com= pat_vdso/Makefile index 8a395b5dd037..452c623d1a44 100644 --- a/arch/riscv/kernel/compat_vdso/Makefile +++ b/arch/riscv/kernel/compat_vdso/Makefile @@ -43,6 +43,7 @@ LDFLAGS_compat_vdso.so.dbg =3D -shared -S -soname=3Dlinux= -compat_vdso.so.1 \ --build-id=3Dsha1 --hash-style=3Dboth --eh-frame-hdr =20 $(obj-compat_vdso) : KBUILD_AFLAGS +=3D $(COMPAT_CC_FLAGS) +$(obj-compat_vdso) : KBUILD_CFLAGS +=3D $(COMPAT_CC_FLAGS) =20 # strip rule for the .so file $(obj)/%.so: OBJCOPYFLAGS :=3D -S --=20 2.47.3 From nobody Sat Jul 25 05:59:33 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 EDC953CF1E3 for ; Fri, 17 Jul 2026 08:06:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784275614; cv=none; b=E3sTY8n+FeWbUNoaZLCCO4Jkhcc6rSzOaTLHxDTF9vdZt6viHb1lhTBg+y092Fo/5u+nfoVmTztNG3l1cLvqdZ6rflK4LMEdkiTnwclUAXfpmZ7ofdj5/KsOSmnnGfGDPuGiX1kyiv7clNp5p9k+98vdR5fCYp5tH+YrZSglhqw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784275614; c=relaxed/simple; bh=8bkzCwwhzqEfigvF2IHE4AiC4OFNKF4l1XPpudU9Lyw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WOjkTWHiZt0o8ZZkKSJw1X7bJuOIpu/62qCIHwGxan4xY/qr3TMogbUUrwXIqr5MmXXzH1pOSsSr3Vx2J+jmBj6c37l+iMlC/tTa3dOdC/A/Tj1awKMIPebJ1vxCnIzowKasZAb7ez0B0hO1F+oipw1T/tIdv7MDcff6U5evxJQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=BrM041GN; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=VcSXoklX; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="BrM041GN"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="VcSXoklX" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1784275611; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pBDhUIAkr3h7kDmW6cW3zlXUtNbH/QbCHeJocp9cdb0=; b=BrM041GNN1/1MNNEoIDTHygmuKZCGwzqryUwiLpR3XWBQvnK2mKk0r9BaFygxiO6OSXOQn 9ocRjwEGdfOhTi1dvXxR6/KRB5kPTIlqdor/e2el37n5HNvr7NXnZu3GThcP96KFxHsABg larTa/hRJ3wf+e/pBi37HAQ1+MAsvtT1eRlWntex45qhS0AGdtsnrW5XJAwrsPhvw9WgJj vy8yXN/KYSLZRxKvhC46VSDcGNd6umWsKPThlZLWyJ1g/EN+8QrNszJUPX+86jql2SJSjN VB7irxQA3BEDTz+tqxHL0xkY/9zYhHaekKFO7ItV+5/0CcUMNg8rbq/iJCOeeg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1784275611; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pBDhUIAkr3h7kDmW6cW3zlXUtNbH/QbCHeJocp9cdb0=; b=VcSXoklXmig7w9WUcc1PO9Yu5sc+DNOodBSkGc0ELbtkJN6OZIGt2Xy1/HB1PPj/rT1ItY estwVKWj9QGf0YAg== To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , =?UTF-8?q?Andr=C3=A9=20Almeida?= , Mathieu Desnoyers , Thomas Gleixner , Peter Zijlstra , Sebastian Andrzej Siewior Cc: Nam Cao Subject: [PATCH v3 3/5] riscv: compat_vdso: Introduce COMPAT_MARCH variable Date: Fri, 17 Jul 2026 10:06:36 +0200 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The -march option is inside COMPAT_CC_FLAGS, making it difficult to extend. Introduce COMPAT_MARCH variable to allow extension. A follow-up commit will take advantage of this to add _zacas to -march. Signed-off-by: Nam Cao Reviewed-by: Thomas Wei=C3=9Fschuh --- arch/riscv/kernel/compat_vdso/Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/riscv/kernel/compat_vdso/Makefile b/arch/riscv/kernel/com= pat_vdso/Makefile index 452c623d1a44..63580b33e3ce 100644 --- a/arch/riscv/kernel/compat_vdso/Makefile +++ b/arch/riscv/kernel/compat_vdso/Makefile @@ -13,10 +13,13 @@ COMPAT_LD :=3D $(LD) # binutils 2.35 does not support the zifencei extension, but in the ISA # spec 20191213, G stands for IMAFD_ZICSR_ZIFENCEI. ifdef CONFIG_TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI - COMPAT_CC_FLAGS :=3D -march=3Drv32g -mabi=3Dilp32 + COMPAT_MARCH :=3D rv32g else - COMPAT_CC_FLAGS :=3D -march=3Drv32imafd -mabi=3Dilp32 + COMPAT_MARCH :=3D rv32imafd endif + +COMPAT_CC_FLAGS :=3D -march=3D$(COMPAT_MARCH) -mabi=3Dilp32 + COMPAT_LD_FLAGS :=3D -melf32lriscv =20 # Disable attributes, as they're useless and break the build. --=20 2.47.3 From nobody Sat Jul 25 05:59:33 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 8CFEC3D5666 for ; Fri, 17 Jul 2026 08:06:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784275615; cv=none; b=XLNSysQFtmgjAY7dZ+dzIYJod9q+53jlgmjKf6Qahpc2H5fhRxsu27XtdHRW9cDOgN7udO1KJXrnuGf9ThIunPQG2A0wEt1hOHGKS/pqpYKGx4vi29nPA9Xul9XxWYY2dZyk6qUL+GwAStPdmWy20XcsGk9X/n6Y7rqWGvm54vY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784275615; c=relaxed/simple; bh=RSxF4hsjb25+Eb1PnPwC4aVOieIn5GvF8qBaSIsI/BQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=su99+IQB1dx7KaJDUkylMMlSonuE9kD/nlqfx3wKEwAvfn4v6qommWmN9jz/swJNiudnIyn6WLFvT+LhCDZCSXb2H9e1CmuVjJxRoqQvC9oxwOcm1eHr3mrWl4izW5NXXKhXmqWsRoE/geLTgDBa+wvpUCgE02h6YOpBSe6y4L4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=P2HMMg6s; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=E03gajk3; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="P2HMMg6s"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="E03gajk3" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1784275611; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F/AiuPjv8/IO6sSkiI0H94eP5h3JqqboNr8FcqhnBQ0=; b=P2HMMg6syw0s7sNy7qj1afJFpYblf2hD8TzYTBOKtOEe/WPrTLKg9Ce93gCxFd8ccxizCK /699u8k3AWTYMLx6HlCn+TOG3ZQdRhoR61A33lL13XTqF9VNET+KOOtFiCrPZR1P/Vynz6 oJOl8Jmq62ZUJfi0C/dN2gJ5wryitlv277sJE6axlT3mnjL7FbAoP1eQ8aawDNgvf06FOU fVRkZIQVBglVqAAY+1DIMf3ji/IDQK1dLmbHdhbO+A29gGkX48ego9BF76QTeWQJXnJ06D RT73lFqoHaKo7ebJxnBXmiFzjVw5FeAT8JODn+QjQ+zGAEs97PTcu8Cwv3FndA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1784275611; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F/AiuPjv8/IO6sSkiI0H94eP5h3JqqboNr8FcqhnBQ0=; b=E03gajk3rpQ2sO/BL8gwGq06mW/blU3uq7rAfqXSgXiqMIOeoJoOkiQr805oIMb4PjWuBr pr5mOS5wf+SPSOAQ== To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , =?UTF-8?q?Andr=C3=A9=20Almeida?= , Mathieu Desnoyers , Thomas Gleixner , Peter Zijlstra , Sebastian Andrzej Siewior Cc: Nam Cao Subject: [PATCH v3 4/5] riscv: compat_vdso: Build with zacas if available Date: Fri, 17 Jul 2026 10:06:37 +0200 Message-ID: <704e0bbacee5f23d1351a686f3a783e31699fb3b.1784274927.git.namcao@linutronix.de> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The compat vdso Makefile does not enable zacas, disallowing source files from using zacas instructions. This is an obstacle to adding robust __vdso_futex_robust_list32_try_unlock() in a follow-up commit. Build with zacas, if compiler supports it. Signed-off-by: Nam Cao Reviewed-by: Thomas Wei=C3=9Fschuh --- arch/riscv/kernel/compat_vdso/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/riscv/kernel/compat_vdso/Makefile b/arch/riscv/kernel/com= pat_vdso/Makefile index 63580b33e3ce..ffbf84aeb081 100644 --- a/arch/riscv/kernel/compat_vdso/Makefile +++ b/arch/riscv/kernel/compat_vdso/Makefile @@ -18,6 +18,10 @@ else COMPAT_MARCH :=3D rv32imafd endif =20 +ifneq ($(call cc-option,-mabi=3Dilp32 -march=3Drv32ima_zacas),) +COMPAT_MARCH :=3D $(COMPAT_MARCH)_zacas +endif + COMPAT_CC_FLAGS :=3D -march=3D$(COMPAT_MARCH) -mabi=3Dilp32 =20 COMPAT_LD_FLAGS :=3D -melf32lriscv --=20 2.47.3 From nobody Sat Jul 25 05:59:33 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 D1D703DFC7F for ; Fri, 17 Jul 2026 08:06:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784275621; cv=none; b=IaQQ/guUu/g7MIDU6F5SkbSL9edo3VIq+0B2AEGEiGzS9w70DAjzTKAwSfUu3CSw5S5Gh/GIai0pGocblhFjfnpvRHozcNBXSrocdBfWo6EZh0rIabQfiWy7pCwbCIhi7aLe/pGk+dfpT928U4tc6McXpadPNaB+Ifk2vHisEUA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784275621; c=relaxed/simple; bh=UqnpI70xEOKty31rdMMmLs9A7qirU+hGBCd1OS3QxqM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nI+9XQ4hR7olVl21yfABR1Ha6hDIKsadJKJeWXJqhjmIL0gzeRdS4rwU2OdAmoAYJxuDfUAbkEzM99wX8SmZrX3++GBLFtbvrVdJDTWKGxq24FeSI3CsPczM20wkdczqkp8mTJv68z0QeJyxecBFQLhMGInp/0i5254aQzV3abg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=TaTDw8sV; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=z8zL8O8L; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="TaTDw8sV"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="z8zL8O8L" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1784275612; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+lMjZlelgELpZ/oSbFyjbp8Vn7GFS8BtfsG+e4436ww=; b=TaTDw8sVEOrsZUre9O33TBUiNyM7QXZjgpnGlfs0Y+iQ20Mz6u0CBRUxk0Y0QuHNzvVNRs PmLT1J1lXXUjp/ir9R8Oc4Vs+PODp6TZV9qJYn4MX4EkubDAFdFpMU2bAg639ADU8TuFOo dRJEqQa58r4vSr53V+B5IhXXzLrNQ+/PV1wScWIgY3Zj+lFljW01JYgKjkk6lwL1ZFWFwl rR9Ln/TwN+eNEUUI8YCoWnDpxGmjAdlevfY2FBqHt6RF0q9MXXItCH5+7fa6SkIAMkG1Jv dGhrNBugSpJnFy4CXXZ38/npASrzNdnmCcswHm8su4/aa90oVT3pw6H+oEB/Fg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1784275612; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+lMjZlelgELpZ/oSbFyjbp8Vn7GFS8BtfsG+e4436ww=; b=z8zL8O8LeVc7ZNzSCY2p7a2CDwuw2ZoP6e1/GoUFqV5IItoQHl6Vixef5zPkoK4NFl9LOU gPhgLvdGR71O6jBg== To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , =?UTF-8?q?Andr=C3=A9=20Almeida?= , Mathieu Desnoyers , Thomas Gleixner , Peter Zijlstra , Sebastian Andrzej Siewior Cc: Nam Cao Subject: [PATCH v3 5/5] riscv: vdso: Implement __vdso_futex_robust_try_unlock() Date: Fri, 17 Jul 2026 10:06:38 +0200 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This is the RISC-V port for __vdso_futex_robust_try_unlock(). It is based on the x86's implementation in commit 61cfc8e372d1 ("x86/vdso: Prepare for robust futex unlock support") and commit a2274cc0091e ("x86/vdso: Implement __vdso_futex_robust_try_unlock()"). When the FUTEX_ROBUST_UNLOCK mechanism is used for unlocking (PI-)futexes, the unlock sequence in userspace looks like this: 1) robust_list_set_op_pending(mutex); 2) robust_list_remove(mutex); lval =3D gettid(); 3) if (atomic_try_cmpxchg(&mutex->lock, lval, 0)) 4) robust_list_clear_op_pending(); else 5) sys_futex(OP,...FUTEX_ROBUST_UNLOCK); That still leaves a minimal race window between #3 and #4 where the mutex could be acquired by some other task which observes that it is the last user and: 1) unmaps the mutex memory 2) maps a different file, which ends up covering the same address When then the original task exits before reaching #4 then the kernel robust list handling observes the pending op entry and tries to fix up user space. In case that the newly mapped data contains the TID of the exiting thread at the address of the mutex/futex the kernel will set the owner died bit in that memory and therefore corrupt unrelated data. Provide a VDSO function which exposes the critical section window in the VDSO symbol table. The resulting addresses are updated in the task's mm when the VDSO is (re)map()'ed. The core code detects when a task was interrupted within the critical section and is about to deliver a signal. It then invokes an architecture specific function which determines whether the pending op pointer has to be cleared or not. The unlock assembly sequence on 64-bit is: mv a5, a0 ; move LOCK to a5 .Lretry lr.w a0, (a5) ; load *LOCK bne a0, a1, 24 .Lend ; if (*LOCK !=3D TID) then exit sc.w.rl t0, zero, (a5) ; try changing *LOCK from TID to zero .Lstart bnez t0, .Lretry ; retry if store-conditional failed sd zero, 0(a2) ; clear POP .Lend sext.w a0,a0 ret So if the kernel sees that the user task is between .Lstart and .Lend, t0 can be checked to determine if the pending op pointer (POP) should be cleared. When the kernel is built with ZACAS, another unlock assembly sequence is provided using ZACAS instructions. If the CPU supports ZACAS, that alternative sequence is used and the critical section is also changed to that. There are two entry points to handle the different robust list pending op pointer sizes: __vdso_futex_robust_list64_try_unlock() __vdso_futex_robust_list32_try_unlock() The 32-bit VDSO and compat VDSO provides __vdso_futex_robust_list32_try_unlock(). Unlike x86, the RISC-V 64-bit VDSO provides only provides __vdso_futex_robust_list64_try_unlock(). Because RISC-V threads can only have one list_op_pending pointer type. Signed-off-by: Nam Cao Reviewed-by: Thomas Wei=C3=9Fschuh --- arch/riscv/Kconfig | 1 + arch/riscv/include/asm/cpufeature-macros.h | 2 + arch/riscv/include/asm/futex_robust.h | 16 +++++ arch/riscv/include/asm/vdso/futex.h | 14 ++++ arch/riscv/kernel/compat_vdso/Makefile | 7 +- arch/riscv/kernel/compat_vdso/futex.c | 3 + arch/riscv/kernel/vdso.c | 61 ++++++++++++++++ arch/riscv/kernel/vdso/Makefile | 14 +++- arch/riscv/kernel/vdso/futex.c | 84 ++++++++++++++++++++++ arch/riscv/kernel/vdso/vdso.lds.S | 8 +++ 10 files changed, 208 insertions(+), 2 deletions(-) create mode 100644 arch/riscv/include/asm/futex_robust.h create mode 100644 arch/riscv/include/asm/vdso/futex.h create mode 100644 arch/riscv/kernel/compat_vdso/futex.c create mode 100644 arch/riscv/kernel/vdso/futex.c diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index c2c2f5f3ed5e..588963bef804 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -166,6 +166,7 @@ config RISCV select HAVE_FUNCTION_GRAPH_TRACER if HAVE_DYNAMIC_FTRACE_WITH_ARGS select HAVE_FUNCTION_GRAPH_FREGS select HAVE_FUNCTION_TRACER if HAVE_DYNAMIC_FTRACE + select HAVE_FUTEX_ROBUST_UNLOCK select HAVE_EBPF_JIT if MMU select HAVE_GENERIC_TIF_BITS select HAVE_GUP_FAST if MMU diff --git a/arch/riscv/include/asm/cpufeature-macros.h b/arch/riscv/includ= e/asm/cpufeature-macros.h index a8103edbf51f..f522c6c3cd97 100644 --- a/arch/riscv/include/asm/cpufeature-macros.h +++ b/arch/riscv/include/asm/cpufeature-macros.h @@ -6,6 +6,8 @@ #ifndef _ASM_CPUFEATURE_MACROS_H #define _ASM_CPUFEATURE_MACROS_H =20 +#include + #include #include =20 diff --git a/arch/riscv/include/asm/futex_robust.h b/arch/riscv/include/asm= /futex_robust.h new file mode 100644 index 000000000000..16ec58e925c8 --- /dev/null +++ b/arch/riscv/include/asm/futex_robust.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_RISCV_FUTEX_ROBUST_H +#define _ASM_RISCV_FUTEX_ROBUST_H + +#include +#include + +static inline void __user *arch_futex_robust_unlock_get_pop(struct pt_regs= *regs) +{ + if (cpu_supports_zacas()) + return (regs->a0 =3D=3D regs->a1) ? (void __user *)regs->a2 : NULL; + else + return (regs->t0 =3D=3D 0) ? (void __user *)regs->a2 : NULL; +} + +#endif /* _ASM_RISCV_FUTEX_ROBUST_H */ diff --git a/arch/riscv/include/asm/vdso/futex.h b/arch/riscv/include/asm/v= dso/futex.h new file mode 100644 index 000000000000..9e173f45f3e2 --- /dev/null +++ b/arch/riscv/include/asm/vdso/futex.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __ASM_VDSO_FUTEX_H +#define __ASM_VDSO_FUTEX_H + +#include + +static inline bool cpu_supports_zacas(void) +{ + return IS_ENABLED(CONFIG_RISCV_ISA_ZACAS) && IS_ENABLED(CONFIG_TOOLCHAIN_= HAS_ZACAS) && + riscv_has_extension_unlikely(RISCV_ISA_EXT_ZACAS); +} + +#endif /* __ASM_VDSO_FUTEX_H */ diff --git a/arch/riscv/kernel/compat_vdso/Makefile b/arch/riscv/kernel/com= pat_vdso/Makefile index ffbf84aeb081..5736297e6281 100644 --- a/arch/riscv/kernel/compat_vdso/Makefile +++ b/arch/riscv/kernel/compat_vdso/Makefile @@ -31,7 +31,12 @@ COMPAT_CC_FLAGS +=3D $(call cc-option,-mno-riscv-attribu= te) COMPAT_CC_FLAGS +=3D $(call as-option,-Wa$(comma)-mno-arch-attr) =20 # Files to link into the compat_vdso -obj-compat_vdso =3D $(patsubst %, %.o, $(compat_vdso-syms)) note.o +obj-compat_vdso :=3D $(patsubst %, %.o, $(compat_vdso-syms)) note.o + +ifdef CONFIG_FUTEX_ROBUST_UNLOCK +compat_vdso-syms +=3D __vdso_futex_robust_list32_try_unlock +obj-compat_vdso +=3D futex.o +endif =20 # Build rules targets :=3D $(obj-compat_vdso) compat_vdso.so compat_vdso.so.dbg compat_v= dso.lds diff --git a/arch/riscv/kernel/compat_vdso/futex.c b/arch/riscv/kernel/comp= at_vdso/futex.c new file mode 100644 index 000000000000..ad05ded43955 --- /dev/null +++ b/arch/riscv/kernel/compat_vdso/futex.c @@ -0,0 +1,3 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include "../vdso/futex.c" diff --git a/arch/riscv/kernel/vdso.c b/arch/riscv/kernel/vdso.c index 9c2f5e442338..2610363f9a02 100644 --- a/arch/riscv/kernel/vdso.c +++ b/arch/riscv/kernel/vdso.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -33,11 +34,69 @@ static struct __vdso_info vdso_info; static struct __vdso_info compat_vdso_info; #endif =20 +#define _CONCAT3(a, b, c) a ## b ## c +#define CONCAT3(a, b, c) _CONCAT3(a, b, c) + +#if defined(CONFIG_RISCV_ISA_ZACAS) && defined(CONFIG_TOOLCHAIN_HAS_ZACAS) +#define FUTEX_CAS_SET_VDSO_CS_RANGE(vdso, fd, idx, xlen, symbol) \ +({ \ + void *start =3D symbol(vdso, CONCAT3(futex_list, xlen, _try_unlock_cs_cas= _start)); \ + void *end =3D symbol(vdso, CONCAT3(futex_list, xlen, _try_unlock_cs_cas= _end)); \ + \ + futex_set_vdso_cs_range(fd, idx, (uintptr_t)start, (uintptr_t)end, xlen = =3D=3D 32); \ +}) +#else +#define FUTEX_CAS_SET_VDSO_CS_RANGE(...) BUILD_BUG() +#endif + +#define FUTEX_LRSC_SET_VDSO_CS_RANGE(vdso, fd, idx, xlen, symbol) \ +({ \ + void *start =3D symbol(vdso, CONCAT3(futex_list, xlen, _try_unlock_cs_lrs= c_start)); \ + void *end =3D symbol(vdso, CONCAT3(futex_list, xlen, _try_unlock_cs_lrs= c_end)); \ + \ + futex_set_vdso_cs_range(fd, idx, (uintptr_t)start, (uintptr_t)end, xlen = =3D=3D 32); \ +}) + +#define FUTEX_SET_VDSO_CS_RANGE(vdso, fd, idx, xlen, symbol) \ +({ \ + if (cpu_supports_zacas()) \ + FUTEX_CAS_SET_VDSO_CS_RANGE(vdso, fd, idx, xlen, symbol); \ + else \ + FUTEX_LRSC_SET_VDSO_CS_RANGE(vdso, fd, idx, xlen, symbol); \ +}) + +#ifdef CONFIG_FUTEX_ROBUST_UNLOCK + +/* Allow parameters to expand first */ +#define __VDSO_SYMBOL(vdso, name) VDSO_SYMBOL(vdso, name) +#define __COMPAT_VDSO_SYMBOL(vdso, name) COMPAT_VDSO_SYMBOL(vdso, name) + +static void vdso_futex_robust_unlock_update_ips(void) +{ + unsigned long vdso =3D (unsigned long) current->mm->context.vdso; + struct futex_mm_data *fd =3D ¤t->mm->futex; + + futex_reset_cs_ranges(fd); + + if (!is_compat_task()) + FUTEX_SET_VDSO_CS_RANGE(vdso, fd, 0, __riscv_xlen, __VDSO_SYMBOL); + +#ifdef CONFIG_COMPAT + if (is_compat_task()) + FUTEX_SET_VDSO_CS_RANGE(vdso, fd, 0, 32, __COMPAT_VDSO_SYMBOL); +#endif +} +#else +static inline void vdso_futex_robust_unlock_update_ips(void) {} +#endif + static int vdso_mremap(const struct vm_special_mapping *sm, struct vm_area_struct *new_vma) { current->mm->context.vdso =3D (void *)new_vma->vm_start; =20 + vdso_futex_robust_unlock_update_ips(); + return 0; } =20 @@ -147,6 +206,8 @@ static int __setup_additional_pages(struct mm_struct *m= m, if (IS_ERR(ret)) goto up_fail; =20 + vdso_futex_robust_unlock_update_ips(); + return 0; =20 up_fail: diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makef= ile index 8dbf2532a573..d4238db8c6d3 100644 --- a/arch/riscv/kernel/vdso/Makefile +++ b/arch/riscv/kernel/vdso/Makefile @@ -27,12 +27,24 @@ asflags-y +=3D -DVDSO_CFI=3D1 endif =20 # Files to link into the vdso -obj-vdso =3D $(patsubst %, %.o, $(vdso-syms)) note.o +obj-vdso :=3D $(patsubst %, %.o, $(vdso-syms)) note.o =20 ifdef CONFIG_VDSO_GETRANDOM obj-vdso +=3D vgetrandom-chacha.o endif =20 +ifdef CONFIG_FUTEX_ROBUST_UNLOCK + +obj-vdso +=3D futex.o + +ifdef CONFIG_64BIT +vdso-syms +=3D __vdso_futex_robust_list64_try_unlock +else +vdso-syms +=3D __vdso_futex_robust_list32_try_unlock +endif + +endif + ccflags-y :=3D -fno-stack-protector ccflags-y +=3D -DDISABLE_BRANCH_PROFILING ccflags-y +=3D -fno-builtin diff --git a/arch/riscv/kernel/vdso/futex.c b/arch/riscv/kernel/vdso/futex.c new file mode 100644 index 000000000000..7da77e635012 --- /dev/null +++ b/arch/riscv/kernel/vdso/futex.c @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include +#include +#include +#include +#include + +#define LABEL(pop_size, which) __stringify(__vdso_futex_list##pop_size##_t= ry_unlock_cs_##which) + +#define futex_robust_try_unlock_cas(pop_size, store_pop, lock, tid, pop) \ +({ \ + /* \ + * arch_futex_robust_unlock_get_pop() assumes the variables are in \ + * those registers. So make sure. \ + * \ + * tid and pop are in a1 and a2 at function entry according to the \ + * calling convention, so it likely still works if we remove _tid \ + * and _pop. But technically compiler is allowed to move tid and pop \ + * to different registers, and _tid and _pop do not generate any \ + * extra instructions so it does not hurt to keep them. \ + */ \ + register __u32 ret asm ("a0") =3D tid; \ + register __u32 _tid asm ("a1") =3D tid; \ + register void *_pop asm ("a2") =3D pop; \ + \ + asm volatile ( \ + " amocas.w.rl %[ret], zero, (%[lock])\n" \ + LABEL(pop_size, cas_start)":" \ + " bne %[ret], %[tid], "LABEL(pop_size, cas_end)"\n" \ + " "store_pop" zero, (%[pop])\n" \ + LABEL(pop_size, cas_end)":" \ + : [ret] "+&r" (ret) \ + : [tid] "r" (_tid), \ + [lock] "r" (lock), \ + [pop] "r" (_pop) \ + : "memory" \ + ); \ + \ + ret; \ +}) + +#define futex_robust_try_unlock_lrsc(pop_size, store_pop, lock, tid, pop) \ +({ \ + register void *_pop asm ("a2") =3D pop; \ + __u32 ret; \ + \ + asm volatile ( \ + "1: lr.w %[ret], (%[lock])\n" \ + " bne %[ret], %[tid], "LABEL(pop_size, lrsc_end)"\n" \ + " sc.w.rl t0, x0, (%[lock])\n" \ + LABEL(pop_size, lrsc_start)":" \ + " bnez t0, 1b\n" \ + " "store_pop" zero, (%[pop])\n" \ + LABEL(pop_size, lrsc_end)":" \ + : [ret] "=3D&r" (ret) \ + : [tid] "r" (tid), \ + [lock] "r" (lock), \ + [pop] "r" (_pop) \ + : "t0", "memory" \ + ); \ + \ + ret; \ +}) + + +#if __riscv_xlen =3D=3D 64 +__u32 __vdso_futex_robust_list64_try_unlock(__u32 *lock, __u32 tid, __u64 = *pop) +{ + if (cpu_supports_zacas()) + return futex_robust_try_unlock_cas(64, "sd", lock, tid, pop); + else + return futex_robust_try_unlock_lrsc(64, "sd", lock, tid, pop); +} +#endif + +#if __riscv_xlen =3D=3D 32 +__u32 __vdso_futex_robust_list32_try_unlock(__u32 *lock, __u32 tid, __u32 = *pop) +{ + if (cpu_supports_zacas()) + return futex_robust_try_unlock_cas(32, "sw", lock, tid, pop); + else + return futex_robust_try_unlock_lrsc(32, "sw", lock, tid, pop); +} +#endif diff --git a/arch/riscv/kernel/vdso/vdso.lds.S b/arch/riscv/kernel/vdso/vds= o.lds.S index c29ef12a63bb..9acfa9ef5bab 100644 --- a/arch/riscv/kernel/vdso/vdso.lds.S +++ b/arch/riscv/kernel/vdso/vdso.lds.S @@ -82,6 +82,14 @@ VERSION #endif #if defined(CONFIG_VDSO_GETRANDOM) && !defined(COMPAT_VDSO) __vdso_getrandom; +#endif + +#ifdef CONFIG_FUTEX_ROBUST_UNLOCK +#if defined(CONFIG_32BIT) || defined(COMPAT_VDSO) + __vdso_futex_robust_list32_try_unlock; +#else + __vdso_futex_robust_list64_try_unlock; +#endif #endif local: *; }; --=20 2.47.3