lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Wed, 25 May 2022 05:25:38 +0000
From:   Mingwei Zhang <mizhang@...gle.com>
To:     linux-kernel@...r.kernel.org
Cc:     Jim Mattson <jmattson@...gle.com>,
        Mingwei Zhang <mizhang@...gle.com>
Subject: [PATCH] selftests: KVM/x86: Add APIC state into kvm_x86_state

Add APIC state into kvm_x86_state and properly save/restore it in
vcpu_{save,load}_state().

Doing so fix a bug that was triggered internally in Google. The selftest
(WIP) creates an L1 which then creates an L2 and runs L2 in vcpu0. Before
L2 finish, it exits to L0, save the state, stops the VM, restarts it and
add the vcpu back and finally load the state back. The test uses another
vcpu to shoot a posted interrupt. The result demonstrates that the L2,
after this vm save/restore, was not able to receive posted interrupt.

Our debugging shows that it is the APIC state was software disabled after
vcpu_load_state(). Adding the APIC state into the kvm_x86_state and loading
it in vcpu_load_state() fixes the issue.

Cc: Jim Mattson <jmattson@...gle.com>

Signed-off-by: Mingwei Zhang <mizhang@...gle.com>
---
 tools/testing/selftests/kvm/include/x86_64/processor.h | 1 +
 tools/testing/selftests/kvm/lib/x86_64/processor.c     | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h
index d0d51adec76eb..e4683429bd8b8 100644
--- a/tools/testing/selftests/kvm/include/x86_64/processor.h
+++ b/tools/testing/selftests/kvm/include/x86_64/processor.h
@@ -123,6 +123,7 @@ struct kvm_x86_state {
 		struct kvm_nested_state nested;
 		char nested_[16384];
 	};
+	struct kvm_lapic_state apic;
 	struct kvm_msrs msrs;
 };
 
diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/testing/selftests/kvm/lib/x86_64/processor.c
index 33ea5e9955d9b..113f4ce752579 100644
--- a/tools/testing/selftests/kvm/lib/x86_64/processor.c
+++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c
@@ -1173,6 +1173,10 @@ struct kvm_x86_state *vcpu_save_state(struct kvm_vm *vm, uint32_t vcpuid)
 	TEST_ASSERT(r == 0, "Unexpected result from KVM_GET_DEBUGREGS, r: %i",
 		    r);
 
+	r = ioctl(vcpu->fd, KVM_GET_LAPIC, &state->apic);
+	TEST_ASSERT(r == 0, "Unexpected result from KVM_GET_LAPIC, r: %i",
+		    r);
+
 	free(list);
 	return state;
 }
@@ -1222,6 +1226,10 @@ void vcpu_load_state(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_x86_state *s
 		TEST_ASSERT(r == 0, "Unexpected result from KVM_SET_NESTED_STATE, r: %i",
 			    r);
 	}
+
+	r = ioctl(vcpu->fd, KVM_SET_LAPIC, &state->apic);
+	TEST_ASSERT(r == 0,
+		"Unexpected result from KVM_SET_LAPIC, r: %i", r);
 }
 
 void kvm_x86_state_cleanup(struct kvm_x86_state *state)

base-commit: f3f19f939c11925dadd3f4776f99f8c278a7017b
-- 
2.36.1.124.g0e6072fb45-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