Skip to contentSkip to conversation

kernel-features: add new class

PATCH In review Armin Kuster 2 participants 6 messages May 31, 2021

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 kernel-features: add new class

This provides a common place to define kernel fragments that may be usefull to the larger community.

---
v2]
Rename class
Add warning
Add TPM

---
 meta/classes/kernel-features.bbclass | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 meta/classes/kernel-features.bbclass
meta/classes/kernel-features.bbclass new file +13 -0
new file mode 100644
index 0000000000..5735edbd7d
@@ -0,0 +1,13 @@
+#
+# Class to place yocto-kernel-cache fragments
+# selections usfull to anyone
+#
+python __anonymous() {
+    if not (bb.data.inherits_class('kernel-yocto', d)):
+        bb.warn("kernel-features class being inherited without kernel-yocto")
+}
+
+KERNEL_FEATURES_append = " ${@bb.utils.contains("DISTRO_FEATURES", "apparmor", " features/apparmor/apparmor.scc", "" ,d)}"
+KERNEL_FEATURES_append = " ${@bb.utils.contains("DISTRO_FEATURES", "smack", " features/smack/smack.scc", "" ,d)}"
+KERNEL_FEATURES_append = " ${@bb.utils.contains("DISTRO_FEATURES", "dm-verity", " features/device-mapper/dm-verity.scc", "" ,d)}"
+KERNEL_FEATURES_append = " ${@bb.utils.contains_any("MACHINE_FEATURES", "tpm tpm2", " features/tpm/tpm.scc","", d)}"
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 2/3 kernel.bbclass: link in kernel-features

--
V2]
rename kernel-kfrag to kernel-features

---
 meta/classes/kernel.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/kernel.bbclass +1 -1
index 8693ab86be..493136dfb0 100644
@@ -1,4 +1,4 @@
-inherit linux-kernel-base kernel-module-split
+inherit linux-kernel-base kernel-module-split kernel-features
 
 COMPATIBLE_HOST = ".*-linux"
 
Signature · 1 line
2.25.1
#2 lore raw

Re: [OE-core] [v2][PATCH 2/3] kernel.bbclass: link in kernel-features

Thanks for v2!

Quoted 15 lines · Armin Kuster

--
V2]
rename kernel-kfrag to kernel-features

---
 meta/classes/kernel.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/kernel.bbclass +0 -0
index 8693ab86be..493136dfb0 100644

meta/classes/kernel.bbclass line 1

Quoted 2 lines
meta/classes/kernel.bbclass +1 -1
@@ -1,4 +1,4 @@
-inherit linux-kernel-base kernel-module-split
+inherit linux-kernel-base kernel-module-split kernel-features

Since we have the bbwarn, can this just go into kernel-yocto.bbclass as a default include (for now) ?

As part of my series to move things around, I can relocate it to kernel.bbclass.

We are sending two different messages as it stands, and everyone is going to get a bbawarn that isn't using linux-yocto, but is using kernel.bbclass :D (not that i mind, but others will object ;))

Bruce

Quoted 9 lines
meta/classes/kernel.bbclass +0 -1
 COMPATIBLE_HOST = ".*-linux"
 
--

2.25.1

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II
#3 lore raw

Re: [OE-core] [v2][PATCH 2/3] kernel.bbclass: link in kernel-features

Quoted 12 lines · Bruce Ashfield

Thanks for v2!

Quoted 9 lines · Armin Kuster

--
V2]
rename kernel-kfrag to kernel-features

---
 meta/classes/kernel.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 9 lines

meta/classes/kernel.bbclass line 1

Quoted 7 lines
meta/classes/kernel.bbclass +1 -1
index 8693ab86be..493136dfb0 100644
@@ -1,4 +1,4 @@
-inherit linux-kernel-base kernel-module-split
+inherit linux-kernel-base kernel-module-split kernel-features

Since we have the bbwarn, can this just go into kernel-yocto.bbclass as a default include (for now) ?

sure.

Quoted 6 lines

As part of my series to move things around, I can relocate it to kernel.bbclass.

We are sending two different messages as it stands, and everyone is going to get a bbawarn that isn't using linux-yocto, but is using kernel.bbclass :D (not that i mind, but others will object ;))

Well. One message is from the Crazy Uncle ( and its not you )

