All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
* [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel
@ 2026-11-26 14:30 Konstantin Khorenko
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 01/14] ms/KVM: x86/mmu: Conditionally resched when retrying gPTE walk on A/D update failure Konstantin Khorenko
                   ` (14 more replies)
  0 siblings, 15 replies; 30+ messages in thread
From: Konstantin Khorenko @ 2026-11-26 14:30 UTC (permalink / raw)
  To: Pavel Tikhomirov; +Cc: devel

Upstream fixes for the 24.x branch.

KVM, from 6.12.y stable where it has them:
- patches 1-4 (VSTOR-157287): guest-triggered host lockups and
  exhaustion, CVE-2026-99713, CVE-2026-99712, an nVMX MSR unwind fix
  and CVE-2026-99710, in patch order.
- patches 5-7 (VSTOR-157389): CVE-2026-99312, L1 left on a stale L2
  MMU root after INIT (patch 5), the same stale root reached when L2
  clears EFER.SVME without an intercept (patch 6) and its selftest.

objtool/klp (VSTOR-157133, patches 8-14): RK modules built from this
kernel would leave calls into other modules' exports unrelocated
("call +0"), point into the middle of cloned strings, accept a static
key of another module and bind a static symbol to a same-named export.
tools/objtool now matches the tree RK 10.15 for 20.14 is built with.

Assisted-by: LLM
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
Joe Lawrence (2):
      ms/objtool/klp: fix data alignment in __clone_symbol()
      ms/objtool/klp: Normalize Module.symvers paths to module names

Josh Poimboeuf (5):
      ms/objtool: Fix data alignment in elf_add_data()
      ms/objtool/klp: Fix module name normalization for paths with dots
      ms/objtool/klp: Fix cross-module klp relocation section naming
      ms/objtool/klp: Fix detection of corrupt static branch/call entries
      ms/objtool/klp: Don't match local symbols against exports

Sean Christopherson (5):
      ms/KVM: x86/mmu: Conditionally resched when retrying gPTE walk on A/D update failure
      ms/KVM: x86: Conditionally resched when restarting REP string emulation
      ms/KVM: nVMX: Process each host MSR entry at most once when unwinding failed VM-Entry
      ms/KVM: x86/mmu: Cap number of parent PTEs per SP at 1000 (the arbitrary rmap limit)
      ms/KVM: x86: Unconditionally reset MMU context when emulating INIT

Yosry Ahmed (2):
      ms/KVM: SVM: Triple fault L1 on unintercepted EFER.SVME clear by L2
      ms/KVM: selftests: Add a test for L2 clearing EFER.SVME without intercept

 arch/x86/kvm/mmu/mmu.c                             | 10 +++
 arch/x86/kvm/mmu/paging_tmpl.h                     | 11 +++-
 arch/x86/kvm/svm/svm.c                             | 13 ++++
 arch/x86/kvm/vmx/nested.c                          |  1 +
 arch/x86/kvm/x86.c                                 | 31 ++++++----
 tools/objtool/elf.c                                |  2 +-
 tools/objtool/include/objtool/klp.h                | 10 ++-
 tools/objtool/klp-diff.c                           | 71 +++++++++++++++++-----
 tools/objtool/klp-post-link.c                      | 53 +++++++++-------
 tools/testing/selftests/kvm/Makefile.kvm           |  1 +
 .../selftests/kvm/x86/svm_nested_clear_efer_svme.c | 55 +++++++++++++++++
 11 files changed, 203 insertions(+), 55 deletions(-)
---
base-commit: 8d0b6e79cc277f9895f7b25ae4356351a38f2202
change-id: 20261126-khorenko-vstor-157133-klp-and-kvm-fixes-da27221d06b3

Best regards,
--  
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Devel] [PATCH hci-8.1 01/14] ms/KVM: x86/mmu: Conditionally resched when retrying gPTE walk on A/D update failure
  2026-11-26 14:30 [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel Konstantin Khorenko
@ 2026-11-26 14:30 ` Konstantin Khorenko
  2026-12-01  0:34   ` no-reply
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 02/14] ms/KVM: x86: Conditionally resched when restarting REP string emulation Konstantin Khorenko
                   ` (13 subsequent siblings)
  14 siblings, 1 reply; 30+ messages in thread
From: Konstantin Khorenko @ 2026-11-26 14:30 UTC (permalink / raw)
  To: Pavel Tikhomirov; +Cc: devel

From: Sean Christopherson <seanjc@google.com>

[ Upstream commit b2691b3a6cd230209736c89684dab90d939aa56b ]

Conditionally reschedule when retrying a guest PTE walk because the CMPXCHG
to update A/D bits failed, e.g. because a different task/vCPU modified the
relevant gPTEs.  On kernels without involuntary preemption of some kind, a
misbehaving guest can "capture" a pCPU effectively indefinitely and trigger
soft lockups by continuously modifying its gPTEs such that the result of
the walk is remains valid.

Fixes: b3e4e63fd9ee ("KVM: MMU: Use cmpxchg for pte updates on walk_addr()")
Cc: stable@vger.kernel.org
Reported-by: Stefan Teodorescu <fane@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-ID: <20261022015903.282261-1-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 399c8c1e2ea42018960a31ef3a2e93554e50f606)

https://virtuozzo.atlassian.net/browse/VSTOR-157287
Feature: fix ms/kvm
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 arch/x86/kvm/mmu/paging_tmpl.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h
index af220c9c8ab8d..1727399b6899f 100644
--- a/arch/x86/kvm/mmu/paging_tmpl.h
+++ b/arch/x86/kvm/mmu/paging_tmpl.h
@@ -321,6 +321,13 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker,
 	gpa_t real_gpa;
 	gfn_t gfn;
 
+	/*
+	 * KVM might sleep/resched when retrying the walk if the updating A/D
+	 * fails because the gPTE changed between reading the gPTE and trying
+	 * the CMPXHG to set A/D bits.
+	 */
+	might_sleep();
+
 	trace_kvm_mmu_pagetable_walk(addr, access);
 retry_walk:
 	walker->level = mmu->cpu_role.base.level;
@@ -467,8 +474,10 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker,
 							addr, write_fault);
 		if (unlikely(ret < 0))
 			goto error;
-		else if (ret)
+		else if (ret) {
+			cond_resched();
 			goto retry_walk;
+		}
 	}
 
 	return 1;

-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Devel] [PATCH hci-8.1 02/14] ms/KVM: x86: Conditionally resched when restarting REP string emulation
  2026-11-26 14:30 [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel Konstantin Khorenko
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 01/14] ms/KVM: x86/mmu: Conditionally resched when retrying gPTE walk on A/D update failure Konstantin Khorenko
@ 2026-11-26 14:30 ` Konstantin Khorenko
  2026-12-01  0:34   ` no-reply
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 03/14] ms/KVM: nVMX: Process each host MSR entry at most once when unwinding failed VM-Entry Konstantin Khorenko
                   ` (12 subsequent siblings)
  14 siblings, 1 reply; 30+ messages in thread
From: Konstantin Khorenko @ 2026-11-26 14:30 UTC (permalink / raw)
  To: Pavel Tikhomirov; +Cc: devel

From: Sean Christopherson <seanjc@google.com>

[ Upstream commit ae85ac25eb671d174811cc3101549448671fd505 ]

When restarting emulation, e.g. of a REP-prefixed string instruction,
conditionally reschedule as emulating guest writes can be deceptively slow
and expensive, e.g. when shadow paging is in use and each write can trigger
write tracking.

In a perfect world, restarting emulation (or not) would be less arbitrary,
e.g. would honor not only host events (NEED_RESCHED, signals, etc.) but
also guest events (e.g. by checking kvm_vcpu_has_events()).  Unfortunately,
as pointed out by Sashiko, pio_in_emulated()'s read-ahead logic is baked
into the restart logic, as KVM relies on restarting emulation to drain the
cache and avoid duplicate reads from the I/O port.  I.e. re-entering the
guest on kvm_vcpu_has_events() or __xfer_to_guest_mode_work_pending() would
introduce architecturally-incorrect, guest-visible changes.

Fixes: 5cd21917da24 ("KVM: x86 emulator: restart string instruction without going back to a guest.")
Cc: stable@vger.kernel.org
Cc: David Woodhouse <dwmw2@infradead.org>
Reported-by: Stefan Teodorescu <fane@google.com>
Suggested-by: Stefan Teodorescu <fane@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-ID: <20261028173638.1765329-1-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit c1293d2134c2d63741b197a1e5a6363894ed4bce)

https://virtuozzo.atlassian.net/browse/VSTOR-157287
Feature: fix ms/kvm
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 arch/x86/kvm/x86.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index de38b59d90161..e0f575bc67f47 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -9252,10 +9252,12 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa,
 	} else if (vcpu->arch.complete_userspace_io) {
 		writeback = false;
 		r = 0;
-	} else if (r == EMULATION_RESTART)
+	} else if (r == EMULATION_RESTART) {
+		cond_resched();
 		goto restart;
-	else
+	} else {
 		r = 1;
+	}
 
 writeback:
 	if (writeback) {

-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Devel] [PATCH hci-8.1 03/14] ms/KVM: nVMX: Process each host MSR entry at most once when unwinding failed VM-Entry
  2026-11-26 14:30 [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel Konstantin Khorenko
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 01/14] ms/KVM: x86/mmu: Conditionally resched when retrying gPTE walk on A/D update failure Konstantin Khorenko
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 02/14] ms/KVM: x86: Conditionally resched when restarting REP string emulation Konstantin Khorenko
@ 2026-11-26 14:30 ` Konstantin Khorenko
  2026-12-01  0:35   ` no-reply
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 04/14] ms/KVM: x86/mmu: Cap number of parent PTEs per SP at 1000 (the arbitrary rmap limit) Konstantin Khorenko
                   ` (11 subsequent siblings)
  14 siblings, 1 reply; 30+ messages in thread
From: Konstantin Khorenko @ 2026-11-26 14:30 UTC (permalink / raw)
  To: Pavel Tikhomirov; +Cc: devel

From: Sean Christopherson <seanjc@google.com>

[ Upstream commit c33ef9d334059f7cb167569ed7b4779752fe4425 ]

