From patchwork Tue Dec 10 07:45:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 3314721 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 66733C0D4A for ; Tue, 10 Dec 2013 07:46:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4B5212018C for ; Tue, 10 Dec 2013 07:46:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B809120184 for ; Tue, 10 Dec 2013 07:46:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751905Ab3LJHqF (ORCPT ); Tue, 10 Dec 2013 02:46:05 -0500 Received: from mout.web.de ([212.227.15.4]:57522 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751085Ab3LJHqD (ORCPT ); Tue, 10 Dec 2013 02:46:03 -0500 Received: from mchn199C.mchp.siemens.de ([95.157.58.223]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0MPHGG-1VuhrN0Jyy-004V7x for ; Tue, 10 Dec 2013 08:46:01 +0100 Message-ID: <52A6C6B4.1020307@web.de> Date: Tue, 10 Dec 2013 08:45:56 +0100 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Paolo Bonzini CC: Gleb Natapov , kvm Subject: Re: [PATCH] KVM: nVMX: Add support for activity state HLT References: <529EE0BE.4050501@siemens.com> <52A04CC8.3090007@redhat.com> <52A1C7C5.10803@siemens.com> In-Reply-To: <52A1C7C5.10803@siemens.com> X-Enigmail-Version: 1.6 X-Provags-ID: V03:K0:NhlQamjO4Vei5rl00MWDlZdZ2qwl0+7pESF0xuwB9hwd0iKhd0U dHYaeW1jXH2YCByF66wv1+BZLJDWYjxeB8v7G/Mb6NiQ+cVTI0STyyq3CaMdlpt3EFeN7rZ +77qd2H7gOf1lfHsUxjFAC/+hJl7sYa0rTmQ2tNGhbQLakPDH3ofgB4lEVW6HLwUClfOEnj CSKDQZO5zjZiY5mxOEuyA== Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_TVD_MIME_EPI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 2013-12-06 13:49, Jan Kiszka wrote: > On 2013-12-05 10:52, Paolo Bonzini wrote: >> Il 04/12/2013 08:58, Jan Kiszka ha scritto: >>> We can easily emulate the HLT activity state for L1: If it decides that >>> L2 shall be halted on entry, just invoke the normal emulation of halt >>> after switching to L2. We do not depend on specific host features to >>> provide this, so we can expose the capability unconditionally. >>> >>> Signed-off-by: Jan Kiszka >>> --- >>> >>> Jailhouse would like to use this. Experimental code works fine so far, >>> both on patched KVM and real HW. >> >> Nice. :) >> >> Do you have a testcase for kvm-unit-tests? > > Not yet. Maybe I will find a little time these days. Test are still ongoing, but it seems there are problems remaining with halting in L2 in general, i.e. with unintercepted hlt. I'm currently applying this to get beyond some hangups, but I'm still experiencing some delayed IRQ delivery to L2: Jan diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 31eb577..fad04ce 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -4684,6 +4684,7 @@ static int vmx_interrupt_allowed(struct kvm_vcpu *vcpu) vmcs12->vm_exit_reason = EXIT_REASON_EXTERNAL_INTERRUPT; vmcs12->vm_exit_intr_info = 0; + kvm_make_request(KVM_REQ_UNHALT, vcpu); /* * fall through to normal code, but now in L1, not L2 */ @@ -8057,8 +8058,6 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch) enter_guest_mode(vcpu); - vmx->nested.nested_run_pending = 1; - vmx->nested.vmcs01_tsc_offset = vmcs_read64(TSC_OFFSET); cpu = get_cpu(); @@ -8077,6 +8076,8 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch) if (vmcs12->guest_activity_state == GUEST_ACTIVITY_HLT) return kvm_emulate_halt(vcpu); + vmx->nested.nested_run_pending = 1; + /* * Note no nested_vmx_succeed or nested_vmx_fail here. At this point * we are no longer running L1, and VMLAUNCH/VMRESUME has not yet