Skip to content

Commit 26b2922

Browse files
committed
chore: update patch series again
Use Fuad's just-published v13 as the base, and disable CONFIG_KVM_KVM_XEN because the kvm-clock hack breaks it (and we also dont need it for Firecracker, so let's just disable for now until we have a proper kvmclock patch). Signed-off-by: Patrick Roy <[email protected]>
1 parent 00f9feb commit 26b2922

File tree

54 files changed

+1554
-1232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1554
-1232
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
86731a2a651e58953fc949573895f2fa6d456841
1+
d7b8f8e20813f0179d8ef519541a3527e7661d3a

resources/hiding_ci/kernel_config_overrides

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ CONFIG_KVM_GENERIC_HARDWARE_ENABLING=y
1414
CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES=y
1515
CONFIG_KVM_GENERIC_PRIVATE_MEM=y
1616
CONFIG_DEBUG_INFO=y
17+
CONFIG_KVM_XEN=n
Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
From ba45bc1cd4624badfab75d73286d753403b3cfb5 Mon Sep 17 00:00:00 2001
1+
From fc57b8c1deda99bc1e64d45dd7f97a1b9259d16e Mon Sep 17 00:00:00 2001
22
From: Fuad Tabba <[email protected]>
3-
Date: Wed, 11 Jun 2025 14:33:13 +0100
4-
Subject: [PATCH 02/42] KVM: Rename CONFIG_KVM_PRIVATE_MEM to CONFIG_KVM_GMEM
3+
Date: Wed, 9 Jul 2025 11:59:27 +0100
4+
Subject: [PATCH 01/45] KVM: Rename CONFIG_KVM_PRIVATE_MEM to CONFIG_KVM_GMEM
55

6-
The option KVM_PRIVATE_MEM enables guest_memfd in general. Subsequent
7-
patches add shared memory support to guest_memfd. Therefore, rename it
8-
to KVM_GMEM to make its purpose clearer.
6+
Rename the Kconfig option CONFIG_KVM_PRIVATE_MEM to CONFIG_KVM_GMEM. The
7+
original name implied that the feature only supported "private" memory.
8+
However, CONFIG_KVM_PRIVATE_MEM enables guest_memfd in general, which is
9+
not exclusively for private memory. Subsequent patches in this series
10+
will add guest_memfd support for non-CoCo VMs, whose memory is not
11+
private.
12+
13+
Renaming the Kconfig option to CONFIG_KVM_GMEM more accurately reflects
14+
its broader scope as the main Kconfig option for all guest_memfd-backed
15+
memory. This provides clearer semantics for the option and avoids
16+
confusion as new features are introduced.
917

1018
Reviewed-by: Ira Weiny <[email protected]>
1119
Reviewed-by: Gavin Shan <[email protected]>
@@ -16,15 +24,15 @@ Signed-off-by: David Hildenbrand <[email protected]>
1624
Signed-off-by: Fuad Tabba <[email protected]>
1725
---
1826
arch/x86/include/asm/kvm_host.h | 2 +-
19-
include/linux/kvm_host.h | 10 +++++-----
27+
include/linux/kvm_host.h | 14 +++++++-------
2028
virt/kvm/Kconfig | 8 ++++----
2129
virt/kvm/Makefile.kvm | 2 +-
2230
virt/kvm/kvm_main.c | 4 ++--
2331
virt/kvm/kvm_mm.h | 4 ++--
24-
6 files changed, 15 insertions(+), 15 deletions(-)
32+
6 files changed, 17 insertions(+), 17 deletions(-)
2533