Add a missing "break" in the inner for-loop of the open coded mess that
unwinds MSRs back to the pre-VM-Enter state when VMLAUNCH/VMRESUME VM-Fails
due to a consistency check that is caught by hardware but missed by KVM.
I.e. move on to the next MSR in the VM-Entry load list after performing a
write using a value found in the VM-Exit load list.  Processing *every*
matching entry in the VM-Exit load list makes the processing quadratic,
which is problematic if the load lists are full of MSRs that are expensive
to emulate.  E.g. writing APIC_BASE triggers kvm_recalculate_apic_map() and
a whole pile of unnecessary work.

Functionally, arbitrarily restoring the value of the first matching entry
is "fine", because none of this is architecturally correct: the load lists
are never supposed to have been used in the first place.  In practice, it's
likely a moot point as no well-behaved VMM will have multiple, diverging
entries in the load lists.

Fixes: bd18bffca353 ("KVM: nVMX: restore host state in nested_vmx_vmexit for VMFail")
Cc: stable@vger.kernel.org
Cc: David Woodhouse <dwmw2@infradead.org>
Reported-by: Stefan Teodorescu <fane@google.com>
Suggested-by: Stefan Teodorescu <fane@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-ID: <20261027185917.1478906-1-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 05fae367c6878d08f54a7c5bb6986a5e57e9bd1c)

https://virtuozzo.atlassian.net/browse/VSTOR-157287
Feature: fix ms/kvm
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 arch/x86/kvm/vmx/nested.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 1e34dc5313246..94facc1a2f2e7 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -4956,6 +4956,7 @@ static void nested_vmx_restore_host_state(struct kvm_vcpu *vcpu)
 					__func__, j, h.index, h.value);
 				goto vmabort;
 			}
+			break;
 		}
 	}
 

-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Devel] [PATCH hci-8.1 04/14] ms/KVM: x86/mmu: Cap number of parent PTEs per SP at 1000 (the arbitrary rmap limit)
  2026-11-26 14:30 [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel Konstantin Khorenko
                   ` (2 preceding siblings ...)
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 03/14] ms/KVM: nVMX: Process each host MSR entry at most once when unwinding failed VM-Entry Konstantin Khorenko
@ 2026-11-26 14:30 ` Konstantin Khorenko
  2026-12-01  0:36   ` no-reply
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 05/14] ms/KVM: x86: Unconditionally reset MMU context when emulating INIT Konstantin Khorenko
                   ` (10 subsequent siblings)
  14 siblings, 1 reply; 30+ messages in thread
From: Konstantin Khorenko @ 2026-11-26 14:30 UTC (permalink / raw)
  To: Pavel Tikhomirov; +Cc: devel

From: Sean Christopherson <seanjc@google.com>

[ Upstream commit e4558c3d7198ed9a0adc3304681f561f4e4d80e1 ]

When potentially reusing a shadow page, zap the shadow page if its number
of parent PTEs exceeds KVM's (mostly) arbitrary rmap recycling threshold.
Letting the guest create a (mostly) unbounded number of parent PTEs allows
the guest to coerce KVM into creating lists containing millions of PTEs,
effectively bounded only by the maximum number of shadow pages.

Because PTE lists are simple singly linked lists, removal is O(n).  Even
worse, if a list is constructed just so, teardown can be O(n^2), e.g. if
SPTEs are built such that zapping child SPTEs always zaps the last entry
in the list.  To cap things off, all paths that walk PTE lists do so
while holding mmu_lock, without conditionally rescheduling.

Using a doubly linked list would not address the issue, as removal would
remain O(n) since KVM still wouldn't know where in the list to remove from.
Removal could be made O(1) by storing a per-SPTE pointer, but that would
largely defeat the purpose of reusing SPs, and would penalize well-behaved
guests, especially for nested TDP where aliasing page tables is uncommon.

So, cap the maximum number of parent PTEs at the rmap limit.  In practice,
well-behaved guests will likely never run afoul of the limit.  E.g. when
running Linux as L1 with TDP, the number of parent PTEs for a single SP
tops out at under 200 (though undoubtedly obscure workloads can push it
higher).  Deliberately use a "greater than or equal" as opposed to rmap's
strictly "greater than", as the rmap code checks the threshold immediately
*after* inserting into the list, i.e. the limit is 1000 for rmaps, KVM just
very briefly blows past it.

Apply the check to both indirect and direct SPs, because while a fully
direct MMU naturally limits the number of parent PTEs to '1', direct SPs in
indirect MMUs have no such constraint.  E.g. if the guest maps a huge PTE
into many locations in its page tables, and KVM is backing the hugepage
with a direct SP, i.e. with a series of smaller pages, then KVM could end
up with a direct SP with many parents.

Note, shadow_mmu_try_split_huge_pages() always restarts the rmap walk or
bails entirely if it gets to the point where it tries to grab a SP, i.e.
there is *no* pre-existing bug that would be tripped by zapping a SP and
thus rmaps when getting a SP.

Cc: Jim Mattson <jmattson@google.com>
Cc: James Houghton <jthoughton@google.com>
Cc: Yosry Ahmed <yosry@kernel.org>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: stable@vger.kernel.org
Reported-by: Stefan Teodorescu <fane@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-ID: <20261027171518.1432557-1-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit edf87e07376054eedcd5306e0794a26e3004d97b)

https://virtuozzo.atlassian.net/browse/VSTOR-157287
Feature: fix ms/kvm
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 arch/x86/kvm/mmu/mmu.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 66bda34aeb7f6..d7527f2180e7a 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -2270,6 +2270,16 @@ static struct kvm_mmu_page *kvm_mmu_find_shadow_page(struct kvm *kvm,
 			continue;
 		}
 
+		/*
+		 * Note!  Unlike fully direct MMUs, direct SPs in indirect MMUs
+		 * can have an arbitrary number of parents, e.g if the guest is
+		 * mapping a huge PTE at many points in its page tables.
+		 */
+		if (pte_list_count(&sp->parent_ptes) >= RMAP_RECYCLE_THRESHOLD) {
+			kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list);
+			break;
+		}
+
 		/* unsync and write-flooding only apply to indirect SPs. */
 		if (sp->role.direct)
 			goto out;

-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Devel] [PATCH hci-8.1 05/14] ms/KVM: x86: Unconditionally reset MMU context when emulating INIT
  2026-11-26 14:30 [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel Konstantin Khorenko
                   ` (3 preceding siblings ...)
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 04/14] ms/KVM: x86/mmu: Cap number of parent PTEs per SP at 1000 (the arbitrary rmap limit) Konstantin Khorenko
@ 2026-11-26 14:30 ` Konstantin Khorenko
  2026-12-01  0:37   ` no-reply
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 06/14] ms/KVM: SVM: Triple fault L1 on unintercepted EFER.SVME clear by L2 Konstantin Khorenko
                   ` (9 subsequent siblings)
  14 siblings, 1 reply; 30+ messages in thread
From: Konstantin Khorenko @ 2026-11-26 14:30 UTC (permalink / raw)
  To: Pavel Tikhomirov; +Cc: devel

From: Sean Christopherson <seanjc@google.com>

[ Upstream commit c7c288d178cb0b78d3464a616b16b1aa0b316049 ]

Force an MMU reset when emulating an INIT even if paging was already
disabled, as the MMU page role includes guest_mode (L2), i.e. an INIT while
L2 is running with CR0.PG=0 will result in KVM running L1 with a stale MMU
context.

Alternatively, the reset could be scoped strictly to paging being enabled
or L2 being active, but SMM is also encoded in the page role.  Even though
it _should_ be impossible for the vCPU to be INIT'd while SMM is active,
there's zero value in not handling SMM.  At that point, the only scenario
where KVM _doesn't_ need to reset the MMU context is on an INIT with the
vCPU running in Real Mode or Unpaged Protect Mode, and while INIT in those
modes is somewhat common, it's far from a hot path and re-initializing the
MMU is not expensive, especially when the role isn't changing (KVM elides
most of the re-configuration in that case).

Note, like the Fixes commit, this bug only affects nested SVM as INIT is an
unconditional intercept on VMX, i.e. it's impossible to emulate INIT while
L2 is active.

Temporarily keep the guest TLB flush when CR0.PG is being cleared even
though it is fully redundant with the flush that is emitted on all INIT
events (KVM itself only does RESET when a vCPU is being created, i.e. when
CR0.PG must be '0').

Fixes: ed129ec9057f ("KVM: x86: forcibly leave nested mode on vCPU reset")
Reported-by: Stefan Teodorescu <fane@google.com>
Reported-by: Oren Yomtov <thenameisoren@gmail.com>
Reported-by: Chris Mason <mason@kernel.org>
Cc: stable@vger.kernel.org
Cc: Yosry Ahmed <yosry@kernel.org>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-ID: <20261022015407.279870-2-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit f55a3e4e08dc004b4bab7c1e9323d7e7e96e266a)

https://virtuozzo.atlassian.net/browse/VSTOR-157389
Feature: fix ms/kvm
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 arch/x86/kvm/x86.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index e0f575bc67f47..a825a48093ae1 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -12596,18 +12596,23 @@ void kvm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
 	kvm_x86_call(set_efer)(vcpu, 0);
 	kvm_x86_call(update_exception_bitmap)(vcpu);
 
+	if (old_cr0 & X86_CR0_PG)
+		kvm_make_request(KVM_REQ_TLB_FLUSH_GUEST, vcpu);
+
 	/*
-	 * On the standard CR0/CR4/EFER modification paths, there are several
-	 * complex conditions determining whether the MMU has to be reset and/or
-	 * which PCIDs have to be flushed.  However, CR0.WP and the paging-related
-	 * bits in CR4 and EFER are irrelevant if CR0.PG was '0'; and a reset+flush
-	 * is needed anyway if CR0.PG was '1' (which can only happen for INIT, as
-	 * CR0 will be '0' prior to RESET).  So we only need to check CR0.PG here.
+	 * Unconditionally reset the MMU, even though super strictly speaking,
+	 * a MMU reset is only necessary if and only one of the page role bits
+	 * is changing.  All of the CR0/CR4/EFER bits effectively get covered
+	 * by checking CR0.PG=1, as CR0.WP and the paging-related bits in CR4
+	 * and EFER are irrelevant if CR0.PG was '0'.  Subtly, if the vCPU was
+	 * in guest mode (L2) or SMM (although emulating INIT in SMM _should_
+	 * be impossible), an MMU reset is also necessary as "guest mode" and
+	 * "smm" are both encoded in the shadow page role.  As a result, the
+	 * only scenarios where an MMU reset is *not* needed is if the vCPU is
+	 * in Real Mode or Unpaged Protected Mode, and micro-optimizing those
+	 * paths are not worth the risk of running with a stale MMU context.
 	 */
