[LTP] [PATCH 5/9] kvm_find_free_descriptor(): Skip descriptor 0

Martin Doucha mdoucha@suse.cz
Tue Apr 30 14:22:01 CEST 2024


The GDT/LDT descriptor 0 should always be empty. Start search for free
descriptor table entry at index 1.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 testcases/kernel/kvm/lib_x86.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/kvm/lib_x86.c b/testcases/kernel/kvm/lib_x86.c
index 3e6656f11..1c0e629c3 100644
--- a/testcases/kernel/kvm/lib_x86.c
+++ b/testcases/kernel/kvm/lib_x86.c
@@ -174,7 +174,7 @@ int kvm_find_free_descriptor(const struct segment_descriptor *table,
 	const struct segment_descriptor *ptr;
 	size_t i;
 
-	for (i = 0, ptr = table; i < size; i++, ptr++) {
+	for (i = 1, ptr = table + 1; i < size; i++, ptr++) {
 		if (!(ptr->flags_lo & SEGFLAG_PRESENT))
 			return i;
 
-- 
2.44.0



More information about the ltp mailing list