From: Qian Cai <cai@lca.pw>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
torvalds@linux-foundation.org
Subject: Re: [PATCH 19/30] KVM: nSVM: extract svm_set_gif
Date: Fri, 5 Jun 2020 16:33:56 -0400 [thread overview]
Message-ID: <20200605203356.GC5393@lca.pw> (raw)
In-Reply-To: <20200529153934.11694-20-pbonzini@redhat.com>
On Fri, May 29, 2020 at 11:39:23AM -0400, Paolo Bonzini wrote:
> Extract the code that is needed to implement CLGI and STGI,
> so that we can run it from VMRUN and vmexit (and in the future,
> KVM_SET_NESTED_STATE). Skip the request for KVM_REQ_EVENT unless needed,
> subsuming the evaluate_pending_interrupts optimization that is found
> in enter_svm_guest_mode.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> arch/x86/kvm/irq.c | 1 +
> arch/x86/kvm/svm/nested.c | 22 ++---------------
> arch/x86/kvm/svm/svm.c | 51 ++++++++++++++++++++++++++-------------
> arch/x86/kvm/svm/svm.h | 1 +
> 4 files changed, 38 insertions(+), 37 deletions(-)
[]
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -1981,6 +1981,38 @@ static int vmrun_interception(struct vcpu_svm *svm)
> return nested_svm_vmrun(svm);
> }
>
> +void svm_set_gif(struct vcpu_svm *svm, bool value)
> +{
> + if (value) {
> + /*
> + * If VGIF is enabled, the STGI intercept is only added to
> + * detect the opening of the SMI/NMI window; remove it now.
> + * Likewise, clear the VINTR intercept, we will set it
> + * again while processing KVM_REQ_EVENT if needed.
> + */
> + if (vgif_enabled(svm))
> + clr_intercept(svm, INTERCEPT_STGI);
> + if (is_intercept(svm, SVM_EXIT_VINTR))
A simple qemu-kvm will trigger the warning. (Looks like the patch had
already been pulled into the mainline quickly.)
# qemu-kvm -name ubuntu-18.04-server-cloudimg -cpu host -smp 2 -m 2G \
-hda ubuntu-18.04-server-cloudimg.qcow2 \
-cdrom ubuntu-18.04-server-cloudimg.iso -nic user,hostfwd=tcp::2222-:22 \
-nographic -device vfio-pci,host=0000:04:0a.0
[ 1362.284812][ T2195] ================================================================================
[ 1362.294789][ T2195] UBSAN: shift-out-of-bounds in arch/x86/kvm/svm/svm.h:316:47
[ 1362.302209][ T2195] shift exponent 100 is too large for 64-bit type 'long long unsigned int'
[ 1362.310715][ T2195] CPU: 51 PID: 2195 Comm: qemu-kvm Not tainted 5.7.0-next-20200605 #6
[ 1362.319244][ T2195] Hardware name: HPE ProLiant DL385 Gen10/ProLiant DL385 Gen10, BIOS A40 03/09/2018
[ 1362.328530][ T2195] Call Trace:
[ 1362.331710][ T2195] dump_stack+0xa7/0xea
[ 1362.335758][ T2195] ubsan_epilogue+0x9/0x45
[ 1362.340070][ T2195] __ubsan_handle_shift_out_of_bounds.cold.13+0x14/0x98
[ 1362.347386][ T2195] ? __kasan_check_write+0x14/0x20
[ 1362.352405][ T2195] ? set_msr_interception+0x1b8/0x300 [kvm_amd]
[ 1362.358558][ T2195] svm_set_gif.cold.64+0x16/0xd1 [kvm_amd]
[ 1362.364276][ T2195] svm_set_efer+0xbc/0xc0 [kvm_amd]
svm_set_efer at arch/x86/kvm/svm/svm.c:281
[ 1362.369866][ T2195] init_vmcb+0x107c/0x1b80 [kvm_amd]
[ 1362.375056][ T2195] svm_create_vcpu+0x237/0x360 [kvm_amd]
[ 1362.380677][ T2195] kvm_arch_vcpu_create+0x490/0x5f0 [kvm]
[ 1362.386381][ T2195] kvm_vm_ioctl+0x10c5/0x17f0 [kvm]
[ 1362.391561][ T2195] ? kvm_unregister_device_ops+0xd0/0xd0 [kvm]
[ 1362.398118][ T2195] ? validate_chain+0xab/0x1b30
[ 1362.402864][ T2195] ? __kasan_check_read+0x11/0x20
[ 1362.407784][ T2195] ? check_chain_key+0x1df/0x2e0
[ 1362.412615][ T2195] ? __lock_acquire+0x74c/0xc10
[ 1362.417363][ T2195] ? match_held_lock+0x20/0x2f0
[ 1362.422593][ T2195] ? check_chain_key+0x1df/0x2e0
[ 1362.427425][ T2195] ? find_held_lock+0xca/0xf0
[ 1362.431997][ T2195] ? __fget_files+0x172/0x270
[ 1362.436565][ T2195] ? lock_downgrade+0x3e0/0x3e0
[ 1362.441310][ T2195] ? rcu_read_lock_held+0xac/0xc0
[ 1362.446744][ T2195] ? rcu_read_lock_sched_held+0xe0/0xe0
[ 1362.452190][ T2195] ? __fget_files+0x18c/0x270
[ 1362.456759][ T2195] ? __fget_light+0xf2/0x110
[ 1362.461242][ T2195] ksys_ioctl+0x26e/0xc60
[ 1362.465464][ T2195] ? generic_block_fiemap+0x70/0x70
[ 1362.471024][ T2195] ? find_held_lock+0xca/0xf0
[ 1362.475597][ T2195] ? __task_pid_nr_ns+0x145/0x290
[ 1362.480517][ T2195] ? check_flags.part.26+0x86/0x230
[ 1362.485613][ T2195] ? __kasan_check_read+0x11/0x20
[ 1362.490535][ T2195] ? entry_SYSCALL_64_after_hwframe+0x44/0xa9
[ 1362.497009][ T2195] ? do_syscall_64+0x23/0x340
[ 1362.501581][ T2195] ? rcu_read_lock_sched_held+0xac/0xe0
[ 1362.507023][ T2195] ? mark_held_locks+0x34/0xb0
[ 1362.511679][ T2195] ? do_syscall_64+0x29/0x340
[ 1362.516254][ T2195] __x64_sys_ioctl+0x43/0x4c
[ 1362.521177][ T2195] do_syscall_64+0x64/0x340
[ 1362.525573][ T2195] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[ 1362.531366][ T2195] RIP: 0033:0x7f8c609cb87b
[ 1362.535676][ T2195] Code: Bad RIP value.
[ 1362.539633][ T2195] RSP: 002b:00007f8c517fb6c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[ 1362.548399][ T2195] RAX: ffffffffffffffda RBX: 0000564c201f9110 RCX: 00007f8c609cb87b
[ 1362.556287][ T2195] RDX: 0000000000000000 RSI: 000000000000ae41 RDI: 000000000000000a
[ 1362.564178][ T2195] RBP: 0000564c201f9110 R08: 0000564c1e47cd50 R09: 0000564c201f9110
[ 1362.572455][ T2195] R10: 0000564c1ebfd680 R11: 0000000000000246 R12: 0000564c201954d0
[ 1362.580344][ T2195] R13: 00007ffe3a592d6f R14: 00007ffe3a592e00 R15: 00007f8c517fb840
[ 1362.588287][ T2195] ================================================================================
> + svm_clear_vintr(svm);
> +
> + enable_gif(svm);
> + if (svm->vcpu.arch.smi_pending ||
> + svm->vcpu.arch.nmi_pending ||
> + kvm_cpu_has_injectable_intr(&svm->vcpu))
> + kvm_make_request(KVM_REQ_EVENT, &svm->vcpu);
> + } else {
> + disable_gif(svm);
> +
> + /*
> + * After a CLGI no interrupts should come. But if vGIF is
> + * in use, we still rely on the VINTR intercept (rather than
> + * STGI) to detect an open interrupt window.
> + */
> + if (!vgif_enabled(svm))
> + svm_clear_vintr(svm);
> + }
> +}
> +
next prev parent reply other threads:[~2020-06-05 20:34 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-29 15:39 [PATCH v3 00/28] KVM: nSVM: event fixes and migration support Paolo Bonzini
2020-05-29 15:39 ` [PATCH 01/30] KVM: x86: track manually whether an event has been injected Paolo Bonzini
2020-05-29 15:39 ` [PATCH 02/30] KVM: x86: enable event window in inject_pending_event Paolo Bonzini
2020-05-29 15:39 ` [PATCH 03/30] KVM: nSVM: inject exceptions via svm_check_nested_events Paolo Bonzini
2020-05-29 15:39 ` [PATCH 04/30] KVM: nSVM: remove exit_required Paolo Bonzini
2020-05-29 15:39 ` [PATCH 05/30] KVM: nSVM: correctly inject INIT vmexits Paolo Bonzini
2020-05-29 15:39 ` [PATCH 06/30] KVM: SVM: always update CR3 in VMCB Paolo Bonzini
2020-05-29 17:41 ` Krish Sadhukhan
2020-05-29 17:56 ` Sean Christopherson
2020-05-29 15:39 ` [PATCH 07/30] KVM: nVMX: always update CR3 in VMCS Paolo Bonzini
2020-05-29 15:39 ` [PATCH 08/30] KVM: nSVM: move map argument out of enter_svm_guest_mode Paolo Bonzini
2020-05-29 18:10 ` Krish Sadhukhan
2020-05-29 19:04 ` Paolo Bonzini
2020-05-29 20:02 ` Krish Sadhukhan
2020-05-29 15:39 ` [PATCH 09/30] KVM: nSVM: extract load_nested_vmcb_control Paolo Bonzini
2020-05-29 15:39 ` [PATCH 10/30] KVM: nSVM: extract preparation of VMCB for nested run Paolo Bonzini
2020-05-29 18:27 ` Krish Sadhukhan
2020-05-29 19:02 ` Paolo Bonzini
2020-05-29 15:39 ` [PATCH 11/30] KVM: nSVM: move MMU setup to nested_prepare_vmcb_control Paolo Bonzini
2020-05-29 15:39 ` [PATCH 12/30] KVM: nSVM: clean up tsc_offset update Paolo Bonzini
2020-05-29 15:39 ` [PATCH 13/30] KVM: nSVM: pass vmcb_control_area to copy_vmcb_control_area Paolo Bonzini
2020-05-29 15:39 ` [PATCH 14/30] KVM: nSVM: remove trailing padding for struct vmcb_control_area Paolo Bonzini
2020-05-29 15:39 ` [PATCH 15/30] KVM: nSVM: save all control fields in svm->nested Paolo Bonzini
2020-05-29 15:39 ` [PATCH 16/30] KVM: nSVM: restore clobbered INT_CTL fields after clearing VINTR Paolo Bonzini
2020-05-29 15:39 ` [PATCH 17/30] KVM: nSVM: synchronize VMCB controls updated by the processor on every vmexit Paolo Bonzini
2020-05-30 2:06 ` Krish Sadhukhan
2020-05-30 5:10 ` Paolo Bonzini
2020-05-29 15:39 ` [PATCH 18/30] KVM: nSVM: remove unnecessary if Paolo Bonzini
2020-05-29 15:39 ` [PATCH 19/30] KVM: nSVM: extract svm_set_gif Paolo Bonzini
2020-06-05 20:33 ` Qian Cai [this message]
2020-06-08 11:11 ` Paolo Bonzini
2020-05-29 15:39 ` [PATCH 20/30] KVM: SVM: preserve VGIF across VMCB switch Paolo Bonzini
2020-05-31 23:11 ` Krish Sadhukhan
2020-06-01 7:30 ` Paolo Bonzini
2020-05-29 15:39 ` [PATCH 21/30] KVM: nSVM: synthesize correct EXITINTINFO on vmexit Paolo Bonzini
2020-05-29 15:39 ` [PATCH 22/30] KVM: nSVM: remove HF_VINTR_MASK Paolo Bonzini
2020-05-29 15:39 ` [PATCH 23/30] KVM: nSVM: remove HF_HIF_MASK Paolo Bonzini
2020-05-29 15:39 ` [PATCH 24/30] KVM: nSVM: split nested_vmcb_check_controls Paolo Bonzini
2020-05-29 15:39 ` [PATCH 25/30] KVM: nSVM: leave guest mode when clearing EFER.SVME Paolo Bonzini
2020-06-01 2:26 ` Krish Sadhukhan
2020-06-01 7:28 ` Paolo Bonzini
2020-05-29 15:39 ` [PATCH 26/30] KVM: MMU: pass arbitrary CR0/CR4/EFER to kvm_init_shadow_mmu Paolo Bonzini
2020-05-29 15:39 ` [PATCH 27/30] selftests: kvm: introduce cpu_has_svm() check Paolo Bonzini
2020-05-29 15:39 ` [PATCH 28/30] selftests: kvm: add a SVM version of state-test Paolo Bonzini
2020-05-29 15:39 ` [PATCH 29/30] selftests: kvm: fix smm test on SVM Paolo Bonzini
2020-05-29 15:39 ` [PATCH 30/30] KVM: nSVM: implement KVM_GET_NESTED_STATE and KVM_SET_NESTED_STATE Paolo Bonzini
2020-06-02 0:11 ` Krish Sadhukhan
2020-06-04 14:47 ` Paolo Bonzini
2020-05-29 17:59 ` [PATCH v3 00/28] KVM: nSVM: event fixes and migration support Sean Christopherson
2020-05-29 19:07 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200605203356.GC5393@lca.pw \
--to=cai@lca.pw \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.