-	if (old_cr0 & X86_CR0_PG) {
-		kvm_make_request(KVM_REQ_TLB_FLUSH_GUEST, vcpu);
-		kvm_mmu_reset_context(vcpu);
-	}
+	kvm_mmu_reset_context(vcpu);
 
 	/*
 	 * Intel's SDM states that all TLB entries are flushed on INIT.  AMD's

-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Devel] [PATCH hci-8.1 06/14] ms/KVM: SVM: Triple fault L1 on unintercepted EFER.SVME clear by L2
  2026-11-26 14:30 [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel Konstantin Khorenko
                   ` (4 preceding siblings ...)
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 05/14] ms/KVM: x86: Unconditionally reset MMU context when emulating INIT Konstantin Khorenko
@ 2026-11-26 14:30 ` Konstantin Khorenko
  2026-12-01  0:38   ` no-reply
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 07/14] ms/KVM: selftests: Add a test for L2 clearing EFER.SVME without intercept Konstantin Khorenko
                   ` (8 subsequent siblings)
  14 siblings, 1 reply; 30+ messages in thread
From: Konstantin Khorenko @ 2026-11-26 14:30 UTC (permalink / raw)
  To: Pavel Tikhomirov; +Cc: devel

From: Yosry Ahmed <yosry.ahmed@linux.dev>

KVM tracks when EFER.SVME is set and cleared to initialize and tear down
nested state. However, it doesn't differentiate if EFER.SVME is getting
toggled in L1 or L2+. If L2 clears EFER.SVME, and L1 does not intercept
the EFER write, KVM exits guest mode and tears down nested state while
L2 is running, executing L1 without injecting a proper #VMEXIT.

According to the APM:

    The effect of turning off EFER.SVME while a guest is running is
    undefined; therefore, the VMM should always prevent guests from
    writing EFER.

Since the behavior is architecturally undefined, KVM gets to choose what
to do. Inject a triple fault into L1 as a more graceful option that
running L1 with corrupted state.

Co-developed-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
base-commit: 95deaec3557dced322e2540bfa426e60e5373d46
Link: https://patch.msgid.link/20260209195142.2554532-2-yosry.ahmed@linux.dev
Signed-off-by: Sean Christopherson <seanjc@google.com>
(cherry picked from commit cdc69269b18a19cb76eaf7bf4fa47fe270dcaf11)

https://virtuozzo.atlassian.net/browse/VSTOR-157389
Feature: fix ms/kvm
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 arch/x86/kvm/svm/svm.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 385b6db1698af..f4e581d35c88b 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -222,6 +222,19 @@ int svm_set_efer(struct kvm_vcpu *vcpu, u64 efer)
 
 	if ((old_efer & EFER_SVME) != (efer & EFER_SVME)) {
 		if (!(efer & EFER_SVME)) {
+			/*
+			 * Architecturally, clearing EFER.SVME while a guest is
+			 * running yields undefined behavior, i.e. KVM can do
+			 * literally anything.  Force the vCPU back into L1 as
+			 * that is the safest option for KVM, but synthesize a
+			 * triple fault (for L1!) so that KVM at least doesn't
+			 * run random L2 code in the context of L1.  Do so if
+			 * and only if the vCPU is actively running, e.g. to
+			 * avoid positives if userspace is stuffing state.
+			 */
+			if (is_guest_mode(vcpu) && vcpu->wants_to_run)
+				kvm_make_request(KVM_REQ_TRIPLE_FAULT, vcpu);
+
 			svm_leave_nested(vcpu);
 			svm_set_gif(svm, true);
 			/* #GP intercept is still needed for vmware backdoor */

-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Devel] [PATCH hci-8.1 07/14] ms/KVM: selftests: Add a test for L2 clearing EFER.SVME without intercept
  2026-11-26 14:30 [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel Konstantin Khorenko
                   ` (5 preceding siblings ...)
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 06/14] ms/KVM: SVM: Triple fault L1 on unintercepted EFER.SVME clear by L2 Konstantin Khorenko
@ 2026-11-26 14:30 ` Konstantin Khorenko
  2026-12-01  0:38   ` no-reply
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 08/14] ms/objtool: Fix data alignment in elf_add_data() Konstantin Khorenko
                   ` (7 subsequent siblings)
  14 siblings, 1 reply; 30+ messages in thread
From: Konstantin Khorenko @ 2026-11-26 14:30 UTC (permalink / raw)
  To: Pavel Tikhomirov; +Cc: devel

From: Yosry Ahmed <yosry.ahmed@linux.dev>

Add a test that verifies KVM's newly introduced behavior of synthesizing
a triple fault in L1 if L2 clears EFER.SVME without an L1 interception
(which is architecturally undefined).

Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
Link: https://patch.msgid.link/20260209195142.2554532-3-yosry.ahmed@linux.dev
Signed-off-by: Sean Christopherson <seanjc@google.com>
[khorenko@: Makefile.kvm context: 24.x has no svm_nested_invalid_vmcb12_gpa
 test]
(cherry picked from commit 3900e56eb184abcc8a16ab52af24ea255589acc2)

https://virtuozzo.atlassian.net/browse/VSTOR-157389
Feature: fix ms/kvm
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 tools/testing/selftests/kvm/Makefile.kvm           |  1 +
 .../selftests/kvm/x86/svm_nested_clear_efer_svme.c | 55 ++++++++++++++++++++++
 2 files changed, 56 insertions(+)

diff --git a/tools/testing/selftests/kvm/Makefile.kvm b/tools/testing/selftests/kvm/Makefile.kvm
index 9d41f0d045ab0..a5d4d6a784ce7 100644
--- a/tools/testing/selftests/kvm/Makefile.kvm
+++ b/tools/testing/selftests/kvm/Makefile.kvm
@@ -97,6 +97,7 @@ TEST_GEN_PROGS_x86 += x86/state_test
 TEST_GEN_PROGS_x86 += x86/vmx_preemption_timer_test
 TEST_GEN_PROGS_x86 += x86/svm_vmcall_test
 TEST_GEN_PROGS_x86 += x86/svm_int_ctl_test
+TEST_GEN_PROGS_x86 += x86/svm_nested_clear_efer_svme
 TEST_GEN_PROGS_x86 += x86/svm_nested_shutdown_test
 TEST_GEN_PROGS_x86 += x86/svm_nested_soft_inject_test
 TEST_GEN_PROGS_x86 += x86/tsc_scaling_sync
diff --git a/tools/testing/selftests/kvm/x86/svm_nested_clear_efer_svme.c b/tools/testing/selftests/kvm/x86/svm_nested_clear_efer_svme.c
new file mode 100644
index 0000000000000..a521a9eed0613
--- /dev/null
+++ b/tools/testing/selftests/kvm/x86/svm_nested_clear_efer_svme.c
@@ -0,0 +1,55 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2026, Google LLC.
+ */
+#include "kvm_util.h"
+#include "vmx.h"
+#include "svm_util.h"
+#include "kselftest.h"
+
+
+#define L2_GUEST_STACK_SIZE 64
+
+static void l2_guest_code(void)
+{
+	unsigned long efer = rdmsr(MSR_EFER);
+
+	/* generic_svm_setup() initializes EFER_SVME set for L2 */
+	GUEST_ASSERT(efer & EFER_SVME);
+	wrmsr(MSR_EFER, efer & ~EFER_SVME);
+
+	/* Unreachable, L1 should be shutdown */
+	GUEST_ASSERT(0);
+}
+
+static void l1_guest_code(struct svm_test_data *svm)
+{
+	unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
+
+	generic_svm_setup(svm, l2_guest_code,
+			  &l2_guest_stack[L2_GUEST_STACK_SIZE]);
+	run_guest(svm->vmcb, svm->vmcb_gpa);
+
+	/* Unreachable, L1 should be shutdown */
+	GUEST_ASSERT(0);
+}
+
+int main(int argc, char *argv[])
+{
+	struct kvm_vcpu *vcpu;
+	struct kvm_vm *vm;
+	vm_vaddr_t nested_gva = 0;
+
+	TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_SVM));
+
+	vm = vm_create_with_one_vcpu(&vcpu, l1_guest_code);
+
+	vcpu_alloc_svm(vm, &nested_gva);
+	vcpu_args_set(vcpu, 1, nested_gva);
+
+	vcpu_run(vcpu);
+	TEST_ASSERT_KVM_EXIT_REASON(vcpu, KVM_EXIT_SHUTDOWN);
+
+	kvm_vm_free(vm);
+	return 0;
+}