I am not hung up on my solution. Whatevery works  when I  define a 'unique name'  to pull in kernel fragment that live in the yocto-kernel-cache. I think is silly I am doing this in a s/w layer.

-armin

Quoted 13 lines

Bruce

Quoted 8 lines
meta/classes/kernel.bbclass +0 -1
 COMPATIBLE_HOST = ".*-linux"
 
--

2.25.1

#4 lore raw

Re: [OE-core] [v2][PATCH 2/3] kernel.bbclass: link in kernel-features

Quoted 29 lines · On Mon, May 31, 2021 at 2:41 PM akuster808 <[email protected]> wrote:
Quoted 12 lines · Bruce Ashfield

Thanks for v2!

Quoted 9 lines · Armin Kuster

--
V2]
rename kernel-kfrag to kernel-features

---
 meta/classes/kernel.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 9 lines

meta/classes/kernel.bbclass line 1

Quoted 7 lines
meta/classes/kernel.bbclass +1 -1
index 8693ab86be..493136dfb0 100644
@@ -1,4 +1,4 @@
-inherit linux-kernel-base kernel-module-split
+inherit linux-kernel-base kernel-module-split kernel-features

Since we have the bbwarn, can this just go into kernel-yocto.bbclass as a default include (for now) ?

sure.

Quoted 3 lines

As part of my series to move things around, I can relocate it to kernel.bbclass.

Quoted 8 lines
Quoted 3 lines

We are sending two different messages as it stands, and everyone is going to get a bbawarn that isn't using linux-yocto, but is using kernel.bbclass :D (not that i mind, but others will object ;))

Well. One message is from the Crazy Uncle ( and its not you )

I am not hung up on my solution. Whatevery works when I define a 'unique name' to pull in kernel fragment that live in the yocto-kernel-cache. I think is silly I am doing this in a s/w layer.

I'm doing similar things in my layers as well, since from some points of view it is better to keep the userspace components that need those features close to where the KERNEL_FEATURE is enabled. But having a place where it is easy to look at what is available via DISTRO_FEATURES -> KERNEL_FEATURES is a good idea, and that's what I see in your solution.

But for this comment, I'm just suggesting that until we have some other features in place, it can serve the same purpose, but be limited in scope to kernel-yocto, where we know that it will work (and there's a smaller set of kernel versions).

The other concern that I had with some of my earlier implementations, is that with the _append technique, it isn't easy for a layer to opt-out of having those fragments applied. They can of course provide their own fragments, but keeping them out of KERNEL_FEATURES at all, is harder. Which led me to think that there should also be a global toggle.

Let me dig up my bugzilla and and see if there's any elements of that we can apply to this.

Bruce

Quoted 16 lines

-armin

Quoted 13 lines

Bruce

Quoted 8 lines
meta/classes/kernel.bbclass +0 -1
 COMPATIBLE_HOST = ".*-linux"
 
--

2.25.1

--
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end
- "Use the force Harry" - Gandalf, Star Trek II

#5 lore raw

PATCH v2 3/3 kernel-features: add ima kfrag selection

In reply to Armin Kuster
---
 meta/classes/kernel-features.bbclass | 4 ++++
 1 file changed, 4 insertions(+)
meta/classes/kernel-features.bbclass +4 -0
index 5735edbd7d..2531b42d59 100644
@@ -11,3 +11,7 @@ KERNEL_FEATURES_append = " ${@bb.utils.contains("DISTRO_FEATURES", "apparmor", "
 KERNEL_FEATURES_append = " ${@bb.utils.contains("DISTRO_FEATURES", "smack", " features/smack/smack.scc", "" ,d)}"
 KERNEL_FEATURES_append = " ${@bb.utils.contains("DISTRO_FEATURES", "dm-verity", " features/device-mapper/dm-verity.scc", "" ,d)}"
 KERNEL_FEATURES_append = " ${@bb.utils.contains_any("MACHINE_FEATURES", "tpm tpm2", " features/tpm/tpm.scc","", d)}"
+KERNEL_FEATURES_append = " ${@bb.utils.contains("DISTRO_FEATURES", "ima", " features/ima/ima.scc", "" ,d)}"
+
+KERNEL_FEATURES_append = " ${@bb.utils.contains("DISTRO_FEATURES", "modsign", " features/ima/modsign.scc", "", d)}"
+
Signature · 1 line
2.25.1