From patchwork Wed Feb 23 05:22:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junaid Shahid X-Patchwork-Id: 12756397 Return-Path: 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 70216C433F5 for ; Wed, 23 Feb 2022 05:25:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C41228D000A; Wed, 23 Feb 2022 00:25:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B51EF8D0001; Wed, 23 Feb 2022 00:25:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F5358D000A; Wed, 23 Feb 2022 00:25:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0051.hostedemail.com [216.40.44.51]) by kanga.kvack.org (Postfix) with ESMTP id 9139B8D0001 for ; Wed, 23 Feb 2022 00:25:09 -0500 (EST) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 4F084181CA34A for ; Wed, 23 Feb 2022 05:25:09 +0000 (UTC) X-FDA: 79172905938.31.F4823F4 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf16.hostedemail.com (Postfix) with ESMTP id CF1BE180004 for ; Wed, 23 Feb 2022 05:25:08 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id i6-20020a255406000000b006241e97e420so18865132ybb.5 for ; Tue, 22 Feb 2022 21:25:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=MBcUE/GjgKAOqkE7k3I16nNGFc2xdrG3rcZqdKaqU1M=; b=huyqkiXgbsdUUaeO2YcSpDguTaIsD2ZiHBttX5Znp2Wu7SotB1quckmXNNZhq3hhVZ CvfghBA5TRiyV7nNwREBXze4Ut4RZl9/dXE69gre6OrHccOhGsM1R39ve/3Fg95dFOoY BvDeP6788/BG9zG4uemrkiHvTMwkxVsftUJqZuGB4ivr+/aWtu4qk7dIqmSXEwo1GhxB UQrfqBGsjla2ZXhbWoUWiWOKjoE4zvV4OfIuCxJHeuNkl1zKwODoNYWYiaOMSwj9wOKz BS0K9yywZ4zV80Is1LL2lLof7xLiZKUcwJTWCzQDyX5SOghoozr2KNat8Mt1uT82lph4 NHIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=MBcUE/GjgKAOqkE7k3I16nNGFc2xdrG3rcZqdKaqU1M=; b=wtrYg4hlCKcKhN0Ke0JznZznj+T52B0bljoFzYqSHOr1jNoo3oHdII96a/0Q2T063S jwH8VdzV4I7VUhLMNSlnRR3FcRf2pib8ee9apxDTk81wRbyqzEV73K/vaxtNwK5GvnlE bMJEhdSULeKLMduaYLy+SSdHwomcrYysZ2N1+NKRBUfcF8rUJNJT3sXQrjpcRdVDNz/e 4Jx1SOB8qdWFK8ONwh1sv4y0AnI7yEdl7DWDGWy61AqgwXYzB2T1eOTaQRC27vTv9AEt zIsGyjgj+Pita+qoWkka9TTA5U70akb42jeih+gUrlNv4JN8IfwZ+hJdvqyrWOx/84Oz /gKg== X-Gm-Message-State: AOAM533CO8ggGU2ernavM0rJMy6BKCJvGdJFD7Y6Jg6SnFg6xNgxlw5D ODZEfnCpQ8GanVl5y2Gg5muucY90ubUG X-Google-Smtp-Source: ABdhPJzeh7uokPy0ce1B9Y+L+/uH+xpWq2sOY5OlnwbNrO2jfXStVDw+VQrszqUGfmnR9pf7y3TYhwx7yyIZ X-Received: from js-desktop.svl.corp.google.com ([2620:15c:2cd:202:ccbe:5d15:e2e6:322]) (user=junaids job=sendgmr) by 2002:a81:7d56:0:b0:2d6:90d9:770c with SMTP id y83-20020a817d56000000b002d690d9770cmr26589608ywc.277.1645593908116; Tue, 22 Feb 2022 21:25:08 -0800 (PST) Date: Tue, 22 Feb 2022 21:22:13 -0800 In-Reply-To: <20220223052223.1202152-1-junaids@google.com> Message-Id: <20220223052223.1202152-38-junaids@google.com> Mime-Version: 1.0 References: <20220223052223.1202152-1-junaids@google.com> X-Mailer: git-send-email 2.35.1.473.g83b2b277ed-goog Subject: [RFC PATCH 37/47] mm: asi: ASI annotation support for static variables. From: Junaid Shahid To: linux-kernel@vger.kernel.org Cc: Ofir Weisse , kvm@vger.kernel.org, pbonzini@redhat.com, jmattson@google.com, pjt@google.com, alexandre.chartre@oracle.com, rppt@linux.ibm.com, dave.hansen@linux.intel.com, peterz@infradead.org, tglx@linutronix.de, luto@kernel.org, linux-mm@kvack.org X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: CF1BE180004 X-Rspam-User: Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=huyqkiXg; spf=pass (imf16.hostedemail.com: domain of 3NMUVYgcKCC0SdWJRMbPXXPUN.LXVURWdg-VVTeJLT.XaP@flex--junaids.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3NMUVYgcKCC0SdWJRMbPXXPUN.LXVURWdg-VVTeJLT.XaP@flex--junaids.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: 8rqs96xweyx1g3psxydmt5kxprw3djfz X-HE-Tag: 1645593908-291455 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: From: Ofir Weisse Added the following annotations: __asi_not_sensitive: for static variables which are considered not sensitive. __asi_not_sensitive_readmostly: similar to __read_mostly, for non-sensitive static variables. Signed-off-by: Ofir Weisse --- arch/x86/include/asm/asi.h | 12 ++++++++++++ include/asm-generic/asi.h | 6 ++++++ include/asm-generic/vmlinux.lds.h | 18 +++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/asi.h b/arch/x86/include/asm/asi.h index bdb2f70d4f85..6dd9c7c8a2b8 100644 --- a/arch/x86/include/asm/asi.h +++ b/arch/x86/include/asm/asi.h @@ -177,6 +177,18 @@ static inline pgd_t *asi_pgd(struct asi *asi) return asi->pgd; } +/* IMPORTANT: Any modification to the name here should also be applied to + * include/asm-generic/vmlinux.lds.h */ +#define ASI_NON_SENSITIVE_SECTION_NAME ".data..asi_non_sensitive" +#define ASI_NON_SENSITIVE_READ_MOSTLY_SECTION_NAME \ + ".data..asi_non_sensitive_readmostly" + +#define __asi_not_sensitive \ + __section(ASI_NON_SENSITIVE_SECTION_NAME) + +#define __asi_not_sensitive_readmostly \ + __section(ASI_NON_SENSITIVE_READ_MOSTLY_SECTION_NAME) + #else /* CONFIG_ADDRESS_SPACE_ISOLATION */ static inline void asi_intr_enter(void) { } diff --git a/include/asm-generic/asi.h b/include/asm-generic/asi.h index fffb323d2a00..d9082267a5dd 100644 --- a/include/asm-generic/asi.h +++ b/include/asm-generic/asi.h @@ -121,6 +121,12 @@ void asi_flush_tlb_range(struct asi *asi, void *addr, size_t len) { } #define static_asi_enabled() false +/* IMPORTANT: Any modification to the name here should also be applied to + * include/asm-generic/vmlinux.lds.h */ + +#define __asi_not_sensitive +#define __asi_not_sensitive_readmostly + #endif /* !_ASSEMBLY_ */ #endif /* !CONFIG_ADDRESS_SPACE_ISOLATION */ diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 42f3866bca69..c769d939c15f 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -374,10 +374,26 @@ . = ALIGN(PAGE_SIZE); \ __nosave_end = .; +#ifdef CONFIG_ADDRESS_SPACE_ISOLATION +#define ASI_NOT_SENSITIVE_DATA(page_align) \ + . = ALIGN(page_align); \ + __start_asi_nonsensitive = .; \ + *(.data..asi_non_sensitive) \ + . = ALIGN(page_align); \ + __end_asi_nonsensitive = .; \ + __start_asi_nonsensitive_readmostly = .; \ + *(.data..asi_non_sensitive_readmostly) \ + . = ALIGN(page_align); \ + __end_asi_nonsensitive_readmostly = .; +#else +#define ASI_NOT_SENSITIVE_DATA +#endif + #define PAGE_ALIGNED_DATA(page_align) \ . = ALIGN(page_align); \ *(.data..page_aligned) \ - . = ALIGN(page_align); + . = ALIGN(page_align); \ + ASI_NOT_SENSITIVE_DATA(page_align) #define READ_MOSTLY_DATA(align) \ . = ALIGN(align); \