-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Devel] [PATCH hci-8.1 08/14] ms/objtool: Fix data alignment in elf_add_data()
  2026-11-26 14:30 [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel Konstantin Khorenko
                   ` (6 preceding siblings ...)
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 07/14] ms/KVM: selftests: Add a test for L2 clearing EFER.SVME without intercept Konstantin Khorenko
@ 2026-11-26 14:30 ` Konstantin Khorenko
  2026-12-01  0:39   ` no-reply
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 09/14] ms/objtool/klp: fix data alignment in __clone_symbol() Konstantin Khorenko
                   ` (6 subsequent siblings)
  14 siblings, 1 reply; 30+ messages in thread
From: Konstantin Khorenko @ 2026-11-26 14:30 UTC (permalink / raw)
  To: Pavel Tikhomirov; +Cc: devel

From: Josh Poimboeuf <jpoimboe@kernel.org>

Any data added to a section needs to be aligned in accordance with the
section's sh_addralign value.  Particularly strings added to a .str1.8
section.  Otherwise you may get some funky strings.

Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffing object files")
Link: https://patch.msgid.link/d962fc0ca24fa0825cca8dad71932dccdd9312a9.1772681234.git.jpoimboe@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
(cherry picked from commit 356e4b2f5b80f757965f3f4d0219c81fca91b6f2)

https://virtuozzo.atlassian.net/browse/VSTOR-157133
Feature: klp-build support
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 tools/objtool/elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index bc1ca8e439c9a..da20cec49374b 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -1351,7 +1351,7 @@ void *elf_add_data(struct elf *elf, struct section *sec, const void *data, size_
 		memcpy(sec->data->d_buf, data, size);
 
 	sec->data->d_size = size;
-	sec->data->d_align = 1;
+	sec->data->d_align = sec->sh.sh_addralign;
 
 	offset = ALIGN_UP(sec->sh.sh_size, sec->sh.sh_addralign);
 	sec->sh.sh_size = offset + size;

-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Devel] [PATCH hci-8.1 09/14] ms/objtool/klp: fix data alignment in __clone_symbol()
  2026-11-26 14:30 [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel Konstantin Khorenko
                   ` (7 preceding siblings ...)
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 08/14] ms/objtool: Fix data alignment in elf_add_data() Konstantin Khorenko
@ 2026-11-26 14:30 ` Konstantin Khorenko
  2026-12-01  0:39   ` no-reply
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 10/14] ms/objtool/klp: Fix module name normalization for paths with dots Konstantin Khorenko
                   ` (5 subsequent siblings)
  14 siblings, 1 reply; 30+ messages in thread
From: Konstantin Khorenko @ 2026-11-26 14:30 UTC (permalink / raw)
  To: Pavel Tikhomirov; +Cc: devel

From: Joe Lawrence <joe.lawrence@redhat.com>

Commit 356e4b2f5b80 ("objtool: Fix data alignment in elf_add_data()")
corrected the alignment of data within a section (honoring the section's
sh_addralign).  Apply the same alignment when klp-diff mode clones a
symbol, adjusting the new symbol's offset for the output section's
sh_addralign.

Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffing object files")
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Link: https://patch.msgid.link/20260310203751.1479229-2-joe.lawrence@redhat.com
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
(cherry picked from commit 2f2600decb3004938762a3f2d0eba3ea9e01045b)

https://virtuozzo.atlassian.net/browse/VSTOR-157133
Feature: klp-build support
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 tools/objtool/klp-diff.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c
index 4d1f9e9977eb9..9b69666d0badc 100644
--- a/tools/objtool/klp-diff.c
+++ b/tools/objtool/klp-diff.c
@@ -14,6 +14,7 @@
 #include <objtool/util.h>
 #include <arch/special.h>
 
+#include <linux/align.h>
 #include <linux/objtool_types.h>
 #include <linux/livepatch_external.h>
 #include <linux/stringify.h>
@@ -531,7 +532,7 @@ static struct symbol *__clone_symbol(struct elf *elf, struct symbol *patched_sym
 		}
 
 		if (!is_sec_sym(patched_sym))
-			offset = sec_size(out_sec);
+			offset = ALIGN(sec_size(out_sec), out_sec->sh.sh_addralign);
 
 		if (patched_sym->len || is_sec_sym(patched_sym)) {
 			void *data = NULL;

-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Devel] [PATCH hci-8.1 10/14] ms/objtool/klp: Fix module name normalization for paths with dots
  2026-11-26 14:30 [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel Konstantin Khorenko
                   ` (8 preceding siblings ...)
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 09/14] ms/objtool/klp: fix data alignment in __clone_symbol() Konstantin Khorenko
@ 2026-11-26 14:30 ` Konstantin Khorenko
  2026-12-01  0:40   ` no-reply
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 11/14] ms/objtool/klp: Normalize Module.symvers paths to module names Konstantin Khorenko
                   ` (4 subsequent siblings)
  14 siblings, 1 reply; 30+ messages in thread
From: Konstantin Khorenko @ 2026-11-26 14:30 UTC (permalink / raw)
  To: Pavel Tikhomirov; +Cc: devel

From: Josh Poimboeuf <jpoimboe@kernel.org>

When .modinfo has no "name=" tag, __find_modname() falls back to
converting the object's build-tree path to a runtime module name by
stripping directory components, converting '-' to '_' and truncating the
file extension.

It does all that in a single pass over the entire path, so the first dot
anywhere in the path ends the name.  For an object built in a directory
whose name contains a dot, e.g. "drivers/foo-1.0/bar.o", the result is a
bogus module name.

Strip the directory components up front so only the basename is scanned
for the extension separator.

Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffing object files")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: live-patching@vger.kernel.org
Link: https://patch.msgid.link/9017b4609553bed16674e8f924d34691cbc2b2c1.1785727106.git.jpoimboe@kernel.org
(cherry picked from commit 165affd6f095323d953b0ed5823ec4d0db3b7d0d)

https://virtuozzo.atlassian.net/browse/VSTOR-157133
Feature: klp-build support
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 tools/objtool/klp-diff.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c
index 9b69666d0badc..87d14377afdc6 100644
--- a/tools/objtool/klp-diff.c
+++ b/tools/objtool/klp-diff.c
@@ -743,7 +743,7 @@ static struct export *find_export(struct symbol *sym)
 static const char *__find_modname(struct elfs *e)
 {
 	struct section *sec;
-	char *name;
+	char *name, *slash;
 
 	sec = find_section_by_name(e->orig, ".modinfo");
 	if (!sec) {
@@ -761,10 +761,12 @@ static const char *__find_modname(struct elfs *e)
 		return NULL;
 	}
 
+	slash = strrchr(name, '/');
+	if (slash)
+		name = slash + 1;
+
 	for (char *c = name; *c; c++) {
-		if (*c == '/')
-			name = c + 1;
-		else if (*c == '-')
+		if (*c == '-')
 			*c = '_';
 		else if (*c == '.') {
 			*c = '\0';

-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Devel] [PATCH hci-8.1 11/14] ms/objtool/klp: Normalize Module.symvers paths to module names
  2026-11-26 14:30 [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel Konstantin Khorenko
                   ` (9 preceding siblings ...)
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 10/14] ms/objtool/klp: Fix module name normalization for paths with dots Konstantin Khorenko
@ 2026-11-26 14:30 ` Konstantin Khorenko
  2026-12-01  0:40   ` no-reply
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 12/14] ms/objtool/klp: Fix cross-module klp relocation section naming Konstantin Khorenko
                   ` (3 subsequent siblings)
  14 siblings, 1 reply; 30+ messages in thread
From: Konstantin Khorenko @ 2026-11-26 14:30 UTC (permalink / raw)
  To: Pavel Tikhomirov; +Cc: devel

From: Joe Lawrence <joe.lawrence@redhat.com>

Module.symvers contains build-tree object paths as module identifiers
(e.g., "arch/x86/kvm/kvm") rather than runtime module names ("kvm").
Objtool's clone_reloc_klp() uses this field directly for exported
symbols, while unexported symbols correctly go through __find_modname().

This means that exported symbol relocations may land in a .klp.rela
section named with the build path rather than the module name.  That is
a crash waiting to happen: the kernel's livepatch loader silently skips
this relocation because it doesn't match the expected klp_object name.
The unresolved relocation sits in the newly activated code, crashing
when executed.

Normalize export->mod at Module.symvers read time using the same logic
as __find_modname() (refactored into a shared normalize_modname()
helper).

Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffing object files")
Reported-by: Ben Procknow <bprockno@redhat.com>
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Cc: live-patching@vger.kernel.org
Link: https://patch.msgid.link/dbe1b72931bd3c31b751fd0729613d9f2226fff6.1785727106.git.jpoimboe@kernel.org
(cherry picked from commit 8668bf91e0508abeb8e98b4edd89032be02228a1)

https://virtuozzo.atlassian.net/browse/VSTOR-157133
Feature: klp-build support
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 tools/objtool/klp-diff.c | 49 +++++++++++++++++++++++++++++++++---------------
 1 file changed, 34 insertions(+), 15 deletions(-)

diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c
index 87d14377afdc6..2dec06a4a02dc 100644
--- a/tools/objtool/klp-diff.c
+++ b/tools/objtool/klp-diff.c
@@ -83,6 +83,35 @@ static char *escape_str(const char *orig)
 	return new;
 }
 
+/*
+ * Convert a build-tree object path to a runtime module name: strip
+ * directory components, replace '-' with '_', and remove file
+ * extensions.  Examples:
+ *
+ *   "arch/x86/kvm/kvm" -> "kvm"
+ *   "arch/x86/kvm/kvm-intel" -> "kvm_intel".
+ *
+ * Used by read_exports() to normalize Module.symvers entries and by
+ * __find_modname() as a fallback when .modinfo lacks a "name=" tag.
+ */
+static char *normalize_modname(char *name)
+{
+	char *slash = strrchr(name, '/');
+
+	if (slash)
+		name = slash + 1;
+
+	for (char *c = name; *c; c++) {
+		if (*c == '-')
+			*c = '_';
+		else if (*c == '.') {
+			*c = '\0';
+			break;
+		}
+	}
+	return name;
+}
+
 static int read_exports(void)
 {
 	const char *symvers = "Module.symvers";
@@ -150,6 +179,9 @@ static int read_exports(void)
 			return -1;
 		}
 
+		if (strcmp(export->mod, "vmlinux"))
+			export->mod = normalize_modname(export->mod);
+
 		export->sym = strdup(sym);
 		if (!export->sym) {
 			ERROR_GLIBC("strdup");
@@ -743,7 +775,7 @@ static struct export *find_export(struct symbol *sym)
 static const char *__find_modname(struct elfs *e)
 {
 	struct section *sec;
-	char *name, *slash;
+	char *name;
 
 	sec = find_section_by_name(e->orig, ".modinfo");
 	if (!sec) {
@@ -761,20 +793,7 @@ static const char *__find_modname(struct elfs *e)
 		return NULL;
 	}
 
-	slash = strrchr(name, '/');
-	if (slash)
-		name = slash + 1;
-
-	for (char *c = name; *c; c++) {
-		if (*c == '-')
-			*c = '_';
-		else if (*c == '.') {
-			*c = '\0';
-			break;
-		}
-	}
-
-	return name;
+	return normalize_modname(name);
 }
 
 /* Get the object's module name as defined by the kernel (and klp_object) */

-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Devel] [PATCH hci-8.1 12/14] ms/objtool/klp: Fix cross-module klp relocation section naming
  2026-11-26 14:30 [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel Konstantin Khorenko
                   ` (10 preceding siblings ...)
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 11/14] ms/objtool/klp: Normalize Module.symvers paths to module names Konstantin Khorenko
@ 2026-11-26 14:30 ` Konstantin Khorenko
  2026-12-01  0:41   ` no-reply
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 13/14] ms/objtool/klp: Fix detection of corrupt static branch/call entries Konstantin Khorenko
                   ` (2 subsequent siblings)
  14 siblings, 1 reply; 30+ messages in thread
From: Konstantin Khorenko @ 2026-11-26 14:30 UTC (permalink / raw)
  To: Pavel Tikhomirov; +Cc: devel

From: Josh Poimboeuf <jpoimboe@kernel.org>

A klp relocation section is .klp.rela.<objname>.<secname>, where objname
is the object being patched.

klp-build wrongly derives objname from where the referenced symbol
lives, not where it's referenced.  For a cross-module reference like
patched can_isotp code calling can.ko's can_rx_unregister(), that gives
.klp.rela.can..text rather than .klp.rela.can_isotp..text.  Unless the
patch happens to patch can.ko as well, the relocation never gets applied
and the call goes off into the weeds.

Name the intermediate section __klp_relocs.<objname> so post-link can
read the patched object's name from there.

Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffing object files")
Reported-by: Joe Lawrence <joe.lawrence@redhat.com>
Link: https://lore.kernel.org/20260720145658.1103243-2-joe.lawrence@redhat.com
Acked-by: Song Liu <song@kernel.org>
Acked-by: Joe Lawrence <joe.lawrence@redhat.com>
Link: https://patch.msgid.link/ee93a08f3e55e76ffa67d04e283917ddaa893f09.1786138493.git.jpoimboe@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
(cherry picked from commit 07f14d6af9d7791fdc2b44a3dd0693e42c71d2b8)

https://virtuozzo.atlassian.net/browse/VSTOR-157133
Feature: klp-build support
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 tools/objtool/include/objtool/klp.h | 10 ++++---
 tools/objtool/klp-diff.c            | 17 +++++++++---
 tools/objtool/klp-post-link.c       | 53 ++++++++++++++++++++++---------------
 3 files changed, 52 insertions(+), 28 deletions(-)

diff --git a/tools/objtool/include/objtool/klp.h b/tools/objtool/include/objtool/klp.h
index ad830a7ce55b6..d9cb594f49244 100644
--- a/tools/objtool/include/objtool/klp.h
+++ b/tools/objtool/include/objtool/klp.h
@@ -14,11 +14,15 @@
 #define KLP_FUNCS_SEC	"__klp_funcs"
 
 /*
- * __klp_relocs is an intermediate section which are created by klp diff and
- * converted into KLP symbols/relas by "objtool klp post-link".  This is needed
- * to work around the linker, which doesn't preserve SHN_LIVEPATCH or
+ * __klp_relocs.<objname> are intermediate sections which are created by klp
+ * diff and converted into KLP symbols/relas by "objtool klp post-link".  This
+ * is needed to work around the linker, which doesn't preserve SHN_LIVEPATCH or
  * SHF_RELA_LIVEPATCH, nor does it support having two RELA sections for a
  * single PROGBITS section.
+ *
+ * "objname" is the name of the object being patched ("vmlinux" or a module
+ * name).  post-link uses it to name the resulting
+ * .klp.rela.objname.section_name sections.
  */
 #define KLP_RELOCS_SEC	"__klp_relocs"
 #define KLP_STRINGS_SEC	".rodata.klp.str1.1"
diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c
index 2dec06a4a02dc..62c9dae25cebf 100644
--- a/tools/objtool/klp-diff.c
+++ b/tools/objtool/klp-diff.c
@@ -994,8 +994,8 @@ static int clone_reloc_klp(struct elfs *e, struct reloc *patched_reloc,
 	}
 
 	/*
-	 * Create the __klp_relocs entry.  This will be converted to an actual
-	 * KLP rela by "objtool klp post-link".
+	 * Create the __klp_relocs.<objname> entry.  This will be converted to
+	 * an actual KLP rela by "objtool klp post-link".
 	 *
 	 * This intermediate step is necessary to prevent corruption by the
 	 * linker, which doesn't know how to properly handle two rela sections
@@ -1003,7 +1003,18 @@ static int clone_reloc_klp(struct elfs *e, struct reloc *patched_reloc,
 	 */
 
 	if (!klp_relocs) {
-		klp_relocs = elf_create_section(e->out, KLP_RELOCS_SEC, 0,
+		const char *objname = find_modname(e);
+		char sec_name[SEC_NAME_LEN];
+
+		if (!objname)
+			return -1;
+
+		/* section format: __klp_relocs.objname */
+		if (snprintf_check(sec_name, SEC_NAME_LEN,
+				   KLP_RELOCS_SEC ".%s", objname))
+			return -1;
+
+		klp_relocs = elf_create_section(e->out, sec_name, 0,
 						0, SHT_PROGBITS, 8, SHF_ALLOC);
 		if (!klp_relocs)
 			return -1;
diff --git a/tools/objtool/klp-post-link.c b/tools/objtool/klp-post-link.c
index c013e39957b11..350d20495897b 100644
--- a/tools/objtool/klp-post-link.c
+++ b/tools/objtool/klp-post-link.c
@@ -19,19 +19,11 @@
 #include <objtool/util.h>
 #include <linux/livepatch_external.h>
 
-static int fix_klp_relocs(struct elf *elf)
+static int fix_klp_reloc_sec(struct elf *elf, struct section *symtab,
+			     struct section *klp_relocs)
 {
-	struct section *symtab, *klp_relocs;
-
-	klp_relocs = find_section_by_name(elf, KLP_RELOCS_SEC);
-	if (!klp_relocs)
-		return 0;
-
-	symtab = find_section_by_name(elf, ".symtab");
-	if (!symtab) {
-		ERROR("missing .symtab");
-		return -1;
-	}
+	/* section format: __klp_relocs.sec_objname */
+	const char *sec_objname = klp_relocs->name + strlen(KLP_RELOCS_SEC ".");
 
 	for (int i = 0; i < sec_size(klp_relocs) / sizeof(struct klp_reloc); i++) {
 		struct klp_reloc *klp_reloc;
@@ -39,7 +31,6 @@ static int fix_klp_relocs(struct elf *elf)
 		struct section *sec, *tmp, *klp_rsec;
 		unsigned long offset;
 		struct reloc *reloc;
-		char sym_modname[64];
 		char rsec_name[SEC_NAME_LEN];
 		u64 addend;
 		struct symbol *sym, *klp_sym;
@@ -55,7 +46,7 @@ static int fix_klp_relocs(struct elf *elf)
 		reloc = find_reloc_by_dest(elf, klp_relocs,
 					   klp_reloc_off + offsetof(struct klp_reloc, offset));
 		if (!reloc) {
-			ERROR("malformed " KLP_RELOCS_SEC " section");
+			ERROR("malformed %s section", klp_relocs->name);
 			return -1;
 		}
 
@@ -66,17 +57,13 @@ static int fix_klp_relocs(struct elf *elf)
 		reloc = find_reloc_by_dest(elf, klp_relocs,
 					   klp_reloc_off + offsetof(struct klp_reloc, sym));
 		if (!reloc) {
-			ERROR("malformed " KLP_RELOCS_SEC " section");
+			ERROR("malformed %s section", klp_relocs->name);
 			return -1;
 		}
 
 		klp_sym = reloc->sym;
 		addend = reloc_addend(reloc);
 
-		/* symbol format: .klp.sym.modname.sym_name,sympos */
-		if (sscanf(klp_sym->name + strlen(KLP_SYM_PREFIX), "%55[^.]", sym_modname) != 1)
-			ERROR("can't find modname in klp symbol '%s'", klp_sym->name);
-
 		/*
 		 * Create the KLP rela:
 		 */
@@ -84,7 +71,7 @@ static int fix_klp_relocs(struct elf *elf)
 		/* section format: .klp.rela.sec_objname.section_name */
 		if (snprintf_check(rsec_name, SEC_NAME_LEN,
 				   KLP_RELOC_SEC_PREFIX "%s.%s",
-				   sym_modname, sec->name))
+				   sec_objname, sec->name))
 			return -1;
 
 		klp_rsec = find_section_by_name(elf, rsec_name);
@@ -134,10 +121,32 @@ static int fix_klp_relocs(struct elf *elf)
 	return 0;
 }
 
+static int fix_klp_relocs(struct elf *elf)
+{
+	struct section *symtab, *sec;
+
+	symtab = find_section_by_name(elf, ".symtab");
+	if (!symtab) {
+		ERROR("missing .symtab");
+		return -1;
+	}
+
+	for_each_sec(elf, sec) {
+		if (strncmp(sec->name, KLP_RELOCS_SEC ".",
+			    strlen(KLP_RELOCS_SEC ".")))
+			continue;
+
+		if (fix_klp_reloc_sec(elf, symtab, sec))
+			return -1;
+	}
+
+	return 0;
+}
+
 /*
  * This runs on the livepatch module after all other linking has been done.  It
- * converts the intermediate __klp_relocs section into proper KLP relocs to be
- * processed by livepatch.  This needs to run last to avoid linker wreckage.
+ * converts the intermediate __klp_relocs.* sections into proper KLP relocs to
+ * be processed by livepatch.  This needs to run last to avoid linker wreckage.
  * Linkers don't tend to handle the "two rela sections for a single base
  * section" case very well, nor do they appreciate SHN_LIVEPATCH.
  */

-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Devel] [PATCH hci-8.1 13/14] ms/objtool/klp: Fix detection of corrupt static branch/call entries
  2026-11-26 14:30 [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel Konstantin Khorenko
                   ` (11 preceding siblings ...)
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 12/14] ms/objtool/klp: Fix cross-module klp relocation section naming Konstantin Khorenko
@ 2026-11-26 14:30 ` Konstantin Khorenko
  2026-12-01  0:43   ` no-reply
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 14/14] ms/objtool/klp: Don't match local symbols against exports Konstantin Khorenko
  2026-11-26 14:46 ` [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel Konstantin Khorenko
  14 siblings, 1 reply; 30+ messages in thread
From: Konstantin Khorenko @ 2026-11-26 14:30 UTC (permalink / raw)
  To: Pavel Tikhomirov; +Cc: devel

From: Josh Poimboeuf <jpoimboe@kernel.org>

Patching a function which references a static key living in a kernel
module is unsupported due to ordering issues inherent to late module
patching:

  1) Load a livepatch module which has a __jump_table entry which needs
     a klp reloc to reference static key K which lives in module M.

  2) The __jump_table klp reloc does *not* get resolved because module M
     is not yet loaded.

  3) jump_label_add_module() corrupts memory (or causes a panic) when
     dereferencing the uninitialized pointer to key K.

validate_special_section_klp_reloc() intends to prevent that from ever
happening by catching it at build time.  However, it incorrectly assumes
the special section entry's reloc symbol references have already been
converted from section symbols to object symbols, causing the validation
to miss corruption in extracted static branch/call table entries.

Make sure the references have been properly converted before doing the
validation.

Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffing object files")
Reported-by: Song Liu <song@kernel.org>
Reviewed-and-tested-by: Song Liu <song@kernel.org>
Link: https://patch.msgid.link/124ad747b751df0df1725eff89de8332e3fb26d6.1770759954.git.jpoimboe@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
(cherry picked from commit f9fb44b0ecefc1f218db56661ed66d4e8d67317d)

https://virtuozzo.atlassian.net/browse/VSTOR-157133
Feature: klp-build support
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 tools/objtool/klp-diff.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c
index 62c9dae25cebf..e27cde34c1a18 100644
--- a/tools/objtool/klp-diff.c
+++ b/tools/objtool/klp-diff.c
@@ -1368,6 +1368,9 @@ static int validate_special_section_klp_reloc(struct elfs *e, struct symbol *sym
 		const char *sym_modname;
 		struct export *export;
 
+		if (convert_reloc_sym(e->patched, reloc))
+			continue;
+
 		/* Static branch/call keys are always STT_OBJECT */
 		if (reloc->sym->type != STT_OBJECT) {
 

-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Devel] [PATCH hci-8.1 14/14] ms/objtool/klp: Don't match local symbols against exports
  2026-11-26 14:30 [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel Konstantin Khorenko
                   ` (12 preceding siblings ...)
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 13/14] ms/objtool/klp: Fix detection of corrupt static branch/call entries Konstantin Khorenko
@ 2026-11-26 14:30 ` Konstantin Khorenko
  2026-12-01  0:43   ` no-reply
  2026-11-26 14:46 ` [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel Konstantin Khorenko
  14 siblings, 1 reply; 30+ messages in thread
From: Konstantin Khorenko @ 2026-11-26 14:30 UTC (permalink / raw)
  To: Pavel Tikhomirov; +Cc: devel

From: Josh Poimboeuf <jpoimboe@kernel.org>

While cloning a reloc, klp diff calls find_export() to determine whether
the referenced symbol is exported.  That decides whether the reference
needs a klp reloc, which object the klp symbol belongs to, and whether
the symbol's data needs to be copied into the patch module.

But find_export() matches purely on symbol name, so a static function or
variable which happens to share its name with an export is mistaken for
a reference to that export:

  - klp_reloc_needed() creates a klp reloc pointing at the exporting
    module's symbol rather than the local one.  For a vmlinux export it
    skips the klp reloc altogether, leaving a normal reloc which the
    module loader resolves to the vmlinux symbol.

  - clone_reloc() treats the symbol as external and clones it without
    its data, leaving a dangling reference.

  - validate_special_section_klp_reloc() attributes a static branch or
    call key to the wrong module, and for a vmlinux export skips the
    unsupported-key check entirely.

Exports are always global, so ignore local symbols in find_export().

Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffing object files")
Acked-by: Song Liu <song@kernel.org>
Acked-by: Joe Lawrence <joe.lawrence@redhat.com>
Link: https://patch.msgid.link/dafc7c017d1f62e2190a20dc84a52fbfc4c70210.1786138493.git.jpoimboe@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
(cherry picked from commit 86a697572c6271083694025eefa8de518eeef623)

https://virtuozzo.atlassian.net/browse/VSTOR-157133
Feature: klp-build support
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 tools/objtool/klp-diff.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c
index e27cde34c1a18..7bf248f6938b7 100644
--- a/tools/objtool/klp-diff.c
+++ b/tools/objtool/klp-diff.c
@@ -764,6 +764,9 @@ static struct export *find_export(struct symbol *sym)
 {
 	struct export *export;
 
+	if (is_local_sym(sym))
+		return NULL;
+
 	hash_for_each_possible(exports, export, hash, str_hash(sym->name)) {
 		if (!strcmp(export->sym, sym->name))
 			return export;

-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel
  2026-11-26 14:30 [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel Konstantin Khorenko
                   ` (13 preceding siblings ...)
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 14/14] ms/objtool/klp: Don't match local symbols against exports Konstantin Khorenko
@ 2026-11-26 14:46 ` Konstantin Khorenko
  14 siblings, 0 replies; 30+ messages in thread
From: Konstantin Khorenko @ 2026-11-26 14:46 UTC (permalink / raw)
  To: Pavel Tikhomirov, Konstantin Khorenko; +Cc: devel

On Thu, 26 Nov 2026 15:30:13 +0100, Konstantin Khorenko wrote:
> objtool/klp and KVM fixes for the 8.1 kernel
> 
> Upstream fixes for the 24.x branch.
> 
> KVM, from 6.12.y stable where it has them:
> - patches 1-4 (VSTOR-157287): guest-triggered host lockups and
>   exhaustion, CVE-2026-99713, CVE-2026-99712, an nVMX MSR unwind fix
>   and CVE-2026-99710, in patch order.
> - patches 5-7 (VSTOR-157389): CVE-2026-99312, L1 left on a stale L2
>   MMU root after INIT (patch 5), the same stale root reached when L2
>   clears EFER.SVME without an intercept (patch 6) and its selftest.
> 
> [...]

Applied to branch-rh10-6.12.0-211.75.1.24.x.vz10-ovz, will be released in rh10-6.12.0-211.75.1.24.4.vz10, thanks!

[01/14] ms/KVM: x86/mmu: Conditionally resched when retrying gPTE walk on A/D update failure
        https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/02ea93c63d02
[02/14] ms/KVM: x86: Conditionally resched when restarting REP string emulation
        https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/a4f5e352bffe
[03/14] ms/KVM: nVMX: Process each host MSR entry at most once when unwinding failed VM-Entry
        https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/32b101c30687
[04/14] ms/KVM: x86/mmu: Cap number of parent PTEs per SP at 1000 (the arbitrary rmap limit)
        https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/b2abf97538dd
[05/14] ms/KVM: x86: Unconditionally reset MMU context when emulating INIT
        https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/780fb895ea40
[06/14] ms/KVM: SVM: Triple fault L1 on unintercepted EFER.SVME clear by L2
        https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/19d16ba1d9bf
[07/14] ms/KVM: selftests: Add a test for L2 clearing EFER.SVME without intercept
        https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/38092e9c8583
[08/14] ms/objtool: Fix data alignment in elf_add_data()
        https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/5a92972280e7
[09/14] ms/objtool/klp: fix data alignment in __clone_symbol()
        https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/f65d843eb106
[10/14] ms/objtool/klp: Fix module name normalization for paths with dots
        https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/c2155cfb68c3
[11/14] ms/objtool/klp: Normalize Module.symvers paths to module names
        https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/67b5a96e0e10
[12/14] ms/objtool/klp: Fix cross-module klp relocation section naming
        https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/ae940d829f61
[13/14] ms/objtool/klp: Fix detection of corrupt static branch/call entries
        https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/77c47c65eaf3
[14/14] ms/objtool/klp: Don't match local symbols against exports
        https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/c9c907710082

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Devel] [PATCH hci-8.1 01/14] ms/KVM: x86/mmu: Conditionally resched when retrying gPTE walk on A/D update failure
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 01/14] ms/KVM: x86/mmu: Conditionally resched when retrying gPTE walk on A/D update failure Konstantin Khorenko
@ 2026-12-01  0:34   ` no-reply
  0 siblings, 0 replies; 30+ messages in thread
From: no-reply @ 2026-12-01  0:34 UTC (permalink / raw)
  To: Konstantin Khorenko, Pavel Tikhomirov; +Cc: devel

> From: Sean Christopherson <seanjc@google.com>
> 
> [ Upstream commit b2691b3a6cd230209736c89684dab90d939aa56b ]
> 
> Conditionally reschedule when retrying a guest PTE walk because the CMPXCHG
> to update A/D bits failed, e.g. because a different task/vCPU modified the
> relevant gPTEs.  On kernels without involuntary preemption of some kind, a
> misbehaving guest can "capture" a pCPU effectively indefinitely and trigger
> soft lockups by continuously modifying its gPTEs such that the result of
> the walk is remains valid.
> 
> Fixes: b3e4e63fd9ee ("KVM: MMU: Use cmpxchg for pte updates on walk_addr()")
> Cc: stable@vger.kernel.org
> Reported-by: Stefan Teodorescu <fane@google.com>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> Message-ID: <20261022015903.282261-1-seanjc@google.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> (cherry picked from commit 399c8c1e2ea42018960a31ef3a2e93554e50f606)
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-157287
> Feature: fix ms/kvm
> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261126-khorenko-vstor-157133-klp-and-kvm-fixes-v1-0-0ec8eaadf1bc@virtuozzo.com?part=1


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Devel] [PATCH hci-8.1 02/14] ms/KVM: x86: Conditionally resched when restarting REP string emulation
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 02/14] ms/KVM: x86: Conditionally resched when restarting REP string emulation Konstantin Khorenko
@ 2026-12-01  0:34   ` no-reply
  0 siblings, 0 replies; 30+ messages in thread
From: no-reply @ 2026-12-01  0:34 UTC (permalink / raw)
  To: Konstantin Khorenko, Pavel Tikhomirov; +Cc: devel

> From: Sean Christopherson <seanjc@google.com>
> 
> [ Upstream commit ae85ac25eb671d174811cc3101549448671fd505 ]
> 
> When restarting emulation, e.g. of a REP-prefixed string instruction,
> conditionally reschedule as emulating guest writes can be deceptively slow
> and expensive, e.g. when shadow paging is in use and each write can trigger
> write tracking.
> 
> In a perfect world, restarting emulation (or not) would be less arbitrary,
> e.g. would honor not only host events (NEED_RESCHED, signals, etc.) but
> also guest events (e.g. by checking kvm_vcpu_has_events()).  Unfortunately,
> as pointed out by Sashiko, pio_in_emulated()'s read-ahead logic is baked
> into the restart logic, as KVM relies on restarting emulation to drain the
> cache and avoid duplicate reads from the I/O port.  I.e. re-entering the
> [ ... ]
> (cherry picked from commit c1293d2134c2d63741b197a1e5a6363894ed4bce)
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-157287
> Feature: fix ms/kvm
> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261126-khorenko-vstor-157133-klp-and-kvm-fixes-v1-0-0ec8eaadf1bc@virtuozzo.com?part=2


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Devel] [PATCH hci-8.1 03/14] ms/KVM: nVMX: Process each host MSR entry at most once when unwinding failed VM-Entry
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 03/14] ms/KVM: nVMX: Process each host MSR entry at most once when unwinding failed VM-Entry Konstantin Khorenko
@ 2026-12-01  0:35   ` no-reply
  0 siblings, 0 replies; 30+ messages in thread
From: no-reply @ 2026-12-01  0:35 UTC (permalink / raw)
  To: Konstantin Khorenko, Pavel Tikhomirov; +Cc: devel

> From: Sean Christopherson <seanjc@google.com>
> 
> [ Upstream commit c33ef9d334059f7cb167569ed7b4779752fe4425 ]
> 
> Add a missing "break" in the inner for-loop of the open coded mess that
> unwinds MSRs back to the pre-VM-Enter state when VMLAUNCH/VMRESUME VM-Fails
> due to a consistency check that is caught by hardware but missed by KVM.
> I.e. move on to the next MSR in the VM-Entry load list after performing a
> write using a value found in the VM-Exit load list.  Processing *every*
> matching entry in the VM-Exit load list makes the processing quadratic,
> which is problematic if the load lists are full of MSRs that are expensive
> to emulate.  E.g. writing APIC_BASE triggers kvm_recalculate_apic_map() and
> a whole pile of unnecessary work.
> 
> Functionally, arbitrarily restoring the value of the first matching entry
> [ ... ]
> (cherry picked from commit 05fae367c6878d08f54a7c5bb6986a5e57e9bd1c)
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-157287
> Feature: fix ms/kvm
> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261126-khorenko-vstor-157133-klp-and-kvm-fixes-v1-0-0ec8eaadf1bc@virtuozzo.com?part=3


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Devel] [PATCH hci-8.1 04/14] ms/KVM: x86/mmu: Cap number of parent PTEs per SP at 1000 (the arbitrary rmap limit)
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 04/14] ms/KVM: x86/mmu: Cap number of parent PTEs per SP at 1000 (the arbitrary rmap limit) Konstantin Khorenko
@ 2026-12-01  0:36   ` no-reply
  0 siblings, 0 replies; 30+ messages in thread
From: no-reply @ 2026-12-01  0:36 UTC (permalink / raw)
  To: Konstantin Khorenko, Pavel Tikhomirov; +Cc: devel

> From: Sean Christopherson <seanjc@google.com>
> 
> [ Upstream commit e4558c3d7198ed9a0adc3304681f561f4e4d80e1 ]
> 
> When potentially reusing a shadow page, zap the shadow page if its number
> of parent PTEs exceeds KVM's (mostly) arbitrary rmap recycling threshold.
> Letting the guest create a (mostly) unbounded number of parent PTEs allows
> the guest to coerce KVM into creating lists containing millions of PTEs,
> effectively bounded only by the maximum number of shadow pages.
> 
> Because PTE lists are simple singly linked lists, removal is O(n).  Even
> worse, if a list is constructed just so, teardown can be O(n^2), e.g. if
> SPTEs are built such that zapping child SPTEs always zaps the last entry
> in the list.  To cap things off, all paths that walk PTE lists do so
> while holding mmu_lock, without conditionally rescheduling.
> [ ... ]
> (cherry picked from commit edf87e07376054eedcd5306e0794a26e3004d97b)
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-157287
> Feature: fix ms/kvm
> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261126-khorenko-vstor-157133-klp-and-kvm-fixes-v1-0-0ec8eaadf1bc@virtuozzo.com?part=4


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Devel] [PATCH hci-8.1 05/14] ms/KVM: x86: Unconditionally reset MMU context when emulating INIT
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 05/14] ms/KVM: x86: Unconditionally reset MMU context when emulating INIT Konstantin Khorenko
@ 2026-12-01  0:37   ` no-reply
  0 siblings, 0 replies; 30+ messages in thread
From: no-reply @ 2026-12-01  0:37 UTC (permalink / raw)
  To: Konstantin Khorenko, Pavel Tikhomirov; +Cc: devel

> From: Sean Christopherson <seanjc@google.com>
> 
> [ Upstream commit c7c288d178cb0b78d3464a616b16b1aa0b316049 ]
> 
> Force an MMU reset when emulating an INIT even if paging was already
> disabled, as the MMU page role includes guest_mode (L2), i.e. an INIT while
> L2 is running with CR0.PG=0 will result in KVM running L1 with a stale MMU
> context.
> 
> Alternatively, the reset could be scoped strictly to paging being enabled
> or L2 being active, but SMM is also encoded in the page role.  Even though
> it _should_ be impossible for the vCPU to be INIT'd while SMM is active,
> there's zero value in not handling SMM.  At that point, the only scenario
> where KVM _doesn't_ need to reset the MMU context is on an INIT with the
> vCPU running in Real Mode or Unpaged Protect Mode, and while INIT in those
> [ ... ]
> (cherry picked from commit f55a3e4e08dc004b4bab7c1e9323d7e7e96e266a)
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-157389
> Feature: fix ms/kvm
> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261126-khorenko-vstor-157133-klp-and-kvm-fixes-v1-0-0ec8eaadf1bc@virtuozzo.com?part=5


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Devel] [PATCH hci-8.1 06/14] ms/KVM: SVM: Triple fault L1 on unintercepted EFER.SVME clear by L2
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 06/14] ms/KVM: SVM: Triple fault L1 on unintercepted EFER.SVME clear by L2 Konstantin Khorenko
@ 2026-12-01  0:38   ` no-reply
  0 siblings, 0 replies; 30+ messages in thread
From: no-reply @ 2026-12-01  0:38 UTC (permalink / raw)
  To: Konstantin Khorenko, Pavel Tikhomirov; +Cc: devel

> From: Yosry Ahmed <yosry.ahmed@linux.dev>
> 
> KVM tracks when EFER.SVME is set and cleared to initialize and tear down
> nested state. However, it doesn't differentiate if EFER.SVME is getting
> toggled in L1 or L2+. If L2 clears EFER.SVME, and L1 does not intercept
> the EFER write, KVM exits guest mode and tears down nested state while
> L2 is running, executing L1 without injecting a proper #VMEXIT.
> 
> According to the APM:
> 
>     The effect of turning off EFER.SVME while a guest is running is
>     undefined; therefore, the VMM should always prevent guests from
>     writing EFER.
> 
> Since the behavior is architecturally undefined, KVM gets to choose what
> to do. Inject a triple fault into L1 as a more graceful option that
> running L1 with corrupted state.
> 
> Co-developed-by: Sean Christopherson <seanjc@google.com>
> Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
> base-commit: 95deaec3557dced322e2540bfa426e60e5373d46
> Link: https://patch.msgid.link/20260209195142.2554532-2-yosry.ahmed@linux.dev
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> (cherry picked from commit cdc69269b18a19cb76eaf7bf4fa47fe270dcaf11)
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-157389
> Feature: fix ms/kvm
> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261126-khorenko-vstor-157133-klp-and-kvm-fixes-v1-0-0ec8eaadf1bc@virtuozzo.com?part=6


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Devel] [PATCH hci-8.1 07/14] ms/KVM: selftests: Add a test for L2 clearing EFER.SVME without intercept
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 07/14] ms/KVM: selftests: Add a test for L2 clearing EFER.SVME without intercept Konstantin Khorenko
@ 2026-12-01  0:38   ` no-reply
  0 siblings, 0 replies; 30+ messages in thread
From: no-reply @ 2026-12-01  0:38 UTC (permalink / raw)
  To: Konstantin Khorenko, Pavel Tikhomirov; +Cc: devel

> From: Yosry Ahmed <yosry.ahmed@linux.dev>
> 
> Add a test that verifies KVM's newly introduced behavior of synthesizing
> a triple fault in L1 if L2 clears EFER.SVME without an L1 interception
> (which is architecturally undefined).
> 
> Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
> Link: https://patch.msgid.link/20260209195142.2554532-3-yosry.ahmed@linux.dev
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> [khorenko@: Makefile.kvm context: 24.x has no svm_nested_invalid_vmcb12_gpa
>  test]
> (cherry picked from commit 3900e56eb184abcc8a16ab52af24ea255589acc2)
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-157389
> Feature: fix ms/kvm
> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261126-khorenko-vstor-157133-klp-and-kvm-fixes-v1-0-0ec8eaadf1bc@virtuozzo.com?part=7


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Devel] [PATCH hci-8.1 08/14] ms/objtool: Fix data alignment in elf_add_data()
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 08/14] ms/objtool: Fix data alignment in elf_add_data() Konstantin Khorenko
@ 2026-12-01  0:39   ` no-reply
  0 siblings, 0 replies; 30+ messages in thread
From: no-reply @ 2026-12-01  0:39 UTC (permalink / raw)
  To: Konstantin Khorenko, Pavel Tikhomirov; +Cc: devel

> From: Josh Poimboeuf <jpoimboe@kernel.org>
> 
> Any data added to a section needs to be aligned in accordance with the
> section's sh_addralign value.  Particularly strings added to a .str1.8
> section.  Otherwise you may get some funky strings.
> 
> Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffing object files")
> Link: https://patch.msgid.link/d962fc0ca24fa0825cca8dad71932dccdd9312a9.1772681234.git.jpoimboe@kernel.org
> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
> (cherry picked from commit 356e4b2f5b80f757965f3f4d0219c81fca91b6f2)
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-157133
> Feature: klp-build support
> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261126-khorenko-vstor-157133-klp-and-kvm-fixes-v1-0-0ec8eaadf1bc@virtuozzo.com?part=8


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Devel] [PATCH hci-8.1 09/14] ms/objtool/klp: fix data alignment in __clone_symbol()
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 09/14] ms/objtool/klp: fix data alignment in __clone_symbol() Konstantin Khorenko
@ 2026-12-01  0:39   ` no-reply
  0 siblings, 0 replies; 30+ messages in thread
From: no-reply @ 2026-12-01  0:39 UTC (permalink / raw)
  To: Konstantin Khorenko, Pavel Tikhomirov; +Cc: devel

> From: Joe Lawrence <joe.lawrence@redhat.com>
> 
> Commit 356e4b2f5b80 ("objtool: Fix data alignment in elf_add_data()")
> corrected the alignment of data within a section (honoring the section's
> sh_addralign).  Apply the same alignment when klp-diff mode clones a
> symbol, adjusting the new symbol's offset for the output section's
> sh_addralign.
> 
> Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffing object files")
> Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
> Link: https://patch.msgid.link/20260310203751.1479229-2-joe.lawrence@redhat.com
> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
> (cherry picked from commit 2f2600decb3004938762a3f2d0eba3ea9e01045b)
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-157133
> Feature: klp-build support
> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261126-khorenko-vstor-157133-klp-and-kvm-fixes-v1-0-0ec8eaadf1bc@virtuozzo.com?part=9


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Devel] [PATCH hci-8.1 10/14] ms/objtool/klp: Fix module name normalization for paths with dots
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 10/14] ms/objtool/klp: Fix module name normalization for paths with dots Konstantin Khorenko
@ 2026-12-01  0:40   ` no-reply
  0 siblings, 0 replies; 30+ messages in thread
From: no-reply @ 2026-12-01  0:40 UTC (permalink / raw)
  To: Konstantin Khorenko, Pavel Tikhomirov; +Cc: devel

> From: Josh Poimboeuf <jpoimboe@kernel.org>
> 
> When .modinfo has no "name=" tag, __find_modname() falls back to
> converting the object's build-tree path to a runtime module name by
> stripping directory components, converting '-' to '_' and truncating the
> file extension.
> 
> It does all that in a single pass over the entire path, so the first dot
> anywhere in the path ends the name.  For an object built in a directory
> whose name contains a dot, e.g. "drivers/foo-1.0/bar.o", the result is a
> bogus module name.
> 
> Strip the directory components up front so only the basename is scanned
> for the extension separator.
> 
> Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffing object files")
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> Cc: live-patching@vger.kernel.org
> Link: https://patch.msgid.link/9017b4609553bed16674e8f924d34691cbc2b2c1.1785727106.git.jpoimboe@kernel.org
> (cherry picked from commit 165affd6f095323d953b0ed5823ec4d0db3b7d0d)
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-157133
> Feature: klp-build support
> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261126-khorenko-vstor-157133-klp-and-kvm-fixes-v1-0-0ec8eaadf1bc@virtuozzo.com?part=10


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Devel] [PATCH hci-8.1 11/14] ms/objtool/klp: Normalize Module.symvers paths to module names
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 11/14] ms/objtool/klp: Normalize Module.symvers paths to module names Konstantin Khorenko
@ 2026-12-01  0:40   ` no-reply
  0 siblings, 0 replies; 30+ messages in thread
From: no-reply @ 2026-12-01  0:40 UTC (permalink / raw)
  To: Konstantin Khorenko, Pavel Tikhomirov; +Cc: devel

> From: Joe Lawrence <joe.lawrence@redhat.com>
> 
> Module.symvers contains build-tree object paths as module identifiers
> (e.g., "arch/x86/kvm/kvm") rather than runtime module names ("kvm").
> Objtool's clone_reloc_klp() uses this field directly for exported
> symbols, while unexported symbols correctly go through __find_modname().
> 
> This means that exported symbol relocations may land in a .klp.rela
> section named with the build path rather than the module name.  That is
> a crash waiting to happen: the kernel's livepatch loader silently skips
> this relocation because it doesn't match the expected klp_object name.
> The unresolved relocation sits in the newly activated code, crashing
> when executed.
> 
> Normalize export->mod at Module.symvers read time using the same logic
> [ ... ]
> (cherry picked from commit 8668bf91e0508abeb8e98b4edd89032be02228a1)
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-157133
> Feature: klp-build support
> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261126-khorenko-vstor-157133-klp-and-kvm-fixes-v1-0-0ec8eaadf1bc@virtuozzo.com?part=11


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Devel] [PATCH hci-8.1 12/14] ms/objtool/klp: Fix cross-module klp relocation section naming
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 12/14] ms/objtool/klp: Fix cross-module klp relocation section naming Konstantin Khorenko
@ 2026-12-01  0:41   ` no-reply
  0 siblings, 0 replies; 30+ messages in thread
