[PATCH v11 10/23] x86/kvmclock: Avoid clearing decrypted clock memory twice

Aneesh Kumar K.V (Arm) aneesh.kumar at kernel.org
Wed Dec 2 01:54:33 PST 2026


set_memory_decrypted() now clears the range even when memory encryption
is inactive, so call it unconditionally and remove the separate
memset().

Cc: Paolo Bonzini <pbonzini at redhat.com>
Cc: Thomas Gleixner <tglx at kernel.org>
Cc: Ingo Molnar <mingo at redhat.com>
Cc: Borislav Petkov <bp at alien8.de>
Cc: Dave Hansen <dave.hansen at linux.intel.com>
Cc: x86 at kernel.org
Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar at kernel.org>
---
 arch/x86/kernel/kvmclock.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index cb3d0ca1fa22..c7c306275a64 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -16,7 +16,6 @@
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/set_memory.h>
-#include <linux/cc_platform.h>
 
 #include <asm/hypervisor.h>
 #include <asm/timer.h>
@@ -247,18 +246,13 @@ static void __init kvmclock_init_mem(void)
 	 * hvclock is shared between the guest and the hypervisor, must
 	 * be mapped decrypted.
 	 */
-	if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)) {
-		r = set_memory_decrypted((unsigned long) hvclock_mem,
-					 1UL << order);
-		if (r) {
-			__free_pages(p, order);
-			hvclock_mem = NULL;
-			pr_warn("kvmclock: set_memory_decrypted() failed. Disabling\n");
-			return;
-		}
+	r = set_memory_decrypted((unsigned long)hvclock_mem, 1UL << order);
+	if (r) {
+		__free_pages(p, order);
+		hvclock_mem = NULL;
+		pr_warn("kvmclock: set_memory_decrypted() failed. Disabling\n");
+		return;
 	}
-
-	memset(hvclock_mem, 0, PAGE_SIZE << order);
 }
 
 static int __init kvm_setup_vsyscall_timeinfo(void)
-- 
2.43.0




More information about the linux-arm-kernel mailing list