2634
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
27-
index b4a391929cdb..6e0bbf4c2202 100644
35+
index 639d9bcee842..66bdd0759d27 100644
2836
--- a/arch/x86/include/asm/kvm_host.h
2937
+++ b/arch/x86/include/asm/kvm_host.h
3038
@@ -2269,7 +2269,7 @@ void kvm_configure_mmu(bool enable_tdp, int tdp_forced_root_level,
@@ -37,7 +45,7 @@ index b4a391929cdb..6e0bbf4c2202 100644
3745
#else
3846
#define kvm_arch_has_private_mem(kvm) false
3947
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
40-
index 3bde4fb5c6aa..b2c415e81e2e 100644
48+
index 3bde4fb5c6aa..755b09dcafce 100644
4149
--- a/include/linux/kvm_host.h
4250
+++ b/include/linux/kvm_host.h
4351
@@ -601,7 +601,7 @@ struct kvm_memory_slot {
@@ -49,9 +57,14 @@ index 3bde4fb5c6aa..b2c415e81e2e 100644
4957
struct {
5058
/*
5159
* Writes protected by kvm->slots_lock. Acquiring a
52-
@@ -722,7 +722,7 @@ static inline int kvm_arch_vcpu_memslots_id(struct kvm_vcpu *vcpu)
53-
* Arch code must define kvm_arch_has_private_mem if support for private memory
54-
* is enabled.
60+
@@ -719,10 +719,10 @@ static inline int kvm_arch_vcpu_memslots_id(struct kvm_vcpu *vcpu)
61+
#endif
62+
63+
/*
64+
- * Arch code must define kvm_arch_has_private_mem if support for private memory
65+
- * is enabled.
66+
+ * Arch code must define kvm_arch_has_private_mem if support for guest_memfd is
67+
+ * enabled.
5568
*/
5669
-#if !defined(kvm_arch_has_private_mem) && !IS_ENABLED(CONFIG_KVM_PRIVATE_MEM)
5770
+#if !defined(kvm_arch_has_private_mem) && !IS_ENABLED(CONFIG_KVM_GMEM)
Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
From 3d9f3ec523f188f416761e52a5c47f7a7b457ad0 Mon Sep 17 00:00:00 2001
1+
From 2ce4cc59bb3e067e019842870824d7a459d140f0 Mon Sep 17 00:00:00 2001
22
From: Fuad Tabba <[email protected]>
3-
Date: Wed, 11 Jun 2025 14:33:14 +0100
4-
Subject: [PATCH 03/42] KVM: Rename CONFIG_KVM_GENERIC_PRIVATE_MEM to
3+
Date: Wed, 9 Jul 2025 11:59:28 +0100
4+
Subject: [PATCH 02/45] KVM: Rename CONFIG_KVM_GENERIC_PRIVATE_MEM to
55
CONFIG_KVM_GENERIC_GMEM_POPULATE
66

7-
The option KVM_GENERIC_PRIVATE_MEM enables populating a GPA range with
8-
guest data. Rename it to KVM_GENERIC_GMEM_POPULATE to make its purpose
9-
clearer.
7+
The original name was vague regarding its functionality. This Kconfig
8+
option specifically enables and gates the kvm_gmem_populate() function,
9+
which is responsible for populating a GPA range with guest data.
10+
11+
The new name, KVM_GENERIC_GMEM_POPULATE, describes the purpose of the
12+
option: to enable generic guest_memfd population mechanisms. This
13+
improves clarity for developers and ensures the name accurately reflects
14+
the functionality it controls, especially as guest_memfd support expands
15+
beyond purely "private" memory scenarios.
1016

1117
Reviewed-by: Ira Weiny <[email protected]>
1218
Reviewed-by: Gavin Shan <[email protected]>
@@ -16,14 +22,14 @@ Co-developed-by: David Hildenbrand <[email protected]>
1622
Signed-off-by: David Hildenbrand <[email protected]>
1723
Signed-off-by: Fuad Tabba <[email protected]>
1824
---
19-
arch/x86/kvm/Kconfig | 4 ++--
25+
arch/x86/kvm/Kconfig | 6 +++---
2026
include/linux/kvm_host.h | 2 +-
2127
virt/kvm/Kconfig | 2 +-
2228
virt/kvm/guest_memfd.c | 2 +-
23-
4 files changed, 5 insertions(+), 5 deletions(-)
29+
4 files changed, 6 insertions(+), 6 deletions(-)
2430

2531
diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig
26-
index 2eeffcec5382..9151cd82adab 100644
32+
index 2eeffcec5382..df1fdbb4024b 100644
2733
--- a/arch/x86/kvm/Kconfig
2834
+++ b/arch/x86/kvm/Kconfig
2935
@@ -46,7 +46,7 @@ config KVM_X86
@@ -35,6 +41,15 @@ index 2eeffcec5382..9151cd82adab 100644
3541
select KVM_WERROR if WERROR
3642

3743
config KVM
44+
@@ -95,7 +95,7 @@ config KVM_SW_PROTECTED_VM
45+
config KVM_INTEL
46+
tristate "KVM for Intel (and compatible) processors support"
47+
depends on KVM && IA32_FEAT_CTL
48+
- select KVM_GENERIC_PRIVATE_MEM if INTEL_TDX_HOST
49+
+ select KVM_GENERIC_GMEM_POPULATE if INTEL_TDX_HOST
50+
select KVM_GENERIC_MEMORY_ATTRIBUTES if INTEL_TDX_HOST
51+
help
52+
Provides support for KVM on processors equipped with Intel's VT
3853
@@ -157,7 +157,7 @@ config KVM_AMD_SEV
3954
depends on KVM_AMD && X86_64
4055
depends on CRYPTO_DEV_SP_PSP && !(KVM_AMD=y && CRYPTO_DEV_CCP_DD=m)
@@ -45,7 +60,7 @@ index 2eeffcec5382..9151cd82adab 100644
4560
select HAVE_KVM_ARCH_GMEM_INVALIDATE
4661
help
4762
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
48-
index b2c415e81e2e..7700efc06e35 100644
63+
index 755b09dcafce..359baaae5e9f 100644
4964
--- a/include/linux/kvm_host.h
5065
+++ b/include/linux/kvm_host.h
5166
@@ -2556,7 +2556,7 @@ static inline int kvm_gmem_get_pfn(struct kvm *kvm,
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
From 85b1525e138e76dd43f58e8b5cfd2f0f861ae6a6 Mon Sep 17 00:00:00 2001
2+
From: Fuad Tabba <[email protected]>
3+
Date: Wed, 9 Jul 2025 11:59:29 +0100
4+
Subject: [PATCH 03/45] KVM: Introduce kvm_arch_supports_gmem()
5+
6+
Introduce kvm_arch_supports_gmem() to explicitly indicate whether an
7+
architecture supports guest_memfd.
8+
9+
Previously, kvm_arch_has_private_mem() was used to check for guest_memfd
10+
support. However, this conflated guest_memfd with "private" memory,
11+
implying that guest_memfd was exclusively for CoCo VMs or other private
12+
memory use cases.
13+
14+
With the expansion of guest_memfd to support non-private memory, such as
15+
shared host mappings, it is necessary to decouple these concepts. The
16+
new kvm_arch_supports_gmem() function provides a clear way to check for
17+
guest_memfd support.
18+
19+
Reviewed-by: Ira Weiny <[email protected]>
20+
Reviewed-by: Gavin Shan <[email protected]>
21+
Reviewed-by: Shivank Garg <[email protected]>
22+
Reviewed-by: Vlastimil Babka <[email protected]>
23+
Co-developed-by: David Hildenbrand <[email protected]>
24+
Signed-off-by: David Hildenbrand <[email protected]>
25+
Signed-off-by: Fuad Tabba <[email protected]>
26+
---
27+
arch/x86/include/asm/kvm_host.h | 4 +++-
28+
include/linux/kvm_host.h | 11 +++++++++++
29+
virt/kvm/kvm_main.c | 4 ++--
30+
3 files changed, 16 insertions(+), 3 deletions(-)
31+
32+
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
33+
index 66bdd0759d27..09f4f6240d9d 100644
34+
--- a/arch/x86/include/asm/kvm_host.h
35+
+++ b/arch/x86/include/asm/kvm_host.h
36+
@@ -2271,8 +2271,10 @@ void kvm_configure_mmu(bool enable_tdp, int tdp_forced_root_level,
37+
38+
#ifdef CONFIG_KVM_GMEM
39+
#define kvm_arch_has_private_mem(kvm) ((kvm)->arch.has_private_mem)
40+
+#define kvm_arch_supports_gmem(kvm) kvm_arch_has_private_mem(kvm)
41+
#else
42+
#define kvm_arch_has_private_mem(kvm) false
43+
+#define kvm_arch_supports_gmem(kvm) false
44+
#endif
45+
46+
#define kvm_arch_has_readonly_mem(kvm) (!(kvm)->arch.has_protected_state)
47+
@@ -2325,7 +2327,7 @@ enum {
48+
#define HF_SMM_INSIDE_NMI_MASK (1 << 2)
49+
50+
# define KVM_MAX_NR_ADDRESS_SPACES 2
51+
-/* SMM is currently unsupported for guests with private memory. */
52+
+/* SMM is currently unsupported for guests with guest_memfd private memory. */
53+
# define kvm_arch_nr_memslot_as_ids(kvm) (kvm_arch_has_private_mem(kvm) ? 1 : 2)
54+
# define kvm_arch_vcpu_memslots_id(vcpu) ((vcpu)->arch.hflags & HF_SMM_MASK ? 1 : 0)
55+
# define kvm_memslots_for_spte_role(kvm, role) __kvm_memslots(kvm, (role).smm)
56+
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
57+
index 359baaae5e9f..ab1bde048034 100644
58+
--- a/include/linux/kvm_host.h
59+
+++ b/include/linux/kvm_host.h
60+
@@ -729,6 +729,17 @@ static inline bool kvm_arch_has_private_mem(struct kvm *kvm)
61+
}
62+
#endif
63+
64+
+/*
65+
+ * Arch code must define kvm_arch_supports_gmem if support for guest_memfd is
66+
+ * enabled.
67+
+ */
68+
+#if !defined(kvm_arch_supports_gmem) && !IS_ENABLED(CONFIG_KVM_GMEM)
69+
+static inline bool kvm_arch_supports_gmem(struct kvm *kvm)
70+
+{
71+
+ return false;
72+
+}
73+
+#endif
74+
+
75+
#ifndef kvm_arch_has_readonly_mem
76+
static inline bool kvm_arch_has_readonly_mem(struct kvm *kvm)
77+
{
78+
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
79+
index 898c3d5a7ba8..afbc025ce4d3 100644
80+
--- a/virt/kvm/kvm_main.c
81+
+++ b/virt/kvm/kvm_main.c
82+
@@ -1588,7 +1588,7 @@ static int check_memory_region_flags(struct kvm *kvm,
83+
{
84+
u32 valid_flags = KVM_MEM_LOG_DIRTY_PAGES;
85+
86+
- if (kvm_arch_has_private_mem(kvm))
87+
+ if (kvm_arch_supports_gmem(kvm))
88+
valid_flags |= KVM_MEM_GUEST_MEMFD;
89+
90+
/* Dirty logging private memory is not currently supported. */
91+
@@ -4912,7 +4912,7 @@ static int kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg)
92+
#endif
93+
#ifdef CONFIG_KVM_GMEM
94+
case KVM_CAP_GUEST_MEMFD:
95+
- return !kvm || kvm_arch_has_private_mem(kvm);
96+
+ return !kvm || kvm_arch_supports_gmem(kvm);
97+
#endif
98+
default:
99+
break;
100+
--
101+
2.49.0
102+

resources/hiding_ci/linux_patches/05-mmap-support/0004-KVM-Rename-kvm_arch_has_private_mem-to-kvm_arch_supp.patch

Lines changed: 0 additions & 147 deletions
This file was deleted.

0 commit comments

Comments
 (0)