From: no-reply @ 2026-12-01  0:41 UTC (permalink / raw)
  To: Konstantin Khorenko, Pavel Tikhomirov; +Cc: devel

> From: Josh Poimboeuf <jpoimboe@kernel.org>
> 
> A klp relocation section is .klp.rela.<objname>.<secname>, where objname
> is the object being patched.
> 
> klp-build wrongly derives objname from where the referenced symbol
> lives, not where it's referenced.  For a cross-module reference like
> patched can_isotp code calling can.ko's can_rx_unregister(), that gives
> .klp.rela.can..text rather than .klp.rela.can_isotp..text.  Unless the
> patch happens to patch can.ko as well, the relocation never gets applied
> and the call goes off into the weeds.
> 
> Name the intermediate section __klp_relocs.<objname> so post-link can
> read the patched object's name from there.
> 
> Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffing object files")
> Reported-by: Joe Lawrence <joe.lawrence@redhat.com>
> Link: https://lore.kernel.org/20260720145658.1103243-2-joe.lawrence@redhat.com
> Acked-by: Song Liu <song@kernel.org>
> Acked-by: Joe Lawrence <joe.lawrence@redhat.com>
> Link: https://patch.msgid.link/ee93a08f3e55e76ffa67d04e283917ddaa893f09.1786138493.git.jpoimboe@kernel.org
> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
> (cherry picked from commit 07f14d6af9d7791fdc2b44a3dd0693e42c71d2b8)
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-157133
> Feature: klp-build support
> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261126-khorenko-vstor-157133-klp-and-kvm-fixes-v1-0-0ec8eaadf1bc@virtuozzo.com?part=12


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Devel] [PATCH hci-8.1 13/14] ms/objtool/klp: Fix detection of corrupt static branch/call entries
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 13/14] ms/objtool/klp: Fix detection of corrupt static branch/call entries Konstantin Khorenko
@ 2026-12-01  0:43   ` no-reply
  0 siblings, 0 replies; 30+ messages in thread
From: no-reply @ 2026-12-01  0:43 UTC (permalink / raw)
  To: Konstantin Khorenko, Pavel Tikhomirov; +Cc: devel

> From: Josh Poimboeuf <jpoimboe@kernel.org>
> 
> Patching a function which references a static key living in a kernel
> module is unsupported due to ordering issues inherent to late module
> patching:
> 
>   1) Load a livepatch module which has a __jump_table entry which needs
>      a klp reloc to reference static key K which lives in module M.
> 
>   2) The __jump_table klp reloc does *not* get resolved because module M
>      is not yet loaded.
> 
>   3) jump_label_add_module() corrupts memory (or causes a panic) when
>      dereferencing the uninitialized pointer to key K.
> 
> [ ... ]
> (cherry picked from commit f9fb44b0ecefc1f218db56661ed66d4e8d67317d)
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-157133
> Feature: klp-build support
> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261126-khorenko-vstor-157133-klp-and-kvm-fixes-v1-0-0ec8eaadf1bc@virtuozzo.com?part=13


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Devel] [PATCH hci-8.1 14/14] ms/objtool/klp: Don't match local symbols against exports
  2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 14/14] ms/objtool/klp: Don't match local symbols against exports Konstantin Khorenko
@ 2026-12-01  0:43   ` no-reply
  0 siblings, 0 replies; 30+ messages in thread
