Re: [PATCH] sparse/parse.c: ignore hotpatch attribute

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 29, 2015 at 04:22:13PM -0700, Christopher Li wrote:
> That patch looks fine.
> 
> Can you add some test case for the hot patch as well?
> It need to cover the case you run into.
> 
> Preferably cover each of the variation of hot patch.
> 
> It will be useful when we parse these attributes properly.
> 
> Chris

Something like below? I have to admit that I have not much of a clue
of what I'm doing ;)

>From 03da0b28318100cc9a1389c81920654b29405d73 Mon Sep 17 00:00:00 2001
From: Heiko Carstens <heiko.carstens@xxxxxxxxxx>
Date: Thu, 30 Apr 2015 12:53:28 +0200
Subject: [PATCH] sparse/parse.c: ignore hotpatch attribute

gcc knows about a new "hotpatch" attribute which sparse can safely ignore,
since it modifies only which code will be generated just like the
"no_instrument_function" attribute.

The gcc hotpatch feature patch:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=11762b8363737591bfb9c66093bc2edf289b917f

Currently the Linux kernel makes use of this attribute:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=61f552141c9c0e88b3fdc7046265781ffd8fa68a

Without this patch sparse will emit warnings like
"error: attribute 'hotpatch': unknown attribute"

Signed-off-by: Heiko Carstens <heiko.carstens@xxxxxxxxxx>
---
 ident-list.h               | 1 +
 parse.c                    | 2 ++
 validation/attr-hotpatch.c | 7 +++++++
 3 files changed, 10 insertions(+)
 create mode 100644 validation/attr-hotpatch.c

diff --git a/ident-list.h b/ident-list.h
index b65b667da720..1849ea613b47 100644
--- a/ident-list.h
+++ b/ident-list.h
@@ -81,6 +81,7 @@ IDENT(constructor); IDENT(__constructor__);
 IDENT(destructor); IDENT(__destructor__);
 IDENT(cold); IDENT(__cold__);
 IDENT(hot); IDENT(__hot__);
+IDENT(hotpatch); IDENT(__hotpatch__);
 IDENT(cdecl); IDENT(__cdecl__);
 IDENT(stdcall); IDENT(__stdcall__);
 IDENT(fastcall); IDENT(__fastcall__);
diff --git a/parse.c b/parse.c
index b43d6835528b..8afae73d5325 100644
--- a/parse.c
+++ b/parse.c
@@ -540,6 +540,8 @@ const char *ignored_attributes[] = {
 	"__gnu_inline__",
 	"hot",
 	"__hot__",
+	"hotpatch",
+	"__hotpatch__",
         "leaf",
         "__leaf__",
 	"l1_text",
diff --git a/validation/attr-hotpatch.c b/validation/attr-hotpatch.c
new file mode 100644
index 000000000000..205169389956
--- /dev/null
+++ b/validation/attr-hotpatch.c
@@ -0,0 +1,7 @@
+static void __attribute__((hotpatch(0,3))) bar(void)
+{
+}
+
+/*
+ * check-name: attribute hotpatch
+ */
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux