Received: by 10.223.176.5 with SMTP id f5csp3128890wra; Thu, 1 Feb 2018 11:12:45 -0800 (PST) X-Google-Smtp-Source: AH8x226HQBdtcgY6XIxnsNarwk0ejCP5/HIzqPSJSXST4roYR2CdKjeomfxIdSGP6uS+eTKq0TnF X-Received: by 10.99.155.9 with SMTP id r9mr23406150pgd.333.1517512365536; Thu, 01 Feb 2018 11:12:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517512365; cv=none; d=google.com; s=arc-20160816; b=opPl0tLUFmG6RMnx4ag2gWzHq4vLnn5sxztYjUh7oRKcLHRz7z3ehB5kY8Rdsg/mae kp1K/IHNjguCFWD9MLBZesJR2MUrkqn99013zr3KiCBGLUmj0qwvIsGsWAc41T3mptha nbPe+RpJJDLd0bJ0smr/QVgfNRlsVirOiUn6RHu/h+/8CG/QbMKKT3OoCw2oxRyvM5yR HG4BYPbY+6UGCZIMTo5IuiEhr2DW6eWWc58sUrs5NSZ86Kwy5W9sQgQeNPKfdXGWG+Pg ag/bzstNsX1RftxehXBro7kUCUO8gBKYW7BkZrYRy8flZoUpMzgbQeI4YLpKV4/jLdg2 QIDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=rXid/O/MI8KMqR12r4KnxoiLqQ8EnEg512Q8MHLg5SQ=; b=SwAUQAvXP4dk8tWWrOIQrKbegKr2P55bw8vGTgQSdA0FglY+int3Ee4z4c//894je1 dfYlDpj+fASo+dpkutpEEGODi68d5WURJqCO1uowHfwZHcC+GXlEayfpQZ0Y4q3YdEij +P0Z94h71dIDtE48V6H3HGfxZrEIxeZbxEtWrDMIGmUFDeoDQZ1gKXCxh+vAlUptbv14 K9EG5Y9xdgq8hnjhl2pETd97eLaSWKnAApwtZHhBbp9fciPsnX0jKxQWWvzUp6Zy/Py0 Fe+zL+lGYytvgwKOxhHAqkWPO+5LdomrQPQddgxyyNGr6ddLihJUoucYVyMQRDni6fSQ YVVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f12si140606pgn.455.2018.02.01.11.12.30; Thu, 01 Feb 2018 11:12:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753446AbeBATLC (ORCPT + 99 others); Thu, 1 Feb 2018 14:11:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43436 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752973AbeBATK4 (ORCPT ); Thu, 1 Feb 2018 14:10:56 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E21D67EBD3; Thu, 1 Feb 2018 19:10:55 +0000 (UTC) Received: from flask (unknown [10.43.2.80]) by smtp.corp.redhat.com (Postfix) with SMTP id 9E5BE5D6B7; Thu, 1 Feb 2018 19:10:53 +0000 (UTC) Received: by flask (sSMTP sendmail emulation); Thu, 01 Feb 2018 20:10:41 +0100 Date: Thu, 1 Feb 2018 20:10:41 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Wanpeng Li , stable@vger.kernel.org Subject: Re: [PATCH] KVM: x86: fix backward migration with async_PF Message-ID: <20180201191040.GD26932@flask> References: <20180201175022.25011-1-rkrcmar@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 01 Feb 2018 19:10:55 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2018-02-01 13:09-0500, Paolo Bonzini: > On 01/02/2018 12:50, Radim Krčmář wrote: > > Guests on new hypersiors might set KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT > > bit when enabling async_PF, but this bit is reserved on old hypervisors, > > which results in a failure upon migration. > > > > Guests at least expect that KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT might not > > be present when booting, so we allow userspace to handle migration > > compatibility by adding a KVM CPUID flag that determines the presence of > > KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT. > > > > Fixes: 52a5c155cf79 ("KVM: async_pf: Let guest support delivery of async_pf from guest mode") > > Cc: > > Signed-off-by: Radim Krčmář > > This has to be documented in Documentation/virtual/kvm/cpuid.txt. Will add, also to the MSR if we agree on v2. > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > > index 4c3103f449a3..c16740a06f0c 100644 > > --- a/arch/x86/kvm/x86.c > > +++ b/arch/x86/kvm/x86.c > > @@ -2139,8 +2139,10 @@ static int kvm_pv_enable_async_pf(struct kvm_vcpu *vcpu, u64 data) > > { > > gpa_t gpa = data & ~0x3f; > > > > - /* Bits 3:5 are reserved, Should be zero */ > > - if (data & 0x38) > > + /* Bits 3:5 are reserved, Should be zero. */ > > + if (data & 0x38 || > > + (data & KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT && > > + !guest_kvm_cpuid_has(vcpu, KVM_FEATURE_ASYNC_PF_VMEXIT))) > > return 1; > > > > vcpu->arch.apf.msr_val = data; > > > > This check will break migration if the source guest and host both have > the recent kernels which support KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT, so > I am not sure about it. Otherwise, the patch is okay! Good point, breaking forward migration is worse than doing nothing. A compromise solution would be to drop the feature check from the hypervisor. Newer guests would work everywhere and there would be no change to old systems, so v4.13-v4.15 guests could at least upgrade. Slightly better than doing nothing, IMO, thanks.