Message ID | 20240812115945.484051-5-ubizjak@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E22DCC52D7C for <linux-mm@archiver.kernel.org>; Mon, 12 Aug 2024 12:00:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4D1FC6B009E; Mon, 12 Aug 2024 08:00:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 482C96B009F; Mon, 12 Aug 2024 08:00:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2AE216B00A0; Mon, 12 Aug 2024 08:00:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 0B2AD6B009E for <linux-mm@kvack.org>; Mon, 12 Aug 2024 08:00:08 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id ACD78C1CEA for <linux-mm@kvack.org>; Mon, 12 Aug 2024 12:00:07 +0000 (UTC) X-FDA: 82443450054.01.852064F Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) by imf16.hostedemail.com (Postfix) with ESMTP id 8F17618000D for <linux-mm@kvack.org>; Mon, 12 Aug 2024 12:00:05 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=MD3eaSLq; spf=pass (imf16.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.208.178 as permitted sender) smtp.mailfrom=ubizjak@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723463951; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=x3uJRiNLLgOcZsmmzORMPDWc5fHy9y5CyFJXSzVXE+M=; b=bqz3X3P3SaaEnFXQ2kPZpayGqk+O6E5fBMR1D+aNrFSMFnKYti3KYEkDuuFKfgJXRrpEvo XjXVsduZnud2pJutzYYoVaUYNJhC6rrFXBzI3gig+AGAUhzy8u1yEHyRXBHZEevfnQO87g ne1nJDldsHnMW6Pji9PLlGaxmFlHs9s= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=MD3eaSLq; spf=pass (imf16.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.208.178 as permitted sender) smtp.mailfrom=ubizjak@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723463951; a=rsa-sha256; cv=none; b=tSW1PVz583zpkszl7lHWe6H3BwquxKzbr9hmfgik6r98lVNbn2BEUKkMILiR0T/2+fgO8f juDt3A/fQNSO2xz4jbSk8xDbJ4Nfo4Fo7DbY/w3LeWm0KIm32Le4BjdEVLWLr2mi5z2dfX Nx3lFabCmlIODS7zMNb8MA+5T35cukw= Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2f15790b472so53121271fa.0 for <linux-mm@kvack.org>; Mon, 12 Aug 2024 05:00:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723464003; x=1724068803; darn=kvack.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=x3uJRiNLLgOcZsmmzORMPDWc5fHy9y5CyFJXSzVXE+M=; b=MD3eaSLqDKVEAkKjm8GtrAykzPJ/o0+QdCIvqybhhkx8dQmz86WbiHebKE5+w12YaR qGb1VrXGcmLyLh764X5eNnjpKVgx8xcY0ZpTD16IUfAis1tFp+0/AW7QrGYmtZdaqO4y B6uYqdx8fUBKsROEprR38QSzGJO1yziU0TZSYVbLj0NzwYRlor8bq2zBrIiGIqvxRoGN ZHgp52TO/8DAz4jvKdGB+i1kMFA6hXH1GOiDVlx4Wf/eLN9080YPDVn39T1D/xVBn9al xn4tmYw1gjXefZ9uMdSDqadvUhjsDLUL7MkFs5x8L6DEj526SyV94Egi+LjssqYNk/rf ot7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723464003; x=1724068803; 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=x3uJRiNLLgOcZsmmzORMPDWc5fHy9y5CyFJXSzVXE+M=; b=TFsvR/Ttw47I0n2HoezRgASbNs53C5UgTn3jOteS6Ojm/ea1xh6Txtsmj4NbGWIPVj wVpumlMNWeYCi1ztcXhCwkRG8ePq9Hdq497vtmZb3ci7BMLulhUEPa3jLVI+CtMcyRyq 24yh0G01XZ5Dlm2uP/7UQXr4wdjVwFIXjZCllj8A6dYNdnk7263IR8Egr1tAg88bSdrn svcdKlbw4rMuH8u+VDtqg7+XW08U6rAwSI1jOpwuaZiAnhbHnAFw1nFaLlYk1p6pWoYQ Yd4YRIH5mZbmxgwrAbQ9sTJoxrdIIK0GEHOgpnudqKGR6CrPHEtWaLMldlTubfbRvP+t nq3A== X-Gm-Message-State: AOJu0Yy3Z10yl8Hq6BEd5xk3XUqoMjOV96fjaPzMcowXSP9ycnlCO0Ha KeKQb1hIOTHg9R24VOgHj9O907AYXkMc13/O4dcNQQmstx6Rt6JTIGt/p/Q+bRo= X-Google-Smtp-Source: AGHT+IHKlXKj0B7JY5kmC2Q2zZaBnmA29zjjoQCSZ3jusm9LFJTTfxdKLemTAAxWJakoGZgPOzvHiQ== X-Received: by 2002:a05:651c:545:b0:2ef:c281:54f7 with SMTP id 38308e7fff4ca-2f1a6cf52a4mr60754621fa.37.1723464002929; Mon, 12 Aug 2024 05:00:02 -0700 (PDT) Received: from fedora.iskraemeco.si ([193.77.86.250]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5bd1a5e04aesm2055970a12.76.2024.08.12.05.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 05:00:01 -0700 (PDT) From: Uros Bizjak <ubizjak@gmail.com> To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Uros Bizjak <ubizjak@gmail.com>, Dennis Zhou <dennis@kernel.org>, Tejun Heo <tj@kernel.org>, Christoph Lameter <cl@linux.com>, Andy Lutomirski <luto@kernel.org>, Ingo Molnar <mingo@kernel.org>, Nadav Amit <nadav.amit@gmail.com>, Brian Gerst <brgerst@gmail.com>, Denys Vlasenko <dvlasenk@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>, Linus Torvalds <torvalds@linux-foundation.org>, Peter Zijlstra <peterz@infradead.org>, Thomas Gleixner <tglx@linutronix.de>, Borislav Petkov <bp@alien8.de>, Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Subject: [RFC PATCH v2 4/4] percpu/x86: Enable strict percpu checks via named AS qualifiers Date: Mon, 12 Aug 2024 13:57:38 +0200 Message-ID: <20240812115945.484051-5-ubizjak@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240812115945.484051-1-ubizjak@gmail.com> References: <20240812115945.484051-1-ubizjak@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Stat-Signature: qc43may7wtocbo5h9o9ch91puq41o4o8 X-Rspam-User: X-Rspamd-Queue-Id: 8F17618000D X-Rspamd-Server: rspam02 X-HE-Tag: 1723464005-202441 X-HE-Meta: U2FsdGVkX1/uaxCZxbaZsTzovdPdzgMysiyR7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1TS6vamef9OA+rQ0+CbYt3kefVhDkvltk1sVXyh3/iDgmcdP48mYQglj2ZPfaRlkiBik/U8EvyH8y6kAjkGZEjqfBurWdPiAg6ZaFXhOwqd+9Rjd5DJ3t1BzK35yuOOb01uerv04BqzgAh+b94b6Z5Nrb1MAqzmgdKUUqhbxHUE791shU+vHNs+SPBegVh1qXRAb2SPq4DlIO7/SKq8C7WlDPmniIwyKNqqW/B3+yA/zBltcOje20UJNNPBTzEOX3b/8FZv87cGbAEMVsSBbYtV036wx8NYyjpP0tY61CZMFM+ZASgEbPwTuvl133OyPkPHJ2qFgYq/TjdiEFqIpkIHvbU64NOsapBz5bmm1A2K0MO5JObEx6AJsUdjJPjCctDVqHf1Rl0XXia00HGyvRskjLGyRAX9lWMGnituHrBoU7Zv5UAzLcbnz+Rqqlft530QWEP4ot5QRGZzOwo3lDzLAMYZ+6syRd9O5stHumTdk7jE/DCAsceAQxkU2vUHP1+vfStw/MGGrwgzD5UHQbQBx45agGieoXAZIjQ7uRODbJHcqc2GR/NKvuqluHDdTuzjL08+DtuO8vAWQeiihv8duT8ADXGxjJ4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
Enable strict percpu address space checks
|
expand
|
diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index 4ab4ad60d767..b54119398c4b 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -95,9 +95,18 @@ #endif /* CONFIG_SMP */ -#define __my_cpu_type(var) typeof(var) __percpu_seg_override -#define __my_cpu_ptr(ptr) (__my_cpu_type(*(ptr))*)(__force uintptr_t)(ptr) -#define __my_cpu_var(var) (*__my_cpu_ptr(&(var))) +#if defined(CONFIG_USE_X86_SEG_SUPPORT) && defined(CONFIG_CC_HAS_TYPEOF_UNQUAL) +# define __my_cpu_type(var) typeof(var) +# define __my_cpu_ptr(ptr) (ptr) +# define __my_cpu_var(var) (var) + +# define __per_cpu_qual __percpu_seg_override +#else +# define __my_cpu_type(var) typeof(var) __percpu_seg_override +# define __my_cpu_ptr(ptr) (__my_cpu_type(*(ptr))*)(__force uintptr_t)(ptr) +# define __my_cpu_var(var) (*__my_cpu_ptr(&(var))) +#endif + #define __percpu_arg(x) __percpu_prefix "%" #x #define __force_percpu_arg(x) __force_percpu_prefix "%" #x
Declare percpu variables in __seg_gs/__seg_fs named AS and keep them named AS qualified until they are dereferenced with percpu accessor. This approach enables various compiler check for cross-namespace variable assignments. Signed-off-by: Uros Bizjak <ubizjak@gmail.com> Cc: Dennis Zhou <dennis@kernel.org> Cc: Tejun Heo <tj@kernel.org> Cc: Christoph Lameter <cl@linux.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Nadav Amit <nadav.amit@gmail.com> Cc: Brian Gerst <brgerst@gmail.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Borislav Petkov <bp@alien8.de> Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- arch/x86/include/asm/percpu.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)