From nobody Fri Dec 19 11:52:32 2025 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) (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 21B9B3D994 for ; Mon, 8 Dec 2025 01:35:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765157704; cv=none; b=V6FeCykJmY1iPIRO7sOb5nKbo6dwyHs0GReHORjVWiNqvj8CSUAIGd/g9jMC1n0VRU+Gw/MoH6C3HIekaHmYpbSfa1f0aOYcE/B0yHAYPQTwPKmON9QpPiXIsmC7PsXeHW5EUoGcj1MUlTeodEQtIWTC+iQ7aPr0rZvyoeVb9Zs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765157704; c=relaxed/simple; bh=SO/uBVpBkuIIzQKJ7FJ4N6XOc0AIPnI/9YWidv3DGGU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=DBA4y01LzRRnCrKaponL11Mp9l2+A2xWafVYqVYMLI9AZG58gTNINhaIA66ZeqbieGhm78OJ+ZzKkvJbX93GzE2ATfmHTm5Q1wIW7A+Agq0r/ONgC90eOVL2ud73fqGn9rF21XQaIaK90I1hQu+tsX5mAG99gIjF3ImNy5k/ER4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=LWg9yqwY; arc=none smtp.client-ip=209.85.221.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="LWg9yqwY" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-42e29783a15so2467015f8f.1 for ; Sun, 07 Dec 2025 17:35:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1765157701; x=1765762501; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=eBtkJjZbx1I9UXTOuE2VVg0l9FPIfLrBbeb691OK32A=; b=LWg9yqwYGDpfJDE/SxYZfrM+Wrq2cGfE2RXRG4aSjifLayCuFNUSWLWIiO7mzc8VYF sXLqwhJyAbAcqfmbQ5oTjFY1go8rKoQ2yW7r5swZs+YNix+WqwgRCthUitDnq6asQves YfeMoI+2QMS8oI7VEcfQrXPEMyc8okNmddvihb6RB0FCfsK7MhI/AkA7BHozY9zO+TNk xgWIE9Ww6qs6IxYqdXhgdhSxu/tBZdK99+zxelouQUL3Oaq4x9aSlq3eOnOb1b0okzue vVx3KeN5n9c0Pmhv6pXucC+q0VT7Tq6EjuKjq7HLpJsHw6dNbyxW1c96C6Ri3jahq/oQ UdWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765157701; x=1765762501; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eBtkJjZbx1I9UXTOuE2VVg0l9FPIfLrBbeb691OK32A=; b=rdV9j6AR3WlpV8vJOPR+32aaUhqDWuhJgZ0Jc8eq1vVEuNfXtNqr40gbRpDU3JfI7E Ykdnk+pIbQ1DoRze1/v1XYGJ9wu2lw7n3LYv8AHbfXWZAmqAVYe7yrEs8Paf8rzhsBNC e0jjhLcBIZ4ogx21v8pR89/0j30AX4UBlInihHOOEp+sc633FPmGGQS6od9iAjJhfFJN m/pEiuEyYvu2XtqNzhL9y1Wz34yMVn3Pa0ELXMqRNek8CL0SNib333ILEDBUBcpsISkM LrMkiaebf6sx9yKGsiPJob/wBmqqWDVdeU01Zhv15mEVVjNq4/MkO0c3UM+vtHiJE0Tq Mhew== X-Forwarded-Encrypted: i=1; AJvYcCUXbKMQ81RRCr4rK/F71PPzsHoGViI1uGLjZD4Xn3EQ3p98CZF7TsSqijo+Kl9w/Z6+spHn0BTOFKhv6K8=@vger.kernel.org X-Gm-Message-State: AOJu0Yy8Wnz9lVHQV3NL5UnvH8bSGRRPcp8/wJ5p0+0zkZEMdxlqa7om qZ2F5x06Wv5pHAw/WjnEkNDtWK0wOj33jLgQBGb9Tpr9avmUF32I07wRG12p2zNzGcYD89lSwwI D/rW2p6Nmx4z0Rg== X-Google-Smtp-Source: AGHT+IFX1rQUzkbJ60inRUfGA+l8vilM82rM8xoDJk0SvBpm8ZDcz9WSvHjCCGPUjNa404N6kx3hE2aOyyc1eQ== X-Received: from wrod8.prod.google.com ([2002:adf:ef88:0:b0:42c:c2d6:2a4]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:4301:b0:429:ca7f:8d6f with SMTP id ffacd0b85a97d-42f89eeb0e1mr7707623f8f.15.1765157701430; Sun, 07 Dec 2025 17:35:01 -0800 (PST) Date: Mon, 08 Dec 2025 01:34:58 +0000 In-Reply-To: <20251208-gcov-inline-noinstr-v1-0-623c48ca5714@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251208-gcov-inline-noinstr-v1-0-623c48ca5714@google.com> X-Mailer: b4 0.14.2 Message-ID: <20251208-gcov-inline-noinstr-v1-1-623c48ca5714@google.com> Subject: [PATCH 1/2] kasan: mark !__SANITIZE_ADDRESS__ stubs __always_inline From: Brendan Jackman To: Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Marco Elver , Ard Biesheuvel Cc: kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, Brendan Jackman Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The x86 instrumented bitops in include/asm-generic/bitops/instrumented-non-atomic.h are KASAN-instrumented via explicit calls to instrument_* functions from include/linux/instrumented.h. This bitops are used from noinstr code in __sev_es_nmi_complete(). This code avoids noinstr violations by disabling __SANITIZE_ADDRESS__ etc for the compilation unit. However, when GCOV is enabled, there can still be violations caused by the stub versions of these functions, since coverage instrumentation is injected that causes them to be out-of-lined. (Note: the GCOV isntrumentation itself also appears to violate noinstr in principle, but it appears to be harmless - basically just an inc instruction). Fix this by just applying __always_inline. Signed-off-by: Brendan Jackman --- include/linux/kasan-checks.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/kasan-checks.h b/include/linux/kasan-checks.h index 3d6d22a25bdc391c0015a6daf2249d6bea752dcb..9aa0f1cc90133ca334afa478b5f= 762aef9e5d79c 100644 --- a/include/linux/kasan-checks.h +++ b/include/linux/kasan-checks.h @@ -37,11 +37,11 @@ static inline bool __kasan_check_write(const volatile v= oid *p, unsigned int size #define kasan_check_read __kasan_check_read #define kasan_check_write __kasan_check_write #else -static inline bool kasan_check_read(const volatile void *p, unsigned int s= ize) +static __always_inline bool kasan_check_read(const volatile void *p, unsig= ned int size) { return true; } -static inline bool kasan_check_write(const volatile void *p, unsigned int = size) +static __always_inline bool kasan_check_write(const volatile void *p, unsi= gned int size) { return true; } --=20 2.50.1 From nobody Fri Dec 19 11:52:32 2025 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) (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 386B722156F for ; Mon, 8 Dec 2025 01:35:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765157705; cv=none; b=MlZ0Zcw8z/Ex3njBHnhL9NlXo4w9j9b7TkDzc9kP35+Xlo1zjNBMBPSOscGCwKai7z+btn5rrddsPqQ5TYpOVKZ+LlXAeG9JFoowMj6zU9sd5ODUErg0OMZqEr9b3T5qALsu/5Jbbcr7IwA6zEhI7X0hBpW/6OdrBTC85qwJpdo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765157705; c=relaxed/simple; bh=T9HB6vI7Yc90v+b5JO4UtrN0928qnQaXIVtCCIgeHRM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=kOSKGXvlc55G6x4gHU2gpbzVDnAsLY3PZPxqexO9/Kr0xELJ3DpVzeyEBj+alV7kK1ATosZdC9XdDnpKYAoMVBUkAc+5OlQ2rwvAwOA5x/8g1BjTsA6i8pmdhgjQG8jW0wJ2B2VVNV300NcB4YNqyugj8stAvvJv3fDf853FtNE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=rXSFNPiE; arc=none smtp.client-ip=209.85.221.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="rXSFNPiE" Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-42b30184be7so1856594f8f.2 for ; Sun, 07 Dec 2025 17:35:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1765157702; x=1765762502; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=p5d1/KP4GxMhsEhwScdwPIgTBK+KcZfvdYekHvom6ic=; b=rXSFNPiEOxpQkxHHXoik31I6g3LmCHOEAX7GBUsA2aqOcu9WSkJ2EASZ+bnsoFG4iW edqI//MzKJihi/qLSyqx0HBZwh+APYklYtvOugQ58khdAyr9pjLvbSAOgx/9o2A1TRTZ ZutG7blsf/iU9Iyq7PmR814enFfgc9AR9Lq8UFkawdo6qsy//diUV1Z6RYDHYOJCbU2R t68t0n83uwswmPcIhVDJqqqyc7CUolcLcfPTa4jdzfyZi9fZBIdKbG3Pr+uyKhTTjEJj /bsmi8cQOeA3GMK6JaUkXirm9kED2WxrSfxGMq8zbZP0foKHyT0A/ZA3oWyG3yklj0vL bclg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765157702; x=1765762502; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=p5d1/KP4GxMhsEhwScdwPIgTBK+KcZfvdYekHvom6ic=; b=dFbGcAh3dfReZdPe6EJiu/ktJf39TYXtWg+SZeEdig99GP19DDWlINvAuuXSEPG7eQ fH3r5NJghTmZWYPzmslCZ6q3RyuUnUh5ZRUe5FI2ArG5H5wPS/hBHDIcpHcqwZJk38Lg iL3KjUOpPKBJdHSEft/8/dUMNF+wkKSWyJG0Nzd0yehsmjYaCwJ+GTqovwnlWSs/5ZjI CAZra6no+1X0qqyMCmBrAbKecisApbVR87OO/WC8pkJH+90IS1eJBOZqIFI1G7nv2DVb 87XxTK/3jx1Ofp+4EGO/rjdJgZKKaJUi5BiqTcP+nxSuihlcexU9PYwu0mRG61A0BPLZ vW+A== X-Forwarded-Encrypted: i=1; AJvYcCVeoIeXdUBpCtjwzCPZ6TVKwqPCfJtpNVjy6EmMTenBFoF3BhjdMUjIyUDSaxxmS/gi1GcNJKKVpzb+jz8=@vger.kernel.org X-Gm-Message-State: AOJu0YzeuWHc2DvnSCD7ujoSQ6pHhZK6Y/dbRfIXPjZ7djLH5Vt71EKj pAwa6ZbbhlrFLE7y7CsF1tfcGGQ+BZ4gBjsqOL7u1/kmAKlKQ14tPgKvjgyUC2x0/H0APDWRf0x gLFBl0TIdxX4XsA== X-Google-Smtp-Source: AGHT+IGzubu4+j4Wm71gbOmjK++zW+K5G1tJhZ31ZLEKts+FoujmHMCGALeFVIBAjlYDJOU9iVo1j5mmNPGzAw== X-Received: from wrno14.prod.google.com ([2002:adf:eace:0:b0:42c:c2d6:29a]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:2f88:b0:429:c4bb:fbd6 with SMTP id ffacd0b85a97d-42f89f48525mr6497770f8f.31.1765157702413; Sun, 07 Dec 2025 17:35:02 -0800 (PST) Date: Mon, 08 Dec 2025 01:34:59 +0000 In-Reply-To: <20251208-gcov-inline-noinstr-v1-0-623c48ca5714@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251208-gcov-inline-noinstr-v1-0-623c48ca5714@google.com> X-Mailer: b4 0.14.2 Message-ID: <20251208-gcov-inline-noinstr-v1-2-623c48ca5714@google.com> Subject: [PATCH 2/2] kcsan: mark !__SANITIZE_THREAD__ stub __always_inline From: Brendan Jackman To: Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Marco Elver , Ard Biesheuvel Cc: kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, Brendan Jackman Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The x86 instrumented bitops in include/asm-generic/bitops/instrumented-non-atomic.h are KCSAN-instrumented via explicit calls to instrument_* functions from include/linux/instrumented.h. This bitops are used from noinstr code in __sev_es_nmi_complete(). This code avoids noinstr violations by disabling __SANITIZE_THREAD__ etc for the compilation unit. However, when GCOV is enabled, there can still be violations caused by the stub versions of these functions, since coverage instrumentation is injected that causes them to be out-of-lined. (Note: the GCOV isntrumentation itself also appears to violate noinstr in principle, but it appears to be harmless - basically just an inc instruction). Fix this by just applying __always_inline. Signed-off-by: Brendan Jackman --- include/linux/kcsan-checks.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/kcsan-checks.h b/include/linux/kcsan-checks.h index 92f3843d9ebb8177432bb4eccc151ea66d3dcbb7..cabb2ae46bdc0963bd89533777c= ab586ab4d5a1b 100644 --- a/include/linux/kcsan-checks.h +++ b/include/linux/kcsan-checks.h @@ -226,7 +226,7 @@ static inline void kcsan_end_scoped_access(struct kcsan= _scoped_access *sa) { } #define __kcsan_disable_current kcsan_disable_current #define __kcsan_enable_current kcsan_enable_current_nowarn #else /* __SANITIZE_THREAD__ */ -static inline void kcsan_check_access(const volatile void *ptr, size_t siz= e, +static __always_inline void kcsan_check_access(const volatile void *ptr, s= ize_t size, int type) { } static inline void __kcsan_enable_current(void) { } static inline void __kcsan_disable_current(void) { } --=20 2.50.1