From: no-reply @ 2026-12-01  0:43 UTC (permalink / raw)
  To: Konstantin Khorenko, Pavel Tikhomirov; +Cc: devel

> From: Josh Poimboeuf <jpoimboe@kernel.org>
> 
> While cloning a reloc, klp diff calls find_export() to determine whether
> the referenced symbol is exported.  That decides whether the reference
> needs a klp reloc, which object the klp symbol belongs to, and whether
> the symbol's data needs to be copied into the patch module.
> 
> But find_export() matches purely on symbol name, so a static function or
> variable which happens to share its name with an export is mistaken for
> a reference to that export:
> 
>   - klp_reloc_needed() creates a klp reloc pointing at the exporting
>     module's symbol rather than the local one.  For a vmlinux export it
>     skips the klp reloc altogether, leaving a normal reloc which the
>     module loader resolves to the vmlinux symbol.
> [ ... ]
> (cherry picked from commit 86a697572c6271083694025eefa8de518eeef623)
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-157133
> Feature: klp-build support
> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261126-khorenko-vstor-157133-klp-and-kvm-fixes-v1-0-0ec8eaadf1bc@virtuozzo.com?part=14


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2026-12-01  0:44 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26 14:30 [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel Konstantin Khorenko
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 01/14] ms/KVM: x86/mmu: Conditionally resched when retrying gPTE walk on A/D update failure Konstantin Khorenko
2026-12-01  0:34   ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 02/14] ms/KVM: x86: Conditionally resched when restarting REP string emulation Konstantin Khorenko
2026-12-01  0:34   ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 03/14] ms/KVM: nVMX: Process each host MSR entry at most once when unwinding failed VM-Entry Konstantin Khorenko
2026-12-01  0:35   ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 04/14] ms/KVM: x86/mmu: Cap number of parent PTEs per SP at 1000 (the arbitrary rmap limit) Konstantin Khorenko
2026-12-01  0:36   ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 05/14] ms/KVM: x86: Unconditionally reset MMU context when emulating INIT Konstantin Khorenko
2026-12-01  0:37   ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 06/14] ms/KVM: SVM: Triple fault L1 on unintercepted EFER.SVME clear by L2 Konstantin Khorenko
2026-12-01  0:38   ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 07/14] ms/KVM: selftests: Add a test for L2 clearing EFER.SVME without intercept Konstantin Khorenko
2026-12-01  0:38   ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 08/14] ms/objtool: Fix data alignment in elf_add_data() Konstantin Khorenko
2026-12-01  0:39   ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 09/14] ms/objtool/klp: fix data alignment in __clone_symbol() Konstantin Khorenko
2026-12-01  0:39   ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 10/14] ms/objtool/klp: Fix module name normalization for paths with dots Konstantin Khorenko
2026-12-01  0:40   ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 11/14] ms/objtool/klp: Normalize Module.symvers paths to module names Konstantin Khorenko
2026-12-01  0:40   ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 12/14] ms/objtool/klp: Fix cross-module klp relocation section naming Konstantin Khorenko
2026-12-01  0:41   ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 13/14] ms/objtool/klp: Fix detection of corrupt static branch/call entries Konstantin Khorenko
2026-12-01  0:43   ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 14/14] ms/objtool/klp: Don't match local symbols against exports Konstantin Khorenko
2026-12-01  0:43   ` no-reply
2026-11-26 14:46 ` [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel Konstantin Khorenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.