From nobody Tue Nov 26 19:45:29 2024 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 A0E1F1F80C7 for ; Wed, 16 Oct 2024 08:37:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729067852; cv=none; b=ueh/FVD8ND+e/bZ1TmVZYxEDWuPfPVu2J1EYH2cwpfYH4pf+ch3ZQ09DbBuQyut11lxZWHA4qY8rp8XRSRVVHyTMMrcSIx4f5Mxq0orMx7qD/u+gS2RhhbyGlsb90G8LGZKWb5lPC3Pese91hrR1buOt9dQSKx9u/vzW1o/Yl/8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729067852; c=relaxed/simple; bh=ELkP+/LlvaLc+XLPJhx3hY+pNjpVHD4I9RrhF1TIZYk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SMI2gcw0XGQSC9Ylh0v7tTYwZiq/imABTFS8LbqrAiyq2wkWofTma3KLyscVE7F1WXiiZ9p/rQjUurEbN3rg00oOCrebP72Gi5BoH1OfrvUfEnc0tG06pkYE+0t3bK6XSiLhEYQzhjQFkvK8q+aNfGSXhP+jM6yZTX9JCn/zW8Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=d6V1vFxc; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="d6V1vFxc" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4305413aec9so60661415e9.2 for ; Wed, 16 Oct 2024 01:37:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1729067849; x=1729672649; darn=vger.kernel.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=9jJdJXmZIFUypkGDe9/4mfd3DKdJwjPw93ZM7h9RdKg=; b=d6V1vFxcP538ogDKAAHC4xvcXZRQXTQvBNCbXNBn/b4/fStwl6so3RghLXkRFjVvfi 23QtqR5py/tqNhgvi44yU59YDUc8xTJOvtcilMKDEobJCHXbnvGzfMQQIuzytpwtjnpZ OKMtpHxFoJLAgLQ98kvcr/4fmo468qDj4YS9JPNXi9RxWzfKCtCxG07F80k+L59c++V5 XYC68xCIXR00yE7NT/R49+PP23Y47n34avGf5wI7Xk6HqgFuJziKaDjia/+hPQHt56CB Zdqn80r+YSsPSQBmVy+O21XYxzzTZ+uvwwvXobH3dtxcSN+V3ds1A0DBeoFPmNp177Pe ZqJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729067849; x=1729672649; 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=9jJdJXmZIFUypkGDe9/4mfd3DKdJwjPw93ZM7h9RdKg=; b=XWKAubLbwB5s/g8MZ+wrQ//B03DVDajJP/VOPhYzf1YJkPyaep6pA6jCBs1y7A9hLs Afr9knUEmRM4OX1gcGuH8Y+5W4UCnYT8IJXuuOLFUCE2GeC8vFwdstL9AtBOgLujvlm3 Bljc1LB2UT25oDkLV0bGYSclogCs0Zsl/Gols/wqdaSyijp4IkwDw+ye00jquQcGaYiP Wk5CGzTYLCKbpxysvkgVkqFJl3aQie4UoSRuGbgoxtdhHvLfmkDYBBkdfpqgyuPIirzx LV470HnIP0iwrUeeAycrqNbUhpuK7bdpwbBjyhSpZLBi9gD1h//R7zZytmRiYwrpuFJN VJTw== X-Forwarded-Encrypted: i=1; AJvYcCWWbWCJmM28/UUWbpYyWpjzv9+wvFmgaC4rLVwH8EXPhrF4D8YK5HS+0RDCOxzrZImdGuSKkMBBHfzq9sE=@vger.kernel.org X-Gm-Message-State: AOJu0Yxd/mS0w7zXW3LaIu6cMsNvzBH43aF6PQ6T7z+MtR2Tf53O6X8T VnPShDH438H8GPZwCh77fPUdaoci8UQ4WRyxmh0n2HWkvDtWT1YDe+6y/qjKjmo= X-Google-Smtp-Source: AGHT+IFp3TkzbiKrwAorGoZodCtXXr7F5FcNaRIdRFI7+3ysQVBFKjSKd4I+hM6P7+iGyX8KPTwG+g== X-Received: by 2002:a05:600c:1c98:b0:431:150e:4e8d with SMTP id 5b1f17b1804b1-4314a31da99mr27011475e9.21.1729067848919; Wed, 16 Oct 2024 01:37:28 -0700 (PDT) Received: from alex-rivos.ba.rivosinc.com (lfbn-lyo-1-472-36.w2-7.abo.wanadoo.fr. [2.7.62.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4313f6b1e9esm42168205e9.37.2024.10.16.01.37.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 01:37:28 -0700 (PDT) From: Alexandre Ghiti To: Vladimir Isaev , Roman Artemev , Guo Ren , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Ghiti , stable@vger.kernel.org Subject: [PATCH v3 1/2] riscv: vdso: Prevent the compiler from inserting calls to memset() Date: Wed, 16 Oct 2024 10:36:24 +0200 Message-Id: <20241016083625.136311-2-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241016083625.136311-1-alexghiti@rivosinc.com> References: <20241016083625.136311-1-alexghiti@rivosinc.com> 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 compiler is smart enough to insert a call to memset() in riscv_vdso_get_cpus(), which generates a dynamic relocation. So prevent this by using -fno-builtin option. Fixes: e2c0cdfba7f6 ("RISC-V: User-facing API") Cc: stable@vger.kernel.org Signed-off-by: Alexandre Ghiti Reviewed-by: Guo Ren --- arch/riscv/kernel/vdso/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makef= ile index 960feb1526ca..3f1c4b2d0b06 100644 --- a/arch/riscv/kernel/vdso/Makefile +++ b/arch/riscv/kernel/vdso/Makefile @@ -18,6 +18,7 @@ obj-vdso =3D $(patsubst %, %.o, $(vdso-syms)) note.o =20 ccflags-y :=3D -fno-stack-protector ccflags-y +=3D -DDISABLE_BRANCH_PROFILING +ccflags-y +=3D -fno-builtin =20 ifneq ($(c-gettimeofday-y),) CFLAGS_vgettimeofday.o +=3D -fPIC -include $(c-gettimeofday-y) --=20 2.39.2 From nobody Tue Nov 26 19:45:29 2024 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 CF7961FCC6D for ; Wed, 16 Oct 2024 08:38:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729067913; cv=none; b=YNP3mGlOJB3+T7LJbP6cgVOY3fbaccLbMmKz+1CHA0Gsh8V0a8BFCAyIcojT7ozPQFXS7pFxVY/Ci3I3+S6sR6oCScpQeC1YDhiusG8v37jykpBKsGw1fkpoQXcGc2WFPuX8eUzMr97Li9D4JfBn85shsc9IIjeMcwIo/y3DnVk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729067913; c=relaxed/simple; bh=/rLgq3p4ObPxtfQzLO2A450swrlwKaY+mRcWaH3/8I4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=pxkk6ef1lHkn0sux1C4AHEtdNHLzphBGQiLPL9f87I//MeYNGR2otHLixn1bBHiTlsXb6zRFGAUhudKK509wq8Z5hwhyYSyiR5JUhfptpZIrHwG+X5PwpFRBW721f5yqe1PRepPfMbNwkQ7t3jzYUorpYmNsOkeAzxPvu5iT/x0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=VX7Hsm19; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="VX7Hsm19" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4305413aec9so60675235e9.2 for ; Wed, 16 Oct 2024 01:38:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1729067910; x=1729672710; darn=vger.kernel.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=FmChZIcn3ram5DrPXLsJi2oFdsO/Sp5E7s6oakOpriw=; b=VX7Hsm194/aTh/HY4TDAwZL0zr3F2ARxS3huGON+W9lFUUAl9eb5Hq5/UQdh+DV4Bi aBXYegFj4Vfu9ReBNr3uBr8SkuTeDNZC6WHH2x48VLyYF1gxeyU7PKKxAvQOUrpnLc6k 5A7d/glMefeQxqkbyuKxJ6M5FhnSP7gJaWaZ4430ORW+QzQtXyn4bkh1gq01d1YLY4eo Fm8H1C4uzM1OK7i8tn1UkK4SROwCMlMhlsIdsRxaz2PdemBc/vwouXyzQA3vYjTJ4zch T9syz6j3dJKx61bbTopyd/ojIe3g6tMj4C0VKsWHr4ZJSm7nqIM2Q1Xkm1Vqxgxw+pNT 7iuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729067910; x=1729672710; 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=FmChZIcn3ram5DrPXLsJi2oFdsO/Sp5E7s6oakOpriw=; b=c8KI7pRXY/TuPDvhWQ1g/NLAEfnfulxQRO1DAyRpAtQzJSPmNPC1HdLZJRwzEN5VtL hCgSDgYajOy/DBOpRgmGHUhDrkbBgnZRA8JMPrwFy3X7PHh0CQRsvvGlAlYt9ZnnKAhw qlk4KLIiLhL8dsdDA7GvylS5IgwymECyXE/qhJEPN1FVO70KwylZMVxAulWbn6t53ixI WlWacNZCZIfGcq+aunMHZs9lqdTR9NMRMLG80gIvJP8bKNTRHTWSU+mXAKjw785V1Kj2 NH6X+dWh3a5L7feuW9HAhKuNIiKkQgbhGSk10CuVFYHi6pnQMAZezZzcMQnkXbyI2nb0 Hrtg== X-Forwarded-Encrypted: i=1; AJvYcCX16lmGMcwUK9l4PpNymqhNFu+q48v4zP563/0rEweM2IY1ENxO3saq+AGQzB0rjoegcrzcyWRjmDPgJS4=@vger.kernel.org X-Gm-Message-State: AOJu0YyZ2SlLUZFk/AYPpB7Pg1ttTEn5NJJ6SOFU4AhnuQmL396Lg4Bl u+SmMsNoPiPkxKgjNOQgLe/P/TfXvuoDOBJiNQTeaAwspCE8NoKxHmA15v4RcCA0E8zEYBiECon J X-Google-Smtp-Source: AGHT+IGR0n+c7XSqnCHxTJU2G9C304U+ZAi49P3/9N45hFLnwx6sLPhF+8rNeg2KuWiIJB7D9B4i+g== X-Received: by 2002:a05:600c:1906:b0:42c:b45d:4a7b with SMTP id 5b1f17b1804b1-4314a37bb99mr28526255e9.25.1729067910135; Wed, 16 Oct 2024 01:38:30 -0700 (PDT) Received: from alex-rivos.ba.rivosinc.com (lfbn-lyo-1-472-36.w2-7.abo.wanadoo.fr. [2.7.62.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4313f6b3c72sm42449965e9.35.2024.10.16.01.38.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 01:38:29 -0700 (PDT) From: Alexandre Ghiti To: Vladimir Isaev , Roman Artemev , Guo Ren , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Ghiti , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= Subject: [PATCH v3 2/2] riscv: Check that vdso does not contain any dynamic relocations Date: Wed, 16 Oct 2024 10:36:25 +0200 Message-Id: <20241016083625.136311-3-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241016083625.136311-1-alexghiti@rivosinc.com> References: <20241016083625.136311-1-alexghiti@rivosinc.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="utf-8" Content-Transfer-Encoding: quoted-printable Like other architectures, use the common cmd_vdso_check to make sure of that. Reviewed-by: Bj=C3=B6rn T=C3=B6pel Tested-by: Vladimir Isaev Signed-off-by: Alexandre Ghiti Reviewed-by: Guo Ren --- arch/riscv/kernel/vdso/Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makef= ile index 3f1c4b2d0b06..9a1b555e8733 100644 --- a/arch/riscv/kernel/vdso/Makefile +++ b/arch/riscv/kernel/vdso/Makefile @@ -45,7 +45,7 @@ $(obj)/vdso.o: $(obj)/vdso.so =20 # link rule for the .so file, .lds has to be first $(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE - $(call if_changed,vdsold) + $(call if_changed,vdsold_and_check) LDFLAGS_vdso.so.dbg =3D -shared -soname=3Dlinux-vdso.so.1 \ --build-id=3Dsha1 --hash-style=3Dboth --eh-frame-hdr =20 @@ -65,7 +65,8 @@ include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE # actual build commands # The DSO images are built using a special linker script # Make sure only to export the intended __vdso_xxx symbol offsets. -quiet_cmd_vdsold =3D VDSOLD $@ - cmd_vdsold =3D $(LD) $(ld_flags) -T $(filter-out FORCE,$^) -o $@.tmp= && \ +quiet_cmd_vdsold_and_check =3D VDSOLD $@ + cmd_vdsold_and_check =3D $(LD) $(ld_flags) -T $(filter-out FORCE,$^)= -o $@.tmp && \ $(OBJCOPY) $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.= tmp $@ && \ - rm $@.tmp + rm $@.tmp && \ + $(cmd_vdso_check) --=20 2.39.2